changeset 9:ea51e779b381

error message
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 13 Nov 2012 16:35:34 +0900
parents b2e2eec87764
children 0740e88a783b
files ie-virsh.c newvm.py
diffstat 2 files changed, 14 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/ie-virsh.c	Tue Nov 13 16:15:15 2012 +0900
+++ b/ie-virsh.c	Tue Nov 13 16:35:34 2012 +0900
@@ -29,8 +29,11 @@
 #define start_command "start"
 #define stop_command "destroy"
 #define define_command "define"
+#define undefine_command "undefine"
 #define dumpxml_command "dumpxml"
 
+static char bad_name[] = "Bad vmname. Try students/e11/e115711/01 or teachers/kono/02\n";
+
 #define VMNAME_MAX (512)
 
 typedef struct vmlist {
@@ -96,7 +99,8 @@
 void 
 usage()
 {
-  printf("Usage: COMMAND [list|start|destroy|xmldump] [vm-name]\n");
+  printf("Usage: COMMAND [define|list|start|destroy|xmldump|undefine] [vm-name]\n");
+  printf("   vm-name should be students/e11/e115711/01 or teachers/kono/02\n");
 }
 
 /* main(int argc, char **argv) - main process loop */
@@ -140,11 +144,11 @@
  if (argc>=3) {
     if ( strncmp(argv[1], "define", 6) == 0 ) {
         if (regexec(pattern, argv[2], (size_t) 0, NULL, 0)) {
-           fprintf(stderr, "bad vmname for define\n");
+           fprintf(stderr, bad_name);
            exit(0);
         }
         if (check_name(argv[2])) {
-           fprintf(stderr, "bad vmname for define\n");
+           fprintf(stderr, bad_name);
            exit(0);
         }
         char exec[1024];
@@ -165,7 +169,7 @@
 	 strncpy(name_xml,argv[2],900);
 	 strncat(name_xml,".xml",1000);
     } else if (check_vmlist_name(vmlist, argv[2])==0) {
-        fprintf(stderr, "bad vmname\n");
+        fprintf(stderr, bad_name);
         print_vmlist(vmlist);
         exit(0);
     }
@@ -198,6 +202,11 @@
      if (execl(command, command, define_command, name_xml, NULL) < 0) {
        perror("Execl:");
      }
+ } else if ( strncmp(argv[1], "undefine", 8) == 0 ) {
+     chdir("/etc/libvirt/qemu");
+     if (execl(command, command, undefine_command, argv[2], NULL) < 0) {
+       perror("Execl:");
+     }
  } else {
     usage();
     exit(1);
--- a/newvm.py	Tue Nov 13 16:15:15 2012 +0900
+++ b/newvm.py	Tue Nov 13 16:35:34 2012 +0900
@@ -45,7 +45,7 @@
         ie_mkdir1('/var/log/libvirt/qemu/'+dir)
         ie_mkdir1('/var/run/libvirt/qemu/'+dir)
         ie_mkdir1('/var/lib/libvirt/qemu/'+dir)
-        os.chown('/media/fcs/'+dir,os.getlogin(),-1)
+        os.system("/bin/chown "+os.getlogin()+" /media/fcs/"+dir)
  
 parser = OptionParser();
 parser.add_option("-n", "--name", dest="name",