Mercurial > hg > Applications > virsh-wrapper
comparison ie-virsh.c @ 5:9ecd833b9570
filtering worked.
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 13 Nov 2012 07:59:17 +0900 |
parents | 349bbbd3fbd5 |
children | 25c14d1144a8 |
comparison
equal
deleted
inserted
replaced
4:349bbbd3fbd5 | 5:9ecd833b9570 |
---|---|
71 | 71 |
72 int | 72 int |
73 check_vmlist_name(VMLISTPTR list, char *arg) | 73 check_vmlist_name(VMLISTPTR list, char *arg) |
74 { | 74 { |
75 for(;list && list->name[0]; list=list->next) { | 75 for(;list && list->name[0]; list=list->next) { |
76 if (strcmp(list->name,arg)==0) return 1; | 76 if (strstr(list->name,arg)!=0) return 1; |
77 } | 77 } |
78 return 0; | 78 return 0; |
79 } | 79 } |
80 | 80 |
81 void | 81 void |
82 usage() | 82 usage() |
83 { | 83 { |
84 printf("Usage: COMMAND [list|start|stop|xmldump] [vm-name]\n"); | 84 printf("Usage: COMMAND [list|start|destroy|xmldump] [vm-name]\n"); |
85 } | 85 } |
86 | 86 |
87 /* main(int argc, char **argv) - main process loop */ | 87 /* main(int argc, char **argv) - main process loop */ |
88 | 88 |
89 int main(int argc, char **argv) | 89 int main(int argc, char **argv) |
121 setgid(0); | 121 setgid(0); |
122 setuid(0); | 122 setuid(0); |
123 | 123 |
124 VMLISTPTR vmlist = get_vmlist(pattern); | 124 VMLISTPTR vmlist = get_vmlist(pattern); |
125 | 125 |
126 if (argc==3) { | 126 if (argc>=3) { |
127 if (check_vmlist_name(vmlist, argv[2])!=0) { | 127 if (check_vmlist_name(vmlist, argv[2])==0) { |
128 fprintf(stderr, "bad vmname\n"); | 128 fprintf(stderr, "bad vmname\n"); |
129 print_vmlist(vmlist); | 129 print_vmlist(vmlist); |
130 exit(0); | 130 exit(0); |
131 } | 131 } |
132 } else if (argc<2) { | 132 } else if (argc<2) { |
133 print_vmlist(vmlist); | |
133 usage(); | 134 usage(); |
134 exit(0); | 135 exit(0); |
135 } | 136 } |
136 | 137 |
137 /* Check argv for proper arguments and run | 138 /* Check argv for proper arguments and run |
142 print_vmlist(vmlist); | 143 print_vmlist(vmlist); |
143 } else if ( strncmp(argv[1], "start", 5) == 0 ) { | 144 } else if ( strncmp(argv[1], "start", 5) == 0 ) { |
144 if (execl(command, command, start_command, argv[2], NULL) < 0) { | 145 if (execl(command, command, start_command, argv[2], NULL) < 0) { |
145 perror("Execl:"); | 146 perror("Execl:"); |
146 } | 147 } |
147 } else if ( strncmp(argv[1], "stop", 4) == 0 ) { | 148 } else if ( strncmp(argv[1], "destroy", 4) == 0 ) { |
148 if (execl(command, command, stop_command, argv[2], NULL) < 0) { | 149 if (execl(command, command, stop_command, argv[2], NULL) < 0) { |
149 perror("Execl:"); | 150 perror("Execl:"); |
150 } | 151 } |
151 } else if ( strncmp(argv[1], "dumpxml", 7) == 0 ) { | 152 } else if ( strncmp(argv[1], "dumpxml", 7) == 0 ) { |
152 if (execl(command, command, dumpxml_command, argv[2], NULL) < 0) { | 153 if (execl(command, command, dumpxml_command, argv[2], NULL) < 0) { |