mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 17:34:18 +03:00
qemu: Extend QEMU with tpm-spapr support
Extend QEMU with tpm-spapr support. Assign a device address to the vTPM device model. Signed-off-by: Stefan Berger <stefanb@linux.ibm.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Signed-off-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
20d9340268
commit
12fcdede80
@ -9064,15 +9064,19 @@ qemuBuildDomainLoaderCommandLine(virCommandPtr cmd,
|
||||
|
||||
|
||||
static char *
|
||||
qemuBuildTPMDevStr(const virDomainDef *def)
|
||||
qemuBuildTPMDevStr(const virDomainDef *def,
|
||||
virQEMUCapsPtr qemuCaps)
|
||||
{
|
||||
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||
const virDomainTPMDef *tpm = def->tpm;
|
||||
virDomainTPMDef *tpm = def->tpm;
|
||||
const char *model = virDomainTPMModelTypeToString(tpm->model);
|
||||
|
||||
virBufferAsprintf(&buf, "%s,tpmdev=tpm-%s,id=%s",
|
||||
model, tpm->info.alias, tpm->info.alias);
|
||||
|
||||
if (qemuBuildDeviceAddressStr(&buf, def, &tpm->info, qemuCaps) < 0)
|
||||
return NULL;
|
||||
|
||||
return virBufferContentAndReset(&buf);
|
||||
}
|
||||
|
||||
@ -9162,7 +9166,8 @@ qemuBuildTPMBackendStr(const virDomainDef *def,
|
||||
|
||||
static int
|
||||
qemuBuildTPMCommandLine(virCommandPtr cmd,
|
||||
const virDomainDef *def)
|
||||
const virDomainDef *def,
|
||||
virQEMUCapsPtr qemuCaps)
|
||||
{
|
||||
char *optstr;
|
||||
g_autofree char *chardev = NULL;
|
||||
@ -9202,7 +9207,7 @@ qemuBuildTPMCommandLine(virCommandPtr cmd,
|
||||
VIR_FREE(fdset);
|
||||
}
|
||||
|
||||
if (!(optstr = qemuBuildTPMDevStr(def)))
|
||||
if (!(optstr = qemuBuildTPMDevStr(def, qemuCaps)))
|
||||
return -1;
|
||||
|
||||
virCommandAddArgList(cmd, "-device", optstr, NULL);
|
||||
@ -9918,7 +9923,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
|
||||
chardevStdioLogd) < 0)
|
||||
return NULL;
|
||||
|
||||
if (qemuBuildTPMCommandLine(cmd, def) < 0)
|
||||
if (qemuBuildTPMCommandLine(cmd, def, qemuCaps) < 0)
|
||||
return NULL;
|
||||
|
||||
if (qemuBuildInputCommandLine(cmd, def, qemuCaps) < 0)
|
||||
|
@ -7798,6 +7798,8 @@ qemuDomainDeviceDefValidateTPM(virDomainTPMDef *tpm,
|
||||
flag = QEMU_CAPS_DEVICE_TPM_CRB;
|
||||
break;
|
||||
case VIR_DOMAIN_TPM_MODEL_SPAPR:
|
||||
flag = QEMU_CAPS_DEVICE_TPM_SPAPR;
|
||||
break;
|
||||
case VIR_DOMAIN_TPM_MODEL_LAST:
|
||||
default:
|
||||
virReportEnumRangeError(virDomainTPMModel, tpm->model);
|
||||
|
@ -35,6 +35,7 @@ VIR_LOG_INIT("qemu.qemu_domain_address");
|
||||
#define VIO_ADDR_SCSI 0x2000ul
|
||||
#define VIO_ADDR_SERIAL 0x30000000ul
|
||||
#define VIO_ADDR_NVRAM 0x3000ul
|
||||
#define VIO_ADDR_TPM 0x4000ul
|
||||
|
||||
|
||||
/**
|
||||
@ -267,6 +268,14 @@ qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (def->tpm) {
|
||||
if (qemuDomainIsPSeries(def))
|
||||
def->tpm->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO;
|
||||
if (qemuDomainAssignSpaprVIOAddress(def, &def->tpm->info,
|
||||
VIO_ADDR_TPM) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* No other devices are currently supported on spapr-vio */
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user