Re: Documentation

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

 



On 08/08/2011 05:30 AM, Rafael Fernández López wrote:
Hi all,

Reading libvirt documentation I have found that there is an example
that is pretty broken.

Thanks for the report.


I'm referring to
http://libvirt.org/guide/html/Application_Development_Guide-Guest_Domains-Listing.html,
example 4.6.

The source for this example is maintained in a git repository:
git://libvirt.org/libvirt-appdev-guide.git
en-US/Guest_Domains.xml


I attach a patch (untested) that fixes some logic, type and function
signature problems. I kept small problems like 'i' missing definition
for the sake of readiness.

I've gone ahead and applied your patch, but also adding the missing definition for 'i'.

diff --git i/en-US/Guest_Domains.xml w/en-US/Guest_Domains.xml
index af29864..0324e78 100644
--- i/en-US/Guest_Domains.xml
+++ w/en-US/Guest_Domains.xml
@@ -220,35 +220,36 @@ free(inactiveDomains);
       <title>Fetching all domain objects</title>
       <programlisting>
 virDomainPtr *allDomains;
-int numDomains;
+int numDomains = 0;
 int numActiveDomains, numInactiveDomains;
-char *inactiveDomains;
+char **inactiveDomains;
 int *activeDomains;
+int i;

 numActiveDomains = virConnectNumOfDomains(conn);
 numInactiveDomains = virConnectNumOfDefinedDomains(conn);

 allDomains = malloc(sizeof(virDomainPtr) *
-numActiveDomains + numInactiveDomains);
-inactiveDomains = malloc(sizeof(char *) * numDomains);
-activeDomains = malloc(sizeof(int) * numDomains);
+    (numActiveDomains + numInactiveDomains));
+inactiveDomains = malloc(sizeof(char *) * numInactiveDomains);
+activeDomains = malloc(sizeof(int) * numActiveDomains);

 numActiveDomains = virConnectListDomains(conn,
-activeDomains,
-numActiveDomains);
+    activeDomains,
+    numActiveDomains);
 numInactiveDomains = virConnectListDefinedDomains(conn,
-inactiveDomains,
-numInactiveDomains);
+    inactiveDomains,
+    numInactiveDomains);

 for (i = 0 ; i &lt; numActiveDomains ; i++) {
-    allDomains[numDomains] = virDomainLookupByID(activeDomains[i]);
-    numDomains++
+    allDomains[numDomains] = virDomainLookupByID(conn, activeDomains[i]);
+    numDomains++;
 }

 for (i = 0 ; i &lt; numInactiveDomains ; i++) {
-    allDomains[numDomains] = virDomainLookupByName(inactiveDomains[i]);
+ allDomains[numDomains] = virDomainLookupByName(conn, inactiveDomains[i]);
     free(inactiveDomains[i]);
-    numDomains++
+    numDomains++;
 }
 free(activeDomains);
 free(inactiveDomains);


--
Eric Blake   eblake@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

--
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]