qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Søren Sandmann" <sandmann@cs.au.dk>
To: spice-devel@freedesktop.org, qemu-devel@nongnu.org
Cc: "Søren Sandmann Pedersen" <ssp@redhat.com>
Subject: [Qemu-devel] [PATCH 2/5] Add new set_client_capabilities() interface to QXLInstance
Date: Mon,  3 Sep 2012 13:53:52 -0400	[thread overview]
Message-ID: <1346694835-23590-2-git-send-email-sandmann@cs.au.dk> (raw)
In-Reply-To: <1346694835-23590-1-git-send-email-sandmann@cs.au.dk>

From: Søren Sandmann Pedersen <ssp@redhat.com>

A new interface

  set_client_capabilities (QXLInstance *qin,
  			   uint8_t client_present,
  			   uint8_t caps[58]);

is added to QXLInstance, and spice server is changed to call it
whenever a client connects or disconnects. The QXL device in response
is expected to update the client capability bits in the ROM of the
device and raise the QXL_INTERRUPT_CLIENT interrupt.

There is a potential race condition in the case where a client
disconnects and a new client with fewer capabilities connects. There
may be commands in the ring that the new client can't handle. This
case is handled by first changing the capability bits, then processing
all commands in the ring, and then start forwarding commands to the
new client. As long as the guest obeys the capability bits, the new
client will never see anything it doesn't understand.
---
 server/red_worker.c |   24 ++++++++++++++++++++++++
 server/spice.h      |    3 +++
 2 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/server/red_worker.c b/server/red_worker.c
index 133ba94..60b5471 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -10359,6 +10359,23 @@ static void handle_new_display_channel(RedWorker *worker, RedClient *client, Red
     spice_info("jpeg %s", display_channel->enable_jpeg ? "enabled" : "disabled");
     spice_info("zlib-over-glz %s", display_channel->enable_zlib_glz_wrap ? "enabled" : "disabled");
 
+    if (worker->qxl->st->qif->set_client_capabilities) {
+        RedChannelClient *rcc = (RedChannelClient *)dcc;
+        uint8_t caps[58] = { 0 };
+
+#define SET_CAP(a,c)                                                    \
+        ((a)[(c) / 8] |= (1 << ((c) % 8)))
+
+        if (red_channel_client_test_remote_cap(rcc, SPICE_DISPLAY_CAP_SIZED_STREAM))
+            SET_CAP(caps, SPICE_DISPLAY_CAP_SIZED_STREAM);
+        if (red_channel_client_test_remote_cap(rcc, SPICE_DISPLAY_CAP_MONITORS_CONFIG))
+            SET_CAP(caps, SPICE_DISPLAY_CAP_MONITORS_CONFIG);
+        if (red_channel_client_test_remote_cap(rcc, SPICE_DISPLAY_CAP_COMPOSITE))
+            SET_CAP(caps, SPICE_DISPLAY_CAP_COMPOSITE);
+
+        worker->qxl->st->qif->set_client_capabilities(worker->qxl, TRUE, caps);
+    }
+    
     // todo: tune level according to bandwidth
     display_channel->zlib_level = ZLIB_DEFAULT_COMPRESSION_LEVEL;
     red_display_client_init_streams(dcc);
@@ -11213,9 +11230,16 @@ void handle_dev_display_disconnect(void *opaque, void *payload)
 {
     RedWorkerMessageDisplayDisconnect *msg = payload;
     RedChannelClient *rcc = msg->rcc;
+    RedWorker *worker = opaque;
 
     spice_info("disconnect display client");
     spice_assert(rcc);
+
+    if (worker->qxl->st->qif->set_client_capabilities) {
+        uint8_t caps[58] = { 0 };
+        worker->qxl->st->qif->set_client_capabilities(worker->qxl, FALSE, caps);
+    }
+
     red_channel_client_disconnect(rcc);
 }
 
diff --git a/server/spice.h b/server/spice.h
index 0dc9d05..9d65efa 100644
--- a/server/spice.h
+++ b/server/spice.h
@@ -239,6 +239,9 @@ struct QXLInterface {
     void (*update_area_complete)(QXLInstance *qin, uint32_t surface_id,
                                  struct QXLRect *updated_rects,
                                  uint32_t num_updated_rects);
+    void (*set_client_capabilities)(QXLInstance *qin,
+				    uint8_t client_present,
+				    uint8_t caps[58]);
 };
 
 struct QXLInstance {
-- 
1.7.4

  reply	other threads:[~2012-09-03 17:51 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-27 17:20 [Qemu-devel] Add ability to advertise client capabilities to QXL device Søren Sandmann Pedersen
2012-08-27 17:20 ` [Qemu-devel] [PATCH] Add new client_present and client capabilities fields to QXLRom Søren Sandmann Pedersen
2012-08-28  6:15   ` Gerd Hoffmann
2012-08-29  0:58     ` Søren Sandmann
2012-08-29  6:00       ` Gerd Hoffmann
2012-08-29 21:05         ` Søren Sandmann
2012-08-29 10:14       ` [Qemu-devel] [Spice-devel] " Alon Levy
2012-08-29 20:51         ` Søren Sandmann
2012-08-30  5:34           ` Gerd Hoffmann
2012-08-30 16:03             ` Søren Sandmann
2012-08-31  7:32               ` Gerd Hoffmann
2012-09-02 21:35                 ` [Qemu-devel] New patches to add capabilities to spice and qxl Søren Sandmann Pedersen
2012-09-02 21:35                   ` [Qemu-devel] [PATCH-v2 spice-protocol 1/2] Add A8 surface capability Søren Sandmann Pedersen
2012-09-02 21:35                   ` [Qemu-devel] [PATCH-v2 spice-protocol 2/2] Add new client_present and client capabilities fields to QXLRom Søren Sandmann Pedersen
2012-09-02 21:35                   ` [Qemu-devel] [PATCH-v2 spice-gtk] Advertise SPICE_DISPLAY_CAP_A8_SURFACE Søren Sandmann Pedersen
2012-09-02 21:35                   ` [Qemu-devel] [PATCH-v2 spice 1/2] Set a8 capability in the QXL device if supported by the client Søren Sandmann Pedersen
2012-09-03  7:34                     ` Alon Levy
2012-09-03 17:33                       ` Søren Sandmann
2012-09-03 17:49                         ` Søren Sandmann
2012-09-03 17:53                           ` [Qemu-devel] [PATCH 1/5] client: Advertise A8_SURFACE capability Søren Sandmann
2012-09-03 17:53                             ` Søren Sandmann [this message]
2012-09-03 17:53                             ` [Qemu-devel] [PATCH 3/5] Process outstanding commands in the ring after changing capability bits Søren Sandmann
2012-09-03 18:31                               ` [Qemu-devel] [Spice-devel] " Alon Levy
2012-09-03 17:53                             ` [Qemu-devel] [PATCH 4/5] Set a8 capability in the QXL device if supported by the client Søren Sandmann
2012-09-03 17:53                             ` [Qemu-devel] [PATCH 5/5] Bump spice.h version number to 0.11.4 Søren Sandmann
2012-09-02 21:35                   ` [Qemu-devel] [PATCH-v2 spice 2/2] " Søren Sandmann Pedersen
2012-09-02 21:35                   ` [Qemu-devel] [PATCH-v2 qemu] qxl: Add set_client_capabilities() interface to QXLInterface Søren Sandmann Pedersen
2012-09-03 17:36                     ` [Qemu-devel] [Spice-devel] " Søren Sandmann
2012-09-03 17:40                       ` [Qemu-devel] [PATCH] " Søren Sandmann
2012-09-03 18:21                         ` Alon Levy
2012-09-04 10:12                     ` [Qemu-devel] [PATCH-v2 qemu] " Gerd Hoffmann
2012-09-04 14:14                       ` [Qemu-devel] [PATCH 1/2] " Søren Sandmann
2012-09-04 14:14                         ` [Qemu-devel] [PATCH 2/2] Remove #ifdef QXL_COMMAND_FLAG_COMPAT_16BPP Søren Sandmann
2012-09-04 14:46                         ` [Qemu-devel] [PATCH 1/2] qxl: Add set_client_capabilities() interface to QXLInterface Gerd Hoffmann
2012-08-27 17:20 ` [Qemu-devel] [PATCH] Add new set_client_capabilities() interface to QXLInstance Søren Sandmann Pedersen
2012-08-27 17:20 ` [Qemu-devel] [PATCH] qxl: Add set_client_capabilities() interface to QXLInterface Søren Sandmann Pedersen
2012-08-28  6:19   ` Gerd Hoffmann
2012-08-27 17:20 ` [Qemu-devel] Add ability to advertise client capabilities to QXL device Søren Sandmann Pedersen

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=1346694835-23590-2-git-send-email-sandmann@cs.au.dk \
    --to=sandmann@cs.au.dk \
    --cc=qemu-devel@nongnu.org \
    --cc=spice-devel@freedesktop.org \
    --cc=ssp@redhat.com \
    /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).