From nobody Sun Feb 8 18:28:23 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.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 1547601370061261.3108717771014; Tue, 15 Jan 2019 17:16:10 -0800 (PST) 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 3EAE8C057E00; Wed, 16 Jan 2019 01:16:08 +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 F3A2810640FC; Wed, 16 Jan 2019 01:16:07 +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 6DDF33F7CB; Wed, 16 Jan 2019 01:16:07 +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 x0G1Fv5Z022745 for ; Tue, 15 Jan 2019 20:15:57 -0500 Received: by smtp.corp.redhat.com (Postfix) id F122519940; Wed, 16 Jan 2019 01:15:56 +0000 (UTC) Received: from unknown0050b6a41c42.attlocal.net.com (ovpn-116-153.phx2.redhat.com [10.3.116.153]) by smtp.corp.redhat.com (Postfix) with ESMTP id AE0FD19C7C for ; Wed, 16 Jan 2019 01:15:56 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 15 Jan 2019 20:15:46 -0500 Message-Id: <20190116011549.16309-5-jferlan@redhat.com> In-Reply-To: <20190116011549.16309-1-jferlan@redhat.com> References: <20190116011549.16309-1-jferlan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/7] conf: Alter virCapabilitiesFormatGuestXML to take virCapsGuestPtr 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.31]); Wed, 16 Jan 2019 01:16:08 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Rather than deref off of "caps->guests", let's pass "caps->guests" and caps->nguests to have the helper use "guests[i]->" instead. Signed-off-by: John Ferlan --- src/conf/capabilities.c | 71 +++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index c320c0f72d..1269a4c739 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -1179,31 +1179,32 @@ virCapabilitiesFormatHostXML(virCapsHostPtr host, =20 =20 static void -virCapabilitiesFormatGuestXML(virCapsPtr caps, +virCapabilitiesFormatGuestXML(virCapsGuestPtr *guests, + size_t nguests, virBufferPtr buf) { size_t i, j, k; =20 - for (i =3D 0; i < caps->nguests; i++) { + for (i =3D 0; i < nguests; i++) { virBufferAddLit(buf, "\n"); virBufferAdjustIndent(buf, 2); virBufferAsprintf(buf, "%s\n", - virDomainOSTypeToString(caps->guests[i]->ostype)= ); - if (caps->guests[i]->arch.id) + virDomainOSTypeToString(guests[i]->ostype)); + if (guests[i]->arch.id) virBufferAsprintf(buf, "\n", - virArchToString(caps->guests[i]->arch.id)); + virArchToString(guests[i]->arch.id)); virBufferAdjustIndent(buf, 2); virBufferAsprintf(buf, "%d\n", - caps->guests[i]->arch.wordsize); - if (caps->guests[i]->arch.defaultInfo.emulator) + guests[i]->arch.wordsize); + if (guests[i]->arch.defaultInfo.emulator) virBufferAsprintf(buf, "%s\n", - caps->guests[i]->arch.defaultInfo.emulator); - if (caps->guests[i]->arch.defaultInfo.loader) + guests[i]->arch.defaultInfo.emulator); + if (guests[i]->arch.defaultInfo.loader) virBufferAsprintf(buf, "%s\n", - caps->guests[i]->arch.defaultInfo.loader); + guests[i]->arch.defaultInfo.loader); =20 - for (j =3D 0; j < caps->guests[i]->arch.defaultInfo.nmachines; j++= ) { - virCapsGuestMachinePtr machine =3D caps->guests[i]->arch.defau= ltInfo.machines[j]; + for (j =3D 0; j < guests[i]->arch.defaultInfo.nmachines; j++) { + virCapsGuestMachinePtr machine =3D guests[i]->arch.defaultInfo= .machines[j]; virBufferAddLit(buf, "canonical) virBufferAsprintf(buf, " canonical=3D'%s'", machine->canon= ical); @@ -1212,26 +1213,26 @@ virCapabilitiesFormatGuestXML(virCapsPtr caps, virBufferAsprintf(buf, ">%s\n", machine->name); } =20 - for (j =3D 0; j < caps->guests[i]->arch.ndomains; j++) { + for (j =3D 0; j < guests[i]->arch.ndomains; j++) { virBufferAsprintf(buf, "guests[i]->arch.domains[j]= ->type)); - if (!caps->guests[i]->arch.domains[j]->info.emulator && - !caps->guests[i]->arch.domains[j]->info.loader && - !caps->guests[i]->arch.domains[j]->info.nmachines) { + virDomainVirtTypeToString(guests[i]->arch.domains[j]->type= )); + if (!guests[i]->arch.domains[j]->info.emulator && + !guests[i]->arch.domains[j]->info.loader && + !guests[i]->arch.domains[j]->info.nmachines) { virBufferAddLit(buf, "/>\n"); continue; } virBufferAddLit(buf, ">\n"); virBufferAdjustIndent(buf, 2); - if (caps->guests[i]->arch.domains[j]->info.emulator) + if (guests[i]->arch.domains[j]->info.emulator) virBufferAsprintf(buf, "%s\n", - caps->guests[i]->arch.domains[j]->info.e= mulator); - if (caps->guests[i]->arch.domains[j]->info.loader) + guests[i]->arch.domains[j]->info.emulato= r); + if (guests[i]->arch.domains[j]->info.loader) virBufferAsprintf(buf, "%s\n", - caps->guests[i]->arch.domains[j]->info.l= oader); + guests[i]->arch.domains[j]->info.loader); =20 - for (k =3D 0; k < caps->guests[i]->arch.domains[j]->info.nmach= ines; k++) { - virCapsGuestMachinePtr machine =3D caps->guests[i]->arch.d= omains[j]->info.machines[k]; + for (k =3D 0; k < guests[i]->arch.domains[j]->info.nmachines; = k++) { + virCapsGuestMachinePtr machine =3D guests[i]->arch.domains= [j]->info.machines[k]; virBufferAddLit(buf, "canonical) virBufferAsprintf(buf, " canonical=3D'%s'", machine->c= anonical); @@ -1246,23 +1247,23 @@ virCapabilitiesFormatGuestXML(virCapsPtr caps, virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); =20 - if (caps->guests[i]->nfeatures) { + if (guests[i]->nfeatures) { virBufferAddLit(buf, "\n"); virBufferAdjustIndent(buf, 2); =20 - for (j =3D 0; j < caps->guests[i]->nfeatures; j++) { - if (STREQ(caps->guests[i]->features[j]->name, "pae") || - STREQ(caps->guests[i]->features[j]->name, "nonpae") || - STREQ(caps->guests[i]->features[j]->name, "ia64_be") || - STREQ(caps->guests[i]->features[j]->name, "cpuselectio= n") || - STREQ(caps->guests[i]->features[j]->name, "deviceboot"= )) { + for (j =3D 0; j < guests[i]->nfeatures; j++) { + if (STREQ(guests[i]->features[j]->name, "pae") || + STREQ(guests[i]->features[j]->name, "nonpae") || + STREQ(guests[i]->features[j]->name, "ia64_be") || + STREQ(guests[i]->features[j]->name, "cpuselection") || + STREQ(guests[i]->features[j]->name, "deviceboot")) { virBufferAsprintf(buf, "<%s/>\n", - caps->guests[i]->features[j]->name); + guests[i]->features[j]->name); } else { virBufferAsprintf(buf, "<%s default=3D'%s' toggle=3D'%= s'/>\n", - caps->guests[i]->features[j]->name, - caps->guests[i]->features[j]->defaul= tOn ? "on" : "off", - caps->guests[i]->features[j]->toggle= ? "yes" : "no"); + guests[i]->features[j]->name, + guests[i]->features[j]->defaultOn ? = "on" : "off", + guests[i]->features[j]->toggle ? "ye= s" : "no"); } } =20 @@ -1294,7 +1295,7 @@ virCapabilitiesFormatXML(virCapsPtr caps) if (virCapabilitiesFormatHostXML(&caps->host, &buf) < 0) goto error; =20 - virCapabilitiesFormatGuestXML(caps, &buf); + virCapabilitiesFormatGuestXML(caps->guests, caps->nguests, &buf); =20 virBufferAdjustIndent(&buf, -2); virBufferAddLit(&buf, "\n"); --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list