Skip to contentSkip to conversation

xen: pv domain support.

PATCH In review Gerd Hoffmann 6 participants 21 messages Apr 21, 2009 – May 19, 2009 Kbuild

lore
Share & tools
lore
#0 lore raw

cover xen: pv domain support.

Hi,

Next round, addressing review comments:

* Fixup more "if (-1 == foo()) bar()" compare style.
* Fixup logging: kill fprintf(stderr, ...), use logging API.
* Kill some unneeded malloc failure checks.

The patches are also rebased to latest git and got a few adaptions to recent changes.

Short overview (individual patches have longer descriptions):

  #1  - groundwork for xen support (makefiles, configure, ...).
  #2  - backend driver core (common code used by all backends).
  #3  - add console backend driver.
  #4  - add framebuffer backend driver.

With these four patches in place upstream qemu is functional aequivalent to qemu-xen for paravirtual guests. The patches are merged into qemu-xen already, with the exception of a few framebuffer bits which got hold back due to displaystate work and the most recent updates due to review comments.

#5 - add block device backend driver.
#6 - add net backend driver.

These two patches add backend drivers for disk and network to qemu.

  #7  - blk & nic configuration via cmd line.
  #8  - pv domain builder.
  #9  - simplify vga selection

#10 - add -vga xenfb option, configure xenfb

These patches add support to qemu for creating xen pv guests. That way one can run xen guests without xend. Patch #8 is the domain builder code itself. The other patches add support for configuring devices (fb, disk, nic) via command line.

The patches are also available via git:
git: git://git.et.redhat.com/qemu-kraxel.git
gitweb: http://git.et.redhat.com/?p=qemu-kraxel.git

branches:

 xenbits.v7  -  this patch series.
 qx.misc.v6  -  xenfb update + review changes for qemu-xen.

Ian, is just pulling from git fine with you? Or do you want the qemu-xen patches mailed to xen-devel?

cheers,
Gerd

#1 lore raw

PATCH 1/10 xen: groundwork for xen support

- configure script and build system changes.
- wind up new machine type.
- add -xen-* command line options.

---
 Makefile.target       |    7 +++++
 configure             |   34 +++++++++++++++++++++++++++
 hw/boards.h           |    3 ++
 hw/xen.h              |   20 ++++++++++++++++
 hw/xen_machine_pv.c   |   60 +++++++++++++++++++++++++++++++++++++++++++++++++
 qemu-options.hx       |   11 +++++++++
 target-i386/machine.c |    3 ++
 vl.c                  |   12 +++++++++
 8 files changed, 150 insertions(+), 0 deletions(-)
 create mode 100644 hw/xen.h
 create mode 100644 hw/xen_machine_pv.c
Makefile.target +7 -0
index b27696a..ab59af3 100644
@@ -560,6 +560,13 @@ ifdef CONFIG_BLUEZ
 LIBS += $(CONFIG_BLUEZ_LIBS)
 endif
 
+# xen backend driver support
+XEN_OBJS := xen_machine_pv.o
+ifeq ($(CONFIG_XEN), yes)
+  OBJS += $(XEN_OBJS)
+  LIBS += $(XEN_LIBS)
+endif
+
 # SCSI layer
 OBJS+= lsi53c895a.o esp.o
 
configure +34 -0
index 8bf44de..ec761ff 100755
@@ -191,6 +191,7 @@ aix="no"
 blobs="yes"
 fdt="yes"
 sdl_x11="no"
+xen="yes"
 pkgversion=""
 
 # OS specific
@@ -421,6 +422,8 @@ for opt do
   ;;
   --disable-kqemu) kqemu="no"
   ;;
+  --disable-xen) xen="no"
+  ;;
   --disable-brlapi) brlapi="no"
   ;;
   --disable-bluez) bluez="no"
@@ -586,6 +589,7 @@ echo "                           Available drivers: $audio_possible_drivers"
 echo "  --audio-card-list=LIST   set list of emulated audio cards [$audio_card_list]"
 echo "                           Available cards: $audio_possible_cards"
 echo "  --enable-mixemu          enable mixer emulation"
+echo "  --disable-xen            disable xen backend driver support"
 echo "  --disable-brlapi         disable BrlAPI"
 echo "  --disable-vnc-tls        disable TLS encryption for VNC server"
 echo "  --disable-vnc-sasl       disable SASL encryption for VNC server"
@@ -802,6 +806,22 @@ else
 fi
 
 ##########################################
+# xen probe
+
+if test "$xen" = "yes" ; then
+cat > $TMPC <<EOF
+#include <xenctrl.h>
+#include <xs.h>
+int main(void) { xs_daemon_open; xc_interface_open; }
+EOF
+   if $cc $ARCH_CFLAGS -c -o $TMPO $TMPC -lxenstore -lxenctrl 2> /dev/null ; then
+      :
+   else
+      xen="no"
+   fi
+fi
+
+##########################################
 # SDL probe
 
 sdl_too_old=no
@@ -1296,6 +1316,7 @@ if test -n "$sparc_cpu"; then
     echo "Target Sparc Arch $sparc_cpu"
 fi
 echo "kqemu support     $kqemu"
+echo "xen support       $xen"
 echo "brlapi support    $brlapi"
 echo "Documentation     $build_docs"
 [ ! -z "$uname_release" ] && \
@@ -1612,6 +1633,9 @@ if test "$bluez" = "yes" ; then
   echo "CONFIG_BLUEZ_LIBS=$bluez_libs" >> $config_mak
   echo "#define CONFIG_BLUEZ 1" >> $config_h
 fi
+if test "$xen" = "yes" ; then
+  echo "XEN_LIBS=-lxenstore -lxenctrl" >> $config_mak
+fi
 if test "$aio" = "yes" ; then
   echo "#define CONFIG_AIO 1" >> $config_h
   echo "CONFIG_AIO=yes" >> $config_mak
@@ -1777,6 +1801,11 @@ case "$target_cpu" in
       echo "KVM_CFLAGS=$kvm_cflags" >> $config_mak
       echo "#define CONFIG_KVM 1" >> $config_h
     fi
+    if test "$xen" = "yes" -a "$target_softmmu" = "yes";
+    then
+      echo "CONFIG_XEN=yes" >> $config_mak
+      echo "#define CONFIG_XEN 1" >> $config_h
+    fi
   ;;
   x86_64)
     echo "TARGET_ARCH=x86_64" >> $config_mak
@@ -1793,6 +1822,11 @@ case "$target_cpu" in
       echo "KVM_CFLAGS=$kvm_cflags" >> $config_mak
       echo "#define CONFIG_KVM 1" >> $config_h
     fi
+    if test "$xen" = "yes" -a "$target_softmmu" = "yes"
+    then
+      echo "CONFIG_XEN=yes" >> $config_mak
+      echo "#define CONFIG_XEN 1" >> $config_h
+    fi
   ;;
   alpha)
     echo "TARGET_ARCH=alpha" >> $config_mak
hw/boards.h +3 -0
index 7fada94..5611d2c 100644
@@ -32,6 +32,9 @@ extern QEMUMachine axisdev88_machine;
 extern QEMUMachine pc_machine;
 extern QEMUMachine isapc_machine;
 
+/* xen_machine.c */
+extern QEMUMachine xenpv_machine;
+
 /* ppc.c */
 extern QEMUMachine prep_machine;
 extern QEMUMachine core99_machine;
hw/xen.h new file +20 -0
new file mode 100644
index 0000000..3c8da41
@@ -0,0 +1,20 @@
+#ifndef QEMU_HW_XEN_H
+#define QEMU_HW_XEN_H 1
+/*
+ * public xen header
+ *   stuff needed outside xen-*.c, i.e. interfaces to qemu.
+ *   must not depend on any xen headers being present in
+ *   /usr/include/xen, so it can be included unconditionally.
+ */
+
+/* xen-machine.c */
+enum xen_mode {
+    XEN_EMULATE = 0,  // xen emulation, using xenner (default)
+    XEN_CREATE,       // create xen domain
+    XEN_ATTACH        // attach to xen domain created by xend
+};
+
+extern uint32_t xen_domid;
+extern enum xen_mode xen_mode;
+
+#endif /* QEMU_HW_XEN_H */
hw/xen_machine_pv.c new file +60 -0

60 lines not on this page · raw message

qemu-options.hx +11 -0
index 1d783e5..1f78021 100644
@@ -1333,6 +1333,17 @@ Enable KVM full virtualization support. This option is only available
 if KVM support is enabled when compiling.
 ETEXI
 
+#ifdef CONFIG_XEN
+DEF("xen-domid", HAS_ARG, QEMU_OPTION_xen_domid,
+    "-xen-domid id   specify xen guest domain id\n")
+DEF("xen-create", 0, QEMU_OPTION_xen_create,
+    "-xen-create     create domain using xen hypercalls, bypassing xend\n"
+    "                warning: should not be used when xend is in use\n")
+DEF("xen-attach", 0, QEMU_OPTION_xen_attach,
+    "-xen-attach     attach to existing xen domain\n"
+    "                xend will use this when starting qemu\n")
+#endif
+
 DEF("no-reboot", 0, QEMU_OPTION_no_reboot, \
     "-no-reboot      exit instead of rebooting\n")
 STEXI
target-i386/machine.c +3 -0
index 1cf49d5..1b0d36d 100644
@@ -9,6 +9,9 @@ void register_machines(void)
 {
     qemu_register_machine(&pc_machine);
     qemu_register_machine(&isapc_machine);
+#ifdef CONFIG_XEN
+    qemu_register_machine(&xenpv_machine);
+#endif
 }
 
 static void cpu_put_seg(QEMUFile *f, SegmentCache *dt)
vl.c +12 -0
index 55a9bc5..b681775 100644
@@ -139,6 +139,7 @@ int main(int argc, char **argv)
 #include "hw/baum.h"
 #include "hw/bt.h"
 #include "hw/smbios.h"
+#include "hw/xen.h"
 #include "bt-host.h"
 #include "net.h"
 #include "monitor.h"
@@ -4972,6 +4973,17 @@ int main(int argc, char **argv, char **envp)
                 run_as = optarg;
                 break;
 #endif
+#ifdef CONFIG_XEN
+            case QEMU_OPTION_xen_domid:
+                xen_domid = atoi(optarg);
+                break;
+            case QEMU_OPTION_xen_create:
+                xen_mode = XEN_CREATE;
+                break;
+            case QEMU_OPTION_xen_attach:
+                xen_mode = XEN_ATTACH;
+                break;
+#endif
             }
         }
     }
Signature · 1 line
1.6.2.2
#2 lore raw

PATCH 2/10 xen: backend driver core

In reply to 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, ...

---
 Makefile.target     |    2 +-
 hw/xen_backend.c    |  713 +++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/xen_backend.h    |   86 ++++++
 hw/xen_common.h     |   34 +++
 hw/xen_machine_pv.c |    8 +-
 5 files changed, 841 insertions(+), 2 deletions(-)
 create mode 100644 hw/xen_backend.c
 create mode 100644 hw/xen_backend.h
 create mode 100644 hw/xen_common.h
Makefile.target +1 -1
index ab59af3..52c8cd2 100644
@@ -561,7 +561,7 @@ LIBS += $(CONFIG_BLUEZ_LIBS)
 endif
 
 # xen backend driver support
-XEN_OBJS := xen_machine_pv.o
+XEN_OBJS := xen_machine_pv.o xen_backend.o
 ifeq ($(CONFIG_XEN), yes)
   OBJS += $(XEN_OBJS)
   LIBS += $(XEN_LIBS)
hw/xen_backend.c new file +713 -0

713 lines not on this page · raw message

hw/xen_backend.h new file +86 -0

86 lines not on this page · raw message

hw/xen_common.h new file +34 -0
new file mode 100644
index 0000000..7562567
@@ -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 */
hw/xen_machine_pv.c +7 -1
index f32ba7f..a6070fd 100644
@@ -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 @@ static void xen_init_pv(ram_addr_t ram_size, int vga_ram_size,
     }
     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 = {
Signature · 1 line
1.6.2.2
#3 lore raw

PATCH 3/10 xen: add console backend driver.

In reply to Gerd Hoffmann

This patch adds a xenconsole backend driver. It it based on current xen-unstable code. It has been changed to make use of the common backend driver code.

---
 Makefile.target     |    1 +
 hw/xen_backend.h    |    3 +
 hw/xen_console.c    |  270 +++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/xen_machine_pv.c |    1 +
 4 files changed, 275 insertions(+), 0 deletions(-)
 create mode 100644 hw/xen_console.c
Makefile.target +1 -0
index 52c8cd2..1cb86f9 100644
@@ -562,6 +562,7 @@ endif
 
 # xen backend driver support
 XEN_OBJS := xen_machine_pv.o xen_backend.o
+XEN_OBJS += xen_console.o
 ifeq ($(CONFIG_XEN), yes)
   OBJS += $(XEN_OBJS)
   LIBS += $(XEN_LIBS)
hw/xen_backend.h +3 -0
index a1243f6..4744713 100644
@@ -83,4 +83,7 @@ int xen_be_send_notify(struct XenDevice *xendev);
 void xen_be_printf(struct XenDevice *xendev, int msg_level, const char *fmt, ...)
     __attribute__ ((format(printf, 3, 4)));
 
+/* actual backend drivers */
+extern struct XenDevOps xen_console_ops;      /* xen_console.c     */
+
 #endif /* QEMU_HW_XEN_BACKEND_H */
hw/xen_console.c new file +270 -0

270 lines not on this page · raw message

hw/xen_machine_pv.c +1 -0
index a6070fd..93ab312 100644
@@ -56,6 +56,7 @@ static void xen_init_pv(ram_addr_t ram_size, int vga_ram_size,
         fprintf(stderr, "%s: xen backend core setup failed\n", __FUNCTION__);
         exit(1);
     }
+    xen_be_register("console", &xen_console_ops);
 }
 
 QEMUMachine xenpv_machine = {
Signature · 1 line
1.6.2.2
#4 lore raw

Re: [Qemu-devel] [PATCH 03/10] xen: add console backend driver.

Quoted 5 lines · Gerd Hoffmann

This patch adds a xenconsole backend driver. It it based on current
xen-unstable code. It has been changed to make use of the common backend driver code.

+ if (!type || 0 != strcmp(type, "ioemu")) {

Still one of these.

#5 lore raw

PATCH 4/10 xen: add framebuffer backend driver

In reply to Gerd Hoffmann

This patch adds a frsamebuffer (and kbd+mouse) backend driver. It it based on current xen-unstable code. It has been changed to make use of the common backend driver code. It also has been changed to compile with xen headers older than release 3.3

---
 Makefile.target     |    2 +-
 hw/xen_backend.h    |    4 +
 hw/xen_machine_pv.c |    5 +
 hw/xenfb.c          | 1013 +++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 1023 insertions(+), 1 deletions(-)
 create mode 100644 hw/xenfb.c
Makefile.target +1 -1
index 1cb86f9..8734190 100644
@@ -562,7 +562,7 @@ endif
 
 # xen backend driver support
 XEN_OBJS := xen_machine_pv.o xen_backend.o
-XEN_OBJS += xen_console.o
+XEN_OBJS += xen_console.o xenfb.o
 ifeq ($(CONFIG_XEN), yes)
   OBJS += $(XEN_OBJS)
   LIBS += $(XEN_LIBS)
hw/xen_backend.h +4 -0
index 4744713..e9a4e2d 100644
@@ -85,5 +85,9 @@ void xen_be_printf(struct XenDevice *xendev, int msg_level, const char *fmt, ...
 
 /* actual backend drivers */
 extern struct XenDevOps xen_console_ops;      /* xen_console.c     */
+extern struct XenDevOps xen_kbdmouse_ops;     /* xen_framebuffer.c */
+extern struct XenDevOps xen_framebuffer_ops;  /* xen_framebuffer.c */
+
+void xen_init_display(int domid);
 
 #endif /* QEMU_HW_XEN_BACKEND_H */
hw/xen_machine_pv.c +5 -0
index 93ab312..1f0b3ec 100644
@@ -57,6 +57,11 @@ static void xen_init_pv(ram_addr_t ram_size, int vga_ram_size,
         exit(1);
     }
     xen_be_register("console", &xen_console_ops);
+    xen_be_register("vkbd", &xen_kbdmouse_ops);
+    xen_be_register("vfb", &xen_framebuffer_ops);
+
+    /* setup framebuffer */
+    xen_init_display(xen_domid);
 }
 
 QEMUMachine xenpv_machine = {
hw/xenfb.c new file +1013 -0

1,013 lines not on this page · raw message

Signature · 1 line
1.6.2.2
#6 lore raw

PATCH 5/10 xen: add block device backend driver.

In reply to Gerd Hoffmann

This patch adds a block device backend driver to qemu. It is a pure userspace implemention using the gntdev interface. It uses "qdisk" as backend name in xenstore so it doesn't interfere with the other existing backends (blkback aka "vbd" and tapdisk aka "tap").

---
 Makefile.target     |    2 +-
 hw/xen_backend.h    |    2 +
 hw/xen_blkif.h      |  103 +++++++
 hw/xen_disk.c       |  779 +++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/xen_machine_pv.c |    1 +
 sysemu.h            |    2 +-
 vl.c                |    6 +-
 7 files changed, 892 insertions(+), 3 deletions(-)
 create mode 100644 hw/xen_blkif.h
 create mode 100644 hw/xen_disk.c
Makefile.target +1 -1
index 8734190..ea3b9d5 100644
@@ -562,7 +562,7 @@ endif
 
 # xen backend driver support
 XEN_OBJS := xen_machine_pv.o xen_backend.o
-XEN_OBJS += xen_console.o xenfb.o
+XEN_OBJS += xen_console.o xenfb.o xen_disk.o
 ifeq ($(CONFIG_XEN), yes)
   OBJS += $(XEN_OBJS)
   LIBS += $(XEN_LIBS)
hw/xen_backend.h +2 -0
index e9a4e2d..dd426dd 100644
@@ -2,6 +2,7 @@
 #define QEMU_HW_XEN_BACKEND_H 1
 
 #include "xen_common.h"
+#include "sysemu.h"
 
 /* ------------------------------------------------------------- */
 
@@ -87,6 +88,7 @@ void xen_be_printf(struct XenDevice *xendev, int msg_level, const char *fmt, ...
 extern struct XenDevOps xen_console_ops;      /* xen_console.c     */
 extern struct XenDevOps xen_kbdmouse_ops;     /* xen_framebuffer.c */
 extern struct XenDevOps xen_framebuffer_ops;  /* xen_framebuffer.c */
+extern struct XenDevOps xen_blkdev_ops;       /* xen_disk.c        */
 
 void xen_init_display(int domid);
 
hw/xen_blkif.h new file +103 -0

103 lines not on this page · raw message

hw/xen_disk.c new file +779 -0

779 lines not on this page · raw message

hw/xen_machine_pv.c +1 -0
index 1f0b3ec..c764bea 100644
@@ -59,6 +59,7 @@ static void xen_init_pv(ram_addr_t ram_size, int vga_ram_size,
     xen_be_register("console", &xen_console_ops);
     xen_be_register("vkbd", &xen_kbdmouse_ops);
     xen_be_register("vfb", &xen_framebuffer_ops);
+    xen_be_register("qdisk", &xen_blkdev_ops);
 
     /* setup framebuffer */
     xen_init_display(xen_domid);
sysemu.h +1 -1
index 24b4bd1..1f1a280 100644
@@ -127,7 +127,7 @@ extern unsigned int nb_prom_envs;
 #endif
 
 typedef enum {
-    IF_IDE, IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD, IF_SD, IF_VIRTIO
+    IF_IDE, IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD, IF_SD, IF_VIRTIO, IF_XEN
 } BlockInterfaceType;
 
 typedef enum {
vl.c +5 -1
index b681775..19cd28f 100644
@@ -2369,7 +2369,10 @@ int drive_init(struct drive_opt *arg, int snapshot, void *opaque)
         } else if (!strcmp(buf, "virtio")) {
             type = IF_VIRTIO;
             max_devs = 0;
-        } else {
+	} else if (!strcmp(buf, "xen")) {
+	    type = IF_XEN;
+            max_devs = 0;
+	} else {
             fprintf(stderr, "qemu: '%s' unsupported bus type '%s'\n", str, buf);
             return -1;
 	}
@@ -2583,6 +2586,7 @@ int drive_init(struct drive_opt *arg, int snapshot, void *opaque)
     switch(type) {
     case IF_IDE:
     case IF_SCSI:
+    case IF_XEN:
         switch(media) {
 	case MEDIA_DISK:
             if (cyls != 0) {
Signature · 1 line
1.6.2.2
#7 lore raw

Re: [Qemu-devel] [PATCH 05/10] xen: add block device backend driver.

Quoted 6 lines · Gerd Hoffmann

This patch adds a block device backend driver to qemu. It is a pure
userspace implemention using the gntdev interface. It uses "qdisk" as backend name in xenstore so it doesn't interfere with the other existing backends (blkback aka "vbd" and tapdisk aka "tap").

+ if (BLKIF_OP_READ != ioreq->req.operation && blkdev->mode[0] != 'w') {

Another one.

Quoted 1 line

+ while ((rc != rp)) {

Extra parenthesis.

#8 lore raw

PATCH 6/10 xen: add net backend driver.

In reply to Gerd Hoffmann

This patch adds a network interface backend driver to qemu. It is a pure userspace implemention using the gntdev interface. It uses "qnet" as backend name in xenstore so it doesn't interfere with the netback backend (aka "vnif").

The network backend is hooked into the corrosponding qemu vlan, i.e. vif 0 is hooked into vlan 0. To make the packages actually arrive somewhere you additionally have to link the vlan to the outside world using the usual qemu command line options such as "-net tap,...".

---
 Makefile.target     |    2 +-
 hw/xen_backend.h    |    1 +
 hw/xen_machine_pv.c |    1 +
 hw/xen_nic.c        |  406 +++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 409 insertions(+), 1 deletions(-)
 create mode 100644 hw/xen_nic.c
Makefile.target +1 -1
index ea3b9d5..8eeccbb 100644
@@ -562,7 +562,7 @@ endif
 
 # xen backend driver support
 XEN_OBJS := xen_machine_pv.o xen_backend.o
-XEN_OBJS += xen_console.o xenfb.o xen_disk.o
+XEN_OBJS += xen_console.o xenfb.o xen_disk.o xen_nic.o
 ifeq ($(CONFIG_XEN), yes)
   OBJS += $(XEN_OBJS)
   LIBS += $(XEN_LIBS)
hw/xen_backend.h +1 -0
index dd426dd..4e4be14 100644
@@ -89,6 +89,7 @@ extern struct XenDevOps xen_console_ops;      /* xen_console.c     */
 extern struct XenDevOps xen_kbdmouse_ops;     /* xen_framebuffer.c */
 extern struct XenDevOps xen_framebuffer_ops;  /* xen_framebuffer.c */
 extern struct XenDevOps xen_blkdev_ops;       /* xen_disk.c        */
+extern struct XenDevOps xen_netdev_ops;       /* xen_nic.c         */
 
 void xen_init_display(int domid);
 
hw/xen_machine_pv.c +1 -0
index c764bea..c21617a 100644
@@ -60,6 +60,7 @@ static void xen_init_pv(ram_addr_t ram_size, int vga_ram_size,
     xen_be_register("vkbd", &xen_kbdmouse_ops);
     xen_be_register("vfb", &xen_framebuffer_ops);
     xen_be_register("qdisk", &xen_blkdev_ops);
+    xen_be_register("qnic", &xen_netdev_ops);
 
     /* setup framebuffer */
     xen_init_display(xen_domid);
hw/xen_nic.c new file +406 -0

406 lines not on this page · raw message

Signature · 1 line
1.6.2.2
#9 lore raw

PATCH 7/10 xen: blk & nic configuration via cmd line.

In reply to Gerd Hoffmann

This patch makes qemu create backend and frontend device entries in xenstore for devices configured on the command line. It will use qdisk and qnic backend names, so the qemu internal backends will be used.

Disks can be created using -drive if=xen,file=...
Nics can be created using -net nic,macaddr=...

---
 Makefile.target     |    2 +-
 hw/xen_backend.c    |    1 +
 hw/xen_backend.h    |    8 +++
 hw/xen_devconfig.c  |  142 +++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/xen_machine_pv.c |   19 +++++++
 5 files changed, 171 insertions(+), 1 deletions(-)
 create mode 100644 hw/xen_devconfig.c
Makefile.target +1 -1
index 8eeccbb..24d409e 100644
@@ -561,7 +561,7 @@ LIBS += $(CONFIG_BLUEZ_LIBS)
 endif
 
 # xen backend driver support
-XEN_OBJS := xen_machine_pv.o xen_backend.o
+XEN_OBJS := xen_machine_pv.o xen_backend.o xen_devconfig.o
 XEN_OBJS += xen_console.o xenfb.o xen_disk.o xen_nic.o
 ifeq ($(CONFIG_XEN), yes)
   OBJS += $(XEN_OBJS)
hw/xen_backend.c +1 -0
index c1e3728..2f2ec7f 100644
@@ -45,6 +45,7 @@
 /* public */
 int xen_xc;
 struct xs_handle *xenstore = NULL;
+const char *xen_protocol;
 
 /* private */
 static TAILQ_HEAD(XenDeviceHead, XenDevice) xendevs = TAILQ_HEAD_INITIALIZER(xendevs);
hw/xen_backend.h +8 -0
index 4e4be14..7f1804e 100644
@@ -3,6 +3,8 @@
 
 #include "xen_common.h"
 #include "sysemu.h"
+#include "net.h"
+#include "block_int.h"
 
 /* ------------------------------------------------------------- */
 
@@ -56,6 +58,7 @@ struct XenDevice {
 /* variables */
 extern int xen_xc;
 extern struct xs_handle *xenstore;
+extern const char *xen_protocol;
 
 /* xenstore helper functions */
 int xenstore_write_str(const char *base, const char *node, const char *val);
@@ -93,4 +96,9 @@ extern struct XenDevOps xen_netdev_ops;       /* xen_nic.c         */
 
 void xen_init_display(int domid);
 
+/* configuration (aka xenbus setup) */
+void xen_config_cleanup(void);
+int xen_config_dev_blk(DriveInfo *disk);
+int xen_config_dev_nic(NICInfo *nic);
+
 #endif /* QEMU_HW_XEN_BACKEND_H */
hw/xen_devconfig.c new file +142 -0

142 lines not on this page · raw message

hw/xen_machine_pv.c +19 -0
index c21617a..154cf71 100644
@@ -39,6 +39,7 @@ static void xen_init_pv(ram_addr_t ram_size, int vga_ram_size,
 			const char *cpu_model)
 {
     CPUState *env;
+    int i, index;
 
     /* Initialize a dummy CPU */
     if (cpu_model == NULL) {
@@ -62,6 +63,24 @@ static void xen_init_pv(ram_addr_t ram_size, int vga_ram_size,
     xen_be_register("qdisk", &xen_blkdev_ops);
     xen_be_register("qnic", &xen_netdev_ops);
 
+    /* configure disks */
+    for (i = 0; i < 16; i++) {
+        index = drive_get_index(IF_XEN, 0, i);
+        if (index == -1)
+            continue;
+        xen_config_dev_blk(drives_table + index);
+    }
+
+    /* configure nics */
+    for (i = 0; i < nb_nics; i++) {
+        if (!nd_table[i].model || 0 != strcmp(nd_table[i].model, "xen"))
+            continue;
+        xen_config_dev_nic(nd_table + i);
+    }
+
+    /* config cleanup hook */
+    atexit(xen_config_cleanup);
+
     /* setup framebuffer */
     xen_init_display(xen_domid);
 }
Signature · 1 line
1.6.2.2
#10 lore raw

PATCH 8/10 xen: pv domain builder.

In reply to Gerd Hoffmann

This adds domain building support for paravirtual domains to qemu. This allows booting xen guests directly with qemu, without Xend and the management stack.

---
 Makefile.target      |    2 +-
 configure            |    2 +-
 hw/xen_backend.h     |    3 +
 hw/xen_devconfig.c   |   29 +++++
 hw/xen_domainbuild.c |  294 ++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/xen_domainbuild.h |   13 +++
 hw/xen_machine_pv.c  |   19 ++++
 7 files changed, 360 insertions(+), 2 deletions(-)
 create mode 100644 hw/xen_domainbuild.c
 create mode 100644 hw/xen_domainbuild.h
Makefile.target +1 -1
index 24d409e..2171587 100644
@@ -561,7 +561,7 @@ LIBS += $(CONFIG_BLUEZ_LIBS)
 endif
 
 # xen backend driver support
-XEN_OBJS := xen_machine_pv.o xen_backend.o xen_devconfig.o
+XEN_OBJS := xen_machine_pv.o xen_backend.o xen_devconfig.o xen_domainbuild.o
 XEN_OBJS += xen_console.o xenfb.o xen_disk.o xen_nic.o
 ifeq ($(CONFIG_XEN), yes)
   OBJS += $(XEN_OBJS)
configure +1 -1
index ec761ff..b7b7b01 100755
@@ -1634,7 +1634,7 @@ if test "$bluez" = "yes" ; then
   echo "#define CONFIG_BLUEZ 1" >> $config_h
 fi
 if test "$xen" = "yes" ; then
-  echo "XEN_LIBS=-lxenstore -lxenctrl" >> $config_mak
+  echo "XEN_LIBS=-lxenstore -lxenctrl -lxenguest" >> $config_mak
 fi
 if test "$aio" = "yes" ; then
   echo "#define CONFIG_AIO 1" >> $config_h
hw/xen_backend.h +3 -0
index 7f1804e..4dbfdb4 100644
@@ -100,5 +100,8 @@ void xen_init_display(int domid);
 void xen_config_cleanup(void);
 int xen_config_dev_blk(DriveInfo *disk);
 int xen_config_dev_nic(NICInfo *nic);
+int xen_config_dev_vfb(int vdev, const char *type);
+int xen_config_dev_vkbd(int vdev);
+int xen_config_dev_console(int vdev);
 
 #endif /* QEMU_HW_XEN_BACKEND_H */
hw/xen_devconfig.c +29 -0
index 4420561..4121188 100644
@@ -140,3 +140,32 @@ int xen_config_dev_nic(NICInfo *nic)
     /* common stuff */
     return xen_config_dev_all(fe, be);
 }
+
+int xen_config_dev_vfb(int vdev, const char *type)
+{
+    char fe[256], be[256];
+
+    xen_config_dev_dirs("vfb", "vfb", vdev, fe, be, sizeof(fe));
+
+    /* backend */
+    xenstore_write_str(be, "type",  type);
+
+    /* common stuff */
+    return xen_config_dev_all(fe, be);
+}
+
+int xen_config_dev_vkbd(int vdev)
+{
+    char fe[256], be[256];
+
+    xen_config_dev_dirs("vkbd", "vkbd", vdev, fe, be, sizeof(fe));
+    return xen_config_dev_all(fe, be);
+}
+
+int xen_config_dev_console(int vdev)
+{
+    char fe[256], be[256];
+
+    xen_config_dev_dirs("console", "console", vdev, fe, be, sizeof(fe));
+    return xen_config_dev_all(fe, be);
+}
hw/xen_domainbuild.c new file +294 -0

294 lines not on this page · raw message

hw/xen_domainbuild.h new file +13 -0
new file mode 100644
index 0000000..dea0121
@@ -0,0 +1,13 @@
+#ifndef QEMU_HW_XEN_DOMAINBUILD_H
+#define QEMU_HW_XEN_DOMAINBUILD_H 1
+
+#include "xen_common.h"
+
+int xenstore_domain_init1(const char *kernel, const char *ramdisk,
+                          const char *cmdline);
+int xenstore_domain_init2(int xenstore_port, int xenstore_mfn,
+                          int console_port, int console_mfn);
+int xen_domain_build_pv(const char *kernel, const char *ramdisk,
+                        const char *cmdline);
+
+#endif /* QEMU_HW_XEN_DOMAINBUILD_H */
hw/xen_machine_pv.c +19 -0
index 154cf71..56b01aa 100644
@@ -27,6 +27,7 @@
 #include "sysemu.h"
 #include "boards.h"
 #include "xen_backend.h"
+#include "xen_domainbuild.h"
 
 uint32_t xen_domid;
 enum xen_mode xen_mode = XEN_EMULATE;
@@ -57,6 +58,24 @@ static void xen_init_pv(ram_addr_t ram_size, int vga_ram_size,
         fprintf(stderr, "%s: xen backend core setup failed\n", __FUNCTION__);
         exit(1);
     }
+
+    switch (xen_mode) {
+    case XEN_ATTACH:
+        /* nothing to do, xend handles everything */
+        break;
+    case XEN_CREATE:
+        if (xen_domain_build_pv(kernel_filename, initrd_filename,
+                                kernel_cmdline) < 0) {
+            fprintf(stderr, "xen pv domain creation failed\n");
+            exit(1);
+        }
+        break;
+    case XEN_EMULATE:
+        fprintf(stderr, "xen emulation not implemented (yet)\n");
+        exit(1);
+        break;
+    }
+
     xen_be_register("console", &xen_console_ops);
     xen_be_register("vkbd", &xen_kbdmouse_ops);
     xen_be_register("vfb", &xen_framebuffer_ops);
Signature · 1 line
1.6.2.2
#11 lore raw

Re: [Qemu-devel] [PATCH 08/10] xen: pv domain builder.

Quoted 3 lines · Gerd Hoffmann

This adds domain building support for paravirtual domains to qemu.
This allows booting xen guests directly with qemu, without Xend and the management stack.

I found these:

Quoted 3 lines

+ if ((1 != rc) || (info.domid != xen_domid)) {

+ if (EINTR == errno)

#12 lore raw

PATCH 9/10 simplify vga selection

In reply to Gerd Hoffmann
---
 vl.c |   15 ++++-----------
 1 files changed, 4 insertions(+), 11 deletions(-)
vl.c +4 -11
index 19cd28f..7d6dcb6 100644
@@ -4162,23 +4162,16 @@ static void select_vgahw (const char *p)
 {
     const char *opts;
 
+    cirrus_vga_enabled = 0;
+    std_vga_enabled = 0;
+    vmsvga_enabled = 0;
     if (strstart(p, "std", &opts)) {
         std_vga_enabled = 1;
-        cirrus_vga_enabled = 0;
-        vmsvga_enabled = 0;
     } else if (strstart(p, "cirrus", &opts)) {
         cirrus_vga_enabled = 1;
-        std_vga_enabled = 0;
-        vmsvga_enabled = 0;
     } else if (strstart(p, "vmware", &opts)) {
-        cirrus_vga_enabled = 0;
-        std_vga_enabled = 0;
         vmsvga_enabled = 1;
-    } else if (strstart(p, "none", &opts)) {
-        cirrus_vga_enabled = 0;
-        std_vga_enabled = 0;
-        vmsvga_enabled = 0;
-    } else {
+    } else if (!strstart(p, "none", &opts)) {
     invalid_vga:
         fprintf(stderr, "Unknown vga type: %s\n", p);
         exit(1);
Signature · 1 line
1.6.2.2
#13 lore raw

PATCH 10/10 xen: add -vga xenfb option, configure xenfb

In reply to Gerd Hoffmann
---
 hw/xen_machine_pv.c |    6 ++++++
 qemu-options.hx     |    2 +-
 sysemu.h            |    1 +
 vl.c                |    4 ++++
 4 files changed, 12 insertions(+), 1 deletions(-)
hw/xen_machine_pv.c +6 -0
index 56b01aa..58209b8 100644
@@ -82,6 +82,12 @@ static void xen_init_pv(ram_addr_t ram_size, int vga_ram_size,
     xen_be_register("qdisk", &xen_blkdev_ops);
     xen_be_register("qnic", &xen_netdev_ops);
 
+    /* configure framebuffer */
+    if (xenfb_enabled) {
+        xen_config_dev_vfb(0, "vnc");
+        xen_config_dev_vkbd(0);
+    }
+
     /* configure disks */
     for (i = 0; i < 16; i++) {
         index = drive_get_index(IF_XEN, 0, i);
qemu-options.hx +1 -1
index 1f78021..7ae535a 100644
@@ -457,7 +457,7 @@ Rotate graphical output 90 deg left (only PXA LCD).
 ETEXI
 
 DEF("vga", HAS_ARG, QEMU_OPTION_vga,
-    "-vga [std|cirrus|vmware|none]\n"
+    "-vga [std|cirrus|vmware|xenfb|none]\n"
     "                select video card type\n")
 STEXI
 @item -vga @var{type}
sysemu.h +1 -0
index 1f1a280..d3f1cb6 100644
@@ -88,6 +88,7 @@ extern int bios_size;
 extern int cirrus_vga_enabled;
 extern int std_vga_enabled;
 extern int vmsvga_enabled;
+extern int xenfb_enabled;
 extern int graphic_width;
 extern int graphic_height;
 extern int graphic_depth;
vl.c +4 -0
index 7d6dcb6..1b34662 100644
@@ -216,6 +216,7 @@ static int rtc_date_offset = -1; /* -1 means no change */
 int cirrus_vga_enabled = 1;
 int std_vga_enabled = 0;
 int vmsvga_enabled = 0;
+int xenfb_enabled = 0;
 #ifdef TARGET_SPARC
 int graphic_width = 1024;
 int graphic_height = 768;
@@ -4165,12 +4166,15 @@ static void select_vgahw (const char *p)
     cirrus_vga_enabled = 0;
     std_vga_enabled = 0;
     vmsvga_enabled = 0;
+    xenfb_enabled = 0;
     if (strstart(p, "std", &opts)) {
         std_vga_enabled = 1;
     } else if (strstart(p, "cirrus", &opts)) {
         cirrus_vga_enabled = 1;
     } else if (strstart(p, "vmware", &opts)) {
         vmsvga_enabled = 1;
+    } else if (strstart(p, "xenfb", &opts)) {
+        xenfb_enabled = 1;
     } else if (!strstart(p, "none", &opts)) {
     invalid_vga:
         fprintf(stderr, "Unknown vga type: %s\n", p);
Signature · 1 line
1.6.2.2
#14 lore raw
In reply to Gerd Hoffmann

Gerd Hoffmann writes ("[Xen-devel] [PATCH 00/10] xen: pv domain support."):

Quoted 1 line

Next round, addressing review comments:

...

Quoted 2 lines

Ian, is just pulling from git fine with you? Or do you want the qemu-xen patches mailed to xen-devel?

I think that for form's sake it would be good for you to mail the patches to xen-devel but I'm happy to pull. So ideally a patch series submission which says `here are the diffs 0/n and also a git URL'. Is that a lot of work for you ? If so I can probably produce such a series of emails myself but I think since you're the originator of these patches I think it would make more sense for you to do it.

Thanks for your contributions. I'm definitely keen to have them and I'll be branching qemu-xen so that I can take your changes now rather than waiting for the Xen 3.4 release freeze to end.

It's good that you're posting this code to qemu-devel and getting review there. But I'd like the qemu developers to hold off committing these changes to their tree until the files which are being added are 100% identical in Gerd's patch series to in qemu-xen-unstable.

That way qemu upstream will remain directly mergeable into qemu-xen-unstable because the code in the new files will be identical. Anything else will make my life very painful.

To make this happen I'm of course happy to take patches to make sure that the code which is in qemu-xen-unstable is in the form that qemu upstream want it for merging.

Ian.

#15 lore raw
Quoted 10 lines · Ian Jackson

Gerd Hoffmann writes ("[Xen-devel] [PATCH 00/10] xen: pv domain support."):

Quoted 1 line

Next round, addressing review comments:

...

Quoted 2 lines

Ian, is just pulling from git fine with you? Or do you want the qemu-xen patches mailed to xen-devel?

I think that for form's sake it would be good for you to mail the patches to xen-devel but I'm happy to pull. So ideally a patch series submission which says `here are the diffs 0/n and also a git URL'. Is that a lot of work for you ?

No, will do, git does most of the hard work ;)

I'm just asking because it is a bit redundant and I don't want to patch-flood the lists more than necessary ...

cheers,
Gerd

#16 lore raw
In reply to Ian Jackson

Hi Ian,

Quoted 13 lines · Ian Jackson

Gerd Hoffmann writes ("[Xen-devel] [PATCH 00/10] xen: pv domain support."):

Quoted 1 line

Next round, addressing review comments:

...

Quoted 2 lines

Ian, is just pulling from git fine with you?  Or do you want the qemu-xen patches mailed to xen-devel?

I think that for form's sake it would be good for you to mail the patches to xen-devel but I'm happy to pull.  So ideally a patch series submission which says `here are the diffs 0/n and also a git URL'. Is that a lot of work for you ?  If so I can probably produce such a series of emails myself but I think since you're the originator of these patches I think it would make more sense for you to do it.

Quoted 3 lines

Thanks for your contributions.  I'm definitely keen to have them and I'll be branching qemu-xen so that I can take your changes now rather than waiting for the Xen 3.4 release freeze to end.

Do you have an idea when you expect to push these to qemu-unstable?

Thanks,

MRJ

Quoted 20 lines

It's good that you're posting this code to qemu-devel and getting review there.  But I'd like the qemu developers to hold off committing these changes to their tree until the files which are being added are 100% identical in Gerd's patch series to in qemu-xen-unstable.

That way qemu upstream will remain directly mergeable into qemu-xen-unstable because the code in the new files will be identical. Anything else will make my life very painful.

To make this happen I'm of course happy to take patches to make sure that the code which is in qemu-xen-unstable is in the form that qemu upstream want it for merging.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#17 lore raw

Mark Johnson writes ("Re: [Xen-devel] [PATCH 00/10] xen: pv domain support."):

Quoted 1 line

Do you have an idea when you expect to push these to qemu-unstable?

I pushed them to staging earlier today. Hopefully they'll make it through our automated tests without problems.

Thanks,
Ian.

#18 lore raw
In reply to Gerd Hoffmann
Quoted 11 lines · Gerd Hoffmann

Hi,

Next round, addressing review comments:

* Fixup more "if (-1 == foo()) bar()" compare style.
* Fixup logging: kill fprintf(stderr, ...), use logging API.
* Kill some unneeded malloc failure checks.

The patches are also rebased to latest git and got a few adaptions to recent cha

Applied full series. Thanks.

I think it can still use some love (some files missing copyrights/license, for instance), but it's all extremely well contained so there's little point in keeping it out of tree.

Regards,

Anthony Liguori

Quoted 6 lines

cheers,
Gerd

#19 lore raw
Quoted 13 lines · Anthony Liguori
Quoted 11 lines · Gerd Hoffmann

Hi,

Next round, addressing review comments:

* Fixup more "if (-1 == foo()) bar()" compare style.
* Fixup logging: kill fprintf(stderr, ...), use logging API.
* Kill some unneeded malloc failure checks.

The patches are also rebased to latest git and got a few adaptions to recent cha

Quoted 6 lines

Applied full series. Thanks.

I think it can still use some love (some files missing copyrights/license, for instance), but it's all extremely well contained so there's little point in keeping it out of tree.

The point was for Ian to be able to pull directly from qemu without getting any conflicts on those files.
To be honest they are fairly similar now, so I am confident that git will be able to do its magic.

#20 lore raw

Hi,

Quoted 4 lines

The point was for Ian to be able to pull directly from qemu without getting any conflicts on those files.
To be honest they are fairly similar now, so I am confident that git will be able to do its magic.

Ian can merge the changes from my repo first, then upstream qemu. Maybe the later splitted into the first four patches (the stuff already in qemu-xen) and then the remaining bits (disk+nic backend & friends) which Ian wants to get via upstream qemu. That should work out well.

cheers,
Gerd