Skip to contentSkip to conversation

[7220] xen: backend driver core (Gerd Hoffmann)

Qemu-devel Anthony Liguori 1 participant 1 message Apr 22, 2009 Kbuild

lore
Share & tools
lore
#0 lore raw

Revision: 7220

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=7220
Author:   aliguori
Date:     2009-04-22 15:19:15 +0000 (Wed, 22 Apr 2009)

Log Message:
-----------
xen: backend driver core (Gerd Hoffmann)

This patch adds infrastructure for xen backend drivers living in qemu, so drivers don't need to implement common stuff on their own. It's mostly xenbus management stuff: some functions to access xentore, setting up xenstore watches, callbacks on device discovery and state changes, handle event channel, ...

Modified Paths:
--------------
trunk/Makefile.target
trunk/hw/xen_machine_pv.c

Added Paths:
-----------
trunk/hw/xen_backend.c
trunk/hw/xen_backend.h
trunk/hw/xen_common.h

Modified: trunk/Makefile.target
===================================================================

Makefile.target +1 -1
@@ -561,7 +561,7 @@
 endif
 
 # xen backend driver support
-XEN_OBJS := xen_machine_pv.o
+XEN_OBJS := xen_machine_pv.o xen_backend.o
 ifeq ($(CONFIG_XEN), yes)
   OBJS += $(XEN_OBJS)
   LIBS += $(XEN_LIBS)

Added: trunk/hw/xen_backend.c
===================================================================

hw/xen_backend.c +713 -0

713 lines not on this page · raw message

Added: trunk/hw/xen_backend.h
===================================================================

hw/xen_backend.h +86 -0

86 lines not on this page · raw message

Added: trunk/hw/xen_common.h
===================================================================

hw/xen_common.h +34 -0
@@ -0,0 +1,34 @@
+#ifndef QEMU_HW_XEN_COMMON_H
+#define QEMU_HW_XEN_COMMON_H 1
+
+#include <stddef.h>
+#include <inttypes.h>
+
+#include <xenctrl.h>
+#include <xs.h>
+#include <xen/io/xenbus.h>
+
+#include "hw.h"
+#include "xen.h"
+#include "sys-queue.h"   /* BSD list implementation */
+
+/*
+ * tweaks needed to build with different xen versions
+ *  0x00030205 -> 3.1.0
+ *  0x00030207 -> 3.2.0
+ *  0x00030208 -> unstable
+ */
+#include <xen/xen-compat.h>
+#if __XEN_LATEST_INTERFACE_VERSION__ < 0x00030205
+# define evtchn_port_or_error_t int
+#endif
+#if __XEN_LATEST_INTERFACE_VERSION__ < 0x00030207
+# define xc_map_foreign_pages xc_map_foreign_batch
+#endif
+#if __XEN_LATEST_INTERFACE_VERSION__ < 0x00030208
+# define xen_mb()  mb()
+# define xen_rmb() rmb()
+# define xen_wmb() wmb()
+#endif
+
+#endif /* QEMU_HW_XEN_COMMON_H */

Modified: trunk/hw/xen_machine_pv.c
===================================================================

hw/xen_machine_pv.c +7 -1
@@ -26,7 +26,7 @@
 #include "pc.h"
 #include "sysemu.h"
 #include "boards.h"
-#include "xen.h"
+#include "xen_backend.h"
 
 uint32_t xen_domid;
 enum xen_mode xen_mode = XEN_EMULATE;
@@ -50,6 +50,12 @@
     }
     env = cpu_init(cpu_model);
     env->halted = 1;
+
+    /* Initialize backend core & drivers */
+    if (xen_be_init() != 0) {
+        fprintf(stderr, "%s: xen backend core setup failed\n", __FUNCTION__);
+        exit(1);
+    }
 }
 
 QEMUMachine xenpv_machine = {