[virt-tools-list] [PATCH v2 4/6] addhardware: learn to set emulated TPM version

Stefan Berger stefanb at linux.vnet.ibm.com
Fri Jun 8 21:42:42 UTC 2018


From: Marc-André Lureau <marcandre.lureau at redhat.com>

Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
---
 ui/addhardware.ui          | 24 ++++++++++++++++++++++++
 virtManager/addhardware.py | 20 +++++++++++++++++---
 2 files changed, 41 insertions(+), 3 deletions(-)

diff --git a/ui/addhardware.ui b/ui/addhardware.ui
index b4cc35ea..4c266826 100644
--- a/ui/addhardware.ui
+++ b/ui/addhardware.ui
@@ -1477,6 +1477,30 @@
                                 <property name="top_attach">0</property>
                               </packing>
                             </child>
+                            <child>
+                              <object class="GtkLabel" id="tpm-version-label">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="halign">end</property>
+                                <property name="label" translatable="yes">_Version:</property>
+                                <property name="use_underline">True</property>
+                                <property name="mnemonic_widget">tpm-version</property>
+                              </object>
+                              <packing>
+                                <property name="left_attach">0</property>
+                                <property name="top_attach">3</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkComboBox" id="tpm-version">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                              </object>
+                              <packing>
+                                <property name="left_attach">1</property>
+                                <property name="top_attach">3</property>
+                              </packing>
+                            </child>
                             <child internal-child="accessible">
                               <object class="AtkObject" id="table12-atkobject">
                                 <property name="AtkObject::accessible-name">tpm-tab</property>
diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py
index 901ed5fb..6fd6a5eb 100644
--- a/virtManager/addhardware.py
+++ b/virtManager/addhardware.py
@@ -684,6 +684,10 @@ class vmmAddHardware(vmmGObjectUI):
         for t in DeviceTpm.MODELS:
             values.append([t, DeviceTpm.get_pretty_model(t)])
         _build_combo(self.widget("tpm-model"), values)
+        values = []
+        for t in DeviceTpm.VERSIONS:
+            values.append([t, t])
+        _build_combo(self.widget("tpm-version"), values)
 
 
     def _build_panic_model_combo(self):
@@ -897,6 +901,7 @@ class vmmAddHardware(vmmGObjectUI):
 
         tpm_widget_mappings = {
             "device_path": "tpm-device-path",
+            "version": "tpm-version",
         }
 
         self._dev = DeviceTpm(self.conn.get_backend())
@@ -1446,10 +1451,19 @@ class vmmAddHardware(vmmGObjectUI):
         typ = uiutil.get_list_selection(self.widget("tpm-type"))
         model = uiutil.get_list_selection(self.widget("tpm-model"))
         device_path = self.widget("tpm-device-path").get_text()
+        version = uiutil.get_list_selection(self.widget("tpm-version"))
+
+        value_mappings = {
+            "type": typ,
+            "model": model,
+            "device_path": device_path,
+            "version": version,
+        }
+
         self._dev = DeviceTpm(self.conn.get_backend())
-        self._dev.type = typ
-        self._dev.model = model
-        self._dev.device_path = device_path
+        for param_name, val in value_mappings.items():
+            if self._dev.supports_property(param_name) and val is not None:
+                setattr(self._dev, param_name, val)
 
     def _validate_page_panic(self):
         model = uiutil.get_list_selection(self.widget("panic-model"))
-- 
2.14.4




More information about the virt-tools-list mailing list