mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-23 13:05:27 +00:00
qemu: Move TPMs validation out of PostParse
After previous cleanup, the qemuDomainDefTPMsPostParse() function does nothing more than validates TPM devices. Therefore, it should live in qemu_validate.c instead of qemu_domain.c. Move it there and rename to reflect the fact that the function is doing validation instead of PostParsing. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
2b3e8ddd9d
commit
99e2b670fa
@ -4583,37 +4583,6 @@ qemuDomainDefNumaCPUsPostParse(virDomainDef *def,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
|
||||||
qemuDomainDefTPMsPostParse(virDomainDef *def)
|
|
||||||
{
|
|
||||||
virDomainTPMDef *proxyTPM = NULL;
|
|
||||||
virDomainTPMDef *regularTPM = NULL;
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
for (i = 0; i < def->ntpms; i++) {
|
|
||||||
virDomainTPMDef *tpm = def->tpms[i];
|
|
||||||
|
|
||||||
if (tpm->model == VIR_DOMAIN_TPM_MODEL_SPAPR_PROXY) {
|
|
||||||
if (proxyTPM) {
|
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
||||||
_("only a single TPM Proxy device is supported"));
|
|
||||||
return -1;
|
|
||||||
} else {
|
|
||||||
proxyTPM = tpm;
|
|
||||||
}
|
|
||||||
} else if (regularTPM) {
|
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
||||||
_("only a single TPM non-proxy device is supported"));
|
|
||||||
return -1;
|
|
||||||
} else {
|
|
||||||
regularTPM = tpm;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuDomainDefPostParseBasic(virDomainDef *def,
|
qemuDomainDefPostParseBasic(virDomainDef *def,
|
||||||
void *opaque G_GNUC_UNUSED)
|
void *opaque G_GNUC_UNUSED)
|
||||||
@ -4710,9 +4679,6 @@ qemuDomainDefPostParse(virDomainDef *def,
|
|||||||
if (qemuDomainDefNumaCPUsPostParse(def, qemuCaps) < 0)
|
if (qemuDomainDefNumaCPUsPostParse(def, qemuCaps) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (qemuDomainDefTPMsPostParse(def) < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1113,6 +1113,37 @@ qemuValidateDomainDefPanic(const virDomainDef *def,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemuValidateDomainDefTPMs(const virDomainDef *def)
|
||||||
|
{
|
||||||
|
const virDomainTPMDef *proxyTPM = NULL;
|
||||||
|
const virDomainTPMDef *regularTPM = NULL;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < def->ntpms; i++) {
|
||||||
|
virDomainTPMDef *tpm = def->tpms[i];
|
||||||
|
|
||||||
|
if (tpm->model == VIR_DOMAIN_TPM_MODEL_SPAPR_PROXY) {
|
||||||
|
if (proxyTPM) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
|
_("only a single TPM Proxy device is supported"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
proxyTPM = tpm;
|
||||||
|
} else {
|
||||||
|
if (regularTPM) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
|
_("only a single TPM non-proxy device is supported"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
regularTPM = tpm;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
qemuValidateLifecycleAction(virDomainLifecycleAction onPoweroff,
|
qemuValidateLifecycleAction(virDomainLifecycleAction onPoweroff,
|
||||||
virDomainLifecycleAction onReboot,
|
virDomainLifecycleAction onReboot,
|
||||||
@ -1310,6 +1341,9 @@ qemuValidateDomainDef(const virDomainDef *def,
|
|||||||
if (qemuValidateDomainDefPanic(def, qemuCaps) < 0)
|
if (qemuValidateDomainDefPanic(def, qemuCaps) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
if (qemuValidateDomainDefTPMs(def) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
if (def->sec) {
|
if (def->sec) {
|
||||||
switch ((virDomainLaunchSecurity) def->sec->sectype) {
|
switch ((virDomainLaunchSecurity) def->sec->sectype) {
|
||||||
case VIR_DOMAIN_LAUNCH_SECURITY_SEV:
|
case VIR_DOMAIN_LAUNCH_SECURITY_SEV:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user