core: validate dom0 drive path before starting VM

This is very easy if the file/device is in dom0, so do it to avoid
cryptic startup error (`libvirtError: internal error: libxenlight failed
to create domain`).

Fixes QubesOS/qubes-issues#1619
This commit is contained in:
Marek Marczykowski-Górecki 2016-06-20 22:00:57 +02:00
parent 86b7849fd4
commit 5921dd2a1c
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -312,7 +312,16 @@ class QubesHVm(QubesResizableVm):
else:
return -1
def validate_drive_path(self, drive):
drive_type, drive_domain, drive_path = drive.split(':', 2)
if drive_domain == 'dom0':
if not os.path.exists(drive_path):
raise QubesException("Invalid drive path '{}'".format(
drive_path))
def start(self, *args, **kwargs):
if self.drive:
self.validate_drive_path(self.drive)
# make it available to storage.prepare_for_vm_startup, which is
# called before actually building VM libvirt configuration
self.storage.drive = self.drive