From fa396a6da9d3b5cd51c3ba746a0c1a26185b2959 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marta=20Marczykowska-G=C3=B3recka?= Date: Wed, 7 Oct 2020 20:44:32 +0200 Subject: [PATCH] Better error reporting in qvm_start When user provides incorrect image name/path, the tool will now inform what's wrong. --- qubesadmin/tools/qvm_start.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/qubesadmin/tools/qvm_start.py b/qubesadmin/tools/qvm_start.py index c750235..877b9d0 100644 --- a/qubesadmin/tools/qvm_start.py +++ b/qubesadmin/tools/qvm_start.py @@ -98,7 +98,12 @@ def get_drive_assignment(app, drive_str): devtype = 'disk' drive_str = drive_str[len('hd:'):] - backend_domain_name, ident = drive_str.split(':', 1) + try: + backend_domain_name, ident = drive_str.split(':', 1) + except ValueError: + raise ValueError("Incorrect image name: image must be in the format " + "of VMNAME:full_path, for example " + "dom0:/home/user/test.iso") try: backend_domain = app.domains[backend_domain_name] except KeyError: @@ -193,7 +198,8 @@ def main(args=None, app=None): # don't reconnect this device after VM reboot domain.devices['block'].update_persistent( drive_assignment.device, False) - except (IOError, OSError, qubesadmin.exc.QubesException) as e: + except (IOError, OSError, qubesadmin.exc.QubesException, + ValueError) as e: if drive_assignment: try: domain.devices['block'].detach(drive_assignment)