Merge branch 'hvm' of 10.141.1.101:/var/lib/qubes/git/marmarek/core into hvm
This commit is contained in:
commit
48ee9ea5c5
@ -219,6 +219,9 @@ def block_list(vm = None, system_disks = False):
|
|||||||
device_desc = xs.read('', '/local/domain/%s/qubes-block-devices/%s/desc' % (xid, device))
|
device_desc = xs.read('', '/local/domain/%s/qubes-block-devices/%s/desc' % (xid, device))
|
||||||
device_mode = xs.read('', '/local/domain/%s/qubes-block-devices/%s/mode' % (xid, device))
|
device_mode = xs.read('', '/local/domain/%s/qubes-block-devices/%s/mode' % (xid, device))
|
||||||
|
|
||||||
|
if device_size is None or device_desc is None or device_mode is None:
|
||||||
|
print >> sys.stderr, "Missing field in %s device parameters" % device
|
||||||
|
continue
|
||||||
if not device_size.isdigit():
|
if not device_size.isdigit():
|
||||||
print >> sys.stderr, "Invalid %s device size in VM '%s'" % (device, vm_name)
|
print >> sys.stderr, "Invalid %s device size in VM '%s'" % (device, vm_name)
|
||||||
continue
|
continue
|
||||||
@ -303,7 +306,7 @@ def block_attach(vm, backend_vm, device, frontend=None, mode="w", auto_detach=Fa
|
|||||||
attached_vm = block_check_attached(backend_vm, device)
|
attached_vm = block_check_attached(backend_vm, device)
|
||||||
if attached_vm:
|
if attached_vm:
|
||||||
if auto_detach:
|
if auto_detach:
|
||||||
block_detach(None, attached_vm['devid'], vm_xid=attached_vm['vm_xid'])
|
block_detach(None, attached_vm['devid'], vm_xid=attached_vm['xid'])
|
||||||
else:
|
else:
|
||||||
raise QubesException("Device %s from %s already connected to VM %s as %s" % (device, backend_vm.name, attached_vm['vm'], attached_vm['frontend']))
|
raise QubesException("Device %s from %s already connected to VM %s as %s" % (device, backend_vm.name, attached_vm['vm'], attached_vm['frontend']))
|
||||||
|
|
||||||
|
@ -30,15 +30,16 @@ import os
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
usage = "usage: %prog -l [options]\n"\
|
usage = "usage: %prog -l [options]\n"\
|
||||||
"usage: %prog -a [options] <device> <vm-name>\n"\
|
"usage: %prog -a [options] <vm-name> <device-vm-name>:<device>\n"\
|
||||||
"usage: %prog -d [options] <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"\
|
"usage: %prog -d [options] <vm-name>\n"\
|
||||||
"List/set VM PCI devices."
|
"List/set VM PCI devices."
|
||||||
|
|
||||||
parser = OptionParser (usage)
|
parser = OptionParser (usage)
|
||||||
parser.add_option ("-l", "--list", action="store_true", dest="do_list", default=False)
|
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,
|
parser.add_option ("-A", "--attach-file", action="store_true", dest="do_file_attach", default=False,
|
||||||
help="Attach specified file instead of physical device (syntax: qvm-block -A file backend-VM frontend-VM)")
|
help="Attach specified file instead of physical device")
|
||||||
parser.add_option ("-a", "--attach", action="store_true", dest="do_attach", default=False)
|
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 ("-d", "--detach", action="store_true", dest="do_detach", default=False)
|
||||||
parser.add_option ("-f", "--frontend", dest="frontend",
|
parser.add_option ("-f", "--frontend", dest="frontend",
|
||||||
@ -52,7 +53,7 @@ def main():
|
|||||||
|
|
||||||
(options, args) = parser.parse_args ()
|
(options, args) = parser.parse_args ()
|
||||||
|
|
||||||
if options.file_path:
|
if options.do_file_attach:
|
||||||
options.do_attach = True
|
options.do_attach = True
|
||||||
|
|
||||||
if options.do_list + options.do_attach + options.do_detach > 1:
|
if options.do_list + options.do_attach + options.do_detach > 1:
|
||||||
@ -68,19 +69,21 @@ def main():
|
|||||||
if options.do_attach:
|
if options.do_attach:
|
||||||
if (len (args) < 2):
|
if (len (args) < 2):
|
||||||
parser.error ("You must provide device and vm name!")
|
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:
|
if vm is None:
|
||||||
parser.error ("Invalid VM name: %s" % args[1])
|
parser.error ("Invalid VM name: %s" % args[0])
|
||||||
if options.file_path:
|
# 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 = {}
|
||||||
dev['vm'] = args[0]
|
(dev['vm'], dev['device']) = args[1].split(":")
|
||||||
dev['device'] = options.file_path
|
|
||||||
dev['mode'] = 'w'
|
dev['mode'] = 'w'
|
||||||
else:
|
else:
|
||||||
dev_list = block_list()
|
dev_list = block_list()
|
||||||
if not args[0] in dev_list.keys():
|
if not args[1] in dev_list.keys():
|
||||||
parser.error ("Invalid device name: %s" % args[0])
|
parser.error ("Invalid device name: %s" % args[1])
|
||||||
dev = dev_list[args[0]]
|
dev = dev_list[args[1]]
|
||||||
backend_vm = qvm_collection.get_vm_by_name(dev['vm'])
|
backend_vm = qvm_collection.get_vm_by_name(dev['vm'])
|
||||||
assert backend_vm is not None
|
assert backend_vm is not None
|
||||||
kwargs = {}
|
kwargs = {}
|
||||||
|
Loading…
Reference in New Issue
Block a user