* [PATCH 0 of 9] Call hotplug scripts from libxl
@ 2011-09-30 12:43 Roger Pau Monne
2011-09-30 12:43 ` [PATCH 1 of 9] xenbackendd: fix incorrect usage of pidfile Roger Pau Monne
` (9 more replies)
0 siblings, 10 replies; 33+ messages in thread
From: Roger Pau Monne @ 2011-09-30 12:43 UTC (permalink / raw)
To: xen-devel
This patch adds support for NetBSD to call hotplugs scripts directly from libxl, instead of relying on xenbackendd. Also some patches contain general bug fixes that apply to both NetBSD and Linux. Currently Linux hotplug script call functions are empty, so Linux continues to use udev rules to call hotplug scripts.
If possible, all this changes should be backported to xen-4.1 also.
Regards, Roger.
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH 1 of 9] xenbackendd: fix incorrect usage of pidfile
2011-09-30 12:43 [PATCH 0 of 9] Call hotplug scripts from libxl Roger Pau Monne
@ 2011-09-30 12:43 ` Roger Pau Monne
2011-09-30 12:52 ` Christoph Egger
2011-09-30 12:43 ` [PATCH 2 of 9] xenbackendd: pass type of block device to hotplug script Roger Pau Monne
` (8 subsequent siblings)
9 siblings, 1 reply; 33+ messages in thread
From: Roger Pau Monne @ 2011-09-30 12:43 UTC (permalink / raw)
To: xen-devel
# HG changeset patch
# User Roger Pau Monne <roger.pau@entel.upc.edu>
# Date 1317300282 -7200
# Node ID 47005b3da245e2be052b614c02ed212d3d2cecbd
# Parent a422e2a4451e16dc791b293f41966b842fa4781d
xenbackendd: fix incorrect usage of pidfile
Fix xenbackendd ignoring the pidfile passed through the command line.
Signed-off-by: Roger Pau Monne <roger.pau@entel.upc.edu>
diff -r a422e2a4451e -r 47005b3da245 tools/xenbackendd/xenbackendd.c
--- a/tools/xenbackendd/xenbackendd.c Sun Sep 18 00:26:52 2011 +0100
+++ b/tools/xenbackendd/xenbackendd.c Thu Sep 29 14:44:42 2011 +0200
@@ -169,7 +169,7 @@ main(int argc, char * const argv[])
log_file = optarg;
break;
case 'p':
- pidfile = pidfile;
+ pidfile = optarg;
case 's':
vbd_script = optarg;
break;
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH 2 of 9] xenbackendd: pass type of block device to hotplug script
2011-09-30 12:43 [PATCH 0 of 9] Call hotplug scripts from libxl Roger Pau Monne
2011-09-30 12:43 ` [PATCH 1 of 9] xenbackendd: fix incorrect usage of pidfile Roger Pau Monne
@ 2011-09-30 12:43 ` Roger Pau Monne
2011-09-30 12:43 ` [PATCH 3 of 9] libxl: fix for libxl not waiting for devices to disconnect Roger Pau Monne
` (7 subsequent siblings)
9 siblings, 0 replies; 33+ messages in thread
From: Roger Pau Monne @ 2011-09-30 12:43 UTC (permalink / raw)
To: xen-devel
# HG changeset patch
# User Roger Pau Monne <roger.pau@entel.upc.edu>
# Date 1317386335 -7200
# Node ID d10abc15d963b00658405be71981f5726e24c0aa
# Parent 47005b3da245e2be052b614c02ed212d3d2cecbd
xenbackendd: pass type of block device to hotplug script
Pass the type of block device to attach to the block script instead of reading it from xenstore, since new Xen versions don't make a difference between a block device or an image.
Signed-off-by: Roger Pau Monne <roger.pau@entel.upc.edu>
diff -r 47005b3da245 -r d10abc15d963 tools/hotplug/NetBSD/block
--- a/tools/hotplug/NetBSD/block Thu Sep 29 14:44:42 2011 +0200
+++ b/tools/hotplug/NetBSD/block Fri Sep 30 14:38:55 2011 +0200
@@ -19,7 +19,7 @@ error() {
xpath=$1
xstatus=$2
-xtype=$(xenstore-read "$xpath/type")
+xtype=$3
xparams=$(xenstore-read "$xpath/params")
case $xstatus in
diff -r 47005b3da245 -r d10abc15d963 tools/xenbackendd/xenbackendd.c
--- a/tools/xenbackendd/xenbackendd.c Thu Sep 29 14:44:42 2011 +0200
+++ b/tools/xenbackendd/xenbackendd.c Fri Sep 30 14:38:55 2011 +0200
@@ -89,15 +89,15 @@ dodebug(const char *fmt, ...)
}
static void
-doexec(const char *cmd, const char *arg1, const char *arg2)
+doexec(const char *cmd, const char *arg1, const char *arg2, const char *arg3)
{
- dodebug("exec %s %s %s", cmd, arg1, arg2);
+ dodebug("exec %s %s %s %s", cmd, arg1, arg2, arg3);
switch(vfork()) {
case -1:
dolog(LOG_ERR, "can't vfork: %s", strerror(errno));
break;
case 0:
- execl(cmd, cmd, arg1, arg2, NULL);
+ execl(cmd, cmd, arg1, arg2, arg3, NULL);
dolog(LOG_ERR, "can't exec %s: %s", cmd, strerror(errno));
exit(EXIT_FAILURE);
/* NOTREACHED */
@@ -145,11 +145,14 @@ xen_setup(void)
int
main(int argc, char * const argv[])
{
+ struct stat stab;
char **vec;
unsigned int num;
char *s;
int state;
char *sstate;
+ char *stype;
+ char *params;
char *p;
char buf[80];
int type;
@@ -297,11 +300,38 @@ main(int argc, char * const argv[])
strerror(errno));
goto next2;
}
- doexec(s, vec[XS_WATCH_PATH], sstate);
+ doexec(s, vec[XS_WATCH_PATH], sstate, NULL);
break;
case DEVTYPE_VBD:
- doexec(vbd_script, vec[XS_WATCH_PATH], sstate);
+ /* check if given file is a block device or a raw image */
+ snprintf(buf, sizeof(buf), "%s/params", vec[XS_WATCH_PATH]);
+ params = xs_read(xs, XBT_NULL, buf, 0);
+ if(params == NULL) {
+ dolog(LOG_ERR,
+ "Failed to read %s (%s)", buf, strerror(errno));
+ goto next2;
+ }
+ if (stat(params, &stab) < 0) {
+ dolog(LOG_ERR,
+ "Failed to get info about %s (%s)", params,
+ strerror(errno));
+ goto next3;
+ }
+ stype = NULL;
+ if (S_ISBLK(stab.st_mode))
+ stype = "phy";
+ if (S_ISREG(stab.st_mode))
+ stype = "file";
+ if (stype == NULL) {
+ dolog(LOG_ERR,
+ "Failed to attach %s (not a block device or raw image)",
+ params, strerror(errno));
+ goto next3;
+ }
+ doexec(vbd_script, vec[XS_WATCH_PATH], sstate, stype);
+next3:
+ free(params);
break;
default:
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH 3 of 9] libxl: fix for libxl not waiting for devices to disconnect
2011-09-30 12:43 [PATCH 0 of 9] Call hotplug scripts from libxl Roger Pau Monne
2011-09-30 12:43 ` [PATCH 1 of 9] xenbackendd: fix incorrect usage of pidfile Roger Pau Monne
2011-09-30 12:43 ` [PATCH 2 of 9] xenbackendd: pass type of block device to hotplug script Roger Pau Monne
@ 2011-09-30 12:43 ` Roger Pau Monne
2011-09-30 12:43 ` [PATCH 4 of 9] libxl: create pci backend only when there are pci devices Roger Pau Monne
` (6 subsequent siblings)
9 siblings, 0 replies; 33+ messages in thread
From: Roger Pau Monne @ 2011-09-30 12:43 UTC (permalink / raw)
To: xen-devel
# HG changeset patch
# User Roger Pau Monne <roger.pau@entel.upc.edu>
# Date 1317386335 -7200
# Node ID 31b3caad18ac904a242c5bd1ea2bb0e574cd0453
# Parent d10abc15d963b00658405be71981f5726e24c0aa
libxl: fix for libxl not waiting for devices to disconnect
libxl was ignoring the timeout and the number of devices to wait before destroying them.
Signed-off-by: Roger Pau Monne <roger.pau@entel.upc.edu>
diff -r d10abc15d963 -r 31b3caad18ac tools/libxl/libxl_device.c
--- a/tools/libxl/libxl_device.c Fri Sep 30 14:38:55 2011 +0200
+++ b/tools/libxl/libxl_device.c Fri Sep 30 14:38:55 2011 +0200
@@ -422,6 +422,9 @@ static int wait_for_dev_destroy(libxl__g
}
free(l1);
}
+ } else {
+ /* timeout reached */
+ rc = 0;
}
return rc;
}
@@ -482,7 +485,7 @@ int libxl__devices_destroy(libxl__gc *gc
tv.tv_usec = 0;
while (n_watches > 0) {
if (wait_for_dev_destroy(gc, &tv)) {
- break;
+ continue;
} else {
n_watches--;
}
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH 4 of 9] libxl: create pci backend only when there are pci devices
2011-09-30 12:43 [PATCH 0 of 9] Call hotplug scripts from libxl Roger Pau Monne
` (2 preceding siblings ...)
2011-09-30 12:43 ` [PATCH 3 of 9] libxl: fix for libxl not waiting for devices to disconnect Roger Pau Monne
@ 2011-09-30 12:43 ` Roger Pau Monne
2011-10-06 16:26 ` Ian Jackson
2011-10-18 13:16 ` Ian Campbell
2011-09-30 12:43 ` [PATCH 5 of 9] libxl: only use interactive PyGrub mode when a console is attached Roger Pau Monne
` (5 subsequent siblings)
9 siblings, 2 replies; 33+ messages in thread
From: Roger Pau Monne @ 2011-09-30 12:43 UTC (permalink / raw)
To: xen-devel
# HG changeset patch
# User Roger Pau Monne <roger.pau@entel.upc.edu>
# Date 1317386335 -7200
# Node ID 156626fef95b36184ad44dfcb049bae2545435f0
# Parent 31b3caad18ac904a242c5bd1ea2bb0e574cd0453
libxl: create pci backend only when there are pci devices.
Creating empty pci entries made Linux DomUs under NetBSD Dom0 wait a very long time for devices to initialize during kernel boot.
Signed-off-by: Roger Pau Monne <roger.pau@entel.upc.edu>
diff -r 31b3caad18ac -r 156626fef95b tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c Fri Sep 30 14:38:55 2011 +0200
+++ b/tools/libxl/libxl_create.c Fri Sep 30 14:38:55 2011 +0200
@@ -584,12 +584,14 @@ static int do_domain_create(libxl__gc *g
for (i = 0; i < d_config->num_pcidevs; i++)
libxl__device_pci_add(gc, domid, &d_config->pcidevs[i], 1);
- ret = libxl__create_pci_backend(gc, domid, d_config->pcidevs,
- d_config->num_pcidevs);
- if (ret < 0) {
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
- "libxl_create_pci_backend failed: %d", ret);
- goto error_out;
+ if (d_config->num_pcidevs > 0) {
+ ret = libxl__create_pci_backend(gc, domid, d_config->pcidevs,
+ d_config->num_pcidevs);
+ if (ret < 0) {
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
+ "libxl_create_pci_backend failed: %d", ret);
+ goto error_out;
+ }
}
if (d_config->c_info.type == LIBXL_DOMAIN_TYPE_PV &&
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH 5 of 9] libxl: only use interactive PyGrub mode when a console is attached
2011-09-30 12:43 [PATCH 0 of 9] Call hotplug scripts from libxl Roger Pau Monne
` (3 preceding siblings ...)
2011-09-30 12:43 ` [PATCH 4 of 9] libxl: create pci backend only when there are pci devices Roger Pau Monne
@ 2011-09-30 12:43 ` Roger Pau Monne
2011-10-06 16:28 ` Ian Jackson
2011-09-30 12:43 ` [PATCH 6 of 9] libxl: add support for image files for NetBSD Roger Pau Monne
` (4 subsequent siblings)
9 siblings, 1 reply; 33+ messages in thread
From: Roger Pau Monne @ 2011-09-30 12:43 UTC (permalink / raw)
To: xen-devel
# HG changeset patch
# User Roger Pau Monne <roger.pau@entel.upc.edu>
# Date 1317386335 -7200
# Node ID 84a27a9f39f29194a7344e842b2055f592a42250
# Parent 156626fef95b36184ad44dfcb049bae2545435f0
libxl: only use interactive PyGrub mode when a console is attached
Sometimes PyGrub freezed when trying to create a domain without the console attached (without "-c"). This patch adds the "-q" option to PyGrub when "-c" is not specified at creation time. PyGrub freezed trying to set terminal attributes (like reset_prog_mode or nocbreak).
Signed-off-by: Roger Pau Monne <roger.pau@entel.upc.edu>
diff -r 156626fef95b -r 84a27a9f39f2 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h Fri Sep 30 14:38:55 2011 +0200
+++ b/tools/libxl/libxl.h Fri Sep 30 14:38:55 2011 +0200
@@ -287,7 +287,8 @@ int libxl_get_max_cpus(libxl_ctx *ctx);
int libxl_run_bootloader(libxl_ctx *ctx,
libxl_domain_build_info *info,
libxl_device_disk *disk,
- uint32_t domid);
+ uint32_t domid,
+ libxl_console_ready cb);
/* 0 means ERROR_ENOMEM, which we have logged */
diff -r 156626fef95b -r 84a27a9f39f2 tools/libxl/libxl_bootloader.c
--- a/tools/libxl/libxl_bootloader.c Fri Sep 30 14:38:55 2011 +0200
+++ b/tools/libxl/libxl_bootloader.c Fri Sep 30 14:38:55 2011 +0200
@@ -33,7 +33,8 @@
static char **make_bootloader_args(libxl__gc *gc,
libxl_domain_build_info *info,
uint32_t domid,
- const char *fifo, char *disk)
+ const char *fifo, char *disk,
+ libxl_console_ready cb)
{
flexarray_t *args;
int nr = 0;
@@ -55,6 +56,8 @@ static char **make_bootloader_args(libxl
flexarray_set(args, nr++, libxl__sprintf(gc, "--output=%s", fifo));
flexarray_set(args, nr++, "--output-format=simple0");
flexarray_set(args, nr++, libxl__sprintf(gc, "--output-directory=%s", "/var/run/libxl/"));
+ if (!cb)
+ flexarray_set(args, nr++, "-q");
if (info->u.pv.bootloader_args) {
char *saveptr;
@@ -300,7 +303,8 @@ static void parse_bootloader_result(libx
int libxl_run_bootloader(libxl_ctx *ctx,
libxl_domain_build_info *info,
libxl_device_disk *disk,
- uint32_t domid)
+ uint32_t domid,
+ libxl_console_ready cb)
{
libxl__gc gc = LIBXL_INIT_GC(ctx);
int ret, rc = 0;
@@ -362,7 +366,7 @@ int libxl_run_bootloader(libxl_ctx *ctx,
goto out_close;
}
- args = make_bootloader_args(&gc, info, domid, fifo, diskpath);
+ args = make_bootloader_args(&gc, info, domid, fifo, diskpath, cb);
if (args == NULL) {
rc = ERROR_NOMEM;
goto out_close;
diff -r 156626fef95b -r 84a27a9f39f2 tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c Fri Sep 30 14:38:55 2011 +0200
+++ b/tools/libxl/libxl_create.c Fri Sep 30 14:38:55 2011 +0200
@@ -461,7 +461,7 @@ static int do_domain_create(libxl__gc *g
}
if ( restore_fd < 0 ) {
- ret = libxl_run_bootloader(ctx, &d_config->b_info, d_config->num_disks > 0 ? &d_config->disks[0] : NULL, domid);
+ ret = libxl_run_bootloader(ctx, &d_config->b_info, d_config->num_disks > 0 ? &d_config->disks[0] : NULL, domid, cb);
if (ret) {
LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
"failed to run bootloader: %d", ret);
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH 6 of 9] libxl: add support for image files for NetBSD
2011-09-30 12:43 [PATCH 0 of 9] Call hotplug scripts from libxl Roger Pau Monne
` (4 preceding siblings ...)
2011-09-30 12:43 ` [PATCH 5 of 9] libxl: only use interactive PyGrub mode when a console is attached Roger Pau Monne
@ 2011-09-30 12:43 ` Roger Pau Monne
2011-09-30 12:43 ` [PATCH 7 of 9] libxl: execute hotplug scripts directly from libxl Roger Pau Monne
` (3 subsequent siblings)
9 siblings, 0 replies; 33+ messages in thread
From: Roger Pau Monne @ 2011-09-30 12:43 UTC (permalink / raw)
To: xen-devel
# HG changeset patch
# User Roger Pau Monne <roger.pau@entel.upc.edu>
# Date 1317386335 -7200
# Node ID ce4b969a938afa40edb6858629b6eb2905a29f04
# Parent 84a27a9f39f29194a7344e842b2055f592a42250
libxl: add support for image files for NetBSD
Created a helper function to detect if the OS is capable of using image files as phy backends. Create two OS specific files, and changed the Makefile to choose the correct one at compile time.
Signed-off-by: Roger Pau Monne <roger.pau@entel.upc.edu>
diff -r 84a27a9f39f2 -r ce4b969a938a tools/libxl/Makefile
--- a/tools/libxl/Makefile Fri Sep 30 14:38:55 2011 +0200
+++ b/tools/libxl/Makefile Fri Sep 30 14:38:55 2011 +0200
@@ -31,6 +31,8 @@ LIBXL_OBJS-y += libxl_noblktap2.o
endif
LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o
LIBXL_OBJS-$(CONFIG_IA64) += libxl_nocpuid.o
+LIBXL_OBJS-$(CONFIG_NetBSD) += libxl_phybackend.o
+LIBXL_OBJS-$(CONFIG_Linux) += libxl_nophybackend.o
LIBXL_OBJS = flexarray.o libxl.o libxl_create.o libxl_dm.o libxl_pci.o \
libxl_dom.o libxl_exec.o libxl_xshelp.o libxl_device.o \
diff -r 84a27a9f39f2 -r ce4b969a938a tools/libxl/libxl_device.c
--- a/tools/libxl/libxl_device.c Fri Sep 30 14:38:55 2011 +0200
+++ b/tools/libxl/libxl_device.c Fri Sep 30 14:38:55 2011 +0200
@@ -136,15 +136,14 @@ static int disk_try_backend(disk_try_bac
a->disk->format == LIBXL_DISK_FORMAT_EMPTY)) {
goto bad_format;
}
- if (a->disk->format != LIBXL_DISK_FORMAT_EMPTY &&
- !S_ISBLK(a->stab.st_mode)) {
- LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Disk vdev=%s, backend phy"
- " unsuitable as phys path not a block device",
- a->disk->vdev);
- return 0;
- }
- return backend;
+ if (try_phy_backend(a->stab.st_mode))
+ return backend;
+
+ LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Disk vdev=%s, backend phy"
+ " unsuitable as phys path not a block device",
+ a->disk->vdev);
+ return 0;
case LIBXL_DISK_BACKEND_TAP:
if (!libxl__blktap_enabled(a->gc)) {
diff -r 84a27a9f39f2 -r ce4b969a938a tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h Fri Sep 30 14:38:55 2011 +0200
+++ b/tools/libxl/libxl_internal.h Fri Sep 30 14:38:55 2011 +0200
@@ -227,6 +227,9 @@ _hidden int libxl__device_destroy(libxl_
_hidden int libxl__devices_destroy(libxl__gc *gc, uint32_t domid, int force);
_hidden int libxl__wait_for_backend(libxl__gc *gc, char *be_path, char *state);
+/* OS dependant helper function */
+_hidden int try_phy_backend(mode_t st_mode);
+
/* from libxl_pci */
_hidden int libxl__device_pci_add(libxl__gc *gc, uint32_t domid, libxl_device_pci *pcidev, int starting);
diff -r 84a27a9f39f2 -r ce4b969a938a tools/libxl/libxl_nophybackend.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/libxl/libxl_nophybackend.c Fri Sep 30 14:38:55 2011 +0200
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2011
+ * Author Roger Pau Monne <roger.pau@entel.upc.edu>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ */
+
+#include <sys/stat.h>
+
+#include "libxl_internal.h"
+
+int try_phy_backend(mode_t st_mode)
+{
+ if (!S_ISBLK(st_mode)) {
+ return 0;
+ }
+
+ return 1;
+}
diff -r 84a27a9f39f2 -r ce4b969a938a tools/libxl/libxl_phybackend.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/libxl/libxl_phybackend.c Fri Sep 30 14:38:55 2011 +0200
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2011
+ * Author Roger Pau Monne <roger.pau@entel.upc.edu>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ */
+
+#include <sys/stat.h>
+
+#include "libxl_internal.h"
+
+int try_phy_backend(mode_t st_mode)
+{
+ if (S_ISREG(st_mode) || S_ISBLK(st_mode))
+ return 1;
+
+ return 0;
+}
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH 7 of 9] libxl: execute hotplug scripts directly from libxl
2011-09-30 12:43 [PATCH 0 of 9] Call hotplug scripts from libxl Roger Pau Monne
` (5 preceding siblings ...)
2011-09-30 12:43 ` [PATCH 6 of 9] libxl: add support for image files for NetBSD Roger Pau Monne
@ 2011-09-30 12:43 ` Roger Pau Monne
2011-09-30 12:43 ` [PATCH 8 of 9] hotplug NetBSD: detach devices when state is 5 or 6 Roger Pau Monne
` (2 subsequent siblings)
9 siblings, 0 replies; 33+ messages in thread
From: Roger Pau Monne @ 2011-09-30 12:43 UTC (permalink / raw)
To: xen-devel
# HG changeset patch
# User Roger Pau Monne <roger.pau@entel.upc.edu>
# Date 1317386335 -7200
# Node ID a767b85f9c3410c4cbe5cca7b12bd0900415040e
# Parent ce4b969a938afa40edb6858629b6eb2905a29f04
libxl: execute hotplug scripts directly from libxl.
Added the necessary handlers to execute hotplug scripts when necessary from libxl. Split NetBSD from Linux hotplug calls into two separate files, because parameters for hotplug scripts are different. Linux has empty functions, since the calling of hotplug scripts is still done using udev.
Signed-off-by: Roger Pau Monne <roger.pau@entel.upc.edu>
diff -r ce4b969a938a -r a767b85f9c34 tools/libxl/Makefile
--- a/tools/libxl/Makefile Fri Sep 30 14:38:55 2011 +0200
+++ b/tools/libxl/Makefile Fri Sep 30 14:38:55 2011 +0200
@@ -33,10 +33,13 @@ LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.
LIBXL_OBJS-$(CONFIG_IA64) += libxl_nocpuid.o
LIBXL_OBJS-$(CONFIG_NetBSD) += libxl_phybackend.o
LIBXL_OBJS-$(CONFIG_Linux) += libxl_nophybackend.o
+LIBXL_OBJS-$(CONFIG_NetBSD) += hotplug_netbsd.o
+LIBXL_OBJS-$(CONFIG_Linux) += hotplug_linux.o
LIBXL_OBJS = flexarray.o libxl.o libxl_create.o libxl_dm.o libxl_pci.o \
libxl_dom.o libxl_exec.o libxl_xshelp.o libxl_device.o \
- libxl_internal.o libxl_utils.o libxl_uuid.o $(LIBXL_OBJS-y)
+ libxl_internal.o libxl_utils.o libxl_uuid.o libxl_hotplug.o \
+ $(LIBXL_OBJS-y)
LIBXL_OBJS += _libxl_types.o libxl_flask.o
$(LIBXL_OBJS): CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest) $(CFLAGS_libxenstore) $(CFLAGS_libblktapctl)
diff -r ce4b969a938a -r a767b85f9c34 tools/libxl/hotplug_linux.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/libxl/hotplug_linux.c Fri Sep 30 14:38:55 2011 +0200
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2011
+ * Author Roger Pau Monne <roger.pau@entel.upc.edu>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ */
+
+#include "libxl_internal.h"
+
+int libxl_disk_hotplug(libxl__gc *gc, char *be_path)
+{
+ return 0;
+}
+
+int libxl_nic_hotplug_connect(libxl__gc *gc, char *be_path)
+{
+ return 0;
+}
diff -r ce4b969a938a -r a767b85f9c34 tools/libxl/hotplug_netbsd.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/libxl/hotplug_netbsd.c Fri Sep 30 14:38:55 2011 +0200
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2011
+ * Author Roger Pau Monne <roger.pau@entel.upc.edu>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ */
+
+#include <sys/stat.h>
+
+#include "libxl_internal.h"
+
+int libxl_disk_hotplug(libxl__gc *gc, char *be_path)
+{
+ libxl_ctx *ctx = libxl__gc_owner(gc);
+ struct stat stab;
+ char *stype, *sstate, *script, *params;
+ char **args;
+ int nr = 0;
+ flexarray_t *f_args;
+
+ script = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/%s", be_path, "script"));
+ if (!script) {
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Unable to read script from %s",
+ be_path);
+ return -1;
+ }
+
+ params = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/%s", be_path, "params"));
+ if (!params)
+ return -1;
+
+ sstate = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/%s", be_path, "state"));
+ if (!sstate) {
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Unable to read state from %s",
+ be_path);
+ return -1;
+ }
+
+ if (stat(params, &stab) < 0) {
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Failed to get stat info\n");
+ return -1;
+ }
+ if (S_ISBLK(stab.st_mode))
+ stype = "phy";
+ if (S_ISREG(stab.st_mode))
+ stype = "file";
+ if (stype == NULL) {
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Not block or regular file");
+ return -1;
+ }
+
+ f_args = flexarray_make(5, 1);
+ if (!f_args)
+ return -1;
+
+ flexarray_set(f_args, nr++, script);
+ flexarray_set(f_args, nr++, be_path);
+ flexarray_set(f_args, nr++, sstate);
+ flexarray_set(f_args, nr++, stype);
+ flexarray_set(f_args, nr++, NULL);
+
+ args = (char **) flexarray_contents(f_args);
+
+ if (libxl_exec(gc, args) < 0) {
+ free(args);
+ return -1;
+ }
+
+ free(args);
+ return 0;
+}
+
+int libxl_nic_hotplug(libxl__gc *gc, char *be_path)
+{
+ libxl_ctx *ctx = libxl__gc_owner(gc);
+ char *sstate, *script;
+ char **args;
+ int nr = 0;
+ flexarray_t *f_args;
+
+ script = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/%s", be_path, "script"));
+ if (!script) {
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Unable to read script from %s",
+ be_path);
+ return -1;
+ }
+
+ sstate = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/%s", be_path, "state"));
+ if (!sstate) {
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Unable to read state from %s",
+ be_path);
+ return -1;
+ }
+
+ f_args = flexarray_make(4, 1);
+ if (!f_args)
+ return -1;
+
+ flexarray_set(f_args, nr++, script);
+ flexarray_set(f_args, nr++, be_path);
+ flexarray_set(f_args, nr++, sstate);
+ flexarray_set(f_args, nr++, NULL);
+
+ args = (char **) flexarray_contents(f_args);
+
+ if (libxl_exec(gc, args) < 0) {
+ free(args);
+ return -1;
+ }
+
+ free(args);
+ return 0;
+}
diff -r ce4b969a938a -r a767b85f9c34 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c Fri Sep 30 14:38:55 2011 +0200
+++ b/tools/libxl/libxl.c Fri Sep 30 14:38:55 2011 +0200
@@ -1009,6 +1009,11 @@ int libxl_device_disk_add(libxl_ctx *ctx
flexarray_append(back, libxl__device_disk_string_of_backend(disk->backend));
flexarray_append(back, "mode");
flexarray_append(back, disk->readwrite ? "w" : "r");
+ /* TODO: add Linux scripts, NetBSD only has block */
+ flexarray_append(back, "script");
+ flexarray_append(back, libxl__sprintf(&gc, "%s/%s",
+ libxl_xen_script_dir_path(),
+ "block"));
flexarray_append(front, "backend-id");
flexarray_append(front, libxl__sprintf(&gc, "%d", disk->backend_domid));
@@ -1023,6 +1028,14 @@ int libxl_device_disk_add(libxl_ctx *ctx
libxl__xs_kvs_of_flexarray(&gc, back, back->count),
libxl__xs_kvs_of_flexarray(&gc, front, front->count));
+ /* Call hotplug scripts to attach device */
+ if (libxl_disk_hotplug(&gc, libxl__device_backend_path(&gc, &device)) < 0) {
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "unable to execute hotplug script for disk: %s\n",
+ disk->pdev_path);
+ rc = -1;
+ goto out_free;
+ }
+
rc = 0;
out_free:
@@ -1252,6 +1265,15 @@ int libxl_device_nic_add(libxl_ctx *ctx,
libxl__xs_kvs_of_flexarray(&gc, front, front->count));
/* FIXME: wait for plug */
+
+ /* Call hotplug scripts to attach device */
+ if (libxl_nic_hotplug(&gc, libxl__device_backend_path(&gc, &device)) < 0) {
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "unable to execute hotplug script for nic: %s\n",
+ nic->ifname);
+ rc = -1;
+ goto out_free;
+ }
+
rc = 0;
out_free:
flexarray_free(back);
diff -r ce4b969a938a -r a767b85f9c34 tools/libxl/libxl_device.c
--- a/tools/libxl/libxl_device.c Fri Sep 30 14:38:55 2011 +0200
+++ b/tools/libxl/libxl_device.c Fri Sep 30 14:38:55 2011 +0200
@@ -59,6 +59,42 @@ char *libxl__device_backend_path(libxl__
device->domid, device->devid);
}
+static libxl__device_kinds libxl__device_identify(char *be_path)
+{
+ char strkind[16]; /* Longest is actually "console" */
+ int len = sizeof(string_of_kinds)/sizeof(char *);
+
+ /* /local/domain/<domid>/backend/<kind>/ */
+ if (sscanf(be_path, "/local/domain/%*d/backend/%16[^/]s", strkind) != 1)
+ return DEVICE_UNKNOWN;
+
+ for (int j = 1; j < len; j++) {
+ if (strncmp(strkind, string_of_kinds[j], 16) == 0)
+ return j;
+ }
+
+ return DEVICE_UNKNOWN;
+}
+
+static int libxl__device_hotplug(libxl__gc *gc, libxl__device_kinds device,
+ char *be_path)
+{
+ int rc = 0;
+
+ switch(device) {
+ case DEVICE_VIF:
+ rc = libxl_nic_hotplug(gc, be_path);
+ break;
+ case DEVICE_VBD:
+ rc = libxl_disk_hotplug(gc, be_path);
+ break;
+ default:
+ break;
+ }
+
+ return rc;
+}
+
int libxl__device_generic_add(libxl__gc *gc, libxl__device *device,
char **bents, char **fents)
{
@@ -366,11 +402,13 @@ int libxl__device_destroy(libxl__gc *gc,
xs_transaction_t t;
char *state_path = libxl__sprintf(gc, "%s/state", be_path);
char *state = libxl__xs_read(gc, XBT_NULL, state_path);
+ libxl__device_kinds device = libxl__device_identify(be_path);
int rc = 0;
if (!state)
goto out;
if (atoi(state) != 4) {
+ libxl__device_hotplug(gc, device, be_path);
xs_rm(ctx->xsh, XBT_NULL, be_path);
goto out;
}
@@ -391,6 +429,7 @@ retry_transaction:
xs_watch(ctx->xsh, state_path, be_path);
rc = 1;
} else {
+ libxl__device_hotplug(gc, device, be_path);
xs_rm(ctx->xsh, XBT_NULL, be_path);
}
out:
@@ -404,6 +443,7 @@ static int wait_for_dev_destroy(libxl__g
unsigned int n;
fd_set rfds;
char **l1 = NULL;
+ libxl__device_kinds device;
rc = 1;
nfds = xs_fileno(ctx->xsh) + 1;
@@ -415,6 +455,8 @@ static int wait_for_dev_destroy(libxl__g
char *state = libxl__xs_read(gc, XBT_NULL, l1[XS_WATCH_PATH]);
if (!state || atoi(state) == 6) {
xs_unwatch(ctx->xsh, l1[0], l1[1]);
+ device = libxl__device_identify(l1[XS_WATCH_PATH]);
+ libxl__device_hotplug(gc, device, l1[XS_WATCH_PATH]);
xs_rm(ctx->xsh, XBT_NULL, l1[XS_WATCH_TOKEN]);
LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Destroyed device backend at %s", l1[XS_WATCH_TOKEN]);
rc = 0;
diff -r ce4b969a938a -r a767b85f9c34 tools/libxl/libxl_hotplug.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/libxl/libxl_hotplug.c Fri Sep 30 14:38:55 2011 +0200
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2011
+ * Author Roger Pau Monne <roger.pau@entel.upc.edu>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ */
+
+#include <unistd.h>
+
+#include "libxl_internal.h"
+
+int libxl_exec(libxl__gc *gc, char **cmd)
+{
+ libxl_ctx *ctx = libxl__gc_owner(gc);
+
+ LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Executing: %s", cmd[0]);
+ switch(vfork()) {
+ case -1:
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Failed to vfork\n");
+ return -1;
+ case 0:
+ execv(cmd[0], cmd);
+ LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Failed to execute %s\n",
+ cmd[0]);
+ exit(EXIT_FAILURE);
+ break;
+ default:
+ wait(NULL);
+ break;
+ }
+ return 0;
+}
diff -r ce4b969a938a -r a767b85f9c34 tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h Fri Sep 30 14:38:55 2011 +0200
+++ b/tools/libxl/libxl_internal.h Fri Sep 30 14:38:55 2011 +0200
@@ -95,7 +95,8 @@ struct libxl__ctx {
};
typedef enum {
- DEVICE_VIF = 1,
+ DEVICE_UNKNOWN = 0,
+ DEVICE_VIF,
DEVICE_VBD,
DEVICE_QDISK,
DEVICE_PCI,
@@ -230,6 +231,11 @@ _hidden int libxl__wait_for_backend(libx
/* OS dependant helper function */
_hidden int try_phy_backend(mode_t st_mode);
+/* hotplug functions */
+_hidden int libxl_exec(libxl__gc *gc, char **cmd);
+_hidden int libxl_disk_hotplug(libxl__gc *gc, char *be_path);
+_hidden int libxl_nic_hotplug(libxl__gc *gc, char *be_path);
+
/* from libxl_pci */
_hidden int libxl__device_pci_add(libxl__gc *gc, uint32_t domid, libxl_device_pci *pcidev, int starting);
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH 8 of 9] hotplug NetBSD: detach devices when state is 5 or 6
2011-09-30 12:43 [PATCH 0 of 9] Call hotplug scripts from libxl Roger Pau Monne
` (6 preceding siblings ...)
2011-09-30 12:43 ` [PATCH 7 of 9] libxl: execute hotplug scripts directly from libxl Roger Pau Monne
@ 2011-09-30 12:43 ` Roger Pau Monne
2011-09-30 12:43 ` [PATCH 9 of 9] rc.d NetBSD: don't start xenbackendd by default, only when xend needs it Roger Pau Monne
2011-10-04 13:24 ` [PATCH 0 of 9] Call hotplug scripts from libxl Roger Pau Monné
9 siblings, 0 replies; 33+ messages in thread
From: Roger Pau Monne @ 2011-09-30 12:43 UTC (permalink / raw)
To: xen-devel
# HG changeset patch
# User Roger Pau Monne <roger.pau@entel.upc.edu>
# Date 1317386335 -7200
# Node ID 7e44ba113546e4c2db56ebf9b0b251dcd9a1948a
# Parent a767b85f9c3410c4cbe5cca7b12bd0900415040e
hotplug NetBSD: detach devices when state is 5 or 6
With the move of hotplug calls from xenbackendd to libxl, we can detach devices when the state is 5 or 6.
Signed-off-by: Roger Pau Monne <roger.pau@entel.upc.edu>
diff -r a767b85f9c34 -r 7e44ba113546 tools/hotplug/NetBSD/block
--- a/tools/hotplug/NetBSD/block Fri Sep 30 14:38:55 2011 +0200
+++ b/tools/hotplug/NetBSD/block Fri Sep 30 14:38:55 2011 +0200
@@ -23,7 +23,7 @@ xtype=$3
xparams=$(xenstore-read "$xpath/params")
case $xstatus in
-6)
+5|6)
# device removed
case $xtype in
file)
diff -r a767b85f9c34 -r 7e44ba113546 tools/hotplug/NetBSD/vif-bridge
--- a/tools/hotplug/NetBSD/vif-bridge Fri Sep 30 14:38:55 2011 +0200
+++ b/tools/hotplug/NetBSD/vif-bridge Fri Sep 30 14:38:55 2011 +0200
@@ -14,7 +14,7 @@ xpath=$1
xstatus=$2
case $xstatus in
-6)
+5|6)
# device removed
xenstore-rm $xpath
exit 0
diff -r a767b85f9c34 -r 7e44ba113546 tools/hotplug/NetBSD/vif-ip
--- a/tools/hotplug/NetBSD/vif-ip Fri Sep 30 14:38:55 2011 +0200
+++ b/tools/hotplug/NetBSD/vif-ip Fri Sep 30 14:38:55 2011 +0200
@@ -14,7 +14,7 @@ xpath=$1
xstatus=$2
case $xstatus in
-6)
+5|6)
# device removed
xenstore-rm $xpath
exit 0
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH 9 of 9] rc.d NetBSD: don't start xenbackendd by default, only when xend needs it
2011-09-30 12:43 [PATCH 0 of 9] Call hotplug scripts from libxl Roger Pau Monne
` (7 preceding siblings ...)
2011-09-30 12:43 ` [PATCH 8 of 9] hotplug NetBSD: detach devices when state is 5 or 6 Roger Pau Monne
@ 2011-09-30 12:43 ` Roger Pau Monne
2011-10-04 13:24 ` [PATCH 0 of 9] Call hotplug scripts from libxl Roger Pau Monné
9 siblings, 0 replies; 33+ messages in thread
From: Roger Pau Monne @ 2011-09-30 12:43 UTC (permalink / raw)
To: xen-devel
# HG changeset patch
# User Roger Pau Monne <roger.pau@entel.upc.edu>
# Date 1317386335 -7200
# Node ID 3009fd6e30ea90b5a55dc97fd953e0b5ab188276
# Parent 7e44ba113546e4c2db56ebf9b0b251dcd9a1948a
rc.d NetBSD: don't start xenbackendd by default, only when xend needs it.
With the move of hotplug scripts from xenbackendd to libxl xenbackendd is no longer needed by libxl, only start it when xend is started.
Signed-off-by: Roger Pau Monne <roger.pau@entel.upc.edu>
diff -r 7e44ba113546 -r 3009fd6e30ea tools/hotplug/NetBSD/rc.d/xenbackendd
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/hotplug/NetBSD/rc.d/xenbackendd Fri Sep 30 14:38:55 2011 +0200
@@ -0,0 +1,27 @@
+#!/bin/sh
+#
+# PROVIDE: xenbackendd
+# REQUIRE: xencommons
+
+. /etc/rc.subr
+
+DIR=$(dirname "$0")
+. "${DIR}/xen-hotplugpath.sh"
+
+LD_LIBRARY_PATH="${LIBDIR}"
+export LD_LIBRARY_PATH PYTHONPATH
+PATH="${PATH}:${SBINDIR}"
+export PATH
+
+name="xenbackendd"
+rcvar=$name
+command="${SBINDIR}/xenbackendd"
+if [ -n "${XENBACKENDD_DEBUG}" ]; then
+ command_args="${XENBACKENDD_ARGS} -d"
+else
+ command_args="${XENBACKENDD_ARGS}"
+fi
+
+load_rc_config $name
+run_rc_command "$1"
+
diff -r 7e44ba113546 -r 3009fd6e30ea tools/hotplug/NetBSD/rc.d/xencommons
--- a/tools/hotplug/NetBSD/rc.d/xencommons Fri Sep 30 14:38:55 2011 +0200
+++ b/tools/hotplug/NetBSD/rc.d/xencommons Fri Sep 30 14:38:55 2011 +0200
@@ -46,7 +46,7 @@ xen_startcmd()
XENSTORED_ROOTDIR="/var/lib/xenstored"
fi
rm -f ${XENSTORED_ROOTDIR}/tdb* >/dev/null 2>&1
- printf "Starting xenservices: xenstored, xenconsoled, xenbackendd."
+ printf "Starting xenservices: xenstored, xenconsoled."
XENSTORED_ARGS=" --pid-file ${XENSTORED_PIDFILE}"
if [ -n "${XENSTORED_TRACE}" ]; then
XENSTORED_ARGS="${XENSTORED_ARGS} -T /var/log/xen/xenstored-trace.log"
@@ -68,13 +68,6 @@ xen_startcmd()
${SBINDIR}/xenconsoled ${XENCONSOLED_ARGS}
- XENBACKENDD_ARGS=""
- if [ -n "${XENBACKENDD_DEBUG}" ]; then
- XENBACKENDD_ARGS="${XENBACKENDD_ARGS} -d"
- fi
-
- ${SBINDIR}/xenbackendd ${XENBACKENDD_ARGS}
-
printf "\n"
printf "Setting domain 0 name.\n"
diff -r 7e44ba113546 -r 3009fd6e30ea tools/hotplug/NetBSD/rc.d/xend
--- a/tools/hotplug/NetBSD/rc.d/xend Fri Sep 30 14:38:55 2011 +0200
+++ b/tools/hotplug/NetBSD/rc.d/xend Fri Sep 30 14:38:55 2011 +0200
@@ -1,7 +1,7 @@
#!/bin/sh
#
# PROVIDE: xend
-# REQUIRE: xencommons
+# REQUIRE: xencommons xenbackendd
. /etc/rc.subr
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH 1 of 9] xenbackendd: fix incorrect usage of pidfile
2011-09-30 12:43 ` [PATCH 1 of 9] xenbackendd: fix incorrect usage of pidfile Roger Pau Monne
@ 2011-09-30 12:52 ` Christoph Egger
2011-10-06 16:24 ` [PATCH 1 of 9] xenbackendd: fix incorrect usage of pidfile [and 1 more messages] Ian Jackson
0 siblings, 1 reply; 33+ messages in thread
From: Christoph Egger @ 2011-09-30 12:52 UTC (permalink / raw)
To: Roger Pau Monne; +Cc: xen-devel@lists.xensource.com
On 09/30/11 14:43, Roger Pau Monne wrote:
> # HG changeset patch
> # User Roger Pau Monne<roger.pau@entel.upc.edu>
> # Date 1317300282 -7200
> # Node ID 47005b3da245e2be052b614c02ed212d3d2cecbd
> # Parent a422e2a4451e16dc791b293f41966b842fa4781d
> xenbackendd: fix incorrect usage of pidfile
>
> Fix xenbackendd ignoring the pidfile passed through the command line.
>
> Signed-off-by: Roger Pau Monne<roger.pau@entel.upc.edu>
Acked-by: Christoph Egger <Christoph.Egger@amd.com>
>
> diff -r a422e2a4451e -r 47005b3da245 tools/xenbackendd/xenbackendd.c
> --- a/tools/xenbackendd/xenbackendd.c Sun Sep 18 00:26:52 2011 +0100
> +++ b/tools/xenbackendd/xenbackendd.c Thu Sep 29 14:44:42 2011 +0200
> @@ -169,7 +169,7 @@ main(int argc, char * const argv[])
> log_file = optarg;
> break;
> case 'p':
> - pidfile = pidfile;
> + pidfile = optarg;
> case 's':
> vbd_script = optarg;
> break;
>
--
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85689 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH 0 of 9] Call hotplug scripts from libxl
2011-09-30 12:43 [PATCH 0 of 9] Call hotplug scripts from libxl Roger Pau Monne
` (8 preceding siblings ...)
2011-09-30 12:43 ` [PATCH 9 of 9] rc.d NetBSD: don't start xenbackendd by default, only when xend needs it Roger Pau Monne
@ 2011-10-04 13:24 ` Roger Pau Monné
2011-10-04 13:33 ` Ian Campbell
9 siblings, 1 reply; 33+ messages in thread
From: Roger Pau Monné @ 2011-10-04 13:24 UTC (permalink / raw)
To: xen-devel
I've just realized that there's a drawback with this implementation,
domains that are closed from inside the VM (a typical "shutdown -h
now") do not trigger the launch of hotplug scripts, since libxl is not
running and is not aware that the domain has powered off. Don't know
the best way to solve this issue, that doesn't take us back to having
a separate daemon that monitors xenstore states (or udev on Linux).
Regards, Roger.
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: Re: [PATCH 0 of 9] Call hotplug scripts from libxl
2011-10-04 13:24 ` [PATCH 0 of 9] Call hotplug scripts from libxl Roger Pau Monné
@ 2011-10-04 13:33 ` Ian Campbell
2011-10-04 14:15 ` Roger Pau Monné
0 siblings, 1 reply; 33+ messages in thread
From: Ian Campbell @ 2011-10-04 13:33 UTC (permalink / raw)
To: Roger Pau Monné; +Cc: xen-devel@lists.xensource.com
On Tue, 2011-10-04 at 14:24 +0100, Roger Pau Monné wrote:
> I've just realized that there's a drawback with this implementation,
> domains that are closed from inside the VM (a typical "shutdown -h
> now") do not trigger the launch of hotplug scripts, since libxl is not
> running and is not aware that the domain has powered off.
By default xl daemonises itself and monitors the domain waiting for it
to exit, at which point it should perform the necessary cleanup (this is
the call to libxl_domain_destroy in handle_domain_death).
If you ask xl to not do this (using the -e or -F options) then you are
expected to call xl destroy yourself.
The call to libxl_domain_destroy calls libxl__devices_destroy which
tears down the backends. Unfortunately this is done in a slightly
generic way but my recent series should have laid the ground work for
doing this in a more device-specific way.
I have a feeling that libxl__device_destroy should really consist of a
sequence of libxl_device_FOO_list+foreach(thing) libxl_device_FOO_remove
calls rather than the current mechanism. i.e. be really explicit about
what it is tearing down.
Ian.
> Don't know
> the best way to solve this issue, that doesn't take us back to having
> a separate daemon that monitors xenstore states (or udev on Linux).
>
> Regards, Roger.
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: Re: [PATCH 0 of 9] Call hotplug scripts from libxl
2011-10-04 13:33 ` Ian Campbell
@ 2011-10-04 14:15 ` Roger Pau Monné
2011-10-04 14:26 ` Ian Campbell
0 siblings, 1 reply; 33+ messages in thread
From: Roger Pau Monné @ 2011-10-04 14:15 UTC (permalink / raw)
To: Ian Campbell; +Cc: xen-devel@lists.xensource.com
2011/10/4 Ian Campbell <Ian.Campbell@citrix.com>:
> By default xl daemonises itself and monitors the domain waiting for it
> to exit, at which point it should perform the necessary cleanup (this is
> the call to libxl_domain_destroy in handle_domain_death).
libxl daemonises itself if you call "xl shutdown <domain>", but if the
domain shuts down from inside (doing a "halt"), xl is never called,
and therefore hotplug scripts are not executed.
> If you ask xl to not do this (using the -e or -F options) then you are
> expected to call xl destroy yourself.
>
> The call to libxl_domain_destroy calls libxl__devices_destroy which
> tears down the backends. Unfortunately this is done in a slightly
> generic way but my recent series should have laid the ground work for
> doing this in a more device-specific way.
>
> I have a feeling that libxl__device_destroy should really consist of a
> sequence of libxl_device_FOO_list+foreach(thing) libxl_device_FOO_remove
> calls rather than the current mechanism. i.e. be really explicit about
> what it is tearing down.
>
> Ian.
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: Re: [PATCH 0 of 9] Call hotplug scripts from libxl
2011-10-04 14:15 ` Roger Pau Monné
@ 2011-10-04 14:26 ` Ian Campbell
2011-10-05 7:39 ` Roger Pau Monné
0 siblings, 1 reply; 33+ messages in thread
From: Ian Campbell @ 2011-10-04 14:26 UTC (permalink / raw)
To: Roger Pau Monné; +Cc: xen-devel@lists.xensource.com
On Tue, 2011-10-04 at 15:15 +0100, Roger Pau Monné wrote:
> 2011/10/4 Ian Campbell <Ian.Campbell@citrix.com>:
> > By default xl daemonises itself and monitors the domain waiting for it
> > to exit, at which point it should perform the necessary cleanup (this is
> > the call to libxl_domain_destroy in handle_domain_death).
>
> libxl daemonises itself if you call "xl shutdown <domain>", but if the
> domain shuts down from inside (doing a "halt"), xl is never called,
> and therefore hotplug scripts are not executed.
I don't think "xl shutdown" daemonises ever.
"xl create" daemonises itself and waits for the guest to die. It should
be detecting the guest shutdown no matter if it is triggered internally
or externally. That's not to say it's not buggy though...
>
> > If you ask xl to not do this (using the -e or -F options) then you are
> > expected to call xl destroy yourself.
> >
> > The call to libxl_domain_destroy calls libxl__devices_destroy which
> > tears down the backends. Unfortunately this is done in a slightly
> > generic way but my recent series should have laid the ground work for
> > doing this in a more device-specific way.
> >
> > I have a feeling that libxl__device_destroy should really consist of a
> > sequence of libxl_device_FOO_list+foreach(thing) libxl_device_FOO_remove
> > calls rather than the current mechanism. i.e. be really explicit about
> > what it is tearing down.
> >
> > Ian.
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: Re: [PATCH 0 of 9] Call hotplug scripts from libxl
2011-10-04 14:26 ` Ian Campbell
@ 2011-10-05 7:39 ` Roger Pau Monné
0 siblings, 0 replies; 33+ messages in thread
From: Roger Pau Monné @ 2011-10-05 7:39 UTC (permalink / raw)
To: Ian Campbell; +Cc: xen-devel@lists.xensource.com
> I don't think "xl shutdown" daemonises ever.
>
> "xl create" daemonises itself and waits for the guest to die. It should
> be detecting the guest shutdown no matter if it is triggered internally
> or externally. That's not to say it's not buggy though...
Sorry for the stupid question, this seems to not be working ok on
NetBSD, I will check it and post a patch.
Regards, Roger.
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH 1 of 9] xenbackendd: fix incorrect usage of pidfile [and 1 more messages]
2011-09-30 12:52 ` Christoph Egger
@ 2011-10-06 16:24 ` Ian Jackson
0 siblings, 0 replies; 33+ messages in thread
From: Ian Jackson @ 2011-10-06 16:24 UTC (permalink / raw)
To: Christoph Egger, Roger Pau Monne; +Cc: xen-devel
Roger Pau Monne writes ("[Xen-devel] [PATCH 1 of 9] xenbackendd: fix incorrect usage of pidfile"):
> xenbackendd: fix incorrect usage of pidfile
>
> Fix xenbackendd ignoring the pidfile passed through the command line.
>
> Signed-off-by: Roger Pau Monne <roger.pau@entel.upc.edu>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH 4 of 9] libxl: create pci backend only when there are pci devices
2011-09-30 12:43 ` [PATCH 4 of 9] libxl: create pci backend only when there are pci devices Roger Pau Monne
@ 2011-10-06 16:26 ` Ian Jackson
2011-10-18 13:16 ` Ian Campbell
1 sibling, 0 replies; 33+ messages in thread
From: Ian Jackson @ 2011-10-06 16:26 UTC (permalink / raw)
To: Roger Pau Monne; +Cc: xen-devel
Roger Pau Monne writes ("[Xen-devel] [PATCH 4 of 9] libxl: create pci backend on> libxl: create pci backend only when there are pci devices.
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH 5 of 9] libxl: only use interactive PyGrub mode when a console is attached
2011-09-30 12:43 ` [PATCH 5 of 9] libxl: only use interactive PyGrub mode when a console is attached Roger Pau Monne
@ 2011-10-06 16:28 ` Ian Jackson
2011-10-10 13:16 ` Roger Pau Monné
0 siblings, 1 reply; 33+ messages in thread
From: Ian Jackson @ 2011-10-06 16:28 UTC (permalink / raw)
To: Roger Pau Monne; +Cc: xen-devel
Roger Pau Monne writes ("[Xen-devel] [PATCH 5 of 9] libxl: only use interactive > libxl: only use interactive PyGrub mode when a console is attached
I don't think this is correct.
> Sometimes PyGrub freezed when trying to create a domain without the
> console attached (without "-c"). This patch adds the "-q" option to
> PyGrub when "-c" is not specified at creation time. PyGrub freezed
> trying to set terminal attributes (like reset_prog_mode or
> nocbreak).
I think "-c" shouldn't affect the functionality of the domain, just
whether the console is initially connected. Perhaps the console will
be connected somewhere else.
OTOH I think it would be fine to have an option (libxl config
parameter, I guess) to make pygrub run noninteractively.
Ian.
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH 5 of 9] libxl: only use interactive PyGrub mode when a console is attached
2011-10-06 16:28 ` Ian Jackson
@ 2011-10-10 13:16 ` Roger Pau Monné
2011-10-10 13:41 ` Ian Campbell
2011-10-10 14:32 ` Ian Jackson
0 siblings, 2 replies; 33+ messages in thread
From: Roger Pau Monné @ 2011-10-10 13:16 UTC (permalink / raw)
To: Ian Jackson; +Cc: xen-devel
> I think "-c" shouldn't affect the functionality of the domain, just
> whether the console is initially connected. Perhaps the console will
> be connected somewhere else.
>
> OTOH I think it would be fine to have an option (libxl config
> parameter, I guess) to make pygrub run noninteractively.
I've digged a little more into this issue, and found out that NetBSD
ptys have a 1024 buffer limit, and when this limit is hit, the select
from libxl_bootloader:211 blocks and no more data is writen to
xenconsole_fd and no more data is read from bootloader_fd (because
bootloader_buf contains data), which of course blocks the execution of
pygrub. Since the xenconsoled_fd pty is not monitored by xenconsole,
nobody is draining data from it. I don't know the best way to solve
this, but it seems like somebody should read the data from
xenconsoled_fd and dispose it if there is no console attached.
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH 5 of 9] libxl: only use interactive PyGrub mode when a console is attached
2011-10-10 13:16 ` Roger Pau Monné
@ 2011-10-10 13:41 ` Ian Campbell
2011-10-10 13:44 ` Ian Campbell
2011-10-10 14:32 ` Ian Jackson
1 sibling, 1 reply; 33+ messages in thread
From: Ian Campbell @ 2011-10-10 13:41 UTC (permalink / raw)
To: Roger Pau Monné; +Cc: xen-devel@lists.xensource.com, Ian Jackson
On Mon, 2011-10-10 at 14:16 +0100, Roger Pau Monné wrote:
> > I think "-c" shouldn't affect the functionality of the domain, just
> > whether the console is initially connected. Perhaps the console will
> > be connected somewhere else.
> >
> > OTOH I think it would be fine to have an option (libxl config
> > parameter, I guess) to make pygrub run noninteractively.
>
> I've digged a little more into this issue, and found out that NetBSD
> ptys have a 1024 buffer limit, and when this limit is hit, the select
^byte ?
> from libxl_bootloader:211 blocks and no more data is writen to
> xenconsole_fd and no more data is read from bootloader_fd (because
> bootloader_buf contains data),
IIRC I made that last condition like that because it simplified things
because I could avoid worrying about wrapping the consumer round in the
buffer, or something. However if that scheme doesn't work for BSD we
could go the more complex route, assuming it would help.
This could well be a problem on Linux too but we are just avoiding it
due to the larger buffers. I wonder if I can artificially reduce the
buffer size on Linux...
> which of course blocks the execution of
> pygrub. Since the xenconsoled_fd pty is not monitored by xenconsole,
> nobody is draining data from it. I don't know the best way to solve
> this, but it seems like somebody should read the data from
> xenconsoled_fd and dispose it if there is no console attached.
Yes. One option could be to add a timeout to the select and throwaway
data if necessary. I think xenconsoled does this for real guest consoles
too if no one is connected so that behaviour would at least be
consistent. Or maybe xenconsoled should be doing this for this pty like
it does for guests?
Might another option be to increase the size of the buffer in libxl to
>1K? More of a workaround than a solution I suppose.
Ian.
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH 5 of 9] libxl: only use interactive PyGrub mode when a console is attached
2011-10-10 13:41 ` Ian Campbell
@ 2011-10-10 13:44 ` Ian Campbell
0 siblings, 0 replies; 33+ messages in thread
From: Ian Campbell @ 2011-10-10 13:44 UTC (permalink / raw)
To: Roger Pau Monné; +Cc: xen-devel@lists.xensource.com, Ian Jackson
On Mon, 2011-10-10 at 14:41 +0100, Ian Campbell wrote:
> On Mon, 2011-10-10 at 14:16 +0100, Roger Pau Monné wrote:
> > > I think "-c" shouldn't affect the functionality of the domain, just
> > > whether the console is initially connected. Perhaps the console will
> > > be connected somewhere else.
> > >
> > > OTOH I think it would be fine to have an option (libxl config
> > > parameter, I guess) to make pygrub run noninteractively.
> >
> > I've digged a little more into this issue, and found out that NetBSD
> > ptys have a 1024 buffer limit, and when this limit is hit, the select
> ^byte ?
>
> > from libxl_bootloader:211 blocks and no more data is writen to
> > xenconsole_fd and no more data is read from bootloader_fd (because
> > bootloader_buf contains data),
>
> IIRC I made that last condition like that because it simplified things
> because I could avoid worrying about wrapping the consumer round in the
> buffer, or something. However if that scheme doesn't work for BSD we
> could go the more complex route, assuming it would help.
>
> This could well be a problem on Linux too but we are just avoiding it
> due to the larger buffers. I wonder if I can artificially reduce the
> buffer size on Linux...
>
> > which of course blocks the execution of
> > pygrub. Since the xenconsoled_fd pty is not monitored by xenconsole,
> > nobody is draining data from it. I don't know the best way to solve
> > this, but it seems like somebody should read the data from
> > xenconsoled_fd and dispose it if there is no console attached.
>
> Yes. One option could be to add a timeout to the select and throwaway
> data if necessary. I think xenconsoled does this for real guest consoles
> too if no one is connected so that behaviour would at least be
> consistent. Or maybe xenconsoled should be doing this for this pty like
> it does for guests?
Wait, that last suggestion doesn't work because this pty goes direct to
the xencosole client not via the server and the issue is that there is
no client connected.
Ian.
>
> Might another option be to increase the size of the buffer in libxl to
> >1K? More of a workaround than a solution I suppose.
>
> Ian.
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH 5 of 9] libxl: only use interactive PyGrub mode when a console is attached
2011-10-10 13:16 ` Roger Pau Monné
2011-10-10 13:41 ` Ian Campbell
@ 2011-10-10 14:32 ` Ian Jackson
2011-10-10 14:51 ` Roger Pau Monné
1 sibling, 1 reply; 33+ messages in thread
From: Ian Jackson @ 2011-10-10 14:32 UTC (permalink / raw)
To: Roger Pau Monné; +Cc: xen-devel@lists.xensource.com
Roger Pau Monné writes ("Re: [Xen-devel] [PATCH 5 of 9] libxl: only use interactive PyGrub mode when a console is attached"):
> I've digged a little more into this issue, and found out that NetBSD
> ptys have a 1024 buffer limit, and when this limit is hit, the select
> from libxl_bootloader:211 blocks and no more data is writen to
> xenconsole_fd and no more data is read from bootloader_fd (because
> bootloader_buf contains data), which of course blocks the execution of
> pygrub. Since the xenconsoled_fd pty is not monitored by xenconsole,
> nobody is draining data from it. I don't know the best way to solve
> this, but it seems like somebody should read the data from
> xenconsoled_fd and dispose it if there is no console attached.
That sounds unfortunate. I agree with you.
Ian.
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH 5 of 9] libxl: only use interactive PyGrub mode when a console is attached
2011-10-10 14:32 ` Ian Jackson
@ 2011-10-10 14:51 ` Roger Pau Monné
2011-10-11 8:40 ` Ian Campbell
0 siblings, 1 reply; 33+ messages in thread
From: Roger Pau Monné @ 2011-10-10 14:51 UTC (permalink / raw)
To: Ian Jackson; +Cc: xen-devel@lists.xensource.com
> That sounds unfortunate. I agree with you.
Well Ian Campbell proposed to use a timeout in select and drop data
when the timeout is hit, that what I've implemented in
libxl: drop bootloader output if xenconsole file descriptor is not
available for writing
The patch is quite simple and solves the problem, I don't think it
interferes with normal boot process, since a 1s timeout is quite high
for data to be delivered from xenconsoled_fd to the user if the
console is attached. The other option would be to modify xenconsole
daemon, but I think that's far too complicated for a problem that can
be solved easily.
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH 5 of 9] libxl: only use interactive PyGrub mode when a console is attached
2011-10-10 14:51 ` Roger Pau Monné
@ 2011-10-11 8:40 ` Ian Campbell
2011-10-11 10:45 ` Roger Pau Monné
0 siblings, 1 reply; 33+ messages in thread
From: Ian Campbell @ 2011-10-11 8:40 UTC (permalink / raw)
To: Roger Pau Monné; +Cc: xen-devel@lists.xensource.com, Ian Jackson
On Mon, 2011-10-10 at 15:51 +0100, Roger Pau Monné wrote:
> > That sounds unfortunate. I agree with you.
>
> Well Ian Campbell proposed to use a timeout in select and drop data
> when the timeout is hit, that what I've implemented in
>
> libxl: drop bootloader output if xenconsole file descriptor is not
> available for writing
>
> The patch is quite simple and solves the problem, I don't think it
> interferes with normal boot process, since a 1s timeout is quite high
> for data to be delivered from xenconsoled_fd to the user if the
> console is attached.
The case where a user types
xl create /a/domain
xl console adomain
might have a reasonably long delay in it before the console is
connected. Increasing the libxl buffer size would mitigate that but
you'd still have the problem of not reading from an fd if the cons is !=
0.
Can you print out the actual values of the various producers and
consumers at the point of the hang? (maybe track total bytes too for
debug?)
Perhaps where we have:
if (xenconsoled_prod == xenconsoled_cons)
xenconsoled_prod = xenconsoled_cons = 0;
if (bootloader_prod == bootloader_cons)
bootloader_prod = bootloader_cons = 0;
We could also add some suitable memmoves and associated prod/cons
manipulation, such that the unconsumed data is always pulled to the head
of the buffer. That might be a reasonably simple way to improve things
and allow larger buffers to be used? More often than not the memmove
won't be getting called since either XXX_prod == XXX_cons or XXX_cons is
already 0, IOW having a partially consumed buffer would be unusual?
Once we have a larger buffer which we always try to fill discarding data
after a timeout when the buffer is full won't be so critical.
> The other option would be to modify xenconsole
> daemon, but I think that's far too complicated for a problem that can
> be solved easily.
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH 5 of 9] libxl: only use interactive PyGrub mode when a console is attached
2011-10-11 8:40 ` Ian Campbell
@ 2011-10-11 10:45 ` Roger Pau Monné
2011-10-11 11:02 ` Ian Campbell
0 siblings, 1 reply; 33+ messages in thread
From: Roger Pau Monné @ 2011-10-11 10:45 UTC (permalink / raw)
To: Ian Campbell; +Cc: xen-devel@lists.xensource.com, Ian Jackson
2011/10/11 Ian Campbell <Ian.Campbell@citrix.com>:
> On Mon, 2011-10-10 at 15:51 +0100, Roger Pau Monné wrote:
>> > That sounds unfortunate. I agree with you.
>>
>> Well Ian Campbell proposed to use a timeout in select and drop data
>> when the timeout is hit, that what I've implemented in
>>
>> libxl: drop bootloader output if xenconsole file descriptor is not
>> available for writing
>>
>> The patch is quite simple and solves the problem, I don't think it
>> interferes with normal boot process, since a 1s timeout is quite high
>> for data to be delivered from xenconsoled_fd to the user if the
>> console is attached.
>
> The case where a user types
> xl create /a/domain
> xl console adomain
>
> might have a reasonably long delay in it before the console is
> connected. Increasing the libxl buffer size would mitigate that but
> you'd still have the problem of not reading from an fd if the cons is !=
> 0.
>
> Can you print out the actual values of the various producers and
> consumers at the point of the hang? (maybe track total bytes too for
> debug?)
The process gets stuck after writing 1022 bytes to xenconsole_fd, and
the buffer is 24 consumed 48 produced (although that varies, sometimes
I get ~700 produced and ~20 consumed, but the total written bits is
1022 always).
> Perhaps where we have:
> if (xenconsoled_prod == xenconsoled_cons)
> xenconsoled_prod = xenconsoled_cons = 0;
> if (bootloader_prod == bootloader_cons)
> bootloader_prod = bootloader_cons = 0;
> We could also add some suitable memmoves and associated prod/cons
> manipulation, such that the unconsumed data is always pulled to the head
> of the buffer. That might be a reasonably simple way to improve things
> and allow larger buffers to be used? More often than not the memmove
> won't be getting called since either XXX_prod == XXX_cons or XXX_cons is
> already 0, IOW having a partially consumed buffer would be unusual?
I don't really like moving memory around, since it's slow, but I think
implementing a circular buffer would really complicate things. I will
post a new patch that implements the following:
1. Increase buffer.
2. Use memmove to move memory to the head of the buffer and fill it
until the buffer is full.
3. On timeout and full buffer, drop data from the head of the buffer
(older data) and fill it with new data (move the buffer and append new
data at the end).
Do you thing this should be applied to both xenconsoled and
bootloader? since the only one giving problems is xenconsoled.
> Once we have a larger buffer which we always try to fill discarding data
> after a timeout when the buffer is full won't be so critical.
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH 5 of 9] libxl: only use interactive PyGrub mode when a console is attached
2011-10-11 10:45 ` Roger Pau Monné
@ 2011-10-11 11:02 ` Ian Campbell
0 siblings, 0 replies; 33+ messages in thread
From: Ian Campbell @ 2011-10-11 11:02 UTC (permalink / raw)
To: Roger Pau Monné; +Cc: xen-devel@lists.xensource.com, Ian Jackson
On Tue, 2011-10-11 at 11:45 +0100, Roger Pau Monné wrote:
> 2011/10/11 Ian Campbell <Ian.Campbell@citrix.com>:
> > On Mon, 2011-10-10 at 15:51 +0100, Roger Pau Monné wrote:
> >> > That sounds unfortunate. I agree with you.
> >>
> >> Well Ian Campbell proposed to use a timeout in select and drop data
> >> when the timeout is hit, that what I've implemented in
> >>
> >> libxl: drop bootloader output if xenconsole file descriptor is not
> >> available for writing
> >>
> >> The patch is quite simple and solves the problem, I don't think it
> >> interferes with normal boot process, since a 1s timeout is quite high
> >> for data to be delivered from xenconsoled_fd to the user if the
> >> console is attached.
> >
> > The case where a user types
> > xl create /a/domain
> > xl console adomain
> >
> > might have a reasonably long delay in it before the console is
> > connected. Increasing the libxl buffer size would mitigate that but
> > you'd still have the problem of not reading from an fd if the cons is !=
> > 0.
> >
> > Can you print out the actual values of the various producers and
> > consumers at the point of the hang? (maybe track total bytes too for
> > debug?)
>
>
> The process gets stuck after writing 1022 bytes to xenconsole_fd, and
> the buffer is 24 consumed 48 produced (although that varies, sometimes
> I get ~700 produced and ~20 consumed, but the total written bits is
> 1022 always).
Thanks.
>
> > Perhaps where we have:
> > if (xenconsoled_prod == xenconsoled_cons)
> > xenconsoled_prod = xenconsoled_cons = 0;
> > if (bootloader_prod == bootloader_cons)
> > bootloader_prod = bootloader_cons = 0;
> > We could also add some suitable memmoves and associated prod/cons
> > manipulation, such that the unconsumed data is always pulled to the head
> > of the buffer. That might be a reasonably simple way to improve things
> > and allow larger buffers to be used? More often than not the memmove
> > won't be getting called since either XXX_prod == XXX_cons or XXX_cons is
> > already 0, IOW having a partially consumed buffer would be unusual?
>
> I don't really like moving memory around, since it's slow, but I think
> implementing a circular buffer would really complicate things.
I suspect that under normal use the move will never happen because we
will always have either written the entire buffer (so cons==prod,
cheaply reset both to zero) or none of it (so cons==0 and there is
nothing to do).
In the case you are suffering from I expect it will happen exactly once
and then we will be in the cons==0 state from then on unless we become
able to write something.
If that is correct then I don't think the move will be a problem in
practice. Also the buffers aren't all that big so moving them cant bee
all that expensive in the grand scheme of things.
libxl configures xenconsoled to have a limit of 1048576
(LIBXL_XENCONSOLE_LIMIT) by default. Hopefully we can get away with
something smaller for the bootloader interactions.
> I will
> post a new patch that implements the following:
>
> 1. Increase buffer.
> 2. Use memmove to move memory to the head of the buffer and fill it
> until the buffer is full.
> 3. On timeout and full buffer, drop data from the head of the buffer
> (older data) and fill it with new data (move the buffer and append new
> data at the end).
This sounds good.
When xenconsoled drops guest console data it seems to drop data from the
middle. I'm not sure why though. The checkin comment of 2b8efe11096b8
doesn't really go into detail on that aspect.
> Do you thing this should be applied to both xenconsoled and
> bootloader? since the only one giving problems is xenconsoled.
The bootloader buffer is currently larger so we probably don't see any
problems but in theory it's just as vulnerable? We probably don't need
to increase the buffer any further but the other changes probably make
sense.
> > Once we have a larger buffer which we always try to fill discarding data
> > after a timeout when the buffer is full won't be so critical.
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH 4 of 9] libxl: create pci backend only when there are pci devices
2011-09-30 12:43 ` [PATCH 4 of 9] libxl: create pci backend only when there are pci devices Roger Pau Monne
2011-10-06 16:26 ` Ian Jackson
@ 2011-10-18 13:16 ` Ian Campbell
2011-10-19 9:11 ` Roger Pau Monné
1 sibling, 1 reply; 33+ messages in thread
From: Ian Campbell @ 2011-10-18 13:16 UTC (permalink / raw)
To: Roger Pau Monne; +Cc: xen-devel@lists.xensource.com, Ian Jackson
On Fri, 2011-09-30 at 13:43 +0100, Roger Pau Monne wrote:
> # HG changeset patch
> # User Roger Pau Monne <roger.pau@entel.upc.edu>
> # Date 1317386335 -7200
> # Node ID 156626fef95b36184ad44dfcb049bae2545435f0
> # Parent 31b3caad18ac904a242c5bd1ea2bb0e574cd0453
> libxl: create pci backend only when there are pci devices.
>
> Creating empty pci entries made Linux DomUs under NetBSD Dom0 wait a
> very long time for devices to initialize during kernel boot.
I think since this change we need the following. This applies after my
big libxl API series:
Ian.
8<------------------------------------------------------
# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1318943709 -3600
# Node ID e6af32ecb4483457d5ad9a7b674c18aaf20cc085
# Parent 12ac478d1b56f0ff4d3242138b780c551a69f107
libxl: libxl__device_pci_destroy_all should succeed if there is no PCI bus on the domain
Since 23915:4c4b72c94bac "" it is possible that no bus exists and this is not
an error. Removes the following spurious warning when destroying a PV domain
with no PCI devices:
libxl: error: libxl.c:759:libxl_domain_destroy: pci shutdown failed for domid 1005
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
diff -r 12ac478d1b56 -r e6af32ecb448 tools/libxl/libxl_pci.c
--- a/tools/libxl/libxl_pci.c Tue Oct 18 13:36:43 2011 +0100
+++ b/tools/libxl/libxl_pci.c Tue Oct 18 14:15:09 2011 +0100
@@ -1098,7 +1098,7 @@ int libxl__device_pci_destroy_all(libxl_
pcidevs = libxl_device_pci_list(ctx, domid, &num);
if ( pcidevs == NULL )
- return ERROR_FAIL;
+ return 0;
for (i = 0; i < num; i++) {
/* Force remove on shutdown since, on HVM, qemu will not always
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH 4 of 9] libxl: create pci backend only when there are pci devices
2011-10-18 13:16 ` Ian Campbell
@ 2011-10-19 9:11 ` Roger Pau Monné
2011-10-19 9:36 ` Ian Campbell
2011-11-02 16:26 ` [PATCH 4 of 9] libxl: create pci backend only when there are pci devices [and 1 more messages] Ian Jackson
0 siblings, 2 replies; 33+ messages in thread
From: Roger Pau Monné @ 2011-10-19 9:11 UTC (permalink / raw)
To: Ian Campbell; +Cc: xen-devel@lists.xensource.com, Ian Jackson
2011/10/18 Ian Campbell <Ian.Campbell@citrix.com>:
> On Fri, 2011-09-30 at 13:43 +0100, Roger Pau Monne wrote:
>> # HG changeset patch
>> # User Roger Pau Monne <roger.pau@entel.upc.edu>
>> # Date 1317386335 -7200
>> # Node ID 156626fef95b36184ad44dfcb049bae2545435f0
>> # Parent 31b3caad18ac904a242c5bd1ea2bb0e574cd0453
>> libxl: create pci backend only when there are pci devices.
>>
>> Creating empty pci entries made Linux DomUs under NetBSD Dom0 wait a
>> very long time for devices to initialize during kernel boot.
>
> I think since this change we need the following. This applies after my
> big libxl API series:
Yes, this fixes the issue related to the error message "libxl: error:
libxl.c:759:libxl_domain_destroy: pci shutdown failed for domid". I
don't know if I can do this, but anyway:
Acked-by: Roger Pau Monne <roger.pau@entel.upc.edu>
> Ian.
>
> 8<------------------------------------------------------
>
>
> # HG changeset patch
> # User Ian Campbell <ian.campbell@citrix.com>
> # Date 1318943709 -3600
> # Node ID e6af32ecb4483457d5ad9a7b674c18aaf20cc085
> # Parent 12ac478d1b56f0ff4d3242138b780c551a69f107
> libxl: libxl__device_pci_destroy_all should succeed if there is no PCI bus on the domain
>
> Since 23915:4c4b72c94bac "" it is possible that no bus exists and this is not
> an error. Removes the following spurious warning when destroying a PV domain
> with no PCI devices:
> libxl: error: libxl.c:759:libxl_domain_destroy: pci shutdown failed for domid 1005
>
> Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
>
> diff -r 12ac478d1b56 -r e6af32ecb448 tools/libxl/libxl_pci.c
> --- a/tools/libxl/libxl_pci.c Tue Oct 18 13:36:43 2011 +0100
> +++ b/tools/libxl/libxl_pci.c Tue Oct 18 14:15:09 2011 +0100
> @@ -1098,7 +1098,7 @@ int libxl__device_pci_destroy_all(libxl_
>
> pcidevs = libxl_device_pci_list(ctx, domid, &num);
> if ( pcidevs == NULL )
> - return ERROR_FAIL;
> + return 0;
>
> for (i = 0; i < num; i++) {
> /* Force remove on shutdown since, on HVM, qemu will not always
>
>
>
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH 4 of 9] libxl: create pci backend only when there are pci devices
2011-10-19 9:11 ` Roger Pau Monné
@ 2011-10-19 9:36 ` Ian Campbell
2011-11-02 9:28 ` Roger Pau Monné
2011-11-02 16:26 ` [PATCH 4 of 9] libxl: create pci backend only when there are pci devices [and 1 more messages] Ian Jackson
1 sibling, 1 reply; 33+ messages in thread
From: Ian Campbell @ 2011-10-19 9:36 UTC (permalink / raw)
To: Roger Pau Monné; +Cc: xen-devel@lists.xensource.com, Ian Jackson
On Wed, 2011-10-19 at 10:11 +0100, Roger Pau Monné wrote:
> 2011/10/18 Ian Campbell <Ian.Campbell@citrix.com>:
> > On Fri, 2011-09-30 at 13:43 +0100, Roger Pau Monne wrote:
> >> # HG changeset patch
> >> # User Roger Pau Monne <roger.pau@entel.upc.edu>
> >> # Date 1317386335 -7200
> >> # Node ID 156626fef95b36184ad44dfcb049bae2545435f0
> >> # Parent 31b3caad18ac904a242c5bd1ea2bb0e574cd0453
> >> libxl: create pci backend only when there are pci devices.
> >>
> >> Creating empty pci entries made Linux DomUs under NetBSD Dom0 wait a
> >> very long time for devices to initialize during kernel boot.
> >
> > I think since this change we need the following. This applies after my
> > big libxl API series:
>
> Yes, this fixes the issue related to the error message "libxl: error:
> libxl.c:759:libxl_domain_destroy: pci shutdown failed for domid". I
> don't know if I can do this, but anyway:
>
> Acked-by: Roger Pau Monne <roger.pau@entel.upc.edu>
Thanks. FWIW I would encourage anyone who wants and feels qualified to
do so to review any patch and Ack it if they think it is sensible. More
eyes doing review is always a good thing IMHO.
>
> > Ian.
> >
> > 8<------------------------------------------------------
> >
> >
> > # HG changeset patch
> > # User Ian Campbell <ian.campbell@citrix.com>
> > # Date 1318943709 -3600
> > # Node ID e6af32ecb4483457d5ad9a7b674c18aaf20cc085
> > # Parent 12ac478d1b56f0ff4d3242138b780c551a69f107
> > libxl: libxl__device_pci_destroy_all should succeed if there is no PCI bus on the domain
> >
> > Since 23915:4c4b72c94bac "" it is possible that no bus exists and this is not
> > an error. Removes the following spurious warning when destroying a PV domain
> > with no PCI devices:
> > libxl: error: libxl.c:759:libxl_domain_destroy: pci shutdown failed for domid 1005
> >
> > Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
> >
> > diff -r 12ac478d1b56 -r e6af32ecb448 tools/libxl/libxl_pci.c
> > --- a/tools/libxl/libxl_pci.c Tue Oct 18 13:36:43 2011 +0100
> > +++ b/tools/libxl/libxl_pci.c Tue Oct 18 14:15:09 2011 +0100
> > @@ -1098,7 +1098,7 @@ int libxl__device_pci_destroy_all(libxl_
> >
> > pcidevs = libxl_device_pci_list(ctx, domid, &num);
> > if ( pcidevs == NULL )
> > - return ERROR_FAIL;
> > + return 0;
> >
> > for (i = 0; i < num; i++) {
> > /* Force remove on shutdown since, on HVM, qemu will not always
> >
> >
> >
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH 4 of 9] libxl: create pci backend only when there are pci devices
2011-10-19 9:36 ` Ian Campbell
@ 2011-11-02 9:28 ` Roger Pau Monné
2011-11-02 16:26 ` Ian Jackson
0 siblings, 1 reply; 33+ messages in thread
From: Roger Pau Monné @ 2011-11-02 9:28 UTC (permalink / raw)
To: Ian Campbell; +Cc: xen-devel@lists.xensource.com, Ian Jackson
Please remember that this patch fixing the removal of PCI entries has
not been applied along with the "libxl: rationalise libxl_device_*
APIs" series.
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH 4 of 9] libxl: create pci backend only when there are pci devices
2011-11-02 9:28 ` Roger Pau Monné
@ 2011-11-02 16:26 ` Ian Jackson
0 siblings, 0 replies; 33+ messages in thread
From: Ian Jackson @ 2011-11-02 16:26 UTC (permalink / raw)
To: Roger Pau Monné; +Cc: xen-devel@lists.xensource.com, Ian Campbell
Roger Pau Monné writes ("Re: [Xen-devel] [PATCH 4 of 9] libxl: create pci backend only when there are pci devices"):
> Please remember that this patch fixing the removal of PCI entries has
> not been applied along with the "libxl: rationalise libxl_device_*
> APIs" series.
Thanks for the reminder. (I did have to dig a bit to find which patch
you meant.)
Ian.
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH 4 of 9] libxl: create pci backend only when there are pci devices [and 1 more messages]
2011-10-19 9:11 ` Roger Pau Monné
2011-10-19 9:36 ` Ian Campbell
@ 2011-11-02 16:26 ` Ian Jackson
1 sibling, 0 replies; 33+ messages in thread
From: Ian Jackson @ 2011-11-02 16:26 UTC (permalink / raw)
To: Roger Pau Monné, Ian Campbell; +Cc: xen-devel@lists.xensource.com
Ian Campbell writes ("Re: [Xen-devel] [PATCH 4 of 9] libxl: create pci backend only when there are pci devices"):
> libxl: libxl__device_pci_destroy_all should succeed if there is no PCI bus on the domain
Roger Pau Monné writes ("Re: [Xen-devel] [PATCH 4 of 9] libxl: create pci backend only when there are pci devices"):
> Acked-by: Roger Pau Monne <roger.pau@entel.upc.edu>
Applied, thanks.
Ian.
^ permalink raw reply [flat|nested] 33+ messages in thread
end of thread, other threads:[~2011-11-02 16:26 UTC | newest]
Thread overview: 33+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-30 12:43 [PATCH 0 of 9] Call hotplug scripts from libxl Roger Pau Monne
2011-09-30 12:43 ` [PATCH 1 of 9] xenbackendd: fix incorrect usage of pidfile Roger Pau Monne
2011-09-30 12:52 ` Christoph Egger
2011-10-06 16:24 ` [PATCH 1 of 9] xenbackendd: fix incorrect usage of pidfile [and 1 more messages] Ian Jackson
2011-09-30 12:43 ` [PATCH 2 of 9] xenbackendd: pass type of block device to hotplug script Roger Pau Monne
2011-09-30 12:43 ` [PATCH 3 of 9] libxl: fix for libxl not waiting for devices to disconnect Roger Pau Monne
2011-09-30 12:43 ` [PATCH 4 of 9] libxl: create pci backend only when there are pci devices Roger Pau Monne
2011-10-06 16:26 ` Ian Jackson
2011-10-18 13:16 ` Ian Campbell
2011-10-19 9:11 ` Roger Pau Monné
2011-10-19 9:36 ` Ian Campbell
2011-11-02 9:28 ` Roger Pau Monné
2011-11-02 16:26 ` Ian Jackson
2011-11-02 16:26 ` [PATCH 4 of 9] libxl: create pci backend only when there are pci devices [and 1 more messages] Ian Jackson
2011-09-30 12:43 ` [PATCH 5 of 9] libxl: only use interactive PyGrub mode when a console is attached Roger Pau Monne
2011-10-06 16:28 ` Ian Jackson
2011-10-10 13:16 ` Roger Pau Monné
2011-10-10 13:41 ` Ian Campbell
2011-10-10 13:44 ` Ian Campbell
2011-10-10 14:32 ` Ian Jackson
2011-10-10 14:51 ` Roger Pau Monné
2011-10-11 8:40 ` Ian Campbell
2011-10-11 10:45 ` Roger Pau Monné
2011-10-11 11:02 ` Ian Campbell
2011-09-30 12:43 ` [PATCH 6 of 9] libxl: add support for image files for NetBSD Roger Pau Monne
2011-09-30 12:43 ` [PATCH 7 of 9] libxl: execute hotplug scripts directly from libxl Roger Pau Monne
2011-09-30 12:43 ` [PATCH 8 of 9] hotplug NetBSD: detach devices when state is 5 or 6 Roger Pau Monne
2011-09-30 12:43 ` [PATCH 9 of 9] rc.d NetBSD: don't start xenbackendd by default, only when xend needs it Roger Pau Monne
2011-10-04 13:24 ` [PATCH 0 of 9] Call hotplug scripts from libxl Roger Pau Monné
2011-10-04 13:33 ` Ian Campbell
2011-10-04 14:15 ` Roger Pau Monné
2011-10-04 14:26 ` Ian Campbell
2011-10-05 7:39 ` Roger Pau Monné
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.