From nobody Mon Feb 9 09:28:48 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1677853758; cv=none; d=zohomail.com; s=zohoarc; b=A/jMR/MOUuMPtl9+9MVRMiehPHJczU7DETAuF0fI5riiIZAVaMK1XiPqQuGwZ3+WVkDSFJFf5NePGasstgagjU13dY2+aFlpPA5/L4qJzq1C+8chjGbijexd/8C86FmDWJJlvn/55IPhCbgSxVP5Qobztc+QWFL0l+JBtE/mkvg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677853758; 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=J+fp4TfZgHI0C7bp8F6SU3WTsIlY9dtUt4hh2WcuR+A=; b=nhMzcS650OZFnc6fNtEJEIPvlOP1nMNuHweabMpw83oBkzmN30OIaHvYqDrUqRzEyLwYVdnIN8hdeD4I3fK1D9C9yfP6J0GN5fSx5xVdiO0+UK7cQCZ/m07YnyG2sWuy0PUZmg7PXdmoaGc3qJLl1cayFwmTBLFJG/Ih9n/DRmE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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 [170.10.133.124]) by mx.zohomail.com with SMTPS id 1677853758407229.1322197415435; Fri, 3 Mar 2023 06:29:18 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-536-8qc-ey3VMtGWNO7W8vEtXw-1; Fri, 03 Mar 2023 09:29:14 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E836F87A9E3; Fri, 3 Mar 2023 14:29:10 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D5F3AC1602C; Fri, 3 Mar 2023 14:29:10 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id DE506194208F; Fri, 3 Mar 2023 14:28:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D9F371942B4D for ; Fri, 3 Mar 2023 14:28:26 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id BEA294011AC8; Fri, 3 Mar 2023 14:28:26 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4057E4035703 for ; Fri, 3 Mar 2023 14:28:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677853757; 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=J+fp4TfZgHI0C7bp8F6SU3WTsIlY9dtUt4hh2WcuR+A=; b=GcIvxPCucqHkNhzaB1utoxe3vHwV78rqBRYV8etZ8h+jbgFh1QCAnR851EqDS8+FtMRumD MTA1OPaalxi12rPDphYwDzNcxqPM51Dm/Y3KxTWeAkV2uv9cA0uTCEqI+uXvTA0NQbp4/B rSqsWYqrp6dZR63zi5uH/O9eoi0klgY= X-MC-Unique: 8qc-ey3VMtGWNO7W8vEtXw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 21/31] testutilsqemu: Rework setting of fake capabilities Date: Fri, 3 Mar 2023 15:27:55 +0100 Message-Id: <01a3eb723b93ef61bcf21f21f605eb390cc3b14b.1677853487.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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: 1677853758901100001 Content-Type: text/plain; charset="utf-8" Rather that populate a virQEMUCaps object we now populate a bitmap with the fake capabilities and transfer it into the virQEMUCaps later. This unifies the code paths between the fully fake caps tests and real caps + fake flags. Also the same approach will be used in upcomming patch to add possibility to mask out flags from real capabilities. Signed-off-by: Peter Krempa --- tests/testutilsqemu.c | 25 +++++++++---------------- tests/testutilsqemu.h | 3 +-- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index 18a9ca5ee1..55de4bcdc6 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -837,8 +837,6 @@ testQemuInfoSetArgs(struct testQemuInfo *info, testQemuInfoArgName argname; int flag; - info->args.fakeCaps =3D virQEMUCapsNew(); - info->conf =3D conf; info->args.newargs =3D true; @@ -846,10 +844,11 @@ testQemuInfoSetArgs(struct testQemuInfo *info, while ((argname =3D va_arg(argptr, testQemuInfoArgName)) !=3D ARG_END)= { switch (argname) { case ARG_QEMU_CAPS: - info->args.fakeCapsUsed =3D true; + if (!(info->args.fakeCapsAdd)) + info->args.fakeCapsAdd =3D virBitmapNew(QEMU_CAPS_LAST); while ((flag =3D va_arg(argptr, int)) < QEMU_CAPS_LAST) - virQEMUCapsSet(info->args.fakeCaps, flag); + ignore_value(virBitmapSetBit(info->args.fakeCapsAdd, flag)= ); break; case ARG_GIC: @@ -938,6 +937,7 @@ int testQemuInfoInitArgs(struct testQemuInfo *info) { g_autofree char *capsfile =3D NULL; + ssize_t cap; if (!info->args.newargs) return 0; @@ -985,16 +985,6 @@ testQemuInfoInitArgs(struct testQemuInfo *info) info->qemuCaps =3D virQEMUCapsNewCopy(cachedcaps); - if (info->args.fakeCapsUsed) { - size_t i; - for (i =3D 0; i < QEMU_CAPS_LAST; i++) { - if (virQEMUCapsGet(info->args.fakeCaps, i)) { - virQEMUCapsSet(info->qemuCaps, i); - } - } - } - - if (stripmachinealiases) virQEMUCapsStripMachineAliases(info->qemuCaps); @@ -1004,9 +994,12 @@ testQemuInfoInitArgs(struct testQemuInfo *info) capsfile[strlen(capsfile) - 3] =3D '\0'; info->schemafile =3D g_strdup_printf("%sreplies", capsfile); } else { - info->qemuCaps =3D g_steal_pointer(&info->args.fakeCaps); + info->qemuCaps =3D virQEMUCapsNew(); } + for (cap =3D -1; (cap =3D virBitmapNextSetBit(info->args.fakeCapsAdd, = cap)) >=3D 0;) + virQEMUCapsSet(info->qemuCaps, cap); + if (info->args.gic !=3D GIC_NONE && testQemuCapsSetGIC(info->qemuCaps, info->args.gic) < 0) return -1; @@ -1023,7 +1016,7 @@ testQemuInfoClear(struct testQemuInfo *info) VIR_FREE(info->schemafile); VIR_FREE(info->errfile); virObjectUnref(info->qemuCaps); - g_clear_pointer(&info->args.fakeCaps, virObjectUnref); + g_clear_pointer(&info->args.fakeCapsAdd, virBitmapFree); g_clear_pointer(&info->args.fds, g_hash_table_unref); } diff --git a/tests/testutilsqemu.h b/tests/testutilsqemu.h index 51c072cb13..f272e6d41d 100644 --- a/tests/testutilsqemu.h +++ b/tests/testutilsqemu.h @@ -81,8 +81,7 @@ typedef enum { struct testQemuArgs { bool newargs; - virQEMUCaps *fakeCaps; - bool fakeCapsUsed; + virBitmap *fakeCapsAdd; char *capsver; char *capsarch; qemuTestCPUDef capsHostCPUModel; --=20 2.39.2