From 466bf89aae41c20a9d2f5712e69108b7681a3639 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Thu, 14 Dec 2017 02:17:42 +0100 Subject: [PATCH] Fix starting VM with kernel=None When dom0 do not provide the kernel, it should also not set kernel command line in libvirt config. Otherwise qemu in stubdom fails to start because it get -append option without -kernel, which is illegal configuration. Fixes QubesOS/qubes-issues#3339 --- qubes/tests/vm/qubesvm.py | 88 +++++++++++++++++++++++++++++++++++++-- templates/libvirt/xen.xml | 6 ++- test-packages/libvirt.py | 5 ++- 3 files changed, 92 insertions(+), 7 deletions(-) diff --git a/qubes/tests/vm/qubesvm.py b/qubes/tests/vm/qubesvm.py index ce8dfbce..e8637aad 100644 --- a/qubes/tests/vm/qubesvm.py +++ b/qubes/tests/vm/qubesvm.py @@ -28,6 +28,8 @@ import datetime import lxml.etree import unittest.mock +import shutil + import qubes import qubes.exc import qubes.config @@ -147,6 +149,7 @@ class QubesVMTestsMixin(object): super(QubesVMTestsMixin, self).setUp() self.app = qubes.tests.vm.TestApp() self.app.vmm.offline_mode = True + self.app.default_kernel = None # when full test run is called, extensions are loaded by earlier # tests, but if just this test class is run, load them manually here, # to have the same behaviour @@ -583,6 +586,14 @@ class TC_90_QubesVM(QubesVMTestsMixin, qubes.tests.QubesTestCase): vm = self.get_vm(uuid=my_uuid) vm.netvm = None vm.virt_mode = 'pv' + with unittest.mock.patch('qubes.config.qubes_base_dir', + '/tmp/qubes-test'): + kernel_dir = '/tmp/qubes-test/vm-kernels/dummy' + os.makedirs(kernel_dir, exist_ok=True) + open(os.path.join(kernel_dir, 'vmlinuz'), 'w').close() + open(os.path.join(kernel_dir, 'initramfs'), 'w').close() + self.addCleanup(shutil.rmtree, '/tmp/qubes-test') + vm.kernel = 'dummy' # tests for storage are later vm.volumes['kernel'] = unittest.mock.Mock(**{ 'kernels_dir': '/tmp/kernel', @@ -620,8 +631,6 @@ class TC_90_QubesVM(QubesVMTestsMixin, qubes.tests.QubesTestCase): hvmloader - - root=/dev/mapper/dmroot ro nomodeset console=hvc0 rd_NO_PLYMOUTH rd.plymouth.enable=0 plymouth.enable=0 nopat @@ -634,6 +643,7 @@ class TC_90_QubesVM(QubesVMTestsMixin, qubes.tests.QubesTestCase): destroy destroy +