[virt-tools-list] [PATCH RFC] Add support for the new 'removable' disk flag.
Fred A. Kemp
anonym at riseup.net
Wed Oct 2 14:39:28 UTC 2013
From: "Fred A. Kemp" <anonym at riseup.net>
---
ui/details.ui | 39 ++++++++++++++++++++++++++++++++++++++-
virtManager/details.py | 16 +++++++++++++++-
virtManager/domain.py | 4 ++++
virtManager/uihelpers.py | 13 +++++++++++++
virtinst/devicedisk.py | 1 +
5 files changed, 71 insertions(+), 2 deletions(-)
diff --git a/ui/details.ui b/ui/details.ui
index 5d1917f..73fe127 100644
--- a/ui/details.ui
+++ b/ui/details.ui
@@ -3575,7 +3575,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">3</property>
- <property name="n_rows">5</property>
+ <property name="n_rows">6</property>
<property name="n_columns">2</property>
<property name="column_spacing">8</property>
<property name="row_spacing">4</property>
@@ -3612,6 +3612,22 @@
</packing>
</child>
<child>
+ <object class="GtkLabel" id="disk-removable-label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Removab_le:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">disk-removable</property>
+ </object>
+ <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>
<object class="GtkCheckButton" id="disk-readonly">
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -3648,6 +3664,27 @@
</packing>
</child>
<child>
+ <object class="GtkComboBox" id="disk-removable">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="has_entry">True</property>
+ <signal name="changed" handler="on_disk_removable_combo_changed" swapped="no"/>
+ <child internal-child="entry">
+ <object class="GtkEntry" id="combobox-entry-disk-removable">
+ <property name="can_focus">True</property>
+ </object>
+ </child>
+ </object>
+ <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="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="can_focus">False</property>
diff --git a/virtManager/details.py b/virtManager/details.py
index 1b3f6fd..e0212fe 100644
--- a/virtManager/details.py
+++ b/virtManager/details.py
@@ -66,6 +66,7 @@ EDIT_INIT,
EDIT_DISK_RO,
EDIT_DISK_SHARE,
+EDIT_DISK_REMOVABLE,
EDIT_DISK_CACHE,
EDIT_DISK_IO,
EDIT_DISK_BUS,
@@ -94,7 +95,7 @@ EDIT_WATCHDOG_ACTION,
EDIT_CONTROLLER_MODEL,
EDIT_TPM_TYPE,
-) = range(1, 41)
+) = range(1, 42)
# Columns in hw list model
@@ -475,6 +476,7 @@ class vmmDetails(vmmGObjectUI):
"on_disk_readonly_changed": lambda *x: self.enable_apply(x, EDIT_DISK_RO),
"on_disk_shareable_changed": lambda *x: self.enable_apply(x, EDIT_DISK_SHARE),
+ "on_disk_removable_combo_changed": lambda *x: self.enable_apply(x, EDIT_DISK_REMOVABLE),
"on_disk_cache_combo_changed": lambda *x: self.enable_apply(x, EDIT_DISK_CACHE),
"on_disk_io_combo_changed": lambda *x: self.enable_apply(x, EDIT_DISK_IO),
"on_disk_bus_combo_changed": lambda *x: self.enable_apply(x, EDIT_DISK_BUS),
@@ -958,6 +960,10 @@ class vmmDetails(vmmGObjectUI):
if not (self.conn.is_qemu() or self.conn.is_test_conn()):
self.widget("iotune-expander").set_visible(False)
+ # Disk removable combo
+ disk_removable = self.widget("disk-removable")
+ uihelpers.build_disk_removable_combo(self.vm, disk_removable)
+
# Network source
net_source = self.widget("network-source")
net_bridge = self.widget("network-bridge-box")
@@ -2157,6 +2163,10 @@ class vmmDetails(vmmGObjectUI):
add_define(self.vm.define_disk_shareable,
dev_id_info, do_shareable)
+ if self.edited(EDIT_DISK_REMOVABLE):
+ do_removable = self.get_combo_entry("disk-removable")
+ add_define(self.vm.define_disk_removable, dev_id_info, do_removable)
+
if self.edited(EDIT_DISK_CACHE):
cache = self.get_combo_entry("disk-cache")
add_define(self.vm.define_disk_cache, dev_id_info, cache)
@@ -2797,6 +2807,7 @@ class vmmDetails(vmmGObjectUI):
ro = disk.read_only
share = disk.shareable
bus = disk.bus
+ removable = disk.removable
addr = disk.address.type
idx = disk.disk_bus_index
cache = disk.driver_cache
@@ -2828,6 +2839,7 @@ class vmmDetails(vmmGObjectUI):
is_cdrom = (devtype == virtinst.VirtualDisk.DEVICE_CDROM)
is_floppy = (devtype == virtinst.VirtualDisk.DEVICE_FLOPPY)
+ is_usb = (bus == "usb")
if addr == "spapr-vio":
bus = "spapr-vscsi"
@@ -2840,6 +2852,8 @@ class vmmDetails(vmmGObjectUI):
self.widget("disk-readonly").set_active(ro)
self.widget("disk-readonly").set_sensitive(not is_cdrom)
self.widget("disk-shareable").set_active(share)
+ self.set_combo_entry("disk-removable", removable)
+ self.widget("disk-removable").set_sensitive(is_usb and self.conn.is_qemu())
self.widget("disk-size").set_text(size)
self.set_combo_entry("disk-cache", cache)
self.set_combo_entry("disk-io", io)
diff --git a/virtManager/domain.py b/virtManager/domain.py
index b7c286e..1422cf9 100644
--- a/virtManager/domain.py
+++ b/virtManager/domain.py
@@ -647,6 +647,10 @@ class vmmDomain(vmmLibvirtObject):
def change(editdev):
editdev.shareable = do_shareable
return self._redefine_device(change, devobj)
+ def define_disk_removable(self, devobj, do_removable):
+ def change(editdev):
+ editdev.removable = do_removable
+ return self._redefine_device(change, devobj)
def define_disk_cache(self, devobj, new_cache):
def change(editdev):
editdev.driver_cache = new_cache or None
diff --git a/virtManager/uihelpers.py b/virtManager/uihelpers.py
index 1033858..b714881 100644
--- a/virtManager/uihelpers.py
+++ b/virtManager/uihelpers.py
@@ -395,6 +395,19 @@ def build_disk_bus_combo(vm, combo, no_default=False):
combo.set_active(-1)
+def build_disk_removable_combo(vm, combo):
+ ignore = vm
+ model = Gtk.ListStore(str, str)
+ combo.set_model(model)
+ set_combo_text_column(combo, 1)
+
+ options = [[None, _("default")],
+ ["on", _("on")],
+ ["off", _("off")]]
+ for opt in options:
+ model.append(opt)
+
+
def build_vnc_keymap_combo(vm, combo, no_default=False):
ignore = vm
model = Gtk.ListStore(str, str)
diff --git a/virtinst/devicedisk.py b/virtinst/devicedisk.py
index 79e92a8..cefc0c3 100644
--- a/virtinst/devicedisk.py
+++ b/virtinst/devicedisk.py
@@ -507,6 +507,7 @@ class VirtualDisk(VirtualDevice):
bus = XMLProperty("./target/@bus")
target = XMLProperty("./target/@dev")
+ removable = XMLProperty("./target/@removable")
read_only = XMLProperty("./readonly", is_bool=True)
shareable = XMLProperty("./shareable", is_bool=True)
--
1.7.10.4
More information about the virt-tools-list
mailing list