This patch adds support for the user to select Driver Type on the addhardware->filesystems page. Currently only 'path' and 'handle' driver types are supported. When anything but 'path' is selected, the security modes do not apply, hence they are removed from the page based on user's selected driver type. Note: Some changes were needed in libvirt also to ensure smooth experience while dealing with driver and mode fields. Related libvirt patches are posted at ... https://www.redhat.com/archives/libvir-list/2011-December/msg00919.html Signed-off-by: Deepak C Shetty <deepakcs@xxxxxxxxxxxxxxxxxx> --- src/virtManager/addhardware.py | 36 +++++++++++++++++++++++ src/virtManager/details.py | 17 ++++++++++- src/vmm-add-hardware.glade | 63 ++++++++++++++++++++++++++++++++++------ src/vmm-details.glade | 43 ++++++++++++++++++++++----- 4 files changed, 141 insertions(+), 18 deletions(-) diff --git a/src/virtManager/addhardware.py b/src/virtManager/addhardware.py index 27dfbef..5828932 100644 --- a/src/virtManager/addhardware.py +++ b/src/virtManager/addhardware.py @@ -94,6 +94,7 @@ class vmmAddHardware(vmmGObjectUI): "on_char_device_type_changed": self.change_char_device_type, "on_fs_type_combo_changed": self.change_fs_type, + "on_fs_driver_combo_changed": self.change_fs_driver, "on_fs_source_browse_clicked": self.browse_fs_source, "on_usbredir_type_changed": self.change_usbredir_type, @@ -327,6 +328,7 @@ class vmmAddHardware(vmmGObjectUI): [VirtualFilesystem.TYPE_MOUNT, VirtualFilesystem.TYPE_TEMPLATE]) simple_store_set("fs-mode-combo", VirtualFilesystem.MOUNT_MODES) + simple_store_set("fs-driver-combo", VirtualFilesystem.DRIVER_TYPES) self.show_pair_combo("fs-type", self.conn.is_openvz()) # Smartcard widgets @@ -479,6 +481,7 @@ class vmmAddHardware(vmmGObjectUI): # FS params self.widget("fs-type-combo").set_active(0) self.widget("fs-mode-combo").set_active(0) + self.widget("fs-driver-combo").set_active(0) self.widget("fs-source").set_text("") self.widget("fs-target").set_text("") @@ -731,6 +734,14 @@ class vmmAddHardware(vmmGObjectUI): return combo.get_model()[combo.get_active()][0] + def get_config_fs_driver(self): + name = "fs-driver-combo" + combo = self.widget(name) + if not combo.get_property("visible"): + return None + + return combo.get_model()[combo.get_active()][0] + # Smartcard getters def get_config_smartcard_mode(self): mode = self.widget("smartcard-mode") @@ -1012,6 +1023,7 @@ class vmmAddHardware(vmmGObjectUI): idx = src.get_active() fstype = None show_mode_combo = False + show_driver_combo = False if idx >= 0 and src.get_property("visible"): fstype = src.get_model()[idx][0] @@ -1021,10 +1033,31 @@ class vmmAddHardware(vmmGObjectUI): else: source_text = _("_Source path:") show_mode_combo = self.conn.is_qemu() + show_driver_combo = self.conn.is_qemu() self.widget("fs-source-title").set_text(source_text) self.widget("fs-source-title").set_use_underline(True) self.show_pair_combo("fs-mode", show_mode_combo) + self.show_pair_combo("fs-driver", show_driver_combo) + + def change_fs_driver(self, src): + idx = src.get_active() + fsdriver = None + combo = self.widget("fs-mode-combo") + label1 = self.widget("fs-mode-title") + + if idx >= 0 and src.get_property("visible"): + fsdriver = src.get_model()[idx][0] + + if (fsdriver == virtinst.VirtualFilesystem.DRIVER_PATH or + fsdriver == virtinst.VirtualFilesystem.DRIVER_DEFAULT): + combo.set_property("visible", True) + label1.set_property("visible", True) + else: + combo.set_property("visible", False) + label1.set_property("visible", False) + + ###################### @@ -1373,6 +1406,7 @@ class vmmAddHardware(vmmGObjectUI): target = self.widget("fs-target").get_text() mode = self.get_config_fs_mode() fstype = self.get_config_fs_type() + driver = self.get_config_fs_driver() if not source: return self.err.val_err(_("A filesystem source must be specified")) @@ -1391,6 +1425,8 @@ class vmmAddHardware(vmmGObjectUI): self._dev.mode = mode if fstype: self._dev.type = fstype + if driver: + self._dev.driver = driver except Exception, e: return self.err.val_err(_("Filesystem parameter error"), e) diff --git a/src/virtManager/details.py b/src/virtManager/details.py index fcd0652..038dc4a 100644 --- a/src/virtManager/details.py +++ b/src/virtManager/details.py @@ -3134,7 +3134,16 @@ class vmmDetails(vmmGObjectUI): return self.widget("fs-type").set_text(dev.type) - self.widget("fs-mode").set_text(dev.mode) + + # mode can be irrelevant depending on the fs driver type + # selected. + if dev.mode: + self.show_pair("fs-mode", True) + self.widget("fs-mode").set_text(dev.mode) + else: + self.show_pair("fs-mode", False) + + self.widget("fs-driver").set_text(dev.driver) self.widget("fs-source").set_text(dev.source) self.widget("fs-target").set_text(dev.target) @@ -3462,6 +3471,12 @@ class vmmDetails(vmmGObjectUI): # Set a default selection selection.select_path("0") + def show_pair(self, basename, show): + combo = self.widget(basename) + label = self.widget(basename + "-title") + + combo.set_property("visible", show) + label.set_property("visible", show) vmmGObjectUI.type_register(vmmDetails) vmmDetails.signal_new(vmmDetails, "action-save-domain", [str, str]) diff --git a/src/vmm-add-hardware.glade b/src/vmm-add-hardware.glade index 3d13c49..0ec4df4 100644 --- a/src/vmm-add-hardware.glade +++ b/src/vmm-add-hardware.glade @@ -2076,7 +2076,7 @@ access in the guest.</property> </packing> </child> <child> - <widget class="GtkLabel" id="label19"> + <widget class="GtkLabel" id="fs-mode-title"> <property name="visible">True</property> <property name="xalign">0</property> <property name="label" translatable="yes">_Mode:</property> @@ -2119,6 +2119,51 @@ access in the guest.</property> <property name="bottom_attach">2</property> </packing> </child> + <child> + <widget class="GtkLabel" id="fs-driver-title"> + <property name="visible">True</property> + <property name="xalign">0</property> + <property name="label" translatable="yes">_Driver:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">fs-driver-combo</property> + </widget> + <packing> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + <property name="x_options">GTK_FILL</property> + </packing> + </child> + <child> + <widget class="GtkHBox" id="hbox15"> + <property name="visible">True</property> + <child> + <widget class="GtkComboBox" id="fs-driver-combo"> + <property name="visible">True</property> + <signal name="changed" handler="on_fs_driver_combo_changed"/> + </widget> + <packing> + <property name="expand">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <widget class="GtkLabel" id="fs-driver-label"> + <property name="visible">True</property> + <property name="xalign">0</property> + <property name="label" translatable="yes">Default</property> + </widget> + <packing> + <property name="position">1</property> + </packing> + </child> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + </packing> + </child> <child> <widget class="GtkLabel" id="fs-source-title"> <property name="visible">True</property> @@ -2128,8 +2173,8 @@ access in the guest.</property> <property name="mnemonic_widget">fs-source</property> </widget> <packing> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> <property name="x_options">GTK_FILL</property> </packing> </child> @@ -2142,8 +2187,8 @@ access in the guest.</property> <property name="mnemonic_widget">fs-target</property> </widget> <packing> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> + <property name="top_attach">4</property> + <property name="bottom_attach">5</property> <property name="x_options">GTK_FILL</property> </packing> </child> @@ -2156,8 +2201,8 @@ access in the guest.</property> <packing> <property name="left_attach">1</property> <property name="right_attach">2</property> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> + <property name="top_attach">4</property> + <property name="bottom_attach">5</property> </packing> </child> <child> @@ -2192,8 +2237,8 @@ access in the guest.</property> <packing> <property name="left_attach">1</property> <property name="right_attach">2</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> </packing> </child> </widget> diff --git a/src/vmm-details.glade b/src/vmm-details.glade index 852db1f..b89f518 100644 --- a/src/vmm-details.glade +++ b/src/vmm-details.glade @@ -5676,7 +5676,7 @@ I/O:</property> <property name="column_spacing">6</property> <property name="row_spacing">6</property> <child> - <widget class="GtkLabel" id="label63"> + <widget class="GtkLabel" id="fs-mode-title"> <property name="visible">True</property> <property name="xalign">0</property> <property name="label" translatable="yes">Mode:</property> @@ -5689,10 +5689,10 @@ I/O:</property> </packing> </child> <child> - <widget class="GtkLabel" id="label65"> + <widget class="GtkLabel" id="label64"> <property name="visible">True</property> <property name="xalign">0</property> - <property name="label" translatable="yes">Source:</property> + <property name="label" translatable="yes">Driver:</property> </widget> <packing> <property name="top_attach">2</property> @@ -5702,10 +5702,10 @@ I/O:</property> </packing> </child> <child> - <widget class="GtkLabel" id="label66"> + <widget class="GtkLabel" id="label65"> <property name="visible">True</property> <property name="xalign">0</property> - <property name="label" translatable="yes">Target:</property> + <property name="label" translatable="yes">Source:</property> </widget> <packing> <property name="top_attach">3</property> @@ -5715,6 +5715,19 @@ I/O:</property> </packing> </child> <child> + <widget class="GtkLabel" id="label66"> + <property name="visible">True</property> + <property name="xalign">0</property> + <property name="label" translatable="yes">Target:</property> + </widget> + <packing> + <property name="top_attach">4</property> + <property name="bottom_attach">5</property> + <property name="x_options">GTK_FILL</property> + <property name="y_options">GTK_FILL</property> + </packing> + </child> + <child> <widget class="GtkLabel" id="fs-mode"> <property name="visible">True</property> <property name="xalign">0</property> @@ -5729,11 +5742,10 @@ I/O:</property> </packing> </child> <child> - <widget class="GtkLabel" id="fs-source"> + <widget class="GtkLabel" id="fs-driver"> <property name="visible">True</property> <property name="xalign">0</property> <property name="label">label</property> - <property name="ellipsize">end</property> </widget> <packing> <property name="left_attach">1</property> @@ -5744,7 +5756,7 @@ I/O:</property> </packing> </child> <child> - <widget class="GtkLabel" id="fs-target"> + <widget class="GtkLabel" id="fs-source"> <property name="visible">True</property> <property name="xalign">0</property> <property name="label">label</property> @@ -5759,6 +5771,21 @@ I/O:</property> </packing> </child> <child> + <widget class="GtkLabel" id="fs-target"> + <property name="visible">True</property> + <property name="xalign">0</property> + <property name="label">label</property> + <property name="ellipsize">end</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">4</property> + <property name="bottom_attach">5</property> + <property name="y_options">GTK_FILL</property> + </packing> + </child> + <child> <widget class="GtkLabel" id="label67"> <property name="visible">True</property> <property name="xalign">0</property>