From nobody Sun May 5 13:30:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1553705487658554.159125689398; Wed, 27 Mar 2019 09:51:27 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3C11C30B24E7; Wed, 27 Mar 2019 16:51:26 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 125C560CC0; Wed, 27 Mar 2019 16:51:26 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id BEC5141F3D; Wed, 27 Mar 2019 16:51:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x2RGpAot010340 for ; Wed, 27 Mar 2019 12:51:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id C50D7282D5; Wed, 27 Mar 2019 16:51:10 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id CAC4727CD0; Wed, 27 Mar 2019 16:51:09 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 27 Mar 2019 17:50:45 +0100 Message-Id: <8a66d59cdf64222948ad0645a4adfa6a982338ad.1553705181.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 1/2] qemu_capabilities; Drop virQEMUCapsSetVAList X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Wed, 27 Mar 2019 16:51:26 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_capabilities.c | 15 +++------------ src/qemu/qemu_capabilities.h | 2 -- tests/qemuxml2argvtest.c | 6 +++++- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index c5954edaf0..56228e7a36 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -1663,24 +1663,15 @@ virQEMUCapsSet(virQEMUCapsPtr qemuCaps, } =20 =20 -void -virQEMUCapsSetVAList(virQEMUCapsPtr qemuCaps, - va_list list) -{ - int flag; - - while ((flag =3D va_arg(list, int)) < QEMU_CAPS_LAST) - ignore_value(virBitmapSetBit(qemuCaps->flags, flag)); -} - - void virQEMUCapsSetList(virQEMUCapsPtr qemuCaps, ...) { va_list list; + int flag; =20 va_start(list, qemuCaps); - virQEMUCapsSetVAList(qemuCaps, list); + while ((flag =3D va_arg(list, int)) < QEMU_CAPS_LAST) + virQEMUCapsSet(qemuCaps, flag); va_end(list); } =20 diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 7625d754a3..06c7606e2f 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -518,8 +518,6 @@ virQEMUCapsPtr virQEMUCapsNew(void); void virQEMUCapsSet(virQEMUCapsPtr qemuCaps, virQEMUCapsFlags flag) ATTRIBUTE_NONNULL(1); =20 -void virQEMUCapsSetVAList(virQEMUCapsPtr qemuCaps, - va_list list) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NON= NULL(2); void virQEMUCapsSetList(virQEMUCapsPtr qemuCaps, ...) ATTRIBUTE_NONNULL(1); =20 void virQEMUCapsClear(virQEMUCapsPtr qemuCaps, diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 6e7d1b0b9a..4d6e4b0d39 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -642,6 +642,7 @@ testInfoSetArgs(struct testInfo *info, char *capsarch =3D NULL; char *capsver =3D NULL; VIR_AUTOFREE(char *) capsfile =3D NULL; + int flag; int ret =3D -1; =20 va_start(argptr, capslatest); @@ -650,7 +651,10 @@ testInfoSetArgs(struct testInfo *info, case ARG_QEMU_CAPS: if (qemuCaps || !(qemuCaps =3D virQEMUCapsNew())) goto cleanup; - virQEMUCapsSetVAList(qemuCaps, argptr); + + while ((flag =3D va_arg(argptr, int)) < QEMU_CAPS_LAST) + virQEMUCapsSet(qemuCaps, flag); + break; =20 case ARG_GIC: --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 13:30:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1553705478263437.5308856869708; Wed, 27 Mar 2019 09:51:18 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A659630BC644; Wed, 27 Mar 2019 16:51:16 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 843711001DD4; Wed, 27 Mar 2019 16:51:16 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 46BF61803388; Wed, 27 Mar 2019 16:51:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x2RGpDdd010347 for ; Wed, 27 Mar 2019 12:51:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id B63DE27CBC; Wed, 27 Mar 2019 16:51:13 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id C11FC282D5; Wed, 27 Mar 2019 16:51:10 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 27 Mar 2019 17:50:46 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 2/2] qemuxml2argvtest: Drop dependency between testInfoArgName and virQEMUCapsFlags enums X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Wed, 27 Mar 2019 16:51:17 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Introduced in fdf6c89ee7b, this dependency looks weird. It was needed because of the way that while() loop was written - it fetches next argument in every iteration. Therefore, our only option was for ARG_END to have the same value as QEMU_CAPS_LAST. This also meant that QEMU_CAPS_* could have been only at the end of the __VA_ARGS__. This commit reworks the while() loop and removes the dependency. Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- tests/qemuxml2argvtest.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 4d6e4b0d39..0c0dcae197 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -616,19 +616,7 @@ typedef enum { ARG_PARSEFLAGS, ARG_CAPS_ARCH, ARG_CAPS_VER, - - /* ARG_END is our va_args sentinel. The value QEMU_CAPS_LATEST is - * necessary to handle the DO_TEST(..., NONE) case, which through macro - * magic will give the va_args list: - * - * ARG_QEMU_CAPS, NONE, QEMU_CAPS_LAST, ARG_END - * - * SetArgs consumes the first item, hands off control to virQEMUCapsX - * virQEMUCapsX sees NONE aka QEMU_CAPS_LAST, returns to SetArgs. - * SetArgs sees QEMU_CAPS_LAST aka ARG_END, and exits the parse loop. - * If ARG_END !=3D QEMU_CAPS_LAST, this last step would generate an er= ror. - */ - ARG_END =3D QEMU_CAPS_LAST, + ARG_END, } testInfoArgName; =20 static int @@ -646,7 +634,8 @@ testInfoSetArgs(struct testInfo *info, int ret =3D -1; =20 va_start(argptr, capslatest); - while ((argname =3D va_arg(argptr, testInfoArgName)) < ARG_END) { + argname =3D va_arg(argptr, testInfoArgName); + while (argname !=3D ARG_END) { switch (argname) { case ARG_QEMU_CAPS: if (qemuCaps || !(qemuCaps =3D virQEMUCapsNew())) @@ -655,6 +644,22 @@ testInfoSetArgs(struct testInfo *info, while ((flag =3D va_arg(argptr, int)) < QEMU_CAPS_LAST) virQEMUCapsSet(qemuCaps, flag); =20 + /* Some tests are run with NONE capabilities, which is just + * another name for QEMU_CAPS_LAST. If that is the case the + * arguments look like this : + * + * ARG_QEMU_CAPS, NONE, QEMU_CAPS_LAST, ARG_END + * + * Fetch one argument more and if it is QEMU_CAPS_LAST then + * break from the switch() to force getting next argument + * in the line. If it is not QEMU_CAPS_LAST then we've + * fetched real ARG_* and we must process it. + */ + if ((flag =3D va_arg(argptr, int)) !=3D QEMU_CAPS_LAST) { + argname =3D flag; + continue; + } + break; =20 case ARG_GIC: @@ -690,6 +695,8 @@ testInfoSetArgs(struct testInfo *info, fprintf(stderr, "Unexpected test info argument"); goto cleanup; } + + argname =3D va_arg(argptr, testInfoArgName); } =20 if (!!capsarch ^ !!capsver) { --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list