]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Include the default listen address in the live guest XML
authorDaniel P. Berrange <berrange@redhat.com>
Mon, 25 Jun 2012 11:50:52 +0000 (12:50 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Mon, 25 Jun 2012 12:05:55 +0000 (13:05 +0100)
If no 'listen' attribute or <listen> element is set in the
guest XML, the default driver configured listen address is
used. There is no way to client applications to determine
what this address is though. When starting the guest, we
should update the live XML to include this default listen
address

src/qemu/qemu_process.c

index 1df363757ed8fa4b876e45fd7b3d6cf32179b33d..c5140c3c92a9ceec8cb7778c79c8542f60eca486 100644 (file)
@@ -3429,6 +3429,27 @@ int qemuProcessStart(virConnectPtr conn,
                 vm->def->graphics[0]->data.spice.tlsPort = tlsPort;
             }
         }
+
+        if (vm->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC ||
+            vm->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
+            virDomainGraphicsDefPtr graphics = vm->def->graphics[0];
+            if (graphics->nListens == 0) {
+                if (VIR_EXPAND_N(graphics->listens, graphics->nListens, 1) < 0) {
+                    virReportOOMError();
+                    goto cleanup;
+                }
+                graphics->listens[0].type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS;
+                if (vm->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC)
+                    graphics->listens[0].address = strdup(driver->vncListen);
+                else
+                    graphics->listens[0].address = strdup(driver->spiceListen);
+                if (!graphics->listens[0].address) {
+                    VIR_SHRINK_N(graphics->listens, graphics->nListens, 1);
+                    virReportOOMError();
+                    goto cleanup;
+                }
+            }
+        }
     }
 
     if (virFileMakePath(driver->logDir) < 0) {