From nobody Mon Feb 9 09:22:21 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=1641462377; cv=none; d=zohomail.com; s=zohoarc; b=MmYLT5bu3tY7lezxf8Jcx9D0a2+ZC1SEhSGTs4NblmiBie956jjKhGPNQVYbrwuph5uNEm7qaXiLENlp0AnLIEkEBMja6iJMJln48fFZUouk+qKcdcBfWLRyKaURF4Hte7g9yDTB982AcaoFZTDsinPbIVcAq6HYidNqS2uov2w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641462377; 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=lREPr8Uka/nkvOy2uMW21KK+FRhh99gebkRPVMmcHSk=; b=eSO/TxvAkU3sWA3UxiILf+5IcbQPsC54/zM5OrGSEbWySMUnpz4G5cHN+5uCXiqM8gHoLL/ZArsjwsTbZSmwO+4FAC1SKGZaZ5fmumnoR5LRraThh2M4rMaXzTXqakSu9UeV0BR7iqYtmDa7sSWVHo8L+NQuJ1y49fP2WtEr5go= 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 1641462377934725.7262183876846; Thu, 6 Jan 2022 01:46:17 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-344-aj1bjsyMPUaulPZ7Qp8PUw-1; Thu, 06 Jan 2022 04:46:13 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C697685EE7B; Thu, 6 Jan 2022 09:46:08 +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 A6C4B60C53; Thu, 6 Jan 2022 09:46:08 +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 74ADA1802E2D; Thu, 6 Jan 2022 09:46:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 2069k668005873 for ; Thu, 6 Jan 2022 04:46:06 -0500 Received: by smtp.corp.redhat.com (Postfix) id A22297E122; Thu, 6 Jan 2022 09:46:06 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id DF8947CAD2 for ; Thu, 6 Jan 2022 09:46:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641462376; 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=lREPr8Uka/nkvOy2uMW21KK+FRhh99gebkRPVMmcHSk=; b=fxZ1b1fTHl9/ie9DbG9Pew/QN47GN0As4pdYOCqCRONwxUqINcUX/U22QETQ/3/+l4JBtl Xq/LVNI8ce3LWgVDX2i677do+06TtY7QXP9sxyb30T77xRpfAuPMzI65HjuZ7SsZeu9EX2 /FPNxO62+/uWTt+3KiJeP/rxl1i6zYw= X-MC-Unique: aj1bjsyMPUaulPZ7Qp8PUw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 20/21] qemuTestCapsCacheInsert: Extract code for popluating fake machine types Date: Thu, 6 Jan 2022 10:44:19 +0100 Message-Id: <8643b57a5be5d9c742415e70c7e0c228dc463312.1641461748.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.14 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: 1641462380286100005 Content-Type: text/plain; charset="utf-8" Separate the code to aid further refactors. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/testutilsqemu.c | 96 ++++++++++++++++++++++++------------------- 1 file changed, 53 insertions(+), 43 deletions(-) diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index bf3f919dde..94ff538382 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -335,10 +335,60 @@ void qemuTestDriverFree(virQEMUDriver *driver) virCPUDefFree(cpuPower9); } + +static void +qemuTestCapsPopulateFakeMachines(virQEMUCaps *caps, + virArch arch) +{ + size_t i; + const char *defaultRAMid =3D NULL; + + /* default-ram-id appeared in QEMU 5.2.0. Reflect + * this in our capabilities, i.e. set it for new + * enough versions only. */ + if (virQEMUCapsGetVersion(caps) >=3D 5002000) + defaultRAMid =3D qemu_default_ram_id[arch]; + + virQEMUCapsSetArch(caps, arch); + + for (i =3D 0; qemu_machines[arch][i] !=3D NULL; i++) { + virQEMUCapsAddMachine(caps, + VIR_DOMAIN_VIRT_QEMU, + qemu_machines[arch][i], + NULL, + NULL, + 0, + false, + false, + true, + defaultRAMid, + false); + virQEMUCapsSet(caps, QEMU_CAPS_TCG); + } + + if (kvm_machines[arch] !=3D NULL) { + for (i =3D 0; kvm_machines[arch][i] !=3D NULL; i++) { + virQEMUCapsAddMachine(caps, + VIR_DOMAIN_VIRT_KVM, + kvm_machines[arch][i], + NULL, + NULL, + 0, + false, + false, + true, + defaultRAMid, + false); + virQEMUCapsSet(caps, QEMU_CAPS_KVM); + } + } +} + + int qemuTestCapsCacheInsert(virFileCache *cache, virQEMUCaps *caps) { - size_t i, j; + size_t i; for (i =3D 0; i < G_N_ELEMENTS(qemu_emulators); i++) { virQEMUCaps *tmpCaps; @@ -353,48 +403,8 @@ int qemuTestCapsCacheInsert(virFileCache *cache, if (!tmpCaps) return -1; - if (!virQEMUCapsHasMachines(tmpCaps)) { - const char *defaultRAMid =3D NULL; - - /* default-ram-id appeared in QEMU 5.2.0. Reflect - * this in our capabilities, i.e. set it for new - * enough versions only. */ - if (virQEMUCapsGetVersion(tmpCaps) >=3D 5002000) - defaultRAMid =3D qemu_default_ram_id[i]; - - virQEMUCapsSetArch(tmpCaps, i); - - for (j =3D 0; qemu_machines[i][j] !=3D NULL; j++) { - virQEMUCapsAddMachine(tmpCaps, - VIR_DOMAIN_VIRT_QEMU, - qemu_machines[i][j], - NULL, - NULL, - 0, - false, - false, - true, - defaultRAMid, - false); - virQEMUCapsSet(tmpCaps, QEMU_CAPS_TCG); - } - if (kvm_machines[i] !=3D NULL) { - for (j =3D 0; kvm_machines[i][j] !=3D NULL; j++) { - virQEMUCapsAddMachine(tmpCaps, - VIR_DOMAIN_VIRT_KVM, - kvm_machines[i][j], - NULL, - NULL, - 0, - false, - false, - true, - defaultRAMid, - false); - virQEMUCapsSet(tmpCaps, QEMU_CAPS_KVM); - } - } - } + if (!virQEMUCapsHasMachines(tmpCaps)) + qemuTestCapsPopulateFakeMachines(tmpCaps, i); if (virFileCacheInsertData(cache, qemu_emulators[i], tmpCaps) < 0)= { virObjectUnref(tmpCaps); --=20 2.31.1