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:
|
if not rw:
|
||||||
lxml.etree.SubElement(disk, 'readonly')
|
lxml.etree.SubElement(disk, 'readonly')
|
||||||
|
|
||||||
if self.vm.qid != 0:
|
if volume.domain is not None:
|
||||||
lxml.etree.SubElement(disk, 'backenddomain').set(
|
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')
|
xml_string = lxml.etree.tostring(disk, encoding='utf-8')
|
||||||
self.vm.libvirt_domain.attachDevice(xml_string)
|
self.vm.libvirt_domain.attachDevice(xml_string)
|
||||||
|
@ -86,7 +86,7 @@ class DomainPool(Pool):
|
|||||||
|
|
||||||
devices[name][atr] = value
|
devices[name][atr] = value
|
||||||
|
|
||||||
return [DomainVolume(n, self.name, **atrs)
|
return [DomainVolume(n, self.vm, self.name, **atrs)
|
||||||
for n, atrs in devices.items()]
|
for n, atrs in devices.items()]
|
||||||
|
|
||||||
def clone(self, source, target):
|
def clone(self, source, target):
|
||||||
@ -99,11 +99,12 @@ class DomainPool(Pool):
|
|||||||
class DomainVolume(Volume):
|
class DomainVolume(Volume):
|
||||||
''' A volume provided by a block device in an domain '''
|
''' 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')
|
rw = (mode == 'w')
|
||||||
|
|
||||||
super(DomainVolume, self).__init__(desc, pool, vid=name, removable=True,
|
super(DomainVolume, self).__init__(desc, pool, vid=name, removable=True,
|
||||||
rw=rw, **kwargs)
|
rw=rw, **kwargs)
|
||||||
|
self.domain = vm
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def revisions(self):
|
def revisions(self):
|
||||||
|
@ -31,6 +31,7 @@ import os.path
|
|||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
import qubes.devices
|
||||||
import qubes.storage
|
import qubes.storage
|
||||||
|
|
||||||
BLKSIZE = 512
|
BLKSIZE = 512
|
||||||
|
@ -81,7 +81,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if device.domain %}
|
{% if device.domain %}
|
||||||
<domain name="{{ domain }}" />
|
<backenddomain name="{{ domain }}" />
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if device.script %}
|
{% if device.script %}
|
||||||
|
Loading…
Reference in New Issue
Block a user