Skip to content

Commit

Permalink
q-dev: update integration tests fo block devices
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrbartman committed Jun 12, 2024
1 parent 42e062a commit 4a13df1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
7 changes: 5 additions & 2 deletions qubes/ext/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,9 @@ def on_domain_init_load(self, vm, event):
current_devices = dict(
(dev.ident, device_attachments.get(dev.ident, None))
for dev in self.on_device_list_block(vm, None))
self.devices_cache[vm.name] = current_devices.copy()
self.devices_cache[vm.name] = current_devices
else:
self.devices_cache[vm.name] = {}.copy()
self.devices_cache[vm.name] = {}

@qubes.ext.handler('domain-qdb-change:/qubes-block-devices')
def on_qdb_change(self, vm, event, path):
Expand All @@ -328,6 +328,9 @@ def get_device_attachments(vm_):
if not vm.is_running():
continue

if vm.app.vmm.offline_mode:
return result

xml_desc = lxml.etree.fromstring(vm.libvirt_domain.XMLDesc())

for disk in xml_desc.findall('devices/disk'):
Expand Down
4 changes: 2 additions & 2 deletions qubes/tests/vm/qubesvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1482,7 +1482,7 @@ def test_600_libvirt_xml_hvm_cdrom_boot(self):
dom0, 'sda',
{'devtype': 'cdrom', 'read-only': 'yes'},
attach_automatically=True, required=True)
self.loop.run_until_complete(vm.devices['block'].attach(dev))
self.loop.run_until_complete(vm.devices['block'].assign(dev))
libvirt_xml = vm.create_config_file()
self.assertXMLEqual(lxml.etree.XML(libvirt_xml),
lxml.etree.XML(expected))
Expand Down Expand Up @@ -1587,7 +1587,7 @@ def test_600_libvirt_xml_hvm_cdrom_dom0_kernel_boot(self):
dom0, 'sda',
{'devtype': 'cdrom', 'read-only': 'yes'},
attach_automatically=True, required=True)
self.loop.run_until_complete(vm.devices['block'].attach(dev))
self.loop.run_until_complete(vm.devices['block'].assign(dev))
libvirt_xml = vm.create_config_file()
self.assertXMLEqual(lxml.etree.XML(libvirt_xml),
lxml.etree.XML(expected))
Expand Down
12 changes: 11 additions & 1 deletion relaxng/qubes.rng
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,21 @@ the parser will complain about missing combine= attribute on the second <start>.
</data>
</attribute>
<attribute name="id">
<!-- TODO: pattern dependent on class! -->
<data type="string">
<param name="pattern">[0-9a-f]{2}_[0-9a-f]{2}.[0-9a-f]{2}</param>
</data>
</attribute>
<zeroOrMore>
<attribute name="required">
<doc:description>
Flag: is the device required to start domain?
If not present assume 'yes'.
</doc:description>
<data type="string">
<param name="pattern">[yesno]+</param>
</data>
</attribute>
</zeroOrMore>
<zeroOrMore>
<element name="option">
<doc:description>
Expand Down

0 comments on commit 4a13df1

Please sign in to comment.