Mercurial > hg > Applications > virsh-wrapper
changeset 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 |
files | Makefile ie-virsh.c |
diffstat | 2 files changed, 7 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile Mon Nov 12 21:37:14 2012 +0900 +++ b/Makefile Tue Nov 13 07:59:17 2012 +0900 @@ -3,8 +3,8 @@ $(TARGET): $(TARGET).c $(CC) $(CFLAGS) $(TARGET).c -o $(TARGET) - chmod 2711 $(TARGET) sudo chown root $(TARGET) + sudo chmod 4711 $(TARGET) clean: rm $(TARGET)
--- a/ie-virsh.c Mon Nov 12 21:37:14 2012 +0900 +++ b/ie-virsh.c Tue Nov 13 07:59:17 2012 +0900 @@ -73,7 +73,7 @@ check_vmlist_name(VMLISTPTR list, char *arg) { for(;list && list->name[0]; list=list->next) { - if (strcmp(list->name,arg)==0) return 1; + if (strstr(list->name,arg)!=0) return 1; } return 0; } @@ -81,7 +81,7 @@ void usage() { - printf("Usage: COMMAND [list|start|stop|xmldump] [vm-name]\n"); + printf("Usage: COMMAND [list|start|destroy|xmldump] [vm-name]\n"); } /* main(int argc, char **argv) - main process loop */ @@ -123,13 +123,14 @@ VMLISTPTR vmlist = get_vmlist(pattern); - if (argc==3) { - if (check_vmlist_name(vmlist, argv[2])!=0) { + if (argc>=3) { + if (check_vmlist_name(vmlist, argv[2])==0) { fprintf(stderr, "bad vmname\n"); print_vmlist(vmlist); exit(0); } } else if (argc<2) { + print_vmlist(vmlist); usage(); exit(0); } @@ -144,7 +145,7 @@ if (execl(command, command, start_command, argv[2], NULL) < 0) { perror("Execl:"); } - } else if ( strncmp(argv[1], "stop", 4) == 0 ) { + } else if ( strncmp(argv[1], "destroy", 4) == 0 ) { if (execl(command, command, stop_command, argv[2], NULL) < 0) { perror("Execl:"); }