Skip to contentSkip to conversation

merge some xen bits into qemu

PATCH Applied Gerd Hoffmann 12 participants 117 messages Aug 21, 2008 – Sep 7, 2008 10 messages not in the archive Kbuild

lore
Share & tools
lore
#0 lore raw

cover merge some xen bits into qemu

Hi folks,

This is the fourth version of the xen support for qemu patch series, addressing review comments. Also fixed some bugs and made the backend drivers restartable (for boots via pvgrub). New in this submission is the domain building support.

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  -- Handle terminating signals.
  #2  -- add DisplayState->idle
  #3  -- add container_of() macro to osdep.h
  #4  -- move GUI_REFRESH_INTERVAL define from vl.c to console.h
  #5  -- groundwork: build system, cmd line options, ...
  #6  -- xen backend driver infrastructrure
  #7  -- xen console backend driver
  #8  -- xen framebuffer backend driver

#9 -- xen block backend driver
#10 -- xen nic backend driver
#11 -- allow xen disks and nics being configured via qemu command
line options.
#12 -- set vnc password from xenstore.
#13 -- xen: pv domain builder.

The first four patches are preparing patches. They put some stuff in place the other xen patches depend on.

With the next four patches in place upstream qemu can replace xen's qemu-dm for paravirtual domains.

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

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 has gets a new "xenpv" machine type additionally to the "pc" and "isapc" ones.

The patches are also available here:
http://kraxel.fedorapeople.org/patches/qemu-upstream/

There is also a patch queue for qemu-dm, so the patches can get a test-drive there:
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-dm patch series has a slightly different ordering to make the patch queue more bisect-friendly. Also some preparing patches are not needed because they already there. Some extra patches (backports) are there due to the age of the qemu-dm tree. The last two patches are not present (yet).

Comments?

cheers,
Gerd

#1 lore raw

PATCH 1/13 Handle terminating signals.

This patch makes qemu handle signals better. It sets the request_shutdown flag, making the main_loop exit and qemu taking the usual exit route, with atexit handlers being called and so on, instead of qemu just being killed by the signal.

To avoid calling vm_start() from the signal handler main_loop() got an additional check so qemu_system_shutdown_request() works even when the vm is in stopped state.

---
 curses.c |    2 --
 sdl.c    |    9 +--------
 vl.c     |   27 +++++++++++++++++++++++++++
 3 files changed, 28 insertions(+), 10 deletions(-)
curses.c +0 -2
index d09eff2..96b6e49 100644
@@ -350,8 +350,6 @@ void curses_display_init(DisplayState *ds, int full_screen)
     atexit(curses_atexit);
 
 #ifndef _WIN32
-    signal(SIGINT, SIG_DFL);
-    signal(SIGQUIT, SIG_DFL);
 #if defined(SIGWINCH) && defined(KEY_RESIZE)
     /* some curses implementations provide a handler, but we
      * want to be sure this is handled regardless of the library */
sdl.c +1 -8
index 0edc4a0..84a9d6d 100644
@@ -476,10 +476,8 @@ static void sdl_refresh(DisplayState *ds)
                 sdl_process_key(&ev->key);
             break;
         case SDL_QUIT:
-            if (!no_quit) {
+            if (!no_quit)
                 qemu_system_shutdown_request();
-                vm_start();	/* In case we're paused */
-            }
             break;
         case SDL_MOUSEMOTION:
             if (gui_grab || kbd_mouse_is_absolute() ||
@@ -636,11 +634,6 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
         fprintf(stderr, "Could not initialize SDL - exiting\n");
         exit(1);
     }
-#ifndef _WIN32
-    /* NOTE: we still want Ctrl-C to work, so we undo the SDL redirections */
-    signal(SIGINT, SIG_DFL);
-    signal(SIGQUIT, SIG_DFL);
-#endif
 
     ds->dpy_update = sdl_update;
     ds->dpy_resize = sdl_resize;
vl.c +27 -0
index fc5019f..071ee0c 100644
@@ -7619,6 +7619,8 @@ static int main_loop(void)
                 timeout = 0;
             }
         } else {
+            if (shutdown_requested)
+                break;
             timeout = 10;
         }
 #ifdef CONFIG_PROFILER
@@ -8183,6 +8185,26 @@ static BOOL WINAPI qemu_ctrl_handler(DWORD type)
 
 #define MAX_NET_CLIENTS 32
 
+#ifndef _WIN32
+
+static void termsig_handler(int signal)
+{
+    qemu_system_shutdown_request();
+}
+
+void termsig_setup(void)
+{
+    struct sigaction act;
+
+    memset(&act, 0, sizeof(act));
+    act.sa_handler = termsig_handler;
+    sigaction(SIGINT,  &act, NULL);
+    sigaction(SIGHUP,  &act, NULL);
+    sigaction(SIGTERM, &act, NULL);
+}
+
+#endif
+
 int main(int argc, char **argv)
 {
 #ifdef CONFIG_GDBSTUB
@@ -9071,6 +9093,11 @@ int main(int argc, char **argv)
 #endif
     }
 
+#ifndef _WIN32
+    /* must be after terminal init, SDL library changes signal handlers */
+    termsig_setup();
+#endif
+
     /* Maintain compatibility with multiple stdio monitors */
     if (!strcmp(monitor_device,"stdio")) {
         for (i = 0; i < MAX_SERIAL_PORTS; i++) {
Signature · 1 line
1.5.5.1
#45 lore raw

PATCH 2/13 add DisplayState->idle

In reply to Gerd Hoffmann

From: Samuel Thibault <[email protected]>

From: Samuel Thibault <[email protected]>

Add idle field to DisplayState struct, so drivers can figure the display is idle and take advantage of that.

The xen framebuffer driver will use this to communicate the idle state to the guest, so it knows it can stop doing updates to a virtual display which is invisible anyway.

---
 console.h |    1 +
 sdl.c     |    2 ++
 vl.c      |    2 ++
 vnc.c     |    3 +++
 4 files changed, 8 insertions(+), 0 deletions(-)
console.h +1 -0
index 561ef51..233e7ef 100644
@@ -80,6 +80,7 @@ struct DisplayState {
     void *opaque;
     struct QEMUTimer *gui_timer;
     uint64_t gui_timer_interval;
+    int idle;
 
     void (*dpy_update)(struct DisplayState *s, int x, int y, int w, int h);
     void (*dpy_resize)(struct DisplayState *s, int w, int h);
sdl.c +2 -0
index 84a9d6d..15427c5 100644
@@ -524,9 +524,11 @@ static void sdl_refresh(DisplayState *ds)
                 if (ev->active.gain) {
                     /* Back to default interval */
                     ds->gui_timer_interval = 0;
+                    ds->idle = 0;
                 } else {
                     /* Sleeping interval */
                     ds->gui_timer_interval = 500;
+                    ds->idle = 1;
                 }
             }
             break;
vl.c +2 -0
index 071ee0c..ee89107 100644
@@ -5974,6 +5974,8 @@ static void dumb_display_init(DisplayState *ds)
     ds->dpy_update = dumb_update;
     ds->dpy_resize = dumb_resize;
     ds->dpy_refresh = dumb_refresh;
+    ds->gui_timer_interval = 500;
+    ds->idle = 1;
 }
 
 /***********************************************************/
vnc.c +3 -0
index 2d17044..0d55a78 100644
@@ -660,6 +660,7 @@ static int vnc_client_io_error(VncState *vs, int ret, int last_errno)
 	qemu_set_fd_handler2(vs->csock, NULL, NULL, NULL, NULL);
 	closesocket(vs->csock);
 	vs->csock = -1;
+	vs->ds->idle = 1;
 	buffer_reset(&vs->input);
 	buffer_reset(&vs->output);
 	vs->need_update = 0;
@@ -1920,6 +1921,7 @@ static int protocol_version(VncState *vs, uint8_t *version, size_t len)
 static void vnc_connect(VncState *vs)
 {
     VNC_DEBUG("New client on socket %d\n", vs->csock);
+    vs->ds->idle = 0;
     socket_set_nonblock(vs->csock);
     qemu_set_fd_handler2(vs->csock, NULL, vnc_client_read, NULL, vs);
     vnc_write(vs, "RFB 003.008\n", 12);
@@ -1959,6 +1961,7 @@ void vnc_display_init(DisplayState *ds)
 	exit(1);
 
     ds->opaque = vs;
+    ds->idle = 1;
     vnc_state = vs;
     vs->display = NULL;
     vs->password = NULL;
Signature · 1 line
1.5.5.1
#48 lore raw

PATCH 3/13 add container_of() macro to osdep.h

In reply to Gerd Hoffmann
Quoted 1 line

From linux kernel sources, xen bits will use it, put it

into a place where others can see and use it too ;)

---
 osdep.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
osdep.h +4 -0
index 6312e7a..09ebace 100644
@@ -23,6 +23,10 @@
 #define unlikely(x)   __builtin_expect(!!(x), 0)
 #endif
 
+#define container_of(ptr, type, member) ({                      \
+        const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
+        (type *)( (char *)__mptr - offsetof(type,member) );})
+
 #ifndef MIN
 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
 #endif
Signature · 1 line
1.5.5.1
#50 lore raw

PATCH 4/13 move GUI_REFRESH_INTERVAL define from vl.c to console.h

In reply to Gerd Hoffmann
---
 console.h |    3 +++
 vl.c      |    2 --
 2 files changed, 3 insertions(+), 2 deletions(-)
console.h +3 -0
index 233e7ef..069e73d 100644
@@ -9,6 +9,9 @@
 #define MOUSE_EVENT_RBUTTON 0x02
 #define MOUSE_EVENT_MBUTTON 0x04
 
+/* in ms */
+#define GUI_REFRESH_INTERVAL 30
+
 typedef void QEMUPutKBDEvent(void *opaque, int keycode);
 typedef void QEMUPutMouseEvent(void *opaque, int dx, int dy, int dz, int buttons_state);
 
vl.c +0 -2
index ee89107..3211507 100644
@@ -154,8 +154,6 @@ int inet_aton(const char *cp, struct in_addr *ia);
 #else
 #define DEFAULT_RAM_SIZE 128
 #endif
-/* in ms */
-#define GUI_REFRESH_INTERVAL 30
 
 /* Max number of USB devices that can be specified on the commandline.  */
 #define MAX_USB_CMDLINE 8
Signature · 1 line
1.5.5.1
#52 lore raw

PATCH 5/13 xen: groundwork for xen support

In reply to Gerd Hoffmann

- configure script and build system changes.
- wind up new machine type.
- add -domid command line option.
- allow xenpv machines run without disk and kernel specified by adding a nodisk_ok field to QEMUMachine.
- detect xen being present.

---
 Makefile.target       |    8 +++
 configure             |   27 +++++++++
 hw/boards.h           |    3 +
 hw/xen.h              |   18 ++++++
 hw/xen_machine_pv.c   |  146 +++++++++++++++++++++++++++++++++++++++++++++++++
 target-i386/machine.c |    3 +
 vl.c                  |   15 +++++
 7 files changed, 220 insertions(+), 0 deletions(-)
 create mode 100644 hw/xen.h
 create mode 100644 hw/xen_machine_pv.c
Makefile.target +8 -0
index 42162c3..13ee854 100644
@@ -515,6 +515,14 @@ CPPFLAGS += $(CONFIG_VNC_TLS_CFLAGS)
 LIBS += $(CONFIG_VNC_TLS_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 +27 -0
index 74ce443..14689d2 100755
@@ -109,6 +109,7 @@ curses="yes"
 aio="yes"
 nptl="yes"
 mixemu="no"
+xen="no"
 
 # OS specific
 targetos=`uname -s`
@@ -204,6 +205,7 @@ linux="yes"
 linux_user="yes"
 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
     kqemu="yes"
+    xen="yes"
     audio_possible_drivers="$audio_possible_drivers fmod"
 fi
 ;;
@@ -287,6 +289,8 @@ for opt do
   ;;
   --disable-kqemu) kqemu="no"
   ;;
+  --disable-xen) xen="no"
+  ;;
   --disable-brlapi) brlapi="no"
   ;;
   --enable-profiler) profiler="yes"
@@ -425,6 +429,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"
@@ -686,6 +691,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
@@ -946,6 +967,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" ] && \
@@ -1203,6 +1225,11 @@ if test "$brlapi" = "yes" ; then
   echo "#define CONFIG_BRLAPI 1" >> $config_h
   echo "BRLAPI_LIBS=-lbrlapi" >> $config_mak
 fi
+if test "$xen" = "yes" ; then
+  echo "CONFIG_XEN=yes" >> $config_mak
+  echo "#define CONFIG_XEN 1" >> $config_h
+  echo "XEN_LIBS=-lxenstore -lxenctrl" >> $config_mak
+fi
 if test "$aio" = "yes" ; then
   echo "#define CONFIG_AIO 1" >> $config_h
 fi
hw/boards.h +3 -0
index e6dd198..9af9939 100644
@@ -30,6 +30,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 +18 -0
new file mode 100644
index 0000000..a772aad
@@ -0,0 +1,18 @@
+#ifndef QEMU_XEN_H
+#define QEMU_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 */
+extern int xen_domid;
+extern int xen_present;
+extern int xen_emulate;
+extern int xen_domainbuild;
+
+int xen_detect(void);
+
+#endif /* QEMU_XEN_H */
hw/xen_machine_pv.c new file +146 -0

146 lines not on this page · raw message

target-i386/machine.c +3 -0
index 91dbd55..98ece17 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 +15 -0
index 3211507..ff94c6f 100644
@@ -29,6 +29,7 @@
 #include "hw/audiodev.h"
 #include "hw/isa.h"
 #include "hw/baum.h"
+#include "hw/xen.h"
 #include "net.h"
 #include "console.h"
 #include "sysemu.h"
@@ -7780,6 +7781,9 @@ 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
+           "-domid          specify xen guest domain id\n"
+#endif
            "\n"
            "During emulation, the following keys are useful:\n"
            "ctrl-alt-f      toggle full screen\n"
@@ -7885,6 +7889,9 @@ enum {
     QEMU_OPTION_startdate,
     QEMU_OPTION_tb_size,
     QEMU_OPTION_icount,
+#ifdef CONFIG_XEN
+    QEMU_OPTION_domid,
+#endif
 };
 
 typedef struct QEMUOption {
@@ -7973,6 +7980,9 @@ const QEMUOption qemu_options[] = {
 #ifdef CONFIG_CURSES
     { "curses", 0, QEMU_OPTION_curses },
 #endif
+#ifdef CONFIG_XEN
+    { "domid", HAS_ARG, QEMU_OPTION_domid },
+#endif
 
     /* temporary options */
     { "usb", 0, QEMU_OPTION_usb },
@@ -8847,6 +8857,11 @@ int main(int argc, char **argv)
                     icount_time_shift = strtol(optarg, NULL, 0);
                 }
                 break;
+#ifdef CONFIG_XEN
+            case QEMU_OPTION_domid:
+                xen_domid = atoi(optarg);
+                break;
+#endif
             }
         }
     }
Signature · 1 line
1.5.5.1
#54 lore raw

PATCH 6/13 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 |    7 +-
 5 files changed, 818 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 13ee854..78a6402 100644
@@ -516,7 +516,7 @@ LIBS += $(CONFIG_VNC_TLS_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..a9e1d26
@@ -0,0 +1,34 @@
+#ifndef QEMU_XEN_COMMON_H
+#define QEMU_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_XEN_COMMON_H */
hw/xen_machine_pv.c +6 -1
index 05f0e67..2eceb8e 100644
@@ -25,7 +25,7 @@
 #include "hw.h"
 #include "boards.h"
 
-#include <xenctrl.h>
+#include "xen_backend.h"
 
 /* -------------------------------------------------------------------- */
 /* variables                                                            */
@@ -81,6 +81,11 @@ static int xen_init(void)
         xen_emulate = 1;
     }
 
+    if (-1 == xen_be_init()) {
+        fprintf(stderr, "%s: xen backend core setup failed\n", __FUNCTION__);
+        return -1;
+    }
+
     return 0;
 }
 
Signature · 1 line
1.5.5.1
#55 lore raw

PATCH 7/13 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    |  271 +++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/xen_machine_pv.c |    3 +
 4 files changed, 278 insertions(+), 0 deletions(-)
 create mode 100644 hw/xen_console.c
Makefile.target +1 -0
index 78a6402..92ad109 100644
@@ -517,6 +517,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 3a79ad0..10bd1a6 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 */
+struct XenDevOps xen_console_ops;      /* xen_console.c     */
+
 #endif /* QEMU_XEN_BACKEND_H */
hw/xen_console.c new file +271 -0

271 lines not on this page · raw message

hw/xen_machine_pv.c +3 -0
index 2eceb8e..93f66d0 100644
@@ -97,6 +97,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.5.1
#56 lore raw

PATCH 8/13 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 4.0).

---
 Makefile.target      |    2 +-
 hw/xen_backend.h     |    4 +
 hw/xen_framebuffer.c |  975 ++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/xen_machine_pv.c  |    5 +
 4 files changed, 985 insertions(+), 1 deletions(-)
 create mode 100644 hw/xen_framebuffer.c
Makefile.target +1 -1
index 92ad109..bcf4d93 100644
@@ -517,7 +517,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 xen_framebuffer.o
 ifeq ($(CONFIG_XEN), yes)
   OBJS += $(XEN_OBJS)
   LIBS += $(XEN_LIBS)
hw/xen_backend.h +4 -0
index 10bd1a6..d8bc23a 100644
@@ -85,5 +85,9 @@ void xen_be_printf(struct XenDevice *xendev, int msg_level, const char *fmt, ...
 
 /* actual backend drivers */
 struct XenDevOps xen_console_ops;      /* xen_console.c     */
+struct XenDevOps xen_kbdmouse_ops;     /* xen_framebuffer.c */
+struct XenDevOps xen_framebuffer_ops;  /* xen_framebuffer.c */
+
+void xen_set_display(int domid, DisplayState *ds);
 
 #endif /* QEMU_XEN_BACKEND_H */
hw/xen_framebuffer.c new file +975 -0

975 lines not on this page · raw message

hw/xen_machine_pv.c +5 -0
index 93f66d0..d1d0a93 100644
@@ -99,6 +99,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;
 }
Signature · 1 line
1.5.5.1
#57 lore raw

PATCH 9/13 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       |  693 +++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/xen_machine_pv.c |    1 +
 sysemu.h            |    2 +-
 vl.c                |    4 +
 7 files changed, 805 insertions(+), 2 deletions(-)
 create mode 100644 hw/xen_blkif.h
 create mode 100644 hw/xen_disk.c
Makefile.target +1 -1
index bcf4d93..a60ca16 100644
@@ -517,7 +517,7 @@ endif
 
 # xen backend driver support
 XEN_OBJS := xen_machine_pv.o xen_backend.o
-XEN_OBJS += xen_console.o xen_framebuffer.o
+XEN_OBJS += xen_console.o xen_framebuffer.o xen_disk.o
 ifeq ($(CONFIG_XEN), yes)
   OBJS += $(XEN_OBJS)
   LIBS += $(XEN_LIBS)
hw/xen_backend.h +2 -0
index d8bc23a..9dbcb19 100644
@@ -2,6 +2,7 @@
 #define QEMU_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, ...
 struct XenDevOps xen_console_ops;      /* xen_console.c     */
 struct XenDevOps xen_kbdmouse_ops;     /* xen_framebuffer.c */
 struct XenDevOps xen_framebuffer_ops;  /* xen_framebuffer.c */
+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 +693 -0

693 lines not on this page · raw message

hw/xen_machine_pv.c +1 -0
index d1d0a93..27b85e7 100644
@@ -101,6 +101,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 b12fae0..49e75b1 100644
@@ -113,7 +113,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 ff94c6f..5e023e6 100644
@@ -5516,6 +5516,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;
@@ -5701,6 +5704,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.5.1
#58 lore raw

PATCH 10/13 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        |  382 +++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 385 insertions(+), 1 deletions(-)
 create mode 100644 hw/xen_nic.c
Makefile.target +1 -1
index a60ca16..94b5342 100644
@@ -517,7 +517,7 @@ endif
 
 # xen backend driver support
 XEN_OBJS := xen_machine_pv.o xen_backend.o
-XEN_OBJS += xen_console.o xen_framebuffer.o xen_disk.o
+XEN_OBJS += xen_console.o xen_framebuffer.o xen_disk.o xen_nic.o
 ifeq ($(CONFIG_XEN), yes)
   OBJS += $(XEN_OBJS)
   LIBS += $(XEN_LIBS)
hw/xen_backend.h +1 -0
index 9dbcb19..9ea4421 100644
@@ -89,6 +89,7 @@ struct XenDevOps xen_console_ops;      /* xen_console.c     */
 struct XenDevOps xen_kbdmouse_ops;     /* xen_framebuffer.c */
 struct XenDevOps xen_framebuffer_ops;  /* xen_framebuffer.c */
 struct XenDevOps xen_blkdev_ops;       /* xen_disk.c        */
+struct XenDevOps xen_netdev_ops;       /* xen_nic.c         */
 
 void xen_set_display(int domid, DisplayState *ds);
 
hw/xen_machine_pv.c +1 -0
index 27b85e7..e6d2bd6 100644
@@ -102,6 +102,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 +382 -0

382 lines not on this page · raw message

Signature · 1 line
1.5.5.1
#59 lore raw

PATCH 11/13 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.h    |    7 +++
 hw/xen_devconfig.c  |  144 +++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/xen_machine_pv.c |   19 ++++++-
 4 files changed, 170 insertions(+), 2 deletions(-)
 create mode 100644 hw/xen_devconfig.c
Makefile.target +1 -1
index 94b5342..7e507e4 100644
@@ -516,7 +516,7 @@ LIBS += $(CONFIG_VNC_TLS_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 xen_framebuffer.o xen_disk.o xen_nic.o
 ifeq ($(CONFIG_XEN), yes)
   OBJS += $(XEN_OBJS)
hw/xen_backend.h +7 -0
index 9ea4421..f591743 100644
@@ -3,6 +3,8 @@
 
 #include "xen_common.h"
 #include "sysemu.h"
+#include "net.h"
+#include "block_int.h"
 
 /* ------------------------------------------------------------- */
 
@@ -93,4 +95,9 @@ 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_XEN_BACKEND_H */
hw/xen_devconfig.c new file +144 -0

144 lines not on this page · raw message

hw/xen_machine_pv.c +18 -1
index e6d2bd6..851837c 100644
@@ -121,7 +121,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)
@@ -147,6 +147,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.5.1
#60 lore raw

PATCH 12/13 set vnc password from xenstore.

In reply to Gerd Hoffmann
---
 hw/xen_machine_pv.c |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)
hw/xen_machine_pv.c +26 -0
index 851837c..9f18742 100644
@@ -24,6 +24,7 @@
 
 #include "hw.h"
 #include "boards.h"
+#include "console.h"
 
 #include "xen_backend.h"
 
@@ -110,6 +111,29 @@ static int xen_init_pv(DisplayState *ds)
     return 0;
 }
 
+static void xen_init_vnc(void)
+{
+    char xspath[256], *dom = NULL, *vm = NULL, *pw = NULL;
+    int len;
+
+    dom = xs_get_domain_path(xenstore, xen_domid);
+    snprintf(xspath, sizeof(xspath), "%s/vm", dom);
+    vm = xs_read(xenstore, 0, xspath, &len);
+    if (!vm)
+        goto out;
+    snprintf(xspath, sizeof(xspath), "%s/vncpassword", vm);
+    pw = xs_read(xenstore, 0, xspath, &len);
+    if (!pw || !strlen(pw))
+        goto out;
+    vnc_display_password(NULL, pw);
+    fprintf(stderr, "vnc password set from xenstore\n");
+
+out:
+    free(dom);
+    free(vm);
+    free(pw);
+}
+
 /* -------------------------------------------------------------------- */
 /* paravirtualized xen machine                                          */
 
@@ -136,6 +160,8 @@ static void xenpv_init(ram_addr_t ram_size, int vga_ram_size,
         goto err;
     }
 
+    xen_init_vnc();
+
     /* create dummy cpu, halted */
     if (cpu_model == NULL) {
 #ifdef TARGET_X86_64
Signature · 1 line
1.5.5.1
#85 lore raw

PATCH 13/13 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 |  281 ++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/xen_domainbuild.h |    9 ++
 hw/xen_machine_pv.c  |   34 ++++---
 7 files changed, 344 insertions(+), 16 deletions(-)
 create mode 100644 hw/xen_domainbuild.c
 create mode 100644 hw/xen_domainbuild.h
Makefile.target +1 -1
index 7e507e4..47bfc77 100644
@@ -516,7 +516,7 @@ LIBS += $(CONFIG_VNC_TLS_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 xen_framebuffer.o xen_disk.o xen_nic.o
 ifeq ($(CONFIG_XEN), yes)
   OBJS += $(XEN_OBJS)
configure +1 -1
index 14689d2..cec0b48 100755
@@ -1228,7 +1228,7 @@ fi
 if test "$xen" = "yes" ; then
   echo "CONFIG_XEN=yes" >> $config_mak
   echo "#define CONFIG_XEN 1" >> $config_h
-  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 f591743..70ad016 100644
@@ -99,5 +99,8 @@ void xen_set_display(int domid, DisplayState *ds);
 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, char *type);
+int xen_config_dev_vkbd(int vdev);
+int xen_config_dev_console(int vdev);
 
 #endif /* QEMU_XEN_BACKEND_H */
hw/xen_devconfig.c +29 -0
index 25d28b4..0d506ca 100644
@@ -142,3 +142,32 @@ int xen_config_dev_nic(NICInfo *nic)
     /* common stuff */
     return xen_config_dev_all(fe, be);
 }
+
+int xen_config_dev_vfb(int vdev, 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 +281 -0

281 lines not on this page · raw message

hw/xen_domainbuild.h new file +9 -0
new file mode 100644
index 0000000..21ee180
@@ -0,0 +1,9 @@
+#ifndef QEMU_XEN_DOMAINBUILD_H
+#define QEMU_XEN_DOMAINBUILD_H 1
+
+#include "xen_common.h"
+
+int xen_domain_build_pv(const char *kernel, const char *ramdisk,
+                        const char *cmdline);
+
+#endif /* QEMU_XEN_DOMAINBUILD_H */
hw/xen_machine_pv.c +20 -14
index 9f18742..8c9f3c1 100644
@@ -27,6 +27,7 @@
 #include "console.h"
 
 #include "xen_backend.h"
+#include "xen_domainbuild.h"
 
 /* -------------------------------------------------------------------- */
 /* variables                                                            */
@@ -90,7 +91,9 @@ static int xen_init(void)
     return 0;
 }
 
-static int xen_init_pv(DisplayState *ds)
+static int xen_init_pv(const char *kernel_filename,
+		       const char *kernel_cmdline,
+		       const char *initrd_filename)
 {
     int rc;
 
@@ -98,6 +101,19 @@ static int xen_init_pv(DisplayState *ds)
     if (rc < 0)
         return rc;
 
+    if (xen_emulate) {
+        fprintf(stderr, "xen pv emulation not implemented yet\n");
+        return -1;
+    }
+
+    if (xen_domainbuild) {
+        if (xen_domain_build_pv(kernel_filename, initrd_filename,
+                                kernel_cmdline) < 0) {
+            fprintf(stderr, "xen pv domain creation failed\n");
+            return -1;
+        }
+    }
+
     /* xenbus backend drivers */
     xen_be_register("console", &xen_console_ops);
     xen_be_register("vkbd", &xen_kbdmouse_ops);
@@ -105,9 +121,6 @@ static int xen_init_pv(DisplayState *ds)
     xen_be_register("qdisk", &xen_blkdev_ops);
     xen_be_register("qnic", &xen_netdev_ops);
 
-    /* setup framebuffer */
-    xen_set_display(xen_domid, ds);
-
     return 0;
 }
 
@@ -147,19 +160,12 @@ static void xenpv_init(ram_addr_t ram_size, int vga_ram_size,
     CPUState *env;
     int index,i,rc;
 
-    rc = xen_init_pv(ds);
+    rc = xen_init_pv(kernel_filename, kernel_cmdline, initrd_filename);
     if (-1 == rc)
         goto err;
 
-    if (xen_emulate) {
-        fprintf(stderr, "xen pv emulation not implemented yet\n");
-        goto err;
-    }
-    if (xen_domainbuild) {
-        fprintf(stderr, "xen pv domain creation not implemented yet\n");
-        goto err;
-    }
-
+    /* setup framebuffer */
+    xen_set_display(xen_domid, ds);
     xen_init_vnc();
 
     /* create dummy cpu, halted */
Signature · 1 line
1.5.5.1
#46 lore raw

[Qemu-devel] Re: [PATCH 02/13] add DisplayState->idle

In reply to Gerd Hoffmann
Quoted 10 lines · Gerd Hoffmann, le Thu 21 Aug 2008 18:27:23 +0200, a écrit :

From: Samuel Thibault <[email protected]>

From: Samuel Thibault <[email protected]>

Add idle field to DisplayState struct, so drivers can figure the display is idle and take advantage of that.

The xen framebuffer driver will use this to communicate the idle state to the guest, so it knows it can stop doing updates to a virtual display which is invisible anyway.

#2 lore raw

Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals.

In reply to Gerd Hoffmann
Quoted 10 lines · Gerd Hoffmann

This patch makes qemu handle signals better. It sets the request_shutdown flag, making the main_loop exit and qemu taking the usual exit route, with atexit handlers being called and so on, instead of qemu just being killed by the signal.

To avoid calling vm_start() from the signal handler main_loop() got an additional check so qemu_system_shutdown_request() works even when the vm is in stopped state.

Applied. Thanks.

Regards,

Anthony Liguori

#47 lore raw

Re: [Qemu-devel] [PATCH 02/13] add DisplayState->idle

In reply to Gerd Hoffmann
Quoted 4 lines · Gerd Hoffmann

From: Samuel Thibault <[email protected]>

From: Samuel Thibault <[email protected]>

Quoted 10 lines

Add idle field to DisplayState struct, so drivers can figure the display is idle and take advantage of that.

The xen framebuffer driver will use this to communicate the idle state to the guest, so it knows it can stop doing updates to a virtual display which is invisible anyway.

Applied. Thanks.

Regards,

Anthony Liguori

#61 lore raw

Re: [Qemu-devel] [PATCH 12/13] set vnc password from xenstore.

In reply to Gerd Hoffmann

I don't really like this approach. I don't want to have a totally separate management interface just for Xend to use (via xenstore).

Can't Xend use the monitor like every other management tool?

Regards,

Anthony Liguori

#81 lore raw

[Qemu-devel] Re: [Xen-devel] [PATCH 12/13] set vnc password from xenstore.

In reply to Gerd Hoffmann

What is the justification for this change. We already have a means to set the VNC password from the monitor. If this isn't sufficient we should introduce an additional method which isn't Xen specific.

I know XenD currently sends the passwords to QEMU via xenstore, but that's not a good reason to preserve this approach. XenD does lots of stuff via XenStore which it should be doing via command line arguments - such as setting up disks instead of using the -drive param.

IMHO, XenD should just set the VNC password by connecting to the monitor. That's what its there for after all.

Daniel

Quoted 65 lines · Gerd Hoffmann
---
 hw/xen_machine_pv.c |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)
hw/xen_machine_pv.c +26 -0
index 851837c..9f18742 100644
@@ -24,6 +24,7 @@
 
 #include "hw.h"
 #include "boards.h"
+#include "console.h"
 
 #include "xen_backend.h"
 
@@ -110,6 +111,29 @@ static int xen_init_pv(DisplayState *ds)
     return 0;
 }
 
+static void xen_init_vnc(void)
+{
+    char xspath[256], *dom = NULL, *vm = NULL, *pw = NULL;
+    int len;
+
+    dom = xs_get_domain_path(xenstore, xen_domid);
+    snprintf(xspath, sizeof(xspath), "%s/vm", dom);
+    vm = xs_read(xenstore, 0, xspath, &len);
+    if (!vm)
+        goto out;
+    snprintf(xspath, sizeof(xspath), "%s/vncpassword", vm);
+    pw = xs_read(xenstore, 0, xspath, &len);
+    if (!pw || !strlen(pw))
+        goto out;
+    vnc_display_password(NULL, pw);
+    fprintf(stderr, "vnc password set from xenstore\n");
+
+out:
+    free(dom);
+    free(vm);
+    free(pw);
+}
+
 /* -------------------------------------------------------------------- */
 /* paravirtualized xen machine                                          */
 
@@ -136,6 +160,8 @@ static void xenpv_init(ram_addr_t ram_size, int vga_ram_size,
         goto err;
     }
 
+    xen_init_vnc();
+
     /* create dummy cpu, halted */
     if (cpu_model == NULL) {
 #ifdef TARGET_X86_64
Signature · 7 lines
1.5.5.1


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Signature · 4 lines
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
#53 lore raw

Re: [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support

In reply to Gerd Hoffmann
Quoted 10 lines · Gerd Hoffmann

- configure script and build system changes.
- wind up new machine type.
- add -domid command line option.
- allow xenpv machines run without disk and kernel specified by adding a nodisk_ok field to QEMUMachine.
- detect xen being present.

I'm pretty happy with up to 11 in the series but I'll hold off applying them until they show up in qemu-dm or at least are Acked-by Ian or Samuel.

Ian/Samuel: is there any subset of these patches that you are comfortable with or do they all need more discussion?

Regards,

Anthony Liguori

#62 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 12/13] set vnc password from xenstore.

In reply to Anthony Liguori
Quoted 4 lines · Anthony Liguori

I don't really like this approach. I don't want to have a totally separate management interface just for Xend to use (via xenstore).

Can't Xend use the monitor like every other management tool?

If the monitor really isn't sufficient, then I'd suggest allowing an open file descriptor to be specified on the -vnc arg, eg

-vnc localhost:3,passwdfd=6

And then let QEMU read the password from this file descriptor. I'd rather XenD just used the monitor though - it'll ultimately need to use it anyway to perform disk/network hotplug amongst other things.

Daniel

Signature · 4 lines
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
#63 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 12/13] set vnc password from xenstore.

Quoted 4 lines · Daniel P. Berrange
Quoted 2 lines · Anthony Liguori

I don't really like this approach. I don't want to have a totally separate management interface just for Xend to use (via xenstore).

Quoted 8 lines
Quoted 2 lines

Can't Xend use the monitor like every other management tool?

If the monitor really isn't sufficient, then I'd suggest allowing an open file descriptor to be specified on the -vnc arg, eg

-vnc localhost:3,passwdfd=6

In general, I strongly dislike passing file descriptors like this.

Quoted 4 lines

And then let QEMU read the password from this file descriptor. I'd rather XenD just used the monitor though - it'll ultimately need to use it anyway to perform disk/network hotplug amongst other things.

If there are reasons that Xend doesn't want to interact with the monitor (for instance, if you want to support monitor redirection), we can certainly discuss how to enhance the monitor (like having multiple monitor instances). Ultimately, we need to have everyone use the same interface to interact with QEMU.

Regards,

Anthony Liguori

Quoted 2 lines

Daniel

#64 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 12/13] set vnc password from xenstore.

Quoted 22 lines · Anthony Liguori
Quoted 5 lines · Daniel P. Berrange
Quoted 3 lines · Anthony Liguori

I don't really like this approach. I don't want to have a totally separate management interface just for Xend to use (via xenstore).

Quoted 8 lines
Quoted 2 lines

Can't Xend use the monitor like every other management tool?

If the monitor really isn't sufficient, then I'd suggest allowing an open file descriptor to be specified on the -vnc arg, eg

-vnc localhost:3,passwdfd=6

In general, I strongly dislike passing file descriptors like this.

Quoted 4 lines

And then let QEMU read the password from this file descriptor. I'd rather XenD just used the monitor though - it'll ultimately need to use it anyway to perform disk/network hotplug amongst other things.

Quoted 5 lines

If there are reasons that Xend doesn't want to interact with the monitor (for instance, if you want to support monitor redirection), we can certainly discuss how to enhance the monitor (like having multiple monitor instances). Ultimately, we need to have everyone use the same interface to interact with QEMU.

Based on my understanding of XenD code & requirements I think it is mostly just a historical accident that it doesn't use the monitor - quite simply when XenD first picked up QEMU there wasn't much of use the monitor could provide. There were no disk/network/vnc commands for it to use, so it did the easiest thing and read the data out of xenstore, since it was there already.

Daniel

Signature · 4 lines
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
#78 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 12/13] set vnc password from xenstore.

In reply to Daniel P. Berrange
Quoted 4 lines · Daniel P. Berrange

If the monitor really isn't sufficient, then I'd suggest allowing an open file descriptor to be specified on the -vnc arg, eg

-vnc localhost:3,passwdfd=6

If you're going to do that, pass a file name instead.

If someone wants to pass a file descriptor, they can simply write passwd=/proc/self/fd/6.

-- Jamie

#82 lore raw

[Qemu-devel] Re: [Xen-devel] [PATCH 12/13] set vnc password from xenstore.

In reply to Daniel P. Berrange
Quoted 3 lines · Daniel P. Berrange

What is the justification for this change. We already have a means to set the VNC password from the monitor. If this isn't sufficient we should introduce an additional method which isn't Xen specific.

Justification is that I've just implemented what qemu-dm does today, so upstream qemu can easily replace qemu-dm.

I'm perfectly fine with dropping the patch altogether.

Quoted 2 lines

IMHO, XenD should just set the VNC password by connecting to the monitor. That's what its there for after all.

Agreed.

cheers,
Gerd

#79 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 12/13] set vnc password from xenstore.

In reply to Daniel P. Berrange
Quoted 8 lines · Daniel P. Berrange

If the monitor really isn't sufficient, then I'd suggest allowing an open file descriptor to be specified on the -vnc arg, eg

-vnc localhost:3,passwdfd=6

And then let QEMU read the password from this file descriptor. I'd rather XenD just used the monitor though - it'll ultimately need to use it anyway to perform disk/network hotplug amongst other things.

I'd say using the monitor is the way to go for xend. I'd expect setting the vnc port in xenstore (for -vncunused functionality) will be vetoed too. Thus xend will have to use the monitor anyway to figure the vnc port. No point in implementing a passwdfd= option then.

cheers,
Gerd

Signature · 1 line
http://kraxel.fedorapeople.org/xenner/
#65 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 12/13] set vnc password from xenstore.

In reply to Anthony Liguori

Hi,

Quoted 4 lines

If there are reasons that Xend doesn't want to interact with the monitor (for instance, if you want to support monitor redirection), we can certainly discuss how to enhance the monitor (like having multiple monitor instances).

Multiple monitor instances would be very useful anyway.

Right now there is no way to use the monitor for libvirt-managed qemu instances because libvirt uses the monitor. Being able to both use libvirt *and* have a monitor prompt to type commands would be great.

cheers,
Gerd

Signature · 1 line
http://kraxel.fedorapeople.org/xenner/
#66 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 12/13] set vnc password from xenstore.

Quoted 7 lines · Gerd Hoffmann

Hi,

Quoted 4 lines

If there are reasons that Xend doesn't want to interact with the monitor (for instance, if you want to support monitor redirection), we can certainly discuss how to enhance the monitor (like having multiple monitor instances).

Quoted 5 lines

Multiple monitor instances would be very useful anyway.

Right now there is no way to use the monitor for libvirt-managed qemu instances because libvirt uses the monitor. Being able to both use libvirt *and* have a monitor prompt to type commands would be great.

I disagree - that means you'll no longer be able to trust what libvirt tells you about the VM, and libvirt won't have a guarenteed consistent view of the VM's state because things will be changed behind its back.

Daniel

Signature · 4 lines
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
#72 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 12/13] set vnc password from xenstore.

In reply to Gerd Hoffmann
Quoted 11 lines · Gerd Hoffmann

Hi,

Quoted 5 lines

If there are reasons that Xend doesn't want to interact with the monitor (for instance, if you want to support monitor redirection), we can certainly discuss how to enhance the monitor (like having multiple monitor instances).

Multiple monitor instances would be very useful anyway.

The trick here is to add a MonitorState context to every callback and have term_printf() take a MonitorState as the first argument. It's a mostly mechanical change.

Quoted 4 lines

Right now there is no way to use the monitor for libvirt-managed qemu instances because libvirt uses the monitor. Being able to both use libvirt *and* have a monitor prompt to type commands would be great.

It would make the current monitor multiplex hackery a lot cleaner too.

Regards,

Anthony Liguori

Quoted 4 lines

cheers,
Gerd

#67 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 12/13] set vnc password from xenstore.

In reply to Daniel P. Berrange
Quoted 6 lines · Daniel P. Berrange
Quoted 4 lines · Gerd Hoffmann

Hi,

Multiple monitor instances would be very useful anyway.

Quoted 9 lines
Quoted 4 lines

Right now there is no way to use the monitor for libvirt-managed qemu instances because libvirt uses the monitor. Being able to both use libvirt *and* have a monitor prompt to type commands would be great.

I disagree - that means you'll no longer be able to trust what libvirt tells you about the VM, and libvirt won't have a guarenteed consistent view of the VM's state because things will be changed behind its back.

A nice side effect of having multiple monitors is that you can implement a proper 'select' command. This command would block and tell you about asynchronous events (like guest CD-ROM ejecting). You could use this mechanism to notify libvirt when things changed because of other monitors too.

It's more work though from a libvirt perspective and you probably don't want users screwing around in the monitor anyway.

Regards,

Anthony Liguori

Quoted 2 lines

Daniel

#69 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 12/13] set vnc password from xenstore.

In reply to Daniel P. Berrange
Quoted 9 lines · Daniel P. Berrange
Quoted 5 lines

Multiple monitor instances would be very useful anyway.

Right now there is no way to use the monitor for libvirt-managed qemu instances because libvirt uses the monitor. Being able to both use libvirt *and* have a monitor prompt to type commands would be great.

I disagree - that means you'll no longer be able to trust what libvirt tells you about the VM, and libvirt won't have a guarenteed consistent view of the VM's state because things will be changed behind its back.

It is *not* the only purpose of the monitor to confuse libvirt. The whole 'info <foo>' command family is very useful for development and debugging purposes and it will not interfere at all with libvirt.

I can't stand your attitude to refuse any feature just because you fear users might abuse it. That applies to almost any feature which makes life easier for developers. Which in turn means using libvirt for development is either a bit complicated or impossible.

cheers,
Gerd

Signature · 1 line
http://kraxel.fedorapeople.org/xenner/
#73 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 12/13] set vnc password from xenstore.

In reply to Anthony Liguori
Quoted 6 lines · Anthony Liguori
Quoted 1 line · Gerd Hoffmann

Multiple monitor instances would be very useful anyway.

The trick here is to add a MonitorState context to every callback and have term_printf() take a MonitorState as the first argument. It's a mostly mechanical change.

The devil is in the details ...

How do we want support multiple monitors? One way would be using multiple -monitor switches, so you can have -- say -- one pty for libvirt and one vc for the user / developer. Another way would be allowing multiple connects to unix/tcp sockets, which is probably a bit more tricky due to qemu not having infrastructure for that (yet). We also could do both ...

And when touching all monitor command functions anyway, we could also cleanup the handler mess a bit ;)

How about this: We define *two* different callback functions:

    typedef struct term_cmd_t {
        [ ... ]
        void (*handler_one)(MonitorState *s, const char *arg);
        void (*handler_many)(MonitorState *s, int argv, char *argv[])
        [ ... ]
    };

The first one can be used by the monitor functions taking at most one argument, with minimal source code changes, which is probably more than 90% of them. The remaining ones can be converted to use the second form.

cheers,
Gerd

Signature · 1 line
http://kraxel.fedorapeople.org/xenner/
#71 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 12/13] set vnc password from xenstore.

In reply to Daniel P. Berrange
Quoted 10 lines · Daniel P. Berrange
Quoted 9 lines · Gerd Hoffmann

Hi,

Quoted 4 lines

If there are reasons that Xend doesn't want to interact with the monitor (for instance, if you want to support monitor redirection), we can certainly discuss how to enhance the monitor (like having multiple monitor instances).

Multiple monitor instances would be very useful anyway.

Quoted 7 lines
Quoted 3 lines

Right now there is no way to use the monitor for libvirt-managed qemu instances because libvirt uses the monitor. Being able to both use libvirt *and* have a monitor prompt to type commands would be great.

I disagree - that means you'll no longer be able to trust what libvirt tells you about the VM, and libvirt won't have a guarenteed consistent view of the VM's state because things will be changed behind its back.

If there were multiple monitor instances, you could filter them _all_ through libvirt, so it would always know the VM state.

That's what I do in my vM manager script. User can connect to the manager's socket and send a monitor command. It's forwarded to QEMU, but some filtering so the script knows what's going on, e.g. when changing CD-ROM, starting/stopping the CPU etc.

You can't do that nicely now, though, because some commands take a long time to execute.

Also, there's no nice way to wait for events like "tell me when the guest reboots the CPU" at the moment.

-- Jamie

#70 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 12/13] set vnc password from xenstore.

In reply to Gerd Hoffmann
Quoted 11 lines · Gerd Hoffmann
Quoted 9 lines · Daniel P. Berrange
Quoted 5 lines

Multiple monitor instances would be very useful anyway.

Right now there is no way to use the monitor for libvirt-managed qemu instances because libvirt uses the monitor. Being able to both use libvirt *and* have a monitor prompt to type commands would be great.

I disagree - that means you'll no longer be able to trust what libvirt tells you about the VM, and libvirt won't have a guarenteed consistent view of the VM's state because things will be changed behind its back.

Quoted 8 lines

It is *not* the only purpose of the monitor to confuse libvirt. The whole 'info <foo>' command family is very useful for development and debugging purposes and it will not interfere at all with libvirt.

I can't stand your attitude to refuse any feature just because you fear users might abuse it. That applies to almost any feature which makes life easier for developers. Which in turn means using libvirt for development is either a bit complicated or impossible.

I think it's good for libvirt to constrain and protect users, if it's targetting regular VM users. There are too many ways to accidentally break what can be valuable VMs.

But if that's mandatory (can't bypass it when wanted), it should acknowledge that libvirt is _not_ suitable for people wanting to use advanced QEMU functionality - and QEMU features must not be designed to assume libvirt.

It would be nice to manage VMs with a tool like libvirt _and_ still have access to the low-level stuff like the QEMU monitor, and the command line that libvirt generates. Maybe that's asking too much and we have to choose one or the other.

-- Jamie

#74 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 12/13] set vnc password from xenstore.

In reply to Anthony Liguori
Quoted 5 lines · Anthony Liguori
Quoted 3 lines

-vnc localhost:3,passwdfd=6

In general, I strongly dislike passing file descriptors like this.

I find this very useful, and actually think we should encourage it, and also allow passing file descriptors over the monitor (using SCM_RIGHTS). This can help de-privilege qemu. In fact, you can run a guest where qemu doesn't even have permissions to open the backing file.

Signature · 1 line
error compiling committee.c: too many arguments to function
#68 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 12/13] set vnc password from xenstore.

In reply to Anthony Liguori
Quoted 2 lines · Anthony Liguori

A nice side effect of having multiple monitors is that you can implement a proper 'select' command. This command would block and tell you about asynchronous events (like guest CD-ROM ejecting). You could use this mechanism to notify libvirt when things changed because of other monitors too.

I'd much prefer that a single monitor be able to receive async notifications. It's not that difficult to implement; if notification lines had a unique prefix the monitor client could on that.

Signature · 1 line
error compiling committee.c: too many arguments to function
#75 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 12/13] set vnc password from xenstore.

In reply to Avi Kivity
Quoted 9 lines · Avi Kivity
Quoted 3 lines · Anthony Liguori
Quoted 1 line

-vnc localhost:3,passwdfd=6

In general, I strongly dislike passing file descriptors like this.

I find this very useful, and actually think we should encourage it, and also allow passing file descriptors over the monitor (using SCM_RIGHTS). This can help de-privilege qemu. In fact, you can run a guest where qemu doesn't even have permissions to open the backing file.

You can already do this:

    qemu -hdc /proc/self/fd/3 3<>MS-DOS-6.22.img

-- Jamie

#76 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 12/13] set vnc password from xenstore.

Quoted 6 lines · Jamie Lokier
Quoted 4 lines · Avi Kivity
Quoted 2 lines · Anthony Liguori
Quoted 2 lines

-vnc localhost:3,passwdfd=6

Quoted 10 lines
Quoted 4 lines
Quoted 2 lines

In general, I strongly dislike passing file descriptors like this.

I find this very useful, and actually think we should encourage it, and also allow passing file descriptors over the monitor (using SCM_RIGHTS). This can help de-privilege qemu. In fact, you can run a guest where qemu doesn't even have permissions to open the backing file.

You can already do this:

    qemu -hdc /proc/self/fd/3 3<>MS-DOS-6.22.img

Not over the monitor.

Signature · 1 line
error compiling committee.c: too many arguments to function
#77 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 12/13] set vnc password from xenstore.

Quoted 15 lines · Avi Kivity
Quoted 14 lines · Jamie Lokier
Quoted 11 lines · Avi Kivity
Quoted 4 lines · Anthony Liguori
Quoted 2 lines

-vnc localhost:3,passwdfd=6

In general, I strongly dislike passing file descriptors like this.

I find this very useful, and actually think we should encourage it, and also allow passing file descriptors over the monitor (using SCM_RIGHTS). This can help de-privilege qemu. In fact, you can run a guest where qemu doesn't even have permissions to open the backing file.

Quoted 5 lines
Quoted 3 lines

You can already do this:

   qemu -hdc /proc/self/fd/3 3<>MS-DOS-6.22.img

Not over the monitor.

Oh, you're thinking of sending SCM_RIGHTS over the monitor.. Nice :-)

-- Jamie

#80 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 12/13] set vnc password from xenstore.

In reply to Anthony Liguori

Anthony Liguori writes ("[Xen-devel] Re: [Qemu-devel] [PATCH 12/13] set vnc password from xenstore."):

Quoted 2 lines

I don't really like this approach. I don't want to have a totally separate management interface just for Xend to use (via xenstore).

I agree that the xenstore management approach is not right for qemu. It would be better to go through a more stable interface.

Quoted 1 line

Can't Xend use the monitor like every other management tool?

I think it probably could. When I was doing my initial work to start merging our tree with the qemu one, I didn't do this because I wanted a drop-in replacement for the older code, and because I ran out of time.

But as others have noted there are also two things which the monitor doesn't do which we would need: multiple monitors, and the ability for a monitor client to wait for events. We need multiple monitors so that a monitor remains available to those people whose Xen installations are already making use of it.

In the new scheme of things I envisage a xenstore <-> qemu-monitor conversion layer. This would work much like the way xenstore.c works in our Xen qemu tree does. It probably ought not to be part of xend, and I think I would still like it to be compiled as part of our qemu build.

If upstream qemu don't want a bevy of alternative management veneers around the main qemu binary in their tree then I don't think there would be a problem with us maintaining that indefinitely in our version. The important thing is not which tree the code is in, but that we should go through a stable interface intended by qemu upstream to be used for this kind of thing.

So I would suggest that the starting point would be to provide for multiple monitors. Then, we can gradually change the code in our tree's xenstore.c to go via the monitor (adding functionality to the monitor as necessary). Eventually we'll have a xenstore.c which doesn't do anything other than go via the monitor at which point we can either leave things, or include that upstream if desired.

Ian.

#87 lore raw

Re: [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support

In reply to a message not in the archive

Gerd Hoffmann writes ("[Qemu-devel] [PATCH 05/13] xen: groundwork for xen support"):

Quoted 6 lines

+/*
+ * Figure the environment we are running in.
+ * Returns true when xen is present, false otherwise.
+ * Also checks whenever the domain specified via -domid
+ * exists (so we can attach) or whenever it must be created.
+ */

I don't think this is the right approach. The intent appears to be that if you run a particular qemu rune, it will do a completely different thing when running under Xen.

One bad effect of this is that it is not possible to do a software emulation of the Xen environment if the host happens to actually be running under Xen.

The command line, or chosen qemu executable, should specify what qemu is supposed to do:
- supporting tasks (hardware emulation etc.)
for a real Xen domain managed by Xen tools via xenstore etc.
- software emulation of the Xen environment for the benefit of a Xen domU but without using the Xen hypervisor (and this should obviously work even if running under Xen0
- whatever other use cases are important; apparently Gerd seems keen to run some code with parts of the xend toolstack replaced

Note that of course we have also ported qemu to our embedded minios so that it can run as a service domain.

Quoted 1 line

+ "-domid specify xen guest domain id\n"

Now would be a good time to rename this option to have the word `xen' in it.

Ian.

#116 lore raw

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

In reply to a message not in the archive

Gerd Hoffmann writes ("[Qemu-devel] [PATCH 13/13] xen: pv domain builder."):

Quoted 3 lines

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

Gerd Hoffmann writes ("[Qemu-devel] [PATCH 06/13] xen: backend driver core"):

Quoted 5 lines

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

Gerd Hoffmann writes ("[Qemu-devel] [PATCH 11/13] xen: blk & nic configuration via cmd line."):

Quoted 4 lines

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.

These kind of patches are rather troublesome I'm afraid.

On one level they are irrelevant to Xen, or at least to Xen upstream. They exist to support modes of operation which differ from the way upstream Xen works. Having other ways to use the Xen hypervisor is fine by us. So in theory we shouldn't care.

However in practice these changes are going to make it harder to merge the existing Xen code, because they do some but not all of the same things in a different way. If these patches are merged into qemu upstream then I'll have to do a lot of untangling. I might have to put off bringing our tree up to date again. (We had ours frozen for a couple of months for our release.)

What I would prefer is if Gerd would submit a patch or patches to xen-devel, against our qemu, to factor out of the functionality needed by his code. This should be done in a way that is both suitable for his needs and structurally sensible for the xen upstream tree.

When that patch is accepted into qemu-xen, there will be no trouble hopefully porting very similar if not entirely identical code into qemu upstream. And then Gerd can submit patches to qemu-upstream for his new backend drivers, and those patches do not need to conflict with anything in qemu-xen. Although we ought to review them to make sure that the command line options, etc., are all clear and nonconflicting.

Ian.

#4 lore raw

Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals.

In reply to a message not in the archive

Anthony Liguori writes ("Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals."):

Quoted 7 lines
Quoted 4 lines · Gerd Hoffmann

This patch makes qemu handle signals better. It sets the request_shutdown flag, making the main_loop exit and qemu taking the usual exit route, with atexit handlers being called and so on, instead of qemu just being killed by the signal.

Applied. Thanks.

This seems sensible to me.

I have a patch in our tree which changes the signal delivery mechanism for aio completion to use the well known pipe-to-self trick. I had to do this because there were some circumstances where IO completion signals were being lost due to races.

I was planning to send this upstream. Should I enhance my change to do the same to the termination signals too ?

Ian.

#84 lore raw

Re: [Qemu-devel] Re: [Xen-devel] [PATCH 12/13] set vnc password from xenstore.

In reply to a message not in the archive

Gerd Hoffmann writes ("[Qemu-devel] Re: [Xen-devel] [PATCH 12/13] set vnc password from xenstore."):

Quoted 2 lines

Justification is that I've just implemented what qemu-dm does today, so upstream qemu can easily replace qemu-dm.

This seems to be predicated on the idea that xen upstream are just going to drop our tree in favour of Gerd's. That seems unlikely to me.

Rather, we would like to evolve the various branches so that they are closer together. In particular, where changes are though to be needed to bring qemu-xen closer to upstream, we (Xen upstream) would like to consider each such change on its own merits. We don't intend to import a whole pile of externally-written Xen support code to replace what we have now.

Ian.

#117 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 13/13] xen: pv domain builder.

In reply to Ian Jackson
Quoted 8 lines · Ian Jackson, le Tue 26 Aug 2008 11:42:11 +0100, a écrit :

Gerd Hoffmann writes ("[Qemu-devel] [PATCH 06/13] xen: backend driver core"):

Quoted 5 lines

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

These kind of patches are rather troublesome I'm afraid.

The one above should be fine I think (and the relevant console/pvfb refactoring, which Mark seemed happy to see).

Samuel

#5 lore raw

Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals.

In reply to Ian Jackson
Quoted 7 lines · Ian Jackson

I have a patch in our tree which changes the signal delivery mechanism for aio completion to use the well known pipe-to-self trick. I had to do this because there were some circumstances where IO completion signals were being lost due to races.

I was planning to send this upstream. Should I enhance my change to do the same to the termination signals too ?

What this would be useful for? The termination signals usualy one-shot anyway, so I don't see any advantage in doing the pipe-to-self trick.

cheers,
Gerd

#88 lore raw

Re: [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support

In reply to Ian Jackson
Quoted 11 lines · Ian Jackson

Gerd Hoffmann writes ("[Qemu-devel] [PATCH 05/13] xen: groundwork for xen support"):

Quoted 6 lines

+/*
+ * Figure the environment we are running in.
+ * Returns true when xen is present, false otherwise.
+ * Also checks whenever the domain specified via -domid
+ * exists (so we can attach) or whenever it must be created.
+ */

I don't think this is the right approach. The intent appears to be that if you run a particular qemu rune, it will do a completely different thing when running under Xen.

That is the intended default behaviour, yes. If you run on Xen, you most likely want to use it, right? That matches behaviour of kvm and
kqemu: If support is available, it is used by default (there are options to turn it off).

Quoted 3 lines

One bad effect of this is that it is not possible to do a software emulation of the Xen environment if the host happens to actually be running under Xen.

That isn't a fundamental issue. It can trivially be fixed by adding a command line option, which just has to set xen_present = 0.

Quoted 10 lines

The command line, or chosen qemu executable, should specify what qemu is supposed to do:
- supporting tasks (hardware emulation etc.)
for a real Xen domain managed by Xen tools via xenstore etc.
- software emulation of the Xen environment for the benefit of a Xen domU but without using the Xen hypervisor (and this should obviously work even if running under Xen0
- whatever other use cases are important; apparently Gerd seems keen to run some code with parts of the xend toolstack replaced

We can certainly add command line options to force a specific operation mode, see above. I don't think such an option should be required though. IMHO qemu can and should pick sensible defaults.

Quoted 4 lines
Quoted 1 line

+ "-domid specify xen guest domain id\n"

Now would be a good time to rename this option to have the word `xen' in it.

How about -xen-domid? And prefix any other xen specific options with -xen too of course?

cheers,
Gerd

#6 lore raw

Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals.

In reply to Gerd Hoffmann

Gerd Hoffmann writes ("Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals."):

Quoted 2 lines

What this would be useful for? The termination signals usualy one-shot anyway, so I don't see any advantage in doing the pipe-to-self trick.

The point is that then they can interrupt select().

Ian.

#120 lore raw

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

In reply to Ian Jackson
Quoted 6 lines · Ian Jackson

These kind of patches are rather troublesome I'm afraid.

However in practice these changes are going to make it harder to merge the existing Xen code, because they do some but not all of the same things in a different way. If these patches are merged into qemu upstream then I'll have to do a lot of untangling.

If the patches break something, report it and I'll fix it up. "I'm afraid something might break" doesn't help us going forward.

Quoted 4 lines

What I would prefer is if Gerd would submit a patch or patches to xen-devel, against our qemu, to factor out of the functionality needed by his code. This should be done in a way that is both suitable for his needs and structurally sensible for the xen upstream tree.

http://kraxel.fedorapeople.org/patches/qemu-xen/
http://lists.xensource.com/archives/html/xen-devel/2008-08/msg00887.html

cheers,
Gerd

#89 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support

In reply to Ian Jackson
Quoted 11 lines · Ian Jackson

Gerd Hoffmann writes ("[Qemu-devel] [PATCH 05/13] xen: groundwork for xen support"):

Quoted 6 lines

+/*
+ * Figure the environment we are running in.
+ * Returns true when xen is present, false otherwise.
+ * Also checks whenever the domain specified via -domid
+ * exists (so we can attach) or whenever it must be created.
+ */

I don't think this is the right approach. The intent appears to be that if you run a particular qemu rune, it will do a completely different thing when running under Xen.

This particular check is doing two different jobs in one go. I think they need to be dealt with separately.

- Check to see if running on Xen or not. This is a similar idea to to pv_ops where we have one kernel binary, and probe at runtime to decide whether to run in KVM, Xen, VMWare or bare metal mode.

This is important to QEMU too. Merging the source trees for all projects using QEMU is just the first step. A single binary for all is the holy grail, though may not be practical for Mini-OS usage

- Check to see whether the guest domain is pre-created (ie attaching to an existing VM created by XenD), or whether QEMU is constructing the domain from scratch.

Probing for whether a domain ID exists in the hypervisor, and if not, then creating it, has a nasty race condition, where XenD could launch QEMU and then (for whatever reason) decide to kill off the domain, but QEMU then re-creates it during its startup procedure.

If we want QEMU to explicitly created Xen domains from scratch, rather than attaching to an existing one, then there needs to be a way to reliably specify this behaviour via the CLI.

Daniel

Signature · 4 lines
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
#7 lore raw

Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals.

In reply to Ian Jackson
Quoted 5 lines · Ian Jackson

Gerd Hoffmann writes ("Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals."):

Quoted 2 lines

What this would be useful for? The termination signals usualy one-shot anyway, so I don't see any advantage in doing the pipe-to-self trick.

The point is that then they can interrupt select().

Sure, basically any signal can interrupt any system call. I still don't see the point you are trying to make.

cheers,
Gerd

#121 lore raw

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

In reply to Gerd Hoffmann

Gerd Hoffmann writes ("Re: [Qemu-devel] [PATCH 13/13] xen: pv domain builder."):

Quoted 10 lines
Quoted 6 lines · Ian Jackson

These kind of patches are rather troublesome I'm afraid.

However in practice these changes are going to make it harder to merge the existing Xen code, because they do some but not all of the same things in a different way. If these patches are merged into qemu upstream then I'll have to do a lot of untangling.

If the patches break something, report it and I'll fix it up. "I'm afraid something might break" doesn't help us going forward.

What I meant is that if your changes are committed to qemu upstream, I will get an enormous pile of merge conflicts when I try to merge from upstream into our tree. The correct route, for changes which touch code currently only in qemu-xen, is via qemu-xen.

If what you meant is that we should replace our tree with your tree and then complain to you about anything that breaks: sorry, that's not going to happen.

Quoted 6 lines
Quoted 4 lines

What I would prefer is if Gerd would submit a patch or patches to xen-devel, against our qemu, to factor out of the functionality needed by his code. This should be done in a way that is both suitable for his needs and structurally sensible for the xen upstream tree.

http://kraxel.fedorapeople.org/patches/qemu-xen/

Those patches are not suitable for inclusion in qemu-xen. This is because
- They rename files pointlessly
- They contain many changes which consist of the addition of new code which is not relevant for qemu-xen. It is fine for us to change qemu-xen to make it easier for your tree and our tree to converge (such as factoring the backend driver core out of the qemu-xen xenfb). But we do not want (for example) your complete backend driver set. This is why this needs to be done in the stages I outlined above
- http://kraxel.fedorapeople.org/patches/qemu-xen/0001-kraxel-s-stuff.patch
"Kraxel's Stuff" ? This is a joke, right ?
etc.

This has been explained before, I think ?

Ian.

#9 lore raw

Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals.

In reply to Ian Jackson
Quoted 8 lines · Ian Jackson

Gerd Hoffmann writes ("Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals."):

Quoted 3 lines

What this would be useful for? The termination signals usualy one-shot anyway, so I don't see any advantage in doing the pipe-to-self trick.

The point is that then they can interrupt select().

The race I know of is that you may get an aio signal completion before select but after you've already qemu_aio_poll()'d. In practice, we only sleep for 10ms at a time in select() so the race is handled by that. If we wanted to increase the amount of time we slept, we would have to handle this race.

In KVM, we sleep for 1s in select() and use signalfd() to receive the aio notifications. For older hosts, we emulate signalfd using a thread and the pipe-to-self trick.

Regards,

Anthony Liguori

Quoted 4 lines

Ian.

#90 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support

In reply to Daniel P. Berrange
Quoted 4 lines · Daniel P. Berrange

Probing for whether a domain ID exists in the hypervisor, and if not, then creating it, has a nasty race condition, where XenD could launch QEMU and then (for whatever reason) decide to kill off the domain, but QEMU then re-creates it during its startup procedure.

Oops. Yes, that needs to be addressed.

Quoted 3 lines

If we want QEMU to explicitly created Xen domains from scratch, rather than attaching to an existing one, then there needs to be a way to reliably specify this behaviour via the CLI.

So we are scoring at three options for xen now:

  -xen-domid <nr>  specify xen domain id.
  -xen-create      ask qemu to create the domain.
  -xen-emulate     force xen emulation mode.

I'll go add these for the next round.

cheers,
Gerd

#91 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support

Quoted 8 lines · Gerd Hoffmann
Quoted 4 lines · Daniel P. Berrange

Probing for whether a domain ID exists in the hypervisor, and if not, then creating it, has a nasty race condition, where XenD could launch QEMU and then (for whatever reason) decide to kill off the domain, but QEMU then re-creates it during its startup procedure.

Oops. Yes, that needs to be addressed.

Quoted 8 lines
Quoted 3 lines

If we want QEMU to explicitly created Xen domains from scratch, rather than attaching to an existing one, then there needs to be a way to reliably specify this behaviour via the CLI.

So we are scoring at three options for xen now:

-xen-domid <nr> specify xen domain id.
-xen-create ask qemu to create the domain.

Actually I'd invert that, eg -xen-attach since common QEMU semantics
are that it is completely in charge of creation. Attaching to an externally created VM is the xen additional semantics.

Regards,
Daniel

Signature · 4 lines
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
#111 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support

In reply to Daniel P. Berrange

Daniel P. Berrange writes ("Re: [Xen-devel] Re: [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support"):

Quoted 6 lines

This particular check is doing two different jobs in one go. I think they need to be dealt with separately.

- Check to see if running on Xen or not. This is a similar idea to to pv_ops where we have one kernel binary, and probe at runtime to decide whether to run in KVM, Xen, VMWare or bare metal mode.

I don't think this is correct for the Xen case. Certainly it is not correct for a qemu invoked by the Xen management tools, and it is also not correct for a qemu invoked by hand on a system which already has xend etc.

If you're trying to run qemu under Xen but standalone without xend then you're going to have to tell qemu that that's what you want. Otherwise if you try to run the same qemu under Xen but _with_ xend, qemu in dom0 will create a domain bypassing xend and cause all sorts of trouble.

Autodetection of this kind of thing is fragile, and in the Xen toolstack case also unnecessary (since the Xen toolstack can invoke qemu with appropriate options to tell it only to do the emulation parts).

So I think the default mode of operation for qemu instructed to provide a Xen domU environment should be 100% software, or via KVM if KVM is available. KVM is designed as a facility to be used by user processes without negotiation with the system administrator so it is fine to autodetect that and use it.

The Xen hypercall and domain management interfaces are not like that:
the interfaces provided by the hypervisor et al should be used only by cooperation with the Xen management stack.

Quoted 4 lines

This is important to QEMU too. Merging the source trees for all projects using QEMU is just the first step. A single binary for all is the holy grail, though may not be practical for Mini-OS usage

I'm certainly in favour of closer integration. If qemu upstream are willing to take all of our code, including the parts which serve modes of operation and features which qemu upstream don't agree are needed, then excellent.

But I think that for now it would be easier to concentrate on providing interfaces to allow the qemu-xen tree to mainly be additional code which goes through well-defined public interfaces to the rest of qemu. (From this point of view it's a shame that qemu itself isn't more like a library than an executable.)

Certainly the minios port can't be the same executable. The qemu code is statically linked with minios into what amounts to a monolithic PV guest kernel.

Quoted 3 lines

If we want QEMU to explicitly created Xen domains from scratch, rather than attaching to an existing one, then there needs to be a way to reliably specify this behaviour via the CLI.

Yes.

And this should not be done by default because on a system with xend, you don't want to be messing with xend's idea of the running domains.

Ian.

#92 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support

In reply to Gerd Hoffmann

Gerd Hoffmann writes ("Re: [Xen-devel] Re: [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support"):

Quoted 5 lines

So we are scoring at three options for xen now:

  -xen-domid <nr>  specify xen domain id.
  -xen-create      ask qemu to create the domain.
  -xen-emulate     force xen emulation mode.

No, the correct set of options are:

-xen-bare no xend on this system, qemu should create a Xen domain
without this, Xen machine types use emulated Xen functionality

-xen-domid <nr> has slightly different meanings in the various use cases

And if you really think you must have the same executable for the xend case:

-xen-attach used by xend; qemu is to support a Xen HVM domain
not to be used from the command line

Ian.

#10 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals.

In reply to Anthony Liguori

Anthony Liguori writes ("[Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals."):

Quoted 5 lines

The race I know of is that you may get an aio signal completion before select but after you've already qemu_aio_poll()'d. In practice, we only sleep for 10ms at a time in select() so the race is handled by that. If we wanted to increase the amount of time we slept, we would have to handle this race.

Yes. And, 10ms is too long anyway for reasonable performance. During my merge with upstream I found that the qemu aio functionality (which was done quite differently to the old xen ioemu) caused a severe performance regression under some conditions because of this race.

Quoted 3 lines

In KVM, we sleep for 1s in select() and use signalfd() to receive the aio notifications. For older hosts, we emulate signalfd using a thread and the pipe-to-self trick.

Why does it need a thread ? You can just write to the pipe in the signal handler. I'll post my code.

Ian.

#118 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 13/13] xen: pv domain builder.

In reply to Samuel Thibault

Samuel Thibault writes ("Re: [Xen-devel] Re: [Qemu-devel] [PATCH 13/13] xen: pv domain builder."):

Quoted 8 lines
Quoted 7 lines · Ian Jackson, le Tue 26 Aug 2008 11:42:11 +0100, a écrit :

Gerd Hoffmann writes ("[Qemu-devel] [PATCH 06/13] xen: backend driver core"):

Quoted 5 lines

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 4 lines
Quoted 1 line

These kind of patches are rather troublesome I'm afraid.

The one above should be fine I think (and the relevant console/pvfb refactoring, which Mark seemed happy to see).

I think that one is good in principle. But I would like to see that patch on its own against qemu-xen. Then the resulting files in Gerd's tree and my tree will be identical and there is no problem with Gerd's other new files which depend on it going upstream.

Ian.

#112 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support

In reply to Ian Jackson
Quoted 13 lines · Ian Jackson

Daniel P. Berrange writes ("Re: [Xen-devel] Re: [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support"):

Quoted 6 lines

This particular check is doing two different jobs in one go. I think they need to be dealt with separately.

- Check to see if running on Xen or not. This is a similar idea to to pv_ops where we have one kernel binary, and probe at runtime to decide whether to run in KVM, Xen, VMWare or bare metal mode.

I don't think this is correct for the Xen case. Certainly it is not correct for a qemu invoked by the Xen management tools, and it is also not correct for a qemu invoked by hand on a system which already has xend etc.

Quoted 5 lines

If you're trying to run qemu under Xen but standalone without xend then you're going to have to tell qemu that that's what you want. Otherwise if you try to run the same qemu under Xen but _with_ xend, qemu in dom0 will create a domain bypassing xend and cause all sorts of trouble.

Yes, mixing manually created VMs & XenD managed VMs is not a use case I was thinking we should try to address. The core use case for creating VMs on the Xen hypervisor, is that you want to avoid the python stack, and thus you aren't likely to have XenD around anyway.

Daniel

Signature · 4 lines
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
#122 lore raw

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

In reply to Ian Jackson

Hi,

Quoted 5 lines
Quoted 1 line

http://kraxel.fedorapeople.org/patches/qemu-xen/

Those patches are not suitable for inclusion in qemu-xen. This is because
- They rename files pointlessly

You havn't looked at them in detail for a while, right?

The pointless xen_* -> xen-* renames are all gone. Only one is left:
Rename xenfb.c to xen_framebuffer.c for consistency with the other xen files.

Quoted 2 lines

- They contain many changes which consist of the addition of new code which is not relevant for qemu-xen.

Feel free to just ignore them. In theory they should be a no-op anyway, but I though you'd prefer to be able to test that. If you don't want that, fine, I'll happily drop the patches then. Less work for me, which is always welcome.

Quoted 4 lines

It is fine for us to
change qemu-xen to make it easier for your tree and our tree to converge (such as factoring the backend driver core out of the qemu-xen xenfb).

Fine.

Quoted 2 lines

But we do not want (for example) your complete backend driver set.

You'll get them from upstream at some point anyway.
If you don't want them beforehand for testing just tell me, no problem.

Quoted 2 lines

- http://kraxel.fedorapeople.org/patches/qemu-xen/0001-kraxel-s-stuff.patch
"Kraxel's Stuff" ? This is a joke, right ?

Yea, the very first is just some script-age for me, ignore that one.

Patches 02 -> 04 pull depending patches, once you've merged with upstream they are not needed any more and will be removed from the patch set.

Patches 05 -> 09 is the backend core / console / framebuffer stuff you are willing to take.

Patch 10 are the xen_machine_pv.c changes (upstream changeset has this earlier, moved here for better bisectability).

Patch 11+ are disk + nic backends. Ignore them if you don't want them.

Quoted 1 line

This has been explained before, I think ?

Please read the patches and also the introduction text for the patch sets posted to xen-devel and qemu-devel. I *do* address your review comments.

cheers,
Gerd

#126 lore raw

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

In reply to Ian Jackson
Quoted 6 lines
Quoted 2 lines

If the patches break something, report it and I'll fix it up. "I'm afraid something might break" doesn't help us going forward.

What I meant is that if your changes are committed to qemu upstream, I will get an enormous pile of merge conflicts when I try to merge from upstream into our tree.

What do you think about the merge plan outlined in
http://lists.xensource.com/archives/html/xen-devel/2008-08/msg00887.html
That should avoid the enormous pile of merge conflicts, right?

cheers,
Gerd

#93 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support

In reply to Ian Jackson
Quoted 7 lines · Ian Jackson

Gerd Hoffmann writes ("Re: [Xen-devel] Re: [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support"):

Quoted 5 lines

So we are scoring at three options for xen now:

  -xen-domid <nr>  specify xen domain id.
  -xen-create      ask qemu to create the domain.
  -xen-emulate     force xen emulation mode.
Quoted 5 lines

No, the correct set of options are:

-xen-bare no xend on this system, qemu should create a Xen domain
without this, Xen machine types use emulated Xen functionality

I'm not sure I understand what you mean here ? Are you suggesting this for the 'Xen hypervisor present, standalone mode - ie no XenD' ? If so I think that's not right - for standalone mode we shouldn't require any special args for the admin. We should only require additional args for cases where management tools like XenD or libvirt are invoking QEMU.

Quoted 1 line

-xen-domid <nr> has slightly different meanings in the various use cases

Perhaps best not to overload this then - pass domid to the -attach arg directly, and have a -xen-create <nr> for the scenario where you want to specify the domid for a newly created VM

Quoted 5 lines

And if you really think you must have the same executable for the xend case:

-xen-attach used by xend; qemu is to support a Xen HVM domain
not to be used from the command line

I'll try to enumerate the scenarios here...

On KVM, using Xenner + shell : No special args
On KVM, using Xenner + libvirtd : -xen-create <domid>

 On Xen HV + shell     : No special args
 On Xen HV + libvirtd  : -xen-create <domid>
 On Xen HV + XenD      : -xen-attach <domid>

NB. by 'shell' I mean the admin manually launching QEMU from the shell

If neither -xen-create or -xen-attach is given, then it will create a new domain from scratch & auto-allocate a domid. Passing both the -xen-create and -xen-attach args is forbidden / nonsensical.

In all cases, the actual hypervisor domain ID should be exposed via the monitor console.

Ian, did I miss any of the use cases you want addressed ? I'm leaving mini-os out of this now, since as you say, its impossible to have one binary deal with it, but I'll assume its similar to -xen-attach <domid> use case in its working.

Daniel

Signature · 4 lines
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
#123 lore raw

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

In reply to Gerd Hoffmann

Gerd Hoffmann writes ("Re: [Qemu-devel] [PATCH 13/13] xen: pv domain builder."):

Quoted 5 lines
Quoted 3 lines

Those patches are not suitable for inclusion in qemu-xen. This is because
- They rename files pointlessly

You havn't looked at them in detail for a while, right?

I just visited the URL and I still saw ...

Quoted 3 lines

The pointless xen_* -> xen-* renames are all gone. Only one is left:
Rename xenfb.c to xen_framebuffer.c for consistency with the other xen files.

... this. I agree that it would be nice to have the files have nice names. But for the moment when all of our trees are so heavily diverged, and development in many of the trees is proceeding apace I think that renaming files is very harmful.

But thanks a lot for these explanations:

Quoted 11 lines

Patches 02 -> 04 pull depending patches, once you've merged with upstream they are not needed any more and will be removed from the patch set.

Patches 05 -> 09 is the backend core / console / framebuffer stuff you are willing to take.

Patch 10 are the xen_machine_pv.c changes (upstream changeset has this earlier, moved here for better bisectability).

Patch 11+ are disk + nic backends. Ignore them if you don't want them.

Obviously when faced with a 13-patch series the first of which is a mistake, you can understand my scepticism and my reluctance to give each individual patch the full half hour ?

I'll take a more thorough look at 02-06. Do they in your opinion make sense on their own in qemu-xen-unstable ?

Ian.

#94 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support

In reply to Daniel P. Berrange
Quoted 4 lines · Daniel P. Berrange

I'll try to enumerate the scenarios here...

On KVM, using Xenner + shell : No special args
On KVM, using Xenner + libvirtd : -xen-create <domid>

This is "xen emulation" and (according to long term plan plan) doesn't require kvm but should work with qemu emulating things too. This means it doesn't depend on kvm, you can do that with xen underneath too. This is what the -xen-emulate switch is good for.

Quoted 3 lines
 On Xen HV + shell     : No special args
 On Xen HV + libvirtd  : -xen-create <domid>
 On Xen HV + XenD      : -xen-attach <domid>

I like the "create" and "attach" namings as they make pretty clear what qemu should do.

cheers,
Gerd

#95 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support

Quoted 10 lines · Gerd Hoffmann
Quoted 4 lines · Daniel P. Berrange

I'll try to enumerate the scenarios here...

On KVM, using Xenner + shell : No special args
On KVM, using Xenner + libvirtd : -xen-create <domid>

This is "xen emulation" and (according to long term plan plan) doesn't require kvm but should work with qemu emulating things too. This means it doesn't depend on kvm, you can do that with xen underneath too. This is what the -xen-emulate switch is good for.

Wouldn't the non-KVM case already be dealt with by the -no-kvm command line arg to QEMU ?

Quoted 6 lines
Quoted 3 lines
 On Xen HV + shell     : No special args
 On Xen HV + libvirtd  : -xen-create <domid>
 On Xen HV + XenD      : -xen-attach <domid>

I like the "create" and "attach" namings as they make pretty clear what qemu should do.

Regards,
Daniel

Signature · 4 lines
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
#96 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support

Quoted 6 lines · Daniel P. Berrange
Quoted 5 lines · Gerd Hoffmann
Quoted 4 lines · Daniel P. Berrange

I'll try to enumerate the scenarios here...

On KVM, using Xenner + shell : No special args
On KVM, using Xenner + libvirtd : -xen-create <domid>

Quoted 7 lines
Quoted 4 lines

This is "xen emulation" and (according to long term plan plan) doesn't require kvm but should work with qemu emulating things too. This means it doesn't depend on kvm, you can do that with xen underneath too. This is what the -xen-emulate switch is good for.

Wouldn't the non-KVM case already be dealt with by the -no-kvm command line arg to QEMU ?

But when running on xen we want being able to qemu tell it should *not* use the xen hypervisor but emulate things, thus -xen-emulate.

cheers,
Gerd

#11 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals.

In reply to Ian Jackson
Quoted 6 lines · Ian Jackson
Quoted 2 lines

In KVM, we sleep for 1s in select() and use signalfd() to receive the aio notifications. For older hosts, we emulate signalfd using a thread and the pipe-to-self trick.

Why does it need a thread ? You can just write to the pipe in the signal handler. I'll post my code.

Not sure that it matters, but the semantics are slightly different: with a thread you don't get EINTR in random syscalls as the signal thread is the only one that has the signals unblocked.

Signature · 1 line
error compiling committee.c: too many arguments to function
#97 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support

In reply to Gerd Hoffmann
Quoted 12 lines · Gerd Hoffmann
Quoted 11 lines · Daniel P. Berrange
Quoted 9 lines · Gerd Hoffmann
Quoted 4 lines · Daniel P. Berrange

I'll try to enumerate the scenarios here...

On KVM, using Xenner + shell : No special args
On KVM, using Xenner + libvirtd : -xen-create <domid>

This is "xen emulation" and (according to long term plan plan) doesn't require kvm but should work with qemu emulating things too. This means it doesn't depend on kvm, you can do that with xen underneath too. This is what the -xen-emulate switch is good for.

Quoted 5 lines
Quoted 2 lines

Wouldn't the non-KVM case already be dealt with by the -no-kvm command line arg to QEMU ?

But when running on xen we want being able to qemu tell it should *not* use the xen hypervisor but emulate things, thus -xen-emulate.

Oh, i see what you mean. Existing naming practice would suggest naming it -no-xenhv or just -no-xen

All these '-no-XXX' args are getting a little silly though. I'd rather tell QEMU what I *do* want, than what I don't want. A generic arg '-accelerator none|xen|kvm|kqemu' might be worth considering in the future. That can be a separate discussion from these patches though - we should just follow the -no-XXX naming for now to minimize diffs

Daniel

Signature · 4 lines
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
#99 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support

In reply to Gerd Hoffmann

Gerd Hoffmann writes ("Re: [Xen-devel] Re: [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support"):

Quoted 2 lines

But when running on xen we want being able to qemu tell it should *not* use the xen hypervisor but emulate things, thus -xen-emulate.

That should be the default. It is not safe to use the Xen hypervisor directly if there is a management toolstack which expects to mediate domain creation.

Ian.

#44 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals.

In reply to a message not in the archive

Ian Jackson writes ("Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals."):

Quoted 2 lines

Why does it need a thread ? You can just write to the pipe in the signal handler. I'll post my code.

Just done. As you see it's quite straightforward. We have to save/restore errno in the signal handler as usual.

So should I provide a patch to do the same for the termination signals ? They are much less time-critical than aio completion so it's perhaps less important.

Ian.

#13 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals.

In reply to Ian Jackson
Quoted 10 lines · Ian Jackson

Anthony Liguori writes ("[Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals."):

Quoted 2 lines

The race I know of is that you may get an aio signal completion before select but after you've already qemu_aio_poll()'d. In practice, we only sleep for 10ms at a time in select() so the race is handled by that. If we wanted to increase the amount of time we slept, we would have to handle this race.

Yes. And, 10ms is too long anyway for reasonable performance. During my merge with upstream I found that the qemu aio functionality (which was done quite differently to the old xen ioemu) caused a severe performance regression under some conditions because of this race.

Yeah, noticed that too, especially with qcow2.

Quoted 6 lines
Quoted 2 lines

In KVM, we sleep for 1s in select() and use signalfd() to receive the aio notifications. For older hosts, we emulate signalfd using a thread and the pipe-to-self trick.

Why does it need a thread ? You can just write to the pipe in the signal handler. I'll post my code.

It's a little less perfect. Your signal handler can write() to the pipe but what happens if you get EAGAIN?

So what we do in KVM is use sigwait() within a separate thread. We don't set O_NONBLOCK so the thread blocks if the pipe fills up which is exactly the semantics you would want.

Below is our implementation. I'll queue up to push this change into QEMU after I finish with the migration patches.

Regards,

Anthony Liguori

#include <sys/syscall.h>
#include <pthread.h>

struct sigfd_compat_info
{
sigset_t mask;
int fd;
};

static void *sigwait_compat(void *opaque)
{
struct sigfd_compat_info *info = opaque;
int err;
sigset_t all;

   sigfillset(&all);
   sigprocmask(SIG_BLOCK, &all, NULL);

   do {
   siginfo_t siginfo;

   err = sigwaitinfo(&info->mask, &siginfo);
   if (err == -1 && errno == EINTR) {
           err = 0;
           continue;
       }

   if (err > 0) {
       char buffer[128];
       size_t offset = 0;
       memcpy(buffer, &err, sizeof(err));
       while (offset < sizeof(buffer)) {
       ssize_t len;

       len = write(info->fd, buffer + offset,
               sizeof(buffer) - offset);
       if (len == -1 && errno == EINTR)
           continue;

       if (len <= 0) {
           err = -1;
           break;
       }

       offset += len;
       }

}
} while (err >= 0);

return NULL;
}

static int kvm_signalfd_compat(const sigset_t *mask) {
pthread_attr_t attr;
pthread_t tid;
struct sigfd_compat_info *info;
int fds[2];

   info = malloc(sizeof(*info));
   if (info == NULL) {
   errno = ENOMEM;
   return -1;
   }

   if (pipe(fds) == -1) {
   free(info);
   return -1;
   }

   memcpy(&info->mask, mask, sizeof(*mask));
   info->fd = fds[1];

   pthread_attr_init(&attr);
   pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);

   pthread_create(&tid, &attr, sigwait_compat, info);

   pthread_attr_destroy(&attr);

return fds[0];
}

int kvm_signalfd(const sigset_t *mask)
{
#if defined(SYS_signalfd)
int ret;

ret = syscall(SYS_signalfd, -1, mask, _NSIG / 8); if (!(ret == -1 && errno == ENOSYS)) return ret;
#endif

return kvm_signalfd_compat(mask);
}

Quoted 2 lines

Ian.

#109 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support

In reply to a message not in the archive

Daniel P. Berrange writes ("Re: [Xen-devel] Re: [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support"):

Quoted 7 lines · Ian Jackson
Quoted 3 lines

-xen-bare no xend on this system, qemu should create a Xen domain
without this, Xen machine types use emulated Xen functionality

I'm not sure I understand what you mean here ? Are you suggesting this for the 'Xen hypervisor present, standalone mode - ie no XenD' ?

Yes.

Quoted 4 lines

If so I think that's not right - for standalone mode we shouldn't
require any special args for the admin. We should only require additional args for cases where management tools like XenD or libvirt are invoking QEMU.

The usual case for a Xen installation is that xend is running. In that situation, it is wrong for qemu to create a domain directly. That will interfere with xend's management of the whole system.

So that means that it is not right to detect that we are running under Xen and if so create a domain by default. That should only be done if the person invoking qemu knows that there is no xend and therefore that creating the domain directly is sensible.

Quoted 7 lines

I'll try to enumerate the scenarios here...

On KVM, using Xenner + shell : No special args
On KVM, using Xenner + libvirtd : -xen-create <domid>

 On Xen HV + shell     : No special args
 On Xen HV + libvirtd  : -xen-create <domid>
 On Xen HV + XenD      : -xen-attach <domid>

You've missed out entirely software emulation of a Xen environment. AIUI this is pretty mucbh Xenner without KVM.

And see my comments above about running under Xen. The Xen hypervisor is not a system facility which user processes are expected to make use of without negotiating with the prevailing Xen management stack. This is unlike KVM, where all KVM's callers can be oblivious to each other.

If you run qemu to invoke a Xen domU image it should not disturb any existing actual Xen installation, and the behaviour and outcome should not depend on whether the whole lot is running under a real Xen (with xend et al). It is fine to use KVM if available because that's just a performance improvement.

This is because the way to start a Xen domU, as stated in the Xen documentation etc., is via the Xen management tools. If a user tries to do it via qemu then they are either making a mistake, or intending to run an emulated Xen environment. (Note that they may be running qemu on a Xen domU in which case creating a domain isn't even possible.)

If we make qemu actually create a guest by direct hypercalls, the Xen management stack will be disrupted ...

Quoted 3 lines

If neither -xen-create or -xen-attach is given, then it will create a new domain from scratch & auto-allocate a domid. Passing both the -xen-create and -xen-attach args is forbidden / nonsensical.

... so this behaviour should not be the default.

Quoted 4 lines

Ian, did I miss any of the use cases you want addressed ? I'm leaving mini-os out of this now, since as you say, its impossible to have one binary deal with it, but I'll assume its similar to -xen-attach <domid> use case in its working.

Fairly similar.

Ian.

#14 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals.

In reply to Anthony Liguori

Anthony Liguori writes ("Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals."):

Quoted 2 lines

It's a little less perfect. Your signal handler can write() to the pipe but what happens if you get EAGAIN?

Then the pipe already has something in it which is fine. The purpose of writing to it is to make sure that it is not empty. We don't count the bytes.

Quoted 2 lines

Below is our implementation. I'll queue up to push this change into QEMU after I finish with the migration patches.

Please consider my patch instead, which doesn't depend on threads and is a lot smaller.

Ian.

#110 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support

In reply to Ian Jackson
Quoted 30 lines · Ian Jackson

Daniel P. Berrange writes ("Re: [Xen-devel] Re: [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support"):

Quoted 7 lines

I'll try to enumerate the scenarios here...

On KVM, using Xenner + shell : No special args
On KVM, using Xenner + libvirtd : -xen-create <domid>

 On Xen HV + shell     : No special args
 On Xen HV + libvirtd  : -xen-create <domid>
 On Xen HV + XenD      : -xen-attach <domid>

You've missed out entirely software emulation of a Xen environment. AIUI this is pretty mucbh Xenner without KVM.

And see my comments above about running under Xen. The Xen hypervisor is not a system facility which user processes are expected to make use of without negotiating with the prevailing Xen management stack. This is unlike KVM, where all KVM's callers can be oblivious to each other.

If you run qemu to invoke a Xen domU image it should not disturb any existing actual Xen installation, and the behaviour and outcome should not depend on whether the whole lot is running under a real Xen (with xend et al). It is fine to use KVM if available because that's just a performance improvement.

This is because the way to start a Xen domU, as stated in the Xen documentation etc., is via the Xen management tools. If a user tries to do it via qemu then they are either making a mistake, or intending to run an emulated Xen environment. (Note that they may be running qemu on a Xen domU in which case creating a domain isn't even possible.)

Quoted 2 lines

If we make qemu actually create a guest by direct hypercalls, the Xen management stack will be disrupted ...

Ok, in that case dis-regard my sugestion of '-no-xen' in the other mail I just sent. Clearly the negative style args won't work in the xen case, and we have to go for a positive switch - maybe it really is worth doing an explicit '-accelerator none|kvm|xen|kqemu' right away for this patchset...

Daniel

Signature · 4 lines
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
#15 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals.

In reply to Ian Jackson
Quoted 6 lines · Ian Jackson

Anthony Liguori writes ("Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals."):

Then the pipe already has something in it which is fine. The purpose of writing to it is to make sure that it is not empty. We don't count the bytes.

Then you need a pipe per-signal and you can't accurately simulate threadfd() (since you can't communicate siginfo).

Quoted 3 lines

Please consider my patch instead, which doesn't depend on threads and is a lot smaller.

I don't see threads as a problem. Are you concerned about mini-OS?

Regards,

Anthony Liguori

Quoted 2 lines

Ian.

#29 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals.

In reply to Ian Jackson
Quoted 6 lines · Ian Jackson

Anthony Liguori writes ("Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals."):

Then the pipe already has something in it which is fine. The purpose of writing to it is to make sure that it is not empty. We don't count the bytes.

BTW, I don't see your patch yet, but my mail is pretty funky right now.

Then you need a pipe per-signal and you can't accurately simulate threadfd() (since you can't communicate siginfo).

Quoted 3 lines

Please consider my patch instead, which doesn't depend on threads and is a lot smaller.

I don't see threads as a problem. Are you concerned about mini-OS?

Regards,

Anthony Liguori

Quoted 2 lines

Ian.

#31 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals.

In reply to a message not in the archive

Avi Kivity writes ("Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals."):

Quoted 3 lines

Not sure that it matters, but the semantics are slightly different:
with a thread you don't get EINTR in random syscalls as the signal thread is the only one that has the signals unblocked.

That's true but I don't think it's really relevant because we already have other signal handlers (and we might grow further ones) so the rest of the code has to be robust against those.

My experience suggests very strongly that we should avoid doing multithreaded things if at all possible. Threads are less portable; even when they are provided many of the implementations are buggy (although less so nowadays).

There is also the way that once you have a multithreaded program, it is much more difficult to discourage the expansion of the concurrent functionality until the whole program is a mass of race bugs. I would rather not open this stable door.

Ian.

#16 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals.

In reply to Anthony Liguori

Anthony Liguori writes ("Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals."):

Quoted 2 lines

Then you need a pipe per-signal and you can't accurately simulate threadfd() (since you can't communicate siginfo).

No, you don't need a pipe per signal. You only need multiple pipes if you have multiple different event loops which are each capable of handling only a subset of the signals, _and_ you're unwilling to use an atomic flag variable (eg, cpu_interrupt) or its equivalent.

But we already have cpu_interrupt, and of course the aio completion system has its own recording of what's going on. So that does not apply to qemu.

All that's needed is a reliable, race-free, way of avoiding spuriously blocking in a syscall when an event occurs between checking the state variables (aio_error, cpu interrupt check) and the call to select(). One fd is sufficient for that.

Just to make that concrete, even if we extended my patch to use its mechanism for SIGINT et al I don't think a second pipe would be needed.

Quoted 1 line

I don't see threads as a problem. Are you concerned about mini-OS?

Minios certainly doesn't currently have any threads and it would probably be a severe pain to introduce them. That's just one example of a portability problem.

Ian.

#32 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals.

In reply to Ian Jackson
Quoted 14 lines · Ian Jackson

Avi Kivity writes ("Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals."):

Quoted 2 lines

Not sure that it matters, but the semantics are slightly different: with a thread you don't get EINTR in random syscalls as the signal thread is the only one that has the signals unblocked.

That's true but I don't think it's really relevant because we already have other signal handlers (and we might grow further ones) so the rest of the code has to be robust against those.

My experience suggests very strongly that we should avoid doing multithreaded things if at all possible. Threads are less portable; even when they are provided many of the implementations are buggy (although less so nowadays).

Quoted 6 lines

There is also the way that once you have a multithreaded program, it is much more difficult to discourage the expansion of the concurrent functionality until the whole program is a mass of race bugs. I would rather not open this stable door.

In this case the thread is only used to emulate the signalfd() system call; it is not part of qemu proper.

Signature · 1 line
error compiling committee.c: too many arguments to function
#17 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals.

In reply to Ian Jackson
Quoted 14 lines · Ian Jackson

Anthony Liguori writes ("Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals."):

Quoted 2 lines

Then you need a pipe per-signal and you can't accurately simulate threadfd() (since you can't communicate siginfo).

No, you don't need a pipe per signal. You only need multiple pipes if you have multiple different event loops which are each capable of handling only a subset of the signals, _and_ you're unwilling to use an atomic flag variable (eg, cpu_interrupt) or its equivalent.

But we already have cpu_interrupt, and of course the aio completion system has its own recording of what's going on. So that does not apply to qemu.

Quoted 9 lines

All that's needed is a reliable, race-free, way of avoiding spuriously blocking in a syscall when an event occurs between checking the state variables (aio_error, cpu interrupt check) and the call to select(). One fd is sufficient for that.

Just to make that concrete, even if we extended my patch to use its mechanism for SIGINT et al I don't think a second pipe would be needed.

In KVM, we do use the signal number to determine action. We could use globals but since we're multi-threaded, that gets pretty nasty. The same would apply to a threaded QEMU.

Quoted 7 lines
Quoted 2 lines

I don't see threads as a problem. Are you concerned about mini-OS?

Minios certainly doesn't currently have any threads and it would probably be a severe pain to introduce them. That's just one example of a portability problem.

We're definitely not going to avoid threads forever in QEMU. KVM requires threads to support multiple VCPUs. Threads are also needed to support true SMP with TCG.

And right now, implementing a thread pool is the only sane way to get reasonable disk IO in userspace.

I share your concerns about threading, which is why we have to use them in a very careful way. My signalfd() patch uses them in a very isolated way that is pretty easily verified.

You could always add proper signalfd() support to minios. You can also certainly implement a signalfd() emulation that uses pipe(). signalfd() is really the right solution to this problem (and it doesn't require threads by default).

Regards,

Anthony Liguori

Quoted 2 lines

Ian.

#28 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals.

In reply to Ian Jackson
Quoted 4 lines · Ian Jackson, le Tue 26 Aug 2008 16:28:54 +0100, a écrit :
Quoted 1 line

I don't see threads as a problem. Are you concerned about mini-OS?

Minios certainly doesn't currently have any threads and it would probably be a severe pain to introduce them.

It has threads for its own internal uses, but it doesn't provide an interface for them (makes everything a lot simpler and efficient of course)

Samuel

#34 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals.

In reply to a message not in the archive

Avi Kivity writes ("Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals."):

Quoted 6 lines
Quoted 5 lines · Ian Jackson

My experience suggests very strongly that we should avoid doing multithreaded things if at all possible. Threads are less portable; even when they are provided many of the implementations are buggy (although less so nowadays).

Quoted 7 lines
Quoted 4 lines

There is also the way that once you have a multithreaded program, it is much more difficult to discourage the expansion of the concurrent functionality until the whole program is a mass of race bugs. I would rather not open this stable door.

In this case the thread is only used to emulate the signalfd() system call; it is not part of qemu proper.

That doesn't make us any less exposed to bugs in the threading implementation, and is only of marginal use if anything for explaining to people why we shouldn't have a Windows-style multithreaded bug pile.

Also, I think messing about with Linux-specific syscalls and then emulating them is hardly a sensible way to carry on, when the alternative is portable and simple.

Ian.

#35 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals.

Quoted 14 lines · Ian Jackson

Avi Kivity writes ("Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals."):

Quoted 12 lines
Quoted 10 lines · Ian Jackson

My experience suggests very strongly that we should avoid doing multithreaded things if at all possible. Threads are less portable; even when they are provided many of the implementations are buggy (although less so nowadays).

There is also the way that once you have a multithreaded program, it is much more difficult to discourage the expansion of the concurrent functionality until the whole program is a mass of race bugs. I would rather not open this stable door.

Quoted 9 lines
Quoted 2 lines

In this case the thread is only used to emulate the signalfd() system call; it is not part of qemu proper.

That doesn't make us any less exposed to bugs in the threading implementation, and is only of marginal use if anything for explaining to people why we shouldn't have a Windows-style multithreaded bug pile.

Threading bugs in the implementation? In 2008?

Practically all serious software is multithreaded nowadays.

Quoted 3 lines

Also, I think messing about with Linux-specific syscalls and then emulating them is hardly a sensible way to carry on, when the alternative is portable and simple.

This has merit; though signalfd() will be a lot faster than catching a signal and writing to a pipe.

In particular, delivering a signal to userspace has to save the floating point context, while signalfd() avoids it. With the signals used to signal I/O completion, this matters.

Signature · 1 line
error compiling committee.c: too many arguments to function
#36 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals.

Quoted 3 lines · Avi Kivity

Threading bugs in the implementation? In 2008?

Practically all serious software is multithreaded nowadays.

That's not in itself an argument in support of writing threaded code if you don't have to.

I spent much of the last year developing thread-checking tools in the Valgrind framework (Helgrind), and testing them on serious software. From that I would say that practically all serious multithreaded software is riddled with threading bugs, mostly data races and inconsistent lock orderings (potential deadlocks).

J

#37 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals.

Quoted 11 lines · Julian Seward
Quoted 4 lines · Avi Kivity

Threading bugs in the implementation? In 2008?

Practically all serious software is multithreaded nowadays.

That's not in itself an argument in support of writing threaded code if you don't have to.

I know arguing about threading is almost as fun as arguing about XML, but in this very specific, very particular case, it's pretty obvious by simple inspection that there aren't thread safety issues.

Regards,

Anthony Liguori

#18 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals.

In reply to Anthony Liguori
Quoted 3 lines · Anthony Liguori

In KVM, we do use the signal number to determine action. We could use globals but since we're multi-threaded, that gets pretty nasty. The same would apply to a threaded QEMU.

Often one pipe per select-caller is enough, with global state to distinguish events. For signalfd() emulation, that's an array of

    sig_atomic_t signal_was_hit[NSIG];

(Or just `char' - in pthreads that should be safe to write, right? One bit is enough storage, but not thread safe.)

However, if you depend on the signal number _combined_ with which thread receives the signal - then you're in trouble.

pthread_self() should not be called from a signal handler; it's safety is not portable. Thread-local storage (__thread int x) is not portable and might not be signal safe either. All you've got left is gettid(), and that's not portable either.

"signalfd helper thread writing to pipe" wouldn't solve that either. You'd need one _per_ thread that would have called signalfd() (if you had it) - in order to distinguish recipients. But that helper's handler can't tell which thread it is, and therefore which pipe to write to!

But you did say you're using signalfd(). And signalfd() doesn't distinguish thread recipients (I'm surprised it doesn't). That whole meander was just an interesting but irrelevant puzzle.

Leading to: why would (real) signals being used to collect AIO events anyway, if you don't have signalfd()? If you've got a helper thread, just call aio_suspend() in the helper thread. Then you can just deliver the AIO completion result to the relevant data structure or even move it off the waiting queue (pthread_mutex_lock is your friend), then wake the main waiting thread with byte written to its pipe.

-- Jamie

#12 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals.

In reply to Avi Kivity
Quoted 6 lines · Avi Kivity
Quoted 5 lines · Ian Jackson
Quoted 4 lines

In KVM, we sleep for 1s in select() and use signalfd() to receive the aio notifications. For older hosts, we emulate signalfd using a thread and the pipe-to-self trick.

Quoted 7 lines
Quoted 3 lines

Why does it need a thread ? You can just write to the pipe in the signal handler. I'll post my code.

Not sure that it matters, but the semantics are slightly different:
with a thread you don't get EINTR in random syscalls as the signal thread is the only one that has the signals unblocked.

You shouldn't be getting spurious EINTRs if the signal handlers are registered with SA_RESTART. I doubt if any useful host which has threads does not have SA_RESTART.

-- Jamie

#8 lore raw

Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals.

In reply to Gerd Hoffmann
Quoted 9 lines · Gerd Hoffmann
Quoted 5 lines · Ian Jackson

Gerd Hoffmann writes ("Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals."):

Quoted 2 lines

What this would be useful for? The termination signals usualy one-shot anyway, so I don't see any advantage in doing the pipe-to-self trick.

The point is that then they can interrupt select().

Sure, basically any signal can interrupt any system call. I still don't see the point you are trying to make.

Signals interrupting system calls has nothing to do with it.

The point is this sequence:

1. Check for signals / flags from signals... nope.

[[ 2. Signal arrives! Sets flag. ]]

3. Call select().

The signal occurs _after_ the main loop checks for wakeup conditons, but _before_ select() is called. It doesn't interrupt select() because that hasn't started yet. Result: select() blocks for a long time.

In the fixed version, the signal handler writes to the self-pipe, and select() is called in the main loop, and returns immediately because the self-pipe is ready to read. (The data in it is ignored, just read to empty it.)

The other way this can be done is for the signal handler to call siglongjmp(). But that's slower (every call to select() must call sigsetjmp() which is a bit slow), and crashes some OSes. The self-pipe is well known for being reliable.

-- Jamie

#19 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals.

In reply to Jamie Lokier
Quoted 3 lines · Jamie Lokier

But you did say you're using signalfd(). And signalfd() doesn't distinguish thread recipients (I'm surprised it doesn't). That whole meander was just an interesting but irrelevant puzzle.

Gah, ignore that paragraph please. Blind spot in manual reading.

-- Jamie

#20 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals.

In reply to Jamie Lokier
Quoted 3 lines · Jamie Lokier

Leading to: why would (real) signals being used to collect AIO events anyway, if you don't have signalfd()? If you've got a helper thread, just call aio_suspend() in the helper thread.

There is no helper thread when signalfd() is available. The helper thread thing is only for backwards compatibility or for unices that don't support signalfd. Plus, there are a lot of places that we use signals currently.

Quoted 6 lines

Then you can just
deliver the AIO completion result to the relevant data structure or even move it off the waiting queue (pthread_mutex_lock is your friend), then wake the main waiting thread with byte written to its pipe.

It's the queuing with threads where things start getting complicated and error prone.

Regards,

Anthony Liguori

Quoted 4 lines

-- Jamie

#98 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support

In reply to Daniel P. Berrange
Quoted 6 lines · Daniel P. Berrange
Quoted 2 lines · Gerd Hoffmann

But when running on xen we want being able to qemu tell it should *not* use the xen hypervisor but emulate things, thus -xen-emulate.

Oh, i see what you mean. Existing naming practice would suggest naming it -no-xenhv or just -no-xen

Well, as you are going to run a xen guest -no-xen wouldn't be very intuitive IMHO. -no-xenhv is only slightly better.

Quoted 3 lines

All these '-no-XXX' args are getting a little silly though. I'd rather tell QEMU what I *do* want, than what I don't want. A generic arg '-accelerator none|xen|kvm|kqemu' might be worth considering in the future.

Agreed.

cheers,
Gerd

#124 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 13/13] xen: pv domain builder.

In reply to Ian Jackson
Quoted 7 lines
Quoted 7 lines

Patches 02 -> 04 pull depending patches, once you've merged with upstream they are not needed any more and will be removed from the patch set.

Patches 05 -> 09 is the backend core / console / framebuffer stuff you are willing to take.

Quoted 7 lines
Quoted 4 lines

Patch 10 are the xen_machine_pv.c changes (upstream changeset has this earlier, moved here for better bisectability).

Patch 11+ are disk + nic backends. Ignore them if you don't want them.

I'll take a more thorough look at 02-06. Do they in your opinion make sense on their own in qemu-xen-unstable ?

02 -> 04 Make sense if you want to *test* the patches without merging
with upstream qemu before. For *merging* the patches I'd suggest to merge from upstream qemu instead, then wait for me rebasing the patchset (and dropping these patches).

05 -> 06  backend core.
07        switches the console to the new backend core.
08        xenfb.c -> xen_framebuffer.c rename.
09        switch framebuffer to new backend core.

05 + 06 alone are not useful as nobody uses the new backend core then. Merging 07 too gives at least one user. 08+09 going in gives a second user. They are a nice cleanup and certainly make sense for qemu-xen-unstable.

cheers,
Gerd

#119 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 13/13] xen: pv domain builder.

In reply to Samuel Thibault
Quoted 8 lines · Samuel Thibault
Quoted 7 lines · Ian Jackson, le Tue 26 Aug 2008 11:42:11 +0100, a écrit :

Gerd Hoffmann writes ("[Qemu-devel] [PATCH 06/13] xen: backend driver core"):

Quoted 5 lines

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 6 lines
Quoted 1 line

These kind of patches are rather troublesome I'm afraid.

The one above should be fine I think (and the relevant console/pvfb refactoring, which Mark seemed happy to see).

Samuel

Yes, I'm endorsing it. Factoring out the generic backend core makes lots of sense, and the resulting PVFB code is cleaner and easier to understand.

#38 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals.

In reply to Julian Seward
Quoted 8 lines · Julian Seward
Quoted 4 lines · Avi Kivity

Threading bugs in the implementation? In 2008?

Practically all serious software is multithreaded nowadays.

Quoted 9 lines

That's not in itself an argument in support of writing threaded code if you don't have to.

I spent much of the last year developing thread-checking tools in the Valgrind framework (Helgrind), and testing them on serious software. From that I would say that practically all serious multithreaded software is riddled with threading bugs, mostly data races and inconsistent lock orderings (potential deadlocks).

Most serious software has to be threaded. The absence of nonblocking libraries, the complexities of compositing nonblocking components when they do exist, and the requirement for utilizing multiple cores, all push towards threading.

I agree that it's incredibly easy to write badly threaded code. But I don't see a way to avoid it.

Signature · 1 line
error compiling committee.c: too many arguments to function
#39 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals.

Quoted 2 lines

I agree that it's incredibly easy to write badly threaded code. But I don't see a way to avoid it.

Message passing, using the right language tools (in C that unfortunately means writing your own or going back to 60s textbooks)

#100 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support

In reply to Ian Jackson
Quoted 7 lines · Ian Jackson

Gerd Hoffmann writes ("Re: [Xen-devel] Re: [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support"):

Quoted 2 lines

But when running on xen we want being able to qemu tell it should *not* use the xen hypervisor but emulate things, thus -xen-emulate.

That should be the default. It is not safe to use the Xen hypervisor directly if there is a management toolstack which expects to mediate domain creation.

Ok. I think we have three cases then:

(1) xen emulation using xenner (default, with or without kvm).
(2) running on xen, with xend creating the domain, and
(3) running on xen, with qemu creating the domain.

For (2) and (3) we need command line switches to enable these modes. Specifying a domain ID makes sense in all three cases though. So I'd keep the -xen-domid switch, like this:

  -xen-domid <nr>    specify xen domain id.
  -xen-attach        attach to specified domain (created by xend).
  -xen-create        create the domain directly.

Comments?

cheers,
Gerd

#40 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals.

In reply to Alan Cox
Quoted 6 lines · Alan Cox
Quoted 2 lines

I agree that it's incredibly easy to write badly threaded code. But I don't see a way to avoid it.

Message passing, using the right language tools (in C that unfortunately means writing your own or going back to 60s textbooks)

Oh, if we're talking languages, then I'm all for pure functional languages. If you are side effects free, you can let the runtime do all the threading for you automatically.

I don't see that catching on though.

Signature · 1 line
error compiling committee.c: too many arguments to function
#42 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals.

In reply to Alan Cox
Quoted 6 lines · Alan Cox
Quoted 2 lines

I agree that it's incredibly easy to write badly threaded code. But I don't see a way to avoid it.

Message passing, using the right language tools (in C that unfortunately means writing your own or going back to 60s textbooks)

Long live MPI!

--
Gleb.

#41 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals.

In reply to Avi Kivity
Quoted 7 lines · Avi Kivity
Quoted 3 lines

Message passing, using the right language tools (in C that unfortunately means writing your own or going back to 60s textbooks)

Oh, if we're talking languages, then I'm all for pure functional languages. If you are side effects free, you can let the runtime do all the threading for you automatically.

Practical efficient implementation of this is still an open research problem, I believe. At least as far as auto-parallelisation is concerned. It's one of those pure-functional-language myths.

-- Keir

#21 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals.

In reply to Jamie Lokier

Jamie Lokier writes ("Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals."):

Quoted 2 lines

Leading to: why would (real) signals being used to collect AIO events anyway, if you don't have signalfd()? If you've got a helper thread,

If you use aio, glibc has a tendency to emulate it with thread(s). The helper thread I was referring to in my commit message is the glibc-created helper thread. glibc appears (in strace) to do IO in this thread and then raises the signal you asked for (SIGUSR2 in qemu's case).

In some of my tests with qemu that SIGUSR2 was then immediately delivered on the helper thread even though the main program had it blocked. I saw this in strace in a real qemu instance but I wasn't able to reproduce it in a trivial test program. The result is that we lose the race that sigwait() is supposed to avoid. Hence my replacement of sigwait with the self-pipe trick.

This is not to be confused with Anthony Ligouri's helper thread, which is doing the same job as my SIGUSR2 handler. In Anthony's setup there will be two helper threads (assuming no signalfd and no kernel aio):
one invented by glibc to emulate aio, and one invented by Anthony to emulate signalfd. glibc will do the aio in its helper thread, raise SIGUSR2, which will wake up Anthony's thread, which will write to the pipe and thus wake up the main program.

Ah, plumbing.

Ian.

#125 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 13/13] xen: pv domain builder.

In reply to Gerd Hoffmann

Gerd Hoffmann writes ("Re: [Xen-devel] Re: [Qemu-devel] [PATCH 13/13] xen: pv domain builder."):

Quoted 4 lines

02 -> 04 Make sense if you want to *test* the patches without merging
with upstream qemu before. For *merging* the patches I'd suggest to merge from upstream qemu instead, then wait for me rebasing the patchset (and dropping these patches).

Yes.

Quoted 4 lines
05 -> 06  backend core.
07        switches the console to the new backend core.
08        xenfb.c -> xen_framebuffer.c rename.
09        switch framebuffer to new backend core.

Thanks for the explanation.

Quoted 4 lines

05 + 06 alone are not useful as nobody uses the new backend core then. Merging 07 too gives at least one user. 08+09 going in gives a second user. They are a nice cleanup and certainly make sense for qemu-xen-unstable.

That looks like I'll want to take 05-07 and 09. As previously discussed, I don't intend to take 08, at least at this stage, and I would very strongly prefer that 08 didn't go upstream.

Ian.

#101 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support

In reply to Gerd Hoffmann

Gerd Hoffmann writes ("Re: [Xen-devel] Re: [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support"):

Quoted 10 lines

Ok. I think we have three cases then:

(1) xen emulation using xenner (default, with or without kvm).
(2) running on xen, with xend creating the domain, and
(3) running on xen, with qemu creating the domain.

For (2) and (3) we need command line switches to enable these modes. Specifying a domain ID makes sense in all three cases though. So I'd keep the -xen-domid switch, like this:

Quoted 5 lines
  -xen-domid <nr>    specify xen domain id.
  -xen-attach        attach to specified domain (created by xend).
  -xen-create        create the domain directly.

Comments?

That sounds reasonable. Can we please make sure that the usage message for -xen-create and -xen-attach makes it clear that a user should not supply these options on a Xen system using the Xen management toolstack ? (Which I think includes a system using xm and also a system using libvirt, although perhaps Daniel Berrange will correct me.)

Ian.

#102 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support

Quoted 15 lines · Ian Jackson

Gerd Hoffmann writes ("Re: [Xen-devel] Re: [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support"):

Quoted 14 lines

Ok. I think we have three cases then:

(1) xen emulation using xenner (default, with or without kvm).
(2) running on xen, with xend creating the domain, and
(3) running on xen, with qemu creating the domain.

For (2) and (3) we need command line switches to enable these modes. Specifying a domain ID makes sense in all three cases though. So I'd keep the -xen-domid switch, like this:

  -xen-domid <nr>    specify xen domain id.
  -xen-attach        attach to specified domain (created by xend).
  -xen-create        create the domain directly.
Quoted 8 lines
Quoted 1 line

Comments?

That sounds reasonable. Can we please make sure that the usage message for -xen-create and -xen-attach makes it clear that a user should not supply these options on a Xen system using the Xen management toolstack ? (Which I think includes a system using xm and also a system using libvirt, although perhaps Daniel Berrange will correct me.)

There's no requirement from libvirt itself - just whatever infrastructure libvirt is using. So just a message about XenD/xm would be sufficient.

Regards,
Daniel

Signature · 4 lines
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
#103 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support

Daniel P. Berrange writes ("Re: [Xen-devel] Re: [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support"):

Quoted 2 lines

There's no requirement from libvirt itself - just whatever infrastructure libvirt is using. So just a message about XenD/xm would be sufficient.

Right, but I just wanted to avoid the situation where a naive user sees not for xm/xend systems' and thinks that's not me because I'm using libvirt'.

Ian.

#104 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support

Quoted 7 lines · Ian Jackson

Daniel P. Berrange writes ("Re: [Xen-devel] Re: [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support"):

Quoted 2 lines

There's no requirement from libvirt itself - just whatever infrastructure libvirt is using. So just a message about XenD/xm would be sufficient.

Right, but I just wanted to avoid the situation where a naive user sees not for xm/xend systems' and thinks that's not me because I'm using libvirt'.

They could be right in that thinking though - if using libvirt's QEMU backend, instead of XenD backend, then it'd be fine to launch VMs manually. Only the presence of XenD places constraints on usage.

Regards,
Daniel

Signature · 4 lines
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
#105 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support

Quoted 11 lines · Daniel P. Berrange
Quoted 6 lines · Ian Jackson

Daniel P. Berrange writes ("Re: [Xen-devel] Re: [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support"):

Quoted 2 lines

There's no requirement from libvirt itself - just whatever infrastructure libvirt is using. So just a message about XenD/xm would be sufficient.

Right, but I just wanted to avoid the situation where a naive user sees not for xm/xend systems' and thinks that's not me because I'm using libvirt'.

They could be right in that thinking though - if using libvirt's QEMU backend, instead of XenD backend, then it'd be fine to launch VMs manually. Only the presence of XenD places constraints on usage.

What constrains btw?

I'd expect with libvirt managing domains via qemu -xen-create and xend managing domains via -xen-attach basically run into the same class of problems if the user starts booting domains manually.

The most obvious issue would be is that domain IDs are in use by the user-started domains which the management stack thinks are unused and thus might be allocated for new domains. Likewise, both management stacks will find domains in xenstore they don't know anything about.

So I don't see a fundamental difference between libvirt and xend here.

cheers,
Gerd

#106 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support

Quoted 9 lines · Gerd Hoffmann
Quoted 8 lines · Daniel P. Berrange
Quoted 6 lines · Ian Jackson

Daniel P. Berrange writes ("Re: [Xen-devel] Re: [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support"):

Quoted 2 lines

There's no requirement from libvirt itself - just whatever infrastructure libvirt is using. So just a message about XenD/xm would be sufficient.

Right, but I just wanted to avoid the situation where a naive user sees not for xm/xend systems' and thinks that's not me because I'm using libvirt'.

Quoted 5 lines
Quoted 3 lines

They could be right in that thinking though - if using libvirt's QEMU backend, instead of XenD backend, then it'd be fine to launch VMs manually. Only the presence of XenD places constraints on usage.

What constrains btw?

If you start an Xen guest directly with QEMU, that'll be seen by XenD and bad things will start to happen. At best, XenD will tear down your manually created domain if it sees it before you write enough info into xenstore.

Quoted 10 lines

I'd expect with libvirt managing domains via qemu -xen-create and xend managing domains via -xen-attach basically run into the same class of problems if the user starts booting domains manually.

The most obvious issue would be is that domain IDs are in use by the user-started domains which the management stack thinks are unused and thus might be allocated for new domains. Likewise, both management stacks will find domains in xenstore they don't know anything about.

So I don't see a fundamental difference between libvirt and xend here.

In the context of the QEMU driver in libvirt, we don't currently care what the actual Xen hypervisor domain ID is - we make up our own domain ID space, and have no need for it to map to hypervisor IDs. Thus, externally created QEMU instances can use the HV too and won't clash. In fact libvirt won't even care if the VM is using the HV or not - it is just another QEMU process - all the xenstore/xen HV interaction is self contained inside QEMU.

In the context of the Xen driver in libvirt, we're going via XenD and don't create VMs manually.

Daniel

Signature · 4 lines
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
#107 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 05/13] xen: groundwork for xen support

Quoted 9 lines · Daniel P. Berrange
Quoted 4 lines
Quoted 3 lines

They could be right in that thinking though - if using libvirt's QEMU backend, instead of XenD backend, then it'd be fine to launch VMs manually. Only the presence of XenD places constraints on usage.

What constrains btw?

If you start an Xen guest directly with QEMU, that'll be seen by XenD and bad things will start to happen. At best, XenD will tear down your manually created domain if it sees it before you write enough info into xenstore.

Didn't saw that happen.

Quoted 9 lines
Quoted 9 lines

I'd expect with libvirt managing domains via qemu -xen-create and xend managing domains via -xen-attach basically run into the same class of problems if the user starts booting domains manually.

The most obvious issue would be is that domain IDs are in use by the user-started domains which the management stack thinks are unused and thus might be allocated for new domains. Likewise, both management stacks will find domains in xenstore they don't know anything about.

Quoted 5 lines
Quoted 1 line

So I don't see a fundamental difference between libvirt and xend here.

In the context of the QEMU driver in libvirt, we don't currently care what the actual Xen hypervisor domain ID is - we make up our own domain ID space, and have no need for it to map to hypervisor IDs.

They should be identical as that would be less confusing to the user. Having two ID spaces, both called domain ID, is a very bad idea IMHO.

Quoted 4 lines

In fact libvirt
won't even care if the VM is using the HV or not - it is just another QEMU process - all the xenstore/xen HV interaction is self contained inside QEMU.

Yep. But even in that case it would be good if libvirt and the guest os have the same idea about what the domain ID is.

cheers,
Gerd

#22 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals.

In reply to Ian Jackson
Quoted 9 lines · Ian Jackson

Jamie Lokier writes ("Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals."):

Quoted 2 lines

Leading to: why would (real) signals being used to collect AIO events anyway, if you don't have signalfd()? If you've got a helper thread,

If you use aio, glibc has a tendency to emulate it with thread(s). The helper thread I was referring to in my commit message is the glibc-created helper thread. glibc appears (in strace) to do IO in this thread and then raises the signal you asked for (SIGUSR2 in qemu's case).

That observation implies Anthony's helper thread will not always receive the SIGUSR2 signals - Glibc's thread may receive them instead.

So when the signalfd-emulation signal handler writes to the pipe, it might block Glibc's AIO thread. Is that ok, Anthony?

-- Jamie

#23 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals.

Jamie Lokier writes ("Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals."):

Quoted 9 lines
Quoted 5 lines · Ian Jackson

If you use aio, glibc has a tendency to emulate it with thread(s). The helper thread I was referring to in my commit message is the glibc-created helper thread. glibc appears (in strace) to do IO in this thread and then raises the signal you asked for (SIGUSR2 in qemu's case).

That observation implies Anthony's helper thread will not always receive the SIGUSR2 signals - Glibc's thread may receive them instead.

Yes. Err, I'm not sure what effect that will have in Anthony's patch but it probably wouldn't be good.

As I say I haven't managed to reproduce this other than in a full qemu-dm tree (from qemu-xen).

So it may be that it is because of something I did or something the qemu-xen code does - although it seems hard to imagine how it could break the signal mask in the helper thread given that that thread runs entirely glibc code, except when a signal is being delivered (and of course the signal mask is saved and restored for signal delivery).

Ian.

#24 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals.

Quoted 5 lines · Ian Jackson

Jamie Lokier writes ("Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals."):

Yes. Err, I'm not sure what effect that will have in Anthony's patch but it probably wouldn't be good.

Quoted 9 lines

As I say I haven't managed to reproduce this other than in a full qemu-dm tree (from qemu-xen).

So it may be that it is because of something I did or something the qemu-xen code does - although it seems hard to imagine how it could break the signal mask in the helper thread given that that thread runs entirely glibc code, except when a signal is being delivered (and of course the signal mask is saved and restored for signal delivery).

Perhaps the signal is being consumed in one of qemu-dm's other threads mistakenly?

What you're describing would seem like a serious bug. For a while, I was testing a version of QEMU/KVM that slept forever in select() and I never saw any instances of the signal not getting delivered.

Regards,

Anthony Liguori

Quoted 4 lines

Ian.

#25 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals.

In reply to Ian Jackson
Quoted 12 lines · Ian Jackson
Quoted 8 lines
Quoted 5 lines

If you use aio, glibc has a tendency to emulate it with thread(s). The helper thread I was referring to in my commit message is the glibc-created helper thread. glibc appears (in strace) to do IO in this thread and then raises the signal you asked for (SIGUSR2 in qemu's case).

That observation implies Anthony's helper thread will not always receive the SIGUSR2 signals - Glibc's thread may receive them instead.

Yes. Err, I'm not sure what effect that will have in Anthony's patch but it probably wouldn't be good.

Quoted 8 lines

As I say I haven't managed to reproduce this other than in a full qemu-dm tree (from qemu-xen).

So it may be that it is because of something I did or something the qemu-xen code does - although it seems hard to imagine how it could break the signal mask in the helper thread given that that thread runs entirely glibc code, except when a signal is being delivered (and of course the signal mask is saved and restored for signal delivery).

It's not your fault.

A quick read of Glibc 2.3.1 source says its AIO code does not change the signal mask when it creates an AIO handling thread.

(This might be a Glibc bug - threads you don't know about shouldn't be receiving your signals, should they?)

That means if it wasn't masked when you issued the first AIO request, it won't be masked in that thread.

It's quite annoying that POSIX threads doesn't provide any way to say "mask this signal in all other threads", which you often want to do from a library.

-- Jamie

#26 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals.

Jamie Lokier writes ("Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals."):

Quoted 2 lines

A quick read of Glibc 2.3.1 source says its AIO code does not change the signal mask when it creates an AIO handling thread.

Thanks for investigating that.

Quoted 2 lines

(This might be a Glibc bug - threads you don't know about shouldn't be receiving your signals, should they?)

Yes, it's a bug. (I wonder why my test program didn't expose it.)

Quoted 2 lines

That means if it wasn't masked when you issued the first AIO request, it won't be masked in that thread.

In practice since we use aio this probably means we can't rely on signal blocking except for signals which qemu keeps blocked `nearly all' the time. So pipe-to-self in the signal handler is the way to go.

Quoted 3 lines

It's quite annoying that POSIX threads doesn't provide any way to say "mask this signal in all other threads", which you often want to do from a library.

That too.

Ian.

#27 lore raw

Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals.

Quoted 16 lines · Ian Jackson

Jamie Lokier writes ("Re: [Xen-devel] Re: [Qemu-devel] [PATCH 01/13] Handle terminating signals."):

Quoted 3 lines

A quick read of Glibc 2.3.1 source says its AIO code does not change the signal mask when it creates an AIO handling thread.

Thanks for investigating that.

Quoted 3 lines

(This might be a Glibc bug - threads you don't know about shouldn't be receiving your signals, should they?)

Yes, it's a bug. (I wonder why my test program didn't expose it.)

Quoted 9 lines
Quoted 3 lines

That means if it wasn't masked when you issued the first AIO request, it won't be masked in that thread.

In practice since we use aio this probably means we can't rely on signal blocking except for signals which qemu keeps blocked `nearly all' the time. So pipe-to-self in the signal handler is the way to go.

In my signalfd patch, we block SIGUSR2 all the time so it shouldn't be affected by this "bug". We use sigwait or signalfd to receive the signal.

Regards,

Anthony Liguori