Skip to contentSkip to conversation

xen: pv domain support.

PATCH In review Gerd Hoffmann 10 participants 38 messages Apr 1, 2009 – Apr 7, 2009 Kbuild

lore
Share & tools
lore
#0 lore raw

cover xen: pv domain support.

Hi,

It's been a while, but after a looooooooooooong time we've (hopefully) finally sorted the merging issues with qemu-xen. So here is a fresh version of the xen support for qemu patch series. 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.

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

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       |    8 +++++
 configure             |   34 +++++++++++++++++++++++
 hw/boards.h           |    3 ++
 hw/xen.h              |   20 ++++++++++++++
 hw/xen_machine_pv.c   |   70 +++++++++++++++++++++++++++++++++++++++++++++++++
 qemu-options.hx       |   11 +++++++
 target-i386/machine.c |    3 ++
 vl.c                  |   12 ++++++++
 8 files changed, 161 insertions(+), 0 deletions(-)
 create mode 100644 hw/xen.h
 create mode 100644 hw/xen_machine_pv.c
Makefile.target +8 -0
index 046427d..1da8055 100644
@@ -563,6 +563,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 +34 -0
index 5c62c59..212f2e9 100755
@@ -189,6 +189,7 @@ aix="no"
 blobs="yes"
 fdt="yes"
 sdl_x11="no"
+xen="yes"
 
 # OS specific
 if check_define __linux__ ; then
@@ -406,6 +407,8 @@ for opt do
   ;;
   --disable-kqemu) kqemu="no"
   ;;
+  --disable-xen) xen="no"
+  ;;
   --disable-brlapi) brlapi="no"
   ;;
   --disable-bluez) bluez="no"
@@ -555,6 +558,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"
@@ -768,6 +772,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
@@ -1197,6 +1217,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" ] && \
@@ -1496,6 +1517,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
@@ -1657,6 +1681,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
@@ -1672,6 +1701,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 1e18ba6..215ccdc 100644
@@ -34,6 +34,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 +70 -0

70 lines not on this page · raw message

qemu-options.hx +11 -0
index 6c58e2a..895fa89 100644
@@ -1294,6 +1294,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 5e6c621..76fca5a 100644
@@ -138,6 +138,7 @@ int main(int argc, char **argv)
 #include "hw/isa.h"
 #include "hw/baum.h"
 #include "hw/bt.h"
+#include "hw/xen.h"
 #include "bt-host.h"
 #include "net.h"
 #include "monitor.h"
@@ -4943,6 +4944,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.1.3
#2 lore raw

Re: [Qemu-devel] [PATCH 01/10] xen: groundwork for xen support

Quoted 7 lines · Gerd Hoffmann

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

+ $(XEN_OBJS) : CFLAGS += -Wall -Wmissing-prototypes -Wstrict-prototypes

This should not be necessary, we already use all these flags.

Quoted 8 lines

+/*
+ * Local variables:

 + *  indent-tabs-mode: nil
 + *  c-indent-level: 4
 + *  c-basic-offset: 4
 + *  tab-width: 4

+ * End:
+ */

Please remove.

#3 lore raw

Re: [Qemu-devel] [PATCH 01/10] xen: groundwork for xen support

Quoted 10 lines · Blue Swirl
Quoted 7 lines · Gerd Hoffmann

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

+ $(XEN_OBJS) : CFLAGS += -Wall -Wmissing-prototypes -Wstrict-prototypes

This should not be necessary, we already use all these flags.

Great, will drop this.

Quoted 11 lines
Quoted 9 lines

+/*
+ * Local variables:

 + *  indent-tabs-mode: nil
 + *  c-indent-level: 4
 + *  c-basic-offset: 4
 + *  tab-width: 4

+ * End:
+ */

Please remove.

Yep.

cheers,
Gerd

#4 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    |  691 +++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/xen_backend.h    |   86 +++++++
 hw/xen_common.h     |   34 +++
 hw/xen_machine_pv.c |    8 +-
 5 files changed, 819 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 1da8055..dd8c0cb 100644
@@ -564,7 +564,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 +7 -1
index 21b5d9e..0696bcf 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 (-1 == xen_be_init()) {
+        fprintf(stderr, "%s: xen backend core setup failed\n", __FUNCTION__);
+        exit(1);
+    }
 }
 
 QEMUMachine xenpv_machine = {
Signature · 1 line
1.6.1.3
#5 lore raw

Re: [Qemu-devel] [PATCH 02/10] xen: backend driver core

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

 + *  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

The address is now 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

Quoted 2 lines

+ if (NULL == node || 0 == strcmp(node, "online")) {
+ if (-1 == xenstore_read_be_int(xendev, "online", &xendev->online))

This style is alien.

#6 lore raw

Re: [Qemu-devel] [PATCH 02/10] xen: backend driver core

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

Quoted 7 lines
Quoted 5 lines
 + *  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

The address is now 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

Will fix.

Quoted 4 lines
Quoted 2 lines

+ if (NULL == node || 0 == strcmp(node, "online")) {
+ if (-1 == xenstore_read_be_int(xendev, "online", &xendev->online))

This style is alien.

Oops. Still one of them. I though I've killed them all, will check again.

cheers,
Gerd

#7 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    |  276 +++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/xen_machine_pv.c |    1 +
 4 files changed, 281 insertions(+), 0 deletions(-)
 create mode 100644 hw/xen_console.c
Makefile.target +1 -0
index dd8c0cb..b22f7e1 100644
@@ -565,6 +565,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 +1 -0
index 0696bcf..cf2e0a3 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.1.3
#8 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          | 1018 +++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 1028 insertions(+), 1 deletions(-)
 create mode 100644 hw/xenfb.c
Makefile.target +1 -1
index b22f7e1..e824675 100644
@@ -565,7 +565,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 cf2e0a3..fee794a 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 +1018 -0

1,018 lines not on this page · raw message

Signature · 1 line
1.6.1.3
#9 lore raw

Re: [Qemu-devel] [PATCH 04/10] xen: add framebuffer backend driver

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

 +    pgmfns = qemu_mallocz(sizeof(unsigned long) * n_fbdirs);
 +    fbmfns = qemu_mallocz(sizeof(unsigned long) * xenfb->fbpages);
 +    if (!pgmfns || !fbmfns)

+ goto out;

This check should be removed, qemu_malloc will abort if we're out of memory.

#10 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       |  799 +++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/xen_machine_pv.c |    1 +
 sysemu.h            |    2 +-
 vl.c                |    6 +-
 7 files changed, 912 insertions(+), 3 deletions(-)
 create mode 100644 hw/xen_blkif.h
 create mode 100644 hw/xen_disk.c
Makefile.target +1 -1
index e824675..b66ff27 100644
@@ -565,7 +565,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 +799 -0

799 lines not on this page · raw message

hw/xen_machine_pv.c +1 -0
index fee794a..46f5df8 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 3eab34b..7b356b3 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 76fca5a..edf9ea9 100644
@@ -2364,7 +2364,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;
 	}
@@ -2578,6 +2581,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.1.3
#11 lore raw

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

hw/xen_blkif.h line 89

Quoted 5 lines · Gerd Hoffmann
hw/xen_blkif.h new file +4 -0
+static void inline blkif_get_x86_32_req(blkif_request_t *dst, blkif_x86_32_request_t *src)
+{
 
+static void inline blkif_get_x86_64_req(blkif_request_t *dst, blkif_x86_64_request_t *src)
+{

I think you'd be better of moving them to the .c file as normal static function and leave the inlining decisions to the compiler.

hw/xen_disk.c line 25

Quoted 7 lines
hw/xen_disk.c new file +7 -0
+
+/*
+ *  FIXME: the code is designed to handle multiple outstanding
+ *         requests, which isn't used right now.  Plan is to
+ *         switch over to the aio block functions once they got
+ *         vector support.
+ */

We already have bdrv_aio_readv/writev which currently linearize the buffer underneath. Hopefully Anthony will have commited the patch to implement the real one while I'm writing this, too :)

After those patches bdrv_aio_read/write will be gone so this code won't compile anymore, too.

Quoted 15 lines
hw/xen_disk.c new file +15 -0
+static int ioreq_runio_qemu_aio(struct ioreq *ioreq)
+{
+    struct XenBlkDev *blkdev = ioreq->blkdev;
+    int i, len = 0;
+    off_t pos;
+
+    if (-1 == ioreq_map(ioreq))
+	goto err;
+
+    ioreq->aio_inflight++;
+    if (ioreq->presync)
+	bdrv_flush(blkdev->bs); /* FIXME: aio_flush() ??? */
+
+    switch (ioreq->req.operation) {
+    case BLKIF_OP_READ:

hw/xen_disk.c line 419

Quoted 10 lines
hw/xen_disk.c new file +10 -0
+	pos = ioreq->start;
+	for (i = 0; i < ioreq->vecs; i++) {
+            ioreq->aio_inflight++;
+            bdrv_aio_read(blkdev->bs, pos / BLOCK_SIZE,
+                          ioreq->vec[i].iov_base,
+                          ioreq->vec[i].iov_len / BLOCK_SIZE,
+                          qemu_aio_complete, ioreq);
+	    len += ioreq->vec[i].iov_len;
+	    pos += ioreq->vec[i].iov_len;
+	}

hdrv_flush doesn't actually empty the aio queues but only issues a fsync. So we could still re-order requeuests around the barrier with this implementation. I will soon submit a real block-layer level barrier implementation that just allows to flag a bdrv_aio_read/write request as barrier and deal with this under the hood.

#12 lore raw

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

Quoted 9 lines · Christoph Hellwig

hw/xen_blkif.h line 89

Quoted 5 lines · Gerd Hoffmann
hw/xen_blkif.h new file +4 -0
+static void inline blkif_get_x86_32_req(blkif_request_t *dst, blkif_x86_32_request_t *src)
+{
 
+static void inline blkif_get_x86_64_req(blkif_request_t *dst, blkif_x86_64_request_t *src)
+{

I think you'd be better of moving them to the .c file as normal static function and leave the inlining decisions to the compiler.

The .h file is a straight copy, thats why I left it as is. I can cut&paste it into the source file as well, I don't care that much.

Quoted 10 lines

hw/xen_disk.c line 25

Quoted 7 lines
hw/xen_disk.c new file +7 -0
+
+/*
+ *  FIXME: the code is designed to handle multiple outstanding
+ *         requests, which isn't used right now.  Plan is to
+ *         switch over to the aio block functions once they got
+ *         vector support.
+ */

We already have bdrv_aio_readv/writev which currently linearize the buffer underneath.

Right, will adapt and kill the FIXME.

Quoted 2 lines

Hopefully Anthony will have commited the patch to implement the real one while I'm writing this, too :)

Linus committed the preadv syscall patches too (abi is not final yet though).

Quoted 6 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+    if (ioreq->presync)
+	bdrv_flush(blkdev->bs); /* FIXME: aio_flush() ??? */

hdrv_flush doesn't actually empty the aio queues but only issues a fsync. So we could still re-order requeuests around the barrier with this implementation.

Thats why there is a FIXME ...

Quoted 3 lines

I will soon submit a real block-layer level
barrier implementation that just allows to flag a bdrv_aio_read/write request as barrier and deal with this under the hood.

Great.

cheers,
Gerd

#13 lore raw

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

In reply to Christoph Hellwig
Quoted 6 lines · Christoph Hellwig

We already have bdrv_aio_readv/writev which currently linearize the buffer underneath. Hopefully Anthony will have commited the patch to implement the real one while I'm writing this, too :)

Unless I missed it somehow, I'm still expecting another post from you to fix the use-after-free and Win32 issues I raised on the 3/29 posting.

Regards,

Anthony Liguori

#14 lore raw

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

Quoted 10 lines · Anthony Liguori
Quoted 6 lines · Christoph Hellwig

We already have bdrv_aio_readv/writev which currently linearize the buffer underneath. Hopefully Anthony will have commited the patch to implement the real one while I'm writing this, too :)

Unless I missed it somehow, I'm still expecting another post from you to fix the use-after-free and Win32 issues I raised on the 3/29 posting.

I assumes you wanted to fix the use after free that we found inline, but I'll resend the series now. After your removal the patch doesn't touch win32 code anymore and I used the mingw32 cross-compiler to verify that it still builds (it doesn't link either with or without my patches, though)

#15 lore raw

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

In reply to Christoph Hellwig

Hi,

Quoted 3 lines

We already have bdrv_aio_readv/writev which currently linearize the buffer underneath. Hopefully Anthony will have commited the patch to implement the real one while I'm writing this, too :)

Is there any specific reason to keep the nb_sectors argument for bdrv_aio_readv, other than cut&paste from the non-vectored versions? I think it is superfluous now, it can be trivially calculated using iov->size.

cheers,
Gerd

#16 lore raw

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

Quoted 10 lines · Gerd Hoffmann

Hi,

Quoted 3 lines

We already have bdrv_aio_readv/writev which currently linearize the buffer underneath. Hopefully Anthony will have commited the patch to implement the real one while I'm writing this, too :)

Is there any specific reason to keep the nb_sectors argument for bdrv_aio_readv, other than cut&paste from the non-vectored versions? I think it is superfluous now, it can be trivially calculated using iov->size.

For the functions in block.c I want to keep them the same as they were before, and for the methods I want to keep the signature the same as the exported wrappers.

All this is going to change pretty soon I hope, we'll need another argument to bdrv_aio_write for barrier writes, and I might switch to a completely byte based interface for the aio requests with flags in the block driver state for flagging the alignment restrictions.

#17 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        |  396 +++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 399 insertions(+), 1 deletions(-)
 create mode 100644 hw/xen_nic.c
Makefile.target +1 -1
index b66ff27..4b071eb 100644
@@ -565,7 +565,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 46f5df8..50fdd15 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 +396 -0

396 lines not on this page · raw message

Signature · 1 line
1.6.1.3
#18 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  |  145 +++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/xen_machine_pv.c |   19 +++++++
 5 files changed, 174 insertions(+), 1 deletions(-)
 create mode 100644 hw/xen_devconfig.c
Makefile.target +1 -1
index 4b071eb..8bae243 100644
@@ -564,7 +564,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 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 +145 -0

145 lines not on this page · raw message

hw/xen_machine_pv.c +19 -0
index 50fdd15..8c471c2 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.1.3
#19 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 |  293 ++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/xen_domainbuild.h |   13 +++
 hw/xen_machine_pv.c  |   19 ++++
 7 files changed, 359 insertions(+), 2 deletions(-)
 create mode 100644 hw/xen_domainbuild.c
 create mode 100644 hw/xen_domainbuild.h
Makefile.target +1 -1
index 8bae243..626a846 100644
@@ -564,7 +564,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 212f2e9..9e7738e 100755
@@ -1518,7 +1518,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 0ef8012..1417e71 100644
@@ -143,3 +143,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 +293 -0

293 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 8c471c2..5607127 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.1.3
#20 lore raw

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

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

+ /* close all file handles, except stdio/out/err,
+ * our watch pipe and the xen interface handle */
+ for (i = 3; i < 256; i++) {

You should use getdtablesize() or sysconf(_SC_OPEN_MAX) instead of 256.

#21 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 edf9ea9..243fc0f 100644
@@ -4149,23 +4149,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.1.3
#22 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 5607127..0e12bfe 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 895fa89..79c71ac 100644
@@ -452,7 +452,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 7b356b3..e22612b 100644
@@ -87,6 +87,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 243fc0f..1d9ea73 100644
@@ -215,6 +215,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;
@@ -4152,12 +4153,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.1.3
#23 lore raw
In reply to Gerd Hoffmann
Quoted 7 lines · Gerd Hoffmann

Hi,

It's been a while, but after a looooooooooooong time we've (hopefully) finally sorted the merging issues with qemu-xen. So here is a fresh version of the xen support for qemu patch series. Short overview (individual patches have longer descriptions):

Have these made their way into qemu-xen-unstable? If not, has Ian at least Acked them?

Regards,

Anthony Liguori

Quoted 31 lines
  #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.

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

cheers,
Gerd

#24 lore raw

Anthony Liguori writes ("Re: [Qemu-devel] [PATCH 00/10] xen: pv domain support."):

Quoted 5 lines
Quoted 4 lines · Gerd Hoffmann

It's been a while, but after a looooooooooooong time we've (hopefully) finally sorted the merging issues with qemu-xen. So here is a fresh version of the xen support for qemu patch series. Short overview (individual patches have longer descriptions):

Well done and thanks for persisting.

Quoted 2 lines

Have these made their way into qemu-xen-unstable? If not, has Ian at least Acked them?

Some but not all of these are in qemu-xen-unstable. Not all of Gerd's patches ought to go via qemu-xen-unstable - some should go direct.

I've just merged up again from qemu-upstream at the 0.10.0 branch point so that qemu-xen-unstable staging is now reasonably recent. After I have fixed the resulting breakage and got that code through our tests into the main qemu-xen-untable we (Xen) will be in freeze and I'll have some time to look at Gerd's patches and comment and/or ack them individually.

So please wait just a few more days if that's not too inconvenient.

I'm sorry this process is so slow but the massively improved rate of qemu development (yay!) has meant that we have been playing catch-up quite a bit. (Often, resolving conflicts between changes in upstream which are very similar but not identical to ones in our tree, so happily resulting in me being able to drop changes entirely.)

Ian.

#25 lore raw
In reply to Gerd Hoffmann
Quoted 1 line · Gerd Hoffmann

Hi,

Hi,

Quoted 4 lines

It's been a while, but after a looooooooooooong time we've (hopefully) finally sorted the merging issues with qemu-xen. So here is a fresh version of the xen support for qemu patch series. Short overview (individual patches have longer descriptions):

Could you explain how to use it.

Do you need a xend and xenstored running on the host ?

Regards,
Laurent

#26 lore raw
Quoted 5 lines · Laurent Vivier
Quoted 1 line · Gerd Hoffmann

Hi,

Hi,

Quoted 8 lines
Quoted 4 lines

It's been a while, but after a looooooooooooong time we've (hopefully) finally sorted the merging issues with qemu-xen. So here is a fresh version of the xen support for qemu patch series. Short overview (individual patches have longer descriptions):

Could you explain how to use it.

Do you need a xend and xenstored running on the host ?

Depends ;)

Long term plan is to have three ways of supporting xen guests in qemu (pv only for now):

#1: Xen emulation (aka xenner). No code for this is submitted (yet).
That will allow running xen kernels in qemu. No xend, no xenstored needed. Also no Xen hypervisor.

#2: Make qemu attach to an existing domain. That is the way qemu-dm
(xenified qemu version) works right now: xend creates the domain, and qemu attaches to it to provide console and framebuffer backend. Obviously needs both xend and xenstored.

#3: Make qemu create xen domains. xenstored is still needed then. You
can run without xend though.

#2 works with the first 4 patches applied.
#3 works with all patches applied.
#1 needs more patches which are bitrotting in my git repo right now.
I'll dig them out once this patchset is merged.

cheers,
Gerd

#27 lore raw
Quoted 11 lines · Gerd Hoffmann
Quoted 10 lines · Laurent Vivier
Quoted 1 line · Gerd Hoffmann

Hi,

Hi,

Quoted 4 lines

It's been a while, but after a looooooooooooong time we've (hopefully) finally sorted the merging issues with qemu-xen. So here is a fresh version of the xen support for qemu patch series. Short overview (individual patches have longer descriptions):

Quoted 8 lines
Quoted 3 lines

Could you explain how to use it.

Do you need a xend and xenstored running on the host ?

Depends ;)

Long term plan is to have three ways of supporting xen guests in qemu (pv only for now):

One idea I had for full virtualization in a Xen environment would be an PV vmenter/vmexit framework - either by implementing a completely new abstraction or simple traps for privileged operations like VMRUN.

That way we could have a kvm that talks to xen for the VM, rendering kvm useful on Xen dom0s, giving people the best of both worlds.

That was only one of the ideas that came up while talking to people why running kvm on xen isn't as easy as just recompiling :-). Would you think of such a thing as useful?

Alex

#28 lore raw
Quoted 8 lines · Alexander Graf

One idea I had for full virtualization in a Xen environment would be an PV vmenter/vmexit framework - either by implementing a completely new abstraction or simple traps for privileged operations like VMRUN.

That way we could have a kvm that talks to xen for the VM, rendering kvm useful on Xen dom0s, giving people the best of both worlds.

That was only one of the ideas that came up while talking to people why running kvm on xen isn't as easy as just recompiling :-). Would you think of such a thing as useful?

Why would anyone want to do that? If you've got Xen running, just start up a Xen guest.

Signature · 2 lines
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.
#29 lore raw
Quoted 11 lines · Avi Kivity
Quoted 8 lines · Alexander Graf

One idea I had for full virtualization in a Xen environment would be an PV vmenter/vmexit framework - either by implementing a completely new abstraction or simple traps for privileged operations like VMRUN.

That way we could have a kvm that talks to xen for the VM, rendering kvm useful on Xen dom0s, giving people the best of both worlds.

That was only one of the ideas that came up while talking to people why running kvm on xen isn't as easy as just recompiling :-). Would you think of such a thing as useful?

Why would anyone want to do that? If you've got Xen running, just start up a Xen guest.

I'm not saying it's a great idea - that's why I didn't even consider to develop it yet :-).

Basically it would solve two problems:

1) Migration path. If you could already use KVM on a Xen host, you could have Xen PV guests and KVM guests in parallel, easing migration to KVM for customers.

2) Alternative to HVM. That's how this came up from Gerd's mail. We do have KVM support in upstream qemu, but we don't have Xen HVM support. That way you could use the same binary for all your needs. Admittedly, it might make more sense to just implement HVM support :-).

Again, I just like talking to others about random ideas I have and this was one. I don't think it's worth it - IMHO it'd be more useful to create an in-kernel xen-like module that exposes Xen PV functionality, so you get all the PV benefits without the performance hit from full virtualization and duplication of code.

Alex

#30 lore raw
Quoted 13 lines · Alexander Graf
Quoted 10 lines · Avi Kivity
Quoted 8 lines · Alexander Graf

One idea I had for full virtualization in a Xen environment would be an PV vmenter/vmexit framework - either by implementing a completely new abstraction or simple traps for privileged operations like VMRUN.

That way we could have a kvm that talks to xen for the VM, rendering kvm useful on Xen dom0s, giving people the best of both worlds.

That was only one of the ideas that came up while talking to people why running kvm on xen isn't as easy as just recompiling :-). Would you think of such a thing as useful?

Quoted 7 lines
Quoted 1 line

Why would anyone want to do that? If you've got Xen running, just start up a Xen guest.

I'm not saying it's a great idea - that's why I didn't even consider to develop it yet :-).

Basically it would solve two problems:

1) Migration path. If you could already use KVM on a Xen host, you could have Xen PV guests and KVM guests in parallel, easing migration to KVM for customers.

I like this, of course, but we have a path through Xenner. Maybe this (kvm-on-xen) path will be easier to take.

Quoted 2 lines

2) Alternative to HVM. That's how this came up from Gerd's mail. We do have KVM support in upstream qemu, but we don't have Xen HVM support. That way you could use the same binary for all your needs. Admittedly, it might make more sense to just implement HVM support :-).

I was under the impression that this is underway.

Quoted 3 lines

Again, I just like talking to others about random ideas I have and this was one. I don't think it's worth it - IMHO it'd be more useful to create an in-kernel xen-like module that exposes Xen PV functionality, so you get all the PV benefits without the performance hit from full virtualization and duplication of code.

With npt/ept pv performance might be higher running under kvm+xenner than with software-only Xen by letting the guest kernel access pagetables directly. Though Gerd had some issues with 64-bit guests IIRC, which is a pity since it's there that the pv performance hit is greatest.

Signature · 1 line
error compiling committee.c: too many arguments to function
#31 lore raw
Quoted 16 lines · Avi Kivity
Quoted 15 lines · Alexander Graf
Quoted 11 lines · Avi Kivity
Quoted 8 lines · Alexander Graf

One idea I had for full virtualization in a Xen environment would be an PV vmenter/vmexit framework - either by implementing a completely new abstraction or simple traps for privileged operations like VMRUN.

That way we could have a kvm that talks to xen for the VM, rendering kvm useful on Xen dom0s, giving people the best of both worlds.

That was only one of the ideas that came up while talking to people why running kvm on xen isn't as easy as just recompiling :-). Would you think of such a thing as useful?

Why would anyone want to do that? If you've got Xen running, just start up a Xen guest.

Quoted 7 lines
Quoted 5 lines

I'm not saying it's a great idea - that's why I didn't even consider to develop it yet :-).

Basically it would solve two problems:

1) Migration path. If you could already use KVM on a Xen host, you could have Xen PV guests and KVM guests in parallel, easing migration to KVM for customers.

I like this, of course, but we have a path through Xenner. Maybe this (kvm-on-xen) path will be easier to take.

Oh, I thought Xenner was semi on hold? Is it still actively developed? I thought Gerd's main goal for now was to get qemu-dm into upstream qemu for now.

Quoted 3 lines
Quoted 1 line

2) Alternative to HVM. That's how this came up from Gerd's mail. We do have KVM support in upstream qemu, but we don't have Xen HVM support. That way you could use the same binary for all your needs. Admittedly, it might make more sense to just implement HVM support :-).

I was under the impression that this is underway.

Awesome :-).

Quoted 4 lines
Quoted 2 lines

Again, I just like talking to others about random ideas I have and this was one. I don't think it's worth it - IMHO it'd be more useful to create an in-kernel xen-like module that exposes Xen PV functionality, so you get all the PV benefits without the performance hit from full virtualization and duplication of code.

With npt/ept pv performance might be higher running under kvm+xenner than with software-only Xen by letting the guest kernel access pagetables directly. Though Gerd had some issues with 64-bit guests IIRC, which is a pity since it's there that the pv performance hit is greatest.

Well that might be true, but I'm not fully convinced yet :-). Either way with "current" hardware (pre-Nehalem, pre-Barcelona) PV is still faster. Also, FWIW IO performance on PV Xen is still way superior to KVM. Please correct me if I stand wrong there.

Alex

#32 lore raw
Quoted 6 lines · Alexander Graf
Quoted 4 lines
Quoted 2 lines

1) Migration path. If you could already use KVM on a Xen host, you could have Xen PV guests and KVM guests in parallel, easing migration to KVM for customers.

I like this, of course, but we have a path through Xenner. Maybe this (kvm-on-xen) path will be easier to take.

Oh, I thought Xenner was semi on hold? Is it still actively developed? I thought Gerd's main goal for now was to get qemu-dm into upstream qemu for now.

I understood that Xenner is the next thing on the list.

Quoted 3 lines
Quoted 1 line

With npt/ept pv performance might be higher running under kvm+xenner than with software-only Xen by letting the guest kernel access pagetables directly. Though Gerd had some issues with 64-bit guests IIRC, which is a pity since it's there that the pv performance hit is greatest.

Well that might be true, but I'm not fully convinced yet :-). Either way with "current" hardware (pre-Nehalem, pre-Barcelona) PV is still faster.

Right, but every day this is becoming less important.

Quoted 1 line

Also, FWIW IO performance on PV Xen is still way superior to KVM. Please correct me if I stand wrong there.

We still have some work some work to do on virtio, but bandwidth should be comparable. And it has nothing to do with pv-vs-fv.

Signature · 1 line
error compiling committee.c: too many arguments to function
#33 lore raw
Quoted 6 lines · Avi Kivity
Quoted 3 lines · Alexander Graf

Oh, I thought Xenner was semi on hold? Is it still actively developed? I thought Gerd's main goal for now was to get qemu-dm into upstream qemu for now.

I understood that Xenner is the next thing on the list.

qemu-dm code is (largely) backend drivers, which are shared between xen and xenner. Thus this needs to be in first, before the xenner bits can follow. Now that this is mostly sorted I wanna un-stall the work on merging xenner.

cheers,
Gerd

#34 lore raw
In reply to Avi Kivity
Quoted 7 lines · Avi Kivity
Quoted 4 lines
Quoted 1 line

2) Alternative to HVM. That's how this came up from Gerd's mail. We do

have KVM support in upstream qemu, but we don't have Xen HVM support. That way you could use the same binary for all your needs. Admittedly, it might make more sense to just implement HVM support :-).

I was under the impression that this is underway.

We certainly want to do it, we just haven't got the time yet. After Gerd's patches get accepted I think it won't take too long to create a similar patchqueue for hvm, the two tree are getting closer and closer every month.

#35 lore raw
In reply to Alexander Graf
Quoted 3 lines · Alexander Graf

1) Migration path. If you could already use KVM on a Xen host, you could have Xen PV guests and KVM guests in parallel, easing migration to KVM for customers.

I still plan to make xenner handle that use case.
You can also run xen inside kvm via nested svm.

Quoted 4 lines

2) Alternative to HVM. That's how this came up from Gerd's mail. We do have KVM support in upstream qemu, but we don't have Xen HVM support. That way you could use the same binary for all your needs. Admittedly, it might make more sense to just implement HVM support :-).

HVM is more difficuilt. Xen considers the tools <-> hypervisor interface private, i.e. it is a moving target. For PV this isn't a big issue as there is little reason to actually change something. HVM usually has quite a few changes from release to release though, due to emulation changes/improvements and other reasons.

cheers,
Gerd

#36 lore raw
In reply to Alexander Graf
Quoted 6 lines · Alexander Graf

One idea I had for full virtualization in a Xen environment would be an PV vmenter/vmexit framework - either by implementing a completely new abstraction or simple traps for privileged operations like VMRUN.

That way we could have a kvm that talks to xen for the VM, rendering kvm useful on Xen dom0s, giving people the best of both worlds.

Hmm. I suspect xen's direct paging mode makes that quite intrusive as the kvm mmu code would have to know about this extra p2m translation step to get the shadow/ept/ntp tables right. Given that this most likely would be a odd and rarely tested use case I don't think this would be a good idea ...

cheers,
Gerd

#37 lore raw
Quoted 6 lines · Gerd Hoffmann

Hmm. I suspect xen's direct paging mode makes that quite intrusive as the kvm mmu code would have to know about this extra p2m translation step to get the shadow/ept/ntp tables right. Given that this most likely would be a odd and rarely tested use case I don't think this would be a good idea ...

That's mostly encapsulated in the normal pagetable manipulation routines, so if kvm can be convinced to use those to manage its shadow tables, it will all Just Work. That doesn't work well with a non-PAE 32-bit host with kvm's PAE shadow pagetables, but Xen doesn't support non-PAE anyway.

J