qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>, Anthony Liguori <aliguori@amazon.com>
Subject: [Qemu-devel] [PULL 05/10] vnc: allow binding servers to qemu consoles
Date: Thu, 22 Jan 2015 12:04:03 +0100	[thread overview]
Message-ID: <1421924648-21963-6-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1421924648-21963-1-git-send-email-kraxel@redhat.com>

This patch adds a display= parameter to the vnc options.  This allows to
bind a vnc server instance to a specific display, allowing to create a
multiseat setup with a vnc server for each seat.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/vnc.c | 50 +++++++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 43 insertions(+), 7 deletions(-)

diff --git a/ui/vnc.c b/ui/vnc.c
index 24cf08b..091e809 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -27,6 +27,7 @@
 #include "vnc.h"
 #include "vnc-jobs.h"
 #include "trace.h"
+#include "hw/qdev.h"
 #include "sysemu/sysemu.h"
 #include "qemu/sockets.h"
 #include "qemu/timer.h"
@@ -1665,7 +1666,8 @@ static void do_key_event(VncState *vs, int down, int keycode, int sym)
             vs->modifiers_state[keycode] = 0;
         break;
     case 0x02 ... 0x0a: /* '1' to '9' keys */
-        if (down && vs->modifiers_state[0x1d] && vs->modifiers_state[0x38]) {
+        if (vs->vd->dcl.con == NULL &&
+            down && vs->modifiers_state[0x1d] && vs->modifiers_state[0x38]) {
             /* Reset the modifiers sent to the current console */
             reset_keys(vs);
             console_select(keycode - 0x02);
@@ -2073,8 +2075,8 @@ static void set_pixel_format(VncState *vs,
 
     set_pixel_conversion(vs);
 
-    graphic_hw_invalidate(NULL);
-    graphic_hw_update(NULL);
+    graphic_hw_invalidate(vs->vd->dcl.con);
+    graphic_hw_update(vs->vd->dcl.con);
 }
 
 static void pixel_format_message (VncState *vs) {
@@ -2801,7 +2803,7 @@ static void vnc_refresh(DisplayChangeListener *dcl)
         return;
     }
 
-    graphic_hw_update(NULL);
+    graphic_hw_update(vd->dcl.con);
 
     if (vnc_trylock_display(vd)) {
         update_displaychangelistener(&vd->dcl, VNC_REFRESH_INTERVAL_BASE);
@@ -2907,7 +2909,7 @@ void vnc_init_state(VncState *vs)
 
     QTAILQ_INSERT_HEAD(&vd->clients, vs, next);
 
-    graphic_hw_update(NULL);
+    graphic_hw_update(vd->dcl.con);
 
     vnc_write(vs, "RFB 003.008\n", 12);
     vnc_flush(vs);
@@ -2930,7 +2932,7 @@ static void vnc_listen_read(void *opaque, bool websocket)
     int csock;
 
     /* Catch-up */
-    graphic_hw_update(NULL);
+    graphic_hw_update(vs->dcl.con);
 #ifdef CONFIG_VNC_WS
     if (websocket) {
         csock = qemu_accept(vs->lwebsock, (struct sockaddr *)&addr, &addrlen);
@@ -3090,6 +3092,12 @@ static QemuOptsList qemu_vnc_opts = {
             .name = "share",
             .type = QEMU_OPT_STRING,
         },{
+            .name = "display",
+            .type = QEMU_OPT_STRING,
+        },{
+            .name = "head",
+            .type = QEMU_OPT_NUMBER,
+        },{
             .name = "password",
             .type = QEMU_OPT_BOOL,
         },{
@@ -3125,7 +3133,8 @@ void vnc_display_open(const char *id, Error **errp)
 {
     VncDisplay *vs = vnc_display_find(id);
     QemuOpts *opts = qemu_opts_find(&qemu_vnc_opts, id);
-    const char *display, *websocket, *share;
+    const char *display, *websocket, *share, *device_id;
+    QemuConsole *con;
     int password = 0;
     int reverse = 0;
 #ifdef CONFIG_VNC_TLS
@@ -3354,6 +3363,33 @@ void vnc_display_open(const char *id, Error **errp)
 #endif
     vs->lock_key_sync = lock_key_sync;
 
+    device_id = qemu_opt_get(opts, "display");
+    if (device_id) {
+        DeviceState *dev;
+        int head = qemu_opt_get_number(opts, "head", 0);
+
+        dev = qdev_find_recursive(sysbus_get_default(), device_id);
+        if (dev == NULL) {
+            error_set(errp, QERR_DEVICE_NOT_FOUND, device_id);
+            goto fail;
+        }
+
+        con = qemu_console_lookup_by_device(dev, head);
+        if (con == NULL) {
+            error_setg(errp, "Device %s is not bound to a QemuConsole",
+                       device_id);
+            goto fail;
+        }
+    } else {
+        con = NULL;
+    }
+
+    if (con != vs->dcl.con) {
+        unregister_displaychangelistener(&vs->dcl);
+        vs->dcl.con = con;
+        register_displaychangelistener(&vs->dcl);
+    }
+
     if (reverse) {
         /* connect to viewer */
         int csock;
-- 
1.8.3.1

  parent reply	other threads:[~2015-01-22 11:04 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-22 11:03 [Qemu-devel] [PULL 00/10] vnc: add support for multiple vnc displays Gerd Hoffmann
2015-01-22 11:03 ` [Qemu-devel] [PULL 01/10] vnc: remove vnc_display global Gerd Hoffmann
2015-01-22 11:04 ` [Qemu-devel] [PULL 02/10] vnc: remove unused DisplayState parameter, add id instead Gerd Hoffmann
2015-01-22 11:04 ` [Qemu-devel] [PULL 03/10] vnc: add display id to acl names Gerd Hoffmann
2015-01-22 11:04 ` [Qemu-devel] [PULL 04/10] vnc: switch to QemuOpts, allow multiple servers Gerd Hoffmann
2015-01-22 11:04 ` Gerd Hoffmann [this message]
2015-01-22 11:04 ` [Qemu-devel] [PULL 06/10] vnc: update docs/multiseat.txt Gerd Hoffmann
2015-01-22 11:04 ` [Qemu-devel] [PULL 07/10] vnc: track & limit connections Gerd Hoffmann
2015-01-22 11:04 ` [Qemu-devel] [PULL 08/10] vnc: factor out qmp_query_client_list Gerd Hoffmann
2015-01-22 11:04 ` [Qemu-devel] [PULL 09/10] monitor: add query-vnc-servers command Gerd Hoffmann
2015-01-22 11:04 ` [Qemu-devel] [PULL 10/10] monitor: add vnc websockets Gerd Hoffmann
2015-01-22 13:55 ` [Qemu-devel] [PULL 00/10] vnc: add support for multiple vnc displays Peter Maydell
  -- strict thread matches above, loose matches on Subject: below --
2014-12-19  9:04 Gerd Hoffmann
2014-12-19  9:04 ` [Qemu-devel] [PULL 05/10] vnc: allow binding servers to qemu consoles Gerd Hoffmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1421924648-21963-6-git-send-email-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=aliguori@amazon.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).