From 749b84ec434ac28299ab044f2d841987f6a5ac51 Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Tue, 27 Mar 2012 12:59:47 +0200 Subject: [PATCH] dom0/qvm-block: hide system disks by default (#5 pro) --- dom0/qvm-core/qubesutils.py | 7 ++++++- dom0/qvm-tools/qvm-block | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/dom0/qvm-core/qubesutils.py b/dom0/qvm-core/qubesutils.py index 8663f3a2..677a589a 100644 --- a/dom0/qvm-core/qubesutils.py +++ b/dom0/qvm-core/qubesutils.py @@ -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), diff --git a/dom0/qvm-tools/qvm-block b/dom0/qvm-tools/qvm-block index 84d81cbd..ed8de53d 100755 --- a/dom0/qvm-tools/qvm-block +++ b/dom0/qvm-tools/qvm-block @@ -48,6 +48,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 () @@ -116,7 +118,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: