[libvirt] [PATCH 05/10] qemu: command: Remove default port numbers for NBD and GLUSTER

Peter Krempa pkrempa at redhat.com
Mon Jul 10 12:07:37 UTC 2017


The command line generators for the protocols above hardcoded a default
port number. Since we now always assign it when parsing the source
definition, this ad-hoc code is not required any more.
---
 src/qemu/qemu_command.c | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 285167145..10c2dea93 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -792,9 +792,6 @@ qemuBuildTLSx509CommandLine(virCommandPtr cmd,
 }


-#define QEMU_DEFAULT_NBD_PORT "10809"
-#define QEMU_DEFAULT_GLUSTER_PORT "24007"
-
 /* builds the hosts array */
 static virJSONValuePtr
 qemuBuildGlusterDriveJSONHosts(virStorageSourcePtr src)
@@ -804,7 +801,6 @@ qemuBuildGlusterDriveJSONHosts(virStorageSourcePtr src)
     virJSONValuePtr ret = NULL;
     virStorageNetHostDefPtr host;
     const char *transport;
-    const char *portstr;
     size_t i;

     if (!(servers = virJSONValueNewArray()))
@@ -813,19 +809,15 @@ qemuBuildGlusterDriveJSONHosts(virStorageSourcePtr src)
     for (i = 0; i < src->nhosts; i++) {
         host = src->hosts + i;
         transport = virStorageNetHostTransportTypeToString(host->transport);
-        portstr = host->port;

         if (virJSONValueObjectCreate(&server, "s:type", transport, NULL) < 0)
             goto cleanup;

-        if (!portstr)
-            portstr = QEMU_DEFAULT_GLUSTER_PORT;
-
         switch ((virStorageNetHostTransport) host->transport) {
         case VIR_STORAGE_NET_HOST_TRANS_TCP:
             if (virJSONValueObjectAdd(server,
                                       "s:host", host->name,
-                                      "s:port", portstr,
+                                      "s:port", host->port,
                                       NULL) < 0)
                 goto cleanup;
             break;
@@ -979,10 +971,8 @@ qemuBuildNetworkDriveStr(virStorageSourcePtr src,

                 switch (src->hosts->transport) {
                 case VIR_STORAGE_NET_HOST_TRANS_TCP:
-                    virBufferStrcat(&buf, src->hosts->name, NULL);
-                    virBufferAsprintf(&buf, ":%s",
-                                      src->hosts->port ? src->hosts->port :
-                                      QEMU_DEFAULT_NBD_PORT);
+                    virBufferStrcat(&buf, src->hosts->name, ":",
+                                    src->hosts->port, NULL);
                     break;

                 case VIR_STORAGE_NET_HOST_TRANS_UNIX:
-- 
2.12.2




More information about the libvir-list mailing list