rpms/xen/devel xen-pvfb-01-qemu-fv-machine.patch, 1.1.2.1, 1.1.2.2 xen-pvfb-02-qemu-pv-machine.patch, 1.2.2.1, 1.2.2.2 xen-pvfb-03-xenfb-remove.patch, 1.1.2.1, 1.1.2.2 xen-pvfb-04-xenfb-event-handlers.patch, 1.1.2.1, 1.1.2.2 xen-pvfb-05-xenfb-qemu-console.patch, 1.1.2.1, 1.1.2.2 xen-pvfb-06-xenfb-pubpriv-merge.patch, 1.1.2.1, 1.1.2.2 xen-pvfb-07-xenfb-async-startup.patch, 1.1.2.1, 1.1.2.2 xen-pvfb-08-xen-console-qemu.patch, 1.1.2.1, 1.1.2.2 xen-pvfb-09-xend-device-model.patch, 1.1.2.1, 1.1.2.2 xen-pvfb-10-xen-console-ignore.patch, 1.1.2.1, 1.1.2.2 xen.spec, 1.194.2.1, 1.194.2.2
Daniel P. Berrange (berrange)
fedora-extras-commits at redhat.com
Wed Oct 24 20:03:09 UTC 2007
- Previous message (by thread): rpms/ql2100-firmware/devel LICENSE, NONE, 1.1 ql2100-firmware.spec, NONE, 1.1 .cvsignore, 1.1, 1.2 sources, 1.1, 1.2
- Next message (by thread): rpms/ql2200-firmware/devel LICENSE, NONE, 1.1 ql2200-firmware.spec, NONE, 1.1 .cvsignore, 1.1, 1.2 sources, 1.1, 1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Author: berrange
Update of /cvs/pkgs/rpms/xen/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv1778
Modified Files:
Tag: private-berrange-xen-unstable
xen-pvfb-01-qemu-fv-machine.patch
xen-pvfb-02-qemu-pv-machine.patch
xen-pvfb-03-xenfb-remove.patch
xen-pvfb-04-xenfb-event-handlers.patch
xen-pvfb-05-xenfb-qemu-console.patch
xen-pvfb-06-xenfb-pubpriv-merge.patch
xen-pvfb-07-xenfb-async-startup.patch
xen-pvfb-08-xen-console-qemu.patch
xen-pvfb-09-xend-device-model.patch
xen-pvfb-10-xen-console-ignore.patch xen.spec
Log Message:
Refresh patches
xen-pvfb-01-qemu-fv-machine.patch:
Index: xen-pvfb-01-qemu-fv-machine.patch
===================================================================
RCS file: /cvs/pkgs/rpms/xen/devel/xen-pvfb-01-qemu-fv-machine.patch,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- xen-pvfb-01-qemu-fv-machine.patch 19 Oct 2007 23:35:08 -0000 1.1.2.1
+++ xen-pvfb-01-qemu-fv-machine.patch 24 Oct 2007 20:02:57 -0000 1.1.2.2
@@ -1,6 +1,23 @@
-diff -r b4278beaf354 tools/ioemu/Makefile.target
---- a/tools/ioemu/Makefile.target Wed Oct 17 13:12:03 2007 +0100
-+++ b/tools/ioemu/Makefile.target Fri Oct 19 17:32:05 2007 -0400
+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(-)
+
+ Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
+
+
+diff -r b28ae5f00553 tools/ioemu/Makefile.target
+--- a/tools/ioemu/Makefile.target Tue Oct 23 09:26:43 2007 +0100
++++ b/tools/ioemu/Makefile.target Wed Oct 24 15:20:39 2007 -0400
@@ -409,6 +409,7 @@ VL_OBJS+= piix4acpi.o
VL_OBJS+= piix4acpi.o
VL_OBJS+= xenstore.o
@@ -9,10 +26,10 @@
VL_OBJS+= tpm_tis.o
CPPFLAGS += -DHAS_AUDIO
endif
-diff -r b4278beaf354 tools/ioemu/hw/xen_machine_fv.c
+diff -r b28ae5f00553 tools/ioemu/hw/xen_machine_fv.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/tools/ioemu/hw/xen_machine_fv.c Fri Oct 19 17:38:27 2007 -0400
-@@ -0,0 +1,286 @@
++++ b/tools/ioemu/hw/xen_machine_fv.c Wed Oct 24 15:24:39 2007 -0400
+@@ -0,0 +1,288 @@
+/*
+ * QEMU Xen FV Machine
+ *
@@ -193,13 +210,15 @@
+
+#endif /* defined(MAPCACHE) */
+
++
+static void xen_init_fv(uint64_t ram_size, int vga_ram_size, char *boot_device,
+ DisplayState *ds, const char **fd_filename,
+ int snapshot,
+ const char *kernel_filename,
+ const char *kernel_cmdline,
+ const char *initrd_filename,
-+ const char *direct_pci){
++ const char *direct_pci)
++{
+ unsigned long ioreq_pfn;
+ extern void *shared_page;
+ extern void *buffered_io_page;
@@ -299,9 +318,9 @@
+ * tab-width: 4
+ * End:
+ */
-diff -r b4278beaf354 tools/ioemu/vl.c
---- a/tools/ioemu/vl.c Wed Oct 17 13:12:03 2007 +0100
-+++ b/tools/ioemu/vl.c Fri Oct 19 17:33:52 2007 -0400
+diff -r b28ae5f00553 tools/ioemu/vl.c
+--- a/tools/ioemu/vl.c Tue Oct 23 09:26:43 2007 +0100
++++ b/tools/ioemu/vl.c Wed Oct 24 15:21:37 2007 -0400
@@ -96,7 +96,6 @@
#include "exec-all.h"
@@ -598,9 +617,9 @@
/* we always create the cdrom drive, even if no disk is there */
bdrv_init();
if (cdrom_index >= 0) {
-diff -r b4278beaf354 tools/ioemu/vl.h
---- a/tools/ioemu/vl.h Wed Oct 17 13:12:03 2007 +0100
-+++ b/tools/ioemu/vl.h Fri Oct 19 17:32:05 2007 -0400
+diff -r b28ae5f00553 tools/ioemu/vl.h
+--- a/tools/ioemu/vl.h Tue Oct 23 09:26:43 2007 +0100
++++ b/tools/ioemu/vl.h Wed Oct 24 15:20:39 2007 -0400
@@ -1108,6 +1108,9 @@ extern void pci_piix4_acpi_init(PCIBus *
/* pc.c */
extern QEMUMachine pc_machine;
xen-pvfb-02-qemu-pv-machine.patch:
Index: xen-pvfb-02-qemu-pv-machine.patch
===================================================================
RCS file: /cvs/pkgs/rpms/xen/devel/xen-pvfb-02-qemu-pv-machine.patch,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.2
diff -u -r1.2.2.1 -r1.2.2.2
--- xen-pvfb-02-qemu-pv-machine.patch 19 Oct 2007 23:35:08 -0000 1.2.2.1
+++ xen-pvfb-02-qemu-pv-machine.patch 24 Oct 2007 20:02:57 -0000 1.2.2.2
@@ -1,7 +1,52 @@
-diff -r 327024163186 tools/ioemu/Makefile.target
---- a/tools/ioemu/Makefile.target Tue Aug 14 12:52:54 2007 -0400
-+++ b/tools/ioemu/Makefile.target Tue Aug 14 13:26:18 2007 -0400
-@@ -401,6 +401,8 @@ VL_OBJS+= xenstore.o
+This 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(-)
+
+ Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
+
+
+
+diff -r 6081d29591f1 tools/ioemu/Makefile.target
+--- a/tools/ioemu/Makefile.target Tue Sep 11 11:26:39 2007 -0400
++++ b/tools/ioemu/Makefile.target Tue Sep 11 11:28:21 2007 -0400
+@@ -400,6 +400,8 @@ VL_OBJS+= xenstore.o
VL_OBJS+= xenstore.o
VL_OBJS+= xen_platform.o
VL_OBJS+= xen_machine_fv.o
@@ -10,10 +55,10 @@
VL_OBJS+= tpm_tis.o
CPPFLAGS += -DHAS_AUDIO
endif
-diff -r 327024163186 tools/ioemu/hw/xen_machine_pv.c
+diff -r 6081d29591f1 tools/ioemu/hw/xen_machine_pv.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/tools/ioemu/hw/xen_machine_pv.c Tue Aug 14 14:21:29 2007 -0400
-@@ -0,0 +1,231 @@
++++ b/tools/ioemu/hw/xen_machine_pv.c Tue Sep 11 11:28:21 2007 -0400
+@@ -0,0 +1,315 @@
+/*
+ * QEMU Xen PV Machine
+ *
@@ -42,25 +87,70 @@
+#include "../../xenfb/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)); \
++ 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); \
++ *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.
++ * 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)
+{
@@ -69,9 +159,9 @@
+
+ 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);
++ 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) {
@@ -100,26 +190,58 @@
+ dpy_update(ds, x, y, w, h);
+}
+
-+
-+/* Send a keypress from the client to the guest OS */
-+static void xen_pvfb_put_keycode(void *opaque, int keycode)
++/*
++ * 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)
+{
-+ struct xenfb *xenfb = (struct xenfb*)opaque;
-+ xenfb_send_key(xenfb, keycode & 0x80 ? 0 : 1, keycode & 0x7f);
++ 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 */
++/*
++ * 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 = (struct xenfb*)opaque;
++ 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);
++ dx * ds->width / 0x7fff,
++ dy * ds->height / 0x7fff);
+ else
+ xenfb_send_motion(xenfb, dx, dy);
+
@@ -136,17 +258,17 @@
+}
+
+/* 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 = (struct xenfb *)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)
+{
-+ struct xenfb *xenfb = (struct xenfb *)opaque;
-+ xen_pvfb_guest_copy(xenfb, 0, 0, xenfb->width, xenfb->height);
++ xen_pvfb_update(opaque);
+}
+
+/* Screen dump is not used in Xen, so no need to impl this ? */
@@ -154,7 +276,7 @@
+
+void xen_pvfb_dispatch_store(void *opaque) {
+ int ret;
-+ if ((ret = xenfb_dispatch_store((struct xenfb *)opaque)) < 0) {
++ if ((ret = xenfb_dispatch_store(opaque)) < 0) {
+ fprintf(stderr, "Failure while dispatching store: %d\n", ret);
+ exit(1);
+ }
@@ -162,7 +284,7 @@
+
+void xen_pvfb_dispatch_channel(void *opaque) {
+ int ret;
-+ if ((ret = xenfb_dispatch_channel((struct xenfb *)opaque)) < 0) {
++ if ((ret = xenfb_dispatch_channel(opaque)) < 0) {
+ fprintf(stderr, "Failure while dispatching store: %d\n", ret);
+ exit(1);
+ }
@@ -181,7 +303,14 @@
+{
+ struct xenfb *xenfb;
+ extern int domid;
-+ int fd;
++ int fd, 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();
@@ -208,7 +337,7 @@
+ xenfb);
+
+ /* Register our keyboard & mouse handlers */
-+ qemu_add_kbd_event_handler(xen_pvfb_put_keycode, xenfb);
++ 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");
@@ -245,9 +374,9 @@
+ * tab-width: 4
+ * End:
+ */
-diff -r 327024163186 tools/ioemu/target-i386-dm/helper2.c
---- a/tools/ioemu/target-i386-dm/helper2.c Tue Aug 14 12:52:54 2007 -0400
-+++ b/tools/ioemu/target-i386-dm/helper2.c Tue Aug 14 12:58:46 2007 -0400
+diff -r 6081d29591f1 tools/ioemu/target-i386-dm/helper2.c
+--- a/tools/ioemu/target-i386-dm/helper2.c Tue Sep 11 11:26:39 2007 -0400
++++ b/tools/ioemu/target-i386-dm/helper2.c Tue Sep 11 11:28:21 2007 -0400
@@ -616,7 +616,7 @@ int main_loop(void)
extern int shutdown_requested;
extern int suspend_requested;
@@ -267,9 +396,9 @@
xenstore_record_dm_state("running");
while (1) {
-diff -r 327024163186 tools/ioemu/vl.c
---- a/tools/ioemu/vl.c Tue Aug 14 12:52:54 2007 -0400
-+++ b/tools/ioemu/vl.c Tue Aug 14 13:50:44 2007 -0400
+diff -r 6081d29591f1 tools/ioemu/vl.c
+--- a/tools/ioemu/vl.c Tue Sep 11 11:26:39 2007 -0400
++++ b/tools/ioemu/vl.c Tue Sep 11 11:28:21 2007 -0400
@@ -182,7 +182,7 @@ extern int vcpus;
int xc_handle;
@@ -296,10 +425,10 @@
break;
case QEMU_OPTION_d:
domid = atoi(optarg);
-diff -r 327024163186 tools/ioemu/vl.h
---- a/tools/ioemu/vl.h Tue Aug 14 12:52:54 2007 -0400
-+++ b/tools/ioemu/vl.h Tue Aug 14 12:55:35 2007 -0400
-@@ -1120,6 +1120,7 @@ extern QEMUMachine isapc_machine;
+diff -r 6081d29591f1 tools/ioemu/vl.h
+--- a/tools/ioemu/vl.h Tue Sep 11 11:26:39 2007 -0400
++++ b/tools/ioemu/vl.h Tue Sep 11 11:28:21 2007 -0400
+@@ -1110,6 +1110,7 @@ extern QEMUMachine isapc_machine;
extern QEMUMachine isapc_machine;
#ifdef CONFIG_DM
extern QEMUMachine xenfv_machine;
@@ -307,9 +436,9 @@
#endif
extern int fd_bootchk;
-diff -r 327024163186 tools/python/xen/xend/server/vfbif.py
---- a/tools/python/xen/xend/server/vfbif.py Tue Aug 14 12:52:54 2007 -0400
-+++ b/tools/python/xen/xend/server/vfbif.py Tue Aug 14 14:15:52 2007 -0400
+diff -r 6081d29591f1 tools/python/xen/xend/server/vfbif.py
+--- a/tools/python/xen/xend/server/vfbif.py Tue Sep 11 11:26:39 2007 -0400
++++ b/tools/python/xen/xend/server/vfbif.py Tue Sep 11 11:28:21 2007 -0400
@@ -50,8 +50,10 @@ class VfbifController(DevController):
# is HVM, so qemu-dm will handle the vfb.
return
@@ -364,10 +493,10 @@
else:
raise VmError('Unknown vfb type %s (%s)' % (t, repr(config)))
-diff -r 327024163186 tools/xenfb/xenfb.c
---- a/tools/xenfb/xenfb.c Tue Aug 14 12:52:54 2007 -0400
-+++ b/tools/xenfb/xenfb.c Tue Aug 14 13:41:54 2007 -0400
-@@ -676,37 +676,58 @@ static int xenfb_on_state_change(struct
+diff -r 6081d29591f1 tools/xenfb/xenfb.c
+--- a/tools/xenfb/xenfb.c Tue Sep 11 11:26:39 2007 -0400
++++ b/tools/xenfb/xenfb.c Tue Sep 11 11:28:21 2007 -0400
+@@ -670,37 +670,58 @@ static int xenfb_on_state_change(struct
return 0;
}
@@ -446,7 +575,7 @@
}
return 0;
-@@ -721,6 +742,18 @@ int xenfb_select_fds(struct xenfb *xenfb
+@@ -715,6 +736,18 @@ int xenfb_select_fds(struct xenfb *xenfb
FD_SET(fd1, readfds);
FD_SET(fd2, readfds);
return fd1 > fd2 ? fd1 + 1 : fd2 + 1;
@@ -465,7 +594,7 @@
}
static int xenfb_kbd_event(struct xenfb_private *xenfb,
-@@ -783,3 +816,10 @@ int xenfb_send_position(struct xenfb *xe
+@@ -777,3 +810,10 @@ int xenfb_send_position(struct xenfb *xe
return xenfb_kbd_event(xenfb, &event);
}
@@ -476,9 +605,9 @@
+ * tab-width: 8
+ * End:
+ */
-diff -r 327024163186 tools/xenfb/xenfb.h
---- a/tools/xenfb/xenfb.h Tue Aug 14 12:52:54 2007 -0400
-+++ b/tools/xenfb/xenfb.h Tue Aug 14 13:42:04 2007 -0400
+diff -r 6081d29591f1 tools/xenfb/xenfb.h
+--- a/tools/xenfb/xenfb.h Tue Sep 11 11:26:39 2007 -0400
++++ b/tools/xenfb/xenfb.h Tue Sep 11 11:28:21 2007 -0400
@@ -25,8 +25,12 @@ void xenfb_teardown(struct xenfb *xenfb)
int xenfb_attach_dom(struct xenfb *xenfb, int domid);
xen-pvfb-03-xenfb-remove.patch:
Index: xen-pvfb-03-xenfb-remove.patch
===================================================================
RCS file: /cvs/pkgs/rpms/xen/devel/xen-pvfb-03-xenfb-remove.patch,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- xen-pvfb-03-xenfb-remove.patch 19 Oct 2007 23:35:08 -0000 1.1.2.1
+++ xen-pvfb-03-xenfb-remove.patch 24 Oct 2007 20:02:57 -0000 1.1.2.2
@@ -1,6 +1,32 @@
-diff -r 0e5281845f71 Config.mk
---- a/Config.mk Fri Oct 19 17:38:47 2007 -0400
-+++ b/Config.mk Fri Oct 19 17:38:49 2007 -0400
+This 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(-)
+
+ Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
+
+
+
+diff -r 402c7c3fcf94 Config.mk
+--- a/Config.mk Tue Sep 11 11:28:21 2007 -0400
++++ b/Config.mk Tue Sep 11 11:37:36 2007 -0400
@@ -88,7 +88,6 @@ XENSTAT_XENTOP ?= y
XENSTAT_XENTOP ?= y
VTPM_TOOLS ?= n
@@ -9,9 +35,9 @@
PYTHON_TOOLS ?= y
-include $(XEN_ROOT)/.config
-diff -r 0e5281845f71 tools/Makefile
---- a/tools/Makefile Fri Oct 19 17:38:47 2007 -0400
-+++ b/tools/Makefile Fri Oct 19 17:38:49 2007 -0400
+diff -r 402c7c3fcf94 tools/Makefile
+--- a/tools/Makefile Tue Sep 11 11:28:21 2007 -0400
++++ b/tools/Makefile Tue Sep 11 11:37:36 2007 -0400
@@ -20,7 +20,6 @@ SUBDIRS-y += libaio
SUBDIRS-y += libaio
SUBDIRS-y += blktap
@@ -20,9 +46,9 @@
SUBDIRS-$(LIBXENAPI_BINDINGS) += libxen
# These don't cross-compile
-diff -r 0e5281845f71 tools/check/Makefile
---- a/tools/check/Makefile Fri Oct 19 17:38:47 2007 -0400
-+++ b/tools/check/Makefile Fri Oct 19 17:39:15 2007 -0400
+diff -r 402c7c3fcf94 tools/check/Makefile
+--- a/tools/check/Makefile Tue Sep 11 11:28:21 2007 -0400
++++ b/tools/check/Makefile Tue Sep 11 11:37:36 2007 -0400
@@ -7,7 +7,7 @@ all: build
# Check this machine is OK for building on.
.PHONY: build
@@ -41,8 +67,8 @@
.PHONY: clean
clean:
-diff -r 0e5281845f71 tools/check/check_libvncserver
---- a/tools/check/check_libvncserver Fri Oct 19 17:38:47 2007 -0400
+diff -r 402c7c3fcf94 tools/check/check_libvncserver
+--- a/tools/check/check_libvncserver Tue Sep 11 11:28:21 2007 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-#!/bin/sh
@@ -83,8 +109,8 @@
-rm -f $tmpfile
-
-exit $RC
-diff -r 0e5281845f71 tools/check/check_sdl
---- a/tools/check/check_sdl Fri Oct 19 17:38:47 2007 -0400
+diff -r 402c7c3fcf94 tools/check/check_sdl
+--- a/tools/check/check_sdl Tue Sep 11 11:28:21 2007 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-#!/bin/sh
@@ -114,10 +140,10 @@
-fi
-
-exit $RC
-diff -r 0e5281845f71 tools/ioemu/Makefile.target
---- a/tools/ioemu/Makefile.target Fri Oct 19 17:38:47 2007 -0400
-+++ b/tools/ioemu/Makefile.target Fri Oct 19 17:38:49 2007 -0400
-@@ -411,7 +411,7 @@ VL_OBJS+= xen_platform.o
+diff -r 402c7c3fcf94 tools/ioemu/Makefile.target
+--- a/tools/ioemu/Makefile.target Tue Sep 11 11:28:21 2007 -0400
++++ b/tools/ioemu/Makefile.target Tue Sep 11 11:37:36 2007 -0400
+@@ -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
@@ -126,9 +152,9 @@
VL_OBJS+= tpm_tis.o
CPPFLAGS += -DHAS_AUDIO
endif
-diff -r 0e5281845f71 tools/ioemu/hw/xen_machine_pv.c
---- a/tools/ioemu/hw/xen_machine_pv.c Fri Oct 19 17:38:47 2007 -0400
-+++ b/tools/ioemu/hw/xen_machine_pv.c Fri Oct 19 17:38:49 2007 -0400
+diff -r 402c7c3fcf94 tools/ioemu/hw/xen_machine_pv.c
+--- a/tools/ioemu/hw/xen_machine_pv.c Tue Sep 11 11:28:21 2007 -0400
++++ b/tools/ioemu/hw/xen_machine_pv.c Tue Sep 11 11:37:36 2007 -0400
@@ -23,7 +23,7 @@
*/
@@ -137,10 +163,10 @@
+#include "xenfb.h"
#include <linux/input.h>
- /* A convenient function for munging pixels between different depths */
-diff -r 0e5281845f71 tools/ioemu/hw/xenfb.c
+ /*
+diff -r 402c7c3fcf94 tools/ioemu/hw/xenfb.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/tools/ioemu/hw/xenfb.c Fri Oct 19 17:41:45 2007 -0400
++++ b/tools/ioemu/hw/xenfb.c Tue Sep 11 11:37:36 2007 -0400
@@ -0,0 +1,819 @@
+#include <stdarg.h>
+#include <stdlib.h>
@@ -961,9 +987,9 @@
+ * tab-width: 8
+ * End:
+ */
-diff -r 0e5281845f71 tools/ioemu/hw/xenfb.h
+diff -r 402c7c3fcf94 tools/ioemu/hw/xenfb.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/tools/ioemu/hw/xenfb.h Fri Oct 19 17:38:49 2007 -0400
++++ b/tools/ioemu/hw/xenfb.h Tue Sep 11 11:37:36 2007 -0400
@@ -0,0 +1,39 @@
+#ifndef _XENFB_H_
+#define _XENFB_H_
@@ -1004,8 +1030,8 @@
+int xenfb_send_position(struct xenfb *xenfb, int abs_x, int abs_y);
+
+#endif
-diff -r 0e5281845f71 tools/xenfb/Makefile
---- a/tools/xenfb/Makefile Fri Oct 19 17:38:47 2007 -0400
+diff -r 402c7c3fcf94 tools/xenfb/Makefile
+--- a/tools/xenfb/Makefile Tue Sep 11 11:28:21 2007 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-XEN_ROOT=../..
@@ -1040,8 +1066,8 @@
-vncfb: LDLIBS += $(shell libvncserver-config --libs) -lxenctrl -lxenstore
-
-sdlfb.o xenfb.o vncfb.o: xenfb.h
-diff -r 0e5281845f71 tools/xenfb/sdlfb.c
---- a/tools/xenfb/sdlfb.c Fri Oct 19 17:38:47 2007 -0400
+diff -r 402c7c3fcf94 tools/xenfb/sdlfb.c
+--- a/tools/xenfb/sdlfb.c Tue Sep 11 11:28:21 2007 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,342 +0,0 @@
-#include <SDL.h>
@@ -1386,8 +1412,8 @@
-
- return 0;
-}
-diff -r 0e5281845f71 tools/xenfb/vncfb.c
---- a/tools/xenfb/vncfb.c Fri Oct 19 17:38:47 2007 -0400
+diff -r 402c7c3fcf94 tools/xenfb/vncfb.c
+--- a/tools/xenfb/vncfb.c Tue Sep 11 11:28:21 2007 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,522 +0,0 @@
-#define _GNU_SOURCE
@@ -1912,8 +1938,8 @@
-
- return 0;
-}
-diff -r 0e5281845f71 tools/xenfb/xenfb.c
---- a/tools/xenfb/xenfb.c Fri Oct 19 17:38:47 2007 -0400
+diff -r 402c7c3fcf94 tools/xenfb/xenfb.c
+--- a/tools/xenfb/xenfb.c Tue Sep 11 11:28:21 2007 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,819 +0,0 @@
-#include <stdarg.h>
@@ -2735,8 +2761,8 @@
- * tab-width: 8
- * End:
- */
-diff -r 0e5281845f71 tools/xenfb/xenfb.h
---- a/tools/xenfb/xenfb.h Fri Oct 19 17:38:47 2007 -0400
+diff -r 402c7c3fcf94 tools/xenfb/xenfb.h
+--- a/tools/xenfb/xenfb.h Tue Sep 11 11:28:21 2007 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-#ifndef _XENFB_H_
xen-pvfb-04-xenfb-event-handlers.patch:
Index: xen-pvfb-04-xenfb-event-handlers.patch
===================================================================
RCS file: /cvs/pkgs/rpms/xen/devel/Attic/xen-pvfb-04-xenfb-event-handlers.patch,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- xen-pvfb-04-xenfb-event-handlers.patch 19 Oct 2007 23:35:08 -0000 1.1.2.1
+++ xen-pvfb-04-xenfb-event-handlers.patch 24 Oct 2007 20:02:57 -0000 1.1.2.2
@@ -1,13 +1,26 @@
-diff -r bd1bddd42929 tools/ioemu/hw/xen_machine_pv.c
---- a/tools/ioemu/hw/xen_machine_pv.c Tue Aug 14 14:38:28 2007 -0400
-+++ b/tools/ioemu/hw/xen_machine_pv.c Tue Aug 14 15:04:55 2007 -0400
-@@ -136,21 +136,6 @@ void xen_pvfb_invalidate(void *opaque)
+This 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(-)
+
+ Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
+
+
+
+diff -r d25e2cb62784 tools/ioemu/hw/xen_machine_pv.c
+--- a/tools/ioemu/hw/xen_machine_pv.c Tue Sep 11 11:37:37 2007 -0400
++++ b/tools/ioemu/hw/xen_machine_pv.c Tue Sep 11 11:53:28 2007 -0400
+@@ -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((struct xenfb *)opaque)) < 0) {
+- if ((ret = xenfb_dispatch_store(opaque)) < 0) {
- fprintf(stderr, "Failure while dispatching store: %d\n", ret);
- exit(1);
- }
@@ -15,23 +28,25 @@
-
-void xen_pvfb_dispatch_channel(void *opaque) {
- int ret;
-- if ((ret = xenfb_dispatch_channel((struct xenfb *)opaque)) < 0) {
+- 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
-@@ -165,7 +150,6 @@ static void xen_init_pv(uint64_t ram_siz
+ * - ....
+@@ -242,7 +226,7 @@ static void xen_init_pv(uint64_t ram_siz
{
struct xenfb *xenfb;
extern int domid;
-- int fd;
+- int fd, i;
++ int i;
- /* Prepare PVFB state */
- xenfb = xenfb_new();
-@@ -197,19 +181,6 @@ static void xen_init_pv(uint64_t ram_siz
+ /* 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");
@@ -51,9 +66,9 @@
/* Setup QEMU display */
dpy_resize(ds, xenfb->width, xenfb->height);
-diff -r bd1bddd42929 tools/ioemu/hw/xenfb.c
---- a/tools/ioemu/hw/xenfb.c Tue Aug 14 14:38:28 2007 -0400
-+++ b/tools/ioemu/hw/xenfb.c Tue Aug 14 15:10:27 2007 -0400
+diff -r d25e2cb62784 tools/ioemu/hw/xenfb.c
+--- a/tools/ioemu/hw/xenfb.c Tue Sep 11 11:37:37 2007 -0400
++++ b/tools/ioemu/hw/xenfb.c Tue Sep 11 11:53:28 2007 -0400
@@ -8,7 +8,6 @@
#include <xen/io/fbif.h>
#include <xen/io/kbdif.h>
@@ -70,7 +85,7 @@
#include "xenfb.h"
// FIXME defend against malicious frontend?
-@@ -511,96 +511,6 @@ static void xenfb_dev_fatal(struct xenfb
+@@ -505,96 +505,6 @@ static void xenfb_dev_fatal(struct xenfb
xenfb_switch_state(dev, XenbusStateClosing);
}
@@ -167,7 +182,7 @@
static void xenfb_detach_dom(struct xenfb_private *xenfb)
{
-@@ -676,13 +586,13 @@ static int xenfb_on_state_change(struct
+@@ -670,13 +580,13 @@ static int xenfb_on_state_change(struct
return 0;
}
@@ -183,7 +198,7 @@
if (port == xenfb->fb.port)
xenfb_on_fb_event(xenfb);
-@@ -690,12 +600,10 @@ int xenfb_dispatch_channel(struct xenfb
+@@ -684,12 +594,10 @@ int xenfb_dispatch_channel(struct xenfb
xenfb_on_kbd_event(xenfb);
if (xc_evtchn_unmask(xenfb->evt_xch, port) == -1)
@@ -200,7 +215,7 @@
{
struct xenfb_private *xenfb = (struct xenfb_private *)xenfb_pub;
unsigned dummy;
-@@ -708,52 +616,107 @@ int xenfb_dispatch_store(struct xenfb *x
+@@ -702,52 +610,107 @@ int xenfb_dispatch_store(struct xenfb *x
if (r == 0)
r = xenfb_on_state_change(&xenfb->kbd);
if (r == -1)
@@ -352,9 +367,9 @@
}
static int xenfb_kbd_event(struct xenfb_private *xenfb,
-diff -r bd1bddd42929 tools/ioemu/hw/xenfb.h
---- a/tools/ioemu/hw/xenfb.h Tue Aug 14 14:38:28 2007 -0400
-+++ b/tools/ioemu/hw/xenfb.h Tue Aug 14 15:03:42 2007 -0400
+diff -r d25e2cb62784 tools/ioemu/hw/xenfb.h
+--- a/tools/ioemu/hw/xenfb.h Tue Sep 11 11:37:37 2007 -0400
++++ b/tools/ioemu/hw/xenfb.h Tue Sep 11 11:53:28 2007 -0400
@@ -25,13 +25,6 @@ void xenfb_teardown(struct xenfb *xenfb)
int xenfb_attach_dom(struct xenfb *xenfb, int domid);
xen-pvfb-05-xenfb-qemu-console.patch:
Index: xen-pvfb-05-xenfb-qemu-console.patch
===================================================================
RCS file: /cvs/pkgs/rpms/xen/devel/Attic/xen-pvfb-05-xenfb-qemu-console.patch,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- xen-pvfb-05-xenfb-qemu-console.patch 19 Oct 2007 23:35:08 -0000 1.1.2.1
+++ xen-pvfb-05-xenfb-qemu-console.patch 24 Oct 2007 20:02:57 -0000 1.1.2.2
@@ -1,31 +1,88 @@
-diff -r c2aa6c7965a3 tools/ioemu/hw/xen_machine_pv.c
---- a/tools/ioemu/hw/xen_machine_pv.c Wed Aug 15 14:17:30 2007 -0400
-+++ b/tools/ioemu/hw/xen_machine_pv.c Tue Aug 21 22:03:27 2007 -0400
-@@ -24,117 +24,6 @@
+This 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(-)
+
+ Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
+
+
+diff -r 93300915575f tools/ioemu/hw/xen_machine_pv.c
+--- a/tools/ioemu/hw/xen_machine_pv.c Tue Sep 11 11:53:28 2007 -0400
++++ b/tools/ioemu/hw/xen_machine_pv.c Tue Sep 11 11:53:34 2007 -0400
+@@ -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)); \
+- 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); \
+- *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.
+- * 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)
-{
@@ -34,9 +91,9 @@
-
- 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);
+- 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) {
@@ -65,26 +122,58 @@
- dpy_update(ds, x, y, w, h);
-}
-
--
--/* Send a keypress from the client to the guest OS */
--static void xen_pvfb_put_keycode(void *opaque, int keycode)
+-/*
+- * 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)
-{
-- struct xenfb *xenfb = (struct xenfb*)opaque;
-- xenfb_send_key(xenfb, keycode & 0x80 ? 0 : 1, keycode & 0x7f);
+- 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 */
+-/*
+- * 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 = (struct xenfb*)opaque;
+- 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);
+- dx * ds->width / 0x7fff,
+- dy * ds->height / 0x7fff);
- else
- xenfb_send_motion(xenfb, dx, dy);
-
@@ -101,25 +190,40 @@
-}
-
-/* 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 = (struct xenfb *)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)
-{
-- struct xenfb *xenfb = (struct xenfb *)opaque;
-- xen_pvfb_guest_copy(xenfb, 0, 0, xenfb->width, xenfb->height);
+- 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
-@@ -160,30 +49,11 @@ static void xen_init_pv(uint64_t ram_siz
+ * - 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 */
@@ -140,20 +244,17 @@
- xenfb);
-
- /* Register our keyboard & mouse handlers */
-- qemu_add_kbd_event_handler(xen_pvfb_put_keycode, xenfb);
+- 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);
- }
- QEMUMachine xenpv_machine = {
-diff -r c2aa6c7965a3 tools/ioemu/hw/xenfb.c
---- a/tools/ioemu/hw/xenfb.c Wed Aug 15 14:17:30 2007 -0400
-+++ b/tools/ioemu/hw/xenfb.c Tue Aug 21 22:04:25 2007 -0400
+ /* Setup QEMU display */
+ dpy_resize(ds, xenfb->width, xenfb->height);
+diff -r 93300915575f tools/ioemu/hw/xenfb.c
+--- a/tools/ioemu/hw/xenfb.c Tue Sep 11 11:53:28 2007 -0400
++++ b/tools/ioemu/hw/xenfb.c Tue Sep 11 11:53:34 2007 -0400
@@ -16,8 +16,8 @@
#include <string.h>
#include <time.h>
@@ -165,7 +266,84 @@
#include "xenfb.h"
// FIXME defend against malicious frontend?
-@@ -586,6 +586,177 @@ static int xenfb_on_state_change(struct
+@@ -43,6 +43,58 @@ struct xenfb_private {
+ char protocol[64]; /* frontend protocol */
+ };
+
++/* Functions which tie the PVFB into the QEMU device model */
++static void xenfb_key_event(void *opaque, int keycode);
++static void xenfb_mouse_event(void *opaque,
++ int dx, int dy, int dz, int button_state);
++static void xenfb_guest_copy(struct xenfb *xenfb, int x, int y, int w, int h);
++static void xenfb_update(void *opaque);
++static void xenfb_invalidate(void *opaque);
++static void xenfb_screen_dump(void *opaque, const char *name);
++
++/*
++ * 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];
++
++
+ static void xenfb_detach_dom(struct xenfb_private *);
+
+ static char *xenfb_path_in_dom(struct xs_handle *xsh,
+@@ -158,9 +210,17 @@ struct xenfb *xenfb_new(void)
+ {
+ struct xenfb_private *xenfb = malloc(sizeof(*xenfb));
+ int serrno;
++ int i;
+
+ if (xenfb == NULL)
+ return NULL;
++
++ /* 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];
++ }
+
+ memset(xenfb, 0, sizeof(*xenfb));
+ xenfb->evt_xch = xenfb->xc = -1;
+@@ -580,6 +640,68 @@ static int xenfb_on_state_change(struct
return 0;
}
@@ -230,120 +408,11 @@
+ return xenfb_kbd_event(xenfb, &event);
+}
+
-+/* Send a keypress from the client to the guest OS */
-+static void xenfb_put_keycode(void *opaque, int keycode)
-+{
-+ struct xenfb *xenfb = (struct xenfb*)opaque;
-+ xenfb_send_key(xenfb, keycode & 0x80 ? 0 : 1, keycode & 0x7f);
-+}
-+
-+/* Send a mouse event from the client to the guest OS */
-+static void xenfb_mouse_event(void *opaque,
-+ int dx, int dy, int dz, int button_state)
-+{
-+ int i;
-+ struct xenfb *xenfb = (struct 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 = xenfb->button_state & (1 << i);
-+ int down = button_state & (1 << i);
-+ if (down == lastDown)
-+ continue;
-+
-+ if (xenfb_send_key(xenfb, down, BTN_LEFT+i) < 0)
-+ return;
-+ }
-+ xenfb->button_state = button_state;
-+}
-+
-+/* 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 xenfb_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);
-+}
-+
-+/* QEMU display state changed, so refresh the framebuffer copy */
-+static void xenfb_update(void *opaque)
-+{
-+ struct xenfb *xenfb = (struct xenfb *)opaque;
-+ xenfb_guest_copy(xenfb, 0, 0, xenfb->width, xenfb->height);
-+}
-+
-+/* QEMU display state changed, so refresh the framebuffer copy */
-+static void xenfb_invalidate(void *opaque)
-+{
-+ struct xenfb *xenfb = (struct xenfb *)opaque;
-+ xenfb_guest_copy(xenfb, 0, 0, xenfb->width, xenfb->height);
-+}
-+
-+/* Screen dump is not used in Xen, so no need to impl this ? */
-+static void xenfb_screen_dump(void *opaque, const char *name) { }
-+
-+
+
static void xenfb_dispatch_channel(void *xenfb_pub)
{
struct xenfb_private *xenfb = (struct xenfb_private *)xenfb_pub;
-@@ -620,7 +791,7 @@ static void xenfb_dispatch_store(void *x
+@@ -614,7 +736,7 @@ static void xenfb_dispatch_store(void *x
}
@@ -352,12 +421,12 @@
{
struct xenfb_private *xenfb = (struct xenfb_private *)xenfb_pub;
struct xs_handle *xsh = xenfb->xsh;
-@@ -708,6 +879,23 @@ int xenfb_attach_dom(struct xenfb *xenfb
+@@ -702,6 +824,23 @@ int xenfb_attach_dom(struct xenfb *xenfb
if (qemu_set_fd_handler2(xc_evtchn_fd(xenfb->evt_xch), NULL, xenfb_dispatch_channel, NULL, xenfb) < 0)
goto error;
+ /* Register our keyboard & mouse handlers */
-+ qemu_add_kbd_event_handler(xenfb_put_keycode, xenfb);
++ qemu_add_kbd_event_handler(xenfb_key_event, xenfb);
+ qemu_add_mouse_event_handler(xenfb_mouse_event, xenfb,
+ xenfb_pub->abs_pointer_wanted,
+ "Xen PVFB Mouse");
@@ -376,7 +445,7 @@
return 0;
error:
-@@ -719,66 +907,6 @@ int xenfb_attach_dom(struct xenfb *xenfb
+@@ -713,66 +852,154 @@ int xenfb_attach_dom(struct xenfb *xenfb
return -1;
}
@@ -440,12 +509,160 @@
-
- return xenfb_kbd_event(xenfb, &event);
-}
++/*
++ * 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 xenfb_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 xenfb_mouse_event(void *opaque,
++ int dx, int dy, int dz, int button_state)
++{
++ 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 = xenfb->button_state & (1 << i);
++ int down = button_state & (1 << i);
++ if (down == lastDown)
++ continue;
++
++ if (xenfb_send_key(xenfb, down, BTN_LEFT+i) < 0)
++ return;
++ }
++ xenfb->button_state = button_state;
++}
++
++/* 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.
++ * When shifting between colour depths we preserve the MSB.
++ */
++static void xenfb_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);
++}
++
++/* QEMU display state changed, so refresh the framebuffer copy */
++/* XXX - can we optimize this, or the next func at all ? */
++static void xenfb_update(void *opaque)
++{
++ struct xenfb *xenfb = opaque;
++ xenfb_guest_copy(xenfb, 0, 0, xenfb->width, xenfb->height);
++}
++
++/* QEMU display state changed, so refresh the framebuffer copy */
++static void xenfb_invalidate(void *opaque)
++{
++ struct xenfb *xenfb = opaque;
++ xenfb_guest_copy(xenfb, 0, 0, xenfb->width, xenfb->height);
++}
++
++/* Screen dump is not used in Xen, so no need to impl this....yet */
++static void xenfb_screen_dump(void *opaque, const char *name) { }
++
++
/*
* Local variables:
* c-indent-level: 8
-diff -r c2aa6c7965a3 tools/ioemu/hw/xenfb.h
---- a/tools/ioemu/hw/xenfb.h Wed Aug 15 14:17:30 2007 -0400
-+++ b/tools/ioemu/hw/xenfb.h Tue Aug 21 22:03:27 2007 -0400
+diff -r 93300915575f tools/ioemu/hw/xenfb.h
+--- a/tools/ioemu/hw/xenfb.h Tue Sep 11 11:53:28 2007 -0400
++++ b/tools/ioemu/hw/xenfb.h Tue Sep 11 11:53:34 2007 -0400
@@ -1,6 +1,7 @@
#ifndef _XENFB_H_
#define _XENFB_H_
xen-pvfb-06-xenfb-pubpriv-merge.patch:
Index: xen-pvfb-06-xenfb-pubpriv-merge.patch
===================================================================
RCS file: /cvs/pkgs/rpms/xen/devel/Attic/xen-pvfb-06-xenfb-pubpriv-merge.patch,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- xen-pvfb-06-xenfb-pubpriv-merge.patch 19 Oct 2007 23:35:08 -0000 1.1.2.1
+++ xen-pvfb-06-xenfb-pubpriv-merge.patch 24 Oct 2007 20:02:57 -0000 1.1.2.2
@@ -1,6 +1,34 @@
-diff -r 9fcb930c2353 tools/ioemu/hw/xenfb.c
---- a/tools/ioemu/hw/xenfb.c Fri Oct 19 17:42:35 2007 -0400
-+++ b/tools/ioemu/hw/xenfb.c Fri Oct 19 17:43:41 2007 -0400
+This 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(-)
+
+ Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
+
+
+diff -r 58cc6fb7824c tools/ioemu/hw/xen_machine_pv.c
+--- a/tools/ioemu/hw/xen_machine_pv.c Tue Sep 11 11:53:35 2007 -0400
++++ b/tools/ioemu/hw/xen_machine_pv.c Tue Sep 11 11:55:15 2007 -0400
+@@ -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 = {
+diff -r 58cc6fb7824c tools/ioemu/hw/xenfb.c
+--- a/tools/ioemu/hw/xenfb.c Tue Sep 11 11:53:35 2007 -0400
++++ b/tools/ioemu/hw/xenfb.c Tue Sep 11 11:55:15 2007 -0400
@@ -22,6 +22,8 @@
// FIXME defend against malicious frontend?
@@ -10,7 +38,7 @@
struct xenfb_device {
const char *devicetype;
char nodename[64]; /* backend xenstore dir */
-@@ -30,20 +32,33 @@ struct xenfb_device {
+@@ -30,16 +32,23 @@ struct xenfb_device {
enum xenbus_state state; /* backend state */
void *page; /* shared page */
evtchn_port_t port;
@@ -20,36 +48,33 @@
-struct xenfb_private {
- struct xenfb pub;
-+struct xenfb_data
-+{
-+ void *pixels;
-+ size_t len;
-+
-+ int row_stride;
-+ int depth;
-+ int width;
-+ int height;
-+ int abs_pointer_wanted;
-+};
-+
+struct xenfb {
-+ DisplayState *ds;
++ DisplayState *ds; /* QEMU graphical console state */
int evt_xch; /* event channel driver handle */
int xc; /* hypervisor interface handle */
struct xs_handle *xsh; /* xs daemon handle */
struct xenfb_device fb, kbd;
-- size_t fb_len; /* size of framebuffer */
-+ struct xenfb_data data;
++ void *pixels; /* guest framebuffer data */
+ size_t fb_len; /* size of framebuffer */
++ int row_stride; /* width of one row in framebuffer */
++ int depth; /* colour depth of guest framebuffer */
++ int width; /* pixel width of guest framebuffer */
++ int height; /* pixel height of guest framebuffer */
++ int abs_pointer_wanted; /* Whether guest supports absolute pointer */
++ int button_state; /* Last seen pointer button state */
char protocol[64]; /* frontend protocol */
-+ int button_state;
};
+@@ -95,7 +104,7 @@ static unsigned char scancode2linux[512]
+ static unsigned char scancode2linux[512];
+
+
-static void xenfb_detach_dom(struct xenfb_private *);
+static void xenfb_detach_dom(struct xenfb *);
static char *xenfb_path_in_dom(struct xs_handle *xsh,
char *buf, size_t size,
-@@ -124,7 +139,7 @@ static int xenfb_xs_printf(struct xs_han
+@@ -176,7 +185,7 @@ static int xenfb_xs_printf(struct xs_han
static void xenfb_device_init(struct xenfb_device *dev,
const char *type,
@@ -58,7 +83,7 @@
{
dev->devicetype = type;
dev->otherend_id = -1;
-@@ -132,19 +147,17 @@ static void xenfb_device_init(struct xen
+@@ -184,19 +193,17 @@ static void xenfb_device_init(struct xen
dev->xenfb = xenfb;
}
@@ -82,17 +107,16 @@
dev->nodename, sizeof(dev->nodename),
0, "backend/%s/%d/0", dev->devicetype, domid)) {
errno = ENOENT;
-@@ -156,8 +169,8 @@ int xenfb_device_set_domain(struct xenfb
+@@ -208,7 +215,7 @@ int xenfb_device_set_domain(struct xenfb
struct xenfb *xenfb_new(void)
{
- struct xenfb_private *xenfb = malloc(sizeof(*xenfb));
- int serrno;
+ struct xenfb *xenfb = qemu_malloc(sizeof(struct xenfb));
+ int serrno;
+ int i;
- if (xenfb == NULL)
- return NULL;
-@@ -179,30 +192,26 @@ struct xenfb *xenfb_new(void)
+@@ -239,30 +246,26 @@ struct xenfb *xenfb_new(void)
if (!xenfb->xsh)
goto fail;
@@ -129,7 +153,7 @@
xenfb_detach_dom(xenfb);
if (xenfb->xc >= 0)
xc_interface_close(xenfb->xc);
-@@ -334,7 +343,7 @@ static void xenfb_copy_mfns(int mode, in
+@@ -394,7 +397,7 @@ static void xenfb_copy_mfns(int mode, in
dst[i] = (mode == 32) ? src32[i] : src64[i];
}
@@ -138,28 +162,19 @@
{
struct xenfb_page *page = xenfb->fb.page;
int n_fbmfns;
-@@ -389,7 +398,7 @@ static int xenfb_map_fb(struct xenfb_pri
- #endif
- }
-
-- n_fbmfns = (xenfb->fb_len + (XC_PAGE_SIZE - 1)) / XC_PAGE_SIZE;
-+ n_fbmfns = (xenfb->data.len + (XC_PAGE_SIZE - 1)) / XC_PAGE_SIZE;
- n_fbdirs = n_fbmfns * mode / 8;
- n_fbdirs = (n_fbdirs + (XC_PAGE_SIZE - 1)) / XC_PAGE_SIZE;
-
-@@ -406,9 +415,9 @@ static int xenfb_map_fb(struct xenfb_pri
+@@ -466,9 +469,9 @@ static int xenfb_map_fb(struct xenfb_pri
xenfb_copy_mfns(mode, n_fbmfns, fbmfns, map);
munmap(map, n_fbdirs * XC_PAGE_SIZE);
- xenfb->pub.pixels = xc_map_foreign_pages(xenfb->xc, domid,
-+ xenfb->data.pixels = xc_map_foreign_pages(xenfb->xc, domid,
++ xenfb->pixels = xc_map_foreign_pages(xenfb->xc, domid,
PROT_READ | PROT_WRITE, fbmfns, n_fbmfns);
- if (xenfb->pub.pixels == NULL)
-+ if (xenfb->data.pixels == NULL)
++ if (xenfb->pixels == NULL)
goto out;
ret = 0; /* all is fine */
-@@ -423,7 +432,7 @@ static int xenfb_map_fb(struct xenfb_pri
+@@ -483,7 +486,7 @@ static int xenfb_map_fb(struct xenfb_pri
static int xenfb_bind(struct xenfb_device *dev)
{
@@ -168,7 +183,7 @@
unsigned long mfn;
evtchn_port_t evtchn;
-@@ -506,17 +515,74 @@ static void xenfb_dev_fatal(struct xenfb
+@@ -566,17 +569,18 @@ static void xenfb_dev_fatal(struct xenfb
}
@@ -184,74 +199,18 @@
-}
-
-static void xenfb_on_fb_event(struct xenfb_private *xenfb)
-+ if (xenfb->data.pixels) {
-+ munmap(xenfb->data.pixels, xenfb->data.len);
-+ xenfb->data.pixels = NULL;
++ if (xenfb->pixels) {
++ munmap(xenfb->pixels, xenfb->fb_len);
++ xenfb->pixels = NULL;
+ }
+}
+
-+/* 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->data.pixels + (line*xenfb->data.row_stride) + (x*xenfb->data.depth/8)); \
-+ DST_T *dst = (DST_T *)(xenfb->ds->data + (line*xenfb->ds->linesize) + (x*xenfb->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 xenfb_guest_copy(struct xenfb *xenfb, int x, int y, int w, int h)
-+{
-+ int line;
-+
-+ if (xenfb->data.depth == xenfb->ds->depth) { /* Perfect match can use fast path */
-+ for (line = y ; line < (y+h) ; line++) {
-+ memcpy(xenfb->ds->data + (line * xenfb->ds->linesize) + (x*xenfb->ds->depth/8),
-+ xenfb->data.pixels + (line*xenfb->data.row_stride) + (x*xenfb->data.depth/8),
-+ w * xenfb->data.depth/8);
-+ }
-+ } else { /* Mismatch requires slow pixel munging */
-+ if (xenfb->data.depth == 8) {
-+ /* 8 bit source == r:3 g:3 b:2 */
-+ if (xenfb->ds->depth == 16) {
-+ BLT(uint8_t, uint16_t, 5, 2, 0, 11, 5, 0, 7, 7, 3);
-+ } else if (xenfb->ds->depth == 32) {
-+ BLT(uint8_t, uint32_t, 5, 2, 0, 16, 8, 0, 7, 7, 3);
-+ }
-+ } else if (xenfb->data.depth == 16) {
-+ /* 16 bit source == r:5 g:6 b:5 */
-+ if (xenfb->ds->depth == 8) {
-+ BLT(uint16_t, uint8_t, 11, 5, 0, 5, 2, 0, 31, 63, 31);
-+ } else if (xenfb->ds->depth == 32) {
-+ BLT(uint16_t, uint32_t, 11, 5, 0, 16, 8, 0, 31, 63, 31);
-+ }
-+ } else if (xenfb->data.depth == 32) {
-+ /* 32 bit source == r:8 g:8 b:8 (padding:8) */
-+ if (xenfb->ds->depth == 8) {
-+ BLT(uint32_t, uint8_t, 16, 8, 0, 5, 2, 0, 255, 255, 255);
-+ } else if (xenfb->ds->depth == 16) {
-+ BLT(uint32_t, uint16_t, 16, 8, 0, 11, 5, 0, 255, 255, 255);
-+ }
-+ }
-+ }
-+ dpy_update(xenfb->ds, x, y, w, h);
-+}
+
+static void xenfb_on_fb_event(struct xenfb *xenfb)
{
uint32_t prod, cons;
struct xenfb_page *page = xenfb->fb.page;
-@@ -530,11 +596,10 @@ static void xenfb_on_fb_event(struct xen
+@@ -590,11 +594,10 @@ static void xenfb_on_fb_event(struct xen
switch (event->type) {
case XENFB_TYPE_UPDATE:
@@ -267,7 +226,7 @@
}
}
mb(); /* ensure we're done with ring contents */
-@@ -542,7 +607,7 @@ static void xenfb_on_fb_event(struct xen
+@@ -602,7 +605,7 @@ static void xenfb_on_fb_event(struct xen
xc_evtchn_notify(xenfb->evt_xch, xenfb->fb.port);
}
@@ -276,7 +235,7 @@
{
struct xenkbd_page *page = xenfb->kbd.page;
-@@ -580,7 +645,7 @@ static int xenfb_on_state_change(struct
+@@ -640,7 +643,7 @@ static int xenfb_on_state_change(struct
return 0;
}
@@ -285,7 +244,7 @@
union xenkbd_in_event *event)
{
uint32_t prod;
-@@ -602,9 +667,8 @@ static int xenfb_kbd_event(struct xenfb_
+@@ -662,9 +665,8 @@ static int xenfb_kbd_event(struct xenfb_
return xc_evtchn_notify(xenfb->evt_xch, xenfb->kbd.port);
}
@@ -297,7 +256,7 @@
union xenkbd_in_event event;
memset(&event, 0, XENKBD_IN_EVENT_SIZE);
-@@ -615,9 +679,8 @@ static int xenfb_send_key(struct xenfb *
+@@ -675,9 +677,8 @@ static int xenfb_send_key(struct xenfb *
return xenfb_kbd_event(xenfb, &event);
}
@@ -309,7 +268,7 @@
union xenkbd_in_event event;
memset(&event, 0, XENKBD_IN_EVENT_SIZE);
-@@ -628,9 +691,8 @@ static int xenfb_send_motion(struct xenf
+@@ -688,9 +689,8 @@ static int xenfb_send_motion(struct xenf
return xenfb_kbd_event(xenfb, &event);
}
@@ -321,104 +280,9 @@
union xenkbd_in_event event;
memset(&event, 0, XENKBD_IN_EVENT_SIZE);
-@@ -654,11 +716,11 @@ static void xenfb_mouse_event(void *opaq
- {
- int i;
- struct xenfb *xenfb = (struct xenfb*)opaque;
-- DisplayState *ds = (DisplayState *)xenfb->user_data;
-- if (xenfb->abs_pointer_wanted)
-+
-+ if (xenfb->data.abs_pointer_wanted)
- xenfb_send_position(xenfb,
-- dx*ds->width/0x7fff,
-- dy*ds->height/0x7fff);
-+ dx*xenfb->ds->width/0x7fff,
-+ dy*xenfb->ds->height/0x7fff);
- else
- xenfb_send_motion(xenfb, dx, dy);
-
-@@ -674,76 +736,19 @@ static void xenfb_mouse_event(void *opaq
- xenfb->button_state = button_state;
- }
-
--/* 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 xenfb_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);
--}
-
- /* QEMU display state changed, so refresh the framebuffer copy */
- static void xenfb_update(void *opaque)
- {
- struct xenfb *xenfb = (struct xenfb *)opaque;
-- xenfb_guest_copy(xenfb, 0, 0, xenfb->width, xenfb->height);
-+ xenfb_guest_copy(xenfb, 0, 0, xenfb->data.width, xenfb->data.height);
- }
-
- /* QEMU display state changed, so refresh the framebuffer copy */
- static void xenfb_invalidate(void *opaque)
- {
- struct xenfb *xenfb = (struct xenfb *)opaque;
-- xenfb_guest_copy(xenfb, 0, 0, xenfb->width, xenfb->height);
-+ xenfb_guest_copy(xenfb, 0, 0, xenfb->data.width, xenfb->data.height);
+@@ -702,9 +702,9 @@ static int xenfb_send_position(struct xe
}
- /* Screen dump is not used in Xen, so no need to impl this ? */
-@@ -751,9 +756,9 @@ static void xenfb_screen_dump(void *opaq
-
-
-static void xenfb_dispatch_channel(void *xenfb_pub)
-{
@@ -429,7 +293,7 @@
evtchn_port_t port;
port = xc_evtchn_pending(xenfb->evt_xch);
if (port == -1)
-@@ -768,9 +773,9 @@ static void xenfb_dispatch_channel(void
+@@ -719,9 +719,9 @@ static void xenfb_dispatch_channel(void
exit(1);
}
@@ -442,7 +306,7 @@
unsigned dummy;
char **vec;
int r;
-@@ -785,9 +790,8 @@ static void xenfb_dispatch_store(void *x
+@@ -736,9 +736,8 @@ static void xenfb_dispatch_store(void *x
}
@@ -454,39 +318,38 @@
struct xs_handle *xsh = xenfb->xsh;
int val, serrno;
struct xenfb_page *fb_page;
-@@ -843,12 +847,12 @@ int xenfb_attach_dom(struct xenfb *xenfb
+@@ -794,12 +793,12 @@ int xenfb_attach_dom(struct xenfb *xenfb
/* TODO check for permitted ranges */
fb_page = xenfb->fb.page;
- xenfb->pub.depth = fb_page->depth;
- xenfb->pub.width = fb_page->width;
- xenfb->pub.height = fb_page->height;
-+ xenfb->data.depth = fb_page->depth;
-+ xenfb->data.width = fb_page->width;
-+ xenfb->data.height = fb_page->height;
++ xenfb->depth = fb_page->depth;
++ xenfb->width = fb_page->width;
++ xenfb->height = fb_page->height;
/* TODO check for consistency with the above */
-- xenfb->fb_len = fb_page->mem_length;
+ xenfb->fb_len = fb_page->mem_length;
- xenfb->pub.row_stride = fb_page->line_length;
-+ xenfb->data.len = fb_page->mem_length;
-+ xenfb->data.row_stride = fb_page->line_length;
++ xenfb->row_stride = fb_page->line_length;
if (xenfb_map_fb(xenfb, domid) < 0)
goto error;
-@@ -863,7 +867,7 @@ int xenfb_attach_dom(struct xenfb *xenfb
+@@ -814,7 +813,7 @@ int xenfb_attach_dom(struct xenfb *xenfb
if (xenfb_xs_scanf1(xsh, xenfb->kbd.otherend, "request-abs-pointer",
"%d", &val) < 0)
val = 0;
- xenfb->pub.abs_pointer_wanted = val;
-+ xenfb->data.abs_pointer_wanted = val;
++ xenfb->abs_pointer_wanted = val;
/* Listen for events from xenstore */
if (qemu_set_fd_handler2(xs_fileno(xenfb->xsh), NULL, xenfb_dispatch_store, NULL, xenfb) < 0)
-@@ -876,19 +880,18 @@ int xenfb_attach_dom(struct xenfb *xenfb
+@@ -827,19 +826,18 @@ int xenfb_attach_dom(struct xenfb *xenfb
/* Register our keyboard & mouse handlers */
- qemu_add_kbd_event_handler(xenfb_put_keycode, xenfb);
+ qemu_add_kbd_event_handler(xenfb_key_event, xenfb);
qemu_add_mouse_event_handler(xenfb_mouse_event, xenfb,
- xenfb_pub->abs_pointer_wanted,
-+ xenfb->data.abs_pointer_wanted,
++ xenfb->abs_pointer_wanted,
"Xen PVFB Mouse");
- xenfb_pub->update = xenfb_guest_copy;
@@ -501,13 +364,90 @@
- xenfb_pub);
- dpy_resize(ds, xenfb_pub->width, xenfb_pub->height);
+ xenfb);
-+ dpy_resize(ds, xenfb->data.width, xenfb->data.height);
++ dpy_resize(ds, xenfb->width, xenfb->height);
return 0;
-diff -r 9fcb930c2353 tools/ioemu/hw/xenfb.h
---- a/tools/ioemu/hw/xenfb.h Fri Oct 19 17:42:35 2007 -0400
-+++ b/tools/ioemu/hw/xenfb.h Fri Oct 19 17:42:36 2007 -0400
+@@ -898,11 +896,10 @@ static void xenfb_mouse_event(void *opaq
+ {
+ 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);
++ dx * xenfb->ds->width / 0x7fff,
++ dy * xenfb->ds->height / 0x7fff);
+ else
+ xenfb_send_motion(xenfb, dx, dy);
+
+@@ -924,9 +921,9 @@ static void xenfb_mouse_event(void *opaq
+ 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)); \
++ DST_T *dst = (DST_T *)(xenfb->ds->data \
++ + (line * xenfb->ds->linesize) \
++ + (x * xenfb->ds->depth / 8)); \
+ int col; \
+ for (col = x ; col < w ; col++) { \
+ *dst = (((*src >> RRS) & RM) << RLS) | \
+@@ -945,40 +942,39 @@ static void xenfb_mouse_event(void *opaq
+ */
+ static void xenfb_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 */
++ if (xenfb->depth == xenfb->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),
++ memcpy(xenfb->ds->data + (line * xenfb->ds->linesize) + (x * xenfb->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) {
++ if (xenfb->ds->depth == 16) {
+ BLT(uint8_t, uint16_t, 5, 2, 0, 11, 5, 0, 7, 7, 3);
+- } else if (ds->depth == 32) {
++ } else if (xenfb->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) {
++ if (xenfb->ds->depth == 8) {
+ BLT(uint16_t, uint8_t, 11, 5, 0, 5, 2, 0, 31, 63, 31);
+- } else if (ds->depth == 32) {
++ } else if (xenfb->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) {
++ if (xenfb->ds->depth == 8) {
+ BLT(uint32_t, uint8_t, 16, 8, 0, 5, 2, 0, 255, 255, 255);
+- } else if (ds->depth == 16) {
++ } else if (xenfb->ds->depth == 16) {
+ BLT(uint32_t, uint16_t, 16, 8, 0, 11, 5, 0, 255, 255, 255);
+ }
+ }
+ }
+- dpy_update(ds, x, y, w, h);
++ dpy_update(xenfb->ds, x, y, w, h);
+ }
+
+ /* QEMU display state changed, so refresh the framebuffer copy */
+diff -r 58cc6fb7824c tools/ioemu/hw/xenfb.h
+--- a/tools/ioemu/hw/xenfb.h Tue Sep 11 11:53:35 2007 -0400
++++ b/tools/ioemu/hw/xenfb.h Tue Sep 11 11:55:15 2007 -0400
@@ -5,21 +5,7 @@
#include <stdbool.h>
#include <sys/types.h>
xen-pvfb-07-xenfb-async-startup.patch:
Index: xen-pvfb-07-xenfb-async-startup.patch
===================================================================
RCS file: /cvs/pkgs/rpms/xen/devel/Attic/xen-pvfb-07-xenfb-async-startup.patch,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- xen-pvfb-07-xenfb-async-startup.patch 19 Oct 2007 23:35:08 -0000 1.1.2.1
+++ xen-pvfb-07-xenfb-async-startup.patch 24 Oct 2007 20:02:57 -0000 1.1.2.2
@@ -1,7 +1,38 @@
-diff -r 829464d36542 tools/ioemu/hw/xen_machine_pv.c
---- a/tools/ioemu/hw/xen_machine_pv.c Tue Aug 21 22:07:47 2007 -0400
-+++ b/tools/ioemu/hw/xen_machine_pv.c Tue Aug 21 22:08:24 2007 -0400
-@@ -41,16 +41,9 @@ static void xen_init_pv(uint64_t ram_siz
+This 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(-)
+
+ Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
+
+
+diff -r bed4c2406f8b tools/ioemu/hw/xen_machine_pv.c
+--- a/tools/ioemu/hw/xen_machine_pv.c Tue Sep 11 11:55:15 2007 -0400
++++ b/tools/ioemu/hw/xen_machine_pv.c Tue Sep 11 11:56:11 2007 -0400
+@@ -40,16 +40,9 @@ static void xen_init_pv(uint64_t ram_siz
extern int domid;
/* Prepare PVFB state */
@@ -19,60 +50,119 @@
strerror(errno));
exit(1);
}
-diff -r 829464d36542 tools/ioemu/hw/xenfb.c
---- a/tools/ioemu/hw/xenfb.c Tue Aug 21 22:07:47 2007 -0400
-+++ b/tools/ioemu/hw/xenfb.c Tue Aug 21 22:14:04 2007 -0400
-@@ -19,6 +19,12 @@
- #include <linux/input.h>
-
- #include "xenfb.h"
-+#define DEBUG 1
-+#if DEBUG
-+#define LOGF(msg,...) fprintf(stderr, msg, ## __VA_ARGS__)
-+#else
-+#define LOGF(msg,...) do { } while (0)
-+#endif
+diff -r bed4c2406f8b tools/ioemu/hw/xenfb.c
+--- a/tools/ioemu/hw/xenfb.c Tue Sep 11 11:55:15 2007 -0400
++++ b/tools/ioemu/hw/xenfb.c Tue Sep 11 11:56:11 2007 -0400
+@@ -52,6 +52,20 @@ struct xenfb {
+ char protocol[64]; /* frontend protocol */
+ };
+
++/* Functions for frontend/backend state machine*/
++static int xenfb_wait_for_frontend(struct xenfb_device *dev, IOHandler *handler);
++static int xenfb_wait_for_backend(struct xenfb_device *dev, IOHandler *handler);
++static void xenfb_backend_created_kbd(void *opaque);
++static void xenfb_backend_created_fb(void *opaque);
++static void xenfb_frontend_initialized_kbd(void *opaque);
++static void xenfb_frontend_initialized_fb(void *opaque);
++static void xenfb_frontend_connected_kbd(void *opaque);
++
++/* Helper functions for checking state of frontend/backend devices */
++static int xenfb_frontend_connected(struct xenfb_device *dev);
++static int xenfb_frontend_initialized(struct xenfb_device *dev);
++static int xenfb_backend_created(struct xenfb_device *dev);
++
+ /* Functions which tie the PVFB into the QEMU device model */
+ static void xenfb_key_event(void *opaque, int keycode);
+ static void xenfb_mouse_event(void *opaque,
+@@ -60,6 +74,7 @@ static void xenfb_update(void *opaque);
+ static void xenfb_update(void *opaque);
+ static void xenfb_invalidate(void *opaque);
+ static void xenfb_screen_dump(void *opaque, const char *name);
++static int xenfb_register_console(struct xenfb *xenfb);
- // FIXME defend against malicious frontend?
+ /*
+ * Tables to map from scancode to Linux input layer keycode.
+@@ -103,34 +118,6 @@ static const unsigned char atkbd_unxlate
-@@ -167,60 +173,6 @@ static int xenfb_device_set_domain(struc
- return 0;
- }
+ static unsigned char scancode2linux[512];
--struct xenfb *xenfb_new(void)
+-
+-static void xenfb_detach_dom(struct xenfb *);
+-
+-static char *xenfb_path_in_dom(struct xs_handle *xsh,
+- char *buf, size_t size,
+- unsigned domid, const char *fmt, ...)
-{
-- int serrno;
-- struct xenfb *xenfb = qemu_malloc(sizeof(struct xenfb));
+- va_list ap;
+- char *domp = xs_get_domain_path(xsh, domid);
+- int n;
-
-- if (xenfb == NULL)
+- if (domp == NULL)
- return NULL;
-
-- memset(xenfb, 0, sizeof(*xenfb));
-- xenfb->evt_xch = xenfb->xc = -1;
-- xenfb_device_init(&xenfb->fb, "vfb", xenfb);
-- xenfb_device_init(&xenfb->kbd, "vkbd", xenfb);
--
-- xenfb->evt_xch = xc_evtchn_open();
-- if (xenfb->evt_xch == -1)
-- goto fail;
--
-- xenfb->xc = xc_interface_open();
-- if (xenfb->xc == -1)
-- goto fail;
--
-- xenfb->xsh = xs_daemon_open();
-- if (!xenfb->xsh)
-- goto fail;
+- n = snprintf(buf, size, "%s/", domp);
+- free(domp);
+- if (n >= size)
+- return NULL;
-
-- return xenfb;
+- va_start(ap, fmt);
+- n += vsnprintf(buf + n, size - n, fmt, ap);
+- va_end(ap);
+- if (n >= size)
+- return NULL;
-
-- fail:
-- serrno = errno;
-- xenfb_delete(xenfb);
-- errno = serrno;
-- return NULL;
+- return buf;
-}
-
+ static int xenfb_xs_scanf1(struct xs_handle *xsh,
+ const char *dir, const char *node,
+ const char *fmt, void *dest)
+@@ -193,27 +180,7 @@ static void xenfb_device_init(struct xen
+ dev->xenfb = xenfb;
+ }
+
+-static int xenfb_device_set_domain(struct xenfb_device *dev, int domid)
+-{
+- dev->otherend_id = domid;
+-
+- if (!xenfb_path_in_dom(dev->xenfb->xsh,
+- dev->otherend, sizeof(dev->otherend),
+- domid, "device/%s/0", dev->devicetype)) {
+- errno = ENOENT;
+- return -1;
+- }
+- if (!xenfb_path_in_dom(dev->xenfb->xsh,
+- dev->nodename, sizeof(dev->nodename),
+- 0, "backend/%s/%d/0", dev->devicetype, domid)) {
+- errno = ENOENT;
+- return -1;
+- }
+-
+- return 0;
+-}
+-
+-struct xenfb *xenfb_new(void)
++struct xenfb *xenfb_new(int domid, DisplayState *ds)
+ {
+ struct xenfb *xenfb = qemu_malloc(sizeof(struct xenfb));
+ int serrno;
+@@ -246,35 +213,18 @@ struct xenfb *xenfb_new(void)
+ if (!xenfb->xsh)
+ goto fail;
+
++ fprintf(stderr, "FB: Waiting for KBD backend creation\n");
++ xenfb_wait_for_backend(&xenfb->kbd, xenfb_backend_created_kbd);
++
+ return xenfb;
+
+ fail:
+ serrno = errno;
+- xenfb_delete(xenfb);
++ xenfb_shutdown(xenfb);
+ errno = serrno;
+ return NULL;
+ }
+
-/* Remove the backend area in xenbus since the framebuffer really is
- going away. */
-void xenfb_teardown(struct xenfb *xenfb)
@@ -96,26 +186,10 @@
static enum xenbus_state xenfb_read_state(struct xs_handle *xsh,
const char *dir)
-@@ -228,6 +180,7 @@ static enum xenbus_state xenfb_read_stat
- int ret, state;
-
- ret = xenfb_xs_scanf1(xsh, dir, "state", "%d", &state);
-+ LOGF("FB: read state %d %d\n", state, ret);
- if (ret < 0)
- return XenbusStateUnknown;
+@@ -301,89 +251,12 @@ static int xenfb_switch_state(struct xen
+ return 0;
+ }
-@@ -240,65 +193,10 @@ static int xenfb_switch_state(struct xen
- enum xenbus_state state)
- {
- struct xs_handle *xsh = dev->xenfb->xsh;
--
-+ /*LOGF("FB: write state %d\n", state);*/
- if (xenfb_xs_printf(xsh, dev->nodename, "state", "%d", state) < 0)
- return -1;
- dev->state = state;
-- return 0;
--}
--
-static int xenfb_wait_for_state(struct xs_handle *xsh, const char *dir,
- unsigned awaited)
-{
@@ -168,13 +242,17 @@
- return -1;
- }
-
- return 0;
- }
-
-@@ -310,28 +208,6 @@ static int xenfb_hotplug(struct xenfb_de
- return 0;
- }
+- return 0;
+-}
+ static int xenfb_hotplug(struct xenfb_device *dev)
+ {
+ if (xenfb_xs_printf(dev->xenfb->xsh, dev->nodename,
+ "hotplug-status", "connected"))
+ return -1;
+- return 0;
+-}
+-
-static int xenfb_wait_for_frontend_initialised(struct xenfb_device *dev)
-{
- switch (xenfb_wait_for_state(dev->xenfb->xsh, dev->otherend,
@@ -195,12 +273,10 @@
- return -1;
- }
-
-- return 0;
--}
+ return 0;
+ }
- static void xenfb_copy_mfns(int mode, int count, unsigned long *dst, void *src)
- {
-@@ -474,52 +350,6 @@ static void xenfb_unbind(struct xenfb_de
+@@ -522,52 +395,6 @@ static void xenfb_unbind(struct xenfb_de
}
}
@@ -253,16 +329,48 @@
static void xenfb_detach_dom(struct xenfb *xenfb)
{
-@@ -673,6 +503,8 @@ static int xenfb_kbd_event(struct xenfb
+@@ -577,6 +404,24 @@ static void xenfb_detach_dom(struct xenf
+ munmap(xenfb->pixels, xenfb->fb_len);
+ xenfb->pixels = NULL;
+ }
++}
++
++/* Remove the backend area in xenbus since the framebuffer really is
++ going away. */
++void xenfb_shutdown(struct xenfb *xenfb)
++{
++ fprintf(stderr, "FB: Shutting down backend\n");
++ xs_rm(xenfb->xsh, XBT_NULL, xenfb->fb.nodename);
++ xs_rm(xenfb->xsh, XBT_NULL, xenfb->kbd.nodename);
++
++ xenfb_detach_dom(xenfb);
++ if (xenfb->xc >= 0)
++ xc_interface_close(xenfb->xc);
++ if (xenfb->evt_xch >= 0)
++ xc_evtchn_close(xenfb->evt_xch);
++ if (xenfb->xsh)
++ xs_daemon_close(xenfb->xsh);
++ free(xenfb);
+ }
+
+
+@@ -643,6 +488,7 @@ static int xenfb_on_state_change(struct
+ return 0;
+ }
+
++/* Send an event to the keyboard frontend driver */
+ static int xenfb_kbd_event(struct xenfb *xenfb,
+ union xenkbd_in_event *event)
+ {
+@@ -665,6 +511,7 @@ static int xenfb_kbd_event(struct xenfb
return xc_evtchn_notify(xenfb->evt_xch, xenfb->kbd.port);
}
-+
+/* Send a keyboard (or mouse button) event */
static int xenfb_send_key(struct xenfb *xenfb, bool down, int keycode)
{
union xenkbd_in_event event;
-@@ -685,10 +517,11 @@ static int xenfb_send_key(struct xenfb *
+@@ -677,6 +524,7 @@ static int xenfb_send_key(struct xenfb *
return xenfb_kbd_event(xenfb, &event);
}
@@ -270,12 +378,7 @@
static int xenfb_send_motion(struct xenfb *xenfb, int rel_x, int rel_y)
{
union xenkbd_in_event event;
--
-+ LOGF("REL %d %d\n", rel_x, rel_y);
- memset(&event, 0, XENKBD_IN_EVENT_SIZE);
- event.type = XENKBD_TYPE_MOTION;
- event.motion.rel_x = rel_x;
-@@ -697,10 +530,11 @@ static int xenfb_send_motion(struct xenf
+@@ -689,6 +537,7 @@ static int xenfb_send_motion(struct xenf
return xenfb_kbd_event(xenfb, &event);
}
@@ -283,24 +386,10 @@
static int xenfb_send_position(struct xenfb *xenfb, int abs_x, int abs_y)
{
union xenkbd_in_event event;
--
-+ LOGF("ABS %d %d\n", abs_x, abs_y);
- memset(&event, 0, XENKBD_IN_EVENT_SIZE);
- event.type = XENKBD_TYPE_POS;
- event.pos.abs_x = abs_x;
-@@ -753,161 +587,459 @@ static void xenfb_update(void *opaque)
- /* QEMU display state changed, so refresh the framebuffer copy */
- static void xenfb_invalidate(void *opaque)
- {
-- struct xenfb *xenfb = (struct xenfb *)opaque;
-- xenfb_guest_copy(xenfb, 0, 0, xenfb->data.width, xenfb->data.height);
-+ xenfb_update(opaque);
+@@ -701,24 +550,29 @@ static int xenfb_send_position(struct xe
+ return xenfb_kbd_event(xenfb, &event);
}
- /* Screen dump is not used in Xen, so no need to impl this ? */
- static void xenfb_screen_dump(void *opaque, const char *name) { }
-
-
-
+/* Process events from the frontend event channel */
static void xenfb_dispatch_channel(void *opaque)
@@ -325,20 +414,21 @@
exit(1);
-}
-
--static void xenfb_dispatch_store(void *opaque)
--{
-- struct xenfb *xenfb = (struct xenfb *)opaque;
-- unsigned dummy;
-- char **vec;
-- int r;
--
-- vec = xs_read_watch(xenfb->xsh, &dummy);
-- free(vec);
-- r = xenfb_on_state_change(&xenfb->fb);
-- if (r == 0)
-- r = xenfb_on_state_change(&xenfb->kbd);
++ }
++}
++
++/* Process ongoing events from the frontend devices */
+ static void xenfb_dispatch_store(void *opaque)
+ {
+ struct xenfb *xenfb = (struct xenfb *)opaque;
+@@ -731,124 +585,347 @@ static void xenfb_dispatch_store(void *o
+ r = xenfb_on_state_change(&xenfb->fb);
+ if (r == 0)
+ r = xenfb_on_state_change(&xenfb->kbd);
- if (r == -1)
-- exit(1);
++ if (r < 0) {
++ xenfb_shutdown(xenfb);
+ exit(1);
-}
-
-
@@ -350,48 +440,13 @@
+}
+
+
-+/* Process ongoing events from the frontend devices */
-+static void xenfb_frontend_disconnected_kbd(void *opaque)
-+{
-+ struct xenfb_device *dev = (struct xenfb_device *)opaque;
-+ unsigned dummy;
-+ char **vec;
-+ int r;
-+ vec = xs_read_watch(dev->xenfb->xsh, &dummy);
-+ free(vec);
-+
-+ r = xenfb_on_state_change(&dev->xenfb->kbd);
-+ if (r >= 0)
-+ r = xenfb_on_state_change(&dev->xenfb->fb);
-+
-+ if (r < 0) {
-+ xs_unwatch(dev->xenfb->xsh, dev->otherend, "");
-+ xenfb_shutdown(dev->xenfb);
-+ }
-+}
++/****************************************************************
++ *
++ * Functions for processing frontend config
++ *
++ ****************************************************************/
+
+
-+/* Register a QEMU console & input handlers */
-+static void xenfb_register_console(struct xenfb *xenfb) {
-+ /* Register our keyboard & mouse handlers */
-+ qemu_add_kbd_event_handler(xenfb_put_keycode, xenfb);
-+ qemu_add_mouse_event_handler(xenfb_mouse_event, xenfb,
-+ xenfb->data.abs_pointer_wanted,
-+ "Xen PVFB Mouse");
-+
-+ /* Tell QEMU to allocate a graphical console even though
-+ * we're not connected - so user at least has a black screen
-+ * to look at ;-) */
-+ graphic_console_init(xenfb->ds,
-+ xenfb_update,
-+ xenfb_invalidate,
-+ xenfb_screen_dump,
-+ xenfb);
-+
-+ LOGF("FB: Connected, resizing framebuffer\n");
-+ dpy_resize(xenfb->ds, xenfb->data.width, xenfb->data.height);
-+}
-+
+/* Process the frontend framebuffer config */
+static int xenfb_read_frontend_fb_config(struct xenfb *xenfb) {
struct xenfb_page *fb_page;
@@ -447,12 +502,12 @@
-
- /* TODO check for permitted ranges */
- fb_page = xenfb->fb.page;
-- xenfb->data.depth = fb_page->depth;
-- xenfb->data.width = fb_page->width;
-- xenfb->data.height = fb_page->height;
+- xenfb->depth = fb_page->depth;
+- xenfb->width = fb_page->width;
+- xenfb->height = fb_page->height;
- /* TODO check for consistency with the above */
-- xenfb->data.len = fb_page->mem_length;
-- xenfb->data.row_stride = fb_page->line_length;
+- xenfb->fb_len = fb_page->mem_length;
+- xenfb->row_stride = fb_page->line_length;
-
- if (xenfb_map_fb(xenfb, domid) < 0)
- goto error;
@@ -471,7 +526,7 @@
+ "%d", &val) < 0)
+ val = 0;
+ if (!val) {
-+ LOGF("feature-update not supported\n");
++ fprintf(stderr, "feature-update not supported\n");
+ errno = ENOTSUP;
+ return -1;
+ }
@@ -482,13 +537,13 @@
+
+ /* TODO check for permitted ranges */
+ fb_page = xenfb->fb.page;
-+ xenfb->data.depth = fb_page->depth;
-+ xenfb->data.width = fb_page->width;
-+ xenfb->data.height = fb_page->height;
++ xenfb->depth = fb_page->depth;
++ xenfb->width = fb_page->width;
++ xenfb->height = fb_page->height;
+ /* TODO check for consistency with the above */
-+ xenfb->data.len = fb_page->mem_length;
-+ xenfb->data.row_stride = fb_page->line_length;
-+ LOGF("Framebuffer depth %d width %d height %d line %d\n",
++ xenfb->fb_len = fb_page->mem_length;
++ xenfb->row_stride = fb_page->line_length;
++ fprintf(stderr, "Framebuffer depth %d width %d height %d line %d\n",
+ fb_page->depth, fb_page->width, fb_page->height, fb_page->line_length);
+ if (xenfb_map_fb(xenfb, xenfb->fb.otherend_id) < 0)
+ return -1;
@@ -509,7 +564,7 @@
+ if (xenfb_xs_scanf1(xenfb->xsh, xenfb->kbd.otherend, "request-abs-pointer",
"%d", &val) < 0)
val = 0;
- xenfb->data.abs_pointer_wanted = val;
+ xenfb->abs_pointer_wanted = val;
- /* Listen for events from xenstore */
- if (qemu_set_fd_handler2(xs_fileno(xenfb->xsh), NULL, xenfb_dispatch_store, NULL, xenfb) < 0)
@@ -520,21 +575,47 @@
- goto error;
-
- /* Register our keyboard & mouse handlers */
-- qemu_add_kbd_event_handler(xenfb_put_keycode, xenfb);
+- qemu_add_kbd_event_handler(xenfb_key_event, xenfb);
- qemu_add_mouse_event_handler(xenfb_mouse_event, xenfb,
-- xenfb->data.abs_pointer_wanted,
+- xenfb->abs_pointer_wanted,
- "Xen PVFB Mouse");
-
-+ return 0;
+- xenfb->ds = ds;
+-
+- /* Tell QEMU to allocate a graphical console */
+- graphic_console_init(ds,
+- xenfb_update,
+- xenfb_invalidate,
+- xenfb_screen_dump,
+- xenfb);
+- dpy_resize(ds, xenfb->width, xenfb->height);
+-
+ return 0;
+-
+- error:
+- serrno = errno;
+- xenfb_detach_dom(xenfb);
+- xenfb_dev_fatal(&xenfb->fb, serrno, "on fire");
+- xenfb_dev_fatal(&xenfb->kbd, serrno, "on fire");
+- errno = serrno;
+- return -1;
+-}
+}
+
++
++/****************************************************************
++ *
++ * Functions for frontend/backend state machine
++ *
++ ****************************************************************/
++
+/* Register a watch against a frontend device, and setup
+ * QEMU event loop to poll the xenstore FD for notification */
+static int xenfb_wait_for_frontend(struct xenfb_device *dev, IOHandler *handler)
+{
-+ LOGF("Doing frontend watch on %s\n", dev->otherend);
++ fprintf(stderr, "Doing frontend watch on %s\n", dev->otherend);
+ if (!xs_watch(dev->xenfb->xsh, dev->otherend, "")) {
-+ LOGF("Watch for dev failed\n");
++ fprintf(stderr, "Watch for dev failed\n");
+ return -1;
+ }
+
@@ -548,9 +629,9 @@
+ * QEMU event loop to poll the xenstore FD for notification */
+static int xenfb_wait_for_backend(struct xenfb_device *dev, IOHandler *handler)
+{
-+ LOGF("Doing backend watch on %s\n", dev->nodename);
++ fprintf(stderr, "Doing backend watch on %s\n", dev->nodename);
+ if (!xs_watch(dev->xenfb->xsh, dev->nodename, "")) {
-+ LOGF("Watch for dev failed\n");
++ fprintf(stderr, "Watch for dev failed\n");
+ return -1;
+ }
+
@@ -560,6 +641,113 @@
+ return 0;
+}
+
++/* Callback invoked while waiting for KBD backend to change
++ * to the created state */
++static void xenfb_backend_created_kbd(void *opaque)
++{
++ struct xenfb_device *dev = (struct xenfb_device *)opaque;
++ int ret = xenfb_backend_created(dev);
++ if (ret < 0) {
++ xenfb_shutdown(dev->xenfb);
++ exit(1);
++ }
++ if (ret)
++ return; /* Still waiting */
++
++ if (xenfb_xs_printf(dev->xenfb->xsh, dev->nodename, "feature-abs-pointer", "1")) {
++ xenfb_shutdown(dev->xenfb);
++ exit(1);
++ }
++
++ fprintf(stderr, "FB: Waiting for FB backend creation\n");
++ xenfb_wait_for_backend(&dev->xenfb->fb, xenfb_backend_created_fb);
++}
++
++/* Callback invoked while waiting for FB backend to change
++ * to the created state */
++static void xenfb_backend_created_fb(void *opaque)
++{
++ struct xenfb_device *dev = (struct xenfb_device *)opaque;
++ int ret = xenfb_backend_created(dev);
++ if (ret < 0) {
++ xenfb_shutdown(dev->xenfb);
++ exit(1);
++ }
++ if (ret)
++ return; /* Still waiting */
++
++ fprintf(stderr, "FB: Waiting for KBD frontend initialization\n");
++ xenfb_wait_for_frontend(&dev->xenfb->kbd, xenfb_frontend_initialized_kbd);
++}
++
++/* Callback invoked while waiting for KBD frontend to change
++ * to the initialized state */
++static void xenfb_frontend_initialized_kbd(void *opaque)
++{
++ struct xenfb_device *dev = (struct xenfb_device *)opaque;
++ int ret = xenfb_frontend_initialized(dev);
++ if (ret < 0) {
++ xenfb_shutdown(dev->xenfb);
++ exit(1);
++ }
++ if (ret)
++ return; /* Still waiting */
++
++
++ fprintf(stderr, "FB: Waiting for FB frontend initialization\n");
++ xenfb_wait_for_frontend(&dev->xenfb->fb, xenfb_frontend_initialized_fb);
++}
++
++/* Callback invoked while waiting for FB frontend to change
++ * to the initialized state */
++static void xenfb_frontend_initialized_fb(void *opaque)
++{
++ struct xenfb_device *dev = (struct xenfb_device *)opaque;
++ int ret = xenfb_frontend_initialized(dev);
++ if (ret < 0) {
++ xenfb_shutdown(dev->xenfb);
++ exit(1);
++ }
++ if (ret)
++ return; /* Still waiting */
++
++
++ if (xenfb_read_frontend_fb_config(dev->xenfb)) {
++ xenfb_shutdown(dev->xenfb);
++ exit(1);
++ }
++
++ fprintf(stderr, "FB: Waiting for KBD frontend connection\n");
++ xenfb_wait_for_frontend(&dev->xenfb->kbd, xenfb_frontend_connected_kbd);
++}
++
++/* Callback invoked while waiting for KBD frontend to change
++ * to the connected state */
++static void xenfb_frontend_connected_kbd(void *opaque)
++{
++ struct xenfb_device *dev = (struct xenfb_device *)opaque;
++ int ret = xenfb_frontend_connected(dev);
++ if (ret < 0) {
++ xenfb_shutdown(dev->xenfb);
++ exit(1);
++ }
++ if (ret)
++ return; /* Still waiting */
++
++ if (xenfb_read_frontend_kbd_config(dev->xenfb) < 0) {
++ xenfb_shutdown(dev->xenfb);
++ exit(1);
++ }
++
++ xenfb_register_console(dev->xenfb);
++}
++
++
++/****************************************************************
++ *
++ * Helper functions for checking state of frontend/backend devices
++ *
++ ****************************************************************/
+
+/* Helper to determine if a frontend device is in Connected state */
+static int xenfb_frontend_connected(struct xenfb_device *dev)
@@ -568,20 +756,19 @@
+ unsigned int dummy;
+ char **vec;
+ vec = xs_read_watch(dev->xenfb->xsh, &dummy);
-+ if (!vec) {
-+ xs_unwatch(dev->xenfb->xsh, dev->otherend, "");
++ if (!vec)
+ return -1;
-+ }
+ free(vec);
+
+ state = xenfb_read_state(dev->xenfb->xsh, dev->otherend);
+ if (!((1 <<state) & ((1 << XenbusStateUnknown) |
+ (1 << XenbusStateConnected)))) {
-+ LOGF("FB: Carry on waiting\n");
++ fprintf(stderr, "FB: Carry on waiting\n");
+ return 1;
+ }
+
-+ xs_unwatch(dev->xenfb->xsh, dev->otherend, "");
++ /* Don't unwatch frontend - we need to detect shutdown */
++ /*xs_unwatch(dev->xenfb->xsh, dev->otherend, "");*/
+
+ switch (state) {
+ case XenbusStateConnected:
@@ -600,10 +787,8 @@
+ unsigned int dummy;
+ char **vec;
+ vec = xs_read_watch(dev->xenfb->xsh, &dummy);
-+ if (!vec) {
-+ xs_unwatch(dev->xenfb->xsh, dev->otherend, "");
++ if (!vec)
+ return -1;
-+ }
+ free(vec);
+
+ state = xenfb_read_state(dev->xenfb->xsh, dev->otherend);
@@ -614,7 +799,7 @@
+ | (1 << XenbusStateConnected)
+#endif
+ ))) {
-+ LOGF("FB: Carry on waiting\n");
++ fprintf(stderr, "FB: Carry on waiting\n");
+ return 1;
+ }
+
@@ -623,7 +808,7 @@
+ switch (state) {
+#if 1
+ case XenbusStateConnected:
-+ LOGF("Fudging state to %d\n", XenbusStateInitialised); /* FIXME */
++ printf("Fudging state to %d\n", XenbusStateInitialised); /* FIXME */
+#endif
+ case XenbusStateInitialised:
+ break;
@@ -638,16 +823,14 @@
+}
+
+/* Helper to determine if a backend device is in Created state */
-+int xenfb_backend_created(struct xenfb_device *dev)
++static int xenfb_backend_created(struct xenfb_device *dev)
+{
+ unsigned int state;
+ unsigned int dummy;
+ char **vec;
+ vec = xs_read_watch(dev->xenfb->xsh, &dummy);
-+ if (!vec) {
-+ xs_unwatch(dev->xenfb->xsh, dev->nodename, "");
++ if (!vec)
+ return -1;
-+ }
+ free(vec);
+
+ state = xenfb_read_state(dev->xenfb->xsh, dev->nodename);
@@ -661,7 +844,7 @@
+ | (1 << XenbusStateClosing)
+#endif
+ ))) {
-+ LOGF("FB: Carry on waiting\n");
++ fprintf(stderr, "FB: Carry on waiting\n");
+ return 1;
+ }
+
@@ -671,14 +854,14 @@
+#if 1
+ case XenbusStateInitWait:
+ case XenbusStateConnected:
-+ LOGF("FB: Fudging state to %d\n", XenbusStateInitialising); /* FIXME */
++ printf("Fudging state to %d\n", XenbusStateInitialising); /* FIXME */
+#endif
+ case XenbusStateInitialising:
+ case XenbusStateClosing:
+ case XenbusStateClosed:
+ break;
+ default:
-+ LOGF("FB: Wrong state %d\n", state);
++ fprintf(stderr, "Wrong state %d\n", state);
+ return -1;
+ }
+ xenfb_switch_state(dev, XenbusStateInitWait);
@@ -688,199 +871,51 @@
+ return 0;
+}
+
-+/* Callback invoked while waiting for KBD frontend to change
-+ * to the connected state */
-+void xenfb_frontend_connected_kbd(void *opaque)
-+{
-+ struct xenfb_device *dev = (struct xenfb_device *)opaque;
-+ int ret = xenfb_frontend_connected(dev);
-+ if (ret < 0) {
-+ xenfb_shutdown(dev->xenfb);
-+ return;
-+ }
-+ if (ret)
-+ return; /* Still waiting */
-+
-+ if (xenfb_read_frontend_kbd_config(dev->xenfb) < 0) {
-+ xenfb_shutdown(dev->xenfb);
-+ return;
-+ }
-+
-+ xenfb_register_console(dev->xenfb);
-+
-+ if (qemu_set_fd_handler2(dev->xenfb->evt_xch, NULL, xenfb_dispatch_channel, NULL, dev->xenfb) < 0) {
-+ xenfb_shutdown(dev->xenfb);
-+ return;
-+ }
-+
-+ LOGF("FB: Waiting for KBD frontend disconnection\n");
-+ xenfb_wait_for_frontend(&dev->xenfb->kbd, xenfb_frontend_disconnected_kbd);
-+}
-+
-+/* Callback invoked while waiting for FB frontend to change
-+ * to the initialized state */
-+void xenfb_frontend_initialized_fb(void *opaque)
-+{
-+ struct xenfb_device *dev = (struct xenfb_device *)opaque;
-+ int ret = xenfb_frontend_initialized(dev);
-+ if (ret < 0) {
-+ xenfb_shutdown(dev->xenfb);
-+ return;
-+ }
-+ if (ret)
-+ return; /* Still waiting */
-+
-+
-+ if (xenfb_read_frontend_fb_config(dev->xenfb)) {
-+ xenfb_shutdown(dev->xenfb);
-+ return;
-+ }
-+
-+ LOGF("FB: Waiting for KBD frontend connection\n");
-+ xenfb_wait_for_frontend(&dev->xenfb->kbd, xenfb_frontend_connected_kbd);
-+}
-+
-+/* Callback invoked while waiting for KBD frontend to change
-+ * to the initialized state */
-+void xenfb_frontend_initialized_kbd(void *opaque)
-+{
-+ struct xenfb_device *dev = (struct xenfb_device *)opaque;
-+ int ret = xenfb_frontend_initialized(dev);
-+ if (ret < 0) {
-+ xenfb_shutdown(dev->xenfb);
-+ return;
-+ }
-+ if (ret)
-+ return; /* Still waiting */
-+
-+
-+ LOGF("FB: Waiting for FB frontend initialization\n");
-+ xenfb_wait_for_frontend(&dev->xenfb->fb, xenfb_frontend_initialized_fb);
-+}
-+
-+/* Callback invoked while waiting for FB backend to change
-+ * to the created state */
-+void xenfb_backend_created_fb(void *opaque)
-+{
-+ struct xenfb_device *dev = (struct xenfb_device *)opaque;
-+ int ret = xenfb_backend_created(dev);
-+ if (ret < 0) {
-+ xenfb_shutdown(dev->xenfb);
-+ return;
-+ }
-+ if (ret)
-+ return; /* Still waiting */
-+
-+ LOGF("FB: Waiting for KBD frontend initialization\n");
-+ xenfb_wait_for_frontend(&dev->xenfb->kbd, xenfb_frontend_initialized_kbd);
-+}
+
-+/* Callback invoked while waiting for KBD backend to change
-+ * to the created state */
-+void xenfb_backend_created_kbd(void *opaque)
-+{
-+ struct xenfb_device *dev = (struct xenfb_device *)opaque;
-+ int ret = xenfb_backend_created(dev);
-+ if (ret < 0) {
-+ xenfb_shutdown(dev->xenfb);
-+ return;
-+ }
-+ if (ret)
-+ return; /* Still waiting */
-+
-+ if (xenfb_xs_printf(dev->xenfb->xsh, dev->nodename, "feature-abs-pointer", "1")) {
-+ xenfb_shutdown(dev->xenfb);
-+ return;
-+ }
-+
-+ LOGF("FB: Waiting for FB backend creation\n");
-+ xenfb_wait_for_backend(&dev->xenfb->fb, xenfb_backend_created_fb);
-+}
-+
-+
-+/* Create a new Xen FB associated with QEMU DisplayState,
-+ * wait for domid to appear and connect to its frontend */
-+struct xenfb *xenfb_new(int domid, DisplayState *ds)
-+{
-+ int serrno;
-+ struct xenfb *xenfb = qemu_malloc(sizeof(struct xenfb));
-+
-+ if (xenfb == NULL)
-+ return NULL;
-+
-+ memset(xenfb, 0, sizeof(*xenfb));
- xenfb->ds = ds;
--
-- /* Tell QEMU to allocate a graphical console */
-- graphic_console_init(ds,
-- xenfb_update,
-- xenfb_invalidate,
-- xenfb_screen_dump,
-- xenfb);
-- dpy_resize(ds, xenfb->data.width, xenfb->data.height);
--
-- return 0;
--
-- error:
-- serrno = errno;
-- xenfb_detach_dom(xenfb);
-- xenfb_dev_fatal(&xenfb->fb, serrno, "on fire");
-- xenfb_dev_fatal(&xenfb->kbd, serrno, "on fire");
-- errno = serrno;
-- return -1;
-+ xenfb->evt_xch = xenfb->xc = -1;
-+ xenfb_device_init(&xenfb->fb, "vfb", xenfb);
-+ xenfb_device_init(&xenfb->kbd, "vkbd", xenfb);
-+
-+ xenfb->evt_xch = xc_evtchn_open();
-+ if (xenfb->evt_xch == -1)
-+ goto fail;
-+
-+ xenfb->xc = xc_interface_open();
-+ if (xenfb->xc == -1)
-+ goto fail;
-+
-+ xenfb->xsh = xs_daemon_open();
-+ if (!xenfb->xsh)
-+ goto fail;
-+
-+ xenfb_device_set_domain(&xenfb->fb, domid);
-+ xenfb_device_set_domain(&xenfb->kbd, domid);
-+
-+ LOGF("FB: Waiting for KBD backend creation\n");
-+ xenfb_wait_for_backend(&xenfb->kbd, xenfb_backend_created_kbd);
-+
-+ return xenfb;
++/****************************************************************
++ *
++ * QEMU device model integration functions
++ *
++ ****************************************************************/
+
+ /*
+ * Send a key event from the client to the guest OS
+@@ -996,6 +1073,32 @@ static void xenfb_screen_dump(void *opaq
+ static void xenfb_screen_dump(void *opaque, const char *name) { }
+
+
++/* Register a QEMU graphical console, and key/mouse handler,
++ * connecting up their events to the frontend */
++static int xenfb_register_console(struct xenfb *xenfb) {
++ /* Register our keyboard & mouse handlers */
++ qemu_add_kbd_event_handler(xenfb_key_event, xenfb);
++ qemu_add_mouse_event_handler(xenfb_mouse_event, xenfb,
++ xenfb->abs_pointer_wanted,
++ "Xen PVFB Mouse");
++
++ /* Tell QEMU to allocate a graphical console */
++ graphic_console_init(xenfb->ds,
++ xenfb_update,
++ xenfb_invalidate,
++ xenfb_screen_dump,
++ xenfb);
++ dpy_resize(xenfb->ds, xenfb->width, xenfb->height);
++
++ if (qemu_set_fd_handler2(xenfb->evt_xch, NULL, xenfb_dispatch_channel, NULL, xenfb) < 0)
++ return -1;
++ if (qemu_set_fd_handler2(xs_fileno(xenfb->xsh), NULL, xenfb_dispatch_store, NULL, xenfb) < 0)
++ return -1;
+
-+ fail:
-+ serrno = errno;
-+ xenfb_shutdown(xenfb);
-+ errno = serrno;
-+ return NULL;
++ fprintf(stderr, "Xen Framebuffer registered\n");
++ return 0;
+}
+
-+/* Remove the backend area in xenbus since the framebuffer really is
-+ going away. */
-+void xenfb_shutdown(struct xenfb *xenfb)
-+{
-+ LOGF("FB: Shutting down backend\n");
-+ xs_rm(xenfb->xsh, XBT_NULL, xenfb->fb.nodename);
-+ xs_rm(xenfb->xsh, XBT_NULL, xenfb->kbd.nodename);
-+
-+ xenfb_detach_dom(xenfb);
-+ if (xenfb->xc >= 0)
-+ xc_interface_close(xenfb->xc);
-+ if (xenfb->evt_xch >= 0)
-+ xc_evtchn_close(xenfb->evt_xch);
-+ if (xenfb->xsh)
-+ xs_daemon_close(xenfb->xsh);
-+ free(xenfb);
- }
-
/*
-diff -r 829464d36542 tools/ioemu/hw/xenfb.h
---- a/tools/ioemu/hw/xenfb.h Tue Aug 21 22:07:47 2007 -0400
-+++ b/tools/ioemu/hw/xenfb.h Tue Aug 21 22:08:24 2007 -0400
+ * Local variables:
+ * c-indent-level: 8
+diff -r bed4c2406f8b tools/ioemu/hw/xenfb.h
+--- a/tools/ioemu/hw/xenfb.h Tue Sep 11 11:55:15 2007 -0400
++++ b/tools/ioemu/hw/xenfb.h Tue Sep 11 11:56:11 2007 -0400
@@ -7,10 +7,7 @@
struct xenfb;
xen-pvfb-08-xen-console-qemu.patch:
Index: xen-pvfb-08-xen-console-qemu.patch
===================================================================
RCS file: /cvs/pkgs/rpms/xen/devel/Attic/xen-pvfb-08-xen-console-qemu.patch,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- xen-pvfb-08-xen-console-qemu.patch 19 Oct 2007 23:35:08 -0000 1.1.2.1
+++ xen-pvfb-08-xen-console-qemu.patch 24 Oct 2007 20:02:57 -0000 1.1.2.2
@@ -1,6 +1,29 @@
-diff -r e6b8a2d93de9 tools/ioemu/Makefile.target
---- a/tools/ioemu/Makefile.target Fri Oct 19 17:52:43 2007 -0400
-+++ b/tools/ioemu/Makefile.target Fri Oct 19 19:32:55 2007 -0400
+This 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(-)
+
+ Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
+
+
+diff -r 96aa5e956a9f tools/ioemu/Makefile.target
+--- a/tools/ioemu/Makefile.target Wed Oct 24 15:25:24 2007 -0400
++++ b/tools/ioemu/Makefile.target Wed Oct 24 15:25:27 2007 -0400
@@ -412,6 +412,7 @@ VL_OBJS+= xen_machine_fv.o
VL_OBJS+= xen_machine_fv.o
VL_OBJS+= xen_machine_pv.o
@@ -9,10 +32,10 @@
VL_OBJS+= tpm_tis.o
CPPFLAGS += -DHAS_AUDIO
endif
-diff -r e6b8a2d93de9 tools/ioemu/hw/xen_console.c
+diff -r 96aa5e956a9f tools/ioemu/hw/xen_console.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/tools/ioemu/hw/xen_console.c Fri Oct 19 19:32:55 2007 -0400
-@@ -0,0 +1,424 @@
++++ b/tools/ioemu/hw/xen_console.c Wed Oct 24 15:30:41 2007 -0400
+@@ -0,0 +1,432 @@
+/*
+ * Copyright (C) International Business Machines Corp., 2005
+ * Author(s): Anthony Liguori <aliguori at us.ibm.com>
@@ -53,12 +76,6 @@
+
+#include "xen_console.h"
+
-+#define MAX(a, b) (((a) > (b)) ? (a) : (b))
-+#define MIN(a, b) (((a) < (b)) ? (a) : (b))
-+
-+/* Each 10 bits takes ~ 3 digits, plus one, plus one for nul terminator. */
-+#define MAX_STRLEN(x) ((sizeof(x) * CHAR_BIT + CHAR_BIT-1) / 10 * 3 + 2)
-+
+#define dolog(val, fmt, ...) fprintf(stderr, fmt "\n", ## __VA_ARGS__)
+
+struct buffer
@@ -212,7 +229,7 @@
+ PROT_READ|PROT_WRITE,
+ (unsigned long)ring_ref);
+ if (dom->interface == NULL) {
-+ err = -errno;
++ err = errno;
+ goto out;
+ }
+ dom->ring_ref = ring_ref;
@@ -223,7 +240,7 @@
+
+ dom->xce_handle = xc_evtchn_open();
+ if (dom->xce_handle == -1) {
-+ err = -errno;
++ err = errno;
+ goto out;
+ }
+
@@ -231,7 +248,7 @@
+ dom->domid, remote_port);
+
+ if (rc == -1) {
-+ err = -errno;
++ err = errno;
+ xc_evtchn_close(dom->xce_handle);
+ dom->xce_handle = -1;
+ goto out;
@@ -418,13 +435,27 @@
+ return -1;
+
+ /* Setup watches so we asynchronously connect to serial console */
-+ xs_watch(dom->xsh, dom->conspath, "");
-+ xs_watch(dom->xsh, dom->serialpath, "");
++ if (!(xs_watch(dom->xsh, dom->conspath, ""))) {
++ fprintf(stderr, "Unable to watch console %s\n", dom->conspath);
++ goto fail;
++ }
++ if (!(xs_watch(dom->xsh, dom->serialpath, ""))) {
++ fprintf(stderr, "Unable to watch console %s\n", dom->conspath);
++ xs_unwatch(dom->xsh, dom->conspath, "");
++ goto fail;
++ }
+ qemu_set_fd_handler2(xs_fileno(dom->xsh), NULL, xencons_startup, NULL, dom);
+ fprintf(stderr, "Console: prepared domain, waiting for ringref at %s or %s\n",
+ dom->conspath, dom->serialpath);
+
+ return 0;
++
++fail:
++ xs_daemon_close(dom->xsh);
++ free(dom->serialpath);
++ free(dom->conspath);
++ free(dom);
++ return -1;
+}
+
+
@@ -437,9 +468,9 @@
+ * tab-width: 8
+ * End:
+ */
-diff -r e6b8a2d93de9 tools/ioemu/hw/xen_console.h
+diff -r 96aa5e956a9f tools/ioemu/hw/xen_console.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/tools/ioemu/hw/xen_console.h Fri Oct 19 19:32:55 2007 -0400
++++ b/tools/ioemu/hw/xen_console.h Wed Oct 24 15:25:27 2007 -0400
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) International Business Machines Corp., 2005
@@ -466,9 +497,9 @@
+#include "vl.h"
+
+extern int xencons_init(int domid, CharDriverState *chr);
-diff -r e6b8a2d93de9 tools/ioemu/hw/xen_machine_pv.c
---- a/tools/ioemu/hw/xen_machine_pv.c Fri Oct 19 17:52:43 2007 -0400
-+++ b/tools/ioemu/hw/xen_machine_pv.c Fri Oct 19 19:32:55 2007 -0400
+diff -r 96aa5e956a9f tools/ioemu/hw/xen_machine_pv.c
+--- a/tools/ioemu/hw/xen_machine_pv.c Wed Oct 24 15:25:24 2007 -0400
++++ b/tools/ioemu/hw/xen_machine_pv.c Wed Oct 24 15:25:27 2007 -0400
@@ -23,6 +23,7 @@
*/
@@ -476,8 +507,8 @@
+#include "xen_console.h"
#include "xenfb.h"
-
-@@ -39,6 +40,14 @@ static void xen_init_pv(uint64_t ram_siz
+ /* 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;
@@ -492,9 +523,9 @@
/* Prepare PVFB state */
xenfb = xenfb_new(domid, ds);
-diff -r e6b8a2d93de9 tools/ioemu/xenstore.c
---- a/tools/ioemu/xenstore.c Fri Oct 19 17:52:43 2007 -0400
-+++ b/tools/ioemu/xenstore.c Fri Oct 19 19:32:55 2007 -0400
+diff -r 96aa5e956a9f tools/ioemu/xenstore.c
+--- a/tools/ioemu/xenstore.c Wed Oct 24 15:25:24 2007 -0400
++++ b/tools/ioemu/xenstore.c Wed Oct 24 15:25:27 2007 -0400
@@ -17,7 +17,7 @@
#include <sys/stat.h>
#include <fcntl.h>
@@ -504,3 +535,20 @@
static char *media_filename[MAX_DISKS + MAX_SCSI_DISKS];
static QEMUTimer *insert_timer = NULL;
+diff -r 96aa5e956a9f tools/python/xen/xend/XendDomainInfo.py
+--- a/tools/python/xen/xend/XendDomainInfo.py Wed Oct 24 15:25:24 2007 -0400
++++ b/tools/python/xen/xend/XendDomainInfo.py Wed Oct 24 15:30:26 2007 -0400
+@@ -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()
xen-pvfb-09-xend-device-model.patch:
Index: xen-pvfb-09-xend-device-model.patch
===================================================================
RCS file: /cvs/pkgs/rpms/xen/devel/Attic/xen-pvfb-09-xend-device-model.patch,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- xen-pvfb-09-xend-device-model.patch 19 Oct 2007 23:35:08 -0000 1.1.2.1
+++ xen-pvfb-09-xend-device-model.patch 24 Oct 2007 20:02:57 -0000 1.1.2.2
@@ -1,6 +1,38 @@
-diff -r a3ce4d76dd36 tools/python/xen/xend/XendCheckpoint.py
---- a/tools/python/xen/xend/XendCheckpoint.py Fri Oct 19 17:44:06 2007 -0400
-+++ b/tools/python/xen/xend/XendCheckpoint.py Fri Oct 19 17:44:08 2007 -0400
+This 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(-)
+
+ Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
+
+
+diff -r f0a3bb81fbe3 tools/python/xen/xend/XendCheckpoint.py
+--- a/tools/python/xen/xend/XendCheckpoint.py Wed Oct 24 15:31:33 2007 -0400
++++ b/tools/python/xen/xend/XendCheckpoint.py Wed Oct 24 15:57:32 2007 -0400
@@ -6,6 +6,7 @@
# this archive for more details.
@@ -27,9 +59,9 @@
if is_hvm:
qemu_signature = read_exact(fd, len(QEMU_SIGNATURE),
"invalid device model signature read")
-diff -r a3ce4d76dd36 tools/python/xen/xend/XendConfig.py
---- a/tools/python/xen/xend/XendConfig.py Fri Oct 19 17:44:06 2007 -0400
-+++ b/tools/python/xen/xend/XendConfig.py Fri Oct 19 17:44:08 2007 -0400
+diff -r f0a3bb81fbe3 tools/python/xen/xend/XendConfig.py
+--- a/tools/python/xen/xend/XendConfig.py Wed Oct 24 15:31:33 2007 -0400
++++ b/tools/python/xen/xend/XendConfig.py Wed Oct 24 15:31:35 2007 -0400
@@ -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
@@ -101,9 +133,9 @@
def _sxp_to_xapi_unsupported(self, sxp_cfg):
"""Read in an SXP configuration object and populate
-diff -r a3ce4d76dd36 tools/python/xen/xend/XendDomainInfo.py
---- a/tools/python/xen/xend/XendDomainInfo.py Fri Oct 19 17:44:06 2007 -0400
-+++ b/tools/python/xen/xend/XendDomainInfo.py Fri Oct 19 17:44:08 2007 -0400
+diff -r f0a3bb81fbe3 tools/python/xen/xend/XendDomainInfo.py
+--- a/tools/python/xen/xend/XendDomainInfo.py Wed Oct 24 15:31:33 2007 -0400
++++ b/tools/python/xen/xend/XendDomainInfo.py Wed Oct 24 15:58:37 2007 -0400
@@ -1455,10 +1455,16 @@ class XendDomainInfo:
def _releaseDevices(self, suspend = False):
@@ -125,18 +157,7 @@
t = xstransact("%s/device" % self.dompath)
for devclass in XendDevices.valid_devices():
for dev in t.list(devclass):
-@@ -1468,8 +1474,8 @@ class XendDomainInfo:
- except:
- # Log and swallow any exceptions in removal --
- # there's nothing more we can do.
-- log.exception("Device release failed: %s; %s; %s",
-- self.info['name_label'], devclass, dev)
-+ log.exception("Device release failed: %s; %s; %s",
-+ self.info['name_label'], devclass, dev)
-
-
-
-@@ -1695,11 +1701,6 @@ class XendDomainInfo:
+@@ -1709,11 +1715,6 @@ class XendDomainInfo:
bootloader_tidy(self)
if self.image:
@@ -148,21 +169,7 @@
self.image = None
try:
-@@ -1747,10 +1748,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()
-@@ -1868,8 +1868,8 @@ class XendDomainInfo:
+@@ -1881,8 +1882,8 @@ class XendDomainInfo:
ResumeDomain(self.domid)
except:
log.exception("XendDomainInfo.resume: xc.domain_resume failed on domain %s." % (str(self.domid)))
@@ -173,9 +180,9 @@
#
-diff -r a3ce4d76dd36 tools/python/xen/xend/image.py
---- a/tools/python/xen/xend/image.py Fri Oct 19 17:44:06 2007 -0400
-+++ b/tools/python/xen/xend/image.py Fri Oct 19 17:46:43 2007 -0400
+diff -r f0a3bb81fbe3 tools/python/xen/xend/image.py
+--- a/tools/python/xen/xend/image.py Wed Oct 24 15:31:33 2007 -0400
++++ b/tools/python/xen/xend/image.py Wed Oct 24 15:54:42 2007 -0400
@@ -56,10 +56,9 @@ class ImageHandler:
defining in a subclass.
@@ -365,9 +372,9 @@
class LinuxImageHandler(ImageHandler):
-@@ -223,6 +351,19 @@ class LinuxImageHandler(ImageHandler):
- ramdisk = self.ramdisk,
- features = self.vm.getFeatures())
+@@ -229,6 +357,19 @@ class LinuxImageHandler(ImageHandler):
+ flags = self.flags,
+ vhpt = self.vhpt)
+ def parseDeviceModelArgs(self, vmConfig):
+ ret = ImageHandler.parseDeviceModelArgs(self, vmConfig)
@@ -385,7 +392,7 @@
class PPC_LinuxImageHandler(LinuxImageHandler):
ostype = "linux"
-@@ -256,15 +397,6 @@ class HVMImageHandler(ImageHandler):
+@@ -262,15 +403,6 @@ class HVMImageHandler(ImageHandler):
if 'hvm' not in info['xen_caps']:
raise HVMRequired()
@@ -401,7 +408,7 @@
rtc_timeoffset = vmConfig['platform'].get('rtc_timeoffset')
self.vm.storeVm(("image/dmargs", " ".join(self.dmargs)),
-@@ -272,49 +404,18 @@ class HVMImageHandler(ImageHandler):
+@@ -278,49 +410,18 @@ class HVMImageHandler(ImageHandler):
("image/display", self.display))
self.vm.storeVm(("rtc/timeoffset", rtc_timeoffset))
@@ -455,7 +462,7 @@
for a in dmargs:
v = vmConfig['platform'].get(a)
-@@ -343,7 +444,6 @@ class HVMImageHandler(ImageHandler):
+@@ -349,7 +450,6 @@ class HVMImageHandler(ImageHandler):
# Handle disk/network related options
mac = None
@@ -463,7 +470,7 @@
nics = 0
for devuuid in vmConfig['vbd_refs']:
-@@ -372,130 +472,41 @@ class HVMImageHandler(ImageHandler):
+@@ -378,130 +478,43 @@ class HVMImageHandler(ImageHandler):
ret.append("-net")
ret.append("tap,vlan=%d,bridge=%s" % (nics, bridge))
@@ -616,15 +623,17 @@
+ acpi = self.acpi,
+ apic = self.apic)
+ rc['notes'] = { 'SUSPEND_CANCEL': 1 }
++
+ rc['store_mfn'] = xc.hvm_get_param(self.vm.getDomid(),
+ HVM_PARAM_STORE_PFN)
+ xc.hvm_set_param(self.vm.getDomid(), HVM_PARAM_STORE_EVTCHN,
+ store_evtchn)
++
+ return rc
class IA64_HVM_ImageHandler(HVMImageHandler):
-@@ -517,6 +528,13 @@ class IA64_HVM_ImageHandler(HVMImageHand
+@@ -528,6 +541,13 @@ class IA64_HVM_ImageHandler(HVMImageHand
def getRequiredShadowMemory(self, shadow_mem_kb, maxmem_kb):
# Explicit shadow memory is not a concept
return 0
@@ -636,11 +645,11 @@
+ return args
+
- class X86_HVM_ImageHandler(HVMImageHandler):
+ class IA64_Linux_ImageHandler(LinuxImageHandler):
-diff -r a3ce4d76dd36 tools/python/xen/xend/server/vfbif.py
---- a/tools/python/xen/xend/server/vfbif.py Fri Oct 19 17:44:06 2007 -0400
-+++ b/tools/python/xen/xend/server/vfbif.py Fri Oct 19 17:44:08 2007 -0400
+diff -r f0a3bb81fbe3 tools/python/xen/xend/server/vfbif.py
+--- a/tools/python/xen/xend/server/vfbif.py Wed Oct 24 15:31:33 2007 -0400
++++ b/tools/python/xen/xend/server/vfbif.py Wed Oct 24 15:56:36 2007 -0400
@@ -5,14 +5,6 @@ import xen.xend
import xen.xend
import os
@@ -724,7 +733,7 @@
def reconfigureDevice(self, _, config):
""" Only allow appending location information of vnc port into
-@@ -115,20 +51,15 @@ class VfbifController(DevController):
+@@ -115,19 +51,16 @@ class VfbifController(DevController):
raise VmError('Refusing to reconfigure device vfb:%d' % devid)
def destroyDevice(self, devid, force):
@@ -734,25 +743,24 @@
- DevController.destroyDevice(self, devid, True)
- else:
- DevController.destroyDevice(self, devid, force)
--
+ # remove the backend xenstore entries no matter what
+ # because we kill qemu-dm with extreme prejudice
+ # not giving it a chance to remove them itself
+ DevController.destroyDevice(self, devid, True)
+
def migrate(self, deviceConfig, network, dst, step, domName):
- if self.vm.info.get('HVM_boot_policy'):
- return 0
- return DevController.migrate(self, deviceConfig, network, dst, step,
- domName)
--
+ # Handled by qemu-dm so no action needed
+ return 0
+
+
class VkbdifController(DevController):
"""Virtual keyboard controller. Handles all vkbd devices for a domain.
- """
-@@ -141,22 +72,15 @@ class VkbdifController(DevController):
+@@ -141,22 +74,15 @@ class VkbdifController(DevController):
return (devid, back, front)
def waitForDevice(self, config):
xen-pvfb-10-xen-console-ignore.patch:
Index: xen-pvfb-10-xen-console-ignore.patch
===================================================================
RCS file: /cvs/pkgs/rpms/xen/devel/Attic/xen-pvfb-10-xen-console-ignore.patch,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- xen-pvfb-10-xen-console-ignore.patch 19 Oct 2007 23:35:08 -0000 1.1.2.1
+++ xen-pvfb-10-xen-console-ignore.patch 24 Oct 2007 20:02:57 -0000 1.1.2.2
@@ -1,7 +1,27 @@
-diff -r 4559faae3790 tools/console/daemon/io.c
---- a/tools/console/daemon/io.c Wed Aug 22 16:24:48 2007 -0400
-+++ b/tools/console/daemon/io.c Wed Aug 22 18:48:05 2007 -0400
-@@ -327,6 +327,7 @@ static int domain_create_ring(struct dom
+This 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(+)
+
+ Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
+
+
+diff -r b090544a03f1 tools/console/daemon/io.c
+--- a/tools/console/daemon/io.c Wed Oct 24 15:31:35 2007 -0400
++++ b/tools/console/daemon/io.c Wed Oct 24 15:37:24 2007 -0400
+@@ -377,6 +377,7 @@ static int domain_create_ring(struct dom
static int domain_create_ring(struct domain *dom)
{
int err, remote_port, ring_ref, rc;
@@ -9,7 +29,7 @@
err = xs_gather(xs, dom->serialpath,
"ring-ref", "%u", &ring_ref,
-@@ -343,6 +344,14 @@ static int domain_create_ring(struct dom
+@@ -393,6 +394,14 @@ static int domain_create_ring(struct dom
} else
dom->use_consolepath = 0;
@@ -24,10 +44,10 @@
if ((ring_ref == dom->ring_ref) && (remote_port == dom->remote_port))
goto out;
-diff -r 4559faae3790 tools/python/xen/xend/XendDomainInfo.py
---- a/tools/python/xen/xend/XendDomainInfo.py Wed Aug 22 16:24:48 2007 -0400
-+++ b/tools/python/xen/xend/XendDomainInfo.py Wed Aug 22 18:36:15 2007 -0400
-@@ -883,8 +883,15 @@ class XendDomainInfo:
+diff -r b090544a03f1 tools/python/xen/xend/XendDomainInfo.py
+--- a/tools/python/xen/xend/XendDomainInfo.py Wed Oct 24 15:31:35 2007 -0400
++++ b/tools/python/xen/xend/XendDomainInfo.py Wed Oct 24 15:37:24 2007 -0400
+@@ -916,8 +916,15 @@ class XendDomainInfo:
else:
to_store[n] = str(v)
Index: xen.spec
===================================================================
RCS file: /cvs/pkgs/rpms/xen/devel/xen.spec,v
retrieving revision 1.194.2.1
retrieving revision 1.194.2.2
diff -u -r1.194.2.1 -r1.194.2.2
--- xen.spec 19 Oct 2007 23:35:08 -0000 1.194.2.1
+++ xen.spec 24 Oct 2007 20:02:57 -0000 1.194.2.2
@@ -5,7 +5,7 @@
Summary: Xen is a virtual machine monitor
Name: xen
Version: 3.1.1
-Release: 0%{?dist}.2unstable
+Release: 0%{?dist}.3unstable
Group: Development/Libraries
License: GPL
URL: http://www.cl.cam.ac.uk/Research/SRG/netos/xen/index.html
- Previous message (by thread): rpms/ql2100-firmware/devel LICENSE, NONE, 1.1 ql2100-firmware.spec, NONE, 1.1 .cvsignore, 1.1, 1.2 sources, 1.1, 1.2
- Next message (by thread): rpms/ql2200-firmware/devel LICENSE, NONE, 1.1 ql2200-firmware.spec, NONE, 1.1 .cvsignore, 1.1, 1.2 sources, 1.1, 1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the fedora-extras-commits
mailing list