Better error reporting in qvm_start

When user provides incorrect image name/path, the tool
will now inform what's wrong.
This commit is contained in:
Marta Marczykowska-Górecka 2020-10-07 20:44:32 +02:00
parent 806753bbaa
commit fa396a6da9
No known key found for this signature in database
GPG Key ID: 9A752C30B26FD04B

View File

@ -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)