dom0/qvm-block: change order of parameters (#514)
This commit is contained in:
		
							parent
							
								
									cebc24b670
								
							
						
					
					
						commit
						e22fc84715
					
				| @ -30,15 +30,16 @@ import os | ||||
| 
 | ||||
| def main(): | ||||
|     usage = "usage: %prog -l [options]\n"\ | ||||
|             "usage: %prog -a [options] <device> <vm-name>\n"\ | ||||
|             "usage: %prog -d [options] <device>\n"\ | ||||
|             "usage: %prog -a [options] <vm-name> <device-vm-name>:<device>\n"\ | ||||
|             "usage: %prog -A [options] <vm-name> <file-vm-name>:<file>\n"\ | ||||
|             "usage: %prog -d [options] <device-vm-name>:<device>\n"\ | ||||
|             "usage: %prog -d [options] <vm-name>\n"\ | ||||
|             "List/set VM PCI devices." | ||||
| 
 | ||||
|     parser = OptionParser (usage) | ||||
|     parser.add_option ("-l", "--list", action="store_true", dest="do_list", default=False) | ||||
|     parser.add_option ("-A", "--attach-file", action="store", dest="file_path", default=None, | ||||
|                         help="Attach specified file instead of physical device (syntax: qvm-block -A file backend-VM frontend-VM)") | ||||
|     parser.add_option ("-A", "--attach-file", action="store_true", dest="do_file_attach", default=False, | ||||
|                         help="Attach specified file instead of physical device") | ||||
|     parser.add_option ("-a", "--attach", action="store_true", dest="do_attach", default=False) | ||||
|     parser.add_option ("-d", "--detach", action="store_true", dest="do_detach", default=False) | ||||
|     parser.add_option ("-f", "--frontend", dest="frontend",  | ||||
| @ -68,19 +69,21 @@ def main(): | ||||
|     if options.do_attach: | ||||
|         if (len (args) < 2): | ||||
|             parser.error ("You must provide device and vm name!") | ||||
|         vm = qvm_collection.get_vm_by_name(args[1]) | ||||
|         vm = qvm_collection.get_vm_by_name(args[0]) | ||||
|         if vm is None: | ||||
|             parser.error ("Invalid VM name: %s" % args[1]) | ||||
|         if options.file_path: | ||||
|             parser.error ("Invalid VM name: %s" % args[0]) | ||||
|         # FIXME: here we assume that device is always in form "domain:dev", which can be changed in the future | ||||
|         if args[1].find(":") < 0: | ||||
|             parser.error ("Invalid device syntax" % args[1]) | ||||
|         if options.do_file_attach: | ||||
|             dev = {} | ||||
|             dev['vm'] = args[0] | ||||
|             dev['device'] = options.file_path | ||||
|             (dev['vm'], dev['device']) = args[1].split(":") | ||||
|             dev['mode'] = 'w' | ||||
|         else: | ||||
|             dev_list = block_list() | ||||
|             if not args[0] in dev_list.keys(): | ||||
|                 parser.error ("Invalid device name: %s" % args[0]) | ||||
|             dev = dev_list[args[0]] | ||||
|             if not args[1] in dev_list.keys(): | ||||
|                 parser.error ("Invalid device name: %s" % args[1]) | ||||
|             dev = dev_list[args[1]] | ||||
|         backend_vm = qvm_collection.get_vm_by_name(dev['vm']) | ||||
|         assert backend_vm is not None | ||||
|         kwargs = {} | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Marek Marczykowski
						Marek Marczykowski