[virt-tools-list] [ [PATCH 3/3] addhardware: Add disk pr.managed and pr.path options to support SCSI PR
Lin Ma
lma at suse.com
Tue Sep 25 09:12:50 UTC 2018
Signed-off-by: Lin Ma <lma at suse.com>
---
ui/addhardware.ui | 56 ++++++++++++++++++++++++++++++++++++++
virtManager/addhardware.py | 35 ++++++++++++++++++++++++
2 files changed, 91 insertions(+)
diff --git a/ui/addhardware.ui b/ui/addhardware.ui
index dffcf8c6..aa9e0339 100644
--- a/ui/addhardware.ui
+++ b/ui/addhardware.ui
@@ -328,6 +328,62 @@
<property name="top_attach">3</property>
</packing>
</child>
+ <child>
+ <object class="GtkLabel" id="disk-pr-label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">end</property>
+ <property name="label" translatable="yes">_Managed SCSI PR:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">disk-pr-entry</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="disk-pr">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="has_entry">True</property>
+ <child internal-child="entry">
+ <object class="GtkEntry" id="disk-pr-entry">
+ <property name="can_focus">True</property>
+ <signal name="changed" handler="on_disk_pr_combo_changed" swapped="no"/>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="disk-pr-path-label">
+ <property name="visible">False</property>
+ <property name="can_focus">False</property>
+ <property name="halign">end</property>
+ <property name="label" translatable="yes">PR source path:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">disk-pr-path-entry</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">5</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="disk-pr-path-entry">
+ <property name="visible">False</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">5</property>
+ </packing>
+ </child>
</object>
</child>
<child type="label">
diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py
index e1fe699c..7d6ae47a 100644
--- a/virtManager/addhardware.py
+++ b/virtManager/addhardware.py
@@ -111,6 +111,8 @@ class vmmAddHardware(vmmGObjectUI):
"on_usbredir_type_changed": self._change_usbredir_type,
"on_controller_type_changed": self._change_controller_type,
+
+ "on_disk_pr_combo_changed": self._change_disk_pr_combo,
})
self.bind_escape_key_close()
@@ -197,6 +199,7 @@ class vmmAddHardware(vmmGObjectUI):
self.build_disk_discard_combo(self.vm, self.widget("storage-discard"))
self.build_disk_detect_zeroes_combo(self.vm,
self.widget("storage-detect-zeroes"))
+ self.build_disk_pr_managed_combo(self.vm, self.widget("disk-pr"))
self.build_network_model_combo(self.vm, self.widget("net-model"))
self._build_input_combo()
self.build_sound_combo(self.vm, self.widget("sound-model"))
@@ -856,6 +859,15 @@ class vmmAddHardware(vmmGObjectUI):
self.widget("storage-devtype"))
self._refresh_disk_bus(devtype)
+ disk_pr = self.widget("disk-pr")
+ uiutil.set_grid_row_visible(disk_pr, False)
+ disk_pr_path_entry = self.widget("disk-pr-path-entry")
+ uiutil.set_grid_row_visible(disk_pr_path_entry, False)
+ is_lun = devtype == "lun"
+ uiutil.set_grid_row_visible(disk_pr, is_lun)
+ not_managed = (uiutil.get_list_selection(disk_pr) == "no")
+ uiutil.set_grid_row_visible(disk_pr_path_entry, is_lun and not_managed)
+
allow_create = devtype not in ["cdrom", "floppy"]
self.addstorage.widget("storage-create-box").set_sensitive(
allow_create)
@@ -978,6 +990,15 @@ class vmmAddHardware(vmmGObjectUI):
self.populate_controller_model_combo(combo, controller_type)
uiutil.set_grid_row_visible(combo, len(combo.get_model()) > 1)
+ def _change_disk_pr_combo(self, src):
+ ignore = src
+ disk_pr = self.widget("disk-pr")
+ not_managed = (uiutil.get_list_selection(disk_pr) == "no")
+ uiutil.set_grid_row_visible(self.widget("disk-pr-path-label"),
+ not_managed)
+ uiutil.set_grid_row_visible(self.widget("disk-pr-path-entry"),
+ not_managed)
+
######################
# Add device methods #
@@ -1208,6 +1229,14 @@ class vmmAddHardware(vmmGObjectUI):
self.widget("storage-discard"))
detect_zeroes = uiutil.get_list_selection(
self.widget("storage-detect-zeroes"))
+ if device == "lun":
+ pr_managed = uiutil.get_list_selection(self.widget("disk-pr"))
+ pr_path = None
+ if pr_managed == "no":
+ pr_path = self.widget("disk-pr-path-entry").get_text()
+ # Hardcode the vales of the type and the mode
+ pr_type = "unix"
+ pr_mode = "client"
controller_model = None
if (bus == "scsi" and
@@ -1238,6 +1267,12 @@ class vmmAddHardware(vmmGObjectUI):
disk.driver_discard = discard
if detect_zeroes:
disk.driver_detect_zeroes = detect_zeroes
+ if device == "lun":
+ disk.pr_managed = pr_managed
+ if pr_path:
+ disk.pr_path = pr_path
+ disk.pr_type = pr_type
+ disk.pr_mode = pr_mode
# Generate target
disks = (self.vm.xmlobj.devices.disk +
--
2.19.0
More information about the virt-tools-list
mailing list