merge some xen bits into qemu
cover merge some xen bits into qemu
Hi folks,
This is the third version of the xen support for qemu patch series, addressing review comments, mostly the ones from the xen folks.
The console and framebuffer backend drivers are largely based on the xen code, the other bits are rewritten from scratch. Nevertheless the code should be functionally identical.
Overview (individual patches have longer descriptions):
#1 -- Handle terminating signals. #2 -- add DisplayState->idle #3 -- add container_of() macro to osdep.h #4 -- move GUI_REFRESH_INTERVAL define from vl.c to console.h
#5 -- groundwork: build system, cmd line options, ... #6 -- xen backend driver infrastructrure #7 -- xen console backend driver #8 -- xen framebuffer backend driver
#9 -- xen block backend driver
#10 -- xen nic backend driver
#11 -- allow xen disks and nics being configured via qemu command
line options.
The first four patches are preparing patches. They put some stuff in place the other xen patches depend on.
With the next four patches in place upstream qemu can replace xen's qemu-dm for paravirtual domains. The block and nic backend drivers are full userspace implementations using the grant table device (gntdev).
xen support is implemented using another machine type. xen's qemu-dm already uses the machine type to switch between paravirtualized and fully virtualized machines, so this was the natural choice. qemu has gets a new "xenpv" machine type additionally to the "pc" and "isapc" ones.
The patches are also available here, together with some not-yet submitted work-in-progress bits:
http://kraxel.fedorapeople.org/patches/qemu-upstream/
There is also a patch queue for qemu-dm, so the patches can get a test-drive there. Looks slightly different because I left vl.c and the build system largely alone. Also the preparing patches are not needed there. And the last two patches are not ported over (yet), but xen probably wouldn't use these bits anyway ...
http://kraxel.fedorapeople.org/patches/qemu-xen/
Comments?
cheers,
Gerd
PATCH 1/11 Handle terminating signals.
This patch makes qemu handle signals better. For normal signals (SIGINT, SIGTERM & friends) it just sets the request_shutdown flag, making the main_loop exit and qemu taking the usual exit route, with atexit handlers being called and so on, instead of qemu just being killed by the signal.
For fatal signals such as SIGSEGV, where the exit handler can't return, it allows to register clean up handlers which will be called instead of the atexit handlers. Those handlers must be save to run in signal context.
--- Makefile.target | 2 +- curses.c | 2 - sdl.c | 9 +---- termsig.c | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ termsig.h | 15 ++++++++ vl.c | 6 +++ 6 files changed, 127 insertions(+), 11 deletions(-) create mode 100644 termsig.c create mode 100644 termsig.h
Makefile.target +1 -1
@@ -472,7 +472,7 @@ endif #CONFIG_DARWIN_USER # System emulator target ifndef CONFIG_USER_ONLY -OBJS=vl.o osdep.o monitor.o pci.o loader.o isa_mmio.o machine.o net-checksum.o +OBJS=vl.o osdep.o monitor.o pci.o loader.o isa_mmio.o machine.o net-checksum.o termsig.o ifdef CONFIG_WIN32 OBJS+=block-raw-win32.o else
curses.c +0 -2
@@ -346,8 +346,6 @@ void curses_display_init(DisplayState *ds, int full_screen)atexit (curses_atexit);#ifndef _WIN32 -signal (SIGINT ,SIG_DFL ); -signal (SIGQUIT ,SIG_DFL );#if defined(SIGWINCH ) && defined(KEY_RESIZE )/* some curses implementations provide a handler, but we * want to be sure this is handled regardless of the library */
sdl.c +1 -8
@@ -476,10 +476,8 @@ static void sdl_refresh(DisplayState *ds)sdl_process_key (&ev->key);break ;case SDL_QUIT : -if (!no_quit) { +if (!no_quit)qemu_system_shutdown_request (); -vm_start ();/* In case we're paused */ - }break ;case SDL_MOUSEMOTION : if (gui_grab || kbd_mouse_is_absolute() ||
@@ -636,11 +634,6 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)fprintf (stderr,"Could not initialize SDL - exiting\n" );exit (1 ); } -#ifndef _WIN32 -/* NOTE: we still want Ctrl-C to work, so we undo the SDL redirections */ -signal (SIGINT ,SIG_DFL ); -signal (SIGQUIT ,SIG_DFL ); -#endif ds->dpy_update = sdl_update; ds->dpy_resize = sdl_resize;
termsig.c new file +104 -0
104 lines not on this page · raw message
termsig.h new file +15 -0
@@ -0,0 +1,15 @@ +/* +* Register cleanup handler. +* +* These handlers are *only* called for emergeny exits, in case we +* can't use the normal exit() and thus atexit() handlers don't work. +* +* These handlers are called directly from the signal handler and +* thus are limited to functions which can safely be called from +* signal context (see "man 7 signal"). +* +*/ +void fatalsig_register_handler (void (*func)(void )); + +/* setup signal handlers, called from main() */ +void termsig_setup (void );
vl.c +6 -0
@@ -37,6 +37,7 @@#include "qemu-char.h" #include "block.h" #include "audio/audio.h" +#include "termsig.h" #include <unistd.h> #include <fcntl.h>
@@ -7585,6 +7586,8 @@ static int main_loop(void) timeout =0 ; } }else { +if (shutdown_requested) +break ; timeout =10 ; }#ifdef CONFIG_PROFILER
@@ -9031,6 +9034,9 @@ int main(int argc, char **argv)#endif } +/* must be after terminal init, SDL changes signal handlers */ +termsig_setup (); +/* Maintain compatibility with multiple stdio monitors */ has_monitor =0 ;
Signature · 1 line
1.5.5.1
Re: [Qemu-devel] [PATCH 01/11] Handle terminating signals.
Quoted 18 lines · Gerd Hoffmann
curses.c +0
-2@@ -346,8 +346,6 @@ void curses_display_init(DisplayState *ds, int full_screen)atexit (curses_atexit);#ifndef _WIN32 -signal (SIGINT ,SIG_DFL ); -signal (SIGQUIT ,SIG_DFL );#if defined(SIGWINCH ) && defined(KEY_RESIZE )/* some curses implementations provide a handler, but we * want to be sure this is handled regardless of the library */ sdl.c +0
-0
sdl.c static void sdl_refresh(DisplayState *ds) · line 481
Quoted 8 lines
sdl.c +1
-2@@ -476,10 +476,8 @@ static void sdl_refresh(DisplayState *ds)sdl_process_key (&ev->key);break ;case SDL_QUIT : -if (!no_quit) { +if (!no_quit)qemu_system_shutdown_request (); -vm_start ();/* In case we're paused */
I'm curious why this is no longer needed?
Re: [Qemu-devel] [PATCH 01/11] Handle terminating signals.
Quoted 5 lines · Anthony Liguori
Quoted 5 lines
sdl.c +0
-0@@ -476,10 +476,8 @@ static void sdl_refresh(DisplayState *ds)sdl_process_key (&ev->key);break ;
Quoted 8 lines
sdl.c static void sdl_refresh(DisplayState *ds)
Quoted 6 lines
sdl.c +1
-2case SDL_QUIT : -if (!no_quit) { +if (!no_quit)qemu_system_shutdown_request (); -vm_start ();/* In case we're paused */ I'm curious why this is no longer needed?
To avoid calling vm_start() from the signal handler main_loop() got an additional check so qemu_system_shutdown_request() works even when the vm is in stopped state.
[ Hmm, cut&paste -> changelog I guess ... ]
cheers,
Gerd
Signature · 1 line
http://kraxel.fedorapeople.org/xenner/
Re: [Qemu-devel] [PATCH 01/11] Handle terminating signals.
In reply to Gerd HoffmannQuoted 2 lines · Gerd Hoffmann
+void
fatalsig_register_handler(void (*func)(void));
Unless I'm misreading, none of your patches seem to use this function. What are you adding this mechanism for?
Regards,
Anthony Liguori
Re: [Qemu-devel] [PATCH 01/11] Handle terminating signals.
Quoted 6 lines · Anthony Liguori
Quoted 2 lines · Gerd Hoffmann
+void
fatalsig_register_handler(void (*func)(void));Unless I'm misreading, none of your patches seem to use this function. What are you adding this mechanism for?
The patch using that isn't fully polished yet for submission. Sneak preview is here:
http://kraxel.fedorapeople.org/patches/qemu-upstream/0015-xen-domain-builder.patch
Adds pv domain builder to qemu, so you can start pv xen guests using qemu only. In that case we'll want to destroy the guest domain when qemu goes down because the xen management stack will not cleanup after us.
cheers,
Gerd
Signature · 1 line
http://kraxel.fedorapeople.org/xenner/
Re: [Qemu-devel] [PATCH 01/11] Handle terminating signals.
Quoted 10 lines · Gerd Hoffmann
Quoted 7 lines · Anthony Liguori
Quoted 3 lines · Gerd Hoffmann
+void
fatalsig_register_handler(void (*func)(void));Unless I'm misreading, none of your patches seem to use this function. What are you adding this mechanism for?
Quoted 9 lines
The patch using that isn't fully polished yet for submission. Sneak preview is here:
http://kraxel.fedorapeople.org/patches/qemu-upstream/0015-xen-domain-builder.patch
Adds pv domain builder to qemu, so you can start pv xen guests using qemu only. In that case we'll want to destroy the guest domain when qemu goes down because the xen management stack will not cleanup after us.
I was asking because I thought it may be something like this. An alternative to this signal handler stuff would be to fork() off a process with another end of a pipe. That process could just sit their waiting for eof and when eof was received, it could destroy the domain.
The main advantage of this approach is that it works in every possible circumstance. Even if the qemu process totally borks it's stack or tramples over memory in such a way as to render the signal handling code broken.
Regards,
Anthony Liguori
Quoted 4 lines
cheers,
Gerd
PATCH 2/11 add DisplayState->idle
In reply to Gerd HoffmannFrom: Samuel Thibault <[email protected]>
From: Samuel Thibault <[email protected]>
Add idle field to DisplayState struct, so drivers can figure the display is idle and take advantage of that.
The xen framebuffer driver will use this to communicate the idle state to the guest, so it knows it can stop doing updates to a virtual display which is invisible anyway.
--- console.h | 1 + sdl.c | 2 ++ vl.c | 2 ++ vnc.c | 3 +++ 4 files changed, 8 insertions(+), 0 deletions(-)
console.h +1 -0
@@ -80,6 +80,7 @@ struct DisplayState {void *opaque;struct QEMUTimer *gui_timer;uint64_t gui_timer_interval; +int idle;void (*dpy_update)(struct DisplayState *s,int x,int y,int w,int h);void (*dpy_resize)(struct DisplayState *s,int w,int h);
sdl.c +2 -0
@@ -524,9 +524,11 @@ static void sdl_refresh(DisplayState *ds)if (ev->active.gain) {/* Back to default interval */ ds->gui_timer_interval =0 ; + ds->idle =0 ; }else {/* Sleeping interval */ ds->gui_timer_interval =500 ; + ds->idle =1 ; } }break ;
vl.c +2 -0
@@ -5941,6 +5941,8 @@ static void dumb_display_init(DisplayState *ds) ds->dpy_update = dumb_update; ds->dpy_resize = dumb_resize; ds->dpy_refresh = dumb_refresh; + ds->gui_timer_interval =500 ; + ds->idle =1 ; }/***********************************************************/
vnc.c +3 -0
@@ -660,6 +660,7 @@ static int vnc_client_io_error(VncState *vs, int ret, int last_errno)qemu_set_fd_handler2 (vs->csock,NULL ,NULL ,NULL ,NULL );closesocket (vs->csock); vs->csock =-1 ; + vs->ds->idle =1 ;buffer_reset (&vs->input);buffer_reset (&vs->output); vs->need_update =0 ;
@@ -1920,6 +1921,7 @@ static int protocol_version(VncState *vs, uint8_t *version, size_t len)static void vnc_connect (VncState *vs) {VNC_DEBUG ("New client on socket %d\n" , vs->csock); + vs->ds->idle =0 ;socket_set_nonblock (vs->csock);qemu_set_fd_handler2 (vs->csock,NULL , vnc_client_read,NULL , vs);vnc_write (vs,"RFB 003.008\n" ,12 );
@@ -1959,6 +1961,7 @@ void vnc_display_init(DisplayState *ds)exit (1 ); ds->opaque = vs; + ds->idle =1 ; vnc_state = vs; vs->display =NULL ; vs->password =NULL ;
Signature · 1 line
1.5.5.1
[Qemu-devel] Re: [PATCH 02/11] add DisplayState->idle
Quoted 4 lines · Gerd Hoffmann, le Mon 11 Aug 2008 14:32:41 +0200, a écrit :
From: Samuel Thibault <[email protected]>
From: Samuel Thibault <[email protected]>
Quoted 8 lines
Add idle field to DisplayState struct, so drivers can figure the display is idle and take advantage of that.
The xen framebuffer driver will use this to communicate the idle state to the guest, so it knows it can stop doing updates to a virtual display which is invisible anyway.
Signed-off-by Gerd Hoffmann <[email protected]>
PATCH 3/11 add container_of() macro to osdep.h
In reply to Gerd HoffmannQuoted 1 line
From linux kernel sources, xen bits will use it, put it
into a place where others can see and use it too ;)
--- osdep.h | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
osdep.h +4 -0
@@ -19,6 +19,10 @@#define unlikely (x) __builtin_expect(!!(x), 0)#endif +#define container_of (ptr, type, member) ({ \ + const typeof( ((type *)0)->member ) *__mptr = (ptr); \ + (type *)( (char *)__mptr - offsetof(type,member) );}) +#ifndef MIN #define MIN (a, b) (((a) < (b)) ? (a) : (b))#endif
Signature · 1 line
1.5.5.1
PATCH 4/11 move GUI_REFRESH_INTERVAL define from vl.c to console.h
In reply to Gerd Hoffmann--- console.h | 3 +++ vl.c | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-)
console.h +3 -0
@@ -9,6 +9,9 @@#define MOUSE_EVENT_RBUTTON 0x02#define MOUSE_EVENT_MBUTTON 0x04 +/* in ms */ +#define GUI_REFRESH_INTERVAL 30 +typedef void QEMUPutKBDEvent (void *opaque,int keycode);typedef void QEMUPutMouseEvent (void *opaque,int dx,int dy,int dz,int buttons_state);
vl.c +0 -2
@@ -152,8 +152,6 @@ int inet_aton(const char *cp, struct in_addr *ia);#else #define DEFAULT_RAM_SIZE 128#endif -/* in ms */ -#define GUI_REFRESH_INTERVAL 30/* Max number of USB devices that can be specified on the commandline. */ #define MAX_USB_CMDLINE 8
Signature · 1 line
1.5.5.1
PATCH 5/11 xen: groundwork for xen support
In reply to Gerd Hoffmann- configure script and build system changes.
- wind up new machine type.
- add -domid command line option.
- allow xenpv machines run without disk and kernel specified by adding a nodisk_ok field to QEMUMachine.
- detect xen being present.
--- Makefile.target | 8 +++ configure | 27 +++++++++ hw/boards.h | 4 + hw/xen.h | 18 ++++++ hw/xen_machine_pv.c | 146 +++++++++++++++++++++++++++++++++++++++++++++++++ target-i386/machine.c | 3 + vl.c | 19 ++++++- 7 files changed, 223 insertions(+), 2 deletions(-) create mode 100644 hw/xen.h create mode 100644 hw/xen_machine_pv.c
Makefile.target +8 -0
@@ -515,6 +515,14 @@ CPPFLAGS += $(CONFIG_VNC_TLS_CFLAGS) LIBS += $(CONFIG_VNC_TLS_LIBS) endif +# xen backend driver support +XEN_OBJS := xen_machine_pv.o +ifeq ($(CONFIG_XEN), yes) + OBJS += $(XEN_OBJS) + LIBS += $(XEN_LIBS) + $(XEN_OBJS) : CFLAGS += -Wall -Wmissing-prototypes -Wstrict-prototypes +endif + # SCSI layer OBJS+= lsi53c895a.o esp.o
configure +27 -0
@@ -108,6 +108,7 @@ uname_release="" curses="yes" nptl="yes" mixemu="no" +xen="no" # OS specific targetos=`uname -s`
@@ -202,6 +203,7 @@ linux="yes" linux_user="yes" if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then kqemu="yes" + xen="yes" audio_possible_drivers="$audio_possible_drivers fmod" fi ;;
@@ -285,6 +287,8 @@ for opt do ;; --disable-kqemu) kqemu="no" ;; + --disable-xen) xen="no" + ;; --disable-brlapi) brlapi="no" ;; --enable-profiler) profiler="yes"
@@ -421,6 +425,7 @@ echo " Available drivers: $audio_possible_drivers" echo " --audio-card-list=LIST set list of additional emulated audio cards" echo " Available cards: ac97 adlib cs4231a gus" echo " --enable-mixemu enable mixer emulation" +echo " --disable-xen disable xen backend driver support" echo " --disable-brlapi disable BrlAPI" echo " --disable-vnc-tls disable TLS encryption for VNC server" echo " --disable-curses disable curses output"
@@ -681,6 +686,22 @@ else fi ########################################## +# xen probe + +if test "$xen" = "yes" ; then +cat > $TMPC <<EOF +#include <xenctrl.h> +#include <xs.h> +int main(void) { xs_daemon_open; xc_interface_open; } +EOF + if $cc $ARCH_CFLAGS -c -o $TMPO $TMPC -lxenstore -lxenctrl 2> /dev/null ; then + : + else + xen="no" + fi +fi + +########################################## # SDL probe sdl_too_old=no
@@ -924,6 +945,7 @@ if test -n "$sparc_cpu"; then echo "Target Sparc Arch $sparc_cpu" fi echo "kqemu support $kqemu" +echo "xen support $xen" echo "brlapi support $brlapi" echo "Documentation $build_docs" [ ! -z "$uname_release" ] && \
@@ -1175,6 +1197,11 @@ if test "$brlapi" = "yes" ; then echo "#define CONFIG_BRLAPI 1" >> $config_h echo "BRLAPI_LIBS=-lbrlapi" >> $config_mak fi +if test "$xen" = "yes" ; then + echo "CONFIG_XEN=yes" >> $config_mak + echo "#define CONFIG_XEN 1" >> $config_h + echo "XEN_LIBS=-lxenstore -lxenctrl" >> $config_mak +fi # XXX: suppress that if [ "$bsd" = "yes" ] ; then
hw/boards.h +4 -0
@@ -16,6 +16,7 @@ typedef struct QEMUMachine {QEMUMachineInitFunc *init;#define RAMSIZE_FIXED (1 << 0)ram_addr_t ram_require; +int nodisk_ok;struct QEMUMachine *next; } QEMUMachine;
@@ -29,6 +30,9 @@ extern QEMUMachine bareetraxfs_machine;extern QEMUMachine pc_machine;extern QEMUMachine isapc_machine; +/* xen_machine.c */ +extern QEMUMachine xenpv_machine; +/* ppc.c */ extern QEMUMachine prep_machine;extern QEMUMachine core99_machine;
hw/xen.h new file +18 -0
@@ -0,0 +1,18 @@ +#ifndef QEMU_XEN_H +#define QEMU_XEN_H 1 +/* +* public xen header +* stuff needed outside xen-*.c, i.e. interfaces to qemu. +* must not depend on any xen headers being present in +* /usr/include/xen, so it can be included unconditionally. +*/ + +/* xen-machine.c */ +extern int xen_domid; +extern int xen_present; +extern int xen_emulate; +extern int xen_domainbuild; + +int xen_detect (void ); + +#endif /* QEMU_XEN_H */
hw/xen_machine_pv.c new file +146 -0
146 lines not on this page · raw message
target-i386/machine.c +3 -0
@@ -9,6 +9,9 @@ void register_machines(void) {qemu_register_machine (&pc_machine);qemu_register_machine (&isapc_machine); +#ifdef CONFIG_XEN +qemu_register_machine (&xenpv_machine); +#endif }static void cpu_put_seg (QEMUFile *f,SegmentCache *dt)
vl.c +17 -2
@@ -29,6 +29,7 @@#include "hw/audiodev.h" #include "hw/isa.h" #include "hw/baum.h" +#include "hw/xen.h" #include "net.h" #include "console.h" #include "sysemu.h"
@@ -7747,6 +7748,9 @@ static void help(int exitcode) "-startdate select initial date of the clock\n" "-icount [N|auto]\n" " Enable virtual instruction counter with 2^N clock ticks per instruction\n" +#ifdef CONFIG_XEN + "-domid specify xen guest domain id\n" +#endif"\n" "During emulation, the following keys are useful:\n" "ctrl-alt-f toggle full screen\n"
@@ -7852,6 +7856,9 @@ enum { QEMU_OPTION_startdate, QEMU_OPTION_tb_size, QEMU_OPTION_icount, +#ifdef CONFIG_XEN + QEMU_OPTION_domid, +#endif }; typedef struct QEMUOption {
@@ -7940,6 +7947,9 @@ const QEMUOption qemu_options[] = { #ifdef CONFIG_CURSES { "curses", 0, QEMU_OPTION_curses }, #endif +#ifdef CONFIG_XEN + { "domid", HAS_ARG, QEMU_OPTION_domid }, +#endif /* temporary options */ { "usb", 0, QEMU_OPTION_usb },
@@ -8787,6 +8797,11 @@ int main(int argc, char **argv) icount_time_shift =strtol (optarg,NULL ,0 ); }break ; +#ifdef CONFIG_XEN +case QEMU_OPTION_domid: + xen_domid =atoi (optarg); +break ; +#endif } } }
@@ -8861,9 +8876,9 @@ int main(int argc, char **argv) linux_boot = (kernel_filename !=NULL ); net_boot = (boot_devices_bitmap >> ('n' -'a' )) &0xF ; -/* XXX: this should not be: some embedded targets just have flash */ +/* need a disk for this machine to boot ? */ if (!linux_boot && net_boot ==0 && - nb_drives_opt ==0 ) + !machine->nodisk_ok && nb_drives_opt ==0 )help (1 );if (!linux_boot && *kernel_cmdline !='\0' ) {
Signature · 1 line
1.5.5.1
PATCH 6/11 xen: backend driver core
In reply to Gerd HoffmannThis patch adds infrastructure for xen backend drivers living in qemu, so drivers don't need to implement common stuff on their own. It's mostly xenbus management stuff: some functions to access xentore, setting up xenstore watches, callbacks on device discovery and state changes, handle event channel, ...
--- Makefile.target | 2 +- hw/xen_backend.c | 672 +++++++++++++++++++++++++++++++++++++++++++++++++++ hw/xen_backend.h | 86 +++++++ hw/xen_common.h | 34 +++ hw/xen_machine_pv.c | 7 +- 5 files changed, 799 insertions(+), 2 deletions(-) create mode 100644 hw/xen_backend.c create mode 100644 hw/xen_backend.h create mode 100644 hw/xen_common.h
Makefile.target +1 -1
@@ -516,7 +516,7 @@ LIBS += $(CONFIG_VNC_TLS_LIBS) endif # xen backend driver support -XEN_OBJS := xen_machine_pv.o +XEN_OBJS := xen_machine_pv.o xen_backend.o ifeq ($(CONFIG_XEN), yes) OBJS += $(XEN_OBJS) LIBS += $(XEN_LIBS)
hw/xen_backend.c new file +672 -0
672 lines not on this page · raw message
hw/xen_backend.h new file +86 -0
86 lines not on this page · raw message
hw/xen_common.h new file +34 -0
@@ -0,0 +1,34 @@ +#ifndef QEMU_XEN_COMMON_H +#define QEMU_XEN_COMMON_H 1 + +#include <stddef.h> +#include <inttypes.h> + +#include <xenctrl.h> +#include <xs.h> +#include <xen/io/xenbus.h> + +#include "hw.h" +#include "xen.h" +#include "sys-queue.h" /* BSD list implementation */ + +/* +* tweaks needed to build with different xen versions +* 0x00030205 -> 3.1.0 +* 0x00030207 -> 3.2.0 +* 0x00030208 -> unstable +*/ +#include <xen/xen-compat.h> +#if __XEN_LATEST_INTERFACE_VERSION__ <0x00030205 +# define evtchn_port_or_error_t int +#endif +#if __XEN_LATEST_INTERFACE_VERSION__ <0x00030207 +# define xc_map_foreign_pages xc_map_foreign_batch +#endif +#if __XEN_LATEST_INTERFACE_VERSION__ <0x00030208 +# define xen_mb () mb() +# define xen_rmb () rmb() +# define xen_wmb () wmb() +#endif + +#endif /* QEMU_XEN_COMMON_H */
hw/xen_machine_pv.c +6 -1
@@ -25,7 +25,7 @@#include "hw.h" #include "boards.h" -#include <xenctrl.h> +#include "xen_backend.h" /* -------------------------------------------------------------------- */ /* variables */
@@ -81,6 +81,11 @@ static int xen_init(void) xen_emulate =1 ; } +if (-1 ==xen_be_init ()) { +fprintf (stderr,"%s: xen backend core setup failed\n" , __FUNCTION__); +return -1 ; + } +return 0 ; }
Signature · 1 line
1.5.5.1
PATCH 7/11 xen: add console backend driver.
In reply to Gerd HoffmannThis patch adds a xenconsole backend driver. It it based on current xen-unstable code. It has been changed to make use of the common backend driver code.
--- Makefile.target | 1 + hw/xen_backend.h | 3 + hw/xen_console.c | 271 +++++++++++++++++++++++++++++++++++++++++++++++++++ hw/xen_machine_pv.c | 3 + 4 files changed, 278 insertions(+), 0 deletions(-) create mode 100644 hw/xen_console.c
Makefile.target +1 -0
@@ -517,6 +517,7 @@ endif # xen backend driver support XEN_OBJS := xen_machine_pv.o xen_backend.o +XEN_OBJS += xen_console.o ifeq ($(CONFIG_XEN), yes) OBJS += $(XEN_OBJS) LIBS += $(XEN_LIBS)
hw/xen_backend.h +3 -0
@@ -83,4 +83,7 @@ int xen_be_send_notify(struct XenDevice *xendev);void xen_be_printf (struct XenDevice *xendev,int msg_level,const char *fmt, ...) __attribute__ ((format (printf,3 ,4 ))); +/* actual backend drivers */ +struct XenDevOps xen_console_ops;/* xen_console.c */ +#endif /* QEMU_XEN_BACKEND_H */
hw/xen_console.c new file +271 -0
271 lines not on this page · raw message
hw/xen_machine_pv.c +3 -0
@@ -97,6 +97,9 @@ static int xen_init_pv(DisplayState *ds)if (rc <0 )return rc; +/* xenbus backend drivers */ +xen_be_register ("console" , &xen_console_ops); +return 0 ; }
Signature · 1 line
1.5.5.1
PATCH 8/11 xen: add framebuffer backend driver
In reply to Gerd HoffmannThis patch adds a frsamebuffer (and kbd+mouse) backend driver. It it based on current xen-unstable code. It has been changed to make use of the common backend driver code. It also has been changed to compile with xen headers older than unstable (aka son-to-be 4.0).
--- Makefile.target | 2 +- hw/xen_backend.h | 4 + hw/xen_framebuffer.c | 952 ++++++++++++++++++++++++++++++++++++++++++++++++++ hw/xen_machine_pv.c | 5 + 4 files changed, 962 insertions(+), 1 deletions(-) create mode 100644 hw/xen_framebuffer.c
Makefile.target +1 -1
@@ -517,7 +517,7 @@ endif # xen backend driver support XEN_OBJS := xen_machine_pv.o xen_backend.o -XEN_OBJS += xen_console.o +XEN_OBJS += xen_console.o xen_framebuffer.o ifeq ($(CONFIG_XEN), yes) OBJS += $(XEN_OBJS) LIBS += $(XEN_LIBS)
hw/xen_backend.h +4 -0
@@ -85,5 +85,9 @@ void xen_be_printf(struct XenDevice *xendev, int msg_level, const char *fmt, .../* actual backend drivers */ struct XenDevOps xen_console_ops;/* xen_console.c */ +struct XenDevOps xen_kbdmouse_ops;/* xen_framebuffer.c */ +struct XenDevOps xen_framebuffer_ops;/* xen_framebuffer.c */ + +void xen_set_display (int domid,DisplayState *ds);#endif /* QEMU_XEN_BACKEND_H */
hw/xen_framebuffer.c new file +952 -0
952 lines not on this page · raw message
hw/xen_machine_pv.c +5 -0
@@ -99,6 +99,11 @@ static int xen_init_pv(DisplayState *ds)/* xenbus backend drivers */ xen_be_register ("console" , &xen_console_ops); +xen_be_register ("vkbd" , &xen_kbdmouse_ops); +xen_be_register ("vfb" , &xen_framebuffer_ops); + +/* setup framebuffer */ +xen_set_display (xen_domid, ds);return 0 ; }
Signature · 1 line
1.5.5.1
PATCH 9/11 xen: add block device backend driver.
In reply to Gerd HoffmannThis patch adds a block device backend driver to qemu. It is a pure userspace implemention using the gntdev interface. It uses "qdisk" as backend name in xenstore so it doesn't interfere with the other existing backends (blkback aka "vbd" and tapdisk aka "tap").
--- Makefile.target | 2 +- hw/xen_backend.h | 2 + hw/xen_blkif.h | 103 ++++++++ hw/xen_disk.c | 684 +++++++++++++++++++++++++++++++++++++++++++++++++++ hw/xen_machine_pv.c | 1 + sysemu.h | 2 +- vl.c | 4 + 7 files changed, 796 insertions(+), 2 deletions(-) create mode 100644 hw/xen_blkif.h create mode 100644 hw/xen_disk.c
Makefile.target +1 -1
@@ -517,7 +517,7 @@ endif # xen backend driver support XEN_OBJS := xen_machine_pv.o xen_backend.o -XEN_OBJS += xen_console.o xen_framebuffer.o +XEN_OBJS += xen_console.o xen_framebuffer.o xen_disk.o ifeq ($(CONFIG_XEN), yes) OBJS += $(XEN_OBJS) LIBS += $(XEN_LIBS)
hw/xen_backend.h +2 -0
@@ -2,6 +2,7 @@#define QEMU_XEN_BACKEND_H 1#include "xen_common.h" +#include "sysemu.h" /* ------------------------------------------------------------- */
@@ -87,6 +88,7 @@ void xen_be_printf(struct XenDevice *xendev, int msg_level, const char *fmt, ...struct XenDevOps xen_console_ops;/* xen_console.c */ struct XenDevOps xen_kbdmouse_ops;/* xen_framebuffer.c */ struct XenDevOps xen_framebuffer_ops;/* xen_framebuffer.c */ +struct XenDevOps xen_blkdev_ops;/* xen_disk.c */ void xen_set_display (int domid,DisplayState *ds);
hw/xen_blkif.h new file +103 -0
103 lines not on this page · raw message
hw/xen_disk.c new file +684 -0
684 lines not on this page · raw message
hw/xen_machine_pv.c +1 -0
@@ -101,6 +101,7 @@ static int xen_init_pv(DisplayState *ds)xen_be_register ("console" , &xen_console_ops);xen_be_register ("vkbd" , &xen_kbdmouse_ops);xen_be_register ("vfb" , &xen_framebuffer_ops); +xen_be_register ("qdisk" , &xen_blkdev_ops);/* setup framebuffer */ xen_set_display (xen_domid, ds);
sysemu.h +1 -1
@@ -113,7 +113,7 @@ extern unsigned int nb_prom_envs;#endif typedef enum { -IF_IDE ,IF_SCSI ,IF_FLOPPY ,IF_PFLASH ,IF_MTD ,IF_SD +IF_IDE ,IF_SCSI ,IF_FLOPPY ,IF_PFLASH ,IF_MTD ,IF_SD ,IF_XEN }BlockInterfaceType ; typedef struct DriveInfo {
vl.c +4 -0
@@ -5483,6 +5483,9 @@ static int drive_init(struct drive_opt *arg, int snapshot, }else if (!strcmp (buf,"sd" )) { type =IF_SD ; max_devs =0 ; + }else if (!strcmp (buf,"xen" )) { + type =IF_XEN ; + max_devs =0 ; }else {fprintf (stderr,"qemu: '%s' unsupported bus type '%s'\n" , str, buf);return -1 ;
@@ -5668,6 +5671,7 @@ static int drive_init(struct drive_opt *arg, int snapshot,switch (type) {case IF_IDE :case IF_SCSI : +case IF_XEN :switch (media) {case MEDIA_DISK :if (cyls !=0 ) {
Signature · 1 line
1.5.5.1
PATCH 10/11 xen: add net backend driver.
In reply to Gerd HoffmannThis patch adds a network interface backend driver to qemu. It is a pure userspace implemention using the gntdev interface. It uses "qnet" as backend name in xenstore so it doesn't interfere with the netback backend (aka "vnif").
The network backend is hooked into the corrosponding qemu vlan, i.e. vif 0 is hooked into vlan 0. To make the packages actually arrive somewhere you additionally have to link the vlan to the outside world using the usual qemu command line options such as "-net tap,...".
--- Makefile.target | 2 +- hw/xen_backend.h | 1 + hw/xen_machine_pv.c | 1 + hw/xen_nic.c | 380 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 383 insertions(+), 1 deletions(-) create mode 100644 hw/xen_nic.c
Makefile.target +1 -1
@@ -517,7 +517,7 @@ endif # xen backend driver support XEN_OBJS := xen_machine_pv.o xen_backend.o -XEN_OBJS += xen_console.o xen_framebuffer.o xen_disk.o +XEN_OBJS += xen_console.o xen_framebuffer.o xen_disk.o xen_nic.o ifeq ($(CONFIG_XEN), yes) OBJS += $(XEN_OBJS) LIBS += $(XEN_LIBS)
hw/xen_backend.h +1 -0
@@ -89,6 +89,7 @@ struct XenDevOps xen_console_ops; /* xen_console.c */struct XenDevOps xen_kbdmouse_ops;/* xen_framebuffer.c */ struct XenDevOps xen_framebuffer_ops;/* xen_framebuffer.c */ struct XenDevOps xen_blkdev_ops;/* xen_disk.c */ +struct XenDevOps xen_netdev_ops;/* xen_nic.c */ void xen_set_display (int domid,DisplayState *ds);
hw/xen_machine_pv.c +1 -0
@@ -102,6 +102,7 @@ static int xen_init_pv(DisplayState *ds)xen_be_register ("vkbd" , &xen_kbdmouse_ops);xen_be_register ("vfb" , &xen_framebuffer_ops);xen_be_register ("qdisk" , &xen_blkdev_ops); +xen_be_register ("qnic" , &xen_netdev_ops);/* setup framebuffer */ xen_set_display (xen_domid, ds);
hw/xen_nic.c new file +380 -0
380 lines not on this page · raw message
Signature · 1 line
1.5.5.1
PATCH 11/11 xen: blk & nic configuration via cmd line.
In reply to Gerd HoffmannThis patch makes qemu create backend and frontend device entries in xenstore for devices configured on the command line. It will use qdisk and qnic backend names, so the qemu internal backends will be used.
Disks can be created using -drive if=xen,file=...
Nics can be created using -net nic,macaddr=...
--- Makefile.target | 2 +- hw/xen_backend.h | 7 +++ hw/xen_devconfig.c | 144 +++++++++++++++++++++++++++++++++++++++++++++++++++ hw/xen_machine_pv.c | 19 ++++++- 4 files changed, 170 insertions(+), 2 deletions(-) create mode 100644 hw/xen_devconfig.c
Makefile.target +1 -1
@@ -516,7 +516,7 @@ LIBS += $(CONFIG_VNC_TLS_LIBS) endif # xen backend driver support -XEN_OBJS := xen_machine_pv.o xen_backend.o +XEN_OBJS := xen_machine_pv.o xen_backend.o xen_devconfig.o XEN_OBJS += xen_console.o xen_framebuffer.o xen_disk.o xen_nic.o ifeq ($(CONFIG_XEN), yes) OBJS += $(XEN_OBJS)
hw/xen_backend.h +7 -0
@@ -3,6 +3,8 @@#include "xen_common.h" #include "sysemu.h" +#include "net.h" +#include "block_int.h" /* ------------------------------------------------------------- */
@@ -93,4 +95,9 @@ struct XenDevOps xen_netdev_ops; /* xen_nic.c */void xen_set_display (int domid,DisplayState *ds); +/* configuration (aka xenbus setup) */ +void xen_config_cleanup (void ); +int xen_config_dev_blk (DriveInfo *disk); +int xen_config_dev_nic (NICInfo *nic); +#endif /* QEMU_XEN_BACKEND_H */
hw/xen_devconfig.c new file +144 -0
144 lines not on this page · raw message
hw/xen_machine_pv.c +18 -1
@@ -121,7 +121,7 @@ static void xenpv_init(ram_addr_t ram_size, int vga_ram_size, const char *cpu_model) {CPUState *env; -int rc; +int index,i,rc; rc =xen_init_pv (ds);if (-1 == rc)
@@ -147,6 +147,23 @@ static void xenpv_init(ram_addr_t ram_size, int vga_ram_size, env =cpu_init (cpu_model); env->halted =1 ; +/* configure disks */ +for (i =0 ; i <16 ; i++) { + index =drive_get_index (IF_XEN ,0 , i); +if (index ==-1 ) +continue ; +xen_config_dev_blk (drives_table + index); + } + +/* configure nics */ +for (i =0 ; i < nb_nics; i++) { +if (nd_table[i].model &&0 !=strcmp (nd_table[i].model,"xen" )) +continue ; +xen_config_dev_nic (nd_table + i); + } + +/* config cleanup hook */ +atexit (xen_config_cleanup);return ; err:
Signature · 1 line
1.5.5.1