]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu_process: handle port allocation for VNC the same way as for Spice
authorPavel Hrdina <phrdina@redhat.com>
Mon, 25 Apr 2016 13:24:48 +0000 (15:24 +0200)
committerPavel Hrdina <phrdina@redhat.com>
Fri, 6 May 2016 12:54:13 +0000 (14:54 +0200)
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
src/qemu/qemu_driver.c
src/qemu/qemu_process.c
src/qemu/qemu_process.h

index 3d0c7c83a78b118893a61f65081022d0b6e9e321..396e64cf0d389dc912731c8bd1365c9519bc0c85 100644 (file)
@@ -7063,9 +7063,9 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
     /* do fake auto-alloc of graphics ports, if such config is used */
     for (i = 0; i < vm->def->ngraphics; ++i) {
         virDomainGraphicsDefPtr graphics = vm->def->graphics[i];
-        if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC &&
-            !graphics->data.vnc.socket && graphics->data.vnc.autoport) {
-            graphics->data.vnc.port = 5900;
+        if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
+            if (qemuProcessVNCAllocatePorts(driver, graphics, false) < 0)
+                goto cleanup;
         } else if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
             if (qemuProcessSPICEAllocatePorts(driver, cfg, graphics, false) < 0)
                 goto cleanup;
index d07a0237cecc60ca60a4cd1faf04900562123bec..22b27b35a5eaf0342a9052687d7cc8696fd64203 100644 (file)
@@ -3856,15 +3856,23 @@ qemuProcessReconnectAll(virConnectPtr conn, virQEMUDriverPtr driver)
     virDomainObjListForEach(driver->domains, qemuProcessReconnectHelper, &data);
 }
 
-static int
+int
 qemuProcessVNCAllocatePorts(virQEMUDriverPtr driver,
-                            virDomainGraphicsDefPtr graphics)
+                            virDomainGraphicsDefPtr graphics,
+                            bool allocate)
 {
     unsigned short port;
 
     if (graphics->data.vnc.socket)
         return 0;
 
+    if (!allocate) {
+        if (graphics->data.vnc.autoport)
+            graphics->data.vnc.port = 5900;
+
+        return 0;
+    }
+
     if (graphics->data.vnc.autoport) {
         if (virPortAllocatorAcquire(driver->remotePorts, &port) < 0)
             return -1;
@@ -4379,12 +4387,23 @@ qemuProcessSetupGraphics(virQEMUDriverPtr driver,
 
     for (i = 0; i < vm->def->ngraphics; ++i) {
         virDomainGraphicsDefPtr graphics = vm->def->graphics[i];
-        if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
-            if (qemuProcessVNCAllocatePorts(driver, graphics) < 0)
+
+        switch (graphics->type) {
+        case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
+            if (qemuProcessVNCAllocatePorts(driver, graphics, true) < 0)
                 goto cleanup;
-        } else if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
+            break;
+
+        case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
             if (qemuProcessSPICEAllocatePorts(driver, cfg, graphics, true) < 0)
                 goto cleanup;
+            break;
+
+        case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
+        case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
+        case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
+        case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
+            break;
         }
     }
 
index b7262a7e0f37e33b013f250c6854f6bc8e993b48..9e2e036ad328178099824ece9a5d21aad693be2a 100644 (file)
@@ -175,6 +175,9 @@ bool qemuProcessAutoDestroyActive(virQEMUDriverPtr driver,
 int qemuProcessSetSchedParams(int id, pid_t pid, size_t nsp,
                               virDomainThreadSchedParamPtr sp);
 
+int qemuProcessVNCAllocatePorts(virQEMUDriverPtr driver,
+                                virDomainGraphicsDefPtr graphics,
+                                bool allocate);
 int qemuProcessSPICEAllocatePorts(virQEMUDriverPtr driver,
                                   virQEMUDriverConfigPtr cfg,
                                   virDomainGraphicsDefPtr graphics,