This patch wraps it up all the wiring done in previous patches,
enabling a PPC64 guest to launch a guest using a TPM Proxy
device.
Note that device validation is already being done in
qemu_validate.c, qemuValidateDomainDeviceDefTPMProxy(), on
domain define time. We don't need to verify QEMU capabilities for
this device again in qemu_command.c
Signed-off-by: Daniel Henrique Barboza <danielhb413(a)gmail.com>
---
src/libvirt_private.syms | 2 ++
src/qemu/qemu_alias.c | 16 ++++++++++++++++
src/qemu/qemu_command.c | 20 ++++++++++++++++++++
3 files changed, 38 insertions(+)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 935ef7303b..b242c6164e 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -636,6 +636,8 @@ virDomainTPMBackendTypeToString;
virDomainTPMDefFree;
virDomainTPMModelTypeFromString;
virDomainTPMModelTypeToString;
+virDomainTPMProxyModelTypeFromString;
+virDomainTPMProxyModelTypeToString;
virDomainUSBDeviceDefForeach;
virDomainVideoDefaultRAM;
virDomainVideoDefClear;
diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c
index b0ea62af39..b21d5bb514 100644
--- a/src/qemu/qemu_alias.c
+++ b/src/qemu/qemu_alias.c
@@ -413,6 +413,18 @@ qemuAssignDeviceTPMAlias(virDomainTPMDefPtr tpm,
}
+static int
+qemuAssignDeviceTPMProxyAlias(virDomainTPMProxyDefPtr tpmproxy,
+ int idx)
+{
+ if (tpmproxy->info.alias)
+ return 0;
+
+ tpmproxy->info.alias = g_strdup_printf("tpmproxy%d", idx);
+ return 0;
+}
+
+
int
qemuAssignDeviceRedirdevAlias(virDomainDefPtr def,
virDomainRedirdevDefPtr redirdev,
@@ -673,6 +685,10 @@ qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr
qemuCaps)
if (qemuAssignDeviceTPMAlias(def->tpm, 0) < 0)
return -1;
}
+ if (def->tpmproxy) {
+ if (qemuAssignDeviceTPMProxyAlias(def->tpmproxy, 0) < 0)
+ return -1;
+ }
for (i = 0; i < def->nmems; i++) {
if (qemuAssignDeviceMemoryAlias(NULL, def->mems[i], false) < 0)
return -1;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 9065164b1d..40a8505d24 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -9318,6 +9318,23 @@ qemuBuildTPMCommandLine(virCommandPtr cmd,
return 0;
}
+static int
+qemuBuildTPMProxyCommandLine(virCommandPtr cmd,
+ const virDomainDef *def)
+{
+ const virDomainTPMProxyDef *tpmproxy = def->tpmproxy;
+
+ if (!tpmproxy)
+ return 0;
+
+ virCommandAddArg(cmd, "-device");
+ virCommandAddArgFormat(cmd, "%s,id=%s,host-path=%s",
+ virDomainTPMProxyModelTypeToString(tpmproxy->model),
+ tpmproxy->info.alias, tpmproxy->path);
+
+ return 0;
+}
+
static int
qemuBuildSEVCommandLine(virDomainObjPtr vm, virCommandPtr cmd,
virDomainSEVDefPtr sev)
@@ -9999,6 +10016,9 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
if (qemuBuildTPMCommandLine(cmd, def, qemuCaps) < 0)
return NULL;
+ if (qemuBuildTPMProxyCommandLine(cmd, def) < 0)
+ return NULL;
+
if (qemuBuildInputCommandLine(cmd, def, qemuCaps) < 0)
return NULL;
--
2.26.2