qubes/storage: misc fixes for VM-exposed block devices handling
Add 'backenddomain' element when source (not target) domain is not dom0. Fix XML elemenet name. Actually set volume.domain when listing VM-exposed devices. QubesOS/qubes-issues#2256
This commit is contained in:
parent
d7a3c0d319
commit
70d3f58024
@ -255,9 +255,9 @@ class Storage(object):
|
||||
if not rw:
|
||||
lxml.etree.SubElement(disk, 'readonly')
|
||||
|
||||
if self.vm.qid != 0:
|
||||
if volume.domain is not None:
|
||||
lxml.etree.SubElement(disk, 'backenddomain').set(
|
||||
'name', volume.pool.split('p_')[1])
|
||||
'name', volume.domain.name)
|
||||
|
||||
xml_string = lxml.etree.tostring(disk, encoding='utf-8')
|
||||
self.vm.libvirt_domain.attachDevice(xml_string)
|
||||
|
@ -86,7 +86,7 @@ class DomainPool(Pool):
|
||||
|
||||
devices[name][atr] = value
|
||||
|
||||
return [DomainVolume(n, self.name, **atrs)
|
||||
return [DomainVolume(n, self.vm, self.name, **atrs)
|
||||
for n, atrs in devices.items()]
|
||||
|
||||
def clone(self, source, target):
|
||||
@ -99,11 +99,12 @@ class DomainPool(Pool):
|
||||
class DomainVolume(Volume):
|
||||
''' A volume provided by a block device in an domain '''
|
||||
|
||||
def __init__(self, name, pool, desc, mode, **kwargs):
|
||||
def __init__(self, vm, name, pool, desc, mode, **kwargs):
|
||||
rw = (mode == 'w')
|
||||
|
||||
super(DomainVolume, self).__init__(desc, pool, vid=name, removable=True,
|
||||
rw=rw, **kwargs)
|
||||
self.domain = vm
|
||||
|
||||
@property
|
||||
def revisions(self):
|
||||
|
@ -31,6 +31,7 @@ import os.path
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
import qubes.devices
|
||||
import qubes.storage
|
||||
|
||||
BLKSIZE = 512
|
||||
|
@ -81,7 +81,7 @@
|
||||
{% endif %}
|
||||
|
||||
{% if device.domain %}
|
||||
<domain name="{{ domain }}" />
|
||||
<backenddomain name="{{ domain }}" />
|
||||
{% endif %}
|
||||
|
||||
{% if device.script %}
|
||||
|
Loading…
Reference in New Issue
Block a user