[Pkg-libvirt-commits] [SCM] Libguestfs Debian packaging branch, experimental, updated. debian/1%1.21.40-1

Richard W.M. Jones rjones at redhat.com
Sat Jun 1 11:05:03 UTC 2013


The following commit has been merged in the experimental branch:
commit 40691b7167fec6619385b38693eb65c375f0c7bd
Author: Richard W.M. Jones <rjones at redhat.com>
Date:   Mon May 20 15:13:09 2013 +0100

    launch: libvirt: Allow port to be optional.
    
    Actually if you don't specify the port, currently libvirt gives
    an error:
    
      libguestfs: error: could not create appliance through libvirt: XML
      error: missing port for host [code=27 domain=20]
    
    However I think that is a bug in libvirt:
    
      https://bugzilla.redhat.com/show_bug.cgi?id=965142

diff --git a/src/launch-libvirt.c b/src/launch-libvirt.c
index 10a4d2c..160cdb6 100644
--- a/src/launch-libvirt.c
+++ b/src/launch-libvirt.c
@@ -1268,20 +1268,22 @@ construct_libvirt_xml_disk_source_hosts (guestfs_h *g,
     switch (src->servers[i].transport) {
     case drive_transport_none:
     case drive_transport_tcp: {
-      const char *hostname;
-      int port;
-      char port_str[64];
-
-      hostname = src->servers[i].u.hostname;
-      port = src->servers[i].port;
-      snprintf (port_str, sizeof port_str, "%d", port);
+      const char *hostname = src->servers[i].u.hostname;
+      int port = src->servers[i].port;
 
       XMLERROR (-1,
                 xmlTextWriterWriteAttribute (xo, BAD_CAST "name",
                                              BAD_CAST hostname));
-      XMLERROR (-1,
-                xmlTextWriterWriteAttribute (xo, BAD_CAST "port",
-                                             BAD_CAST port_str));
+
+      if (port > 0) {
+        char port_str[64];
+
+        snprintf (port_str, sizeof port_str, "%d", port);
+
+        XMLERROR (-1,
+                  xmlTextWriterWriteAttribute (xo, BAD_CAST "port",
+                                               BAD_CAST port_str));
+      }
       break;
     }
 

-- 
Libguestfs Debian packaging



More information about the Pkg-libvirt-commits mailing list