[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[virt-tools-list] [PATCH v2 3/3] Add support for cpu host-passthrough mode



From: Ken ICHIKAWA <ichikawa ken jp fujitsu com>

We couldn't use host-passthrough mode for virtual cpu from
virt-manager so far. This patch enables virt-manager to
configure host-passthrough mode.

Signed-off-by: Ken ICHIKAWA <ichikawa ken jp fujitsu com>
---
 ui/vmm-details.ui      | 21 +++++++++++++++++++--
 virtManager/details.py | 23 ++++++++++++++++++++++-
 virtManager/domain.py  | 13 ++++++++++---
 3 files changed, 51 insertions(+), 6 deletions(-)

diff --git a/ui/vmm-details.ui b/ui/vmm-details.ui
index ad0652d..b1a70b3 100644
--- a/ui/vmm-details.ui
+++ b/ui/vmm-details.ui
@@ -2314,6 +2314,23 @@ I/O:</property>
                                             <property name="can_focus">False</property>
                                             <property name="spacing">6</property>
                                             <child>
+                                              <object class="GtkCheckButton" id="host-passthrough-enable">
+                                                <property name="label" translatable="yes">Use host-passthrough mode</property>
+                                                <property name="visible">True</property>
+                                                <property name="can_focus">True</property>
+                                                <property name="receives_default">False</property>
+                                                <property name="use_action_appearance">False</property>
+                                                <property name="active">True</property>
+                                                <property name="draw_indicator">True</property>
+                                                <signal name="toggled" handler="on_host_passthrough_enable_toggled" swapped="no"/>
+                                              </object>
+                                              <packing>
+                                                <property name="expand">True</property>
+                                                <property name="fill">True</property>
+                                                <property name="position">0</property>
+                                              </packing>
+                                            </child>
+                                            <child>
                                               <object class="GtkTable" id="table15">
                                                 <property name="visible">True</property>
                                                 <property name="can_focus">False</property>
@@ -2428,7 +2445,7 @@ I/O:</property>
                                               <packing>
                                                 <property name="expand">False</property>
                                                 <property name="fill">True</property>
-                                                <property name="position">0</property>
+                                                <property name="position">1</property>
                                               </packing>
                                             </child>
                                             <child>
@@ -2499,7 +2516,7 @@ I/O:</property>
                                               <packing>
                                                 <property name="expand">False</property>
                                                 <property name="fill">True</property>
-                                                <property name="position">1</property>
+                                                <property name="position">2</property>
                                               </packing>
                                             </child>
                                           </object>
diff --git a/virtManager/details.py b/virtManager/details.py
index bd772ce..1e07047 100644
--- a/virtManager/details.py
+++ b/virtManager/details.py
@@ -424,6 +424,7 @@ class vmmDetails(vmmGObjectUI):
             "on_cpu_threads_changed": lambda *x: self.enable_apply(x, EDIT_TOPOLOGY),
             "on_cpu_copy_host_clicked": self.config_cpu_copy_host,
             "on_cpu_topology_enable_toggled": self.config_cpu_topology_enable,
+            "on_host_passthrough_enable_toggled": self.config_host_passthrough_enable,
 
             "on_config_memory_changed": self.config_memory_changed,
             "on_config_maxmem_changed": self.config_maxmem_changed,
@@ -1822,6 +1823,13 @@ class vmmDetails(vmmGObjectUI):
         self.widget("cpu-topology-table").set_sensitive(do_enable)
         self.enable_apply(EDIT_TOPOLOGY)
 
+    def config_host_passthrough_enable(self, src):
+        do_enable = not src.get_active()
+        self.widget("cpu-copy-host").set_sensitive(do_enable)
+        self.widget("cpu-model").set_sensitive(do_enable)
+        self.widget("cpu-features").set_sensitive(do_enable)
+        self.enable_apply(EDIT_CPU)
+
     # Boot device / Autostart
     def config_bootdev_selected(self, ignore):
         boot_row = self.get_boot_selection()
@@ -2108,10 +2116,14 @@ class vmmDetails(vmmGObjectUI):
             add_hotplug(self.config_vcpu_pin_cpuset, cpuset)
 
         if self.editted(EDIT_CPU):
+            host_passthrough = self.widget("host-passthrough-enable").get_active()
+            mode = "custom"
+            if host_passthrough:
+                mode = "host-passthrough"
             model, vendor = self.get_config_cpu_model()
             features = self.get_config_cpu_features()
             add_define(self.vm.define_cpu,
-                       model, vendor, self._cpu_copy_host, features)
+                       mode, model, vendor, self._cpu_copy_host, features)
 
         if self.editted(EDIT_TOPOLOGY):
             do_top = self.widget("cpu-topology-enable").get_active()
@@ -2835,6 +2847,15 @@ class vmmDetails(vmmGObjectUI):
         self.widget("cpu-cores").set_value(cores)
         self.widget("cpu-threads").set_value(threads)
 
+        host_passthrough = False
+        if cpu.mode == "host-passthrough":
+            host_passthrough = True
+
+        self.widget("host-passthrough-enable").set_active(host_passthrough)
+        self.widget("cpu-copy-host").set_sensitive(not host_passthrough)
+        self.widget("cpu-model").set_sensitive(not host_passthrough)
+        self.widget("cpu-features").set_sensitive(not host_passthrough)
+
         def get_feature_policy(name):
             for f in cpu.features:
                 if f.name == name:
diff --git a/virtManager/domain.py b/virtManager/domain.py
index 4222553..b47feac 100644
--- a/virtManager/domain.py
+++ b/virtManager/domain.py
@@ -458,7 +458,8 @@ class vmmDomain(vmmLibvirtObject):
             cpu.cores = cores
             cpu.threads = threads
         return self._redefine_guest(change)
-    def define_cpu(self, model, vendor, from_host, featurelist):
+
+    def define_cpu(self, mode, model, vendor, from_host, featurelist):
         def change(guest):
             if from_host:
                 guest.cpu.copy_host_cpu()
@@ -467,8 +468,14 @@ class vmmDomain(vmmLibvirtObject):
                 # caps value
                 guest.cpu.vendor = vendor
 
-            guest.cpu.model = model or None
-            if guest.cpu.model is None:
+            guest.cpu.mode = mode
+            if mode == "custom":
+                guest.cpu.model = model or None
+            else:
+                guest.cpu.model = None
+
+            if guest.cpu.model == None:
+                guest.cpu.vendor = None
                 for f in guest.cpu.features:
                     guest.cpu.remove_feature(f)
                 return
-- 
1.8.1.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]