[virt-tools-list] [virt-manager PATCH v2 3/4] Add GUI elements for TPM passthrough details
Stefan Berger
stefanb at linux.vnet.ibm.com
Wed Jun 26 01:45:08 UTC 2013
Signed-off-by: Stefan Berger <stefanb at linux.vnet.ibm.com>
---
tests/testdriver.xml | 24 ++++++++++
ui/vmm-details.ui | 120 +++++++++++++++++++++++++++++++++++++++++++++++++
virtManager/details.py | 57 +++++++++++++++++++++--
virtManager/domain.py | 10 +++++
4 files changed, 208 insertions(+), 3 deletions(-)
diff --git a/tests/testdriver.xml b/tests/testdriver.xml
index d96898e..c2ff977 100644
--- a/tests/testdriver.xml
+++ b/tests/testdriver.xml
@@ -551,6 +551,30 @@
</domain>
+<domain type='test'>
+ <name>test-tpm-passthrough</name>
+ <uuid>0d2b6da9-3dba-42f2-b3ff-0a5341edf31f</uuid>
+ <memory>8388608</memory>
+ <currentMemory>2097152</currentMemory>
+ <vcpu>2</vcpu>
+ <os>
+ <type arch='i686'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <tpm model='tpm-tis'>
+ <backend type='passthrough'>
+ <backend path='/dev/tpm0'/>
+ </backend>
+ </tpm>
+ </devices>
+</domain>
+
+
<!-- ######## -->
diff --git a/ui/vmm-details.ui b/ui/vmm-details.ui
index ea4b53e..8a99bca 100644
--- a/ui/vmm-details.ui
+++ b/ui/vmm-details.ui
@@ -5659,6 +5659,126 @@ I/O:</property>
</packing>
</child>
<child>
+ <object class="GtkVBox" id="vbox17">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkFrame" id="frame20">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment47">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="top_padding">3</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkTable" id="table200">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">3</property>
+ <property name="n_rows">2</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">8</property>
+ <property name="row_spacing">4</property>
+ <child>
+ <object class="GtkLabel" id="tpm-dev-type">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="ypad">2</property>
+ <property name="label" translatable="yes">tpm-dev-type</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"/>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label183">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="ypad">2</property>
+ <property name="label" translatable="yes">T_ype:</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"/>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="tpm-device-path-label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="ypad">2</property>
+ <property name="label" translatable="yes">Device path:</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"/>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="tpm-device-path">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">tpm-device-path</property>
+ </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>
+ <property name="y_options"/>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label180">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes"><b>TPM Device</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">18</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label182">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label">tpm</property>
+ </object>
+ <packing>
+ <property name="position">11</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkVBox" id="vbox59">
<property name="visible">True</property>
<property name="can_focus">False</property>
diff --git a/virtManager/details.py b/virtManager/details.py
index b2d496e..23b5310 100644
--- a/virtManager/details.py
+++ b/virtManager/details.py
@@ -43,7 +43,7 @@ import virtinst
# Parameters that can be editted in the details window
-EDIT_TOTAL = 37
+EDIT_TOTAL = 38
(EDIT_NAME,
EDIT_ACPI,
EDIT_APIC,
@@ -91,7 +91,9 @@ EDIT_VIDEO_MODEL,
EDIT_WATCHDOG_MODEL,
EDIT_WATCHDOG_ACTION,
-EDIT_CONTROLLER_MODEL
+EDIT_CONTROLLER_MODEL,
+
+EDIT_TPM_TYPE,
) = range(EDIT_TOTAL)
@@ -121,13 +123,14 @@ HW_LIST_TYPE_CONTROLLER = 14
HW_LIST_TYPE_FILESYSTEM = 15
HW_LIST_TYPE_SMARTCARD = 16
HW_LIST_TYPE_REDIRDEV = 17
+HW_LIST_TYPE_TPM = 18
remove_pages = [HW_LIST_TYPE_NIC, HW_LIST_TYPE_INPUT,
HW_LIST_TYPE_GRAPHICS, HW_LIST_TYPE_SOUND, HW_LIST_TYPE_CHAR,
HW_LIST_TYPE_HOSTDEV, HW_LIST_TYPE_DISK, HW_LIST_TYPE_VIDEO,
HW_LIST_TYPE_WATCHDOG, HW_LIST_TYPE_CONTROLLER,
HW_LIST_TYPE_FILESYSTEM, HW_LIST_TYPE_SMARTCARD,
- HW_LIST_TYPE_REDIRDEV]
+ HW_LIST_TYPE_REDIRDEV, HW_LIST_TYPE_TPM]
# Boot device columns
BOOT_DEV_TYPE = 0
@@ -499,6 +502,9 @@ class vmmDetails(vmmGObjectUI):
"on_smartcard_mode_combo_changed": lambda *x: self.enable_apply(x,
EDIT_SMARTCARD_MODE),
+ "on_tpm_type_combo_changed": (self.enable_apply,
+ EDIT_TPM_TYPE),
+
"on_config_apply_clicked": self.config_apply,
"on_config_cancel_clicked": self.config_cancel,
@@ -1333,6 +1339,8 @@ class vmmDetails(vmmGObjectUI):
self.refresh_smartcard_page()
elif pagetype == HW_LIST_TYPE_REDIRDEV:
self.refresh_redir_page()
+ elif pagetype == HW_LIST_TYPE_TPM:
+ self.refresh_tpm_page()
else:
pagetype = -1
except Exception, e:
@@ -2034,6 +2042,8 @@ class vmmDetails(vmmGObjectUI):
ret = self.config_smartcard_apply(key)
elif pagetype is HW_LIST_TYPE_CONTROLLER:
ret = self.config_controller_apply(key)
+ elif pagetype is HW_LIST_TYPE_TPM:
+ ret = self.config_tpm_apply(key)
else:
ret = False
except Exception, e:
@@ -2346,6 +2356,18 @@ class vmmDetails(vmmGObjectUI):
return self._change_config_helper(df, da, hf, ha)
+ # TPM options
+ def config_tpm_apply(self, dev_id_info):
+ df, da, add_define, hf, ha, add_hotplug = self.make_apply_data()
+ ignore = add_hotplug
+
+ if self.editted(EDIT_TPM_TYPE):
+ typ = self.get_combo_label_value("tpm-type")
+ if typ:
+ add_define(self.vm.define_tpm_type, dev_id_info, typ)
+
+ return self._change_config_helper(df, da, hf, ha)
+
# Network options
def config_network_apply(self, dev_id_info):
df, da, add_define, hf, ha, add_hotplug = self.make_apply_data()
@@ -3182,6 +3204,30 @@ class vmmDetails(vmmGObjectUI):
self.widget("redir-type-label").set_text(rd.type)
self.widget("redir-type-combo").hide()
+ def refresh_tpm_page(self):
+ tpmdev = self.get_hw_selection(HW_LIST_COL_DEVICE)
+ if not tpmdev:
+ return
+
+ def show_ui(param, val=None):
+ widgetname = "tpm-" + param.replace("_", "-")
+ labelname = widgetname + "-label"
+ doshow = tpmdev.supports_property(param)
+
+ if not val and doshow:
+ val = getattr(tpmdev, param)
+
+ self.widget(widgetname).set_property("visible", doshow)
+ self.widget(labelname).set_property("visible", doshow)
+ self.widget(widgetname).set_text(val or "-")
+
+ dev_type = tpmdev.type
+
+ self.widget("tpm-dev-type").set_text(dev_type)
+
+ # Device type specific properties, only show if apply to the cur dev
+ show_ui("device_path")
+
def refresh_char_page(self):
chardev = self.get_hw_selection(HW_LIST_COL_DEVICE)
if not chardev:
@@ -3618,6 +3664,11 @@ class vmmDetails(vmmGObjectUI):
update_hwlist(HW_LIST_TYPE_SMARTCARD, sc,
_("Smartcard"), "device_serial")
+ # Populate list of TPM devices
+ for tpm in self.vm.get_tpm_devices():
+ update_hwlist(HW_LIST_TYPE_TPM, tpm,
+ _("TPM"), "device_cpu")
+
devs = range(len(hw_list_model))
devs.reverse()
for i in devs:
diff --git a/virtManager/domain.py b/virtManager/domain.py
index bd3d964..7ead272 100644
--- a/virtManager/domain.py
+++ b/virtManager/domain.py
@@ -55,6 +55,7 @@ def compare_device(origdev, newdev, idx):
"filesystem" : ["target" , "vmmindex"],
"smartcard" : ["mode" , "vmmindex"],
"redirdev" : ["bus" , "type", "vmmindex"],
+ "tpm" : ["type" , "vmmindex"],
}
if id(origdev) == id(newdev):
@@ -824,6 +825,13 @@ class vmmDomain(vmmLibvirtObject):
return self._redefine_device(change, devobj)
+ # TPM define methods
+
+ def define_tpm_type(self, devobj, newtype):
+ def change(editdev):
+ editdev.type = newtype
+ return self._redefine_device(change, devobj)
+
####################
@@ -1079,6 +1087,8 @@ class vmmDomain(vmmLibvirtObject):
return self._build_device_list("smartcard")
def get_redirdev_devices(self):
return self._build_device_list("redirdev")
+ def get_tpm_devices(self):
+ return self._build_device_list("tpm")
def get_disk_devices(self, refresh_if_necc=True, inactive=False):
devs = self._build_device_list("disk", refresh_if_necc, inactive)
--
1.8.1.4
More information about the virt-tools-list
mailing list