xenner: event channel implementation.
RFC PATCH 1/1 xenner: event channel implementation.
Hi,
Merging the xen bits seems to be on a good way. Time to look at un-bitrotting the xenner bits ...
Here is a first patch for comments. Not useful on its own. Right now I'm looking more for comments on the way the integration is done.
Event channels on Xen are managed by calling the xc_evtchn_* functions provided by libxenctrl. The library in turn does does hypercalls into the xen kernel. xenner obviously has to provide an alternative implementation for these functions. Also for others. This patch starts with just the event channels though.
It works this way: There is a struct with function pointers to the event channel functions. The struct can be switched at runtime to the xen or xenner version of the functions depending on the qemu operation mode.
The struct is named "xc_evtchn", the function pointer are named like the xc_evtchn_* functions, but without the xc_evtchn_ prefix, i.e. "xc_evtchn_open(...)" becomes xc_evtchn.open(...).
The function calls in the source code (xen backend drivers) are not changed directly, but using a include file with a bunch of #defines. That way I don't have to change s/xc_evtchn_/xc_evtchn./ all over the place. Also xenner can easily be disabled at compile time and the indirect function pointer calls simply go away then.
Comments?
cheers,
Gerd
Quoted 1 line
From
a0a4cfe5040d3792875d7cd105aa2b832f6d8967Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <[email protected]>
Date: Wed, 22 Apr 2009 12:56:04 +0200
Subject: [PATCH 5/5] xenner: event channel implementation.
--- Makefile.target | 6 + configure | 13 ++- hw/xen.h | 2 + hw/xen_backend.h | 1 + hw/xenner_hooks.h | 21 ++ hw/xenner_interfaces.h | 28 +++ hw/xenner_libxc_evtchn.c | 455 ++++++++++++++++++++++++++++++++++++++++++++++ monitor.c | 5 + 8 files changed, 530 insertions(+), 1 deletions(-) create mode 100644 hw/xenner_hooks.h create mode 100644 hw/xenner_interfaces.h create mode 100644 hw/xenner_libxc_evtchn.c
Makefile.target +6 -0
@@ -568,6 +568,12 @@ ifeq ($(CONFIG_XEN), yes) LIBS += $(XEN_LIBS) endif +# xenner support +XENNER_OBJS := xenner_libxc_evtchn.o +ifeq ($(CONFIG_XENNER), yes) + OBJS += $(XENNER_OBJS) +endif + # SCSI layer OBJS+= lsi53c895a.o esp.o
configure +12 -1
@@ -192,6 +192,7 @@ blobs="yes" fdt="yes" sdl_x11="no" xen="yes" +xenner="yes" pkgversion="" # OS specific
@@ -422,7 +423,9 @@ for opt do ;; --disable-kqemu) kqemu="no" ;; - --disable-xen) xen="no" + --disable-xen) xen="no"; xenner="no" + ;; + --disable-xenner) xenner="no" ;; --disable-brlapi) brlapi="no" ;;
@@ -590,6 +593,7 @@ echo " --audio-card-list=LIST set list of emulated audio cards [$audio_card_l echo " Available cards: $audio_possible_cards" echo " --enable-mixemu enable mixer emulation" echo " --disable-xen disable xen backend driver support" +echo " --disable-xenner disable xenner (xen emulation) support" echo " --disable-brlapi disable BrlAPI" echo " --disable-vnc-tls disable TLS encryption for VNC server" echo " --disable-vnc-sasl disable SASL encryption for VNC server"
@@ -818,6 +822,7 @@ EOF : else xen="no" + xenner="no" fi fi
@@ -1317,6 +1322,7 @@ if test -n "$sparc_cpu"; then fi echo "kqemu support $kqemu" echo "xen support $xen" +echo "xenner support $xenner" echo "brlapi support $brlapi" echo "Documentation $build_docs" [ ! -z "$uname_release" ] && \
@@ -1806,6 +1812,11 @@ case "$target_cpu" in echo "CONFIG_XEN=yes" >> $config_mak echo "#define CONFIG_XEN 1" >> $config_h fi + if test "$xenner" = "yes" -a "$target_softmmu" = "yes"; + then + echo "CONFIG_XENNER=yes" >> $config_mak + echo "#define CONFIG_XENNER 1" >> $config_h + fi ;; x86_64) echo "TARGET_ARCH=x86_64" >> $config_mak
hw/xen.h +2 -0
@@ -17,4 +17,6 @@ enum xen_mode {extern uint32_t xen_domid;extern enum xen_mode xen_mode; +void do_info_evtchn (Monitor *mon); +#endif /* QEMU_HW_XEN_H */
hw/xen_backend.h +1 -0
@@ -2,6 +2,7 @@#define QEMU_HW_XEN_BACKEND_H 1#include "xen_common.h" +#include "xenner_hooks.h" #include "sysemu.h" #include "net.h" #include "block_int.h"
hw/xenner_hooks.h new file +21 -0
@@ -0,0 +1,21 @@ +#ifndef QEMU_HW_XENNER_HOOKS_H +#define QEMU_HW_XENNER_HOOKS_H 1 + +#include "xenner_interfaces.h" + +#if defined(CONFIG_XENNER ) + +/* xen event channel interface */ +#define xc_evtchn_open xc_evtchn.open +#define xc_evtchn_close xc_evtchn.close +#define xc_evtchn_fd xc_evtchn.fd +#define xc_evtchn_notify xc_evtchn.notify +#define xc_evtchn_bind_unbound_port xc_evtchn.bind_unbound_port +#define xc_evtchn_bind_interdomain xc_evtchn.bind_interdomain +#define xc_evtchn_bind_virq xc_evtchn.bind_virq +#define xc_evtchn_unbind xc_evtchn.unbind +#define xc_evtchn_pending xc_evtchn.pending +#define xc_evtchn_unmask xc_evtchn.unmask + +#endif /* CONFIG_XENNER */ +#endif /* QEMU_HW_XENNER_HOOKS_H */
hw/xenner_interfaces.h new file +28 -0
@@ -0,0 +1,28 @@ +#ifndef QEMU_HW_XENNER_INTERFACES_H +#define QEMU_HW_XENNER_INTERFACES_H 1 + +#if defined(CONFIG_XENNER ) + +/* ------------------------------------------------------------- */ +/* xen event channel interface */ + +struct XenEvtOps { +int (*open)(void ); +int (*domid)(int xce_handle,int domid); +int (*close)(int xce_handle); +int (*fd)(int xce_handle); +int (*notify)(int xce_handle,evtchn_port_t port); +evtchn_port_or_error_t (*bind_unbound_port)(int xce_handle,int domid); +evtchn_port_or_error_t (*bind_interdomain)(int xce_handle,int domid, +evtchn_port_t remote_port); +evtchn_port_or_error_t (*bind_virq)(int xce_handle,unsigned int virq); +int (*unbind)(int xce_handle,evtchn_port_t port); +evtchn_port_or_error_t (*pending)(int xce_handle); +int (*unmask)(int xce_handle,evtchn_port_t port); +}; +extern struct XenEvtOps xc_evtchn; + +void xenner_evtchn_init (void ); + +#endif /* CONFIG_XENNER */ +#endif /* QEMU_HW_XENNER_INTERFACES_H */
hw/xenner_libxc_evtchn.c new file +455 -0
455 lines not on this page · raw message
monitor.c +5 -0
@@ -27,6 +27,7 @@#include "hw/pcmcia.h" #include "hw/pc.h" #include "hw/pci.h" +#include "hw/xen.h" #include "gdbstub.h" #include "net.h" #include "qemu-char.h"
@@ -1846,6 +1847,10 @@ static const mon_cmd_t info_cmds[] = { { "migrate", "", do_info_migrate, "", "show migration status" }, { "balloon", "", do_info_balloon, "", "show balloon information" }, +#if defined(CONFIG_XENNER) + { "evtchn", "", do_info_evtchn, + "", "show xenner event channel information" }, +#endif { NULL, NULL, }, };
Signature · 1 line
1.6.2.2
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 6 lines · Gerd Hoffmann
Hi,
Merging the xen bits seems to be on a good way. Time to look at un-bitrotting the xenner bits ...
Here is a first patch for comments. Not useful on its own. Right now I'm looking more for comments on the way the integration is done.
Quoted 8 lines
Event channels on Xen are managed by calling the xc_evtchn_* functions provided by libxenctrl. The library in turn does does hypercalls into the xen kernel. xenner obviously has to provide an alternative implementation for these functions. Also for others. This patch starts with just the event channels though.
It works this way: There is a struct with function pointers to the event channel functions. The struct can be switched at runtime to the xen or xenner version of the functions depending on the qemu operation mode.
The struct is named "
xc_evtchn", the function pointer are named like the xc_evtchn_* functions, but without thexc_evtchn_prefix, i.e. "xc_evtchn_open(...)" becomesxc_evtchn.open(...).The function calls in the source code (xen backend drivers) are not changed directly, but using a include file with a bunch of #defines. That way I don't have to change s/xc_evtchn_/xc_evtchn./ all over the place. Also xenner can easily be disabled at compile time and the indirect function pointer calls simply go away then.
I don't think the last bit is worthwhile. Function pointers these days are pretty fast, their cost will be dwarfed by the syscall and hypercall overhead.
configure for opt do · line 428
Quoted 9 lines
pecific
configure +3
-1@@ -422,7 +423,9 @@ for opt do ;; --disable-kqemu) kqemu="no" ;; - --disable-xen) xen="no" + --disable-xen) xen="no"; xenner="no" + ;; + --disable-xenner) xenner="no"
It would be nice to be able to build without the original Xen libraries.
Quoted 12 lines
hw/xenner_libxc_evtchn.c new file +11
-0+ +static struct domain *get_domain (int domid) +{ +struct domain *domain; + + TAILQ_FOREACH(domain, &domains, list) { +if (domain->domid == domid) + goto done; + } + + domain =qemu_mallocz (sizeof (*domain));
hw/xenner_libxc_evtchn.c line 75
Quoted 10 lines
hw/xenner_libxc_evtchn.c new file +10
-0+if (domid) + domain->domid = domid; +TAILQ_INSERT_TAIL (&domains, domain, list); +if (debug) +qemu_log ("xen ev: ?: new domain id %d\n" , domain->domid); + +done: + domain->refcount++; +return domain; +}
Curious, can there be any domain other than the guest and the fake dom0 you're emulating?
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 7 lines · Avi Kivity
Quoted 5 lines · Gerd Hoffmann
The function calls in the source code (xen backend drivers) are not changed directly, but using a include file with a bunch of #defines. That way I don't have to change s/xc_evtchn_/xc_evtchn./ all over the place. Also xenner can easily be disabled at compile time and the indirect function pointer calls simply go away then.
Quoted 8 lines
I don't think the last bit is worthwhile. Function pointers these days are pretty fast, their cost will be dwarfed by the syscall and hypercall overhead.
Quoted 2 lines
- --disable-xen) xen="no"
+ --disable-xen) xen="no"; xenner="no"It would be nice to be able to build without the original Xen libraries.
Hmm. I'll at least need the xen header files (at build time) anyway. Making xen and xenner independent config options and don't link the xen libraries for the !xen case should work without too much hassle (have to make the function pointers mandatory then though).
Quoted 7 lines
hw/xenner_libxc_evtchn.c line 58
Quoted 4 lines
hw/xenner_libxc_evtchn.c new file +4
-0+ +static struct domain *get_domain (int domid) +{ +struct domain *domain;Curious, can there be any domain other than the guest and the fake dom0 you're emulating?
No. It is the case for the current xenner implementation. The event channels are handled by a daemon then and the guests can talk to each other. This code is derived from the daemon. When moving xenner into qemu the event channels allow only host <=> guest communication, so that can probably simplified a bit. Not sure that would save that much code though. I'll have a look.
cheers,
Gerd
Quoted 10 lines · Avi Kivity
Quoted 5 lines · Gerd Hoffmann
The function calls in the source code (xen backend drivers) are not changed directly, but using a include file with a bunch of #defines. That way I don't have to change s/xc_evtchn_/xc_evtchn./ all over the place. Also xenner can easily be disabled at compile time and the indirect function pointer calls simply go away then.
I don't think the last bit is worthwhile. Function pointers these days are pretty fast, their cost will be dwarfed by the syscall and hypercall overhead.
New revision of the patch.
Quoted 4 lines
Quoted 2 lines
- --disable-xen) xen="no"
+ --disable-xen) xen="no"; xenner="no"It would be nice to be able to build without the original Xen libraries.
Planned for. Will not work (yet) though as I'll have to emulate all xen bits, and the event channels are only a part of the whole story.
Quoted 2 lines
Curious, can there be any domain other than the guest and the fake dom0 you're emulating?
Simplified that.
cheers,
Gerd
Quoted 1 line
From
aa19020667d6ccab98eab2077042785e4a8559dfMon Sep 17 00:00:00 2001
From: Gerd Hoffmann <[email protected]>
Date: Wed, 22 Apr 2009 12:56:04 +0200
Subject: [PATCH] xenner: event channel implementation.
--- Makefile.target | 19 ++- configure | 18 ++- hw/xen.h | 2 + hw/xen_backend.h | 1 + hw/xen_interfaces.c | 53 ++++++ hw/xen_interfaces.h | 31 ++++ hw/xen_machine_pv.c | 1 + hw/xen_redirect.h | 18 ++ hw/xenner_libxc_evtchn.c | 401 ++++++++++++++++++++++++++++++++++++++++++++++ monitor.c | 5 + 10 files changed, 541 insertions(+), 8 deletions(-) create mode 100644 hw/xen_interfaces.c create mode 100644 hw/xen_interfaces.h create mode 100644 hw/xen_redirect.h create mode 100644 hw/xenner_libxc_evtchn.c
Makefile.target +14 -5
@@ -561,14 +561,23 @@ ifdef CONFIG_BLUEZ LIBS += $(CONFIG_BLUEZ_LIBS) endif -# xen backend driver support -XEN_OBJS := xen_machine_pv.o xen_backend.o xen_devconfig.o xen_domainbuild.o -XEN_OBJS += xen_console.o xenfb.o xen_disk.o xen_nic.o -ifeq ($(CONFIG_XEN), yes) - OBJS += $(XEN_OBJS) +# xen backend drivers (shared by xenner+xen) +ifneq ($(CONFIG_XEN)$(CONFIG_XENNER),) + OBJS += xen_machine_pv.o xen_backend.o xen_devconfig.o xen_interfaces.o + OBJS += xen_console.o xenfb.o xen_disk.o xen_nic.o +endif + +# xen support +ifeq ($(CONFIG_XEN),yes) + OBJS += xen_domainbuild.o LIBS += $(XEN_LIBS) endif +# xenner support +ifeq ($(CONFIG_XENNER),yes) + OBJS += xenner_libxc_evtchn.o +endif + # SCSI layer OBJS+= lsi53c895a.o esp.o
configure +15 -3
@@ -194,6 +194,7 @@ blobs="yes" fdt="yes" sdl_x11="no" xen="yes" +xenner="yes" pkgversion="" # OS specific
@@ -424,7 +425,9 @@ for opt do ;; --disable-kqemu) kqemu="no" ;; - --disable-xen) xen="no" + --disable-xen) xen="no"; xenner="no" + ;; + --disable-xenner) xenner="no" ;; --disable-brlapi) brlapi="no" ;;
@@ -596,6 +599,7 @@ echo " --audio-card-list=LIST set list of emulated audio cards [$audio_card_l echo " Available cards: $audio_possible_cards" echo " --enable-mixemu enable mixer emulation" echo " --disable-xen disable xen backend driver support" +echo " --disable-xenner disable xenner (xen emulation) support" echo " --disable-brlapi disable BrlAPI" echo " --disable-vnc-tls disable TLS encryption for VNC server" echo " --disable-vnc-sasl disable SASL encryption for VNC server"
@@ -814,9 +818,10 @@ else fi ########################################## -# xen probe +# probe for xen libs and includes +# note: xenner included here as it needs the headers too. -if test "$xen" = "yes" ; then +if test "$xen" = "yes" -o "$xenner" = "yes"; then cat > $TMPC <<EOF #include <xenctrl.h> #include <xs.h>
@@ -826,6 +831,7 @@ EOF : else xen="no" + xenner="no" fi fi
@@ -1330,6 +1336,7 @@ if test -n "$sparc_cpu"; then fi echo "kqemu support $kqemu" echo "xen support $xen" +echo "xenner support $xenner" echo "brlapi support $brlapi" echo "Documentation $build_docs" [ ! -z "$uname_release" ] && \
@@ -1825,6 +1832,11 @@ case "$target_cpu" in echo "CONFIG_XEN=yes" >> $config_mak echo "#define CONFIG_XEN 1" >> $config_h fi + if test "$xenner" = "yes" -a "$target_softmmu" = "yes"; + then + echo "CONFIG_XENNER=yes" >> $config_mak + echo "#define CONFIG_XENNER 1" >> $config_h + fi ;; x86_64) echo "TARGET_ARCH=x86_64" >> $config_mak
hw/xen.h +2 -0
@@ -17,4 +17,6 @@ enum xen_mode {extern uint32_t xen_domid;extern enum xen_mode xen_mode; +void do_info_evtchn (Monitor *mon); +#endif /* QEMU_HW_XEN_H */
hw/xen_backend.h +1 -0
@@ -2,6 +2,7 @@#define QEMU_HW_XEN_BACKEND_H 1#include "xen_common.h" +#include "xen_redirect.h" #include "sysemu.h" #include "net.h" #include "block_int.h"
hw/xen_interfaces.c new file +53 -0
53 lines not on this page · raw message
hw/xen_interfaces.h new file +31 -0
@@ -0,0 +1,31 @@ +#ifndef QEMU_HW_XEN_INTERFACES_H +#define QEMU_HW_XEN_INTERFACES_H 1 + +/* ------------------------------------------------------------- */ +/* xen event channel interface */ + +struct XenEvtOps { +int (*open)(void ); +int (*domid)(int xce_handle,int domid); +int (*close)(int xce_handle); +int (*fd)(int xce_handle); +int (*notify)(int xce_handle,evtchn_port_t port); +evtchn_port_or_error_t (*bind_unbound_port)(int xce_handle,int domid); +evtchn_port_or_error_t (*bind_interdomain)(int xce_handle,int domid, +evtchn_port_t remote_port); +evtchn_port_or_error_t (*bind_virq)(int xce_handle,unsigned int virq); +int (*unbind)(int xce_handle,evtchn_port_t port); +evtchn_port_or_error_t (*pending)(int xce_handle); +int (*unmask)(int xce_handle,evtchn_port_t port); +}; +extern struct XenEvtOps xc_evtchn; + +/* ------------------------------------------------------------- */ + +#ifdef CONFIG_XENNER +extern struct XenEvtOps xc_evtchn_xenner; +#endif + +void xen_interfaces_init (void ); + +#endif /* QEMU_HW_XEN_INTERFACES_H */
hw/xen_machine_pv.c +1 -0
@@ -54,6 +54,7 @@ static void xen_init_pv(ram_addr_t ram_size, int vga_ram_size, env->halted =1 ;/* Initialize backend core & drivers */ +xen_interfaces_init ();if (xen_be_init () !=0 ) {fprintf (stderr,"%s: xen backend core setup failed\n" , __FUNCTION__);exit (1 );
hw/xen_redirect.h new file +18 -0
@@ -0,0 +1,18 @@ +#ifndef QEMU_HW_XEN_REDIRECT_H +#define QEMU_HW_XEN_REDIRECT_H 1 + +#include "xen_interfaces.h" + +/* xen event channel interface */ +#define xc_evtchn_open xc_evtchn.open +#define xc_evtchn_close xc_evtchn.close +#define xc_evtchn_fd xc_evtchn.fd +#define xc_evtchn_notify xc_evtchn.notify +#define xc_evtchn_bind_unbound_port xc_evtchn.bind_unbound_port +#define xc_evtchn_bind_interdomain xc_evtchn.bind_interdomain +#define xc_evtchn_bind_virq xc_evtchn.bind_virq +#define xc_evtchn_unbind xc_evtchn.unbind +#define xc_evtchn_pending xc_evtchn.pending +#define xc_evtchn_unmask xc_evtchn.unmask + +#endif /* QEMU_HW_XEN_REDIRECT_H */
hw/xenner_libxc_evtchn.c new file +401 -0
401 lines not on this page · raw message
monitor.c +5 -0
@@ -27,6 +27,7 @@#include "hw/pcmcia.h" #include "hw/pc.h" #include "hw/pci.h" +#include "hw/xen.h" #include "gdbstub.h" #include "net.h" #include "qemu-char.h"
@@ -1846,6 +1847,10 @@ static const mon_cmd_t info_cmds[] = { { "migrate", "", do_info_migrate, "", "show migration status" }, { "balloon", "", do_info_balloon, "", "show balloon information" }, +#if defined(CONFIG_XENNER) + { "evtchn", "", do_info_evtchn, + "", "show xenner event channel information" }, +#endif { NULL, NULL, }, };
Signature · 1 line
1.6.2.2
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 7 lines · Gerd Hoffmann
Hi,
Merging the xen bits seems to be on a good way. Time to look at un-bitrotting the xenner bits ...
Here is a first patch for comments. Not useful on its own. Right now I'm looking more for comments on the way the integration is done.
Event channels on Xen are managed by calling the xc_evtchn_* functions provided by libxenctrl. The library in turn does does hypercalls into the xen kernel. xenner obviously has to provide an alternative implementation for these functions. Also for others. This patch starts with just the event channels though.
With xenner, do you still use xenstore/xenconsoled? If so, don't you need some LD_PRELOAD magic to make that work?
Regards,
Anthony Liguori
Quoted 10 lines
It works this way: There is a struct with function pointers to the event channel functions. The struct can be switched at runtime to the xen or xenner version of the functions depending on the qemu operation mode.
The struct is named "
xc_evtchn", the function pointer are named like the xc_evtchn_* functions, but without thexc_evtchn_prefix, i.e. "xc_evtchn_open(...)" becomesxc_evtchn.open(...).The function calls in the source code (xen backend drivers) are not changed directly, but using a include file with a bunch of #defines. That way I don't have to change s/xc_evtchn_/xc_evtchn./ all over the place. Also xenner can easily be disabled at compile time and the indirect function pointer calls simply go away then.
Comments?
cheers,
Gerd
Quoted 8 lines · Anthony Liguori
Quoted 5 lines · Gerd Hoffmann
Event channels on Xen are managed by calling the xc_evtchn_* functions provided by libxenctrl. The library in turn does does hypercalls into the xen kernel. xenner obviously has to provide an alternative implementation for these functions. Also for others. This patch starts with just the event channels though.
With xenner, do you still use xenstore/xenconsoled?
The current standalone version does. The qemu-merged version will not.
cheers,
Gerd