]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu_capabilities; Drop virQEMUCapsSetVAList
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 27 Mar 2019 16:19:37 +0000 (17:19 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 28 Mar 2019 08:54:23 +0000 (09:54 +0100)
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>
src/qemu/qemu_capabilities.c
src/qemu/qemu_capabilities.h
tests/qemuxml2argvtest.c

index c5954edaf048b0367e1b3d6b61d60a247d32b7c5..56228e7a36e78ad2ff52a5e83d4af144deea9528 100644 (file)
@@ -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);
 }
 
index 7625d754a390654ab7f544d118dafe15ebb8c685..06c7606e2f2deaaf8abb847452cfa987494b4444 100644 (file)
@@ -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,
index 6e7d1b0b9a8bc3a7c0ea269a099d4649c28db9af..4d6e4b0d39dc424685ca337c59707f334ec6f271 100644 (file)
@@ -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: