PATCH 0/10: Merge PV framebuffer & console into QEMU
The following series of 10 patches is a merge of the xenfb and xenconsoled functionality into the qemu-dm code. The general approach taken is to have qemu-dm provide two machine types - one for xen paravirt, the other for fullyvirt. For compatability the later is the default. The goals overall are to kill LibVNCServer, remove alot of code duplication and/or parallel impls of the same concepts, and increase the functionality for PV. In particular this will let paravirt guests take advantage of TLS encryption for the VNC server, and let us configure the text console in all the variety of ways QEMU supports (PTY, File, TCP, TCP_Telnet,UDP, etc).
One interesting possiblity that merging the text & graphics consoles into same daemon allows for, is to expose the pygrub screens over both a PTY and VNC server at the same time. If I can figure out how to actually code this idea it would solve a major headache when using bootloaders with PV guests remotely.
The patches should be applied in order - to assist bisecting, after each individual patch you should still have a fully operational system for both FV & PV. I have tested save/restore, save+checkpoint, and migration for fullyvirt, paravirt with SUSPEND_CANCEL, and paravirt without SUSPEND_CANCEL.
I've included diffstats inline with each patch, but since there's a fair bit of general re-factoring / moving code in intermediate patches here is a summary of the stats for the series as a whole. I recommend applying each patch individually though to preserve the history of changes.
Config.mk | 1 a/tools/check/check_libvncserver | 38 - a/tools/check/check_sdl | 27 a/tools/xenfb/Makefile | 32 a/tools/xenfb/sdlfb.c | 342 --------- a/tools/xenfb/vncfb.c | 522 --------------- a/tools/xenfb/xenfb.c | 779 ---------------------- a/tools/xenfb/xenfb.h | 35 - b/tools/ioemu/hw/xen_console.c | 432 ++++++++++++ b/tools/ioemu/hw/xen_console.h | 25 b/tools/ioemu/hw/xen_machine_fv.c | 288 ++++++++ b/tools/ioemu/hw/xen_machine_pv.c | 73 ++ b/tools/ioemu/hw/xenfb.c | 1108 ++++++++++++++++++++++++++++++++ b/tools/ioemu/hw/xenfb.h | 13 tools/Makefile | 1 tools/check/Makefile | 4 tools/console/daemon/io.c | 9 tools/ioemu/Makefile.target | 4 tools/ioemu/target-i386-dm/helper2.c | 5 tools/ioemu/vl.c | 249 ------- tools/ioemu/vl.h | 4 tools/ioemu/xenstore.c | 2 tools/python/xen/xend/XendCheckpoint.py | 5 tools/python/xen/xend/XendConfig.py | 35 - tools/python/xen/xend/XendDomainInfo.py | 37 - tools/python/xen/xend/image.py | 382 +++++------ tools/python/xen/xend/server/vfbif.py | 108 --- 27 files changed, 2231 insertions(+), 2329 deletions(-)
The entire series is synced against xen-unstable.hg 16157:b28ae5f00553
Dan.
Signature · 4 lines
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
Re: PATCH 1/10: Add a QEMU machine type for fullvirt guests
This patch does a (no functional change) re-arrangement of the code for starting up a fully virtualized guest. In particular it creates a new QEMU machine type for Xen fullyvirt guests which can be specified with '-M xenfv'. For compatability this is in fact made to be the default. The code for setting up memory maps is moved out of vl.c, and into hw/xen_machine_fv.c. This is basically to ensure that it can be easily skipped when we add a paravirt machine type in the next patch.
b/tools/ioemu/hw/xen_machine_fv.c | 288 ++++++++++++++++++++++++++++++++++++++ tools/ioemu/Makefile.target | 1 tools/ioemu/vl.c | 244 -------------------------------- tools/ioemu/vl.h | 3 4 files changed, 297 insertions(+), 239 deletions(-)
tools/ioemu/Makefile.target +1 -0
@@ -409,6 +409,7 @@ VL_OBJS+= piix4acpi.o VL_OBJS+= piix4acpi.o VL_OBJS+= xenstore.o VL_OBJS+= xen_platform.o +VL_OBJS+= xen_machine_fv.o VL_OBJS+= tpm_tis.o CPPFLAGS += -DHAS_AUDIO endif
tools/ioemu/hw/xen_machine_fv.c new file +288 -0
288 lines not on this page · raw message
tools/ioemu/vl.c +5 -239
289 lines not on this page · raw message
tools/ioemu/vl.h +3 -0
@@ -1108,6 +1108,9 @@ extern void pci_piix4_acpi_init(PCIBus */* pc.c */ extern QEMUMachine pc_machine;extern QEMUMachine isapc_machine; +#ifdef CONFIG_DM +extern QEMUMachine xenfv_machine; +#endif extern int fd_bootchk;void ioport_set_a20 (int enable);
Signature · 4 lines
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
Re: PATCH 2/10: Add a QEMU machine type for paravirt guests
In reply to Daniel P. BerrangeThis patch adds a paravirt machine type to QEMU. This can be requested by passing the arg '-M xenpv' to qemu-dm. Aside from -d, and -domain-name, the only other args that are processed are the VNC / SDL graphics related args. Any others will be ignored. A tweak to helper2.c was made to stop it setting up a file handler watch when there are no CPUs registered.
The paravirt machine is in hw/xen_machine_pv.c and registers an instance of the xenfb class, integrating it with the QEMU event loop and key/mouse handlers. A couple of methods were adding to xenfb.h to allow direct access to the file handles for xenstore & the event channel.
The vfbif.py device controller is modified to launch qemu-dm instead of the old xen-vncfb / sdlfb daemons.
When receiving framebuffer updates from the guest, the update has to be copied into QEMU's copy of the framebuffer. This is because QEMU stores the framebuffer in the format that is native to the SDL display, or VNC client. This is not neccessarily the same as the guest framebuffer which is always 32bpp. If there is an exact depth match we use memcpy for speed, but in the non-matching case we have to fallback to slow code to covert pixel formats. It fully supports all features of the paravirt framebuffer including the choice between absolute & relative pointers. The overall VIRT memory image size is about same as old xen-vncfb, but the resident memory size is a little increased due to copy of the framebuffer & some QEMU static state overhead. Most of this is shared across QEMU processes.
To avoid both moving the xenfb.c and making changes to it in the same patch, this just uses a Makefile hack to link against the xenfb.o from the tools/xenfb/ directory. This will be removed in the following patch.
b/tools/ioemu/hw/xen_machine_pv.c | 315 ++++++++++++++++++++++++++++++++++ tools/ioemu/Makefile.target | 2 tools/ioemu/target-i386-dm/helper2.c | 5 tools/ioemu/vl.c | 5 tools/ioemu/vl.h | 1 tools/python/xen/xend/server/vfbif.py | 26 +- tools/xenfb/xenfb.c | 80 ++++++-- tools/xenfb/xenfb.h | 4 8 files changed, 401 insertions(+), 37 deletions(-)
tools/ioemu/Makefile.target +2 -0
@@ -400,6 +400,8 @@ VL_OBJS+= xenstore.o VL_OBJS+= xenstore.o VL_OBJS+= xen_platform.o VL_OBJS+= xen_machine_fv.o +VL_OBJS+= xen_machine_pv.o +VL_OBJS+= ../../xenfb/xenfb.o VL_OBJS+= tpm_tis.o CPPFLAGS += -DHAS_AUDIO endif
tools/ioemu/hw/xen_machine_pv.c new file +315 -0
315 lines not on this page · raw message
tools/ioemu/target-i386-dm/helper2.c +3 -2
@@ -616,7 +616,7 @@ int main_loop(void)extern int shutdown_requested;extern int suspend_requested;CPUState *env = cpu_single_env; -int evtchn_fd =xc_evtchn_fd (xce_handle); +int evtchn_fd = xce_handle ==-1 ?-1 :xc_evtchn_fd (xce_handle);char qemu_file[PATH_MAX ];fd_set fds;
@@ -624,7 +624,8 @@ int main_loop(void) cpu_single_env);qemu_mod_timer (buffered_io_timer,qemu_get_clock (rt_clock)); -qemu_set_fd_handler (evtchn_fd, cpu_handle_ioreq,NULL , env); +if (evtchn_fd !=-1 ) +qemu_set_fd_handler (evtchn_fd, cpu_handle_ioreq,NULL , env);xenstore_record_dm_state ("running" );while (1 ) {
tools/ioemu/vl.c +3 -2
@@ -182,7 +182,7 @@ extern int vcpus;int xc_handle; -char domain_name[64 ] ="Xen-HVM-no-name" ; +char domain_name[64 ] ="Xen-no-name" ;extern int domid;char vncpasswd[64 ];
@@ -6651,6 +6651,7 @@ void register_machines(void)qemu_register_machine (&isapc_machine);#else qemu_register_machine (&xenfv_machine); +qemu_register_machine (&xenpv_machine);#endif #elif defined(TARGET_PPC)qemu_register_machine (&heathrow_machine);
@@ -7370,7 +7371,7 @@ int main(int argc, char **argv)break ;case QEMU_OPTION_domainname:snprintf (domain_name,sizeof (domain_name), -"Xen-HVM-%s" , optarg); +"Xen-%s" , optarg);break ;case QEMU_OPTION_d: domid =atoi (optarg);
tools/ioemu/vl.h +1 -0
@@ -1110,6 +1110,7 @@ extern QEMUMachine isapc_machine;extern QEMUMachine isapc_machine;#ifdef CONFIG_DM extern QEMUMachine xenfv_machine; +extern QEMUMachine xenpv_machine;#endif extern int fd_bootchk;
tools/python/xen/xend/server/vfbif.py +13 -13
@@ -50,8 +50,10 @@ class VfbifController(DevController): # is HVM, so qemu-dm will handle the vfb. return - std_args = [ "--domid", "%d" % self.vm.getDomid(), - "--title", self.vm.getName() ] + args = [ xen.util.auxbin.pathTo("qemu-dm"), + "-M", "xenpv", + "-d", "%d" % self.vm.getDomid(), + "-domain-name", self.vm.getName() ] t = config.get("type", None) if t == "vnc": passwd = None
@@ -65,15 +67,14 @@ class VfbifController(DevController): else: log.debug("No VNC passwd configured for vfb access") - # Try to start the vnc backend - args = [xen.util.auxbin.pathTo("xen-vncfb")] - if config.has_key("vncunused"): - args += ["--unused"] - elif config.has_key("vncdisplay"): - args += ["--vncport", "%d" % (5900 + int(config["vncdisplay"]))] - vnclisten = config.get("vnclisten", + vnclisten = config.get('vnclisten', xen.xend.XendOptions.instance().get_vnclisten_address()) - args += [ "--listen", vnclisten ] + vncdisplay = config.get('vncdisplay', 0) + args += ['-vnc', "%s:%d" % (vnclisten, vncdisplay)] + + if config.get('vncunused', 0): + args += ['-vncunused'] + if config.has_key("keymap"): args += ["-k", "%s" % config["keymap"]] else:
@@ -81,15 +82,14 @@ class VfbifController(DevController): if xoptions.get_keymap(): args += ["-k", "%s" % xoptions.get_keymap()] - spawn_detached(args[0], args + std_args, os.environ) + spawn_detached(args[0], args, os.environ) elif t == "sdl": - args = [xen.util.auxbin.pathTo("xen-sdlfb")] env = dict(os.environ) if config.has_key("display"): env['DISPLAY'] = config["display"] if config.has_key("xauthority"): env['XAUTHORITY'] = config["xauthority"] - spawn_detached(args[0], args + std_args, env) + spawn_detached(args[0], args, env) else: raise VmError('Unknown vfb type %s (%s)' % (t, repr(config)))
tools/xenfb/xenfb.c +60 -20
106 lines not on this page · raw message
tools/xenfb/xenfb.h +4 -0
@@ -25,8 +25,12 @@ void xenfb_teardown(struct xenfb *xenfb)int xenfb_attach_dom (struct xenfb *xenfb,int domid); +int xenfb_dispatch_store (struct xenfb *xenfb_pub); +int xenfb_dispatch_channel (struct xenfb *xenfb_pub);int xenfb_select_fds (struct xenfb *xenfb,fd_set *readfds);int xenfb_poll (struct xenfb *xenfb,fd_set *readfds); +int xenfb_get_store_fd (struct xenfb *xenfb_pub); +int xenfb_get_channel_fd (struct xenfb *xenfb_pub);int xenfb_send_key (struct xenfb *xenfb,bool down,int keycode);int xenfb_send_motion (struct xenfb *xenfb,int rel_x,int rel_y);
Signature · 4 lines
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
Re: PATCH 3/10: Remove standalone xenfb code
In reply to Daniel P. BerrangeThis patch removes all trace of the standalone paravirt framebuffer daemon. With this there is no longer any requirement for LibVNCServer. Everything is handled by the QEMU device model. The xenfb.c and xenfb.h files are now moved (without code change) into tools/ioemu/hw/ & the temporary Makefile hack from the previous patch is removed.
Config.mk | 1 a/tools/check/check_libvncserver | 38 - a/tools/check/check_sdl | 27 - a/tools/xenfb/Makefile | 32 - a/tools/xenfb/sdlfb.c | 342 ---------------- a/tools/xenfb/vncfb.c | 522 ------------------------ a/tools/xenfb/xenfb.c | 819 --------------------------------------- a/tools/xenfb/xenfb.h | 39 - b/tools/ioemu/hw/xenfb.c | 819 +++++++++++++++++++++++++++++++++++++++ b/tools/ioemu/hw/xenfb.h | 39 + tools/Makefile | 1 tools/check/Makefile | 4 tools/ioemu/Makefile.target | 2 tools/ioemu/hw/xen_machine_pv.c | 2 14 files changed, 862 insertions(+), 1825 deletions(-)
Config.mk +0 -1
@@ -88,7 +88,6 @@ XENSTAT_XENTOP ?= y XENSTAT_XENTOP ?= y VTPM_TOOLS ?= n LIBXENAPI_BINDINGS ?= n -XENFB_TOOLS ?= n PYTHON_TOOLS ?= y -include $(XEN_ROOT)/.config
tools/Makefile +0 -1
@@ -20,7 +20,6 @@ SUBDIRS-y += libaio SUBDIRS-y += libaio SUBDIRS-y += blktap SUBDIRS-y += libfsimage -SUBDIRS-$(XENFB_TOOLS) += xenfb SUBDIRS-$(LIBXENAPI_BINDINGS) += libxen # These don't cross-compile
tools/check/Makefile +2 -2
@@ -7,7 +7,7 @@ all: build # Check this machine is OK for building on. .PHONY: build build: - XENFB_TOOLS=$(XENFB_TOOLS) LIBXENAPI_BINDINGS=$(LIBXENAPI_BINDINGS) ACM_SECURITY=$(ACM_SECURITY) ./chk build + LIBXENAPI_BINDINGS=$(LIBXENAPI_BINDINGS) ACM_SECURITY=$(ACM_SECURITY) ./chk build # Check this machine is OK for installing on. # DO NOT use this check from 'make install' in the parent
@@ -15,7 +15,7 @@ build: # copy rather than actually installing. .PHONY: install install: - XENFB_TOOLS=$(XENFB_TOOLS) LIBXENAPI_BINDINGS=$(LIBXENAPI_BINDINGS) ACM_SECURITY=$(ACM_SECURITY) ./chk install + LIBXENAPI_BINDINGS=$(LIBXENAPI_BINDINGS) ACM_SECURITY=$(ACM_SECURITY) ./chk install .PHONY: clean clean:
tools/check/check_libvncserver deleted +0 -38
@@ -1,38 +0,0 @@ -#!/bin/sh -# CHECK-BUILD CHECK-INSTALL - -if [ ! "$XENFB_TOOLS" = "y" ] -then - echo -n "unused, " - exit 0 -fi - -RC=0 - -LIBVNCSERVER_CONFIG="$(which libvncserver-config)" -tmpfile=$(mktemp) - -if test -z ${LIBVNCSERVER_CONFIG}; then - RC=1 -else - ${LIBVNCSERVER_CONFIG} --libs 2>&1 > /dev/null - RC=$? -fi - -if test $RC -ne 0; then - echo "FAILED" - echo " *** libvncserver-config is missing. " - echo " *** Please install libvncserver." -elif ! ld $($LIBVNCSERVER_CONFIG --libs) -o $tmpfile >/dev/null 2>&1; then - echo "FAILED" - echo " *** dependency libraries for libvncserver are missing: " - RC=1 - for i in $(ld $($LIBVNCSERVER_CONFIG --libs) -o $tmpfile 2>&1 >/dev/null); do - case $i in - -l*) echo lib${i#-l} - esac - done -fi -rm -f $tmpfile - -exit $RC
tools/check/check_sdl deleted +0 -27
@@ -1,27 +0,0 @@ -#!/bin/sh -# CHECK-BUILD CHECK-INSTALL - -if [ ! "$XENFB_TOOLS" = "y" ] -then - echo -n "unused, " - exit 0 -fi - -RC=0 - -SDL_CONFIG="$(which sdl-config)" - -if test -z ${SDL_CONFIG}; then - RC=1 -else - ${SDL_CONFIG} --libs 2>&1 > /dev/null - RC=$? -fi - -if test $RC -ne 0; then - echo "FAILED" - echo " *** sdl-config is missing. " - echo " *** Please install libsdl-dev or sdl." -fi - -exit $RC
tools/ioemu/Makefile.target +1 -1
@@ -401,7 +401,7 @@ VL_OBJS+= xen_platform.o VL_OBJS+= xen_platform.o VL_OBJS+= xen_machine_fv.o VL_OBJS+= xen_machine_pv.o -VL_OBJS+= ../../xenfb/xenfb.o +VL_OBJS+= xenfb.o VL_OBJS+= tpm_tis.o CPPFLAGS += -DHAS_AUDIO endif
tools/ioemu/hw/xen_machine_pv.c +1 -1
@@ -23,7 +23,7 @@*/ #include "vl.h" -#include "../../xenfb/xenfb.h" +#include "xenfb.h" #include <linux/input.h> /*
tools/ioemu/hw/xenfb.c new file +819 -0
819 lines not on this page · raw message
tools/ioemu/hw/xenfb.h new file +39 -0
@@ -0,0 +1,39 @@ +#ifndef _XENFB_H_ +#define _XENFB_H_ + +#include <stdbool.h> +#include <sys/types.h> + +struct xenfb +{ +void *pixels; + +int row_stride; +int depth; +int width; +int height; +int abs_pointer_wanted; + +void *user_data; + +void (*update)(struct xenfb *xenfb,int x,int y,int width,int height); +}; + +struct xenfb *xenfb_new (void ); +void xenfb_delete (struct xenfb *xenfb); +void xenfb_teardown (struct xenfb *xenfb); + +int xenfb_attach_dom (struct xenfb *xenfb,int domid); + +int xenfb_dispatch_store (struct xenfb *xenfb_pub); +int xenfb_dispatch_channel (struct xenfb *xenfb_pub); +int xenfb_select_fds (struct xenfb *xenfb,fd_set *readfds); +int xenfb_poll (struct xenfb *xenfb,fd_set *readfds); +int xenfb_get_store_fd (struct xenfb *xenfb_pub); +int xenfb_get_channel_fd (struct xenfb *xenfb_pub); + +int xenfb_send_key (struct xenfb *xenfb,bool down,int keycode); +int xenfb_send_motion (struct xenfb *xenfb,int rel_x,int rel_y); +int xenfb_send_position (struct xenfb *xenfb,int abs_x,int abs_y); + +#endif
tools/xenfb/Makefile deleted +0 -32
@@ -1,32 +0,0 @@ -XEN_ROOT=../.. -include $(XEN_ROOT)/tools/Rules.mk - -CFLAGS += -I$(XEN_LIBXC) -I$(XEN_XENSTORE) -CFLAGS += -I$(XEN_ROOT)/tools/ioemu -LDFLAGS += -L$(XEN_LIBXC) -L$(XEN_XENSTORE) - -.PHONY: all -all: build - -.PHONY: build -build: - $(MAKE) vncfb sdlfb - -install: all - $(INSTALL_DIR) $(DESTDIR)/usr/$(LIBDIR)/xen/bin - $(INSTALL_PROG) vncfb $(DESTDIR)/usr/$(LIBDIR)/xen/bin/xen-vncfb - $(INSTALL_PROG) sdlfb $(DESTDIR)/usr/$(LIBDIR)/xen/bin/xen-sdlfb - -sdlfb: sdlfb.o xenfb.o - -sdlfb.o: CFLAGS += $(shell sdl-config --cflags) -sdlfb: LDLIBS += $(shell sdl-config --libs) -lxenctrl -lxenstore - -clean: - $(RM) *.o *~ vncfb sdlfb - -vncfb: vncfb.o xenfb.o -vncfb.o: CFLAGS += $(shell libvncserver-config --cflags) -vncfb: LDLIBS += $(shell libvncserver-config --libs) -lxenctrl -lxenstore - -sdlfb.o xenfb.o vncfb.o: xenfb.h
tools/xenfb/sdlfb.c deleted +0 -342
342 lines not on this page · raw message
tools/xenfb/vncfb.c deleted +0 -522
522 lines not on this page · raw message
tools/xenfb/xenfb.c deleted +0 -819
819 lines not on this page · raw message
tools/xenfb/xenfb.h deleted +0 -39
@@ -1,39 +0,0 @@ -#ifndef _XENFB_H_ -#define _XENFB_H_ - -#include <stdbool.h> -#include <sys/types.h> - -struct xenfb -{ -void *pixels; - -int row_stride; -int depth; -int width; -int height; -int abs_pointer_wanted; - -void *user_data; - -void (*update)(struct xenfb *xenfb,int x,int y,int width,int height); -}; - -struct xenfb *xenfb_new (void ); -void xenfb_delete (struct xenfb *xenfb); -void xenfb_teardown (struct xenfb *xenfb); - -int xenfb_attach_dom (struct xenfb *xenfb,int domid); - -int xenfb_dispatch_store (struct xenfb *xenfb_pub); -int xenfb_dispatch_channel (struct xenfb *xenfb_pub); -int xenfb_select_fds (struct xenfb *xenfb,fd_set *readfds); -int xenfb_poll (struct xenfb *xenfb,fd_set *readfds); -int xenfb_get_store_fd (struct xenfb *xenfb_pub); -int xenfb_get_channel_fd (struct xenfb *xenfb_pub); - -int xenfb_send_key (struct xenfb *xenfb,bool down,int keycode); -int xenfb_send_motion (struct xenfb *xenfb,int rel_x,int rel_y); -int xenfb_send_position (struct xenfb *xenfb,int abs_x,int abs_y); - -#endif
Signature · 4 lines
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
Re: PATCH 4/10: Refactor xenfb event handlers
In reply to Daniel P. BerrangeThis patch is a simple code re-factoring to move the event loop integration directly into the xenfb.c file. It is to facilitate the patches which follow.
xen_machine_pv.c | 31 ------ xenfb.c | 249 +++++++++++++++++++++++-------------------------------- xenfb.h | 7 - 3 files changed, 107 insertions(+), 180 deletions(-)
tools/ioemu/hw/xen_machine_pv.c +1 -30
@@ -213,22 +213,6 @@ void xen_pvfb_invalidate(void *opaque)/* Screen dump is not used in Xen, so no need to impl this ? */ void xen_pvfb_screen_dump (void *opaque,const char *name) { } -void xen_pvfb_dispatch_store (void *opaque) { -int ret; -if ((ret =xenfb_dispatch_store (opaque)) <0 ) { -fprintf (stderr,"Failure while dispatching store: %d\n" , ret); -exit (1 ); - } -} - -void xen_pvfb_dispatch_channel (void *opaque) { -int ret; -if ((ret =xenfb_dispatch_channel (opaque)) <0 ) { -fprintf (stderr,"Failure while dispatching store: %d\n" , ret); -exit (1 ); - } -} -/* The Xen PV machine currently provides * - a virtual framebuffer * - ....
@@ -242,7 +226,7 @@ static void xen_init_pv(uint64_t ram_siz {struct xenfb *xenfb;extern int domid; -int fd, i; +int i;/* Prepare scancode mapping table */ for (i =0 ; i <128 ; i++) {
@@ -281,19 +265,6 @@ static void xen_init_pv(uint64_t ram_siz xenfb->abs_pointer_wanted, "Xen PVFB Mouse"); -/* Listen for events from xenstore */ - fd =xenfb_get_store_fd (xenfb); -if (qemu_set_fd_handler2 (fd,NULL , xen_pvfb_dispatch_store,NULL , xenfb) <0 ) { -fprintf (stderr,"Could not register event handler (%s)\n" , -strerror (errno)); - } - -/* Listen for events from the event channel */ - fd =xenfb_get_channel_fd (xenfb); -if (qemu_set_fd_handler2 (fd,NULL , xen_pvfb_dispatch_channel,NULL , xenfb) <0 ) { -fprintf (stderr,"Could not register event handler (%s)\n" , -strerror (errno)); - }/* Setup QEMU display */ dpy_resize (ds, xenfb->width, xenfb->height);
tools/ioemu/hw/xenfb.c +106 -143
292 lines not on this page · raw message
tools/ioemu/hw/xenfb.h +0 -7
@@ -25,13 +25,6 @@ void xenfb_teardown(struct xenfb *xenfb)int xenfb_attach_dom (struct xenfb *xenfb,int domid); -int xenfb_dispatch_store (struct xenfb *xenfb_pub); -int xenfb_dispatch_channel (struct xenfb *xenfb_pub); -int xenfb_select_fds (struct xenfb *xenfb,fd_set *readfds); -int xenfb_poll (struct xenfb *xenfb,fd_set *readfds); -int xenfb_get_store_fd (struct xenfb *xenfb_pub); -int xenfb_get_channel_fd (struct xenfb *xenfb_pub); -int xenfb_send_key (struct xenfb *xenfb,bool down,int keycode);int xenfb_send_motion (struct xenfb *xenfb,int rel_x,int rel_y);int xenfb_send_position (struct xenfb *xenfb,int abs_x,int abs_y);
Signature · 4 lines
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
Re: PATCH 5/10: Refactor QEMU console integration
In reply to Daniel P. BerrangeThis patch moves a bunch of code out of the xen_machine_pv.c file and into the xenfb.c file. This is simply a re-factoring to facilitate the two patches which follow.
xen_machine_pv.c | 214 --------------------------------- xenfb.c | 353 +++++++++++++++++++++++++++++++++++++++++++++---------- xenfb.h | 8 - 3 files changed, 294 insertions(+), 281 deletions(-)
tools/ioemu/hw/xen_machine_pv.c +1 -213
@@ -24,194 +24,6 @@#include "vl.h" #include "xenfb.h" -#include <linux/input.h> - -/* -* Tables to map from scancode to Linux input layer keycode. -* Scancodes are hardware-specific. These maps assumes a -* standard AT or PS/2 keyboard which is what QEMU feeds us. -*/ -static const unsigned char atkbd_set2_keycode[512 ] = { - -0 ,67 ,65 ,63 ,61 ,59 ,60 ,88 ,0 ,68 ,66 ,64 ,62 ,15 ,41 ,117 , -0 ,56 ,42 ,93 ,29 ,16 ,2 ,0 ,0 ,0 ,44 ,31 ,30 ,17 ,3 ,0 , -0 ,46 ,45 ,32 ,18 ,5 ,4 ,95 ,0 ,57 ,47 ,33 ,20 ,19 ,6 ,183 , -0 ,49 ,48 ,35 ,34 ,21 ,7 ,184 ,0 ,0 ,50 ,36 ,22 ,8 ,9 ,185 , -0 ,51 ,37 ,23 ,24 ,11 ,10 ,0 ,0 ,52 ,53 ,38 ,39 ,25 ,12 ,0 , -0 ,89 ,40 ,0 ,26 ,13 ,0 ,0 ,58 ,54 ,28 ,27 ,0 ,43 ,0 ,85 , -0 ,86 ,91 ,90 ,92 ,0 ,14 ,94 ,0 ,79 ,124 ,75 ,71 ,121 ,0 ,0 , -82 ,83 ,80 ,76 ,77 ,72 ,1 ,69 ,87 ,78 ,81 ,74 ,55 ,73 ,70 ,99 , - -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , -217 ,100 ,255 ,0 ,97 ,165 ,0 ,0 ,156 ,0 ,0 ,0 ,0 ,0 ,0 ,125 , -173 ,114 ,0 ,113 ,0 ,0 ,0 ,126 ,128 ,0 ,0 ,140 ,0 ,0 ,0 ,127 , -159 ,0 ,115 ,0 ,164 ,0 ,0 ,116 ,158 ,0 ,150 ,166 ,0 ,0 ,0 ,142 , -157 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,155 ,0 ,98 ,0 ,0 ,163 ,0 ,0 , -226 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,255 ,96 ,0 ,0 ,0 ,143 ,0 , -0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,107 ,0 ,105 ,102 ,0 ,0 ,112 , -110 ,111 ,108 ,112 ,106 ,103 ,0 ,119 ,0 ,118 ,109 ,0 ,99 ,104 ,119 ,0 , - -}; - -static const unsigned char atkbd_unxlate_table[128 ] = { - -0 ,118 ,22 ,30 ,38 ,37 ,46 ,54 ,61 ,62 ,70 ,69 ,78 ,85 ,102 ,13 , -21 ,29 ,36 ,45 ,44 ,53 ,60 ,67 ,68 ,77 ,84 ,91 ,90 ,20 ,28 ,27 , -35 ,43 ,52 ,51 ,59 ,66 ,75 ,76 ,82 ,14 ,18 ,93 ,26 ,34 ,33 ,42 , -50 ,49 ,58 ,65 ,73 ,74 ,89 ,124 ,17 ,41 ,88 ,5 ,6 ,4 ,12 ,3 , -11 ,2 ,10 ,1 ,9 ,119 ,126 ,108 ,117 ,125 ,123 ,107 ,115 ,116 ,121 ,105 , -114 ,122 ,112 ,113 ,127 ,96 ,97 ,120 ,7 ,15 ,23 ,31 ,39 ,47 ,55 ,63 , -71 ,79 ,86 ,94 ,8 ,16 ,24 ,32 ,40 ,48 ,56 ,64 ,72 ,80 ,87 ,111 , -19 ,25 ,57 ,81 ,83 ,92 ,95 ,98 ,99 ,100 ,101 ,103 ,104 ,106 ,109 ,110 - -}; - -static unsigned char scancode2linux[512 ]; - -/* A convenient function for munging pixels between different depths */ -#define BLT (SRC_T ,DST_T ,RLS ,GLS ,BLS ,RRS ,GRS ,BRS ,RM ,GM ,BM ) \ - for (line = y ; line < h ; line++) { \ - SRC_T *src = (SRC_T *)(xenfb->pixels \ - + (line * xenfb->row_stride) \ - + (x * xenfb->depth / 8)); \ - DST_T *dst = (DST_T *)(ds->data \ - + (line * ds->linesize) \ - + (x * ds->depth / 8)); \ - int col; \ - for (col = x ; col < w ; col++) { \ - *dst = (((*src >> RRS) & RM) << RLS) | \ - (((*src >> GRS) & GM) << GLS) | \ - (((*src >> GRS) & BM) << BLS); \ - src++; \ - dst++; \ - } \ - } - -/* This copies data from the guest framebuffer region, into QEMU's copy -* NB. QEMU's copy is stored in the pixel format of a) the local X -* server (SDL case) or b) the current VNC client pixel format. -*/ -static void xen_pvfb_guest_copy (struct xenfb *xenfb,int x,int y,int w,int h) -{ -DisplayState *ds = (DisplayState *)xenfb->user_data; -int line; - -if (xenfb->depth == ds->depth) {/* Perfect match can use fast path */ -for (line = y ; line < (y+h) ; line++) { -memcpy (ds->data + (line * ds->linesize) + (x * ds->depth /8 ), - xenfb->pixels + (line * xenfb->row_stride) + (x * xenfb->depth /8 ), - w * xenfb->depth /8 ); - } - }else {/* Mismatch requires slow pixel munging */ -if (xenfb->depth ==8 ) { -/* 8 bit source == r:3 g:3 b:2 */ -if (ds->depth ==16 ) { -BLT (uint8_t, uint16_t,5 ,2 ,0 ,11 ,5 ,0 ,7 ,7 ,3 ); - }else if (ds->depth ==32 ) { -BLT (uint8_t, uint32_t,5 ,2 ,0 ,16 ,8 ,0 ,7 ,7 ,3 ); - } - }else if (xenfb->depth ==16 ) { -/* 16 bit source == r:5 g:6 b:5 */ -if (ds->depth ==8 ) { -BLT (uint16_t, uint8_t,11 ,5 ,0 ,5 ,2 ,0 ,31 ,63 ,31 ); - }else if (ds->depth ==32 ) { -BLT (uint16_t, uint32_t,11 ,5 ,0 ,16 ,8 ,0 ,31 ,63 ,31 ); - } - }else if (xenfb->depth ==32 ) { -/* 32 bit source == r:8 g:8 b:8 (padding:8) */ -if (ds->depth ==8 ) { -BLT (uint32_t, uint8_t,16 ,8 ,0 ,5 ,2 ,0 ,255 ,255 ,255 ); - }else if (ds->depth ==16 ) { -BLT (uint32_t, uint16_t,16 ,8 ,0 ,11 ,5 ,0 ,255 ,255 ,255 ); - } - } - } -dpy_update (ds, x, y, w, h); -} - -/* -* Send a key event from the client to the guest OS -* QEMU gives us a raw scancode from an AT / PS/2 style keyboard. -* We have to turn this into a Linux Input layer keycode. -* -* Extra complexity from the fact that with extended scancodes -* (like those produced by arrow keys) this method gets called -* twice, but we only want to send a single event. So we have to -* track the '0xe0' scancode state & collapse the extended keys -* as needed. -* -* Wish we could just send scancodes straight to the guest which -* already has code for dealing with this... -*/ -static void xen_pvfb_key_event (void *opaque,int scancode) -{ -static int extended =0 ; -int down =1 ; -if (scancode ==0xe0 ) { - extended =1 ; -return ; - }else if (scancode &0x80 ) { - scancode &=0x7f ; - down =0 ; - } -if (extended) { - scancode |=0x80 ; - extended =0 ; - } -xenfb_send_key (opaque, down, scancode2linux[scancode]); -} - -/* -* Send a mouse event from the client to the guest OS -* -* The QEMU mouse can be in either relative, or absolute mode. -* Movement is sent separately from button state, which has to -* be encoded as virtual key events. We also don't actually get -* given any button up/down events, so have to track changes in -* the button state. -*/ -static void xen_pvfb_mouse_event (void *opaque, -int dx,int dy,int dz,int button_state) -{ -static int old_state =0 ; -int i; -struct xenfb *xenfb = opaque; -DisplayState *ds = (DisplayState *)xenfb->user_data; -if (xenfb->abs_pointer_wanted) -xenfb_send_position (xenfb, - dx * ds->width /0x7fff , - dy * ds->height /0x7fff ); -else -xenfb_send_motion (xenfb, dx, dy); - -for (i =0 ; i <8 ; i++) { -int lastDown = old_state & (1 << i); -int down = button_state & (1 << i); -if (down == lastDown) -continue ; - -if (xenfb_send_key (xenfb, down,BTN_LEFT +i) <0 ) -return ; - } - old_state = button_state; -} - -/* QEMU display state changed, so refresh the framebuffer copy */ -/* XXX - can we optimize this, or the next func at all ? */ -void xen_pvfb_update (void *opaque) -{ -struct xenfb *xenfb = opaque; -xen_pvfb_guest_copy (xenfb,0 ,0 , xenfb->width, xenfb->height); -} - -/* QEMU display state changed, so refresh the framebuffer copy */ -void xen_pvfb_invalidate (void *opaque) -{ -xen_pvfb_update (opaque); -} - -/* Screen dump is not used in Xen, so no need to impl this ? */ -void xen_pvfb_screen_dump (void *opaque,const char *name) { }/* The Xen PV machine currently provides * - a virtual framebuffer
@@ -226,14 +38,6 @@ static void xen_init_pv(uint64_t ram_siz {struct xenfb *xenfb;extern int domid; -int i; - -/* Prepare scancode mapping table */ -for (i =0 ; i <128 ; i++) { - scancode2linux[i] = atkbd_set2_keycode[atkbd_unxlate_table[i]]; - scancode2linux[i |0x80 ] = - atkbd_set2_keycode[atkbd_unxlate_table[i] |0x80 ]; - }/* Prepare PVFB state */ xenfb =xenfb_new ();
@@ -244,27 +48,11 @@ static void xen_init_pv(uint64_t ram_siz }/* Talk to the guest */ -if (xenfb_attach_dom (xenfb, domid) <0 ) { +if (xenfb_attach_dom (xenfb, domid, ds) <0 ) {fprintf (stderr,"Could not connect to domain (%s)\n" ,strerror (errno));exit (1 ); } - xenfb->update = xen_pvfb_guest_copy; - xenfb->user_data = ds; - -/* Tell QEMU to allocate a graphical console */ -graphic_console_init (ds, - xen_pvfb_update, - xen_pvfb_invalidate, - xen_pvfb_screen_dump, - xenfb); - -/* Register our keyboard & mouse handlers */ -qemu_add_kbd_event_handler (xen_pvfb_key_event, xenfb); -qemu_add_mouse_event_handler (xen_pvfb_mouse_event, xenfb, - xenfb->abs_pointer_wanted, -"Xen PVFB Mouse" ); -/* Setup QEMU display */ dpy_resize (ds, xenfb->width, xenfb->height);
tools/ioemu/hw/xenfb.c +290 -63
398 lines not on this page · raw message
tools/ioemu/hw/xenfb.h +3 -5
@@ -1,6 +1,7 @@#ifndef _XENFB_H_#define _XENFB_H_ +#include "vl.h" #include <stdbool.h> #include <sys/types.h>
@@ -13,6 +14,7 @@ struct xenfbint width;int height;int abs_pointer_wanted; +int button_state;void *user_data;
@@ -23,10 +25,6 @@ void xenfb_delete(struct xenfb *xenfb);void xenfb_delete (struct xenfb *xenfb);void xenfb_teardown (struct xenfb *xenfb); -int xenfb_attach_dom (struct xenfb *xenfb,int domid); - -int xenfb_send_key (struct xenfb *xenfb,bool down,int keycode); -int xenfb_send_motion (struct xenfb *xenfb,int rel_x,int rel_y); -int xenfb_send_position (struct xenfb *xenfb,int abs_x,int abs_y); +int xenfb_attach_dom (struct xenfb *xenfb,int domid,DisplayState *ds);#endif
Signature · 4 lines
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
Re: PATCH 6/10: Merge private & public xenfb structs
In reply to Daniel P. BerrangeThis patch merges the public & private structs from the paravirt FB into a single struct. Since QEMU is the only consumer of this code there is no need for the artifical pub/priv split. Merging the two will make it possible to more tightly integrate with QEMU's event loop and do asynchronous non-blocking negoiation with the frontend devices (see next patch).
xen_machine_pv.c | 3 xenfb.c | 166 ++++++++++++++++++++++++++----------------------------- xenfb.h | 16 ----- 3 files changed, 82 insertions(+), 103 deletions(-)
tools/ioemu/hw/xen_machine_pv.c +0 -3
@@ -53,9 +53,6 @@ static void xen_init_pv(uint64_t ram_siz strerror(errno));exit (1 ); } - -/* Setup QEMU display */ -dpy_resize (ds, xenfb->width, xenfb->height); }QEMUMachine xenpv_machine = {
tools/ioemu/hw/xenfb.c +81 -85
390 lines not on this page · raw message
tools/ioemu/hw/xenfb.h +1 -15
@@ -5,21 +5,7 @@#include <stdbool.h> #include <sys/types.h> -struct xenfb -{ -void *pixels; - -int row_stride; -int depth; -int width; -int height; -int abs_pointer_wanted; -int button_state; - -void *user_data; - -void (*update)(struct xenfb *xenfb,int x,int y,int width,int height); -}; +struct xenfb ;struct xenfb *xenfb_new (void );void xenfb_delete (struct xenfb *xenfb);
Signature · 4 lines
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
Re: PATCH 7/10: Async negotiation with xenfb frontend
In reply to Daniel P. BerrangeThis patch re-factors the paravirt console xenfb_attach_dom method. The original method blocks the caller until the front & backends have both switched to the connected state. This isn't an immediate problem, but patches which follow will extend qemu to also handle the text console so blocking on graphics console startup will block the text console processing.
The new code is basically a state machine. It starts off with a watch waiting for the KBD backend to switch to 'initialized' mode, then does the same for the FB backend. Now it waits for KBD & FB frontend devices to initialize, reading & mapping the framebuffer & its config at the appropriate step. When the KBD frontend finally reaches the connected state it registers a graphical console with QEMU and sets up the various framebuffer, mouse & keyboard event handlers. If a client connects to the VNC server before this is completed, then they will merely see a text console (or perhaps the monitor if configured that way).
The main difference from previous versions of this patch, is that at the suggestion of Markus Armbruster, I'vere-ordered the individual static functions so they are in order-of-call, rather than reversed. Although I now have to pre-declare them, it is much easier to read the code. I have also fixed the keycode -> keysym translations to match previous behaviour.
xen_machine_pv.c | 9 xenfb.c | 721 +++++++++++++++++++++++++++++++------------------------ xenfb.h | 7 3 files changed, 415 insertions(+), 322 deletions(-)
tools/ioemu/hw/xen_machine_pv.c +1 -8
@@ -40,16 +40,9 @@ static void xen_init_pv(uint64_t ram_sizextern int domid;/* Prepare PVFB state */ - xenfb =xenfb_new (); + xenfb =xenfb_new (domid, ds);if (xenfb ==NULL ) {fprintf (stderr,"Could not create framebuffer (%s)\n" , -strerror (errno)); -exit (1 ); - } - -/* Talk to the guest */ -if (xenfb_attach_dom (xenfb, domid, ds) <0 ) { -fprintf (stderr,"Could not connect to domain (%s)\n" ,strerror (errno));exit (1 ); }
tools/ioemu/hw/xenfb.c +412 -309
845 lines not on this page · raw message
tools/ioemu/hw/xenfb.h +2 -5
@@ -7,10 +7,7 @@struct xenfb ; -struct xenfb *xenfb_new (void ); -void xenfb_delete (struct xenfb *xenfb); -void xenfb_teardown (struct xenfb *xenfb); - -int xenfb_attach_dom (struct xenfb *xenfb,int domid,DisplayState *ds); +struct xenfb *xenfb_new (int domid,DisplayState *ds); +void xenfb_shutdown (struct xenfb *xenfb);#endif
Signature · 4 lines
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
Re: PATCH 8/10: Add pv console to QEMU paravirt machine
In reply to Daniel P. BerrangeThis patch adds a paravirt console driver to qemu-dm. This is used when the QEMU machine type is 'xenpv', connecting to the ring buffer provided by the guest kernel. The '-serial' command line flag controls how the guest console is exposed.
For parity with xenconsoled the '-serial pty' arg can be used. For guests which are running a qemu-dm device model, the xenconsoled daemon is no longer needed for guest consoles. The code for the xen_console.c is based on the original code in tools/console/daemon/io.c, but simplified; since its only dealing with a single guest there's no state tracking to worry about.
b/tools/ioemu/hw/xen_console.c | 432 ++++++++++++++++++++++++++++++++ b/tools/ioemu/hw/xen_console.h | 25 + tools/ioemu/Makefile.target | 1 tools/ioemu/hw/xen_machine_pv.c | 9 tools/ioemu/xenstore.c | 2 tools/python/xen/xend/XendDomainInfo.py | 7 6 files changed, 471 insertions(+), 5 deletions(-)
tools/ioemu/Makefile.target +1 -0
@@ -412,6 +412,7 @@ VL_OBJS+= xen_machine_fv.o VL_OBJS+= xen_machine_fv.o VL_OBJS+= xen_machine_pv.o VL_OBJS+= xenfb.o +VL_OBJS+= xen_console.o VL_OBJS+= tpm_tis.o CPPFLAGS += -DHAS_AUDIO endif
tools/ioemu/hw/xen_console.c new file +432 -0
432 lines not on this page · raw message
tools/ioemu/hw/xen_console.h new file +25 -0
@@ -0,0 +1,25 @@ +/* +* Copyright (C) International Business Machines Corp., 2005 +* Author(s): Anthony Liguori <[email protected]> +* +* Copyright (C) Red Hat 2007 +* +* Xen Console +* +* 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; under version 2 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, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "vl.h" + +extern int xencons_init (int domid,CharDriverState *chr);
tools/ioemu/hw/xen_machine_pv.c +9 -0
@@ -23,6 +23,7 @@*/ #include "vl.h" +#include "xen_console.h" #include "xenfb.h" /* The Xen PV machine currently provides
@@ -38,6 +39,14 @@ static void xen_init_pv(uint64_t ram_siz {struct xenfb *xenfb;extern int domid; + +/* Connect to text console */ +if (serial_hds[0 ]) { +if (xencons_init (domid, serial_hds[0 ]) <0 ) { +fprintf (stderr,"Could not connect to domain console\n" ); +exit (1 ); + } + }/* Prepare PVFB state */ xenfb =xenfb_new (domid, ds);
tools/ioemu/xenstore.c +1 -1
@@ -17,7 +17,7 @@#include <sys/stat.h> #include <fcntl.h> -static struct xs_handle *xsh =NULL ; +struct xs_handle *xsh =NULL ;static char *media_filename[MAX_DISKS +MAX_SCSI_DISKS ];static QEMUTimer *insert_timer =NULL ;
tools/python/xen/xend/XendDomainInfo.py +3 -4
@@ -1761,10 +1761,9 @@ class XendDomainInfo: self.console_mfn = console_mfn self._introduceDomain() - if self.info.is_hvm(): - self.image = image.create(self, self.info) - if self.image: - self.image.createDeviceModel(True) + self.image = image.create(self, self.info) + if self.image: + self.image.createDeviceModel(True) self._storeDomDetails() self._registerWatches() self.refreshShutdown()
Signature · 4 lines
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
Re: PATCH 9/10: XenD device model re-factoring
In reply to Daniel P. BerrangeThis patches adapts XenD so that it is capable of starting a qemu-dm device model for both paravirt and fullyvirt guests. A paravirt guest will only be given a device model if it has a VFB configured, or the user explicitly include the device_model option in the config config. This avoids unneccessary overhead for those wanting a minimal paravirt guest.
The bulk of this patch involves moving code from the HVMImageHandler into the base ImageHandler class. The HVMImageHandler and LinuxImageHandler subclasses now merely containing a couple of overrides to set some specific command line flags. The most important is -M xenpv, vs -M xenfv.
The XenConfig class has a minor refactoring to add a has_rfb() method to avoid duplicating code in a couple of places. Instead of hardcoding DEFAULT_DM it now uses the xen.util.auxbin APIs to locate it - this works on platforms where qemu-dm is in /usr/lib64 instead of /usr/lib. As before paravirt only gets a default qemu-dm if using a VFB
The vfbif.py class is trimmed out since it no longer needs to spawn a daemon. A few other misc fixes deal with qemu-dm interactions when saving/restoring, and in particular recovering from save failures (or checkpointing).
XendCheckpoint.py | 5 XendConfig.py | 35 ++-- XendDomainInfo.py | 23 +-- image.py | 382 ++++++++++++++++++++++++++++-------------------------- server/vfbif.py | 108 ++------------- 5 files changed, 251 insertions(+), 302 deletions(-)
tools/python/xen/xend/XendCheckpoint.py +4 -1
@@ -6,6 +6,7 @@ # this archive for more details. import os +import os.path import re import string import threading
@@ -108,7 +109,7 @@ def save(fd, dominfo, network, live, dst forkHelper(cmd, fd, saveInputHandler, False) # put qemu device model state - if hvm: + if os.path.exists("/var/lib/xen/qemu-save.%d" % dominfo.getDomid()): write_exact(fd, QEMU_SIGNATURE, "could not write qemu signature") qemu_fd = os.open("/var/lib/xen/qemu-save.%d" % dominfo.getDomid(), os.O_RDONLY)
@@ -245,6 +246,8 @@ def restore(xd, fd, dominfo = None, paus raise XendError('Could not read console MFN') # get qemu state and create a tmp file for dm restore + # Even PV guests may have QEMU stat, but its not currently + # used so only bother with HVM currently. if is_hvm: qemu_signature = read_exact(fd, len(QEMU_SIGNATURE), "invalid device model signature read")
tools/python/xen/xend/XendConfig.py +17 -18
@@ -32,6 +32,7 @@ from xen.xend.server.netif import random from xen.xend.server.netif import randomMAC from xen.util.blkif import blkdev_name_to_number from xen.util import xsconstants +import xen.util.auxbin log = logging.getLogger("xend.XendConfig") log.setLevel(logging.WARN)
@@ -233,8 +234,6 @@ LEGACY_XENSTORE_VM_PARAMS = [ 'on_xend_start', 'on_xend_stop', ] - -DEFAULT_DM = '/usr/lib/xen/bin/qemu-dm' ## ## Config Choices
@@ -393,13 +392,14 @@ class XendConfig(dict): self['name_label'] = 'Domain-' + self['uuid'] def _platform_sanity_check(self): + if 'keymap' not in self['platform'] and XendOptions.instance().get_keymap(): + self['platform']['keymap'] = XendOptions.instance().get_keymap() + + if self.is_hvm() or self.has_rfb(): + if 'device_model' not in self['platform']: + self['platform']['device_model'] = xen.util.auxbin.pathTo("qemu-dm") + if self.is_hvm(): - if 'keymap' not in self['platform'] and XendOptions.instance().get_keymap(): - self['platform']['keymap'] = XendOptions.instance().get_keymap() - - if 'device_model' not in self['platform']: - self['platform']['device_model'] = DEFAULT_DM - # Compatibility hack, can go away soon. if 'soundhw' not in self['platform'] and \ self['platform'].get('enable_audio'):
@@ -744,16 +744,7 @@ class XendConfig(dict): # coalesce hvm vnc frame buffer with vfb config if self.is_hvm() and int(self['platform'].get('vnc', 0)) != 0: # add vfb device if it isn't there already - has_rfb = False - for console_uuid in self['console_refs']: - if self['devices'][console_uuid][1].get('protocol') == 'rfb': - has_rfb = True - break - if self['devices'][console_uuid][0] == 'vfb': - has_rfb = True - break - - if not has_rfb: + if not self.has_rfb(): dev_config = ['vfb'] dev_config.append(['type', 'vnc']) # copy VNC related params from platform config to vfb dev conf
@@ -764,6 +755,14 @@ class XendConfig(dict): self.device_add('vfb', cfg_sxp = dev_config) + + def has_rfb(self): + for console_uuid in self['console_refs']: + if self['devices'][console_uuid][1].get('protocol') == 'rfb': + return True + if self['devices'][console_uuid][0] == 'vfb': + return True + return False def _sxp_to_xapi_unsupported(self, sxp_cfg): """Read in an SXP configuration object and populate
tools/python/xen/xend/XendDomainInfo.py +12 -11
@@ -1455,10 +1455,16 @@ class XendDomainInfo: def _releaseDevices(self, suspend = False): """Release all domain's devices. Nothrow guarantee.""" - if suspend and self.image: - self.image.destroy(suspend) - return - + if self.image: + try: + log.debug("Destroying device model") + self.image.destroyDeviceModel() + except Exception, e: + log.exception("Device model destroy failed %s" % str(e)) + else: + log.debug("No device model") + + log.debug("Releasing devices") t = xstransact("%s/device" % self.dompath) for devclass in XendDevices.valid_devices(): for dev in t.list(devclass):
@@ -1709,11 +1715,6 @@ class XendDomainInfo: bootloader_tidy(self) if self.image: - try: - self.image.destroy() - except: - log.exception( - "XendDomainInfo.cleanup: image.destroy() failed.") self.image = None try:
@@ -1881,8 +1882,8 @@ class XendDomainInfo: ResumeDomain(self.domid) except: log.exception("XendDomainInfo.resume: xc.domain_resume failed on domain %s." % (str(self.domid))) - if self.is_hvm(): - self.image.resumeDeviceModel() + self.image.resumeDeviceModel() + log.debug("XendDomainInfo.resumeDomain: completed") #
tools/python/xen/xend/image.py +201 -181
455 lines not on this page · raw message
tools/python/xen/xend/server/vfbif.py +17 -91
137 lines not on this page · raw message
Signature · 4 lines
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
Re: PATCH 10/10: Make xenconsoled ignore doms with qemu-dm
In reply to Daniel P. BerrangeThis patch writes a field /local/vm/DOMID/console/type taking the value 'ioemu' or 'xenconsoled'. If xenconsoled sees a type that is not its own, then it skips handling of that guest. The qemu-dm process doesn't need to read this field since it will only attach to the console if given the -serial pty arg which XenD already ensures matches this xenstore field.
The overall behaviour is that if a paravirt guest has a qemu-dm process running then that handles the console, otherwise the xenconsoled handles it. The former is more functional, with the exception of not currently supporting persistent logging to a file at the same time as exposing a PTY.
console/daemon/io.c | 9 +++++++++ python/xen/xend/XendDomainInfo.py | 7 +++++++ 2 files changed, 16 insertions(+)
tools/console/daemon/io.c +9 -0
@@ -377,6 +377,7 @@ static int domain_create_ring(struct domstatic int domain_create_ring (struct domain *dom) {int err, remote_port, ring_ref, rc; +char *type, path[PATH_MAX ]; err = xs_gather(xs, dom->serialpath, "ring-ref", "%u", &ring_ref,
@@ -393,6 +394,14 @@ static int domain_create_ring(struct dom }else dom->use_consolepath =0 ; +sprintf (path,"%s/type" , dom->use_consolepath ? dom->conspath: dom->serialpath); + type =xs_read (xs,XBT_NULL , path,NULL ); +if (type &&strcmp (type,"xenconsoled" ) !=0 ) { +free (type); +return 0 ; + } +free (type); +if ((ring_ref == dom->ring_ref) && (remote_port == dom->remote_port)) goto out;
tools/python/xen/xend/XendDomainInfo.py +7 -0
@@ -916,8 +916,15 @@ class XendDomainInfo: else: to_store[n] = str(v) + # Figure out if we need to tell xenconsoled to ignore this guest's + # console - device model will handle console if it is running + constype = "ioemu" + if 'device_model' not in self.info['platform']: + constype = "xenconsoled" + f('console/port', self.console_port) f('console/ring-ref', self.console_mfn) + f('console/type', constype) f('store/port', self.store_port) f('store/ring-ref', self.store_mfn)
Signature · 4 lines
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
Quoted 2 lines · Daniel P. Berrange
The following series of 10 patches is a merge of the xenfb and xenconsoled functionality into the qemu-dm code.
Hi Dan,
Does anything change with respect to specifying a vfb= option with
this series? On ia64, the guest xenbus never seems to find the device it's looking for:
NET: Registered protocol family 1
NET: Registered protocol family 17
Bridge firewalling registered
xen privcmd uses pseudo physical addr range [0x100000000, 0x3ffff000000] (4190192MB)
Xen p2m: assign p2m table of [0x0000000000000000, 0x0000000100004000) Xen p2m: to [0x0000000100000000, 0x0000000104000000) (65536 KBytes)
XENBUS: Waiting for devices to initialise:
295s...290s...285s...280s...275s...270s...265s...260s...255s...250s...245s...
I do have a qemu process running for this domain:
/usr/lib/xen/bin/qemu-dm -d 7 -domain-name debian -vnc 0.0.0.0:0 -serial pty -M xenpv
Seems like the async hookup isn't happening. Anything obvious to check? I confirmed I do still have vfb on ia64 with a tools build from the cset before this series. Thanks,
Alex
Signature · 1 line
Alex Williamson HP Open Source & Linux Org.
Quoted 10 lines · Alex Williamson
Quoted 2 lines · Daniel P. Berrange
The following series of 10 patches is a merge of the xenfb and xenconsoled functionality into the qemu-dm code.
Hi Dan,
Does anything change with respect to specifying a vfb= option with
this series? On ia64, the guest xenbus never seems to find the device it's looking for:
The configuration doesn't change, but now QEMU is responsible for being the backend instead of xen-vncfb. The /var/log/xen/qemu-dm-<domid>.log file will print out a message for each of the xenbus state transitiions the QEMU backend goes through when connecting to the frontend PVFB.
Quoted 11 lines
NET: Registered protocol family 1
NET: Registered protocol family 17
Bridge firewalling registered
xen privcmd uses pseudo physical addr range [0x100000000,0x3ffff000000] (4190192MB)
Xen p2m: assign p2m table of [0x0000000000000000,0x0000000100004000) Xen p2m: to [0x0000000100000000,0x0000000104000000) (65536 KBytes)
XENBUS: Waiting for devices to initialise:
295s...290s...285s...280s...275s...270s...265s...260s...255s...250s...245s...
Quoted 3 lines
I do have a qemu process running for this domain:
/usr/lib/xen/bin/qemu-dm-d 7 -domain-name debian -vnc 0.0.0.0:0 -serial pty -M xenpv
That's looking correct.
Quoted 3 lines
Seems like the async hookup isn't happening. Anything obvious to check? I confirmed I do still have vfb on ia64 with a tools build from the cset before this series. Thanks,
The QEMU logfile is the best place to look. And compare what state it is in, with the info in xenstore associated with the front/back ends. If you wnat any help, mail me the output of 'xenstore-ls' and the QEMU logfile and I can see if anything obvious is wrong.
Dan.
Signature · 4 lines
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
Quoted 4 lines · Alex Williamson
Quoted 2 lines · Daniel P. Berrange
The following series of 10 patches is a merge of the xenfb and xenconsoled functionality into the qemu-dm code.
[snip]
Quoted 3 lines
Seems like the async hookup isn't happening. Anything obvious to check? I confirmed I do still have vfb on ia64 with a tools build from the cset before this series. Thanks,
Another thing worth testing, is to try a build at 16225:695871933840 vs 16226:695871933840. 16226 contains a refactoring of the front/back handshake code, so if it still works on 16225 then it points to a bug in the state machine changes I did.
Dan.
Signature · 4 lines
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
Quoted 8 lines · Daniel P. Berrange
Quoted 3 lines
Seems like the async hookup isn't happening. Anything obvious to check? I confirmed I do still have vfb on ia64 with a tools build from the cset before this series. Thanks,
Another thing worth testing, is to try a build at 16225:695871933840 vs 16226:695871933840. 16226 contains a refactoring of the front/back handshake code, so if it still works on 16225 then it points to a bug in the state machine changes I did.
Yes, that is the case. 16225 works fine. On 16226, the domu hangs,
then gives me a vkbd error:
Error: Device 0 (vkbd) could not be connected. Hotplug scripts not working.
Here's was I see in the qmeu log file:
xs_read(): vncpasswd get
error. /vm/c766b61d-58e1-8efe-b853-40addbd451ae/vncpasswd. shift keysym 003e keycode 86
shift keysym 00a6 keycode 86
keypad keysym ffae keycode 83
keypad keysym ffac keycode 83
...
shift keysym 0021 keycode 2
shift keysym 0040 keycode 3
shift keysym 0023 keycode 4
...
shift keysym 003f keycode 53
FB: Waiting for KBD backend creation
Doing backend watch on
Watch for dev failed
The same failure happens in the qmeu log with tip. It seems odd to me that xenfb_new() can return failure, but we don't make use of the return value from xenfb_wait_for_backend(). I also attached the xenstore-ls output. This was domid 5 for this latest attempt on cset 16226. Thanks,
Alex
Signature · 1 line
Alex Williamson HP Open Source & Linux Org.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Hrrrm, diagnostics omit errno. Alex, could you retry with the appended (obvious, but untested) patch applied?
ioemu/hw/xenfb.c renamed from ioemu/hw/xenfb.c~ +4 -2
@@ -664,7 +664,8 @@ {fprintf (stderr,"Doing frontend watch on %s\n" , dev->otherend);if (!xs_watch (dev->xenfb->xsh, dev->otherend,"" )) { -fprintf (stderr,"Watch for dev failed\n" ); +fprintf (stderr,"Watch for dev failed (%s)\n" , +strerror (errno));return -1 ; }
@@ -680,7 +681,8 @@ {fprintf (stderr,"Doing backend watch on %s\n" , dev->nodename);if (!xs_watch (dev->xenfb->xsh, dev->nodename,"" )) { -fprintf (stderr,"Watch for dev failed\n" ); +fprintf (stderr,"Watch for dev failed (%s)\n" , +strerror (errno));return -1 ; }
Quoted 19 lines · Alex Williamson
Quoted 8 lines · Daniel P. Berrange
Quoted 3 lines
Seems like the async hookup isn't happening. Anything obvious to check? I confirmed I do still have vfb on ia64 with a tools build from the cset before this series. Thanks,
Another thing worth testing, is to try a build at 16225:695871933840 vs 16226:695871933840. 16226 contains a refactoring of the front/back handshake code, so if it still works on 16225 then it points to a bug in the state machine changes I did.
Yes, that is the case. 16225 works fine. On 16226, the domu hangs,
then gives me a vkbd error:Error: Device 0 (vkbd) could not be connected. Hotplug scripts not working.
Here's was I see in the qmeu log file:
Quoted 14 lines
xs_read(): vncpasswd get
error. /vm/c766b61d-58e1-8efe-b853-40addbd451ae/vncpasswd. shift keysym 003e keycode 86
shift keysym 00a6 keycode 86
keypad keysym ffae keycode 83
keypad keysym ffac keycode 83
...
shift keysym 0021 keycode 2
shift keysym 0040 keycode 3
shift keysym 0023 keycode 4
...
shift keysym 003f keycode 53
FB: Waiting for KBD backend creation
Doing backend watch on
This was the useful line ^^^^ there should have been a xenstore device path there, but I lost the hunk of a patch which initialized this. I just sent a patch to the list which will fix this. It wasn't ia64 specific.
Regards,
Dan.
Signature · 4 lines
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|