Add patches to support capability bits in QXL

Also add patches for the included copy of spice-protocol.
This commit is contained in:
Søren Sandmann Pedersen 2012-09-06 13:58:53 -04:00
parent 4a8f34ac5f
commit 67b8b9fd9d
8 changed files with 315 additions and 0 deletions

View File

@ -0,0 +1,27 @@
From 8459b35ec0a2c1cddd7dab8b726e752bcde4c609 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=B8ren=20Sandmann=20Pedersen?= <ssp@redhat.com>
Date: Sat, 1 Sep 2012 11:19:41 -0400
Subject: [PATCH 1/2] Add A8 surface capability
Even though the ability to handle a8 surfaces was added at the same
time as the composite command, they are logically separate, so add a
capability bit to indicate the presence of a8 surfaces.
---
spice-common/spice-protocol/spice/protocol.h | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/spice-common/spice-protocol/spice/protocol.h b/spice-common/spice-protocol/spice/protocol.h
index 7008399..0671292 100644
--- a/spice-common/spice-protocol/spice/protocol.h
+++ b/spice-common/spice-protocol/spice/protocol.h
@@ -128,6 +128,7 @@ enum {
SPICE_DISPLAY_CAP_SIZED_STREAM,
SPICE_DISPLAY_CAP_MONITORS_CONFIG,
SPICE_DISPLAY_CAP_COMPOSITE,
+ SPICE_DISPLAY_CAP_A8_SURFACE,
};
enum {
--
1.7.4

View File

@ -0,0 +1,24 @@
From 9e9432c0233ff2e62170543634e5b2419891c0da Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=B8ren=20Sandmann=20Pedersen?= <ssp@redhat.com>
Date: Sat, 1 Sep 2012 11:30:58 -0400
Subject: [PATCH 1/5] client: Advertise A8_SURFACE capability
---
client/display_channel.cpp | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/client/display_channel.cpp b/client/display_channel.cpp
index d08072d..49a4c6a 100644
--- a/client/display_channel.cpp
+++ b/client/display_channel.cpp
@@ -652,6 +652,7 @@ DisplayChannel::DisplayChannel(RedClient& client, uint32_t id,
set_draw_handlers();
set_capability(SPICE_DISPLAY_CAP_COMPOSITE);
+ set_capability(SPICE_DISPLAY_CAP_A8_SURFACE);
}
DisplayChannel::~DisplayChannel()
--
1.7.4

View File

@ -0,0 +1,48 @@
From 361fd166b26b4450617b1f7175be9aaa7d8f6a7e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=B8ren=20Sandmann=20Pedersen?= <ssp@redhat.com>
Date: Fri, 24 Aug 2012 17:53:13 -0400
Subject: [PATCH 2/2] Add new client_present and client capabilities fields to QXLRom
The client_present field is a byte that is set of non-zero when a
client is connected and to zero when no client is connected.
The client_capabilities[58] array contains 464 bits that indicate the
capabilities of the client. Each bit corresponds to a
SPICE_DISPLAY_CAP_* capability. In particular, if the client has
capability C, then bit (C % 8) in byte (C / 8) is set. The capability
bits only have a defined meaning when a client is connected, ie., when
client_present is non-zero. The number 58 was chosen to fill out a
cache line in QXLRom.
A new QXL_INTERRUPT_CLIENT interrupt is defined, which will be raised
whenever a client connects or disconnects.
---
spice-common/spice-protocol/spice/qxl_dev.h | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/spice-common/spice-protocol/spice/qxl_dev.h b/spice-common/spice-protocol/spice/qxl_dev.h
index 1292767..50784dc 100644
--- a/spice-common/spice-protocol/spice/qxl_dev.h
+++ b/spice-common/spice-protocol/spice/qxl_dev.h
@@ -148,7 +148,9 @@ typedef struct SPICE_ATTR_PACKED QXLRom {
uint8_t slot_gen_bits;
uint8_t slot_id_bits;
uint8_t slot_generation;
- uint8_t padding[3]; /* Padding to 32bit align */
+ /* appended for qxl-4 */
+ uint8_t client_present;
+ uint8_t client_capabilities[58];
} QXLRom;
/* qxl-1 compat: fixed */
@@ -231,6 +233,7 @@ SPICE_RING_DECLARE(QXLReleaseRing, uint64_t, QXL_RELEASE_RING_SIZE);
#define QXL_INTERRUPT_CURSOR (1 << 1)
#define QXL_INTERRUPT_IO_CMD (1 << 2)
#define QXL_INTERRUPT_ERROR (1 << 3)
+#define QXL_INTERRUPT_CLIENT (1 << 4)
/* qxl-1 compat: append only */
typedef struct SPICE_ATTR_PACKED QXLRam {
--
1.7.4

View File

@ -0,0 +1,90 @@
From 83b3e3f20dbd7c87e2d7cace68d99138c09ed6ab Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=B8ren=20Sandmann=20Pedersen?= <ssp@redhat.com>
Date: Thu, 23 Aug 2012 22:04:24 -0400
Subject: [PATCH 2/5] Add new set_client_capabilities() interface to QXLInstance
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 eee9915..1e301c4 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -10344,6 +10344,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);
@@ -11198,9 +11215,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 fdcfbb7..6114407 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

View File

@ -0,0 +1,34 @@
From f5145d9185d02c597672d5fd65420d5ffc692b4a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=B8ren=20Sandmann=20Pedersen?= <ssp@redhat.com>
Date: Sat, 1 Sep 2012 11:13:49 -0400
Subject: [PATCH 3/5] Process outstanding commands in the ring after changing capability bits
When a new client connects, there may be commands in the ring that it
can't understand, so we need to process these before forwarding new
commands to the client. By doing this after changing the capability
bits we ensure that the new client will never see a command that it
doesn't understand (under the assumption that the guest will read and
obey the capability bits).
---
server/red_worker.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/server/red_worker.c b/server/red_worker.c
index 1e301c4..75bc045 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -9478,6 +9478,11 @@ static void on_new_display_channel_client(DisplayChannelClient *dcc)
}
red_channel_client_ack_zero_messages_window(&dcc->common.base);
if (worker->surfaces[0].context.canvas) {
+ int ring_is_empty;
+
+ while (red_process_commands(worker, MAX_PIPE_SIZE, &ring_is_empty)) {
+ }
+
red_current_flush(worker, 0);
push_new_primary_surface(dcc);
red_push_surface_image(dcc, 0);
--
1.7.4

View File

@ -0,0 +1,25 @@
From c7ab6dfdea5edca6ad407b1fcb6df5ff30007fc0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=B8ren=20Sandmann=20Pedersen?= <ssp@redhat.com>
Date: Sat, 1 Sep 2012 11:34:43 -0400
Subject: [PATCH 4/5] Set a8 capability in the QXL device if supported by the client
---
server/red_worker.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/server/red_worker.c b/server/red_worker.c
index 75bc045..81fffd7 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -10362,6 +10362,8 @@ static void handle_new_display_channel(RedWorker *worker, RedClient *client, Red
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);
+ if (red_channel_client_test_remote_cap(rcc, SPICE_DISPLAY_CAP_A8_SURFACE))
+ SET_CAP(caps, SPICE_DISPLAY_CAP_A8_SURFACE);
worker->qxl->st->qif->set_client_capabilities(worker->qxl, TRUE, caps);
}
--
1.7.4

View File

@ -0,0 +1,30 @@
From 02133161419e56880594a357c525f1ec57f711c5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=B8ren=20Sandmann=20Pedersen?= <ssp@redhat.com>
Date: Sat, 1 Sep 2012 11:42:56 -0400
Subject: [PATCH 5/5] Bump spice.h version number to 0.11.4
No new symbols are added, but there is an addition to QXLInterface:
void (*set_client_capabilities)(QXLInstance *qin,
uint8_t client_present,
uint8_t caps[58]);
---
server/spice.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/server/spice.h b/server/spice.h
index 6114407..3152f8c 100644
--- a/server/spice.h
+++ b/server/spice.h
@@ -22,7 +22,7 @@
#include <sys/socket.h>
#include <spice/qxl_dev.h>
-#define SPICE_SERVER_VERSION 0x000b02 /* release 0.11.2 */
+#define SPICE_SERVER_VERSION 0x000b04 /* release 0.11.4 */
/* interface base type */
--
1.7.4

View File

@ -17,6 +17,28 @@ URL: http://www.spice-space.org/
Source0: http://www.spice-space.org/download/releases/%{name}-%{version}.tar.bz2
Source1: spice-xpi-client-spicec
Patch1: 0001-client-Advertise-A8_SURFACE-capability.patch
Patch2: 0002-Add-new-set_client_capabilities-interface-to-QXLInst.patch
Patch3: 0003-Process-outstanding-commands-in-the-ring-after-chang.patch
Patch4: 0004-Set-a8-capability-in-the-QXL-device-if-supported-by-.patch
Patch5: 0005-Bump-spice.h-version-number-to-0.11.4.patch
# -=-=-=- Protocol patches -=-=-=-
#
# FIXME: These patches are required because the upstream package now
# includes and builds against its own copy of spice-protocol instead
# of the one installed on the system.
#
# This needs to be fixed upstream. Keeping patches in sync across
# spice-protocol and spice is unmaintainable. Possible fixes:
#
# - Stop using a spice-protocol submodule
#
# - Add a configure switch to use the system spice-protocol headers.
#
Patch6: 0001-Add-A8-surface-capability.patch
Patch7: 0002-Add-new-client_present-and-client-capabilities-field.patch
# https://bugzilla.redhat.com/show_bug.cgi?id=613529
%if 0%{?rhel}
@ -86,6 +108,14 @@ using spice-server, you will need to install spice-server-devel.
%prep
%setup -q
%patch1 -p1 -b 0001-client-Advertise-A8_SURFACE-capability
%patch2 -p1 -b 0002-Add-new-set_client_capabilities-interface-to-QXLInst
%patch3 -p1 -b 0003-Process-outstanding-commands-in-the-ring-after-chang
%patch4 -p1 -b 0004-Set-a8-capability-in-the-QXL-device-if-supported-by-
%patch5 -p1 -b 0005-Bump-spice.h-version-number-to-0.11.4
%patch6 -p1 -b 0001-Add-A8-surface-capability
%patch7 -p1 -b 0002-Add-new-client_present-and-client-capabilities-field
%build
%if %{build_client}
@ -142,6 +172,13 @@ fi
%{_libdir}/pkgconfig/spice-server.pc
%changelog
* Thu Sep 6 2012 Soren Sandmann <ssp@redhat.com> - 0.11.3-1
- Add capability patches
- Add capability patches to the included copy of spice-protocol
Please see the comment above Patch6 and Patch7
regarding this situation.
* Thu Sep 6 2012 Soren Sandmann <ssp@redhat.com> - 0.11.3-1
- Update to 0.11.3 and drop upstreamed patches
- BuildRequire spice-protocol 0.12.1