mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 03:21:19 +00:00
qemu: qemuDomainSetLaunchSecurityState: check for params presence
We require the header and the secret to be present. Use a different approach to virParams to report an error if they are not present, instead of trying to pass empty arguments to QEMU via QMP. Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
d248e3dca8
commit
07ddb4c6b3
@ -19975,10 +19975,9 @@ qemuDomainSetLaunchSecurityState(virDomainPtr domain,
|
|||||||
virDomainObj *vm;
|
virDomainObj *vm;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
int rc;
|
int rc;
|
||||||
size_t i;
|
|
||||||
g_autoptr(virQEMUCaps) qemucaps = NULL;
|
g_autoptr(virQEMUCaps) qemucaps = NULL;
|
||||||
g_autofree char *secrethdr = NULL;
|
const char *secrethdr = NULL;
|
||||||
g_autofree char *secret = NULL;
|
const char *secret = NULL;
|
||||||
unsigned long long setaddr = 0;
|
unsigned long long setaddr = 0;
|
||||||
bool hasSetaddr = false;
|
bool hasSetaddr = false;
|
||||||
int state;
|
int state;
|
||||||
@ -20019,19 +20018,25 @@ qemuDomainSetLaunchSecurityState(virDomainPtr domain,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < nparams; i++) {
|
if (virTypedParamsGetString(params, nparams,
|
||||||
virTypedParameterPtr param = ¶ms[i];
|
VIR_DOMAIN_LAUNCH_SECURITY_SEV_SECRET_HEADER,
|
||||||
|
&secrethdr) < 0 ||
|
||||||
if (STREQ(param->field, VIR_DOMAIN_LAUNCH_SECURITY_SEV_SECRET_HEADER)) {
|
virTypedParamsGetString(params, nparams,
|
||||||
secrethdr = g_strdup(param->value.s);
|
VIR_DOMAIN_LAUNCH_SECURITY_SEV_SECRET,
|
||||||
} else if (STREQ(param->field, VIR_DOMAIN_LAUNCH_SECURITY_SEV_SECRET)) {
|
&secret) < 0) {
|
||||||
secret = g_strdup(param->value.s);
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
} else if (STREQ(param->field, VIR_DOMAIN_LAUNCH_SECURITY_SEV_SECRET_SET_ADDRESS)) {
|
"%s",
|
||||||
setaddr = param->value.ul;
|
_("Both secret and the secret header are required"));
|
||||||
hasSetaddr = true;
|
goto cleanup;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((rc = virTypedParamsGetULLong(params, nparams,
|
||||||
|
VIR_DOMAIN_LAUNCH_SECURITY_SEV_SECRET_SET_ADDRESS,
|
||||||
|
&setaddr)) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
else if (rc == 1)
|
||||||
|
hasSetaddr = true;
|
||||||
|
|
||||||
if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
|
if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user