From patchwork Thu Jan 22 11:04:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 431771 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 50617140281 for ; Thu, 22 Jan 2015 22:11:17 +1100 (AEDT) Received: from localhost ([::1]:52371 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEFfP-0000qd-Fa for incoming@patchwork.ozlabs.org; Thu, 22 Jan 2015 06:11:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38509) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEFYl-0006L2-6I for qemu-devel@nongnu.org; Thu, 22 Jan 2015 06:04:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YEFYe-0002YO-1Q for qemu-devel@nongnu.org; Thu, 22 Jan 2015 06:04:23 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60961) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEFYd-0002Xx-R1 for qemu-devel@nongnu.org; Thu, 22 Jan 2015 06:04:15 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0MB4ET8000712 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 22 Jan 2015 06:04:14 -0500 Received: from nilsson.home.kraxel.org (ovpn-116-36.ams2.redhat.com [10.36.116.36]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t0MB4Dif029926; Thu, 22 Jan 2015 06:04:13 -0500 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id D384480E4D; Thu, 22 Jan 2015 12:04:10 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 22 Jan 2015 12:04:03 +0100 Message-Id: <1421924648-21963-6-git-send-email-kraxel@redhat.com> In-Reply-To: <1421924648-21963-1-git-send-email-kraxel@redhat.com> References: <1421924648-21963-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Gerd Hoffmann , Anthony Liguori Subject: [Qemu-devel] [PULL 05/10] vnc: allow binding servers to qemu consoles X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- 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;