Re: [PATCH v8 5/8] parallels: add support of VNC remote display

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 07/04/12 19:42, Dmitry Guryanov wrote:
Add support for reading VNC parameters of the VM.

Signed-off-by: Dmitry Guryanov <dguryanov@xxxxxxxxxxxxx>
---
  src/parallels/parallels_driver.c |   65 ++++++++++++++++++++++++++++++++++++++
  1 files changed, 65 insertions(+), 0 deletions(-)

diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c
index 270ac21..b3d863f 100644
--- a/src/parallels/parallels_driver.c
+++ b/src/parallels/parallels_driver.c
@@ -259,6 +259,68 @@ parallelsAddDomainHardware(virDomainObjPtr dom, virJSONValuePtr jobj)
      return -1;
  }

+static int
+parallelsAddVNCInfo(virDomainObjPtr dom, virJSONValuePtr jobj_root)
+{
+    const char *tmp;
+    unsigned int port;
+    virJSONValuePtr jobj;
+    int ret = -1;
+
+    virDomainDefPtr def = dom->def;
+
+    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;
+
+    if (VIR_REALLOC_N(def->graphics, def->ngraphics + 1) < 0) {
+        virDomainGraphicsDefFree(gr);

Free this in the cleanup section.

+        goto no_memory;
+    }
+
+    def->graphics[def->ngraphics++] = gr;
+    return 0;
+
+  no_memory:
+    virReportOOMError();
+  cleanup:
+    VIR_FREE(gr);

And use the proper freeing function.

+    return ret;
+}
+
  /*
   * Must be called with privconn->lock held
   */
@@ -410,6 +472,9 @@ parallelsLoadDomain(parallelsConnPtr privconn, virJSONValuePtr jobj)
      if (parallelsAddDomainHardware(dom, jobj2) < 0)
          goto cleanup_unlock;

+    if (parallelsAddVNCInfo(dom, jobj) < 0)
+        goto cleanup_unlock;
+
      virDomainObjUnlock(dom);

      return dom;


Otherwise looks good.

Peter

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]