[virt-tools-list] [PATCH] virt-manager: add support for iotune

David Shane Holden dpejesh at yahoo.com
Sun Feb 17 13:40:37 UTC 2013


---
 src/virtManager/details.py |   85 ++++++++++++++-
 src/virtManager/domain.py  |   30 +++++
 src/vmm-details.ui         |  261 +++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 374 insertions(+), 2 deletions(-)

diff --git a/src/virtManager/details.py b/src/virtManager/details.py
index aeff71d..b29bf3d 100644
--- a/src/virtManager/details.py
+++ b/src/virtManager/details.py
@@ -51,7 +51,7 @@ _comboentry_xml = """
 """
 
 # Parameters that can be editted in the details window
-EDIT_TOTAL = 36
+EDIT_TOTAL = 37
 (EDIT_NAME,
 EDIT_ACPI,
 EDIT_APIC,
@@ -80,6 +80,7 @@ EDIT_DISK_IO,
 EDIT_DISK_BUS,
 EDIT_DISK_SERIAL,
 EDIT_DISK_FORMAT,
+EDIT_DISK_IOTUNE,
 
 EDIT_SOUND_MODEL,
 
@@ -444,6 +445,8 @@ class vmmDetails(vmmGObjectUI):
             "on_disk_bus_combo_changed": (self.enable_apply, EDIT_DISK_BUS),
             "on_disk_format_changed": (self.enable_apply, EDIT_DISK_FORMAT),
             "on_disk_serial_changed": (self.enable_apply, EDIT_DISK_SERIAL),
+            
+            "on_disk_iotune_changed": self.iotune_changed,
 
             "on_network_source_combo_changed": (self.enable_apply,
                                                 EDIT_NET_SOURCE),
@@ -936,6 +939,10 @@ class vmmDetails(vmmGObjectUI):
         # Disk bus combo
         disk_bus = self.widget("disk-bus-combo")
         uihelpers.build_disk_bus_combo(self.vm, disk_bus)
+        
+        # Disk iotune expander
+        if not self.conn.is_qemu():
+            self.widget("iotune-expander").set_property("visible", False)
 
         # Network source
         net_source = self.widget("network-source-combo")
@@ -1869,6 +1876,52 @@ class vmmDetails(vmmGObjectUI):
 
         self.repopulate_boot_list(boot_devs, boot_selection)
         self.enable_apply(EDIT_BOOTORDER)
+    
+    # IO Tuning
+    def iotune_changed(self, ignore):
+        iotune_read_bytes_sec = int(self.get_text("disk-iotune-read-bytes-sec") or 0)
+        iotune_read_iops_sec = int(self.get_text("disk-iotune-read-iops-sec") or 0)
+        iotune_total_bytes_sec = int(self.get_text("disk-iotune-total-bytes-sec") or 0)
+        iotune_total_iops_sec = int(self.get_text("disk-iotune-total-iops-sec") or 0)
+        iotune_write_bytes_sec = int(self.get_text("disk-iotune-write-bytes-sec") or 0)
+        iotune_write_iops_sec = int(self.get_text("disk-iotune-write-iops-sec") or 0)
+        
+        # libvirt doesn't support having read/write settings along side total
+        # settings, so disable the widgets accordingly.
+        
+        if (iotune_read_bytes_sec > 0 or iotune_write_bytes_sec > 0):
+            iotune_total_bytes_sec = int(0)
+            self.widget("disk-iotune-total-bytes-sec").get_adjustment().value = int(0)
+            self.widget("disk-iotune-total-bytes-sec").set_sensitive(False)
+        else:
+            self.widget("disk-iotune-total-bytes-sec").set_sensitive(True)
+        
+        if (iotune_total_bytes_sec > 0):
+            self.widget("disk-iotune-read-bytes-sec").get_adjustment().value = int(0)
+            self.widget("disk-iotune-write-bytes-sec").get_adjustment().value = int(0)
+            self.widget("disk-iotune-read-bytes-sec").set_sensitive(False)
+            self.widget("disk-iotune-write-bytes-sec").set_sensitive(False)
+        else:
+            self.widget("disk-iotune-read-bytes-sec").set_sensitive(True)
+            self.widget("disk-iotune-write-bytes-sec").set_sensitive(True)
+        
+        if (iotune_read_iops_sec > 0 or iotune_write_iops_sec > 0):
+            iotune_total_iops_sec = int(0)
+            self.widget("disk-iotune-total-iops-sec").get_adjustment().value = int(0)
+            self.widget("disk-iotune-total-iops-sec").set_sensitive(False)
+        else:
+            self.widget("disk-iotune-total-iops-sec").set_sensitive(True)
+        
+        if (iotune_total_iops_sec > 0):
+            self.widget("disk-iotune-read-iops-sec").get_adjustment().value = int(0)
+            self.widget("disk-iotune-write-iops-sec").get_adjustment().value = int(0)
+            self.widget("disk-iotune-read-iops-sec").set_sensitive(False)
+            self.widget("disk-iotune-write-iops-sec").set_sensitive(False)
+        else:
+            self.widget("disk-iotune-read-iops-sec").set_sensitive(True)
+            self.widget("disk-iotune-write-iops-sec").set_sensitive(True)
+        
+        self.enable_apply(EDIT_DISK_IOTUNE)
 
     # CDROM Eject/Connect
     def toggle_storage_media(self, src_ignore):
@@ -2215,6 +2268,21 @@ class vmmDetails(vmmGObjectUI):
         if self.editted(EDIT_DISK_SERIAL):
             serial = self.get_text("disk-serial")
             add_define(self.vm.define_disk_serial, dev_id_info, serial)
+        
+        if self.editted(EDIT_DISK_IOTUNE):
+            iotune_read_bytes_sec = int(self.widget("disk-iotune-read-bytes-sec").get_adjustment().value * 1024)
+            iotune_read_iops_sec = int(self.widget("disk-iotune-read-iops-sec").get_adjustment().value)
+            iotune_total_bytes_sec = int(self.widget("disk-iotune-total-bytes-sec").get_adjustment().value * 1024)
+            iotune_total_iops_sec = int(self.widget("disk-iotune-total-iops-sec").get_adjustment().value)
+            iotune_write_bytes_sec = int(self.widget("disk-iotune-write-bytes-sec").get_adjustment().value * 1024)
+            iotune_write_iops_sec = int(self.widget("disk-iotune-write-iops-sec").get_adjustment().value)
+            
+            add_define(self.vm.define_disk_iotune_read_bytes_sec, dev_id_info, iotune_read_bytes_sec)
+            add_define(self.vm.define_disk_iotune_read_iops_sec, dev_id_info, iotune_read_iops_sec)
+            add_define(self.vm.define_disk_iotune_total_bytes_sec, dev_id_info, iotune_total_bytes_sec)
+            add_define(self.vm.define_disk_iotune_total_iops_sec, dev_id_info, iotune_total_iops_sec)
+            add_define(self.vm.define_disk_iotune_write_bytes_sec, dev_id_info, iotune_write_bytes_sec)
+            add_define(self.vm.define_disk_iotune_write_iops_sec, dev_id_info, iotune_write_iops_sec)
 
         # Do this last since it can change uniqueness info of the dev
         if self.editted(EDIT_DISK_BUS):
@@ -2826,6 +2894,14 @@ class vmmDetails(vmmGObjectUI):
         io = disk.driver_io
         driver_type = disk.driver_type or ""
         serial = disk.serial
+        
+        iotune_read_bytes_sec = disk.iotune_read_bytes_sec / 1024
+        iotune_read_iops_sec = disk.iotune_read_iops_sec
+        iotune_total_bytes_sec = disk.iotune_total_bytes_sec / 1024
+        iotune_total_iops_sec = disk.iotune_total_iops_sec
+        iotune_write_bytes_sec = disk.iotune_write_bytes_sec / 1024
+        iotune_write_iops_sec = disk.iotune_write_iops_sec
+        
         show_format = (not self.is_customize_dialog or
                        disk.path_exists(disk.conn, disk.path))
 
@@ -2867,6 +2943,13 @@ class vmmDetails(vmmGObjectUI):
         self.populate_disk_bus_combo(devtype, no_default)
         self.set_combo_label("disk-bus", bus)
         self.widget("disk-serial").set_text(serial or "")
+        
+        self.widget("disk-iotune-read-bytes-sec").get_adjustment().value = iotune_read_bytes_sec
+        self.widget("disk-iotune-read-iops-sec").get_adjustment().value = iotune_read_iops_sec
+        self.widget("disk-iotune-total-bytes-sec").get_adjustment().value = iotune_total_bytes_sec
+        self.widget("disk-iotune-total-iops-sec").get_adjustment().value = iotune_total_iops_sec
+        self.widget("disk-iotune-write-bytes-sec").get_adjustment().value = iotune_write_bytes_sec
+        self.widget("disk-iotune-write-iops-sec").get_adjustment().value = iotune_write_iops_sec
 
         button = self.widget("config-cdrom-connect")
         if is_cdrom or is_floppy:
diff --git a/src/virtManager/domain.py b/src/virtManager/domain.py
index a8a7ea8..e0d1558 100644
--- a/src/virtManager/domain.py
+++ b/src/virtManager/domain.py
@@ -615,6 +615,36 @@ class vmmDomain(vmmLibvirtObject):
             if val != editdev.serial:
                 editdev.serial = val or None
         return self._redefine_device(change, devobj)
+    
+    def define_disk_iotune_read_bytes_sec(self, devobj, val):
+        def change(editdev):
+            editdev.iotune_read_bytes_sec = val
+        return self._redefine_device(change, devobj)
+    
+    def define_disk_iotune_read_iops_sec(self, devobj, val):
+        def change(editdev):
+            editdev.iotune_read_iops_sec = val
+        return self._redefine_device(change, devobj)
+    
+    def define_disk_iotune_total_bytes_sec(self, devobj, val):
+        def change(editdev):
+            editdev.iotune_total_bytes_sec = val
+        return self._redefine_device(change, devobj)
+    
+    def define_disk_iotune_total_iops_sec(self, devobj, val):
+        def change(editdev):
+            editdev.iotune_total_iops_sec = val
+        return self._redefine_device(change, devobj)
+    
+    def define_disk_iotune_write_bytes_sec(self, devobj, val):
+        def change(editdev):
+            editdev.iotune_write_bytes_sec = val
+        return self._redefine_device(change, devobj)
+    
+    def define_disk_iotune_write_iops_sec(self, devobj, val):
+        def change(editdev):
+            editdev.iotune_write_iops_sec = val
+        return self._redefine_device(change, devobj)
 
     # Network define methods
 
diff --git a/src/vmm-details.ui b/src/vmm-details.ui
index 39372d8..565808c 100644
--- a/src/vmm-details.ui
+++ b/src/vmm-details.ui
@@ -51,6 +51,30 @@
     <property name="step_increment">1</property>
     <property name="page_increment">2</property>
   </object>
+  <object class="GtkAdjustment" id="adjustment8">
+    <property name="upper">1000000000</property>
+    <property name="step_increment">1024</property>
+  </object>
+  <object class="GtkAdjustment" id="adjustment9">
+    <property name="upper">1000000000</property>
+    <property name="step_increment">10</property>
+  </object>
+  <object class="GtkAdjustment" id="adjustment10">
+    <property name="upper">1000000000</property>
+    <property name="step_increment">1024</property>
+  </object>
+  <object class="GtkAdjustment" id="adjustment11">
+    <property name="upper">1000000000</property>
+    <property name="step_increment">10</property>
+  </object>
+  <object class="GtkAdjustment" id="adjustment12">
+    <property name="upper">1000000000</property>
+    <property name="step_increment">1024</property>
+  </object>
+  <object class="GtkAdjustment" id="adjustment13">
+    <property name="upper">1000000000</property>
+    <property name="step_increment">10</property>
+  </object>
   <object class="GtkImage" id="image1">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
@@ -3994,7 +4018,7 @@ I/O:</property>
                                                   <object class="GtkTable" id="table11">
                                                     <property name="visible">True</property>
                                                     <property name="can_focus">False</property>
-                                                    <property name="n_rows">4</property>
+                                                    <property name="n_rows">5</property>
                                                     <property name="n_columns">2</property>
                                                     <property name="column_spacing">8</property>
                                                     <property name="row_spacing">3</property>
@@ -4277,6 +4301,241 @@ I/O:</property>
                                                         <property name="bottom_attach">4</property>
                                                       </packing>
                                                     </child>
+                                                    <child>
+                                                      <object class="GtkExpander" id="iotune-expander">
+                                                        <property name="visible">True</property>
+                                                        <property name="can_focus">True</property>
+                                                        <child>
+                                                          <object class="GtkTable" id="table20">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="halign">start</property>
+                                                            <property name="n_rows">4</property>
+                                                            <property name="n_columns">3</property>
+                                                            <property name="column_spacing">8</property>
+                                                            <property name="row_spacing">3</property>
+                                                            <child>
+                                                            <object class="GtkLabel" id="label80">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="xalign">1</property>
+                                                            <property name="label" translatable="yes">Read:</property>
+                                                            <property name="use_underline">True</property>
+                                                            </object>
+                                                            <packing>
+                                                            <property name="top_attach">1</property>
+                                                            <property name="bottom_attach">2</property>
+                                                            <property name="x_options">GTK_FILL</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <object class="GtkLabel" id="label82">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="xalign">1</property>
+                                                            <property name="label" translatable="yes">Write:</property>
+                                                            <property name="use_underline">True</property>
+                                                            </object>
+                                                            <packing>
+                                                            <property name="top_attach">2</property>
+                                                            <property name="bottom_attach">3</property>
+                                                            <property name="x_options">GTK_FILL</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <object class="GtkLabel" id="label84">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="xalign">1</property>
+                                                            <property name="xpad">2</property>
+                                                            <property name="use_underline">True</property>
+                                                            </object>
+                                                            <packing>
+                                                            <property name="x_options">GTK_FILL</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <object class="GtkLabel" id="label85">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="xalign">1</property>
+                                                            <property name="label" translatable="yes">Total:</property>
+                                                            <property name="use_underline">True</property>
+                                                            </object>
+                                                            <packing>
+                                                            <property name="top_attach">3</property>
+                                                            <property name="bottom_attach">4</property>
+                                                            <property name="x_options">GTK_FILL</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <object class="GtkLabel" id="label86">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="xalign">1</property>
+                                                            <property name="label" translatable="yes">KBytes/Sec</property>
+                                                            <property name="use_underline">True</property>
+                                                            <property name="max_width_chars">20</property>
+                                                            </object>
+                                                            <packing>
+                                                            <property name="left_attach">1</property>
+                                                            <property name="right_attach">2</property>
+                                                            <property name="x_options"></property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <object class="GtkLabel" id="label87">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="xalign">1</property>
+                                                            <property name="label" translatable="yes">IOPS/Sec</property>
+                                                            <property name="use_underline">True</property>
+                                                            <property name="max_width_chars">20</property>
+                                                            </object>
+                                                            <packing>
+                                                            <property name="left_attach">2</property>
+                                                            <property name="right_attach">3</property>
+                                                            <property name="x_options"></property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <object class="GtkSpinButton" id="disk-iotune-read-bytes-sec">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property name="invisible_char">●</property>
+                                                            <property name="width_chars">16</property>
+                                                            <property name="adjustment">adjustment8</property>
+                                                            <property name="climb_rate">1</property>
+                                                            <property name="numeric">True</property>
+                                                            <property name="update_policy">if-valid</property>
+                                                            <signal name="changed" handler="on_disk_iotune_changed" swapped="no"/>
+                                                            </object>
+                                                            <packing>
+                                                            <property name="left_attach">1</property>
+                                                            <property name="right_attach">2</property>
+                                                            <property name="top_attach">1</property>
+                                                            <property name="bottom_attach">2</property>
+                                                            <property name="x_options">GTK_FILL</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <object class="GtkSpinButton" id="disk-iotune-read-iops-sec">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property name="invisible_char">●</property>
+                                                            <property name="width_chars">16</property>
+                                                            <property name="adjustment">adjustment9</property>
+                                                            <property name="climb_rate">1</property>
+                                                            <property name="numeric">True</property>
+                                                            <property name="update_policy">if-valid</property>
+                                                            <signal name="changed" handler="on_disk_iotune_changed" swapped="no"/>
+                                                            </object>
+                                                            <packing>
+                                                            <property name="left_attach">2</property>
+                                                            <property name="right_attach">3</property>
+                                                            <property name="top_attach">1</property>
+                                                            <property name="bottom_attach">2</property>
+                                                            <property name="x_options">GTK_FILL</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <object class="GtkSpinButton" id="disk-iotune-write-bytes-sec">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property name="invisible_char">●</property>
+                                                            <property name="width_chars">16</property>
+                                                            <property name="adjustment">adjustment10</property>
+                                                            <property name="climb_rate">1</property>
+                                                            <property name="numeric">True</property>
+                                                            <property name="update_policy">if-valid</property>
+                                                            <signal name="changed" handler="on_disk_iotune_changed" swapped="no"/>
+                                                            </object>
+                                                            <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="x_options">GTK_FILL</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <object class="GtkSpinButton" id="disk-iotune-write-iops-sec">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property name="invisible_char">●</property>
+                                                            <property name="width_chars">16</property>
+                                                            <property name="adjustment">adjustment11</property>
+                                                            <property name="climb_rate">1</property>
+                                                            <property name="numeric">True</property>
+                                                            <property name="update_policy">if-valid</property>
+                                                            <signal name="changed" handler="on_disk_iotune_changed" swapped="no"/>
+                                                            </object>
+                                                            <packing>
+                                                            <property name="left_attach">2</property>
+                                                            <property name="right_attach">3</property>
+                                                            <property name="top_attach">2</property>
+                                                            <property name="bottom_attach">3</property>
+                                                            <property name="x_options">GTK_FILL</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <object class="GtkSpinButton" id="disk-iotune-total-bytes-sec">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property name="invisible_char">●</property>
+                                                            <property name="width_chars">16</property>
+                                                            <property name="adjustment">adjustment12</property>
+                                                            <property name="climb_rate">1</property>
+                                                            <property name="numeric">True</property>
+                                                            <property name="update_policy">if-valid</property>
+                                                            <signal name="changed" handler="on_disk_iotune_changed" swapped="no"/>
+                                                            </object>
+                                                            <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="x_options">GTK_FILL</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
+                                                            <object class="GtkSpinButton" id="disk-iotune-total-iops-sec">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property name="invisible_char">●</property>
+                                                            <property name="width_chars">16</property>
+                                                            <property name="adjustment">adjustment13</property>
+                                                            <property name="climb_rate">1</property>
+                                                            <property name="numeric">True</property>
+                                                            <property name="update_policy">if-valid</property>
+                                                            <signal name="changed" handler="on_disk_iotune_changed" swapped="no"/>
+                                                            </object>
+                                                            <packing>
+                                                            <property name="left_attach">2</property>
+                                                            <property name="right_attach">3</property>
+                                                            <property name="top_attach">3</property>
+                                                            <property name="bottom_attach">4</property>
+                                                            <property name="x_options">GTK_FILL</property>
+                                                            </packing>
+                                                            </child>
+                                                          </object>
+                                                        </child>
+                                                        <child type="label">
+                                                          <object class="GtkLabel" id="label83">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label" translatable="yes">IO _Tuning</property>
+                                                            <property name="use_underline">True</property>
+                                                            <property name="mnemonic_widget">iotune-expander</property>
+                                                          </object>
+                                                        </child>
+                                                      </object>
+                                                      <packing>
+                                                        <property name="right_attach">2</property>
+                                                        <property name="top_attach">4</property>
+                                                        <property name="bottom_attach">5</property>
+                                                      </packing>
+                                                    </child>
                                                   </object>
                                                 </child>
                                                 <child type="label">
-- 
1.7.10.4




More information about the virt-tools-list mailing list