# HG changeset patch # User Shinji KONO # Date 1352792134 -32400 # Node ID ea51e779b38152874fdb5320def561ac5ca35826 # Parent b2e2eec87764c21286336131aa34b157a9daf802 error message diff -r b2e2eec87764 -r ea51e779b381 ie-virsh.c --- 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); diff -r b2e2eec87764 -r ea51e779b381 newvm.py --- 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",