mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-11 05:17:59 +03:00
virtinst: disk: Fix seclabel testing
disk devices don't have a full <seclabel> under their <source> element, just a smaller one with only a few options. Fix things to match what libvirt does
This commit is contained in:
parent
263a35fe7a
commit
a8914ae1e6
@ -26,7 +26,7 @@
|
||||
<disk type="block" device="disk">
|
||||
<source dev="/dev/null">
|
||||
<seclabel model='selinux' relabel='no'/>
|
||||
<seclabel model='dac' type='dynamic'/>
|
||||
<seclabel model='dac'/>
|
||||
</source>
|
||||
<target dev="hdb" bus="ide"/>
|
||||
</disk>
|
||||
|
@ -27,7 +27,9 @@
|
||||
<disk type="block" device="disk">
|
||||
<source dev="/dev/null">
|
||||
<seclabel model="selinux" relabel="no"/>
|
||||
<seclabel model="dac" type="none"/>
|
||||
<seclabel model="dac" relabel="yes">
|
||||
<label>foo-my-label</label>
|
||||
</seclabel>
|
||||
</source>
|
||||
<target dev="hdb" bus="ide"/>
|
||||
</disk>
|
||||
|
@ -352,7 +352,8 @@ class XMLParseTest(unittest.TestCase):
|
||||
disk = guest.get_devices("disk")[1]
|
||||
check = self._make_checker(disk.seclabel[1])
|
||||
check("model", "dac")
|
||||
check("type", "dynamic", "none")
|
||||
check("relabel", None, True)
|
||||
check("label", None, "foo-my-label")
|
||||
|
||||
disk = _get_disk("hdc")
|
||||
check = self._make_checker(disk)
|
||||
|
@ -30,7 +30,7 @@ from . import diskbackend
|
||||
from . import util
|
||||
from .device import VirtualDevice
|
||||
from .seclabel import Seclabel
|
||||
from .xmlbuilder import XMLChildProperty, XMLProperty
|
||||
from .xmlbuilder import XMLBuilder, XMLChildProperty, XMLProperty
|
||||
|
||||
|
||||
def _qemu_sanitize_drvtype(phystype, fmt, manual_format=False):
|
||||
@ -91,6 +91,17 @@ def _is_dir_searchable(uid, username, path):
|
||||
return bool(re.search("user:%s:..x" % username, out))
|
||||
|
||||
|
||||
class _DiskSeclabel(XMLBuilder):
|
||||
"""
|
||||
This is for disk source <seclabel>. It's similar to a domain
|
||||
<seclabel> but has fewer options
|
||||
"""
|
||||
_XML_ROOT_NAME = "seclabel"
|
||||
model = XMLProperty("./@model")
|
||||
relabel = XMLProperty("./@relabel", is_yesno=True)
|
||||
label = XMLProperty("./label")
|
||||
|
||||
|
||||
class VirtualDisk(VirtualDevice):
|
||||
virtual_device_type = VirtualDevice.VIRTUAL_DEV_DISK
|
||||
|
||||
@ -742,7 +753,7 @@ class VirtualDisk(VirtualDevice):
|
||||
iotune_wbs = XMLProperty("./iotune/write_bytes_sec", is_int=True)
|
||||
iotune_wis = XMLProperty("./iotune/write_iops_sec", is_int=True)
|
||||
|
||||
seclabel = XMLChildProperty(Seclabel, relative_xpath="./source")
|
||||
seclabel = XMLChildProperty(_DiskSeclabel, relative_xpath="./source")
|
||||
|
||||
|
||||
#################################
|
||||
|
Loading…
Reference in New Issue
Block a user