From 5921dd2a1c9d57fa2712db03633ed13b128eb2ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Mon, 20 Jun 2016 22:00:57 +0200 Subject: [PATCH] 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 --- core-modules/01QubesHVm.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core-modules/01QubesHVm.py b/core-modules/01QubesHVm.py index 2a6e9f04..c98b67b5 100644 --- a/core-modules/01QubesHVm.py +++ b/core-modules/01QubesHVm.py @@ -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