Skip to contentSkip to conversation

initial spice support.

PATCH In review Gerd Hoffmann 2 participants 12 messages Sep 21, 2010 – Oct 5, 2010 Kbuild

lore
Share & tools
lore
#0 lore raw

v6 cover initial spice support.

Hi,

Here comes v6 of the iniial spice support patch series which is largely a repost of v5.

* Detect spice in configure, Makefile windup.
* Support for keyboard, mouse and tablet.
* Support for simple display output (works as DisplayChangeListener, plays with any gfx card, sends simple draw commands to update dirty regions).

Note that this patch series does *not* yet contain the qxl paravirtual gfx card. That will come as part of a additional patch series after sorting the vgabios support.

The patches are also available in the git repository at:
git://anongit.freedesktop.org/spice/qemu submit.6

Changes since v5:
* Rebased to latest master.
* Sorted some minor conflicts with trace patches.

Changes since v4:
* Code style fixups.
* Small bug fix (display_remote not being set when configuring spice via config file).

Changes since v3:
* Drop global spice_server variable, provide a thin wrapper function instead so spice interfaces can be registered without needing spice_server.
* Update locking comments.

Changes since v2:
* Add copyright headers to the files.
* Add dprint for debug logging.
* Add mapping for buttons and leds.
* Add comments for locking+threads.
* Drop includes which qemu-common.h brings in.
* Compile -spice switch unconditionally.
* Hook up spice init using module.h, drop #ifdefs.
* Misc minor tweaks.

Gerd Hoffmann (10):
Use display types for local display only. Use machine_init() to register virtfs config options. add pflib: PixelFormat conversion library.
configure: add logging
add spice into the configure file
spice: core bits
spice: add keyboard
spice: add mouse
spice: simple display
spice: add tablet support

 Makefile.objs      |    3 +
 configure          |   42 +++++-
 fsdev/qemu-fsdev.c |    9 +
 pflib.c            |  213 +++++++++++++++++++++++++++
 pflib.h            |   20 +++
 qemu-config.c      |   18 +++
 qemu-config.h      |    1 +
 qemu-options.hx    |   21 +++
 sysemu.h           |    1 -
 ui/qemu-spice.h    |   41 +++++
 ui/spice-core.c    |  189 ++++++++++++++++++++++++
 ui/spice-display.c |  412 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 ui/spice-display.h |   69 +++++++++
 ui/spice-input.c   |  217 +++++++++++++++++++++++++++
 vl.c               |   50 +++++--
 15 files changed, 1287 insertions(+), 19 deletions(-)
 create mode 100644 pflib.c
 create mode 100644 pflib.h
 create mode 100644 ui/qemu-spice.h
 create mode 100644 ui/spice-core.c
 create mode 100644 ui/spice-display.c
 create mode 100644 ui/spice-display.h
 create mode 100644 ui/spice-input.c
#1 lore raw

PATCH v6 1/10 Use display types for local display only.

This patch drops DT_VNC. The display types are only used to select select the local display (i.e. curses, sdl, coca, ...). Remote displays (for now only vnc, spice will follow) can be enabled independently.

---
 sysemu.h |    1 -
 vl.c     |   24 +++++++++++++-----------
 2 files changed, 13 insertions(+), 12 deletions(-)
sysemu.h +0 -1
index a1f6466..b81a70e 100644
@@ -94,7 +94,6 @@ typedef enum DisplayType
     DT_DEFAULT,
     DT_CURSES,
     DT_SDL,
-    DT_VNC,
     DT_NOGRAPHIC,
 } DisplayType;
 
vl.c +13 -11
index 3f45aa9..f434193 100644
@@ -176,6 +176,7 @@ static const char *data_dir;
 const char *bios_name = NULL;
 enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
 DisplayType display_type = DT_DEFAULT;
+int display_remote = 0;
 const char* keyboard_layout = NULL;
 ram_addr_t ram_size;
 const char *mem_path = NULL;
@@ -2477,7 +2478,7 @@ int main(int argc, char **argv, char **envp)
                 }
                 break;
 	    case QEMU_OPTION_vnc:
-                display_type = DT_VNC;
+                display_remote++;
 		vnc_display = optarg;
 		break;
             case QEMU_OPTION_no_acpi:
@@ -2921,17 +2922,17 @@ int main(int argc, char **argv, char **envp)
     /* just use the first displaystate for the moment */
     ds = get_displaystate();
 
-    if (display_type == DT_DEFAULT) {
+    if (display_type == DT_DEFAULT && !display_remote) {
 #if defined(CONFIG_SDL) || defined(CONFIG_COCOA)
         display_type = DT_SDL;
 #else
-        display_type = DT_VNC;
         vnc_display = "localhost:0,to=99";
         show_vnc_port = 1;
 #endif
     }
         
 
+    /* init local displays */
     switch (display_type) {
     case DT_NOGRAPHIC:
         break;
@@ -2949,7 +2950,12 @@ int main(int argc, char **argv, char **envp)
         cocoa_display_init(ds, full_screen);
         break;
 #endif
-    case DT_VNC:
+    default:
+        break;
+    }
+
+    /* init remote displays */
+    if (vnc_display) {
         vnc_display_init(ds);
         if (vnc_display_open(ds, vnc_display) < 0)
             exit(1);
@@ -2957,12 +2963,10 @@ int main(int argc, char **argv, char **envp)
         if (show_vnc_port) {
             printf("VNC server running on `%s'\n", vnc_display_local_addr(ds));
         }
-        break;
-    default:
-        break;
     }
-    dpy_resize(ds);
 
+    /* display setup */
+    dpy_resize(ds);
     dcl = ds->listeners;
     while (dcl != NULL) {
         if (dcl->dpy_refresh != NULL) {
@@ -2972,12 +2976,10 @@ int main(int argc, char **argv, char **envp)
         }
         dcl = dcl->next;
     }
-
-    if (display_type == DT_NOGRAPHIC || display_type == DT_VNC) {
+    if (ds->gui_timer == NULL) {
         nographic_timer = qemu_new_timer(rt_clock, nographic_update, NULL);
         qemu_mod_timer(nographic_timer, qemu_get_clock(rt_clock));
     }
-
     text_consoles_set_display(ds);
 
     if (gdbstub_dev && gdbserver_start(gdbstub_dev) < 0) {
Signature · 1 line
1.7.1
#2 lore raw

PATCH v6 2/10 Use machine_init() to register virtfs config options.

In reply to Gerd Hoffmann
---
 fsdev/qemu-fsdev.c |    9 +++++++++
 vl.c               |    5 -----
 2 files changed, 9 insertions(+), 5 deletions(-)
fsdev/qemu-fsdev.c +9 -0
index ad69b0e..280b8f5 100644
@@ -16,6 +16,7 @@
 #include "qemu-queue.h"
 #include "osdep.h"
 #include "qemu-common.h"
+#include "qemu-config.h"
 
 static QTAILQ_HEAD(FsTypeEntry_head, FsTypeListEntry) fstype_entries =
     QTAILQ_HEAD_INITIALIZER(fstype_entries);
@@ -75,3 +76,11 @@ FsTypeEntry *get_fsdev_fsentry(char *id)
     }
     return NULL;
 }
+
+static void fsdev_register_config(void)
+{
+    qemu_add_opts(&qemu_fsdev_opts);
+    qemu_add_opts(&qemu_virtfs_opts);
+}
+machine_init(fsdev_register_config);
+
vl.c +0 -5
index f434193..2edc853 100644
@@ -1863,11 +1863,6 @@ int main(int argc, char **argv, char **envp)
     tb_size = 0;
     autostart= 1;
 
-#ifdef CONFIG_VIRTFS
-    qemu_add_opts(&qemu_fsdev_opts);
-    qemu_add_opts(&qemu_virtfs_opts);
-#endif
-
     /* first pass of option parsing */
     optind = 1;
     while (optind < argc) {
Signature · 1 line
1.7.1
#3 lore raw

PATCH v6 3/10 add pflib: PixelFormat conversion library.

In reply to Gerd Hoffmann
---
 Makefile.objs |    1 +
 pflib.c       |  213 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 pflib.h       |   20 ++++++
 3 files changed, 234 insertions(+), 0 deletions(-)
 create mode 100644 pflib.c
 create mode 100644 pflib.h
Makefile.objs +1 -0
index 3ef6d80..8268574 100644
@@ -83,6 +83,7 @@ common-obj-y += qemu-char.o savevm.o #aio.o
 common-obj-y += msmouse.o ps2.o
 common-obj-y += qdev.o qdev-properties.o
 common-obj-y += block-migration.o
+common-obj-y += pflib.o
 
 common-obj-$(CONFIG_BRLAPI) += baum.o
 common-obj-$(CONFIG_POSIX) += migration-exec.o migration-unix.o migration-fd.o
pflib.c new file +213 -0

213 lines not on this page · raw message

pflib.h new file +20 -0
new file mode 100644
index 0000000..b70c313
@@ -0,0 +1,20 @@
+#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
#4 lore raw

PATCH v6 4/10 configure: add logging

In reply to Gerd Hoffmann

Write compile commands and messages to config.log. Useful for debugging configure.

---
 configure |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
configure +5 -2
index 3bfc5e9..66b1d0b 100755
@@ -16,15 +16,18 @@ TMPO="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.o"
 TMPE="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.exe"
 
 trap "rm -f $TMPC $TMPO $TMPE ; exit" EXIT INT QUIT TERM
+rm -f config.log
 
 compile_object() {
-  $cc $QEMU_CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null
+  echo $cc $QEMU_CFLAGS -c -o $TMPO $TMPC >> config.log
+  $cc $QEMU_CFLAGS -c -o $TMPO $TMPC >> config.log 2>&1
 }
 
 compile_prog() {
   local_cflags="$1"
   local_ldflags="$2"
-  $cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags > /dev/null 2> /dev/null
+  echo $cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags >> config.log
+  $cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags >> config.log 2>&1
 }
 
 # check whether a command is available to this shell (may be either an
Signature · 1 line
1.7.1
#5 lore raw

PATCH v6 5/10 add spice into the configure file

In reply to Gerd Hoffmann
---
 configure |   35 +++++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)
configure +35 -0
index 66b1d0b..695a632 100755
@@ -325,6 +325,7 @@ user_pie="no"
 zero_malloc=""
 trace_backend="nop"
 trace_file="trace"
+spice=""
 
 # OS specific
 if check_define __linux__ ; then
@@ -630,6 +631,10 @@ for opt do
   ;;
   --enable-kvm) kvm="yes"
   ;;
+  --disable-spice) spice="no"
+  ;;
+  --enable-spice) spice="yes"
+  ;;
   --enable-profiler) profiler="yes"
   ;;
   --enable-cocoa)
@@ -912,6 +917,8 @@ echo "  --enable-vhost-net       enable vhost-net acceleration support"
 echo "  --trace-backend=B        Trace backend nop simple ust"
 echo "  --trace-file=NAME        Full PATH,NAME of file to store traces"
 echo "                           Default:trace-<pid>"
+echo "  --disable-spice          disable spice"
+echo "  --enable-spice           enable spice"
 echo ""
 echo "NOTE: The object files are built at the place where configure is launched"
 exit 1
@@ -2062,6 +2069,29 @@ if compile_prog "" ""; then
     gcc_attribute_warn_unused_result=yes
 fi
 
+# spice probe
+if test "$spice" != "no" ; then
+  cat > $TMPC << EOF
+#include <spice.h>
+int main(void) { spice_server_new(); return 0; }
+EOF
+  spice_cflags=$($pkgconfig --cflags spice-protocol spice-server 2>/dev/null)
+  spice_libs=$($pkgconfig --libs spice-protocol spice-server 2>/dev/null)
+  if $pkgconfig --atleast-version=0.5.3 spice-server &&\
+     compile_prog "$spice_cflags" "$spice_libs" ; then
+    spice="yes"
+    libs_softmmu="$libs_softmmu $spice_libs"
+    QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
+  else
+    if test "$spice" = "yes" ; then
+      feature_not_found "spice"
+    fi
+    spice="no"
+  fi
+fi
+
+##########################################
+
 ##########################################
 # check if we have fdatasync
 
@@ -2245,6 +2275,7 @@ echo "uuid support      $uuid"
 echo "vhost-net support $vhost_net"
 echo "Trace backend     $trace_backend"
 echo "Trace output file $trace_file-<pid>"
+echo "spice support     $spice"
 
 if test $sdl_too_old = "yes"; then
 echo "-> Your SDL version is too old - please upgrade to have SDL support"
@@ -2482,6 +2513,10 @@ if test "$fdatasync" = "yes" ; then
   echo "CONFIG_FDATASYNC=y" >> $config_host_mak
 fi
 
+if test "$spice" = "yes" ; then
+  echo "CONFIG_SPICE=y" >> $config_host_mak
+fi
+
 # XXX: suppress that
 if [ "$bsd" = "yes" ] ; then
   echo "CONFIG_BSD=y" >> $config_host_mak
Signature · 1 line
1.7.1
#6 lore raw

PATCH v6 6/10 spice: core bits

In reply to Gerd Hoffmann

Add -spice command line switch. Has support setting passwd and port for now. With this patch applied the spice client can successfully connect to qemu. You can't do anything useful yet though.

---
 Makefile.objs   |    2 +
 qemu-config.c   |   18 +++++
 qemu-config.h   |    1 +
 qemu-options.hx |   21 ++++++
 ui/qemu-spice.h |   39 ++++++++++++
 ui/spice-core.c |  187 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 vl.c            |   14 ++++
 7 files changed, 282 insertions(+), 0 deletions(-)
 create mode 100644 ui/qemu-spice.h
 create mode 100644 ui/spice-core.c
Makefile.objs +2 -0
index 8268574..2b58109 100644
@@ -88,6 +88,8 @@ common-obj-y += pflib.o
 common-obj-$(CONFIG_BRLAPI) += baum.o
 common-obj-$(CONFIG_POSIX) += migration-exec.o migration-unix.o migration-fd.o
 
+common-obj-$(CONFIG_SPICE) += ui/spice-core.o
+
 audio-obj-y = audio.o noaudio.o wavaudio.o mixeng.o
 audio-obj-$(CONFIG_SDL) += sdlaudio.o
 audio-obj-$(CONFIG_OSS) += ossaudio.o
qemu-config.c +18 -0
index e3b746c..5c6ae63 100644
@@ -351,6 +351,24 @@ static QemuOptsList qemu_cpudef_opts = {
     },
 };
 
+QemuOptsList qemu_spice_opts = {
+    .name = "spice",
+    .head = QTAILQ_HEAD_INITIALIZER(qemu_spice_opts.head),
+    .desc = {
+        {
+            .name = "port",
+            .type = QEMU_OPT_NUMBER,
+        },{
+            .name = "password",
+            .type = QEMU_OPT_STRING,
+        },{
+            .name = "disable-ticketing",
+            .type = QEMU_OPT_BOOL,
+        },
+        { /* end if list */ }
+    },
+};
+
 static QemuOptsList *vm_config_groups[32] = {
     &qemu_drive_opts,
     &qemu_chardev_opts,
qemu-config.h +1 -0
index 533a049..20d707f 100644
@@ -3,6 +3,7 @@
 
 extern QemuOptsList qemu_fsdev_opts;
 extern QemuOptsList qemu_virtfs_opts;
+extern QemuOptsList qemu_spice_opts;
 
 QemuOptsList *qemu_find_opts(const char *group);
 void qemu_add_opts(QemuOptsList *list);
qemu-options.hx +21 -0
index a0b5ae9..718d47a 100644
@@ -670,6 +670,27 @@ STEXI
 Enable SDL.
 ETEXI
 
+DEF("spice", HAS_ARG, QEMU_OPTION_spice,
+    "-spice <args>   enable spice\n", QEMU_ARCH_ALL)
+STEXI
+@item -spice @var{option}[,@var{option}[,...]]
+@findex -spice
+Enable the spice remote desktop protocol. Valid options are
+
+@table @option
+
+@item port=<nr>
+Set the TCP port spice is listening on.
+
+@item password=<secret>
+Set the password you need to authenticate.
+
+@item disable-ticketing
+Allow client connects without authentication.
+
+@end table
+ETEXI
+
 DEF("portrait", 0, QEMU_OPTION_portrait,
     "-portrait       rotate graphical output 90 deg left (only PXA LCD)\n",
     QEMU_ARCH_ALL)
ui/qemu-spice.h new file +39 -0
new file mode 100644
index 0000000..50faefb
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2010 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 or
+ * (at your option) version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef QEMU_SPICE_H
+#define QEMU_SPICE_H
+
+#ifdef CONFIG_SPICE
+
+#include <spice.h>
+
+#include "qemu-option.h"
+#include "qemu-config.h"
+
+extern int using_spice;
+
+void qemu_spice_init(void);
+int qemu_spice_add_interface(SpiceBaseInstance *sin);
+
+#else  /* CONFIG_SPICE */
+
+#define using_spice 0
+
+#endif /* CONFIG_SPICE */
+
+#endif /* QEMU_SPICE_H */
ui/spice-core.c new file +187 -0

187 lines not on this page · raw message

vl.c +14 -0
index 2edc853..27d9392 100644
@@ -165,6 +165,8 @@ int main(int argc, char **argv)
 #include "cpus.h"
 #include "arch_init.h"
 
+#include "ui/qemu-spice.h"
+
 //#define DEBUG_NET
 //#define DEBUG_SLIRP
 
@@ -2616,6 +2618,18 @@ int main(int argc, char **argv, char **envp)
                     }
                     break;
                 }
+            case QEMU_OPTION_spice:
+                olist = qemu_find_opts("spice");
+                if (!olist) {
+                    fprintf(stderr, "spice is not supported by this qemu build.\n");
+                    exit(1);
+                }
+                opts = qemu_opts_parse(olist, optarg, 0);
+                if (!opts) {
+                    fprintf(stderr, "parse error: %s\n", optarg);
+                    exit(1);
+                }
+                break;
             case QEMU_OPTION_writeconfig:
                 {
                     FILE *fp;
Signature · 1 line
1.7.1
#7 lore raw

PATCH v6 7/10 spice: add keyboard

In reply to Gerd Hoffmann

Open keyboard channel. Now you can type into the spice client and the keyboard events are sent to your guest. You'll need some other display like vnc to actually see the guest responding to them though.

---
 Makefile.objs    |    2 +-
 ui/qemu-spice.h  |    1 +
 ui/spice-core.c  |    2 +
 ui/spice-input.c |   85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 89 insertions(+), 1 deletions(-)
 create mode 100644 ui/spice-input.c
Makefile.objs +1 -1
index 2b58109..a95106f 100644
@@ -88,7 +88,7 @@ common-obj-y += pflib.o
 common-obj-$(CONFIG_BRLAPI) += baum.o
 common-obj-$(CONFIG_POSIX) += migration-exec.o migration-unix.o migration-fd.o
 
-common-obj-$(CONFIG_SPICE) += ui/spice-core.o
+common-obj-$(CONFIG_SPICE) += ui/spice-core.o ui/spice-input.o
 
 audio-obj-y = audio.o noaudio.o wavaudio.o mixeng.o
 audio-obj-$(CONFIG_SDL) += sdlaudio.o
ui/qemu-spice.h +1 -0
index 50faefb..175c961 100644
@@ -28,6 +28,7 @@
 extern int using_spice;
 
 void qemu_spice_init(void);
+void qemu_spice_input_init(void);
 int qemu_spice_add_interface(SpiceBaseInstance *sin);
 
 #else  /* CONFIG_SPICE */
ui/spice-core.c +2 -0
index 006604b..8b5e4a8 100644
@@ -167,6 +167,8 @@ void qemu_spice_init(void)
 
     spice_server_init(spice_server, &core_interface);
     using_spice = 1;
+
+    qemu_spice_input_init();
 }
 
 int qemu_spice_add_interface(SpiceBaseInstance *sin)
ui/spice-input.c new file +85 -0

85 lines not on this page · raw message

Signature · 1 line
1.7.1
#8 lore raw

PATCH v6 8/10 spice: add mouse

In reply to Gerd Hoffmann

Open mouse channel. Now you can move the guests mouse pointer. No tablet / absolute positioning (yet) though.

---
 ui/spice-input.c |   52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 52 insertions(+), 0 deletions(-)
ui/spice-input.c +52 -0
index 5538a79..91cf18d 100644
@@ -74,12 +74,64 @@ static void kbd_leds(void *opaque, int ledstate)
     spice_server_kbd_leds(&kbd->sin, ledstate);
 }
 
+/* mouse bits */
+
+typedef struct QemuSpiceMouse {
+    SpiceMouseInstance sin;
+} QemuSpiceMouse;
+
+static int map_buttons(int spice_buttons)
+{
+    int qemu_buttons = 0;
+
+    /*
+     * Note: SPICE_MOUSE_BUTTON_* specifies the wire protocol but this
+     * isn't what we get passed in via interface callbacks for the
+     * middle and right button ...
+     */
+    if (spice_buttons & SPICE_MOUSE_BUTTON_MASK_LEFT) {
+        qemu_buttons |= MOUSE_EVENT_LBUTTON;
+    }
+    if (spice_buttons & 0x04 /* SPICE_MOUSE_BUTTON_MASK_MIDDLE */) {
+        qemu_buttons |= MOUSE_EVENT_MBUTTON;
+    }
+    if (spice_buttons & 0x02 /* SPICE_MOUSE_BUTTON_MASK_RIGHT */) {
+        qemu_buttons |= MOUSE_EVENT_RBUTTON;
+    }
+    return qemu_buttons;
+}
+
+static void mouse_motion(SpiceMouseInstance *sin, int dx, int dy, int dz,
+                         uint32_t buttons_state)
+{
+    kbd_mouse_event(dx, dy, dz, map_buttons(buttons_state));
+}
+
+static void mouse_buttons(SpiceMouseInstance *sin, uint32_t buttons_state)
+{
+    kbd_mouse_event(0, 0, 0, map_buttons(buttons_state));
+}
+
+static const SpiceMouseInterface mouse_interface = {
+    .base.type          = SPICE_INTERFACE_MOUSE,
+    .base.description   = "mouse",
+    .base.major_version = SPICE_INTERFACE_MOUSE_MAJOR,
+    .base.minor_version = SPICE_INTERFACE_MOUSE_MINOR,
+    .motion             = mouse_motion,
+    .buttons            = mouse_buttons,
+};
+
 void qemu_spice_input_init(void)
 {
     QemuSpiceKbd *kbd;
+    QemuSpiceMouse *mouse;
 
     kbd = qemu_mallocz(sizeof(*kbd));
     kbd->sin.base.sif = &kbd_interface.base;
     qemu_spice_add_interface(&kbd->sin.base);
     qemu_add_led_event_handler(kbd_leds, kbd);
+
+    mouse = qemu_mallocz(sizeof(*mouse));
+    mouse->sin.base.sif = &mouse_interface.base;
+    qemu_spice_add_interface(&mouse->sin.base);
 }
Signature · 1 line
1.7.1
#9 lore raw

PATCH v6 9/10 spice: simple display

In reply to Gerd Hoffmann

With that patch applied you'll actually see the guests screen in the spice client. This does *not* bring qxl and full spice support though. This is basically the qxl vga mode made more generic, so it plays together with any qemu-emulated gfx card. You can display stdvga or cirrus via spice client. You can have both vnc and spice enabled and clients connected at the same time.

---
 Makefile.objs      |    2 +-
 ui/qemu-spice.h    |    1 +
 ui/spice-display.c |  412 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 ui/spice-display.h |   69 +++++++++
 vl.c               |    7 +
 5 files changed, 490 insertions(+), 1 deletions(-)
 create mode 100644 ui/spice-display.c
 create mode 100644 ui/spice-display.h
Makefile.objs +1 -1
index a95106f..a3113d8 100644
@@ -88,7 +88,7 @@ common-obj-y += pflib.o
 common-obj-$(CONFIG_BRLAPI) += baum.o
 common-obj-$(CONFIG_POSIX) += migration-exec.o migration-unix.o migration-fd.o
 
-common-obj-$(CONFIG_SPICE) += ui/spice-core.o ui/spice-input.o
+common-obj-$(CONFIG_SPICE) += ui/spice-core.o ui/spice-input.o ui/spice-display.o
 
 audio-obj-y = audio.o noaudio.o wavaudio.o mixeng.o
 audio-obj-$(CONFIG_SDL) += sdlaudio.o
ui/qemu-spice.h +1 -0
index 175c961..063c7dc 100644
@@ -29,6 +29,7 @@ extern int using_spice;
 
 void qemu_spice_init(void);
 void qemu_spice_input_init(void);
+void qemu_spice_display_init(DisplayState *ds);
 int qemu_spice_add_interface(SpiceBaseInstance *sin);
 
 #else  /* CONFIG_SPICE */
ui/spice-display.c new file +412 -0

412 lines not on this page · raw message

ui/spice-display.h new file +69 -0

69 lines not on this page · raw message

vl.c +7 -0
index 27d9392..ee4f8c8 100644
@@ -2931,6 +2931,8 @@ int main(int argc, char **argv, char **envp)
     /* just use the first displaystate for the moment */
     ds = get_displaystate();
 
+    if (using_spice)
+        display_remote++;
     if (display_type == DT_DEFAULT && !display_remote) {
 #if defined(CONFIG_SDL) || defined(CONFIG_COCOA)
         display_type = DT_SDL;
@@ -2973,6 +2975,11 @@ int main(int argc, char **argv, char **envp)
             printf("VNC server running on `%s'\n", vnc_display_local_addr(ds));
         }
     }
+#ifdef CONFIG_SPICE
+    if (using_spice) {
+        qemu_spice_display_init(ds);
+    }
+#endif
 
     /* display setup */
     dpy_resize(ds);
Signature · 1 line
1.7.1
#10 lore raw

PATCH v6 10/10 spice: add tablet support

In reply to Gerd Hoffmann

Add support for the spice tablet interface. The tablet interface will be registered (and then used by the spice client) as soon as a absolute pointing device is available and used by the guest, i.e. you'll have to configure your guest with '-usbdevice tablet'.

---
 ui/spice-display.c |    2 +-
 ui/spice-input.c   |   94 ++++++++++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 88 insertions(+), 8 deletions(-)
ui/spice-display.c +1 -1
index 0bc230e..6702dfd 100644
@@ -180,7 +180,7 @@ void qemu_spice_create_host_primary(SimpleSpiceDisplay *ssd)
     surface.width      = ds_get_width(ssd->ds);
     surface.height     = ds_get_height(ssd->ds);
     surface.stride     = -surface.width * 4;
-    surface.mouse_mode = 0;
+    surface.mouse_mode = true;
     surface.flags      = 0;
     surface.type       = 0;
     surface.mem        = (intptr_t)ssd->buf;
ui/spice-input.c +87 -7

119 lines not on this page · raw message

Signature · 1 line
1.7.1
#11 lore raw
In reply to Gerd Hoffmann
Quoted 11 lines · Gerd Hoffmann
   Hi,

Here comes v6 of the iniial spice support patch series which is largely a repost of v5.

* Detect spice in configure, Makefile windup.
* Support for keyboard, mouse and tablet.
* Support for simple display output (works as DisplayChangeListener, plays with any gfx card, sends simple draw commands to update dirty regions).

Quoted 7 lines

Note that this patch series does *not* yet contain the qxl paravirtual gfx card. That will come as part of a additional patch series after sorting the vgabios support.

The patches are also available in the git repository at:
git://anongit.freedesktop.org/spice/qemu submit.6

Pulled. Thanks.

Regards,

Anthony Liguori

Quoted 65 lines

Changes since v5:
* Rebased to latest master.
* Sorted some minor conflicts with trace patches.

Changes since v4:
* Code style fixups.
* Small bug fix (display_remote not being set when configuring spice via config file).

Changes since v3:
* Drop global spice_server variable, provide a thin wrapper function instead so spice interfaces can be registered without needing spice_server.
* Update locking comments.

Changes since v2:
* Add copyright headers to the files.
* Add dprint for debug logging.
* Add mapping for buttons and leds.
* Add comments for locking+threads.
* Drop includes which qemu-common.h brings in.
* Compile -spice switch unconditionally.
* Hook up spice init using module.h, drop #ifdefs.
* Misc minor tweaks.

Gerd Hoffmann (10):
Use display types for local display only. Use machine_init() to register virtfs config options. add pflib: PixelFormat conversion library.
configure: add logging
add spice into the configure file
spice: core bits
spice: add keyboard
spice: add mouse
spice: simple display
spice: add tablet support

  Makefile.objs      |    3 +
  configure          |   42 +++++-
  fsdev/qemu-fsdev.c |    9 +
  pflib.c            |  213 +++++++++++++++++++++++++++
  pflib.h            |   20 +++
  qemu-config.c      |   18 +++
  qemu-config.h      |    1 +
  qemu-options.hx    |   21 +++
  sysemu.h           |    1 -
  ui/qemu-spice.h    |   41 +++++
  ui/spice-core.c    |  189 ++++++++++++++++++++++++
  ui/spice-display.c |  412 ++++++++++++++++++++++++++++++++++++++++++++++++++++
  ui/spice-display.h |   69 +++++++++
  ui/spice-input.c   |  217 +++++++++++++++++++++++++++
  vl.c               |   50 +++++--
  15 files changed, 1287 insertions(+), 19 deletions(-)

create mode 100644 pflib.c
create mode 100644 pflib.h
create mode 100644 ui/qemu-spice.h
create mode 100644 ui/spice-core.c
create mode 100644 ui/spice-display.c
create mode 100644 ui/spice-display.h
create mode 100644 ui/spice-input.c