mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 01:34:11 +03:00
qemu_capabilities; Drop virQEMUCapsSetVAList
There is one specific caller (testInfoSetArgs() in qemuxml2argvtest.c) which expect the va_list argument to change after returning from the virQEMUCapsSetVAList() function. However, since we are passing plain va_list this is not guaranteed. The man page of stdarg(3) says: If ap is passed to a function that uses va_arg(ap,type), then the value of ap is undefined after the return of that function. (ap is a variable of type va_list) I've seen this in action in fact: on i686 the qemuxml2argvtest fails on the second test case because testInfoSetArgs() sees ARG_QEMU_CAPS and calls virQEMUCapsSetVAList to process the capabilities (in this case there's just one QEMU_CAPS_SECCOMP_BLACKLIST). But since the changes are not reflected in the caller, in the next iteration testInfoSetArgs() sees the QEMU capability and not ARG_END. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
598641f460
commit
087a74e160
@ -1663,24 +1663,15 @@ virQEMUCapsSet(virQEMUCapsPtr qemuCaps,
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
virQEMUCapsSetVAList(virQEMUCapsPtr qemuCaps,
|
||||
va_list list)
|
||||
{
|
||||
int flag;
|
||||
|
||||
while ((flag = va_arg(list, int)) < QEMU_CAPS_LAST)
|
||||
ignore_value(virBitmapSetBit(qemuCaps->flags, flag));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
virQEMUCapsSetList(virQEMUCapsPtr qemuCaps, ...)
|
||||
{
|
||||
va_list list;
|
||||
int flag;
|
||||
|
||||
va_start(list, qemuCaps);
|
||||
virQEMUCapsSetVAList(qemuCaps, list);
|
||||
while ((flag = va_arg(list, int)) < QEMU_CAPS_LAST)
|
||||
virQEMUCapsSet(qemuCaps, flag);
|
||||
va_end(list);
|
||||
}
|
||||
|
||||
|
@ -518,8 +518,6 @@ virQEMUCapsPtr virQEMUCapsNew(void);
|
||||
void virQEMUCapsSet(virQEMUCapsPtr qemuCaps,
|
||||
virQEMUCapsFlags flag) ATTRIBUTE_NONNULL(1);
|
||||
|
||||
void virQEMUCapsSetVAList(virQEMUCapsPtr qemuCaps,
|
||||
va_list list) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
||||
void virQEMUCapsSetList(virQEMUCapsPtr qemuCaps, ...) ATTRIBUTE_NONNULL(1);
|
||||
|
||||
void virQEMUCapsClear(virQEMUCapsPtr qemuCaps,
|
||||
|
@ -642,6 +642,7 @@ testInfoSetArgs(struct testInfo *info,
|
||||
char *capsarch = NULL;
|
||||
char *capsver = NULL;
|
||||
VIR_AUTOFREE(char *) capsfile = NULL;
|
||||
int flag;
|
||||
int ret = -1;
|
||||
|
||||
va_start(argptr, capslatest);
|
||||
@ -650,7 +651,10 @@ testInfoSetArgs(struct testInfo *info,
|
||||
case ARG_QEMU_CAPS:
|
||||
if (qemuCaps || !(qemuCaps = virQEMUCapsNew()))
|
||||
goto cleanup;
|
||||
virQEMUCapsSetVAList(qemuCaps, argptr);
|
||||
|
||||
while ((flag = va_arg(argptr, int)) < QEMU_CAPS_LAST)
|
||||
virQEMUCapsSet(qemuCaps, flag);
|
||||
|
||||
break;
|
||||
|
||||
case ARG_GIC:
|
||||
|
Loading…
Reference in New Issue
Block a user