diff options
author | Cole Robinson <crobinso@redhat.com> | 2016-06-11 17:43:18 -0400 |
---|---|---|
committer | Cole Robinson <crobinso@redhat.com> | 2016-06-11 17:43:18 -0400 |
commit | a8914ae1e69a4436bf5873a51d3a23c055f3ec13 (patch) | |
tree | 806940997b61dd4fd7313739573235ec691a1983 | |
parent | 263a35fe7aad032486cb7577d00cbe88ca807cbb (diff) | |
download | virt-manager-a8914ae1e69a4436bf5873a51d3a23c055f3ec13.tar.gz |
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
-rw-r--r-- | tests/xmlparse-xml/change-disk-in.xml | 2 | ||||
-rw-r--r-- | tests/xmlparse-xml/change-disk-out.xml | 4 | ||||
-rw-r--r-- | tests/xmlparse.py | 3 | ||||
-rw-r--r-- | virtinst/devicedisk.py | 15 |
4 files changed, 19 insertions, 5 deletions
diff --git a/tests/xmlparse-xml/change-disk-in.xml b/tests/xmlparse-xml/change-disk-in.xml index 3c4d7259..22896ad8 100644 --- a/tests/xmlparse-xml/change-disk-in.xml +++ b/tests/xmlparse-xml/change-disk-in.xml @@ -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> diff --git a/tests/xmlparse-xml/change-disk-out.xml b/tests/xmlparse-xml/change-disk-out.xml index fe042f05..cc5eede8 100644 --- a/tests/xmlparse-xml/change-disk-out.xml +++ b/tests/xmlparse-xml/change-disk-out.xml @@ -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> diff --git a/tests/xmlparse.py b/tests/xmlparse.py index 7a763b8e..6db77db8 100644 --- a/tests/xmlparse.py +++ b/tests/xmlparse.py @@ -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) diff --git a/virtinst/devicedisk.py b/virtinst/devicedisk.py index e2ae610f..5270c120 100644 --- a/virtinst/devicedisk.py +++ b/virtinst/devicedisk.py @@ -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") ################################# |