[PATCH 4/7] conf: Alter virCapabilitiesFormatGuestXML to take virCapsGuestPtr

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <jferlan@xxxxxxxxxx>
---
 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,
 
 
 static void
-virCapabilitiesFormatGuestXML(virCapsPtr caps,
+virCapabilitiesFormatGuestXML(virCapsGuestPtr *guests,
+                              size_t nguests,
                               virBufferPtr buf)
 {
     size_t i, j, k;
 
-    for (i = 0; i < caps->nguests; i++) {
+    for (i = 0; i < nguests; i++) {
         virBufferAddLit(buf, "<guest>\n");
         virBufferAdjustIndent(buf, 2);
         virBufferAsprintf(buf, "<os_type>%s</os_type>\n",
-                          virDomainOSTypeToString(caps->guests[i]->ostype));
-        if (caps->guests[i]->arch.id)
+                          virDomainOSTypeToString(guests[i]->ostype));
+        if (guests[i]->arch.id)
             virBufferAsprintf(buf, "<arch name='%s'>\n",
-                              virArchToString(caps->guests[i]->arch.id));
+                              virArchToString(guests[i]->arch.id));
         virBufferAdjustIndent(buf, 2);
         virBufferAsprintf(buf, "<wordsize>%d</wordsize>\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, "<emulator>%s</emulator>\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, "<loader>%s</loader>\n",
-                              caps->guests[i]->arch.defaultInfo.loader);
+                              guests[i]->arch.defaultInfo.loader);
 
-        for (j = 0; j < caps->guests[i]->arch.defaultInfo.nmachines; j++) {
-            virCapsGuestMachinePtr machine = caps->guests[i]->arch.defaultInfo.machines[j];
+        for (j = 0; j < guests[i]->arch.defaultInfo.nmachines; j++) {
+            virCapsGuestMachinePtr machine = guests[i]->arch.defaultInfo.machines[j];
             virBufferAddLit(buf, "<machine");
             if (machine->canonical)
                 virBufferAsprintf(buf, " canonical='%s'", machine->canonical);
@@ -1212,26 +1213,26 @@ virCapabilitiesFormatGuestXML(virCapsPtr caps,
             virBufferAsprintf(buf, ">%s</machine>\n", machine->name);
         }
 
-        for (j = 0; j < caps->guests[i]->arch.ndomains; j++) {
+        for (j = 0; j < guests[i]->arch.ndomains; j++) {
             virBufferAsprintf(buf, "<domain type='%s'",
-                virDomainVirtTypeToString(caps->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, "<emulator>%s</emulator>\n",
-                                  caps->guests[i]->arch.domains[j]->info.emulator);
-            if (caps->guests[i]->arch.domains[j]->info.loader)
+                                  guests[i]->arch.domains[j]->info.emulator);
+            if (guests[i]->arch.domains[j]->info.loader)
                 virBufferAsprintf(buf, "<loader>%s</loader>\n",
-                                  caps->guests[i]->arch.domains[j]->info.loader);
+                                  guests[i]->arch.domains[j]->info.loader);
 
-            for (k = 0; k < caps->guests[i]->arch.domains[j]->info.nmachines; k++) {
-                virCapsGuestMachinePtr machine = caps->guests[i]->arch.domains[j]->info.machines[k];
+            for (k = 0; k < guests[i]->arch.domains[j]->info.nmachines; k++) {
+                virCapsGuestMachinePtr machine = guests[i]->arch.domains[j]->info.machines[k];
                 virBufferAddLit(buf, "<machine");
                 if (machine->canonical)
                     virBufferAsprintf(buf, " canonical='%s'", machine->canonical);
@@ -1246,23 +1247,23 @@ virCapabilitiesFormatGuestXML(virCapsPtr caps,
         virBufferAdjustIndent(buf, -2);
         virBufferAddLit(buf, "</arch>\n");
 
-        if (caps->guests[i]->nfeatures) {
+        if (guests[i]->nfeatures) {
             virBufferAddLit(buf, "<features>\n");
             virBufferAdjustIndent(buf, 2);
 
-            for (j = 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, "cpuselection") ||
-                    STREQ(caps->guests[i]->features[j]->name, "deviceboot")) {
+            for (j = 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='%s' toggle='%s'/>\n",
-                                      caps->guests[i]->features[j]->name,
-                                      caps->guests[i]->features[j]->defaultOn ? "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 ? "yes" : "no");
                 }
             }
 
@@ -1294,7 +1295,7 @@ virCapabilitiesFormatXML(virCapsPtr caps)
     if (virCapabilitiesFormatHostXML(&caps->host, &buf) < 0)
         goto error;
 
-    virCapabilitiesFormatGuestXML(caps, &buf);
+    virCapabilitiesFormatGuestXML(caps->guests, caps->nguests, &buf);
 
     virBufferAdjustIndent(&buf, -2);
     virBufferAddLit(&buf, "</capabilities>\n");
-- 
2.20.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux