Skip to contentSkip to conversation

merge some xen bits into qemu

PATCH In review Gerd Hoffmann 6 participants 21 messages Oct 28, 2008 – Oct 30, 2008 Kbuild

lore
Share & tools
lore
#0 lore raw

cover merge some xen bits into qemu

Hi folks,

This is version #5 of the xen support for qemu patch series.

It has been quiet for a while, mostly due to qemu-xen lagging behind qemu-upstream. Now it catched up with upstream, so it is time to make some progress here. Not many changes since the last time I posted the patches. Some prelimary stuff has been merged and thus is gone, some bugs have been fixed, some adaptions to recent changes happend.

The console and framebuffer backend drivers are largely based on the xen code, the other bits are rewritten from scratch. Nevertheless the code should be functionally identical.

Overview (individual patches have longer descriptions):

#1 -- groundwork: build system, cmd line options, ... #2 -- xen backend driver infrastructrure
#3 -- xen console backend driver
#4 -- xen framebuffer backend driver

#5 -- xen block backend driver
#6 -- xen nic backend driver
#7 -- allow xen disks and nics being configured via qemu command
line options.

With first next four patches in place upstream qemu can replace xen's qemu-dm for paravirtual domains. Due to some small differences in the command line syntax it can't work as drop-in replacement though.

The last three patches add full userspace implementations of block and nic backend drivers using the grant table device (gntdev) and command line support config support for setting up these backends.

xen support is implemented using another machine type. xen's qemu-dm already uses the machine type to switch between paravirtualized and fully virtualized machines, so this was the natural choice. qemu gets a new "xenpv" machine type additionally to the "pc" and "isapc" ones.

The patches are also available here (Patches 0002 -> 0008):
http://kraxel.fedorapeople.org/patches/qemu-upstream/

There is also a patch queue for qemu-xen, located here:
http://kraxel.fedorapeople.org/patches/qemu-xen/

There also a '-b' (no whitespace changes) version for easier review:
http://kraxel.fedorapeople.org/patches/qemu-xen/no-ws/

The qemu-xen patch series has a slightly different ordering to make the patch queue more bisect-friendly. Also the command line syntax is unchanged, so we don't break qemu-dm <=> xend interaction. It should work just fine as drop-in replacement, without regressions, with the additional bonus that the framebuffer handles a restart cycle correctly (i.e. pvgrub in graphical mode actually works).

Comments?

cheers,
Gerd

#1 lore raw

PATCH 1/7 xen: groundwork for xen support

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

---
 Makefile.target       |    8 ++++
 configure             |   36 +++++++++++++++++
 hw/boards.h           |    3 +
 hw/xen.h              |   20 +++++++++
 hw/xen_machine_pv.c   |  105 +++++++++++++++++++++++++++++++++++++++++++++++++
 target-i386/machine.c |    3 +
 vl.c                  |   29 +++++++++++++
 7 files changed, 204 insertions(+), 0 deletions(-)
 create mode 100644 hw/xen.h
 create mode 100644 hw/xen_machine_pv.c
Makefile.target +8 -0
index f9c0b34..5368f6e 100644
@@ -629,6 +629,14 @@ 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)
+  $(XEN_OBJS) : CFLAGS += -Wall -Wmissing-prototypes -Wstrict-prototypes
+endif
+
 # SCSI layer
 OBJS+= lsi53c895a.o esp.o
 
configure +36 -0
index ccc4ae0..b1ab014 100755
@@ -114,6 +114,9 @@ aio="yes"
 nptl="yes"
 mixemu="no"
 bluez="yes"
+signalfd="no"
+eventfd="no"
+xen="yes"
 
 # OS specific
 targetos=`uname -s`
@@ -298,6 +301,8 @@ for opt do
   ;;
   --disable-kqemu) kqemu="no"
   ;;
+  --disable-xen) xen="no"
+  ;;
   --disable-brlapi) brlapi="no"
   ;;
   --disable-bluez) bluez="no"
@@ -441,6 +446,7 @@ echo "                           Available drivers: $audio_possible_drivers"
 echo "  --audio-card-list=LIST   set list of additional emulated audio cards"
 echo "                           Available cards: ac97 adlib cs4231a gus"
 echo "  --enable-mixemu          enable mixer emulation"
+echo "  --disable-xen            disable xen backend driver support"
 echo "  --disable-brlapi         disable BrlAPI"
 echo "  --disable-vnc-tls        disable TLS encryption for VNC server"
 echo "  --disable-curses         disable curses output"
@@ -748,6 +754,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
@@ -1026,6 +1048,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" ] && \
@@ -1296,6 +1319,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
@@ -1417,6 +1443,11 @@ case "$target_cpu" in
     then
       echo "#define USE_KQEMU 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
     gcc3minver=`$cc --version 2> /dev/null| fgrep "(GCC) 3." | awk '{ print $3 }' | cut -f2 -d.`
     if test -n "$gcc3minver" && test $gcc3minver -gt 3
     then
@@ -1434,6 +1465,11 @@ case "$target_cpu" in
     then
       echo "#define USE_KQEMU 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 d30c0fc..9bcfdae 100644
@@ -32,6 +32,9 @@ extern QEMUMachine bareetraxfs_machine;
 extern QEMUMachine pc_machine;
 extern QEMUMachine isapc_machine;
 
+/* xen_machine.c */
+extern QEMUMachine xenpv_machine;
+
 /* ppc.c */
 extern QEMUMachine prep_machine;
 extern QEMUMachine core99_machine;
hw/xen.h new file +20 -0
new file mode 100644
index 0000000..4bcc0f1
@@ -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 int xen_domid;
+extern enum xen_mode xen_mode;
+
+#endif /* QEMU_HW_XEN_H */
hw/xen_machine_pv.c new file +105 -0

105 lines not on this page · raw message

target-i386/machine.c +3 -0
index 9d440fb..be10cfb 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 +29 -0
index 0ca7151..0d275bf 100644
@@ -30,6 +30,7 @@
 #include "hw/isa.h"
 #include "hw/baum.h"
 #include "hw/bt.h"
+#include "hw/xen.h"
 #include "net.h"
 #include "console.h"
 #include "sysemu.h"
@@ -8282,6 +8283,13 @@ static void help(int exitcode)
            "-startdate      select initial date of the clock\n"
            "-icount [N|auto]\n"
            "                Enable virtual instruction counter with 2^N clock ticks per instruction\n"
+#ifdef CONFIG_XEN
+           "-xen-domid id   specify xen guest domain id\n"
+           "-xen-create     create domain using xen hypercalls, bypassing xend\n"
+           "                warning: should not be used when xend is in use\n"
+           "-xen-attach     attach to existing xen domain\n"
+           "                xend will use this when starting qemu\n"
+#endif
            "\n"
            "During emulation, the following keys are useful:\n"
            "ctrl-alt-f      toggle full screen\n"
@@ -8387,6 +8395,11 @@ enum {
     QEMU_OPTION_icount,
     QEMU_OPTION_uuid,
     QEMU_OPTION_incoming,
+#ifdef CONFIG_XEN
+    QEMU_OPTION_xen_domid,
+    QEMU_OPTION_xen_create,
+    QEMU_OPTION_xen_attach,
+#endif
 };
 
 typedef struct QEMUOption {
@@ -8476,6 +8489,11 @@ static const QEMUOption qemu_options[] = {
     { "curses", 0, QEMU_OPTION_curses },
 #endif
     { "uuid", HAS_ARG, QEMU_OPTION_uuid },
+#ifdef CONFIG_XEN
+    { "xen-domid", HAS_ARG, QEMU_OPTION_xen_domid },
+    { "xen-create", 0, QEMU_OPTION_xen_create },
+    { "xen-attach", 0, QEMU_OPTION_xen_attach },
+#endif
 
     /* temporary options */
     { "usb", 0, QEMU_OPTION_usb },
@@ -9403,6 +9421,17 @@ int main(int argc, char **argv)
             case QEMU_OPTION_incoming:
                 incoming = optarg;
                 break;
+#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.5.6.5
#2 lore raw

PATCH 2/7 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    |  691 +++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/xen_backend.h    |   86 +++++++
 hw/xen_common.h     |   34 +++
 hw/xen_machine_pv.c |    8 +-
 5 files changed, 818 insertions(+), 3 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 5368f6e..c18cbc6 100644
@@ -630,7 +630,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 +691 -0

691 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 +6 -2
index 9daab75..67f997f 100644
@@ -25,8 +25,7 @@
 #include "hw.h"
 #include "boards.h"
 
-#include "xen.h"
-#include <xenctrl.h>
+#include "xen_backend.h"
 
 /* -------------------------------------------------------------------- */
 /* variables                                                            */
@@ -48,6 +47,11 @@ static int xen_init(void)
         fprintf(stderr, "%s: emulating Xen\n", __FUNCTION__);
     }
 
+    if (-1 == xen_be_init()) {
+        fprintf(stderr, "%s: xen backend core setup failed\n", __FUNCTION__);
+        return -1;
+    }
+
     return 0;
 }
 
Signature · 1 line
1.5.6.5
#3 lore raw

PATCH 3/7 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    |  276 +++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/xen_machine_pv.c |    3 +
 4 files changed, 283 insertions(+), 0 deletions(-)
 create mode 100644 hw/xen_console.c
Makefile.target +1 -0
index c18cbc6..50f1dca 100644
@@ -631,6 +631,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 +276 -0

276 lines not on this page · raw message

hw/xen_machine_pv.c +3 -0
index 67f997f..fca2e09 100644
@@ -63,6 +63,9 @@ static int xen_init_pv(DisplayState *ds)
     if (rc < 0)
         return rc;
 
+    /* xenbus backend drivers */
+    xen_be_register("console", &xen_console_ops);
+
     return 0;
 }
 
Signature · 1 line
1.5.6.5
#4 lore raw

Re: [Qemu-devel] [PATCH 3/7] xen: add console backend driver.

Quoted 7 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.

 + *  You should have received a copy of the GNU General Public License
 + *  along with this program; if not, write to the Free Software
 + *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

As if anyone cares: FSF address in this patch and others should probably be 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

#5 lore raw

Re: [Qemu-devel] [PATCH 3/7] xen: add console backend driver.

Quoted 11 lines · Blue Swirl
Quoted 7 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.

 + *  You should have received a copy of the GNU General Public License
 + *  along with this program; if not, write to the Free Software
 + *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

As if anyone cares: FSF address in this patch and others should probably be 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

Hmm, would it be ok to just scratch the whole paragraph from the comment, so we avoid stale address info in the first place? Shouldn't be needed to make clear the source code is GPL, but IANAL ...

cheers,
Gerd

#6 lore raw

PATCH 4/7 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 unstable (aka son-to-be 3.3).

---
 Makefile.target     |    2 +-
 hw/xen_backend.h    |    4 +
 hw/xen_machine_pv.c |    5 +
 hw/xenfb.c          |  977 +++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 987 insertions(+), 1 deletions(-)
 create mode 100644 hw/xenfb.c
Makefile.target +1 -1
index 50f1dca..7606a20 100644
@@ -631,7 +631,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..ceeb3aa 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_set_display(int domid, DisplayState *ds);
 
 #endif /* QEMU_HW_XEN_BACKEND_H */
hw/xen_machine_pv.c +5 -0
index fca2e09..38e7335 100644
@@ -65,6 +65,11 @@ static int xen_init_pv(DisplayState *ds)
 
     /* xenbus backend drivers */
     xen_be_register("console", &xen_console_ops);
+    xen_be_register("vkbd", &xen_kbdmouse_ops);
+    xen_be_register("vfb", &xen_framebuffer_ops);
+
+    /* setup framebuffer */
+    xen_set_display(xen_domid, ds);
 
     return 0;
 }
hw/xenfb.c new file +977 -0

977 lines not on this page · raw message

Signature · 1 line
1.5.6.5
#7 lore raw

PATCH 5/7 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       |  694 +++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/xen_machine_pv.c |    1 +
 sysemu.h            |    2 +-
 vl.c                |    4 +
 7 files changed, 806 insertions(+), 2 deletions(-)
 create mode 100644 hw/xen_blkif.h
 create mode 100644 hw/xen_disk.c
Makefile.target +1 -1
index 7606a20..22bdd69 100644
@@ -631,7 +631,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 ceeb3aa..4fe9ad0 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_set_display(int domid, DisplayState *ds);
 
hw/xen_blkif.h new file +103 -0

103 lines not on this page · raw message

hw/xen_disk.c new file +694 -0

694 lines not on this page · raw message

hw/xen_machine_pv.c +1 -0
index 38e7335..f750b0b 100644
@@ -67,6 +67,7 @@ static int xen_init_pv(DisplayState *ds)
     xen_be_register("console", &xen_console_ops);
     xen_be_register("vkbd", &xen_kbdmouse_ops);
     xen_be_register("vfb", &xen_framebuffer_ops);
+    xen_be_register("qdisk", &xen_blkdev_ops);
 
     /* setup framebuffer */
     xen_set_display(xen_domid, ds);
sysemu.h +1 -1
index 976fecc..67404c2 100644
@@ -123,7 +123,7 @@ extern unsigned int nb_prom_envs;
 #endif
 
 typedef enum {
-    IF_IDE, IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD, IF_SD
+    IF_IDE, IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD, IF_SD, IF_XEN
 } BlockInterfaceType;
 
 typedef struct DriveInfo {
vl.c +4 -0
index 0d275bf..a28ba86 100644
@@ -5563,6 +5563,9 @@ static int drive_init(struct drive_opt *arg, int snapshot,
 	} else if (!strcmp(buf, "sd")) {
 	    type = IF_SD;
             max_devs = 0;
+	} else if (!strcmp(buf, "xen")) {
+	    type = IF_XEN;
+            max_devs = 0;
 	} else {
             fprintf(stderr, "qemu: '%s' unsupported bus type '%s'\n", str, buf);
             return -1;
@@ -5750,6 +5753,7 @@ static int drive_init(struct drive_opt *arg, int snapshot,
     switch(type) {
     case IF_IDE:
     case IF_SCSI:
+    case IF_XEN:
         switch(media) {
 	case MEDIA_DISK:
             if (cyls != 0) {
Signature · 1 line
1.5.6.5
#8 lore raw

PATCH 6/7 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        |  386 +++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 389 insertions(+), 1 deletions(-)
 create mode 100644 hw/xen_nic.c
Makefile.target +1 -1
index 22bdd69..aa4e2c8 100644
@@ -631,7 +631,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 4fe9ad0..d676aeb 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_set_display(int domid, DisplayState *ds);
 
hw/xen_machine_pv.c +1 -0
index f750b0b..9ba2c8a 100644
@@ -68,6 +68,7 @@ static int xen_init_pv(DisplayState *ds)
     xen_be_register("vkbd", &xen_kbdmouse_ops);
     xen_be_register("vfb", &xen_framebuffer_ops);
     xen_be_register("qdisk", &xen_blkdev_ops);
+    xen_be_register("qnic", &xen_netdev_ops);
 
     /* setup framebuffer */
     xen_set_display(xen_domid, ds);
hw/xen_nic.c new file +386 -0

386 lines not on this page · raw message

Signature · 1 line
1.5.6.5
#9 lore raw

PATCH 7/7 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  |  143 +++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/xen_machine_pv.c |   19 ++++++-
 5 files changed, 171 insertions(+), 2 deletions(-)
 create mode 100644 hw/xen_devconfig.c
Makefile.target +1 -1
index aa4e2c8..57ba699 100644
@@ -630,7 +630,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 2678dfa..2bd4433 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 d676aeb..7d2cf0a 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_set_display(int domid, DisplayState *ds);
 
+/* configuration (aka xenbus setup) */
+void xen_config_cleanup(void);
+int xen_config_dev_blk(DriveInfo *disk);
+int xen_config_dev_nic(NICInfo *nic);
+
 #endif /* QEMU_HW_XEN_BACKEND_H */
hw/xen_devconfig.c new file +143 -0

143 lines not on this page · raw message

hw/xen_machine_pv.c +18 -1
index 9ba2c8a..95ad11e 100644
@@ -87,7 +87,7 @@ static void xenpv_init(ram_addr_t ram_size, int vga_ram_size,
 		       const char *cpu_model)
 {
     CPUState *env;
-    int rc;
+    int index,i,rc;
 
     rc = xen_init_pv(ds);
     if (-1 == rc)
@@ -104,6 +104,23 @@ static void xenpv_init(ram_addr_t ram_size, int vga_ram_size,
     env = cpu_init(cpu_model);
     env->halted = 1;
 
+    /* configure disks */
+    for (i = 0; i < 16; i++) {
+        index = drive_get_index(IF_XEN, 0, i);
+	if (index == -1)
+	    continue;
+	xen_config_dev_blk(drives_table + index);
+    }
+
+    /* configure nics */
+    for (i = 0; i < nb_nics; i++) {
+	if (nd_table[i].model && 0 != strcmp(nd_table[i].model, "xen"))
+	    continue;
+        xen_config_dev_nic(nd_table + i);
+    }
+
+    /* config cleanup hook */
+    atexit(xen_config_cleanup);
     return;
 
 err:
Signature · 1 line
1.5.6.5
#10 lore raw
In reply to Gerd Hoffmann

People unfamiliar with the context should note that Gerd's submission is NOT `merging some Xen bits into qemu'. The code that Gerd is submitting is VERY SUBSTANTIALLY DIFFERENT from the code which exists in the Xen version of qemu.

Gerd Hoffmann writes ("[Xen-devel] [PATCH 0/7] merge some xen bits into qemu"):

Quoted 3 lines

The console and framebuffer backend drivers are largely based on the xen code, the other bits are rewritten from scratch. Nevertheless the code should be functionally identical.

I'm afraid I'm still opposed to the approach you are taking here.

The correct route for Xen support for qemu is via qemu-xen-unstable, not directly into upstream qemu.

If you want to generalise the backend driver machinery, which in qemu-xen-unstable is used only for the framebuffer, you should submit your generalised backend machinery on qemu-devel. We will review it and include it (when it is of appropriate quality).

Then when we have the Xen-specific structure and interfaces properly supported, it would be right to submit parts to qemu upstream. This will form a good basis for your other backend drivers (which are not useful in the context of a real Xen setup).

Quoted 3 lines

With first next four patches in place upstream qemu can replace xen's qemu-dm for paravirtual domains. Due to some small differences in the command line syntax it can't work as drop-in replacement though.

qemu-dm is hardly used for paravirtual domains so this is not really very helpful. qemu-dm is not even used at all for most PV domains. The main purpose of qemu-dm is for HVM domains.

Command-line differences are not very important in the grand scheme of things but they too need to come through xen-devel so that there is a sane transition.

Quoted 9 lines

The last three patches add full userspace implementations of block and nic backend drivers using the grant table device (gntdev) and command line support config support for setting up these backends.

xen support is implemented using another machine type. xen's qemu-dm already uses the machine type to switch between paravirtualized and fully virtualized machines, so this was the natural choice. qemu gets a new "xenpv" machine type additionally to the "pc" and "isapc" ones.

For the avoidance of any doubt, Gerd's machine types are for _emulating_ a Xen environment on a machine without a real Xen hypervisor.

Gerd: Why do I keep having to repeat this point ? Your messages always obscure it.

So in summary: Gerd, please post your suggestions to xen-devel only and explain what the purpose of each patch is.

If their intended use is for a system with a real Xen hypervisor and xend, and the patches makes sense, then we will of course take them.

If the intended use is to clean up the code so that it will be easier for you to fit in your simulated-Xen support then that is fine too, but the patches must go through xen-devel and be discussed there in that context. When we have agreed on and committed changes in qemu-xen-unstable, it will be appropriate to submit those to qemu-devel.

In any case, we do not want any huge upheavals in this area that are not dealt with appropriately through the Xen testing and release processes. We definitely don't want to have replacements of whole swathes of our existing code appear in qemu upstream!

Please stop crossposting to qemu-devel; it is just causing confusion.

Ian.

#11 lore raw

Hi Ian,

Quoted 5 lines · Ian Jackson

People unfamiliar with the context should note that Gerd's submission is NOT `merging some Xen bits into qemu'. The code that Gerd is submitting is VERY SUBSTANTIALLY DIFFERENT from the code which exists in the Xen version of qemu.

Here's how I see things:

Gerd has implemented an alternative userspace for Xen PV guests all based on QEMU. The code is well structured and integrates into QEMU in a nice way. On technical merits alone, I have a hard time not merging it into QEMU.

It's not Xend/blktap and while you all haven't been clear on this point, I don't think there's any chance that Xen.org or whatever your formal body is will ever bless this approach.

Naturally, this alternative userspace fits well for something like Xenner which emulates a Xen PV guest in QEMU or KVM. This is also something that I don't think Xen.org will ever bless.

Gerd has posted this series on xen-devel and there hasn't been any real substantial feedback. He's been pretty patient about it. I think this is somewhat misleading because I don't think there's any chance these patches will ever be pulled into xen-unstable. And BTW, any code that has a remote chance of being merged into QEMU eventually should be cross-posted on qemu-devel. Developing on xen-devel and then dropping a big pile of crud onto qemu-devel is not a viable development style. The same is true for other QEMU forks like KVM.

All this said, I don't think we should just pull in Gerd's patches as-is and forget about the Xen.org blessing. I want to encourage all of the work that's being done in xen-unstable to be merged back into QEMU upstream and that would certainly discourage this process.

So at this point, I think we need some clarification. Ian, if you have no intention of ever merging these patches in any form, I think you should be clear about that.

Gerd, I think you need to restructure your patches to do two things. The first is to never mention the name "Xen" as it's trademarked and owned by Xen.org. There should be no confusion that this functionality is in anyway endorsed or supported by Xen.org. The second thing is that whatever you do has to get easily out of the way of anything that's in xen-unstable. It should cause no merging pain to Ian. It should also be relatively easy to exclude from the build. If you just keep everything as separate files as you are, then it's just a matter of not compiling them in.

I hope this will make everyone happy and we can stop posting this series and arguing about it. Does anyone have any objections to this?

Regards,

Anthony Liguori

#12 lore raw

Anthony Liguori writes ("Re: [Qemu-devel] Re: [Xen-devel] [PATCH 0/7] merge some xen bits into qemu"):

Quoted 5 lines

[stuff]

It's not Xend/blktap and while you all haven't been clear on this point, I don't think there's any chance that Xen.org or whatever your formal body is will ever bless this approach.

Well, I don't think it is our (Xen.org's) role to bless it, nor is it our role to deprecate it. Having an alternative way of doing things is good for everyone really so from a personal point of view I would like to see it supported.

Quoted 5 lines

[procedural discussion]

So at this point, I think we need some clarification. Ian, if you have no intention of ever merging these patches in any form, I think you should be clear about that.

I do want to qemu upstream to support Xenner. And as regards qemu-xen I do want Gerd's changes to clean up our pv fb backend.

But I agree that I don't think it makes sense for Gerd's _other_ backend drivers (eg, the blkback) to go into qemu-xen-unstable; I'm happy for them to go into qemu upstream in due course.

Quoted 3 lines

I hope [the things suggested below] will make everyone happy and we can stop posting this series and arguing about it. Does anyone have any objections to this?

I think perhaps I'm being very defensive because I see a giant merge doom approaching. Gerd keeps posting his enormous patch series and my immediate priority is to stop it because it will make my life very difficult if it is just dumped in as-is.

So I apologise if I'm being overly defensive.

And I suppose you (Anthony) are right that I should not object to qemu-devel having visibility of these proposed changes. So I apologise for that.

Quoted 9 lines

Gerd, I think you need to restructure your patches to do two things. The first is to never mention the name "Xen" as it's trademarked and owned by Xen.org. There should be no confusion that this functionality is in anyway endorsed or supported by Xen.org. The second thing is that whatever you do has to get easily out of the way of anything that's in xen-unstable. It should cause no merging pain to Ian. It should also be relatively easy to exclude from the build. If you just keep everything as separate files as you are, then it's just a matter of not compiling them in.

That kind of approach would make me very happy.

I'd also obviously like to share code with Xenner where this is technically sensible.

I think what I would really like is to be able to straight away apply to qemu-xen-unstable the subset of Gerd's patches which are
- structural improvements to the qemu-dm pv fb backend including separating out the
- code improvements to the above
but excluding all of the other non-actual-Xen stuff.

When this is done and in xen-unstable and working, we can provide it to qemu-devel and at that point there won't be a merge problem because the code added in qemu upstream will be the same as that in qemu-xen.

_Then_ Gerd should submit his Xenner patches to qemu-devel and I'll have no objection (provided as Anthony suggests they don't interfere with our real-Xen setups, but I doubt there will be any insoluble problems).

If we could agree on this as an approach then we could spend our time dealing with code rather than trying to do politics.

In a spirit of goodwill I'll probably have a spare hour or two tomorrow to go through Gerd's patch series and try to experimentally separate out the backend-separation part with my tree and review it.

I'm afraid that I probably won't manage to get that stuff into qemu-xen-3.4 because I'm going away and have already just dumped a huge pile of new qemu upstream stuff into qemu-xen-unstable (because I started the merge late due to being pulled away on another project).

But I'm prepared to maintain another branch of qemu-xen-unstable if that helps. I'll discuss this with Keir tomorrow.

In terms of naming, I'm not an official representative of Xen.org or Citrix on this point, but I think since the name `xenner' has already been used to refer to the RH KVM-based Xen-emulation, it might be sensible to use that name to refer to Gerd's new arrangements.

So for example, having xenner_pv' and xenner_hvm' machine types, and `-xenner-vif' or whatever for Xenner's emulated backends.

Ian.

#13 lore raw
Quoted 4 lines · I wrote:

I think what I would really like is to be able to straight away apply to qemu-xen-unstable the subset of Gerd's patches which are
- structural improvements to the qemu-dm pv fb backend including separating out the

... common backend machinery

Quoted 2 lines

- code improvements to the above
but excluding all of the other non-actual-Xen stuff.

Ian.

#14 lore raw
In reply to Ian Jackson
Quoted 6 lines · Ian Jackson
Quoted 3 lines

So at this point, I think we need some clarification. Ian, if you have no intention of ever merging these patches in any form, I think you should be clear about that.

I do want to qemu upstream to support Xenner. And as regards qemu-xen I do want Gerd's changes to clean up our pv fb backend.

Great.

Quoted 8 lines

But I agree that I don't think it makes sense for Gerd's _other_ backend drivers (eg, the blkback) to go into qemu-xen-unstable; I'm happy for them to go into qemu upstream in due course.

I think perhaps I'm being very defensive because I see a giant merge doom approaching. Gerd keeps posting his enormous patch series and my immediate priority is to stop it because it will make my life very difficult if it is just dumped in as-is.

To avoid that merge disaster I have prepared patches for both upstream and qemu-xen, so you'll have the files I'm touching in both trees in a (almost) identical state when it comes to the next merge. git should have no trouble to handle it then.

Quoted 11 lines
Quoted 9 lines

Gerd, I think you need to restructure your patches to do two things. The first is to never mention the name "Xen" as it's trademarked and owned by Xen.org. There should be no confusion that this functionality is in anyway endorsed or supported by Xen.org. The second thing is that whatever you do has to get easily out of the way of anything that's in xen-unstable. It should cause no merging pain to Ian. It should also be relatively easy to exclude from the build. If you just keep everything as separate files as you are, then it's just a matter of not compiling them in.

That kind of approach would make me very happy.

I'm trying hard to not break qemu-xen and will continue to do so.

Quoted 9 lines

I'd also obviously like to share code with Xenner where this is technically sensible.

I think what I would really like is to be able to straight away apply to qemu-xen-unstable the subset of Gerd's patches which are
- structural improvements to the qemu-dm pv fb backend including separating out the
- code improvements to the above
but excluding all of the other non-actual-Xen stuff.

That are patches 1-4 (upstream) and patches 1-5 (qemu-xen).

Patch #1 for upstream qemu is splitted into two for qemu-xen (#1 and #5) to make the qemu-xen patch series bisectable.

The last three patches (5-7 upstream, 6-8 qemu-xen) are block backend, net backend and config bits for these.

Quoted 8 lines

When this is done and in xen-unstable and working, we can provide it to qemu-devel and at that point there won't be a merge problem because the code added in qemu upstream will be the same as that in qemu-xen.

_Then_ Gerd should submit his Xenner patches to qemu-devel and I'll have no objection (provided as Anthony suggests they don't interfere with our real-Xen setups, but I doubt there will be any insoluble problems).

I want keep both patch series in sync exactly to avoid merge issues. Thats why I'm posting the patches on both lists and take into account review comments from both sides. So when we agree on the final cut of the code it can be merged strait into both trees.

Quoted 2 lines

But I'm prepared to maintain another branch of qemu-xen-unstable if that helps. I'll discuss this wih Keir tomorrow.

That will surely help as it will decouple qemu development from xen release cycles. I'd suggest to branch off qemu-xen-3.4 when xen-unstable freezes for the 3.4 release.

Quoted 7 lines

In terms of naming, I'm not an official representative of Xen.org or Citrix on this point, but I think since the name `xenner' has already been used to refer to the RH KVM-based Xen-emulation, it might be sensible to use that name to refer to Gerd's new arrangements.

So for example, having xenner_pv' and xenner_hvm' machine types, and `-xenner-vif' or whatever for Xenner's emulated backends.

The naming convention I'm using right now is prefix 'xen_' for anything usable when running on the Xen hypervisor. That includes code which will be shared by xen and xenner such as the machine type. That also includes the block and net backends. They *do* work on Xen, and with some glue in xend you should be able to use them.

The xen emulation bits are prefixed with 'xenner_'. That includes event channel, grant table and xenstore implementations for example. None of these patches are submitted yet. Right now xenner isn't a separate compile time option. That should be easy to add though.

cheers
Gerd

#15 lore raw
In reply to Ian Jackson
Quoted 4 lines · Ian Jackson

People unfamiliar with the context should note that Gerd's submission is NOT `merging some Xen bits into qemu'. The code that Gerd is submitting is VERY SUBSTANTIALLY DIFFERENT from the code which exists in the Xen version of qemu.

Yes, as the the intro text says. You've even quoted the paragraph here:

Quoted 9 lines

Gerd Hoffmann writes ("[Xen-devel] [PATCH 0/7] merge some xen bits into qemu"):

Quoted 3 lines

The console and framebuffer backend drivers are largely based on the xen code, the other bits are rewritten from scratch. Nevertheless the code should be functionally identical.

I'm afraid I'm still opposed to the approach you are taking here.

The correct route for Xen support for qemu is via qemu-xen-unstable, not directly into upstream qemu.

There are *two* patch series for a reason. The one for upstream qemu, and the one for qemu-xen. After applying both patch sets to both threes they are largely identical. Anthony indicated that he wants to wait for the qemu-xen patches being accepted before merging the patches intended for upstream qemu. So where exactly is your problem?

Quoted 3 lines

If you want to generalise the backend driver machinery, which in qemu-xen-unstable is used only for the framebuffer, you should submit your generalised backend machinery on qemu-devel.

Just done.

Quoted 2 lines

qemu-dm is hardly used for paravirtual domains so this is not really very helpful. qemu-dm is not even used at all for most PV domains.

It isn't mandatory. But every pv domain using the pv framebuffer needs qemu-dm. It also can be used to handle the console instead of xenconsoled.

Quoted 3 lines

Command-line differences are not very important in the grand scheme of things but they too need to come through xen-devel so that there is a sane transition.

As noted in the intro text the qemu-xen patch series don't change the command line interface. I think it is easier to hash that out later separately and not involve xend changes in this patch series.

Quoted 3 lines

For the avoidance of any doubt, Gerd's machine types are for _emulating_ a Xen environment on a machine without a real Xen hypervisor.

That is one long term goal, yes. And I want the same backend code being used for both emulation and xen support. This patchset is about xen support only. There are no emulation bits, they will come later.

Quoted 2 lines

Gerd: Why do I keep having to repeat this point ? Your messages always obscure it.

When submitting xen emulation patches I will clearly state that.

Quoted 2 lines

So in summary: Gerd, please post your suggestions to xen-devel only and explain what the purpose of each patch is.

Not involving qemu-devel here is wrong. Discussing patches for upstream qemu without involving the relevant people isn't going to work.

Each patch comes with a description of the changes.

Quoted 2 lines

If their intended use is for a system with a real Xen hypervisor and xend, and the patches makes sense, then we will of course take them.

They are intended for a system with a Xen hypervisor.
The disk & nic backends need some windup in xend to be usable though.

Quoted 4 lines

In any case, we do not want any huge upheavals in this area that are not dealt with appropriately through the Xen testing and release processes. We definitely don't want to have replacements of whole swathes of our existing code appear in qemu upstream!

The qemu-xen series is bisectable. You can take the patches one by one, run them through the test setup @ XenSource and complain loudly if I broke something.

cheers,
Gerd

#16 lore raw
In reply to Ian Jackson

Ian Jackson <[email protected]> writes:

[...]

Quoted 2 lines

If their intended use is for a system with a real Xen hypervisor and xend, and the patches makes sense, then we will of course take them.

Refraining from comment on how to get Xen support into upstream qemu; instead let me just point out that Gerd's framebuffer code is a massive improvement in maintainability over what we have now in qemu-xen-unstable, and I'd very much like to see it merged there.

[...]

Quoted 1 line

Please stop crossposting to qemu-devel; it is just causing confusion.

I respectfully doubt that.

#17 lore raw
In reply to Gerd Hoffmann
Quoted 2 lines · Gerd Hoffmann, le Tue 28 Oct 2008 13:23:35 +0100, a écrit :

the framebuffer handles a restart cycle correctly
(i.e. pvgrub in graphical mode actually works).

Did you also try to check whether it could perhaps fix xen bug #1365?

Samuel

#18 lore raw
Quoted 5 lines · Samuel Thibault
Quoted 2 lines · Gerd Hoffmann, le Tue 28 Oct 2008 13:23:35 +0100, a écrit :

the framebuffer handles a restart cycle correctly
(i.e. pvgrub in graphical mode actually works).

Did you also try to check whether it could perhaps fix xen bug #1365?

Chances are pretty good it does. I've seen qemu-dm crash too, although it isn't 100% clear from the description it is actually the same bug.

With my fb backend code in place I can boot the domain, connect with a vnc client, see the pvgrub boot menu (framebuffer mode), interactively select a kernel, then watch the guest os come up in framebuffer mode. This all with correct screen display and without qemu-dm crashing along the way.

cheers,
Gerd

#19 lore raw
In reply to Gerd Hoffmann

Gerd Hoffmann writes ("Re: [Qemu-devel] Re: [Xen-devel] [PATCH 0/7] merge some xen bits into qemu"):

Quoted 9 lines
Quoted 6 lines · Ian Jackson

I think what I would really like is to be able to straight away apply to qemu-xen-unstable the subset of Gerd's patches which are
- structural improvements to the qemu-dm pv fb backend including separating out the
- code improvements to the above
but excluding all of the other non-actual-Xen stuff.

That are patches 1-4 (upstream) and patches 1-5 (qemu-xen).

I've taken a look at your `qemu-xen' series. I'm still keen to have the new backend structure.

I'm afraid I wasn't able in the short time I have today to tease out the parts which I think are important to go into qemu-xen-unstable now from the parts which I think should (following discussion) go directly into qemu upstream.

But as there is stuff here that I definitely want and which ought to go into qemu-xen-unstable for Xen 3.4, I was wondering if I could ask you to rework it into a form that I can apply to qemu-xen-unstable when I get back ?

So on to the details:

Firstly, I should say that this review is purely from the point of view of `should this stuff go into qemu-xen-unstable'. One reason not to put things into qemu-xen-unstable is because they should go directly upstream; another is of course that they still need work :-). I'll try to make this distinction clear in my comments.

Re 0002-xen-groundwork-for-xen-support.patch [1]:

* You introduce a new call to register xenpv_machine. But our existing machinery in qemu-xen-unstable for i386-dm already does this. So I think this is a mistake ? (I'm not opposed to a change to the place where qemu-dm does its machine registration if that would suit upstream better but you should surely remove the old registration call too?)

* You introduce the QEMU_OPTION_domid the default behaviour of which is XEN_ATTACH. I don't think this is correct in the long term because I think that by default qemu should never attach (or create). The upstream qemu should always emulate Xen things by default. In a real Xen environment the toolstack (xend) will know to pass qemu-dm an option saying `please attach'.

Otherwise people who try to run vanilla qemu in what happens to be a Xen guest will find all sorts of weird behaviours.

I know that we have a -domid option in qemu-xen-unstable but that is one of the things that we have deliberately avoided passing upstream. If upstream qemu is going to grow a -domid option it needs to default to emulating Xen and we should have a new option for enabling attach.

* I'm not sure that the new Makefile infrastructure you provide here is a good idea for the qemu-xen-unstable tree. The stuff in qemu-xen-unstable's build system is very unpleasant but it is specifically designed to avoid merge conflicts when qemu upstream Makefiles change, as they often do.

I would very much prefer to continue to deal with the Makefiles on this twin-track approach. So I would prefer it if you would add your new object files to xen-hooks.mak and xen-setup and so forth.

Then when the corresponding changes go upstream I'll just remove them again. This will be much less pain for me than dealing with <<< >>> in Makefiles.

I'm sorry that this means you need to do the build system parts of your changes twice. But I think doing it exactly twice is better than doing a similar amount of work every time there are textually-nearby changes in upstream's Makefiles.

Re 0003-xen-backend-driver-core.patch:

* You add xen_backend.o to your new Makefile infrastructure which isn't in qemu-xen-unstable yet - see above. But apart from that I think this is probably OK.

* I did get some compiler warnings eg:
/u/iwj/work/qemu-iwj.git/hw/xenfb.c:810: warning: passing argument 4 of 'xenfb_xs_printf' discards qualifiers from pointer target type
Maybe you don't have -Wwrite-strings in your setup ?

Re 0005-xen-add-framebuffer-backend-driver.patch:

* I haven't reviewed this in detail but I am keen to have your new framebuffer code. So provided this compiles and appears to work in a quick test I would like to apply it ASAP.

I only haven't done so right away because of the comments above.

Re 0004-xen-add-console-backend-driver.patch:

* There are many whitespace changes. Surely some mistake ? Or is this with a view to getting the coding style to resemble that in most of the rest of qemu ?

If so then I would prefer (as an exception!) a first separate patch to re-indent the existing code in hw/xen_console.c: that is, a patch consisting _only_ of whitespace changes. And then a separate patch containing no whitespace changes.

As it is I haven't been able to review this very deeply and I don't have time today to redo the diff myself with -b ...

Re 0006-xen-sync-xen_machine_pv-with-upstream.patch:

* What is the purpose of this patch ? `sync xen_machine_pv with upstream' ? Which upstream ? Many of these changes seem cosmetic.

Re 0007-xen-add-block-device-backend-driver.patch
and 0008-xen-add-net-backend-driver.patch:

* I don't have any objection to these in principle. However they are of no use or relevance to qemu-xen-unstable because we do not and will not use them. So they should go into upstream directly rather than via me I think ? However that needs to wait for the generic backend, which definitely should go into qemu-xen-unstable before it goes into qemu upstream. So I think these should wait for now.

Re 0009-xen-blk-nic-configuration-via-cmd-line.patch:

* I don't think I fully understand the purpose of this patch. It appears to be part of the Xenner emulation AFAICT ? When running under the real Xen toolstack we do not have qemu write these kind of entries to xenstore.

Instead, xenstore.c (in qemu-xen-unstable) reads the necessary information from xenstore and sets up the qemu internals appropriately.

And one final point:

* Have you been testing your tree on a real Xen host under xend ?

Quoted 4 lines

I want keep both patch series in sync exactly to avoid merge issues. Thats why I'm posting the patches on both lists and take into account review comments from both sides. So when we agree on the final cut of the code it can be merged strait into both trees.

That sounds sensible.

Quoted 6 lines
Quoted 2 lines

But I'm prepared to maintain another branch of qemu-xen-unstable if that helps. I'll discuss this wih Keir tomorrow.

That will surely help as it will decouple qemu development from xen release cycles. I'd suggest to branch off qemu-xen-3.4 when xen-unstable freezes for the 3.4 release.

I was thinking of doing that anyway.

Quoted 5 lines

The naming convention I'm using right now is prefix 'xen_' for anything usable when running on the Xen hypervisor. That includes code which will be shared by xen and xenner such as the machine type. That also includes the block and net backends. They *do* work on Xen, and with some glue in xend you should be able to use them.

Before we accept any incompatible changes into qemu-xen-unstable we obviously need the corresponding changes to xend too ?

But we are not going to be using the block and net backends in qemu. In a real Xen system these are provided by the dom0 kernel, which is a far superior arrangement (in our opinion!)

AIUI from your patch the xen_mode specifies whether we're doing Xenner or real Xen ? Am I right in thinking that the modes are these:

* XEN_EMULATE - Xenner (no Xen hypervisor, no xend)
IMO this should be the default for the qemu xen machine types in upstream qemu.
* XEN_ATTACH - for qemu-dm as invoked by xend
IMO arrangements should be made so that this is done only with a special command-line option, which is provided by xend.
* XEN_CREATE - Xen hypervisor but no xend
This is an unusual use case. I don't see any harm in having this as an option for people who want to do it that way. However, how do you control whether the block/net backends used are those in the dom0 kernel or those in qemu ?

I'm afraid that since I'm going away now for three weeks I won't be able to commit any revised versions soon. But as I say I hope to get this into 3.4 and I look forward to seeing your new proposals when I get back.

I hope you find this mail of mine suitably constructive. Again, sorry about being overly defensive earlier.

Ian.

#20 lore raw

Hi,

Quoted 4 lines

I'm afraid I wasn't able in the short time I have today to tease out the parts which I think are important to go into qemu-xen-unstable now from the parts which I think should (following discussion) go directly into qemu upstream.

Nevertheless I'm happy to finally see some progress here. Is somebody (Samuel?) working on qemu-xen while you are away?

Quoted 5 lines

Re 0002-xen-groundwork-for-xen-support.patch [1]:

* You introduce a new call to register xenpv_machine. But our existing machinery in qemu-xen-unstable for i386-dm already does this. So I think this is a mistake ?

It isn't a mistake. It is in the initialization path for qemu-system-{i386,x86_64}, because for upstream qemu I plan to have this as runtime switch, not as separate binary. The code in question isn't even compiled for qemu-dm, so the existing register call must stay.

I can drop the chunk for qemu-xen though if you find that less confusing. Then you'll get it with one of the next upstream merges instead.

Quoted 6 lines

* You introduce the QEMU_OPTION_domid the default behaviour of which is XEN_ATTACH. I don't think this is correct in the long term because I think that by default qemu should never attach (or create). The upstream qemu should always emulate Xen things by default. In a real Xen environment the toolstack (xend) will know to pass qemu-dm an option saying `please attach'.

Yes, that was the agreement we reached last time this was discussed.

The patch for upstream qemu implements exactly this behaviour:
http://kraxel.fedorapeople.org/patches/qemu-upstream/0002-xen-groundwork-for-xen-support.patch

The version for qemu-xen doesn't change the command line arguments to avoid breaking qemu-dm <=> xend interaction. I don't want to have xend patches in this series, to avoid making the merge even more complicated than it already is.

Adding the new ones while keeping the old ones for xend compatibility should work though. I can do that, with comments making clear what the long-term plan is.

Quoted 6 lines

* I'm not sure that the new Makefile infrastructure you provide here is a good idea for the qemu-xen-unstable tree. The stuff in qemu-xen-unstable's build system is very unpleasant but it is specifically designed to avoid merge conflicts when qemu upstream Makefiles change, as they often do.

Quoted 7 lines

I would very much prefer to continue to deal with the Makefiles on this twin-track approach. So I would prefer it if you would add your new object files to xen-hooks.mak and xen-setup and so forth.

Then when the corresponding changes go upstream I'll just remove them again. This will be much less pain for me than dealing with <<< >>> in Makefiles.

The very same Makefile infrastructure is intended for upstream though. But I can leave Makefile.target alone and just use xen-hooks.mak if you prefer that. Either way is fine for me.

Quoted 7 lines

Re 0003-xen-backend-driver-core.patch:

* I did get some compiler warnings eg:
/u/iwj/work/qemu-iwj.git/hw/xenfb.c:810: warning: passing argument 4 of 'xenfb_xs_printf' discards qualifiers from pointer target type
Maybe you don't have -Wwrite-strings in your setup ?

Will check.

Quoted 5 lines

Re 0005-xen-add-framebuffer-backend-driver.patch:

* I haven't reviewed this in detail but I am keen to have your new framebuffer code. So provided this compiles and appears to work in a quick test I would like to apply it ASAP.

Fine ;)

Quoted 5 lines

Re 0004-xen-add-console-backend-driver.patch:

* There are many whitespace changes. Surely some mistake ? Or is this with a view to getting the coding style to resemble that in most of the rest of qemu ?

Yep, was done to adapt qemu style.

Quoted 7 lines

If so then I would prefer (as an exception!) a first separate patch to re-indent the existing code in hw/xen_console.c: that is, a patch consisting _only_ of whitespace changes. And then a separate patch containing no whitespace changes.

As it is I haven't been able to review this very deeply and I don't have time today to redo the diff myself with -b ...

There is a "diff -b" version if the patch series at
http://kraxel.fedorapeople.org/patches/qemu-xen/no-ws/

Is that good enougth for review?

Quoted 5 lines

Re 0006-xen-sync-xen_machine_pv-with-upstream.patch:

* What is the purpose of this patch ? `sync xen_machine_pv with upstream' ? Which upstream ? Many of these changes seem cosmetic.

Patch 0002 + 0006 for qemu-xen is the same as Patch 0002 for qemu-upstream. It has been splitted in the qemu-xen series for better
bisectability: 0002 for qemu-xen does the minimal needed changes only, and 0006 brings xen_machine_pv in sync with the upstream patch.

The code has been restructed a bit with the upcoming emulation bits in mind. There should be no functional change for qemu-dm.

Quoted 7 lines

Re 0007-xen-add-block-device-backend-driver.patch
and 0008-xen-add-net-backend-driver.patch:

* I don't have any objection to these in principle. However they are of no use or relevance to qemu-xen-unstable because we do not and will not use them. So they should go into upstream directly rather than via me I think ?

Whatever you prefer.

Quoted 3 lines

However that needs to wait for the generic
backend, which definitely should go into qemu-xen-unstable before it goes into qemu upstream.

Sure.

Quoted 6 lines

Re 0009-xen-blk-nic-configuration-via-cmd-line.patch:

* I don't think I fully understand the purpose of this patch. It appears to be part of the Xenner emulation AFAICT ? When running under the real Xen toolstack we do not have qemu write these kind of entries to xenstore.

This is for the use cases where xend doesn't create these entries in xenstore. Yes, one user is Xenner. There also is the patch to (optionally) makes qemu create the domain, which needs this too.

Quoted 3 lines

Instead, xenstore.c (in qemu-xen-unstable) reads the necessary information from xenstore and sets up the qemu internals appropriately.

The backends within qemu get their config information from xenstore. Whenever the xenstore entries are created by qemu or by xend doesn't matter, they can deal with both cases.

Quoted 3 lines

And one final point:

* Have you been testing your tree on a real Xen host under xend ?

I did a while back, when I did most of the coding work for these patches. I didn't retest the most recent version though.

Quoted 8 lines
Quoted 5 lines

The naming convention I'm using right now is prefix 'xen_' for anything usable when running on the Xen hypervisor. That includes code which will be shared by xen and xenner such as the machine type. That also includes the block and net backends. They *do* work on Xen, and with some glue in xend you should be able to use them.

Before we accept any incompatible changes into qemu-xen-unstable we obviously need the corresponding changes to xend too ?

There shouldn't be any incompatible changes (see the command line argument discussion above).

Quoted 3 lines

But we are not going to be using the block and net backends in qemu. In a real Xen system these are provided by the dom0 kernel, which is a far superior arrangement (in our opinion!)

Well, the disk backend within qemu isn't fundamentally different from blktap. Right now it doesn't do aio due to some limitations in qemu. But the qemu block layer gets some love to improve the performance right now, so once this is done and aio is enabled in the disk backend I'd expect it to match blktap performance-wise.

The net backend proably is much less useful when you can use the dom0 kernel netback driver instead, although might be use cases the qemu network support can handle and the kernel netback driver can't (-net socket comes to mind).

Quoted 6 lines

AIUI from your patch the xen_mode specifies whether we're doing Xenner or real Xen ? Am I right in thinking that the modes are these:

* XEN_EMULATE - Xenner (no Xen hypervisor, no xend) IMO this should be the default for the qemu xen machine types in upstream qemu.

Yes.

Quoted 3 lines

* XEN_ATTACH - for qemu-dm as invoked by xend
IMO arrangements should be made so that this is done only with a special command-line option, which is provided by xend.

Yes.

Quoted 1 line

* XEN_CREATE - Xen hypervisor but no xend

Yes.

Quoted 3 lines

However,
how do you control whether the block/net backends used are those in the dom0 kernel or those in qemu ?

You can't right now, that it is still on my TODO list. Making XEN_CREATE work needs more patches too, so this isn't a problem yet ;)

My plan is to have an additional option for -drive, might look this way:

 -drive if=xen,backend=vbd,file=...    # blkback backend
 -drive if=xen,backend=tap,file=...    # blktap backend
 -drive if=xen,backend=qdisk,file=...  # qemu backend

Likewise for -net.

cheers,
Gerd