diff options
| author | Vishvananda Ishaya <vishvananda@gmail.com> | 2012-08-16 10:58:33 -0700 |
|---|---|---|
| committer | Vishvananda Ishaya <vishvananda@gmail.com> | 2012-08-16 11:48:24 -0700 |
| commit | 1e7769cf5587c1ce92f206b39fe646975b19fc95 (patch) | |
| tree | ac80c3992d693ed4ca77e30cf4794ba588a1386d | |
| parent | 2f45636ead3aef36c276804372c382558ecf3fe1 (diff) | |
Adds support for serial to libvirt config disks.
In order for users to find a volume that they have attached to
a vm, it is valuable to be able to find it in a consistent
location. A following patch wil accomplish this by setting
the serial number of the device to the uuid of the volume.
This patch prepares for that change by allowing serial numbers
to be set in the libvirt config disk object.
Prepares to fix bug 1004328
Change-Id: Iecdfc17b45e1c38df50f844f127c0e95558ab22c
| -rw-r--r-- | nova/tests/test_libvirt_config.py | 16 | ||||
| -rw-r--r-- | nova/virt/libvirt/config.py | 4 |
2 files changed, 20 insertions, 0 deletions
diff --git a/nova/tests/test_libvirt_config.py b/nova/tests/test_libvirt_config.py index e270ca2aa..a00d5b572 100644 --- a/nova/tests/test_libvirt_config.py +++ b/nova/tests/test_libvirt_config.py @@ -319,6 +319,22 @@ class LibvirtConfigGuestDiskTest(LibvirtConfigBaseTest): <target bus="ide" dev="/dev/hda"/> </disk>""") + def test_config_file_serial(self): + obj = config.LibvirtConfigGuestDisk() + obj.source_type = "file" + obj.source_path = "/tmp/hello" + obj.target_dev = "/dev/hda" + obj.target_bus = "ide" + obj.serial = "7a97c4a3-6f59-41d4-bf47-191d7f97f8e9" + + xml = obj.to_xml() + self.assertXmlEqual(xml, """ + <disk type="file" device="disk"> + <source file="/tmp/hello"/> + <target bus="ide" dev="/dev/hda"/> + <serial>7a97c4a3-6f59-41d4-bf47-191d7f97f8e9</serial> + </disk>""") + def test_config_block(self): obj = config.LibvirtConfigGuestDisk() obj.source_type = "block" diff --git a/nova/virt/libvirt/config.py b/nova/virt/libvirt/config.py index 8a924df56..4c3483cb9 100644 --- a/nova/virt/libvirt/config.py +++ b/nova/virt/libvirt/config.py @@ -363,6 +363,7 @@ class LibvirtConfigGuestDisk(LibvirtConfigGuestDevice): self.auth_username = None self.auth_secret_type = None self.auth_secret_uuid = None + self.serial = None def format_dom(self): dev = super(LibvirtConfigGuestDisk, self).format_dom() @@ -404,6 +405,9 @@ class LibvirtConfigGuestDisk(LibvirtConfigGuestDevice): dev.append(etree.Element("target", dev=self.target_dev, bus=self.target_bus)) + if self.serial is not None: + dev.append(self._text_node("serial", self.serial)) + return dev |
