On Thu, Jul 26, 2012 at 10:34:32PM +0400, Dmitry Guryanov wrote:
Add support for reading VNC parameters of the VM.
Signed-off-by: Dmitry Guryanov <dguryanov(a)parallels.com>
---
src/parallels/parallels_driver.c | 60 ++++++++++++++++++++++++++++++++++++++
1 files changed, 60 insertions(+), 0 deletions(-)
diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c
index ee31e6d..8340b69 100644
--- a/src/parallels/parallels_driver.c
+++ b/src/parallels/parallels_driver.c
@@ -295,6 +295,63 @@ parallelsAddDomainHardware(virDomainDefPtr def, virJSONValuePtr
jobj)
return -1;
}
+static int
+parallelsAddVNCInfo(virDomainDefPtr def, virJSONValuePtr jobj_root)
+{
+ const char *tmp;
+ unsigned int port;
+ virJSONValuePtr jobj;
+ int ret = -1;
+ virDomainGraphicsDefPtr gr = NULL;
+
+ jobj = virJSONValueObjectGet(jobj_root, "Remote display");
+ if (!jobj) {
+ parallelsParseError();
+ goto cleanup;
+ }
+
+ tmp = virJSONValueObjectGetString(jobj, "mode");
+ if (!tmp) {
+ parallelsParseError();
+ goto cleanup;
+ }
+
+ if (STREQ(tmp, "off")) {
+ ret = 0;
+ goto cleanup;
+ }
+
+ if (VIR_ALLOC(gr) < 0)
+ goto no_memory;
+
+ if (virJSONValueObjectGetNumberUint(jobj, "port", &port) < 0) {
+ parallelsParseError();
+ goto cleanup;
+ }
+
+ /* TODO: handle non-auto vnc mode */
+ gr->type = VIR_DOMAIN_GRAPHICS_TYPE_VNC;
+ gr->data.vnc.port = port;
+ gr->data.vnc.autoport = 0;
+ gr->data.vnc.keymap = NULL;
+ gr->data.vnc.socket = NULL;
+ gr->data.vnc.auth.passwd = NULL;
+ gr->data.vnc.auth.expires = 0;
+ gr->data.vnc.auth.connected = 0;
Do you have any information about what address the VNC server listens
on ? eg 127.0.0.1 vs 0.0.0.0, or something else. If so, its desirable
to fill in the listen address details. No worries if it isn't easily
available though.
+
+ if (VIR_REALLOC_N(def->graphics, def->ngraphics + 1) < 0)
+ goto no_memory;
+
+ def->graphics[def->ngraphics++] = gr;
+ return 0;
+
+ no_memory:
+ virReportOOMError();
+ cleanup:
+ virDomainGraphicsDefFree(gr);
+ return ret;
+}
+
/*
* Must be called with privconn->lock held
*/
@@ -421,6 +478,9 @@ parallelsLoadDomain(parallelsConnPtr privconn, virJSONValuePtr jobj)
if (parallelsAddDomainHardware(def, jobj2) < 0)
goto cleanup;
+ if (parallelsAddVNCInfo(def, jobj) < 0)
+ goto cleanup;
+
if (!(dom = virDomainAssignDef(privconn->caps,
&privconn->domains, def, false)))
goto cleanup;
ACK, regardless of my above comment
Daniel
--
|:
http://berrange.com -o-
http://www.flickr.com/photos/dberrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|:
http://entangle-photo.org -o-
http://live.gnome.org/gtk-vnc :|