Avoid setting serial on raw LUN devices
Libvirt now enforces that device="lun" (i.e. raw device passthrough) disks must not have the <serial> property set. We recently enabled the ability to manage devices by alias instead of serial, but to fully enable this use-case we need to avoid putting serial in the XML to appease libvirt. Related-Bug: #2065084 Change-Id: Ifa2df89f27e58e1e64ce046edeaf6e49a7c89490
This commit is contained in:
parent
07f05add31
commit
575ff86a4f
|
@ -1089,6 +1089,48 @@ class LibvirtConfigGuestDiskTest(LibvirtConfigBaseTest):
|
|||
<target bus="ide" dev="/dev/hdc"/>
|
||||
</disk>""")
|
||||
|
||||
def test_config_block_serial(self):
|
||||
obj = config.LibvirtConfigGuestDisk()
|
||||
obj.source_type = "block"
|
||||
obj.source_path = "/tmp/hello"
|
||||
obj.source_device = "cdrom"
|
||||
obj.driver_name = "qemu"
|
||||
obj.target_dev = "/dev/hdc"
|
||||
obj.target_bus = "ide"
|
||||
obj.alias = "ua-this-is-my-disk"
|
||||
obj.serial = "123"
|
||||
|
||||
xml = obj.to_xml()
|
||||
self.assertXmlEqual(xml, """
|
||||
<disk type="block" device="cdrom">
|
||||
<driver name="qemu"/>
|
||||
<alias name="ua-this-is-my-disk"/>
|
||||
<source dev="/tmp/hello"/>
|
||||
<target bus="ide" dev="/dev/hdc"/>
|
||||
<serial>123</serial>
|
||||
</disk>""")
|
||||
|
||||
def test_config_block_lun_no_serial(self):
|
||||
obj = config.LibvirtConfigGuestDisk()
|
||||
obj.source_type = "block"
|
||||
obj.source_path = "/tmp/hello"
|
||||
obj.source_device = "lun"
|
||||
obj.driver_name = "qemu"
|
||||
obj.target_dev = "/dev/sda"
|
||||
obj.target_bus = "scsi"
|
||||
obj.alias = "ua-this-is-my-disk"
|
||||
# This should not be included in the XML because source_device=lun
|
||||
obj.serial = "123"
|
||||
|
||||
xml = obj.to_xml()
|
||||
self.assertXmlEqual(xml, """
|
||||
<disk type="block" device="lun">
|
||||
<driver name="qemu"/>
|
||||
<alias name="ua-this-is-my-disk"/>
|
||||
<source dev="/tmp/hello"/>
|
||||
<target bus="scsi" dev="/dev/sda"/>
|
||||
</disk>""")
|
||||
|
||||
def test_config_block_parse(self):
|
||||
xml = """<disk type="block" device="cdrom">
|
||||
<driver name="qemu"/>
|
||||
|
|
|
@ -1308,7 +1308,7 @@ class LibvirtConfigGuestDisk(LibvirtConfigGuestDevice):
|
|||
dev.append(etree.Element("target", dev=self.target_dev,
|
||||
bus=self.target_bus))
|
||||
|
||||
if self.serial is not None:
|
||||
if self.serial is not None and self.source_device != 'lun':
|
||||
dev.append(self._text_node("serial", self.serial))
|
||||
|
||||
self._format_iotune(dev)
|
||||
|
|
Loading…
Reference in New Issue