From nobody Sun Feb 8 22:24:51 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1629217566; cv=none; d=zohomail.com; s=zohoarc; b=R0B6K7XRW6saJnrhLPIWRNw85n9/gwRV08oUTyaAoULTq7HorN2R1yoUiVSuzglyaSneIZR0vsaYTldN1QAwvzewcVD8Gr9JbDhspXOcUn1ZnK6SgcnDT603J7V7WaIR9EuLaeTAHiQpNlnVX31iRafs58fzVtF3cjZUdQO2SVA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629217566; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9epfcXTzHvhsp6edOfvfMbrnvXYwKwngHbMLS8H8pjE=; b=BA81xR650Hwi0wdC9/OKQq8aHxgXiI9Z71dFZTq8IIaKpas+GW+wYWFYx1euaETtcVviAoHy8+UUkfuX/+PY+GZUbCgXLmgu7t7tA8KiLgML7Lh+kqGfv62274gL4+WMf7/Cet6h3hAmKTTI/OZVKInjiKRdxE+v71uhMh8pxw0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1629217566544107.55986296463539; Tue, 17 Aug 2021 09:26:06 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-57-uNemVXqpMO20Reowlp5YoQ-1; Tue, 17 Aug 2021 12:26:02 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 34649100CF6E; Tue, 17 Aug 2021 16:25:57 +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 1A6D56E6E1; Tue, 17 Aug 2021 16:25:57 +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 D8F23181A2A9; Tue, 17 Aug 2021 16:25:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17HGPai5020224 for ; Tue, 17 Aug 2021 12:25:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id 77063421F; Tue, 17 Aug 2021 16:25:36 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id D48F7620DE for ; Tue, 17 Aug 2021 16:25:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629217565; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=9epfcXTzHvhsp6edOfvfMbrnvXYwKwngHbMLS8H8pjE=; b=NihqGmEFEREVSbiEli3fGPUjI9QBqZZyzzZREQorpOxNsWne3UQQcntbW64cQwhuk/ERBv 7drjJ+Zx4lUe2xm6ndi3JYsj5RrwDmyyF8mzpedyEz95EzxJYw8qqkqFyD4ZZrHD5cv+DA c4A9WCN5Bmuz8PlPnv8XHOrkRxiHA7k= X-MC-Unique: uNemVXqpMO20Reowlp5YoQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v2 05/23] testQemuInfoSetArgs: Always allocate 'info->qemuCaps' Date: Tue, 17 Aug 2021 18:25:06 +0200 Message-Id: <5ea3ed7863adac48234e3c14658053fec6cbee30.1629217367.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1629217567157100004 Content-Type: text/plain; charset="utf-8" Modify the logic so that 'info->qemuCaps' is populated, but empty even when ARG_QEMU_CAPS was not used. The function still retains the interlocking of fake caps with real caps. A lot of the internal code expects qemuCaps to be populated and many tests work this around by using ARG_QEMU_CAPS with no caps. Signed-off-by: Peter Krempa --- tests/testutilsqemu.c | 44 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index 9a0666724a..32119e30c2 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -684,7 +684,8 @@ testQemuInfoSetArgs(struct testQemuInfo *info, { va_list argptr; testQemuInfoArgName argname; - virQEMUCaps *qemuCaps =3D NULL; + g_autoptr(virQEMUCaps) fakeCaps =3D virQEMUCapsNew(); + bool fakeCapsUsed =3D false; int gic =3D GIC_NONE; char *capsarch =3D NULL; char *capsver =3D NULL; @@ -692,16 +693,18 @@ testQemuInfoSetArgs(struct testQemuInfo *info, int flag; int ret =3D -1; + if (!fakeCaps) + abort(); + va_start(argptr, capslatest); argname =3D va_arg(argptr, testQemuInfoArgName); while (argname !=3D ARG_END) { switch (argname) { case ARG_QEMU_CAPS: - if (qemuCaps || !(qemuCaps =3D virQEMUCapsNew())) - goto cleanup; + fakeCapsUsed =3D true; while ((flag =3D va_arg(argptr, int)) < QEMU_CAPS_LAST) - virQEMUCapsSet(qemuCaps, flag); + virQEMUCapsSet(fakeCaps, flag); /* Some tests are run with NONE capabilities, which is just * another name for QEMU_CAPS_LAST. If that is the case the @@ -764,16 +767,16 @@ testQemuInfoSetArgs(struct testQemuInfo *info, goto cleanup; } - if (qemuCaps && (capsarch || capsver)) { - fprintf(stderr, "ARG_QEMU_CAPS can not be combined with ARG_CAPS_A= RCH " - "or ARG_CAPS_VER\n"); - goto cleanup; - } - - if (!qemuCaps && capsarch && capsver) { + if (capsarch && capsver) { bool stripmachinealiases =3D false; virQEMUCaps *cachedcaps =3D NULL; + if (fakeCapsUsed) { + fprintf(stderr, "ARG_QEMU_CAPS can not be combined with ARG_CA= PS_ARCH " + "or ARG_CAPS_VER\n"); + goto cleanup; + } + info->arch =3D virArchFromString(capsarch); if (STREQ(capsver, "latest")) { @@ -785,40 +788,33 @@ testQemuInfoSetArgs(struct testQemuInfo *info, } if (!g_hash_table_lookup_extended(capscache, capsfile, NULL, (void= **) &cachedcaps)) { - if (!(qemuCaps =3D qemuTestParseCapabilitiesArch(info->arch, c= apsfile))) + if (!(cachedcaps =3D qemuTestParseCapabilitiesArch(info->arch,= capsfile))) goto cleanup; - cachedcaps =3D qemuCaps; - - g_hash_table_insert(capscache, g_strdup(capsfile), g_steal_poi= nter(&qemuCaps)); + g_hash_table_insert(capscache, g_strdup(capsfile), cachedcaps); } - if (!(qemuCaps =3D virQEMUCapsNewCopy(cachedcaps))) + if (!(info->qemuCaps =3D virQEMUCapsNewCopy(cachedcaps))) goto cleanup; if (stripmachinealiases) - virQEMUCapsStripMachineAliases(qemuCaps); + virQEMUCapsStripMachineAliases(info->qemuCaps); info->flags |=3D FLAG_REAL_CAPS; /* provide path to the replies file for schema testing */ capsfile[strlen(capsfile) - 3] =3D '\0'; info->schemafile =3D g_strdup_printf("%sreplies", capsfile); + } else { + info->qemuCaps =3D g_steal_pointer(&fakeCaps); } - if (!qemuCaps) { - fprintf(stderr, "No qemuCaps generated\n"); - goto cleanup; - } - info->qemuCaps =3D g_steal_pointer(&qemuCaps); - if (gic !=3D GIC_NONE && testQemuCapsSetGIC(info->qemuCaps, gic) < 0) goto cleanup; ret =3D 0; cleanup: - virObjectUnref(qemuCaps); va_end(argptr); return ret; --=20 2.31.1