diff --git a/Makefile b/Makefile index 195e42c5..5c249c75 100644 --- a/Makefile +++ b/Makefile @@ -138,6 +138,7 @@ ifeq ($(OS),Linux) $(MAKE) install -C linux/system-config endif $(PYTHON) setup.py install -O1 --skip-build --root $(DESTDIR) + ln -s qvm-device $(DESTDIR)/usr/bin/qvm-block ln -s qvm-device $(DESTDIR)/usr/bin/qvm-pci ln -s qvm-device $(DESTDIR)/usr/bin/qvm-usb # $(MAKE) install -C tests diff --git a/qubes/devices.py b/qubes/devices.py index 320dec28..26e6801d 100644 --- a/qubes/devices.py +++ b/qubes/devices.py @@ -272,8 +272,17 @@ class DeviceCollection(object): attached persistently. ''' - devices = self._vm.fire_event('device-list-attached:' + self._bus, - persistent=persistent) + try: + devices = self._vm.fire_event('device-list-attached:' + self._bus, + persistent=persistent) + except Exception as e: # pylint: disable=broad-except + self._vm.log.exception(e, 'Failed to list {} devices'.format( + self._bus)) + if persistent is True: + # don't break app.save() + return self._set + else: + raise result = set() for dev, options in devices: if dev in self._set and not persistent: diff --git a/qubes/tests/__init__.py b/qubes/tests/__init__.py index 98a528fb..06c22b4f 100644 --- a/qubes/tests/__init__.py +++ b/qubes/tests/__init__.py @@ -53,6 +53,7 @@ import pkg_resources import qubes.api import qubes.api.admin +import qubes.api.internal import qubes.backup import qubes.config import qubes.devices diff --git a/qubes/tests/devices_block.py b/qubes/tests/devices_block.py index 820753ec..33620060 100644 --- a/qubes/tests/devices_block.py +++ b/qubes/tests/devices_block.py @@ -345,7 +345,6 @@ class TC_00_Block(qubes.tests.QubesTestCase): ' \n' ' \n' ' \n' - '\n' ' \n' '') vm.libvirt_domain.attachDevice.assert_called_once_with(device_xml) @@ -366,7 +365,6 @@ class TC_00_Block(qubes.tests.QubesTestCase): ' \n' ' \n' ' \n' - '\n' ' \n' '') vm.libvirt_domain.attachDevice.assert_called_once_with(device_xml) @@ -387,7 +385,7 @@ class TC_00_Block(qubes.tests.QubesTestCase): ' \n' ' \n' ' \n' - ' \n\n' + ' \n' ' \n' '') vm.libvirt_domain.attachDevice.assert_called_once_with(device_xml) @@ -462,7 +460,7 @@ class TC_00_Block(qubes.tests.QubesTestCase): ' \n' ' \n' ' \n' - ' \n\n' + ' \n' ' \n' '') vm.libvirt_domain.attachDevice.assert_called_once_with(device_xml) @@ -479,7 +477,7 @@ class TC_00_Block(qubes.tests.QubesTestCase): ' \n' ' \n' ' \n' - ' \n\n' + ' \n' ' \n' '') vm = TestVM({}, domain_xml=domain_xml_template.format(device_xml)) diff --git a/qubes/vm/adminvm.py b/qubes/vm/adminvm.py index 6b8633a9..fd80cbb2 100644 --- a/qubes/vm/adminvm.py +++ b/qubes/vm/adminvm.py @@ -53,6 +53,7 @@ class AdminVM(qubes.vm.BaseVM): super().__init__(*args, **kwargs) self._qdb_connection = None + self._libvirt_domain = None def __str__(self): return self.name @@ -76,12 +77,14 @@ class AdminVM(qubes.vm.BaseVM): @property def libvirt_domain(self): - '''Always :py:obj:`None`. + '''Libvirt object for dom0. .. seealso: :py:attr:`qubes.vm.qubesvm.QubesVM.libvirt_domain` ''' - return None + if self._libvirt_domain is None: + self._libvirt_domain = self.app.vmm.libvirt_conn.lookupByID(0) + return self._libvirt_domain @staticmethod def is_running(): diff --git a/templates/libvirt/devices/block.xml b/templates/libvirt/devices/block.xml index 41327f36..a78dca34 100644 --- a/templates/libvirt/devices/block.xml +++ b/templates/libvirt/devices/block.xml @@ -12,5 +12,7 @@ {%- endif %} + {%- if device.backend_domain.name != 'dom0' %} + {%- endif %} diff --git a/templates/libvirt/xen.xml b/templates/libvirt/xen.xml index 393f670d..e3ff31ac 100644 --- a/templates/libvirt/xen.xml +++ b/templates/libvirt/xen.xml @@ -10,6 +10,15 @@ {{ vm.memory }} {{ vm.vcpus }} {% endblock %} + {% block cpu %} + + + + + + + + {% endblock %} {% block os %} {% if vm.hvm %}