* [Qemu-devel] [PATCH 1/3] qxl: stride fixup
2011-11-01 12:39 [Qemu-devel] [PULL] spice patch queue Gerd Hoffmann
@ 2011-11-01 12:39 ` Gerd Hoffmann
2011-11-01 12:39 ` [Qemu-devel] [PATCH 2/3] qxl: make sure we continue to run with a shared buffer Gerd Hoffmann
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Gerd Hoffmann @ 2011-11-01 12:39 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
spice uses negative stride value to signal the bitmap is upside down.
The qxl renderer (used for scl, vnc and screenshots) wants a positive
value because it is easier to work with. The positive value is then
stored in the very same variable, which has the drawback that the
upside-down test works only once. Fix by using two variables.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/qxl-render.c | 23 ++++++++++++-----------
hw/qxl.h | 3 ++-
2 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/hw/qxl-render.c b/hw/qxl-render.c
index c290739..a567693 100644
--- a/hw/qxl-render.c
+++ b/hw/qxl-render.c
@@ -28,16 +28,16 @@ static void qxl_flip(PCIQXLDevice *qxl, QXLRect *rect)
int len, i;
src += (qxl->guest_primary.surface.height - rect->top - 1) *
- qxl->guest_primary.stride;
- dst += rect->top * qxl->guest_primary.stride;
+ qxl->guest_primary.abs_stride;
+ dst += rect->top * qxl->guest_primary.abs_stride;
src += rect->left * qxl->guest_primary.bytes_pp;
dst += rect->left * qxl->guest_primary.bytes_pp;
len = (rect->right - rect->left) * qxl->guest_primary.bytes_pp;
for (i = rect->top; i < rect->bottom; i++) {
memcpy(dst, src, len);
- dst += qxl->guest_primary.stride;
- src -= qxl->guest_primary.stride;
+ dst += qxl->guest_primary.abs_stride;
+ src -= qxl->guest_primary.abs_stride;
}
}
@@ -45,7 +45,8 @@ void qxl_render_resize(PCIQXLDevice *qxl)
{
QXLSurfaceCreate *sc = &qxl->guest_primary.surface;
- qxl->guest_primary.stride = sc->stride;
+ qxl->guest_primary.qxl_stride = sc->stride;
+ qxl->guest_primary.abs_stride = abs(sc->stride);
qxl->guest_primary.resized++;
switch (sc->format) {
case SPICE_SURFACE_FMT_16_555:
@@ -87,11 +88,11 @@ void qxl_render_update(PCIQXLDevice *qxl)
qemu_free_displaysurface(vga->ds);
qxl->guest_primary.data = memory_region_get_ram_ptr(&qxl->vga.vram);
- if (qxl->guest_primary.stride < 0) {
+ if (qxl->guest_primary.qxl_stride < 0) {
/* spice surface is upside down -> need extra buffer to flip */
- qxl->guest_primary.stride = -qxl->guest_primary.stride;
- qxl->guest_primary.flipped = g_malloc(qxl->guest_primary.surface.width *
- qxl->guest_primary.stride);
+ qxl->guest_primary.flipped =
+ g_malloc(qxl->guest_primary.surface.width *
+ qxl->guest_primary.abs_stride);
ptr = qxl->guest_primary.flipped;
} else {
ptr = qxl->guest_primary.data;
@@ -100,7 +101,7 @@ void qxl_render_update(PCIQXLDevice *qxl)
__FUNCTION__,
qxl->guest_primary.surface.width,
qxl->guest_primary.surface.height,
- qxl->guest_primary.stride,
+ qxl->guest_primary.qxl_stride,
qxl->guest_primary.bytes_pp,
qxl->guest_primary.bits_pp,
qxl->guest_primary.flipped ? "yes" : "no");
@@ -108,7 +109,7 @@ void qxl_render_update(PCIQXLDevice *qxl)
qemu_create_displaysurface_from(qxl->guest_primary.surface.width,
qxl->guest_primary.surface.height,
qxl->guest_primary.bits_pp,
- qxl->guest_primary.stride,
+ qxl->guest_primary.abs_stride,
ptr);
dpy_resize(vga->ds);
}
diff --git a/hw/qxl.h b/hw/qxl.h
index 37b2619..766aa6d 100644
--- a/hw/qxl.h
+++ b/hw/qxl.h
@@ -48,7 +48,8 @@ typedef struct PCIQXLDevice {
QXLSurfaceCreate surface;
uint32_t commands;
uint32_t resized;
- int32_t stride;
+ int32_t qxl_stride;
+ uint32_t abs_stride;
uint32_t bits_pp;
uint32_t bytes_pp;
uint8_t *data, *flipped;
--
1.7.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH 2/3] qxl: make sure we continue to run with a shared buffer
2011-11-01 12:39 [Qemu-devel] [PULL] spice patch queue Gerd Hoffmann
2011-11-01 12:39 ` [Qemu-devel] [PATCH 1/3] qxl: stride fixup Gerd Hoffmann
@ 2011-11-01 12:39 ` Gerd Hoffmann
2011-11-01 12:39 ` [Qemu-devel] [PATCH 3/3] qxl: create slots on post_load in vga state Gerd Hoffmann
2011-11-01 18:13 ` [Qemu-devel] [PULL] spice patch queue Anthony Liguori
3 siblings, 0 replies; 5+ messages in thread
From: Gerd Hoffmann @ 2011-11-01 12:39 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
The qxl renderer works only with a shared displaysurface. So better
make sure we actually have one and restore it when needed.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/qxl-render.c | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/hw/qxl-render.c b/hw/qxl-render.c
index a567693..2c51ba9 100644
--- a/hw/qxl-render.c
+++ b/hw/qxl-render.c
@@ -76,7 +76,14 @@ void qxl_render_update(PCIQXLDevice *qxl)
VGACommonState *vga = &qxl->vga;
QXLRect dirty[32], update;
void *ptr;
- int i;
+ int i, redraw = 0;
+
+ if (!is_buffer_shared(vga->ds->surface)) {
+ dprint(qxl, 1, "%s: restoring shared displaysurface\n", __func__);
+ qxl->guest_primary.resized++;
+ qxl->guest_primary.commands++;
+ redraw = 1;
+ }
if (qxl->guest_primary.resized) {
qxl->guest_primary.resized = 0;
@@ -127,6 +134,10 @@ void qxl_render_update(PCIQXLDevice *qxl)
memset(dirty, 0, sizeof(dirty));
qxl_spice_update_area(qxl, 0, &update,
dirty, ARRAY_SIZE(dirty), 1, QXL_SYNC);
+ if (redraw) {
+ memset(dirty, 0, sizeof(dirty));
+ dirty[0] = update;
+ }
for (i = 0; i < ARRAY_SIZE(dirty); i++) {
if (qemu_spice_rect_is_empty(dirty+i)) {
--
1.7.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH 3/3] qxl: create slots on post_load in vga state
2011-11-01 12:39 [Qemu-devel] [PULL] spice patch queue Gerd Hoffmann
2011-11-01 12:39 ` [Qemu-devel] [PATCH 1/3] qxl: stride fixup Gerd Hoffmann
2011-11-01 12:39 ` [Qemu-devel] [PATCH 2/3] qxl: make sure we continue to run with a shared buffer Gerd Hoffmann
@ 2011-11-01 12:39 ` Gerd Hoffmann
2011-11-01 18:13 ` [Qemu-devel] [PULL] spice patch queue Anthony Liguori
3 siblings, 0 replies; 5+ messages in thread
From: Gerd Hoffmann @ 2011-11-01 12:39 UTC (permalink / raw)
To: qemu-devel; +Cc: Alon Levy, Gerd Hoffmann
From: Alon Levy <alevy@redhat.com>
RHBZ 740547
If we migrate when the device is in vga state the guest
still believes the slots are created, and will cause operations
that reference the slots, causing a "panic: virtual address out of range"
on the first of them. Easy to see by migrating in vga mode with
a driver loaded, for instance windows cmd window in full screen mode,
and then exiting vga mode back to native mode will cause said panic.
Fixed by doing the slot recreation in post_load for vga mode as well.
Note that compat does not require any changes because it creates it's
only slot by a side effect of QXL_IO_SET_MODE.
Signed-off-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/qxl.c | 26 +++++++++++++++++++-------
1 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/hw/qxl.c b/hw/qxl.c
index 12f71aa..84ffd45 100644
--- a/hw/qxl.c
+++ b/hw/qxl.c
@@ -1663,12 +1663,25 @@ static int qxl_pre_load(void *opaque)
return 0;
}
+static void qxl_create_memslots(PCIQXLDevice *d)
+{
+ int i;
+
+ for (i = 0; i < NUM_MEMSLOTS; i++) {
+ if (!d->guest_slots[i].active) {
+ continue;
+ }
+ dprint(d, 1, "%s: restoring guest slot %d\n", __func__, i);
+ qxl_add_memslot(d, i, 0, QXL_SYNC);
+ }
+}
+
static int qxl_post_load(void *opaque, int version)
{
PCIQXLDevice* d = opaque;
uint8_t *ram_start = d->vga.vram_ptr;
QXLCommandExt *cmds;
- int in, out, i, newmode;
+ int in, out, newmode;
dprint(d, 1, "%s: start\n", __FUNCTION__);
@@ -1685,19 +1698,16 @@ static int qxl_post_load(void *opaque, int version)
qxl_mode_to_string(d->mode));
newmode = d->mode;
d->mode = QXL_MODE_UNDEFINED;
+
switch (newmode) {
case QXL_MODE_UNDEFINED:
break;
case QXL_MODE_VGA:
+ qxl_create_memslots(d);
qxl_enter_vga_mode(d);
break;
case QXL_MODE_NATIVE:
- for (i = 0; i < NUM_MEMSLOTS; i++) {
- if (!d->guest_slots[i].active) {
- continue;
- }
- qxl_add_memslot(d, i, 0, QXL_SYNC);
- }
+ qxl_create_memslots(d);
qxl_create_guest_primary(d, 1, QXL_SYNC);
/* replay surface-create and cursor-set commands */
@@ -1722,6 +1732,8 @@ static int qxl_post_load(void *opaque, int version)
break;
case QXL_MODE_COMPAT:
+ /* note: no need to call qxl_create_memslots, qxl_set_mode
+ * creates the mem slot. */
qxl_set_mode(d, d->shadow_rom.mode, 1);
break;
}
--
1.7.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PULL] spice patch queue
2011-11-01 12:39 [Qemu-devel] [PULL] spice patch queue Gerd Hoffmann
` (2 preceding siblings ...)
2011-11-01 12:39 ` [Qemu-devel] [PATCH 3/3] qxl: create slots on post_load in vga state Gerd Hoffmann
@ 2011-11-01 18:13 ` Anthony Liguori
3 siblings, 0 replies; 5+ messages in thread
From: Anthony Liguori @ 2011-11-01 18:13 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: qemu-devel
On 11/01/2011 07:39 AM, Gerd Hoffmann wrote:
> Hi,
>
> Carrying three little qxl fixes.
> Final spice batch for 1.0.
>
> please pull,
> Gerd
>
> The following changes since commit ff74c5a9a91c6dbf1017195462aa4176f7381240:
>
> Merge remote-tracking branch 'riku/linux-user-for-upstream' into staging (2011-10-31 15:05:40 -0500)
>
> are available in the git repository at:
>
> git://anongit.freedesktop.org/spice/qemu spice.v46
Pulled. Thanks.
Regards,
Anthony Liguori
>
> Alon Levy (1):
> qxl: create slots on post_load in vga state
>
> Gerd Hoffmann (2):
> qxl: stride fixup
> qxl: make sure we continue to run with a shared buffer
>
> hw/qxl-render.c | 36 ++++++++++++++++++++++++------------
> hw/qxl.c | 26 +++++++++++++++++++-------
> hw/qxl.h | 3 ++-
> 3 files changed, 45 insertions(+), 20 deletions(-)
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread