Skip to contentSkip to conversation

add spicevmc chardev

PATCH New Alon Levy 1 participant 2 messages Jan 19, 2011 Kbuild

lore
Share & tools
lore

Alon Levy

author
#0 lore raw

cover add spicevmc chardev

In additional to the description in the patch, see following email for uses:
http://lists.nongnu.org/archive/html/qemu-devel/2011-01/msg01208.html

In particular it would/could be used for:
current vdagent of spice uses this for mouse, copy paste proposed smartcard device for qemu uses this with spice usb forwarding
terminal forwarding
qemu monitor forwarding

Alon Levy (1):
spice: add chardev (v5)

 Makefile.objs     |    2 +-
 qemu-char.c       |    4 +
 qemu-config.c     |    6 ++
 qemu-options.hx   |   16 ++++-
 spice-qemu-char.c |  190 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 trace-events      |    6 ++
 ui/qemu-spice.h   |    3 +
 7 files changed, 225 insertions(+), 2 deletions(-)
 create mode 100644 spice-qemu-char.c
Signature · 1 line
1.7.3.4
author
#1 lore raw

PATCH 1/1 spice: add chardev (v5)

Adding a chardev backend for spice, where spice determines what to do with it based on the name attribute given during chardev creation. For usage by spice vdagent in conjunction with a properly named virtio-serial device, and future smartcard channel usage.

Example usage:
qemu -device virtio-serial -chardev spicevmc,name=vdagent,id=vdagent \
-device virtserialport,chardev=vdagent,name=com.redhat.spice.0

v4->v5:
* add tracing events
* fix missing comma
* fix help string to show debug is optional

v3->v4:
* updated commit message

v1->v3 changes: (v2 had a wrong commit message)
* removed spice-qemu-char.h, folded into ui/qemu-spice.h
* removed dead IOCTL code
* removed comment
* removed ifdef CONFIG_SPICE from qemu-config.c and qemu-options.hx help.

---
 Makefile.objs     |    2 +-
 qemu-char.c       |    4 +
 qemu-config.c     |    6 ++
 qemu-options.hx   |   16 ++++-
 spice-qemu-char.c |  190 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 trace-events      |    6 ++
 ui/qemu-spice.h   |    3 +
 7 files changed, 225 insertions(+), 2 deletions(-)
 create mode 100644 spice-qemu-char.c
Makefile.objs +1 -1
index c3e52c5..b9e9ef6 100644
@@ -105,7 +105,7 @@ common-obj-$(CONFIG_BRLAPI) += baum.o
 common-obj-$(CONFIG_POSIX) += migration-exec.o migration-unix.o migration-fd.o
 common-obj-$(CONFIG_WIN32) += version.o
 
-common-obj-$(CONFIG_SPICE) += ui/spice-core.o ui/spice-input.o ui/spice-display.o
+common-obj-$(CONFIG_SPICE) += ui/spice-core.o ui/spice-input.o ui/spice-display.o spice-qemu-char.o
 
 audio-obj-y = audio.o noaudio.o wavaudio.o mixeng.o
 audio-obj-$(CONFIG_SDL) += sdlaudio.o
qemu-char.c +4 -0
index edc9ad6..acc7130 100644
@@ -97,6 +97,7 @@
 #endif
 
 #include "qemu_socket.h"
+#include "ui/qemu-spice.h"
 
 #define READ_BUF_LEN 4096
 
@@ -2495,6 +2496,9 @@ static const struct {
     || defined(__FreeBSD_kernel__)
     { .name = "parport",   .open = qemu_chr_open_pp },
 #endif
+#ifdef CONFIG_SPICE
+    { .name = "spicevmc",     .open = qemu_chr_open_spice },
+#endif
 };
 
 CharDriverState *qemu_chr_open_opts(QemuOpts *opts,
qemu-config.c +6 -0
index 965fa46..323d3c2 100644
@@ -146,6 +146,12 @@ static QemuOptsList qemu_chardev_opts = {
         },{
             .name = "signal",
             .type = QEMU_OPT_BOOL,
+        },{
+            .name = "name",
+            .type = QEMU_OPT_STRING,
+        },{
+            .name = "debug",
+            .type = QEMU_OPT_NUMBER,
         },
         { /* end of list */ }
     },
qemu-options.hx +15 -1
index 898561d..939297a 100644
@@ -1368,6 +1368,9 @@ DEF("chardev", HAS_ARG, QEMU_OPTION_chardev,
 #if defined(__linux__) || defined(__FreeBSD__) || defined(__DragonFly__)
     "-chardev parport,id=id,path=path[,mux=on|off]\n"
 #endif
+#if defined(CONFIG_SPICE)
+    "-chardev spicevmc,id=id,name=name[,debug=debug]\n"
+#endif
     , QEMU_ARCH_ALL
 )
 
@@ -1392,7 +1395,8 @@ Backend is one of:
 @option{stdio},
 @option{braille},
 @option{tty},
-@option{parport}.
+@option{parport},
+@option{spicevmc}.
 The specific backend will determine the applicable options.
 
 All devices must have an id, which can be any string up to 127 characters long.
@@ -1568,6 +1572,16 @@ Connect to a local parallel port.
 @option{path} specifies the path to the parallel port device. @option{path} is
 required.
 
+#if defined(CONFIG_SPICE)
+@item -chardev spicevmc ,id=@var{id} ,debug=@var{debug}, name=@var{name}
+
+@option{debug} debug level for spicevmc
+
+@option{name} name of spice channel to connect to
+
+Connect to a spice virtual machine channel, such as vdiport.
+#endif
+
 @end table
 ETEXI
 
spice-qemu-char.c new file +190 -0

190 lines not on this page · raw message

trace-events +6 -0
index e8fed0f..f08ec79 100644
@@ -213,3 +213,9 @@ disable qed_aio_write_data(void *s, void *acb, int ret, uint64_t offset, size_t
 disable qed_aio_write_prefill(void *s, void *acb, uint64_t start, size_t len, uint64_t offset) "s %p acb %p start %"PRIu64" len %zu offset %"PRIu64""
 disable qed_aio_write_postfill(void *s, void *acb, uint64_t start, size_t len, uint64_t offset) "s %p acb %p start %"PRIu64" len %zu offset %"PRIu64""
 disable qed_aio_write_main(void *s, void *acb, int ret, uint64_t offset, size_t len) "s %p acb %p ret %d offset %"PRIu64" len %zu"
+
+# spice-qemu-char.c
+disable spice_vmc_write(ssize_t out, int len) "spice wrottn %lu of requested %zd"
+disable spice_vmc_read(int bytes, int len) "spice read %lu of requested %zd"
+disable spice_vmc_register_interface(void *scd) "spice vmc registered interface %p"
+disable spice_vmc_unregister_interface(void *scd) "spice vmc unregistered interface %p"
ui/qemu-spice.h +3 -0
index 48239c3..baa951a 100644
@@ -24,6 +24,7 @@
 
 #include "qemu-option.h"
 #include "qemu-config.h"
+#include "qemu-char.h"
 
 extern int using_spice;
 
@@ -39,6 +40,8 @@ int qemu_spice_set_pw_expire(time_t expires);
 void do_info_spice_print(Monitor *mon, const QObject *data);
 void do_info_spice(Monitor *mon, QObject **ret_data);
 
+CharDriverState *qemu_chr_open_spice(QemuOpts *opts);
+
 #else  /* CONFIG_SPICE */
 
 #define using_spice 0
Signature · 1 line
1.7.3.4