From nobody Sun Feb 8 00:26:35 2026 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.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1491572681778411.3589342942755; Fri, 7 Apr 2017 06:44:41 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 724818050B; Fri, 7 Apr 2017 13:44:39 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 40B2EB11F3; Fri, 7 Apr 2017 13:44:39 +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 D5CE25EC67; Fri, 7 Apr 2017 13:44:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v37DiXvT027128 for ; Fri, 7 Apr 2017 09:44:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id C3DD5B11EF; Fri, 7 Apr 2017 13:44:33 +0000 (UTC) Received: from antique-work.brq.redhat.com (dhcp129-230.brq.redhat.com [10.34.129.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4A926A63C1 for ; Fri, 7 Apr 2017 13:44:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 724818050B Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 724818050B From: Pavel Hrdina To: libvir-list@redhat.com Date: Fri, 7 Apr 2017 15:44:19 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/8] tests/testutilsqemu: extract guest creation into separate functions 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: , MIME-Version: 1.0 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 07 Apr 2017 13:44:41 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" All other architectures have separate functions to prepare guest capabilities, do the same for i686 and x86_64 as well. Signed-off-by: Pavel Hrdina --- tests/testutilsqemu.c | 182 +++++++++++++++++++++++++++++++---------------= ---- 1 file changed, 114 insertions(+), 68 deletions(-) diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index 4cc482dfb0..d82cebd578 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -141,6 +141,118 @@ static virCapsGuestMachinePtr *testQemuAllocNewerMach= ines(int *nmachines) } =20 =20 +static int +testQemuAddI686Guest(virCapsPtr caps) +{ + int nmachines =3D 0; + virCapsGuestMachinePtr *machines =3D NULL; + virCapsGuestPtr guest; + + if (!(machines =3D testQemuAllocMachines(&nmachines))) + goto error; + + if (!(guest =3D virCapabilitiesAddGuest(caps, + VIR_DOMAIN_OSTYPE_HVM, + VIR_ARCH_I686, + "/usr/bin/qemu", + NULL, + nmachines, + machines))) + goto error; + + if (!virCapabilitiesAddGuestFeature(guest, "cpuselection", true, false= )) + goto error; + + machines =3D NULL; + + if (!virCapabilitiesAddGuestDomain(guest, + VIR_DOMAIN_VIRT_QEMU, + NULL, + NULL, + 0, + NULL)) + goto error; + + if (!(machines =3D testQemuAllocMachines(&nmachines))) + goto error; + + if (!virCapabilitiesAddGuestDomain(guest, + VIR_DOMAIN_VIRT_KVM, + "/usr/bin/qemu-kvm", + NULL, + nmachines, + machines)) + goto error; + + return 0; + + error: + virCapabilitiesFreeMachines(machines, nmachines); + return -1; +} + + +static int +testQemuAddX86_64Guest(virCapsPtr caps) +{ + int nmachines =3D 0; + virCapsGuestMachinePtr *machines =3D NULL; + virCapsGuestPtr guest; + + if (!(machines =3D testQemuAllocNewerMachines(&nmachines))) + goto error; + + if (!(guest =3D virCapabilitiesAddGuest(caps, + VIR_DOMAIN_OSTYPE_HVM, + VIR_ARCH_X86_64, + "/usr/bin/qemu-system-x86_64", + NULL, + nmachines, + machines))) + goto error; + + if (!virCapabilitiesAddGuestFeature(guest, "cpuselection", true, false= )) + goto error; + + machines =3D NULL; + + if (!virCapabilitiesAddGuestDomain(guest, + VIR_DOMAIN_VIRT_QEMU, + NULL, + NULL, + 0, + NULL)) + goto error; + + if (!(machines =3D testQemuAllocMachines(&nmachines))) + goto error; + + if (!virCapabilitiesAddGuestDomain(guest, + VIR_DOMAIN_VIRT_KVM, + "/usr/bin/kvm", + NULL, + nmachines, + machines)) + goto error; + + machines =3D NULL; + + if (!virCapabilitiesAddGuestDomain(guest, + VIR_DOMAIN_VIRT_KVM, + "/usr/bin/kvm", + NULL, + 0, + NULL)) + goto error; + + return 0; + + error: + virCapabilitiesFreeMachines(machines, nmachines); + return -1; +} + + static int testQemuAddPPC64Guest(virCapsPtr caps) { static const char *machine[] =3D { "pseries" }; @@ -315,9 +427,6 @@ static int testQemuAddAARCH64Guest(virCapsPtr caps) virCapsPtr testQemuCapsInit(void) { virCapsPtr caps; - virCapsGuestPtr guest; - virCapsGuestMachinePtr *machines =3D NULL; - int nmachines =3D 0; =20 if (!(caps =3D virCapabilitiesNew(VIR_ARCH_X86_64, false, false))) return NULL; @@ -341,72 +450,10 @@ virCapsPtr testQemuCapsInit(void) =20 caps->host.nnumaCell_max =3D 4; =20 - if ((machines =3D testQemuAllocMachines(&nmachines)) =3D=3D NULL) + if (testQemuAddI686Guest(caps) < 0) goto cleanup; =20 - if ((guest =3D virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VI= R_ARCH_I686, - "/usr/bin/qemu", NULL, - nmachines, machines)) =3D=3D NULL= || - !virCapabilitiesAddGuestFeature(guest, "cpuselection", true, false= )) - goto cleanup; - machines =3D NULL; - - if (virCapabilitiesAddGuestDomain(guest, - VIR_DOMAIN_VIRT_QEMU, - NULL, - NULL, - 0, - NULL) =3D=3D NULL) - goto cleanup; - - if ((machines =3D testQemuAllocMachines(&nmachines)) =3D=3D NULL) - goto cleanup; - - if (virCapabilitiesAddGuestDomain(guest, - VIR_DOMAIN_VIRT_KVM, - "/usr/bin/qemu-kvm", - NULL, - nmachines, - machines) =3D=3D NULL) - goto cleanup; - machines =3D NULL; - - if ((machines =3D testQemuAllocNewerMachines(&nmachines)) =3D=3D NULL) - goto cleanup; - - if ((guest =3D virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VI= R_ARCH_X86_64, - "/usr/bin/qemu-system-x86_64", NU= LL, - nmachines, machines)) =3D=3D NULL= || - !virCapabilitiesAddGuestFeature(guest, "cpuselection", true, false= )) - goto cleanup; - machines =3D NULL; - - if (virCapabilitiesAddGuestDomain(guest, - VIR_DOMAIN_VIRT_QEMU, - NULL, - NULL, - 0, - NULL) =3D=3D NULL) - goto cleanup; - - if ((machines =3D testQemuAllocMachines(&nmachines)) =3D=3D NULL) - goto cleanup; - - if (virCapabilitiesAddGuestDomain(guest, - VIR_DOMAIN_VIRT_KVM, - "/usr/bin/kvm", - NULL, - nmachines, - machines) =3D=3D NULL) - goto cleanup; - machines =3D NULL; - - if (virCapabilitiesAddGuestDomain(guest, - VIR_DOMAIN_VIRT_KVM, - "/usr/bin/kvm", - NULL, - 0, - NULL) =3D=3D NULL) + if (testQemuAddX86_64Guest(caps) < 0) goto cleanup; =20 if (testQemuAddPPC64Guest(caps)) @@ -442,7 +489,6 @@ virCapsPtr testQemuCapsInit(void) return caps; =20 cleanup: - virCapabilitiesFreeMachines(machines, nmachines); caps->host.cpu =3D NULL; virCPUDefFree(cpuDefault); virCPUDefFree(cpuHaswell); --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list