Skip to contentSkip to conversation

spice patch queue

GIT PULL New Gerd Hoffmann 2 participants 10 messages Nov 2, 2012 – Nov 14, 2012 Kbuild

lore
Share & tools
lore
#0 lore raw

Hi,

Here comes the spice patch queue. It carries some qxl bugfixes, switches spice-display over to pixman, drops the obsolete pflib bits and fixes some fallout from the console cleanup patch series.

please pull,
Gerd

The following changes since commit 4ba79505f43bd0ace35c3fe42197eb02e7e0478e:

Merge remote-tracking branch 'kraxel/pixman.v3' into staging (2012-11-01 11:14:39 -0500)

are available in the git repository at:

git://anongit.freedesktop.org/spice/qemu spice.v62

Alon Levy (2):
hw/qxl: guest bug on primary create with stride %4 != 0 hw/qxl: qxl_send_events: nop if stopped

Gerd Hoffmann (5):
qxl: fix cursor reset
qxl: call dpy_gfx_resize when entering vga mode
spice: switch to pixman
pflib: unused, remove it.
spice: fix initialization order

 Makefile.objs      |    1 -
 console.h          |    5 +
 hw/qxl.c           |   36 ++++++++-
 pflib.c            |  215 ----------------------------------------------------
 pflib.h            |   20 -----
 qemu-pixman.c      |   13 +++
 qemu-pixman.h      |    2 +
 trace-events       |    1 +
 ui/spice-display.c |   53 ++++++-------
 ui/spice-display.h |    7 +-
 10 files changed, 79 insertions(+), 274 deletions(-)
 delete mode 100644 pflib.c
 delete mode 100644 pflib.h
#1 lore raw

PATCH 1/7 hw/qxl: guest bug on primary create with stride %4 != 0

From: Alon Levy <[email protected]>

Due to usage of pixman for rendering on all spice surfaces we have pixman's requirement that the stride be word aligned. A guest not honoring that can crash spice and qemu with it due to failure to create a surface (in spice-server). Avoid this early on in primary surface creation and offscreen surface creation.

Recently windows guests got odd width support which triggers a non word aligned primary surface in 16bit color depth. Off screen surfaces have always been word aligned, but doesn't hurt to check them here too.

---
 hw/qxl.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
hw/qxl.c +12 -0
index 1f56fcd..cc16eaf 100644
@@ -447,6 +447,12 @@ static int qxl_track_command(PCIQXLDevice *qxl, struct QXLCommandExt *ext)
                               qxl->ssd.num_surfaces);
             return 1;
         }
+        if (cmd->type == QXL_SURFACE_CMD_CREATE &&
+            (cmd->u.surface_create.stride & 0x03) != 0) {
+            qxl_set_guest_bug(qxl, "QXL_CMD_SURFACE stride = %d %% 4 != 0\n",
+                              cmd->u.surface_create.stride);
+            return 1;
+        }
         qemu_mutex_lock(&qxl->track_lock);
         if (cmd->type == QXL_SURFACE_CMD_CREATE) {
             qxl->guest_surfaces.cmds[id] = ext->cmd.data;
@@ -1357,6 +1363,12 @@ static void qxl_create_guest_primary(PCIQXLDevice *qxl, int loadvm,
     trace_qxl_create_guest_primary_rest(qxl->id, sc->stride, sc->type,
                                         sc->flags);
 
+    if ((surface.stride & 0x3) != 0) {
+        qxl_set_guest_bug(qxl, "primary surface stride = %d %% 4 != 0",
+                          surface.stride);
+        return;
+    }
+
     surface.mouse_mode = true;
     surface.group_id   = MEMSLOT_GROUP_GUEST;
     if (loadvm) {
Signature · 1 line
1.7.1
#2 lore raw

PATCH 2/7 hw/qxl: qxl_send_events: nop if stopped

In reply to Gerd Hoffmann

From: Alon Levy <[email protected]>

Added a trace point for easy logging.

RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=870972

---
 hw/qxl.c     |    8 +++++++-
 trace-events |    1 +
 2 files changed, 8 insertions(+), 1 deletions(-)
hw/qxl.c +7 -1
index cc16eaf..f19451b 100644
@@ -1701,7 +1701,13 @@ static void qxl_send_events(PCIQXLDevice *d, uint32_t events)
     uint32_t le_events = cpu_to_le32(events);
 
     trace_qxl_send_events(d->id, events);
-    assert(qemu_spice_display_is_running(&d->ssd));
+    if (!qemu_spice_display_is_running(&d->ssd)) {
+        /* spice-server tracks guest running state and should not do this */
+        fprintf(stderr, "%s: spice-server bug: guest stopped, ignoring\n",
+                __func__);
+        trace_qxl_send_events_vm_stopped(d->id, events);
+        return;
+    }
     old_pending = __sync_fetch_and_or(&d->ram->int_pending, le_events);
     if ((old_pending & le_events) == le_events) {
         return;
trace-events +1 -0
index 066cdaf..33846bb 100644
@@ -999,6 +999,7 @@ qxl_spice_update_area(int qid, uint32_t surface_id, uint32_t left, uint32_t righ
 qxl_spice_update_area_rest(int qid, uint32_t num_dirty_rects, uint32_t clear_dirty_region) "%d #d=%d clear=%d"
 qxl_surfaces_dirty(int qid, int surface, int offset, int size) "%d surface=%d offset=%d size=%d"
 qxl_send_events(int qid, uint32_t events) "%d %d"
+qxl_send_events_vm_stopped(int qid, uint32_t events) "%d %d"
 qxl_set_guest_bug(int qid) "%d"
 qxl_interrupt_client_monitors_config(int qid, int num_heads, void *heads) "%d %d %p"
 qxl_client_monitors_config_unsupported_by_guest(int qid, uint32_t int_mask, void *client_monitors_config) "%d %X %p"
Signature · 1 line
1.7.1
#3 lore raw

PATCH 3/7 qxl: fix cursor reset

In reply to Gerd Hoffmann

When resetting the qxl cursor notify the qemu displaystate too.

---
 hw/qxl.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
hw/qxl.c +4 -0
index f19451b..063970d 100644
@@ -293,6 +293,10 @@ void qxl_spice_reset_cursor(PCIQXLDevice *qxl)
     qemu_mutex_lock(&qxl->track_lock);
     qxl->guest_cursor = 0;
     qemu_mutex_unlock(&qxl->track_lock);
+    if (qxl->ssd.cursor) {
+        cursor_put(qxl->ssd.cursor);
+    }
+    qxl->ssd.cursor = cursor_builtin_hidden();
 }
 
 
Signature · 1 line
1.7.1
#4 lore raw

PATCH 4/7 qxl: call dpy_gfx_resize when entering vga mode

In reply to Gerd Hoffmann

When entering vga mode the display size likely changes, notify all displaychangelisteners about this.

Probably went unnoticed for a while as one if the first things the guest does after leaving qxl native mode and entering qxl vga mode is to set the vga video mode. But there is still a small window where qemu can operate on stale data, leading to crashes now and then.

https://bugzilla.redhat.com/show_bug.cgi?id=865767

---
 hw/qxl.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
hw/qxl.c +1 -1
index 063970d..e7bf3a1 100644
@@ -1069,7 +1069,7 @@ static void qxl_enter_vga_mode(PCIQXLDevice *d)
     trace_qxl_enter_vga_mode(d->id);
     qemu_spice_create_host_primary(&d->ssd);
     d->mode = QXL_MODE_VGA;
-    memset(&d->ssd.dirty, 0, sizeof(d->ssd.dirty));
+    dpy_gfx_resize(d->ssd.ds);
     vga_dirty_log_start(&d->vga);
 }
 
Signature · 1 line
1.7.1
#5 lore raw

PATCH 5/7 spice: switch to pixman

In reply to Gerd Hoffmann

Switch over spice-display.c to use the pixman library instead of the home-grown pflib bits.

---
 console.h          |    5 +++++
 qemu-pixman.c      |   13 +++++++++++++
 qemu-pixman.h      |    2 ++
 ui/spice-display.c |   51 ++++++++++++++++++++++-----------------------------
 ui/spice-display.h |    7 +++----
 5 files changed, 45 insertions(+), 33 deletions(-)
console.h +5 -0
index 33ad69b..a52a607 100644
@@ -377,6 +377,11 @@ static inline pixman_format_code_t ds_get_format(DisplayState *ds)
     return ds->surface->format;
 }
 
+static inline pixman_image_t *ds_get_image(DisplayState *ds)
+{
+    return ds->surface->image;
+}
+
 #ifdef CONFIG_CURSES
 #include <curses.h>
 typedef chtype console_ch_t;
qemu-pixman.c +13 -0
index 7547ed7..71a9ea4 100644
@@ -51,6 +51,19 @@ void qemu_pixman_linebuf_fill(pixman_image_t *linebuf, pixman_image_t *fb,
                            0, y, 0, 0, 0, 0, width, 1);
 }
 
+pixman_image_t *qemu_pixman_mirror_create(pixman_format_code_t format,
+                                          pixman_image_t *image)
+{
+    pixman_image_t *mirror;
+
+    mirror = pixman_image_create_bits(format,
+                                      pixman_image_get_width(image),
+                                      pixman_image_get_height(image),
+                                      NULL,
+                                      pixman_image_get_stride(image));
+    return mirror;
+}
+
 void qemu_pixman_image_unref(pixman_image_t *image)
 {
     if (image == NULL) {
qemu-pixman.h +2 -0
index 7652c41..e267d73 100644
@@ -27,6 +27,8 @@ pixman_image_t *qemu_pixman_linebuf_create(pixman_format_code_t format,
                                            int width);
 void qemu_pixman_linebuf_fill(pixman_image_t *linebuf, pixman_image_t *fb,
                               int width, int y);
+pixman_image_t *qemu_pixman_mirror_create(pixman_format_code_t format,
+                                          pixman_image_t *image);
 void qemu_pixman_image_unref(pixman_image_t *image);
 
 #endif /* QEMU_PIXMAN_H */
ui/spice-display.c +22 -29

82 lines not on this page · raw message

ui/spice-display.h +3 -4
index d766927..38b6ea9 100644
@@ -20,8 +20,7 @@
 #include <spice/qxl_dev.h>
 
 #include "qemu-thread.h"
-#include "console.h"
-#include "pflib.h"
+#include "qemu-pixman.h"
 #include "sysemu.h"
 
 #define NUM_MEMSLOTS 8
@@ -72,13 +71,13 @@ typedef struct SimpleSpiceUpdate SimpleSpiceUpdate;
 
 struct SimpleSpiceDisplay {
     DisplayState *ds;
-    uint8_t *ds_mirror;
     void *buf;
     int bufsize;
     QXLWorker *worker;
     QXLInstance qxl;
     uint32_t unique;
-    QemuPfConv *conv;
+    pixman_image_t *surface;
+    pixman_image_t *mirror;
     int32_t num_surfaces;
 
     QXLRect dirty;
Signature · 1 line
1.7.1
#6 lore raw

PATCH 6/7 pflib: unused, remove it.

In reply to Gerd Hoffmann

Replaced by pixman library.

---
 Makefile.objs |    1 -
 pflib.c       |  215 ---------------------------------------------------------
 pflib.h       |   20 -----
 3 files changed, 0 insertions(+), 236 deletions(-)
 delete mode 100644 pflib.c
 delete mode 100644 pflib.h
Makefile.objs +0 -1
index 593a592..37be7e2 100644
@@ -78,7 +78,6 @@ common-obj-y += input.o
 common-obj-y += buffered_file.o migration.o migration-tcp.o
 common-obj-y += qemu-char.o #aio.o
 common-obj-y += block-migration.o iohandler.o
-common-obj-y += pflib.o
 common-obj-y += bitmap.o bitops.o
 common-obj-y += page_cache.o
 
pflib.c deleted +0 -215

215 lines not on this page · raw message

pflib.h deleted +0 -20
deleted file mode 100644
index b70c313..0000000
@@ -1,20 +0,0 @@
-#ifndef __QEMU_PFLIB_H
-#define __QEMU_PFLIB_H
-
-/*
- * PixelFormat conversion library.
- *
- * Author: Gerd Hoffmann <[email protected]>
- *
- * This work is licensed under the terms of the GNU GPL, version 2.  See
- * the COPYING file in the top-level directory.
- *
- */
-
-typedef struct QemuPfConv QemuPfConv;
-
-QemuPfConv *qemu_pf_conv_get(PixelFormat *dst, PixelFormat *src);
-void qemu_pf_conv_run(QemuPfConv *conv, void *dst, void *src, uint32_t cnt);
-void qemu_pf_conv_put(QemuPfConv *conv);
-
-#endif
Signature · 1 line
1.7.1
#7 lore raw

PATCH 7/7 spice: fix initialization order

In reply to Gerd Hoffmann

Register displaychangelistener last, after spice is fully initialized, otherwise we may hit NULL pointer dereferences when qemu starts calling our callbacks.

Commit e250d949feb1334828f27f0d145c35f29c4b7639 triggers this bug.

---
 hw/qxl.c           |   10 ++++++++--
 ui/spice-display.c |    2 +-
 2 files changed, 9 insertions(+), 3 deletions(-)
hw/qxl.c +8 -2
index e7bf3a1..1bc2d32 100644
@@ -2049,6 +2049,7 @@ static int qxl_init_primary(PCIDevice *dev)
     PCIQXLDevice *qxl = DO_UPCAST(PCIQXLDevice, pci, dev);
     VGACommonState *vga = &qxl->vga;
     PortioList *qxl_vga_port_list = g_new(PortioList, 1);
+    int rc;
 
     qxl->id = 0;
     qxl_init_ramsize(qxl);
@@ -2063,9 +2064,14 @@ static int qxl_init_primary(PCIDevice *dev)
     qemu_spice_display_init_common(&qxl->ssd, vga->ds);
 
     qxl0 = qxl;
-    register_displaychangelistener(vga->ds, &display_listener);
 
-    return qxl_init_common(qxl);
+    rc = qxl_init_common(qxl);
+    if (rc != 0) {
+        return rc;
+    }
+
+    register_displaychangelistener(vga->ds, &display_listener);
+    return rc;
 }
 
 static int qxl_init_secondary(PCIDevice *dev)
ui/spice-display.c +1 -1
index fe2fdfb..0cc0116 100644
@@ -573,7 +573,6 @@ void qemu_spice_display_init(DisplayState *ds)
 {
     assert(sdpy.ds == NULL);
     qemu_spice_display_init_common(&sdpy, ds);
-    register_displaychangelistener(ds, &display_listener);
 
     sdpy.qxl.base.sif = &dpy_interface.base;
     qemu_spice_add_interface(&sdpy.qxl.base);
@@ -581,4 +580,5 @@ void qemu_spice_display_init(DisplayState *ds)
 
     qemu_spice_create_host_memslot(&sdpy);
     qemu_spice_create_host_primary(&sdpy);
+    register_displaychangelistener(ds, &display_listener);
 }
Signature · 1 line
1.7.1
#8 lore raw
In reply to Gerd Hoffmann

Hi,

Quoted 1 line

git://anongit.freedesktop.org/spice/qemu spice.v62

Pushed spice.v63 : rebased to latest master, solved one conflict, otherwise unchanged.

cheers,
Gerd

#9 lore raw
In reply to Gerd Hoffmann
Quoted 9 lines · Gerd Hoffmann

Hi,

Here comes the spice patch queue. It carries some qxl bugfixes, switches spice-display over to pixman, drops the obsolete pflib bits and fixes some fallout from the console cleanup patch series.

please pull,
Gerd

Quoted 7 lines

The following changes since commit 4ba79505f43bd0ace35c3fe42197eb02e7e0478e:

Merge remote-tracking branch 'kraxel/pixman.v3' into staging (2012-11-01 11:14:39 -0500)

are available in the git repository at:

git://anongit.freedesktop.org/spice/qemu spice.v62

Pulled v63. Thanks.

Regards,

Anthony Liguori

Quoted 25 lines

Alon Levy (2):
hw/qxl: guest bug on primary create with stride %4 != 0 hw/qxl: qxl_send_events: nop if stopped

Gerd Hoffmann (5):
qxl: fix cursor reset
qxl: call dpy_gfx_resize when entering vga mode
spice: switch to pixman
pflib: unused, remove it.
spice: fix initialization order

 Makefile.objs      |    1 -
 console.h          |    5 +
 hw/qxl.c           |   36 ++++++++-
 pflib.c            |  215 ----------------------------------------------------
 pflib.h            |   20 -----
 qemu-pixman.c      |   13 +++
 qemu-pixman.h      |    2 +
 trace-events       |    1 +
 ui/spice-display.c |   53 ++++++-------
 ui/spice-display.h |    7 +-
 10 files changed, 79 insertions(+), 274 deletions(-)
 delete mode 100644 pflib.c
 delete mode 100644 pflib.h