virt-manager: Add support for filesystem Driver Type

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@linux.vnet.ibm.com>

(crobinso: small fix to handle if dev.driver is None)
This commit is contained in:
Deepak C Shetty 2012-01-12 20:28:26 -05:00 committed by Cole Robinson
parent 18e12e7ad9
commit 708dc74468
4 changed files with 142 additions and 19 deletions

View File

@ -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())
self.show_check_button("fs-readonly", self.conn.is_qemu())
@ -480,6 +482,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("")
self.widget("fs-readonly").set_active(False)
@ -742,6 +745,14 @@ class vmmAddHardware(vmmGObjectUI):
return check.get_active()
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")
@ -1027,6 +1038,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]
@ -1036,10 +1048,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)
######################
@ -1389,6 +1422,7 @@ class vmmAddHardware(vmmGObjectUI):
mode = self.get_config_fs_mode()
fstype = self.get_config_fs_type()
readonly = self.get_config_fs_readonly()
driver = self.get_config_fs_driver()
if not source:
return self.err.val_err(_("A filesystem source must be specified"))
@ -1409,6 +1443,8 @@ class vmmAddHardware(vmmGObjectUI):
self._dev.type = fstype
if readonly:
self._dev.readonly = readonly
if driver:
self._dev.driver = driver
except Exception, e:
return self.err.val_err(_("Filesystem parameter error"), e)

View File

@ -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 or _("Default"))
self.widget("fs-source").set_text(dev.source)
self.widget("fs-target").set_text(dev.target)
if dev.readonly:
@ -3467,6 +3476,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])

View File

@ -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>
@ -2208,8 +2253,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>

View File

@ -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>
@ -5718,7 +5718,20 @@ I/O:</property>
<widget class="GtkLabel" id="fs-readonly-title">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Readonly Filesystem:</property>
<property name="label" translatable="yes">Readonly:</property>
</widget>
<packing>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</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>
@ -5742,11 +5755,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>
@ -5757,7 +5769,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>
@ -5778,6 +5790,21 @@ I/O:</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">5</property>
<property name="bottom_attach">6</property>
<property name="y_options">GTK_FILL</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>