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>
}
-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);
}
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,
char *capsarch = NULL;
char *capsver = NULL;
VIR_AUTOFREE(char *) capsfile = NULL;
+ int flag;
int ret = -1;
va_start(argptr, capslatest);
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: