ext/block: properly list devtype=cdrom option
This commit is contained in:
parent
fd5aaa8866
commit
3548ee1163
@ -205,6 +205,8 @@ class BlockDeviceExtension(qubes.ext.Extension):
|
||||
else:
|
||||
options['read-only'] = 'no'
|
||||
options['frontend-dev'] = frontend_dev
|
||||
if disk.get('device') != 'disk':
|
||||
options['devtype'] = disk.get('device')
|
||||
|
||||
if dev_path.startswith('/dev/'):
|
||||
ident = dev_path[len('/dev/'):]
|
||||
|
@ -328,6 +328,29 @@ class TC_00_Block(qubes.tests.QubesTestCase):
|
||||
self.assertEqual(options['frontend-dev'], 'xvdi')
|
||||
self.assertEqual(options['read-only'], 'no')
|
||||
|
||||
def test_033_list_attached_cdrom(self):
|
||||
disk = '''
|
||||
<disk type="block" device="cdrom">
|
||||
<driver name="phy" />
|
||||
<source dev="/dev/sr0" />
|
||||
<target dev="xvdi" />
|
||||
<readonly />
|
||||
<backenddomain name="sys-usb" />
|
||||
</disk>
|
||||
'''
|
||||
vm = TestVM({}, domain_xml=domain_xml_template.format(disk))
|
||||
vm.app.domains['test-vm'] = vm
|
||||
vm.app.domains['sys-usb'] = TestVM({}, name='sys-usb')
|
||||
devices = sorted(list(self.ext.on_device_list_attached(vm, '')))
|
||||
self.assertEqual(len(devices), 1)
|
||||
dev = devices[0][0]
|
||||
options = devices[0][1]
|
||||
self.assertEqual(dev.backend_domain, vm.app.domains['sys-usb'])
|
||||
self.assertEqual(dev.ident, 'sr0')
|
||||
self.assertEqual(options['frontend-dev'], 'xvdi')
|
||||
self.assertEqual(options['read-only'], 'yes')
|
||||
self.assertEqual(options['devtype'], 'cdrom')
|
||||
|
||||
def test_040_attach(self):
|
||||
back_vm = TestVM(name='sys-usb', qdb={
|
||||
'/qubes-block-devices/sda': b'',
|
||||
|
Loading…
Reference in New Issue
Block a user