From d073ee9a4821046de7df977571995300be827310 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Tue, 8 Sep 2020 12:16:19 -0400 Subject: [PATCH] addstorage: Revive disk serial UI coreos is going to start using disk serial for ignition disk, so setting this in the UI for distro testing will become more common Signed-off-by: Cole Robinson --- tests/uitests/test_addhardware.py | 1 + tests/uitests/test_details.py | 1 + ui/addstorage.ui | 42 ++++++++++++++++++++++++------- virtManager/device/addstorage.py | 11 +++++++- virtManager/object/domain.py | 5 +++- 5 files changed, 49 insertions(+), 11 deletions(-) diff --git a/tests/uitests/test_addhardware.py b/tests/uitests/test_addhardware.py index 4f89b7455..4ad2a407e 100644 --- a/tests/uitests/test_addhardware.py +++ b/tests/uitests/test_addhardware.py @@ -150,6 +150,7 @@ class AddHardware(uiutils.UITestCase): tab.find("Advanced options", "toggle button").click_expander() tab.find("Shareable:", "check box").click() tab.find("Readonly:", "check box").click() + tab.find("Serial:", "text").set_text("ZZZZ") tab.combo_select("Cache mode:", "none") tab.combo_select("Discard mode:", "ignore") tab.combo_select("Detect zeroes:", "unmap") diff --git a/tests/uitests/test_details.py b/tests/uitests/test_details.py index da0d05ac5..69896a70b 100644 --- a/tests/uitests/test_details.py +++ b/tests/uitests/test_details.py @@ -369,6 +369,7 @@ class Details(uiutils.UITestCase): tab.find("Advanced options", "toggle button").click_expander() tab.find("Shareable:", "check box").click() tab.find("Readonly:", "check box").click() + tab.find("Serial:", "text").set_text("1234-ABCD") tab.combo_select("Cache mode:", "unsafe") tab.combo_select("Discard mode:", "unmap") tab.combo_select("Detect zeroes:", "unmap") diff --git a/ui/addstorage.ui b/ui/addstorage.ui index f55d64d84..53aed440e 100644 --- a/ui/addstorage.ui +++ b/ui/addstorage.ui @@ -249,8 +249,8 @@ True False - 3 - 8 + 6 + 6 True @@ -262,7 +262,7 @@ 0 - 3 + 4 @@ -279,7 +279,7 @@ 1 - 3 + 4 @@ -293,7 +293,7 @@ 0 - 4 + 5 @@ -310,7 +310,7 @@ 1 - 4 + 5 @@ -324,7 +324,7 @@ 0 - 5 + 6 @@ -341,7 +341,7 @@ 1 - 5 + 6 @@ -419,7 +419,6 @@ True False start - True True @@ -428,6 +427,31 @@ 2 + + + True + False + end + Seria_l: + True + disk-serial + + + 0 + 3 + + + + + True + True + + + + 1 + 3 + + diff --git a/virtManager/device/addstorage.py b/virtManager/device/addstorage.py index df779193d..0757f80a7 100644 --- a/virtManager/device/addstorage.py +++ b/virtManager/device/addstorage.py @@ -20,7 +20,8 @@ from ..baseclass import vmmGObjectUI _EDIT_RO, _EDIT_SHARE, _EDIT_REMOVABLE, -) = range(1, 7) + _EDIT_SERIAL, +) = range(1, 8) class vmmAddStorage(vmmGObjectUI): @@ -49,6 +50,7 @@ class vmmAddStorage(vmmGObjectUI): "on_disk_readonly_changed": _e(_EDIT_RO), "on_disk_shareable_changed": _e(_EDIT_SHARE), "on_disk_removable_changed": _e(_EDIT_REMOVABLE), + "on_disk_serial_changed": _e(_EDIT_SERIAL), }) self._active_edits = [] @@ -176,6 +178,7 @@ class vmmAddStorage(vmmGObjectUI): self.widget("disk-cache").set_active(0) self.widget("disk-discard").set_active(0) self.widget("disk-detect-zeroes").set_active(0) + self.widget("disk-serial").set_text("") self.widget("storage-advanced").set_expanded(False) self.widget("disk-readonly").set_active(False) self.widget("disk-shareable").set_active(False) @@ -237,6 +240,8 @@ class vmmAddStorage(vmmGObjectUI): disk.read_only = vals.get("readonly") if vals.get("shareable") is not None: disk.shareable = vals.get("shareable") + if vals.get("serial") is not None: + disk.serial = vals.get("serial") if disk.wants_storage_creation(): pool = disk.get_parent_pool() @@ -290,6 +295,7 @@ class vmmAddStorage(vmmGObjectUI): ro = disk.read_only share = disk.shareable removable = disk.removable + serial = disk.serial is_usb = (disk.bus == "usb") can_set_removable = (is_usb and (self.conn.is_qemu() or @@ -304,6 +310,7 @@ class vmmAddStorage(vmmGObjectUI): uiutil.set_list_selection( self.widget("disk-detect-zeroes"), detect_zeroes) + self.widget("disk-serial").set_text(serial or "") self.widget("disk-readonly").set_active(ro) self.widget("disk-readonly").set_sensitive(not disk.is_cdrom()) self.widget("disk-shareable").set_active(share) @@ -334,6 +341,8 @@ class vmmAddStorage(vmmGObjectUI): if _EDIT_REMOVABLE in self._active_edits: ret["removable"] = bool( self.widget("disk-removable").get_active()) + if _EDIT_SERIAL in self._active_edits: + ret["serial"] = self.widget("disk-serial").get_text() return ret diff --git a/virtManager/object/domain.py b/virtManager/object/domain.py index e4103d8fb..7ad9de4c9 100644 --- a/virtManager/object/domain.py +++ b/virtManager/object/domain.py @@ -726,7 +726,8 @@ class vmmDomain(vmmLibvirtObject): def define_disk(self, devobj, do_hotplug, path=_SENTINEL, readonly=_SENTINEL, shareable=_SENTINEL, removable=_SENTINEL, cache=_SENTINEL, - discard=_SENTINEL, detect_zeroes=_SENTINEL, bus=_SENTINEL): + discard=_SENTINEL, detect_zeroes=_SENTINEL, bus=_SENTINEL, + serial=_SENTINEL): xmlobj = self._make_xmlobj_to_define() editdev = self._lookup_device_to_define(xmlobj, devobj, do_hotplug) if not editdev: @@ -744,6 +745,8 @@ class vmmDomain(vmmLibvirtObject): if removable != _SENTINEL: editdev.removable = removable + if serial != _SENTINEL: + editdev.serial = serial or None if cache != _SENTINEL: editdev.driver_cache = cache or None if discard != _SENTINEL: