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

[libvirt] [PATCH 3/3 v3] qemu: add ', share=<policy>' to qemu commandline



example: qemu ${otherargs} \
             -vnc 127.0.0.1:0,share=allow-exclusive
---
 src/qemu/qemu_command.c  | 36 ++++++++++++++++++++++++++++++++++++
 tests/qemuargv2xmltest.c |  1 +
 tests/qemuxml2argvtest.c |  1 +
 3 files changed, 38 insertions(+)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 5b95c07..a462153 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6098,6 +6098,19 @@ qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr cfg,
                 virBufferAsprintf(&opt, ",websocket=%d", graphics->data.vnc.websocket);
             }
 
+        if (graphics->data.vnc.sharePolicy) {
+            if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VNC_SHARE_POLICY)) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                               _("vnc display sharing policy is not "
+                                 "supported with this QEMU"));
+                goto error;
+            }
+
+            virBufferAsprintf(&opt, ",share=%s",
+                              virDomainGraphicsVNCSharePolicyTypeToString(
+                              graphics->data.vnc.sharePolicy));
+        }
+
         if (graphics->data.vnc.auth.passwd || cfg->vncPassword)
             virBufferAddLit(&opt, ",password");
 
@@ -10013,6 +10026,29 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr qemuCaps,
                                 vnc->data.vnc.websocket =
                                     vnc->data.vnc.port + 5700;
                             }
+                        } else if (STRPREFIX(opts, "share=")) {
+                            char *sharePolicy = opts + strlen("share=");
+                            if (sharePolicy && *sharePolicy) {
+                                int policy =
+                                    virDomainGraphicsVNCSharePolicyTypeFromString(sharePolicy);
+
+                                if (policy < 0) {
+                                    virReportError(VIR_ERR_INTERNAL_ERROR,
+                                                   _("unknown vnc display sharing policy '%s'"),
+                                                     sharePolicy);
+                                    virDomainGraphicsDefFree(vnc);
+                                    VIR_FREE(orig_opts);
+                                    goto error;
+                                } else {
+                                    vnc->data.vnc.sharePolicy = policy;
+                                }
+                            } else {
+                                virReportError(VIR_ERR_INTERNAL_ERROR,
+                                               _("missing vnc sharing policy"));
+                                virDomainGraphicsDefFree(vnc);
+                                VIR_FREE(orig_opts);
+                                goto error;
+                            }
                         }
 
                         opts = nextopt;
diff --git a/tests/qemuargv2xmltest.c b/tests/qemuargv2xmltest.c
index 58fabdb..652cd09 100644
--- a/tests/qemuargv2xmltest.c
+++ b/tests/qemuargv2xmltest.c
@@ -201,6 +201,7 @@ mymain(void)
     DO_TEST("graphics-vnc");
     DO_TEST("graphics-vnc-socket");
     DO_TEST("graphics-vnc-websocket");
+    DO_TEST("graphics-vnc-policy");
 
     DO_TEST("graphics-vnc-sasl");
     DO_TEST("graphics-vnc-tls");
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index c751440..e32f12d 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -609,6 +609,7 @@ mymain(void)
     DO_TEST("graphics-vnc", QEMU_CAPS_VNC);
     DO_TEST("graphics-vnc-socket", QEMU_CAPS_VNC);
     DO_TEST("graphics-vnc-websocket", QEMU_CAPS_VNC, QEMU_CAPS_VNC_WEBSOCKET);
+    DO_TEST("graphics-vnc-policy", QEMU_CAPS_VNC, QEMU_CAPS_VNC_SHARE_POLICY);
 
     driver.config->vncSASL = 1;
     VIR_FREE(driver.config->vncSASLdir);
-- 
1.8.1.4


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