static char *
qemuBuildTPMBackendStr(const virDomainDef *def,
virCommandPtr cmd,
- virQEMUCapsPtr qemuCaps,
int *tpmfd,
int *cancelfd,
char **chardev)
switch (tpm->type) {
case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
- if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_TPM_PASSTHROUGH))
- goto no_support;
-
tpmdev = tpm->data.passthrough.source.data.file.path;
if (!(cancel_path = virTPMCreateCancelPath(tpmdev)))
goto error;
break;
case VIR_DOMAIN_TPM_TYPE_EMULATOR:
- if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_TPM_EMULATOR))
- goto no_support;
-
virBufferAddLit(&buf, ",chardev=chrtpm");
if (virAsprintf(chardev, "socket,id=chrtpm,path=%s",
return virBufferContentAndReset(&buf);
- no_support:
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("The QEMU executable %s does not support TPM "
- "backend type %s"),
- def->emulator, type);
-
error:
VIR_FREE(devset);
VIR_FREE(cancel_path);
if (!def->tpm)
return 0;
- if (!(optstr = qemuBuildTPMBackendStr(def, cmd, qemuCaps,
+ if (!(optstr = qemuBuildTPMBackendStr(def, cmd,
&tpmfd, &cancelfd,
&chardev)))
return -1;
static int
qemuDomainDeviceDefValidateTPM(virDomainTPMDef *tpm,
- const virDomainDef *def ATTRIBUTE_UNUSED)
+ const virDomainDef *def,
+ virQEMUCapsPtr qemuCaps)
{
/* TPM 1.2 and 2 are not compatible, so we choose a specific version here */
if (tpm->version == VIR_DOMAIN_TPM_VERSION_DEFAULT)
case VIR_DOMAIN_TPM_VERSION_LAST:
break;
}
+
+ switch (tpm->type) {
+ case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_TPM_PASSTHROUGH))
+ goto no_support;
+ break;
+
+ case VIR_DOMAIN_TPM_TYPE_EMULATOR:
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_TPM_EMULATOR))
+ goto no_support;
+
+ break;
+ case VIR_DOMAIN_TPM_TYPE_LAST:
+ break;
+ }
+
return 0;
+
+ no_support:
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("The QEMU executable %s does not support TPM "
+ "backend type %s"),
+ def->emulator,
+ virDomainTPMBackendTypeToString(tpm->type));
+ return -1;
}
break;
case VIR_DOMAIN_DEVICE_TPM:
- ret = qemuDomainDeviceDefValidateTPM(dev->data.tpm, def);
+ ret = qemuDomainDeviceDefValidateTPM(dev->data.tpm, def, qemuCaps);
break;
case VIR_DOMAIN_DEVICE_GRAPHICS: