dom0/qvm-block: hide system disks by default (#5 pro)
This commit is contained in:
parent
5e1a9c203f
commit
194ac8ddcb
@ -188,7 +188,7 @@ def block_find_unused_frontend(vm = None):
|
||||
return block_devid_to_name(major << 8 | minor)
|
||||
return None
|
||||
|
||||
def block_list(vm = None):
|
||||
def block_list(vm = None, system_disks = False):
|
||||
device_re = re.compile(r"^[a-z0-9]{1,8}$")
|
||||
# FIXME: any better idea of desc_re?
|
||||
desc_re = re.compile(r"^.{1,255}$")
|
||||
@ -232,6 +232,11 @@ def block_list(vm = None):
|
||||
if block_name_to_majorminor(device) == (0, 0):
|
||||
print >> sys.stderr, "Unsupported device %s:%s" % (vm_name, device)
|
||||
continue
|
||||
|
||||
if not system_disks:
|
||||
if xid == '0' and device_desc.startswith(qubes_base_dir):
|
||||
continue
|
||||
|
||||
visible_name = "%s:%s" % (vm_name, device)
|
||||
devices_list[visible_name] = {"name": visible_name, "xid":int(xid),
|
||||
"vm": vm_name, "device":device, "size":int(device_size),
|
||||
|
@ -47,6 +47,8 @@ def main():
|
||||
help="Force read-only mode")
|
||||
parser.add_option ("--no-auto-detach", dest="auto_detach", action="store_false", default=True,
|
||||
help="Fail when device already connected to other VM")
|
||||
parser.add_option ("--show-system-disks", dest="system_disks", action="store_true", default=False,
|
||||
help="List also system disks")
|
||||
|
||||
(options, args) = parser.parse_args ()
|
||||
|
||||
@ -113,7 +115,9 @@ def main():
|
||||
block_detach(None, attached_to['devid'], vm_xid=attached_to['xid'])
|
||||
else:
|
||||
# do_list
|
||||
for dev in block_list().values():
|
||||
kwargs = {}
|
||||
kwargs['system_disks'] = options.system_disks
|
||||
for dev in block_list(**kwargs).values():
|
||||
attached_to = block_check_attached(None, dev['device'], backend_xid = dev['xid'])
|
||||
attached_to_str = ""
|
||||
if attached_to:
|
||||
|
Loading…
Reference in New Issue
Block a user