[libvirt] [PATCH 16/18] qemu_process: move listen code out of qemuProcessSetupGraphics

Pavel Hrdina phrdina at redhat.com
Mon Apr 4 13:20:33 UTC 2016


Move adding the config listen type=address if there is none in
qemuProcessPrepareDomain and move check for multiple listens to
qemuProcessStartValidate.

Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
---
 src/qemu/qemu_process.c | 48 ++++++++++++++++++++++++++++--------------------
 1 file changed, 28 insertions(+), 20 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index cfd8a90..8eb2b52 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -4282,26 +4282,6 @@ qemuProcessSetupGraphics(virQEMUDriverPtr driver,
             if (qemuProcessSPICEAllocatePorts(driver, cfg, graphics, true) < 0)
                 goto cleanup;
         }
-
-        if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC ||
-            graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
-            if (graphics->nListens == 0) {
-                const char *listenAddr
-                    = graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC ?
-                    cfg->vncListen : cfg->spiceListen;
-
-                if (virDomainGraphicsListenAddAddress(graphics, 0,
-                                                      listenAddr) < 0)
-                    goto cleanup;
-
-                graphics->listens[0].fromConfig = true;
-            } else if (graphics->nListens > 1) {
-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                               _("QEMU does not support multiple listen "
-                                 "addresses for one graphics device."));
-                goto cleanup;
-            }
-        }
     }
 
     ret = 0;
@@ -4531,6 +4511,19 @@ qemuProcessStartValidate(virQEMUDriverPtr driver,
         }
     }
 
+    for (i = 0; i < vm->def->ngraphics; i++) {
+        virDomainGraphicsDefPtr graphics = vm->def->graphics[i];
+        if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC ||
+            graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
+            if (graphics->nListens > 1) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                               _("QEMU does not support multiple listen "
+                                 "addresses for one graphics device."));
+                return -1;
+            }
+        }
+    }
+
     return 0;
 }
 
@@ -5011,6 +5004,21 @@ qemuProcessPrepareDomain(virConnectPtr conn,
                 continue;
             }
         }
+
+        if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC ||
+            graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
+            if (graphics->nListens == 0) {
+                const char *listenAddr
+                    = graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC ?
+                    cfg->vncListen : cfg->spiceListen;
+
+                if (virDomainGraphicsListenAddAddress(graphics, 0,
+                                                      listenAddr) < 0)
+                    goto cleanup;
+
+                graphics->listens[0].fromConfig = true;
+            }
+        }
     }
 
     /* "volume" type disk's source must be translated before
-- 
2.7.4




More information about the libvir-list mailing list