diff --git a/tests/testdriver.xml b/tests/testdriver.xml index d96898ed4..c2ff97754 100644 --- a/tests/testdriver.xml +++ b/tests/testdriver.xml @@ -551,6 +551,30 @@ + + test-tpm-passthrough + 0d2b6da9-3dba-42f2-b3ff-0a5341edf31f + 8388608 + 2097152 + 2 + + hvm + + + + destroy + restart + destroy + + + + + + + + + + diff --git a/ui/vmm-details.ui b/ui/vmm-details.ui index 81c2d5380..e2374563b 100644 --- a/ui/vmm-details.ui +++ b/ui/vmm-details.ui @@ -5667,6 +5667,126 @@ I/O: False + + + True + False + 12 + + + True + False + 0 + none + + + True + False + 3 + 12 + + + True + False + 3 + 2 + 2 + 8 + 4 + + + True + False + 0 + 2 + tpm-dev-type + + + 1 + 2 + GTK_FILL + + + + + + True + False + 1 + 2 + T_ype: + True + + + GTK_FILL + + + + + + True + False + 1 + 2 + Device path: + + + 1 + 2 + GTK_FILL + + + + + + True + False + 0 + tpm-device-path + + + 1 + 2 + 1 + 2 + GTK_FILL + + + + + + + + + + True + False + <b>TPM Device</b> + True + + + + + True + True + 0 + + + + + 18 + + + + + True + False + tpm + + + 11 + + True diff --git a/virtManager/details.py b/virtManager/details.py index 9a688198a..37f3b4c9c 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 @@ -500,6 +503,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, @@ -1334,6 +1340,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: @@ -2060,6 +2068,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: @@ -2372,6 +2382,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() @@ -3208,6 +3230,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: @@ -3644,6 +3690,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 bd3d964b7..7ead27204 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)