Skip to contentSkip to conversation

Use system blktap

PATCH Applied George Dunlap 7 participants 45 messages Jul 6, 2015 – Jul 23, 2015

lore
Share & tools
lore
#0 lore raw

cover Use system blktap

Switch to using a blktap provided by the system, rather than building it in-tree.

Do this by adding a block-tap script which calls the tap-ctl binary, rather than linking against a library.

This requires the use of an externally-built tap-ctl binary, which an be built from the master branch of the XenServer blktap tree at
https://github.com/xapi-project/blktap.git

The first two patches and the final patch are general libxl disk handling improvements which can be applied independently of the core.

The third patch (tools: Add a block-tap script for setting up tapdisks via tap-ctl) can also be checked in independently from the fourth and fifth, as it allows someone to disable blktap support in configure but still use externally-built tap-ctl binaries (albeit with a different disk string).

The fifth patch is a straight rm -rf of toosl/blktap2. Rather than spam everyone's mailboxes I've clipped the message here, and provided a tree which can be pulled from:

git://xenbits.xen.org/people/gdunlap/xen.git out/blktap-system/v1

This series also exposes blktap to a bug that prevents HVM guests from using disks created with block scripts. This should be a blocker for the 4.6 release, so I think we should consider checking this series in as is, assuming that bug will be addressed before the release.

George Dunlap (6):
libxl: Make local_initiate_attach more rational
libxl: Remove linux udev rules
tools: Add a block-tap script for setting up tapdisks via tap-ctl
libxl: Use the block-tap script for LIBXL_DISK_BACKEND_TAP
tools: Remove in-tree blktap2
libxl: Add more logging to hotplug script path

 tools/Makefile                               |    1 -
 [tools/blktap2/* removal trimmed]
 tools/config.h.in                            |    3 -
 tools/configure                              |   29 +-
 tools/configure.ac                           |   13 +-
 tools/examples/README                        |    1 -
 tools/hotplug/Linux/Makefile                 |   15 +-
 tools/hotplug/Linux/block-tap                |  123 +
 tools/hotplug/Linux/xen-backend.rules.in     |   13 -
 tools/hotplug/Linux/xen-hotplug-common.sh.in |    7 -
 tools/libxl/Makefile                         |    5 -
 tools/libxl/libxl.c                          |  139 +-
 tools/libxl/libxl_blktap2.c                  |   93 -
 tools/libxl/libxl_create.c                   |   27 -
 tools/libxl/libxl_device.c                   |   34 +-
 tools/libxl/libxl_dm.c                       |    5 +-
 tools/libxl/libxl_internal.c                 |   19 -
 tools/libxl/libxl_internal.h                 |   27 -
 tools/libxl/libxl_linux.c                    |   12 +-
 tools/libxl/libxl_netbsd.c                   |    7 -
 tools/libxl/libxl_noblktap2.c                |   42 -
 146 files changed, 194 insertions(+), 40550 deletions(-)

[delete mode 100644 tools/blktap2/* trimmed]

Signature · 9 lines
CC: Ian Campbell <[email protected]>
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monne <[email protected]>
CC: Felipe Franciosi <[email protected]>
CC: Dave Scott <[email protected]>
CC: Jonathan Ludlam <[email protected]>

1.9.1
#1 lore raw

PATCH 1/6 libxl: Make local_initiate_attach more rational

There are a lot of paths through libxl__device_disk_local_initiate_attach(), but they all really boil down to one thing: Can we just access the file directly, or do we need to attach it?

The requirements for direct access are fairly simple:
* Is this local (as opposed to a driver domain)?
* Is this a raw format (as opposed to cooked)?
* Does this have no scripts associated with it?

If it meets all those requirements, we can access it directly; otherwise we need to attach it.

This fixes a bug where bootloader execution fails for disks with hotplug scripts.

This should fix a theoretical bug when using a qdisk backend in a driver domain. (Not tested.)

Based on a patch by Roger Pau Monne <[email protected]>.

---
CC: Ian Campbell <[email protected]>
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monne <[email protected]>

This is identical to the patch I sent earlier, with the exception that I have fixed a build by removing the (now) unused ctx variable. Given the circumstances I have taken the liberty to retain the Acks above.

---
 tools/libxl/libxl.c | 98 ++++++++++++++---------------------------------------
 1 file changed, 26 insertions(+), 72 deletions(-)
tools/libxl/libxl.c +26 -72
index e9a2d26..92563db 100644
@@ -3058,7 +3058,6 @@ void libxl__device_disk_local_initiate_attach(libxl__egc *egc,
                                      libxl__disk_local_state *dls)
 {
     STATE_AO_GC(dls->ao);
-    libxl_ctx *ctx = CTX;
     char *dev = NULL;
     int rc;
     const libxl_device_disk *in_disk = dls->in_disk;
@@ -3076,55 +3075,21 @@ void libxl__device_disk_local_initiate_attach(libxl__egc *egc,
     rc = libxl__device_disk_setdefault(gc, disk);
     if (rc) goto out;
 
-    switch (disk->backend) {
-        case LIBXL_DISK_BACKEND_PHY:
-            LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "locally attaching PHY disk %s",
-                       disk->pdev_path);
-            dev = disk->pdev_path;
-            break;
-        case LIBXL_DISK_BACKEND_TAP:
-            switch (disk->format) {
-            case LIBXL_DISK_FORMAT_RAW:
-                /* optimise away the early tapdisk attach in this case */
-                LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "locally attaching"
-                           " tap disk %s directly (ie without using blktap)",
-                           disk->pdev_path);
-                dev = disk->pdev_path;
-                break;
-            case LIBXL_DISK_FORMAT_VHD:
-                dev = libxl__blktap_devpath(gc, disk->pdev_path,
-                                            disk->format);
-                break;
-            case LIBXL_DISK_FORMAT_QCOW:
-            case LIBXL_DISK_FORMAT_QCOW2:
-                abort(); /* prevented by libxl__device_disk_set_backend */
-            default:
-                LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
-                           "unrecognized disk format: %d", disk->format);
-                rc = ERROR_FAIL;
-                goto out;
-            }
-            break;
-        case LIBXL_DISK_BACKEND_QDISK:
-            if (disk->format != LIBXL_DISK_FORMAT_RAW) {
-                libxl__prepare_ao_device(ao, &dls->aodev);
-                dls->aodev.callback = local_device_attach_cb;
-                device_disk_add(egc, LIBXL_TOOLSTACK_DOMID, disk,
-                                &dls->aodev, libxl__alloc_vdev,
-                                (void *) blkdev_start);
-                return;
-            } else {
-                dev = disk->pdev_path;
-            }
-            LOG(DEBUG, "locally attaching qdisk %s", dev);
-            break;
-        default:
-            LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "unrecognized disk backend "
-                "type: %d", disk->backend);
-            rc = ERROR_FAIL;
-            goto out;
+    /* If this is in a driver domain, or it's not a raw format, or it involves
+     * running a script, we have to do a local attach. */
+    if (disk->backend_domname != NULL
+        || disk->format != LIBXL_DISK_FORMAT_RAW
+        || disk->script != NULL) {
+        libxl__prepare_ao_device(ao, &dls->aodev);
+        dls->aodev.callback = local_device_attach_cb;
+        device_disk_add(egc, LIBXL_TOOLSTACK_DOMID, disk, &dls->aodev,
+                        libxl__alloc_vdev, (void *) blkdev_start);
+        return;
     }
 
+    LOG(DEBUG, "locally attaching RAW disk %s", disk->pdev_path);
+    dev = disk->pdev_path;
+
     if (dev != NULL)
         dls->diskpath = libxl__strdup(gc, dev);
 
@@ -3157,7 +3122,7 @@ static void local_device_attach_cb(libxl__egc *egc, libxl__ao_device *aodev)
     }
 
     dev = GCSPRINTF("/dev/%s", disk->vdev);
-    LOG(DEBUG, "locally attaching qdisk %s", dev);
+    LOG(DEBUG, "locally attaching disk %s", dev);
 
     rc = libxl__device_from_disk(gc, LIBXL_TOOLSTACK_DOMID, disk, &device);
     if (rc < 0)
@@ -3196,29 +3161,18 @@ void libxl__device_disk_local_initiate_detach(libxl__egc *egc,
 
     if (!dls->diskpath) goto out;
 
-    switch (disk->backend) {
-        case LIBXL_DISK_BACKEND_QDISK:
-            if (disk->vdev != NULL) {
-                GCNEW(device);
-                rc = libxl__device_from_disk(gc, LIBXL_TOOLSTACK_DOMID,
-                                             disk, device);
-                if (rc != 0) goto out;
-
-                aodev->action = LIBXL__DEVICE_ACTION_REMOVE;
-                aodev->dev = device;
-                aodev->callback = local_device_detach_cb;
-                aodev->force = 0;
-                libxl__initiate_device_remove(egc, aodev);
-                return;
-            }
-            /* disk->vdev == NULL; fall through */
-        default:
-            /*
-             * Nothing to do for PHYSTYPE_PHY.
-             * For other device types assume that the blktap2 process is
-             * needed by the soon to be started domain and do nothing.
-             */
-            goto out;
+    if (disk->vdev != NULL) {
+        GCNEW(device);
+        rc = libxl__device_from_disk(gc, LIBXL_TOOLSTACK_DOMID,
+                                     disk, device);
+        if (rc != 0) goto out;
+        
+        aodev->action = LIBXL__DEVICE_ACTION_REMOVE;
+        aodev->dev = device;
+        aodev->callback = local_device_detach_cb;
+        aodev->force = 0;
+        libxl__initiate_device_remove(egc, aodev);
+        return;
     }
 
 out:
Signature · 7 lines
1.9.1


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#2 lore raw

PATCH 2/6 libxl: Remove linux udev rules

In reply to George Dunlap

They are no longer needed, having been replaced by a daemon for driverdomains which will run scripts as necessary.

Worse yet, they seem to be broken for script-based block devices, such as block-iscsi. This wouldn't matter so much if they were never run by default; but if you run block-attach without having created a domain, then the appropriate node to disable running udev scripts will not have been written yet, and the attach will silently fail.

Rather than try to sort out that issue, just remove them entirely.

Note: This changes tools/configure.ac, so autogen.sh may need to be re-run.

---
CC: Ian Campbell <[email protected]>
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monne <[email protected]>

There was some concern that old udev scripts may end up lying around in /etc which will still trigger and run unless libxl/disable_udev exists.

If that's a concern, then for one release we might consider writing libxl/disable_udev manually in xencommons or something to make sure that they don't trigger.

---
 tools/configure                              | 13 ++++++-------
 tools/configure.ac                           |  1 -
 tools/examples/README                        |  1 -
 tools/hotplug/Linux/Makefile                 | 14 +-------------
 tools/hotplug/Linux/xen-backend.rules.in     | 13 -------------
 tools/hotplug/Linux/xen-hotplug-common.sh.in |  7 -------
 tools/libxl/libxl.c                          | 13 -------------
 tools/libxl/libxl_create.c                   | 27 ---------------------------
 tools/libxl/libxl_internal.c                 | 19 -------------------
 tools/libxl/libxl_internal.h                 |  1 -
 tools/libxl/libxl_linux.c                    |  7 -------
 tools/libxl/libxl_netbsd.c                   |  7 -------
 12 files changed, 7 insertions(+), 116 deletions(-)
tools/configure +6 -7
index c940dd1..5138f3d 100755
@@ -2403,7 +2403,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
-ac_config_files="$ac_config_files ../config/Tools.mk hotplug/FreeBSD/rc.d/xencommons hotplug/Linux/init.d/sysconfig.xencommons hotplug/Linux/init.d/xen-watchdog hotplug/Linux/init.d/xencommons hotplug/Linux/init.d/xendomains hotplug/Linux/vif-setup hotplug/Linux/xen-backend.rules hotplug/Linux/xen-hotplug-common.sh hotplug/Linux/xendomains hotplug/NetBSD/rc.d/xencommons libxl/xenlight.pc.in libxl/xlutil.pc.in"
+ac_config_files="$ac_config_files ../config/Tools.mk hotplug/FreeBSD/rc.d/xencommons hotplug/Linux/init.d/sysconfig.xencommons hotplug/Linux/init.d/xen-watchdog hotplug/Linux/init.d/xencommons hotplug/Linux/init.d/xendomains hotplug/Linux/vif-setup hotplug/Linux/xen-hotplug-common.sh hotplug/Linux/xendomains hotplug/NetBSD/rc.d/xencommons libxl/xenlight.pc.in libxl/xlutil.pc.in"
 
 ac_config_headers="$ac_config_headers config.h"
 
@@ -3343,7 +3343,7 @@ else
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -3389,7 +3389,7 @@ else
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -3413,7 +3413,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -3458,7 +3458,7 @@ else
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -3482,7 +3482,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -10050,7 +10050,6 @@ do
     "hotplug/Linux/init.d/xencommons") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/init.d/xencommons" ;;
     "hotplug/Linux/init.d/xendomains") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/init.d/xendomains" ;;
     "hotplug/Linux/vif-setup") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/vif-setup" ;;
-    "hotplug/Linux/xen-backend.rules") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/xen-backend.rules" ;;
     "hotplug/Linux/xen-hotplug-common.sh") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/xen-hotplug-common.sh" ;;
     "hotplug/Linux/xendomains") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/xendomains" ;;
     "hotplug/NetBSD/rc.d/xencommons") CONFIG_FILES="$CONFIG_FILES hotplug/NetBSD/rc.d/xencommons" ;;
tools/configure.ac +0 -1
index 2d371f4..8bfdfcb 100644
@@ -13,7 +13,6 @@ hotplug/Linux/init.d/xen-watchdog
 hotplug/Linux/init.d/xencommons
 hotplug/Linux/init.d/xendomains
 hotplug/Linux/vif-setup
-hotplug/Linux/xen-backend.rules
 hotplug/Linux/xen-hotplug-common.sh
 hotplug/Linux/xendomains
 hotplug/NetBSD/rc.d/xencommons
tools/examples/README +0 -1
index 115ca02..13380a4 100644
@@ -24,7 +24,6 @@ vif-nat             - xen virtual network start/stop script in NAT mode
 vif-route           - xen virtual network start/stop script in routed mode
 xen-backend.agent   - calls block, vif-* scripts to add, remove, hotplug
                       devices  
-xen-backend.rules   - hotplug script rules
 xen-hotplug-common.sh - sourced by vif-common.sh
 xen-network-common.sh - sourced by vif-common.sh
 xen-script-common.sh  - sourced by xen-hotplug-common.sh
tools/hotplug/Linux/Makefile +1 -13
index d94a9cb..8bb2316 100644
@@ -32,9 +32,6 @@ XEN_SCRIPT_DATA = xen-script-common.sh locking.sh logging.sh
 XEN_SCRIPT_DATA += xen-hotplug-common.sh xen-network-common.sh vif-common.sh
 XEN_SCRIPT_DATA += block-common.sh
 
-UDEV_RULES_DIR = $(CONFIG_DIR)/udev
-UDEV_RULES = xen-backend.rules $(UDEV_RULES-y)
-
 .PHONY: all
 all: subdirs-all
 
@@ -42,7 +39,7 @@ all: subdirs-all
 build:
 
 .PHONY: install
-install: install-initd install-scripts install-udev subdirs-install
+install: install-initd install-scripts subdirs-install
 
 # See docs/misc/distro_mapping.txt for INITD_DIR location
 .PHONY: install-initd
@@ -70,15 +67,6 @@ install-scripts:
 	    $(INSTALL_DATA) $$i $(DESTDIR)$(XEN_SCRIPT_DIR); \
 	done
 
-.PHONY: install-udev
-install-udev:
-	[ -d $(DESTDIR)$(UDEV_RULES_DIR) ] || \
-		$(INSTALL_DIR) $(DESTDIR)$(UDEV_RULES_DIR)/rules.d
-	set -e; for i in $(UDEV_RULES); \
-	    do \
-	    $(INSTALL_DATA) $$i $(DESTDIR)$(UDEV_RULES_DIR)/rules.d; \
-	done
-
 .PHONY: clean
 clean: subdirs-clean
 
tools/hotplug/Linux/xen-backend.rules.in deleted +0 -13
deleted file mode 100644
index ee107af..0000000
@@ -1,13 +0,0 @@
-SUBSYSTEM=="xen-backend", KERNEL=="vbd*", ENV{UDEV_CALL}="1", RUN+="@XEN_SCRIPT_DIR@/block $env{ACTION}"
-SUBSYSTEM=="xen-backend", KERNEL=="vif2-*", RUN+="@XEN_SCRIPT_DIR@/vif2 $env{ACTION}"
-SUBSYSTEM=="xen-backend", KERNEL=="vif-*", ENV{UDEV_CALL}="1", ACTION=="online", RUN+="@XEN_SCRIPT_DIR@/vif-setup online type_if=vif"
-SUBSYSTEM=="xen-backend", KERNEL=="vif-*", ENV{UDEV_CALL}="1", ACTION=="offline", RUN+="@XEN_SCRIPT_DIR@/vif-setup offline type_if=vif"
-SUBSYSTEM=="xen-backend", KERNEL=="vscsi*", RUN+="@XEN_SCRIPT_DIR@/vscsi $env{ACTION}"
-SUBSYSTEM=="xen-backend", ACTION=="remove", ENV{UDEV_CALL}="1", RUN+="@XEN_SCRIPT_DIR@/xen-hotplug-cleanup"
-KERNEL=="evtchn", NAME="xen/%k"
-SUBSYSTEM=="blktap2", KERNEL=="blktap[0-9]*", NAME="xen/blktap-2/%k", MODE="0600"
-KERNEL=="blktap-control", NAME="xen/blktap-2/control", MODE="0600"
-KERNEL=="gntdev", NAME="xen/%k", MODE="0600"
-KERNEL=="pci_iomul", NAME="xen/%k", MODE="0600"
-KERNEL=="tapdev[a-z]*", NAME="xen/blktap-2/tapdev%m", MODE="0600"
-SUBSYSTEM=="net", KERNEL=="vif*-emu", ACTION=="add", ENV{UDEV_CALL}="1", RUN+="@XEN_SCRIPT_DIR@/vif-setup $env{ACTION} type_if=tap"
tools/hotplug/Linux/xen-hotplug-common.sh.in +0 -7
index 40b933e..afb240f 100644
@@ -15,13 +15,6 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #
 
-# Hack to prevent the execution of hotplug scripts from udev if the domain
-# has been launched from libxl
-if [ -n "${UDEV_CALL}" ] && \
-   xenstore-read "libxl/disable_udev" >/dev/null 2>&1; then
-    exit 0
-fi
-
 dir=$(dirname "$0")
 . "$dir/hotplugpath.sh"
 . "$dir/logging.sh"
tools/libxl/libxl.c +0 -13
index 92563db..3a83903 100644
@@ -3211,7 +3211,6 @@ out:
 int libxl__device_nic_setdefault(libxl__gc *gc, libxl_device_nic *nic,
                                  uint32_t domid)
 {
-    int run_hotplug_scripts;
     int rc;
 
     if (!nic->mtu)
@@ -3242,12 +3241,6 @@ int libxl__device_nic_setdefault(libxl__gc *gc, libxl_device_nic *nic,
                                   libxl__xen_script_dir_path()) < 0 )
         return ERROR_FAIL;
 
-    run_hotplug_scripts = libxl__hotplug_settings(gc, XBT_NULL);
-    if (run_hotplug_scripts < 0) {
-        LOG(ERROR, "unable to get current hotplug scripts execution setting");
-        return run_hotplug_scripts;
-    }
-
     rc = libxl__resolve_domid(gc, nic->backend_domname, &nic->backend_domid);
     if (rc < 0) return rc;
 
@@ -4550,12 +4543,6 @@ int libxl_device_events_handler(libxl_ctx *ctx,
         goto out;
     }
 
-    rc = libxl__xs_write_checked(gc, XBT_NULL, DISABLE_UDEV_PATH, "1");
-    if (rc) {
-        LOGE(ERROR, "unable to write %s = 1", DISABLE_UDEV_PATH);
-        goto out;
-    }
-
     /*
      * We use absolute paths because we want xswatch to also return
      * absolute paths that can be parsed by libxl__parse_backend_path.
tools/libxl/libxl_create.c +0 -27
index f799081..9c2303c 100644
@@ -682,33 +682,6 @@ retry_transaction:
         goto out;
     }
     libxl_vminfo_list_free(vm_list, nb_vm);
-    int hotplug_setting = libxl__hotplug_settings(gc, t);
-    if (hotplug_setting < 0) {
-        LOG(ERROR, "unable to get current hotplug scripts execution setting");
-        rc = ERROR_FAIL;
-        goto out;
-    }
-    if (libxl_defbool_val(info->run_hotplug_scripts) != hotplug_setting &&
-        (nb_vm - 1)) {
-        LOG(ERROR, "cannot change hotplug execution option once set, "
-                    "please shutdown all guests before changing it");
-        rc = ERROR_FAIL;
-        goto out;
-    }
-
-    if (libxl_defbool_val(info->run_hotplug_scripts)) {
-        rc = libxl__xs_write_checked(gc, t, DISABLE_UDEV_PATH, "1");
-        if (rc) {
-            LOGE(ERROR, "unable to write %s = 1", DISABLE_UDEV_PATH);
-            goto out;
-        }
-    } else {
-        rc = libxl__xs_rm_checked(gc, t, DISABLE_UDEV_PATH);
-        if (rc) {
-            LOGE(ERROR, "unable to delete %s", DISABLE_UDEV_PATH);
-            goto out;
-        }
-    }
 
     xs_write(ctx->xsh, t, libxl__sprintf(gc, "%s/uuid", vm_path), uuid_string, strlen(uuid_string));
     xs_write(ctx->xsh, t, libxl__sprintf(gc, "%s/name", vm_path), info->name, strlen(info->name));
tools/libxl/libxl_internal.c +0 -19
index c2c67bd..42d548e 100644
@@ -376,25 +376,6 @@ int libxl__device_model_version_running(libxl__gc *gc, uint32_t domid)
     return value;
 }
 
-int libxl__hotplug_settings(libxl__gc *gc, xs_transaction_t t)
-{
-    int rc = 0;
-    char *val;
-
-    val = libxl__xs_read(gc, t, DISABLE_UDEV_PATH);
-    if (!val && errno != ENOENT) {
-        LOGE(ERROR, "cannot read %s from xenstore", DISABLE_UDEV_PATH);
-        rc = ERROR_FAIL;
-        goto out;
-    }
-    if (!val) val = "0";
-
-    rc = !!atoi(val);
-
-out:
-    return rc;
-}
-
 /* Portability note: this lock utilises flock(2) so a proper implementation of
  * flock(2) is required.
  */
tools/libxl/libxl_internal.h +0 -1
index d52589e..7129aee 100644
@@ -104,7 +104,6 @@
 #define STUBDOM_CONSOLE_SERIAL 3
 #define STUBDOM_SPECIAL_CONSOLES 3
 #define TAP_DEVICE_SUFFIX "-emu"
-#define DISABLE_UDEV_PATH "libxl/disable_udev"
 #define DOMID_XS_PATH "domid"
 
 #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
tools/libxl/libxl_linux.c +0 -7
index f42a89a..512d2c9 100644
@@ -236,15 +236,8 @@ int libxl__get_hotplug_script_info(libxl__gc *gc, libxl__device *dev,
                                    libxl__device_action action,
                                    int num_exec)
 {
-    char *disable_udev = libxl__xs_read(gc, XBT_NULL, DISABLE_UDEV_PATH);
     int rc;
 
-    /* Check if we have to run hotplug scripts */
-    if (!disable_udev) {
-        rc = 0;
-        goto out;
-    }
-
     switch (dev->backend_kind) {
     case LIBXL__DEVICE_KIND_VBD:
         if (num_exec != 0) {
tools/libxl/libxl_netbsd.c +0 -7
index a2a962e..096c057 100644
@@ -64,15 +64,8 @@ int libxl__get_hotplug_script_info(libxl__gc *gc, libxl__device *dev,
                                    libxl__device_action action,
                                    int num_exec)
 {
-    char *disable_udev = libxl__xs_read(gc, XBT_NULL, DISABLE_UDEV_PATH);
     int rc;
 
-    /* Check if we have to run hotplug scripts */
-    if (!disable_udev || num_exec > 0) {
-        rc = 0;
-        goto out;
-    }
-
     switch (dev->backend_kind) {
     case LIBXL__DEVICE_KIND_VBD:
     case LIBXL__DEVICE_KIND_VIF:
Signature · 1 line
1.9.1
Acked-by on v1 2/6
#3 lore raw

Re: [PATCH 2/6] libxl: Remove linux udev rules

Quoted 9 lines · George Dunlap

They are no longer needed, having been replaced by a daemon for driverdomains which will run scripts as necessary.

Worse yet, they seem to be broken for script-based block devices, such as block-iscsi. This wouldn't matter so much if they were never run by default; but if you run block-attach without having created a domain, then the appropriate node to disable running udev scripts will not have been written yet, and the attach will silently fail.

Quoted 6 lines

Rather than try to sort out that issue, just remove them entirely.

Note: This changes tools/configure.ac, so autogen.sh may need to be re-run.

Quoted 10 lines

---
CC: Ian Campbell <[email protected]>
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monne <[email protected]>

There was some concern that old udev scripts may end up lying around in /etc which will still trigger and run unless libxl/disable_udev exists.

It's certainly not making things worse, right?

I think it's user's responsibility to make sure the installation is clean. It's the same as he / she should avoid having stale libraries around.

Quoted 5 lines

If that's a concern, then for one release we might consider writing libxl/disable_udev manually in xencommons or something to make sure that they don't trigger.

---
 tools/configure                              | 13 ++++++-------

[...]

Quoted 18 lines
     }
     libxl_vminfo_list_free(vm_list, nb_vm);
tools/libxl/libxl_create.c +0 -16
-    int hotplug_setting = libxl__hotplug_settings(gc, t);
-    if (hotplug_setting < 0) {
-        LOG(ERROR, "unable to get current hotplug scripts execution setting");
-        rc = ERROR_FAIL;
-        goto out;
-    }
-    if (libxl_defbool_val(info->run_hotplug_scripts) != hotplug_setting &&
-        (nb_vm - 1)) {
-        LOG(ERROR, "cannot change hotplug execution option once set, "
-                    "please shutdown all guests before changing it");
-        rc = ERROR_FAIL;
-        goto out;
-    }
-
-    if (libxl_defbool_val(info->run_hotplug_scripts)) {
-        rc = libxl__xs_write_checked(gc, t, DISABLE_UDEV_PATH, "1");

tools/libxl/libxl_create.c retry_transaction: · line 710

Quoted 10 lines
tools/libxl/libxl_create.c +0 -10
-        if (rc) {
-            LOGE(ERROR, "unable to write %s = 1", DISABLE_UDEV_PATH);
-            goto out;
-        }
-    } else {
-        rc = libxl__xs_rm_checked(gc, t, DISABLE_UDEV_PATH);
-        if (rc) {
-            LOGE(ERROR, "unable to delete %s", DISABLE_UDEV_PATH);
-            goto out;
-        }

Heh, looks like this is buggy as it is -- every guest shares the same node. I.e. if a guest has run_hotplug_script in xl config file it can overwrite that node easily.

Wei.

#4 lore raw

Re: [PATCH 2/6] libxl: Remove linux udev rules

Quoted 3 lines · Wei Liu
Quoted 2 lines · George Dunlap

They are no longer needed, having been replaced by a daemon for driverdomains which will run scripts as necessary.

This introduces an regression. The 'daemon for driverdomains' is xenbackendd - which only gets built for NetBSD.

That means we can't do Linux driver domains anymore with this patch.

Quoted 78 lines
Quoted 7 lines

Worse yet, they seem to be broken for script-based block devices, such as block-iscsi. This wouldn't matter so much if they were never run by default; but if you run block-attach without having created a domain, then the appropriate node to disable running udev scripts will not have been written yet, and the attach will silently fail.

Quoted 6 lines

Rather than try to sort out that issue, just remove them entirely.

Note: This changes tools/configure.ac, so autogen.sh may need to be re-run.

Quoted 10 lines

---
CC: Ian Campbell <[email protected]>
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monne <[email protected]>

There was some concern that old udev scripts may end up lying around in /etc which will still trigger and run unless libxl/disable_udev exists.

It's certainly not making things worse, right?

I think it's user's responsibility to make sure the installation is clean. It's the same as he / she should avoid having stale libraries around.

Quoted 5 lines

If that's a concern, then for one release we might consider writing libxl/disable_udev manually in xencommons or something to make sure that they don't trigger.

---
 tools/configure                              | 13 ++++++-------

[...]

Quoted 18 lines
     }
     libxl_vminfo_list_free(vm_list, nb_vm);
tools/libxl/libxl_create.c +0 -16
-    int hotplug_setting = libxl__hotplug_settings(gc, t);
-    if (hotplug_setting < 0) {
-        LOG(ERROR, "unable to get current hotplug scripts execution setting");
-        rc = ERROR_FAIL;
-        goto out;
-    }
-    if (libxl_defbool_val(info->run_hotplug_scripts) != hotplug_setting &&
-        (nb_vm - 1)) {
-        LOG(ERROR, "cannot change hotplug execution option once set, "
-                    "please shutdown all guests before changing it");
-        rc = ERROR_FAIL;
-        goto out;
-    }
-
-    if (libxl_defbool_val(info->run_hotplug_scripts)) {
-        rc = libxl__xs_write_checked(gc, t, DISABLE_UDEV_PATH, "1");

tools/libxl/libxl_create.c retry_transaction: · line 710

Quoted 10 lines
tools/libxl/libxl_create.c +0 -10
-        if (rc) {
-            LOGE(ERROR, "unable to write %s = 1", DISABLE_UDEV_PATH);
-            goto out;
-        }
-    } else {
-        rc = libxl__xs_rm_checked(gc, t, DISABLE_UDEV_PATH);
-        if (rc) {
-            LOGE(ERROR, "unable to delete %s", DISABLE_UDEV_PATH);
-            goto out;
-        }

Heh, looks like this is buggy as it is -- every guest shares the same node. I.e. if a guest has run_hotplug_script in xl config file it can overwrite that node easily.

Wei.

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

#5 lore raw

Re: [PATCH 2/6] libxl: Remove linux udev rules

Quoted 7 lines · Konrad Rzeszutek Wilk
Quoted 3 lines · Wei Liu
Quoted 2 lines · George Dunlap

They are no longer needed, having been replaced by a daemon for driverdomains which will run scripts as necessary.

This introduces an regression. The 'daemon for driverdomains' is xenbackendd - which only gets built for NetBSD.

It's not (any more), it's "xl devd", which should be built everywhere.

One thing which is missing is an initscript to launch this, it probably wants to be a new xendriverdomain or something since dom0 doesn't need this so xencommons would be wrong.

Ian.

#6 lore raw

Re: [PATCH 2/6] libxl: Remove linux udev rules

Quoted 10 lines · Ian Campbell
Quoted 7 lines · Konrad Rzeszutek Wilk
Quoted 3 lines · Wei Liu
Quoted 2 lines · George Dunlap

They are no longer needed, having been replaced by a daemon for driverdomains which will run scripts as necessary.

This introduces an regression. The 'daemon for driverdomains' is xenbackendd - which only gets built for NetBSD.

It's not (any more), it's "xl devd", which should be built everywhere.

Aha! I knew I'd seen it somewhere.

In that case, do we actually still need xenbackendd? Or does xenbackendd do something slightly different?

Quoted 3 lines

One thing which is missing is an initscript to launch this, it probably wants to be a new xendriverdomain or something since dom0 doesn't need this so xencommons would be wrong.

...and xencommons starts a bunch of things which should *not* be in driver domains, like xenstored, xenconsoled, &c.

-George

#7 lore raw

Re: [PATCH 2/6] libxl: Remove linux udev rules

Quoted 10 lines · George Dunlap
Quoted 9 lines · Ian Campbell
Quoted 7 lines · Konrad Rzeszutek Wilk
Quoted 3 lines · Wei Liu
Quoted 2 lines · George Dunlap

They are no longer needed, having been replaced by a daemon for driverdomains which will run scripts as necessary.

This introduces an regression. The 'daemon for driverdomains' is xenbackendd - which only gets built for NetBSD.

Quoted 7 lines
Quoted 1 line

It's not (any more), it's "xl devd", which should be built everywhere.

Aha! I knew I'd seen it somewhere.

In that case, do we actually still need xenbackendd? Or does xenbackendd do something slightly different?

That's NetBSD-only thing as far as I remember. Not sure if what it does is NetBSD specific.

Wei.

#8 lore raw

Re: [PATCH 2/6] libxl: Remove linux udev rules

Quoted 13 lines · Wei Liu
Quoted 12 lines · George Dunlap
Quoted 10 lines · Ian Campbell
Quoted 7 lines · Konrad Rzeszutek Wilk
Quoted 3 lines · Wei Liu
Quoted 2 lines · George Dunlap

They are no longer needed, having been replaced by a daemon for driverdomains which will run scripts as necessary.

This introduces an regression. The 'daemon for driverdomains' is xenbackendd - which only gets built for NetBSD.

It's not (any more), it's "xl devd", which should be built everywhere.

Quoted 8 lines
Quoted 5 lines

Aha! I knew I'd seen it somewhere.

In that case, do we actually still need xenbackendd? Or does xenbackendd do something slightly different?

That's NetBSD-only thing as far as I remember. Not sure if what it does is NetBSD specific.

My understanding was it had been subsumed by "xl devd", but I don't know why it hasn't been removed. Probably best to wait until Roger is back...

Ian.

#9 lore raw

Re: [PATCH 2/6] libxl: Remove linux udev rules

El 14/07/15 a les 18.48, Ian Campbell ha escrit:

Quoted 20 lines · Wei Liu
Quoted 19 lines · George Dunlap
Quoted 17 lines · Ian Campbell
Quoted 10 lines · Konrad Rzeszutek Wilk
Quoted 7 lines · Wei Liu
Quoted 3 lines · George Dunlap
Quoted 2 lines

They are no longer needed, having been replaced by a daemon for driverdomains which will run scripts as necessary.

This introduces an regression. The 'daemon for driverdomains' is xenbackendd - which only gets built for NetBSD.

It's not (any more), it's "xl devd", which should be built everywhere.

Aha! I knew I'd seen it somewhere.

In that case, do we actually still need xenbackendd? Or does xenbackendd do something slightly different?

Quoted 5 lines
Quoted 2 lines

That's NetBSD-only thing as far as I remember. Not sure if what it does is NetBSD specific.

My understanding was it had been subsumed by "xl devd", but I don't know why it hasn't been removed. Probably best to wait until Roger is back...

Some time ago I proposed to the NetBSD folks to remove xenbackendd, because I think it's useless now, but the reply was to leave it as is:

http://mail-index.netbsd.org/port-xen/2015/01/29/msg008483.html

Roger.

#10 lore raw

Re: [PATCH 2/6] libxl: Remove linux udev rules

Quoted 35 lines · Roger Pau Monné

El 14/07/15 a les 18.48, Ian Campbell ha escrit:

Quoted 25 lines · Wei Liu
Quoted 24 lines · George Dunlap
Quoted 22 lines · Ian Campbell
Quoted 9 lines
Quoted 7 lines · Konrad Rzeszutek Wilk
Quoted 5 lines · Wei Liu
Quoted 3 lines · George Dunlap

They are no longer needed, having been replaced by a daemon for
driverdomains which will run scripts as necessary.

Quoted 6 lines
Quoted 3 lines

This introduces an regression. The 'daemon for driverdomains'
is xenbackendd - which only gets built for NetBSD.

It's not (any more), it's "xl devd", which should be built everywhere.

Aha! I knew I'd seen it somewhere.

In that case, do we actually still need xenbackendd? Or does xenbackendd do something slightly different?

Quoted 8 lines
Quoted 3 lines

That's NetBSD-only thing as far as I remember. Not sure if what it does
is NetBSD specific.

My understanding was it had been subsumed by "xl devd", but I don't know
why it hasn't been removed. Probably best to wait until Roger is back...

Quoted 5 lines

Some time ago I proposed to the NetBSD folks to remove xenbackendd, because I think it's useless now, but the reply was to leave it as is:

http://mail-index.netbsd.org/port-xen/2015/01/29/msg008483.html

It's redundant with "xl devd", I don't see any reason for use to continue carrying it in xen.git. If xl devd has some short coming relative to xenbackendd then we should address that. But otherwise if folks want to keep xenbackend despite it having been replaced then they can carry the patch IMHO.

Ian.

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

#11 lore raw

PATCH 1/1 tools/hotplug: Add an initscript to start "xl devd" in a driver domain

In reply to Ian Campbell

The removal of the udev rules highlighted that although it has been replaced by "xl devd" there isn't an initscript to replace it.

To enable this add a --pidfile option to xl devd.

Tested on Linux by running the script in dom0 and checking the daemon was started/stopped, but not in an actual driver domain environment since I don't have one conveniently available. I also checked that running without the --pidfile option still works.

Scripts mainly cribbed from the xencommons for each platform.

Cc Roger Pau Monné <[email protected]>
Cc Konrad Rzeszutek Wilk <[email protected]>
Cc George Dunlap <[email protected]>

---
For 4.6: I think having removed the udev rules we ought to include this, it's basically zero risk to normal operation.

Nothing seems to start xl devd for domain 0 in *BSD, nor is xenbackend started. Is that correct?

---
 .gitignore                                    |  3 ++
 tools/configure                               |  5 +-
 tools/configure.ac                            |  3 ++
 tools/hotplug/FreeBSD/Makefile                |  2 +-
 tools/hotplug/FreeBSD/rc.d/xendriverdomain.in | 48 +++++++++++++++++
 tools/hotplug/Linux/Makefile                  |  3 ++
 tools/hotplug/Linux/init.d/xendriverdomain.in | 77 +++++++++++++++++++++++++++
 tools/hotplug/NetBSD/Makefile                 |  2 +-
 tools/hotplug/NetBSD/rc.d/xendriverdomain.in  | 49 +++++++++++++++++
 tools/libxl/xl_cmdimpl.c                      | 42 +++++++++++++--
 tools/libxl/xl_cmdtable.c                     |  3 +-
 11 files changed, 229 insertions(+), 8 deletions(-)
 create mode 100644 tools/hotplug/FreeBSD/rc.d/xendriverdomain.in
 create mode 100644 tools/hotplug/Linux/init.d/xendriverdomain.in
 create mode 100644 tools/hotplug/NetBSD/rc.d/xendriverdomain.in
.gitignore +3 -0
index 3f42ded..bab67e7 100644
@@ -133,10 +133,12 @@ tools/flask/utils/flask-set-bool
 tools/flask/utils/flask-label-pci
 tools/hotplug/common/hotplugpath.sh
 tools/hotplug/FreeBSD/rc.d/xencommons
+tools/hotplug/FreeBSD/rc.d/xendriverdomain
 tools/hotplug/Linux/init.d/sysconfig.xencommons
 tools/hotplug/Linux/init.d/xen-watchdog
 tools/hotplug/Linux/init.d/xencommons
 tools/hotplug/Linux/init.d/xendomains
+tools/hotplug/Linux/init.d/xendriverdomain
 tools/hotplug/Linux/systemd/*.conf
 tools/hotplug/Linux/systemd/*.mount
 tools/hotplug/Linux/systemd/*.socket
@@ -146,6 +148,7 @@ tools/hotplug/Linux/xen-backend.rules
 tools/hotplug/Linux/xen-hotplug-common.sh
 tools/hotplug/Linux/xendomains
 tools/hotplug/NetBSD/rc.d/xencommons
+tools/hotplug/NetBSD/rc.d/xendriverdomain
 tools/include/xen/*
 tools/include/xen-xsm/*
 tools/include/xen-foreign/*.(c|h|size)
tools/configure +4 -1
index 5138f3d..d90db47 100755
@@ -2403,7 +2403,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
-ac_config_files="$ac_config_files ../config/Tools.mk hotplug/FreeBSD/rc.d/xencommons hotplug/Linux/init.d/sysconfig.xencommons hotplug/Linux/init.d/xen-watchdog hotplug/Linux/init.d/xencommons hotplug/Linux/init.d/xendomains hotplug/Linux/vif-setup hotplug/Linux/xen-hotplug-common.sh hotplug/Linux/xendomains hotplug/NetBSD/rc.d/xencommons libxl/xenlight.pc.in libxl/xlutil.pc.in"
+ac_config_files="$ac_config_files ../config/Tools.mk hotplug/FreeBSD/rc.d/xencommons hotplug/FreeBSD/rc.d/xendriverdomain hotplug/Linux/init.d/sysconfig.xencommons hotplug/Linux/init.d/xen-watchdog hotplug/Linux/init.d/xencommons hotplug/Linux/init.d/xendomains hotplug/Linux/init.d/xendriverdomain hotplug/Linux/vif-setup hotplug/Linux/xen-hotplug-common.sh hotplug/Linux/xendomains hotplug/NetBSD/rc.d/xencommons hotplug/NetBSD/rc.d/xendriverdomain libxl/xenlight.pc.in libxl/xlutil.pc.in"
 
 ac_config_headers="$ac_config_headers config.h"
 
@@ -10045,14 +10045,17 @@ do
   case $ac_config_target in
     "../config/Tools.mk") CONFIG_FILES="$CONFIG_FILES ../config/Tools.mk" ;;
     "hotplug/FreeBSD/rc.d/xencommons") CONFIG_FILES="$CONFIG_FILES hotplug/FreeBSD/rc.d/xencommons" ;;
+    "hotplug/FreeBSD/rc.d/xendriverdomain") CONFIG_FILES="$CONFIG_FILES hotplug/FreeBSD/rc.d/xendriverdomain" ;;
     "hotplug/Linux/init.d/sysconfig.xencommons") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/init.d/sysconfig.xencommons" ;;
     "hotplug/Linux/init.d/xen-watchdog") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/init.d/xen-watchdog" ;;
     "hotplug/Linux/init.d/xencommons") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/init.d/xencommons" ;;
     "hotplug/Linux/init.d/xendomains") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/init.d/xendomains" ;;
+    "hotplug/Linux/init.d/xendriverdomain") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/init.d/xendriverdomain" ;;
     "hotplug/Linux/vif-setup") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/vif-setup" ;;
     "hotplug/Linux/xen-hotplug-common.sh") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/xen-hotplug-common.sh" ;;
     "hotplug/Linux/xendomains") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/xendomains" ;;
     "hotplug/NetBSD/rc.d/xencommons") CONFIG_FILES="$CONFIG_FILES hotplug/NetBSD/rc.d/xencommons" ;;
+    "hotplug/NetBSD/rc.d/xendriverdomain") CONFIG_FILES="$CONFIG_FILES hotplug/NetBSD/rc.d/xendriverdomain" ;;
     "libxl/xenlight.pc.in") CONFIG_FILES="$CONFIG_FILES libxl/xenlight.pc.in" ;;
     "libxl/xlutil.pc.in") CONFIG_FILES="$CONFIG_FILES libxl/xlutil.pc.in" ;;
     "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
tools/configure.ac +3 -0
index 8bfdfcb..f6a79c2 100644
@@ -8,14 +8,17 @@ AC_CONFIG_SRCDIR([libxl/libxl.c])
 AC_CONFIG_FILES([
 ../config/Tools.mk
 hotplug/FreeBSD/rc.d/xencommons
+hotplug/FreeBSD/rc.d/xendriverdomain
 hotplug/Linux/init.d/sysconfig.xencommons
 hotplug/Linux/init.d/xen-watchdog
 hotplug/Linux/init.d/xencommons
 hotplug/Linux/init.d/xendomains
+hotplug/Linux/init.d/xendriverdomain
 hotplug/Linux/vif-setup
 hotplug/Linux/xen-hotplug-common.sh
 hotplug/Linux/xendomains
 hotplug/NetBSD/rc.d/xencommons
+hotplug/NetBSD/rc.d/xendriverdomain
 libxl/xenlight.pc.in
 libxl/xlutil.pc.in
 ])
tools/hotplug/FreeBSD/Makefile +1 -1
index 8dfc90a..10fce4f 100644
@@ -6,7 +6,7 @@ XEN_SCRIPTS = vif-bridge
 
 XEN_SCRIPT_DATA =
 
-XEN_RCD_PROG = rc.d/xencommons
+XEN_RCD_PROG = rc.d/xencommons rc.d/xendriverdomain
 
 .PHONY: all
 all:
tools/hotplug/FreeBSD/rc.d/xendriverdomain.in new file +48 -0

48 lines not on this page · raw message

tools/hotplug/Linux/Makefile +3 -0
index bc8ee5e..6e10118 100644
@@ -9,6 +9,8 @@ XENDOMAINS_SYSCONFIG = init.d/sysconfig.xendomains
 XENCOMMONS_INITD = init.d/xencommons
 XENCOMMONS_SYSCONFIG = init.d/sysconfig.xencommons
 
+XENDRIVERDOMAIN_INITD = init.d/xendriverdomain
+
 # Xen script dir and scripts to go there.
 XEN_SCRIPTS = vif-bridge
 XEN_SCRIPTS += vif-route
@@ -53,6 +55,7 @@ install-initd:
 	$(INSTALL_DATA) $(XENDOMAINS_SYSCONFIG) $(DESTDIR)$(SYSCONFIG_DIR)/xendomains
 	$(INSTALL_PROG) $(XENCOMMONS_INITD) $(DESTDIR)$(INITD_DIR)
 	$(INSTALL_DATA) $(XENCOMMONS_SYSCONFIG) $(DESTDIR)$(SYSCONFIG_DIR)/xencommons
+	$(INSTALL_PROG) $(XENDRIVERDOMAIN_INITD) $(DESTDIR)$(INITD_DIR)
 	$(INSTALL_PROG) init.d/xen-watchdog $(DESTDIR)$(INITD_DIR)
 
 .PHONY: install-scripts
tools/hotplug/Linux/init.d/xendriverdomain.in new file +77 -0

77 lines not on this page · raw message

tools/hotplug/NetBSD/Makefile +1 -1
index 4e609e3..d01aabf 100644
@@ -8,7 +8,7 @@ XEN_SCRIPTS += vif-bridge
 XEN_SCRIPTS += vif-ip
 
 XEN_SCRIPT_DATA =
-XEN_RCD_PROG = rc.d/xencommons rc.d/xendomains rc.d/xen-watchdog
+XEN_RCD_PROG = rc.d/xencommons rc.d/xendomains rc.d/xen-watchdog rc.d/xendriverdomain
 
 .PHONY: all
 all:
tools/hotplug/NetBSD/rc.d/xendriverdomain.in new file +49 -0

49 lines not on this page · raw message

tools/libxl/xl_cmdimpl.c +38 -4

73 lines not on this page · raw message

tools/libxl/xl_cmdtable.c +2 -1
index 54dbecc..0071f12 100644
@@ -506,7 +506,8 @@ struct cmd_spec cmd_table[] = {
       &main_devd, 0, 1,
       "Daemon that listens for devices and launches backends",
       "[options]",
-      "-F                      Run in the foreground",
+      "-F                      Run in the foreground.\n"
+      "-p, --pidfile [FILE]    Write PID to pidfile when daemonizing.",
     },
 #ifdef LIBXL_HAVE_PSR_CMT
     { "psr-hwinfo",
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#12 lore raw

Re: [PATCH for-4.6] tools/hotplug: Add an initscript to start "xl devd" in a driver domain

Quoted 22 lines · Ian Campbell

The removal of the udev rules highlighted that although it has been replaced by "xl devd" there isn't an initscript to replace it.

To enable this add a --pidfile option to xl devd.

Tested on Linux by running the script in dom0 and checking the daemon was started/stopped, but not in an actual driver domain environment since I don't have one conveniently available. I also checked that running without the --pidfile option still works.

Scripts mainly cribbed from the xencommons for each platform.

Cc Roger Pau Monné <[email protected]>
Cc Konrad Rzeszutek Wilk <[email protected]>
Cc George Dunlap <[email protected]>

---
For 4.6: I think having removed the udev rules we ought to include this, it's basically zero risk to normal operation.

Nothing seems to start xl devd for domain 0 in *BSD, nor is xenbackend started. Is that correct?

Quoted 12 lines
---
 .gitignore                                    |  3 ++
 tools/configure                               |  5 +-
 tools/configure.ac                            |  3 ++
 tools/hotplug/FreeBSD/Makefile                |  2 +-
 tools/hotplug/FreeBSD/rc.d/xendriverdomain.in | 48 +++++++++++++++++
 tools/hotplug/Linux/Makefile                  |  3 ++
 tools/hotplug/Linux/init.d/xendriverdomain.in | 77 +++++++++++++++++++++++++++
 tools/hotplug/NetBSD/Makefile                 |  2 +-
 tools/hotplug/NetBSD/rc.d/xendriverdomain.in  | 49 +++++++++++++++++
 tools/libxl/xl_cmdimpl.c                      | 42 +++++++++++++--
 tools/libxl/xl_cmdtable.c                     |  3 +-

Systemd unit file is missing.

Wei.

#13 lore raw

Re: [PATCH for-4.6] tools/hotplug: Add an initscript to start "xl devd" in a driver domain

Quoted 36 lines · Wei Liu
Quoted 22 lines · Ian Campbell

The removal of the udev rules highlighted that although it has been replaced by "xl devd" there isn't an initscript to replace it.

To enable this add a --pidfile option to xl devd.

Tested on Linux by running the script in dom0 and checking the daemon was started/stopped, but not in an actual driver domain environment since I don't have one conveniently available. I also checked that running without the --pidfile option still works.

Scripts mainly cribbed from the xencommons for each platform.

Cc Roger Pau Monné <[email protected]>
Cc Konrad Rzeszutek Wilk <[email protected]>
Cc George Dunlap <[email protected]>

---
For 4.6: I think having removed the udev rules we ought to include this, it's basically zero risk to normal operation.

Nothing seems to start xl devd for domain 0 in *BSD, nor is xenbackend started. Is that correct?

Quoted 12 lines
---
 .gitignore                                    |  3 ++
 tools/configure                               |  5 +-
 tools/configure.ac                            |  3 ++
 tools/hotplug/FreeBSD/Makefile                |  2 +-
 tools/hotplug/FreeBSD/rc.d/xendriverdomain.in | 48 +++++++++++++++++
 tools/hotplug/Linux/Makefile                  |  3 ++
 tools/hotplug/Linux/init.d/xendriverdomain.in | 77 +++++++++++++++++++++++++++
 tools/hotplug/NetBSD/Makefile                 |  2 +-
 tools/hotplug/NetBSD/rc.d/xendriverdomain.in  | 49 +++++++++++++++++
 tools/libxl/xl_cmdimpl.c                      | 42 +++++++++++++--
 tools/libxl/xl_cmdtable.c                     |  3 +-
Quoted 1 line

Systemd unit file is missing.

Yes, it is.

I don't think it matters, systemd is supposed to have support for "legacy" init scripts and this one is simple enough IMHO to not need any of the special sauce that a unit would give.

If some systemd person wants to add a unit file then they can do so.

Ian.

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

author Acked-by on v1 1/1
#14 lore raw

Re: [PATCH for-4.6] tools/hotplug: Add an initscript to start "xl devd" in a driver domain

In reply to Ian Campbell
Quoted 10 lines · Ian Campbell

The removal of the udev rules highlighted that although it has been replaced by "xl devd" there isn't an initscript to replace it.

To enable this add a --pidfile option to xl devd.

Tested on Linux by running the script in dom0 and checking the daemon was started/stopped, but not in an actual driver domain environment since I don't have one conveniently available. I also checked that running without the --pidfile option still works.

Quoted 6 lines

Scripts mainly cribbed from the xencommons for each platform.

Cc Roger Pau Monné <[email protected]>
Cc Konrad Rzeszutek Wilk <[email protected]>
Cc George Dunlap <[email protected]>

Looks OK to me:

Quoted 427 lines

---
For 4.6: I think having removed the udev rules we ought to include this, it's basically zero risk to normal operation.

Nothing seems to start xl devd for domain 0 in *BSD, nor is xenbackend started. Is that correct?

---
 .gitignore                                    |  3 ++
 tools/configure                               |  5 +-
 tools/configure.ac                            |  3 ++
 tools/hotplug/FreeBSD/Makefile                |  2 +-
 tools/hotplug/FreeBSD/rc.d/xendriverdomain.in | 48 +++++++++++++++++
 tools/hotplug/Linux/Makefile                  |  3 ++
 tools/hotplug/Linux/init.d/xendriverdomain.in | 77 +++++++++++++++++++++++++++
 tools/hotplug/NetBSD/Makefile                 |  2 +-
 tools/hotplug/NetBSD/rc.d/xendriverdomain.in  | 49 +++++++++++++++++
 tools/libxl/xl_cmdimpl.c                      | 42 +++++++++++++--
 tools/libxl/xl_cmdtable.c                     |  3 +-
 11 files changed, 229 insertions(+), 8 deletions(-)
 create mode 100644 tools/hotplug/FreeBSD/rc.d/xendriverdomain.in
 create mode 100644 tools/hotplug/Linux/init.d/xendriverdomain.in
 create mode 100644 tools/hotplug/NetBSD/rc.d/xendriverdomain.in
.gitignore +3 -0
index 3f42ded..bab67e7 100644
@@ -133,10 +133,12 @@ tools/flask/utils/flask-set-bool
 tools/flask/utils/flask-label-pci
 tools/hotplug/common/hotplugpath.sh
 tools/hotplug/FreeBSD/rc.d/xencommons
+tools/hotplug/FreeBSD/rc.d/xendriverdomain
 tools/hotplug/Linux/init.d/sysconfig.xencommons
 tools/hotplug/Linux/init.d/xen-watchdog
 tools/hotplug/Linux/init.d/xencommons
 tools/hotplug/Linux/init.d/xendomains
+tools/hotplug/Linux/init.d/xendriverdomain
 tools/hotplug/Linux/systemd/*.conf
 tools/hotplug/Linux/systemd/*.mount
 tools/hotplug/Linux/systemd/*.socket
@@ -146,6 +148,7 @@ tools/hotplug/Linux/xen-backend.rules
 tools/hotplug/Linux/xen-hotplug-common.sh
 tools/hotplug/Linux/xendomains
 tools/hotplug/NetBSD/rc.d/xencommons
+tools/hotplug/NetBSD/rc.d/xendriverdomain
 tools/include/xen/*
 tools/include/xen-xsm/*
 tools/include/xen-foreign/*.(c|h|size)
tools/configure +4 -1
index 5138f3d..d90db47 100755
@@ -2403,7 +2403,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
-ac_config_files="$ac_config_files ../config/Tools.mk hotplug/FreeBSD/rc.d/xencommons hotplug/Linux/init.d/sysconfig.xencommons hotplug/Linux/init.d/xen-watchdog hotplug/Linux/init.d/xencommons hotplug/Linux/init.d/xendomains hotplug/Linux/vif-setup hotplug/Linux/xen-hotplug-common.sh hotplug/Linux/xendomains hotplug/NetBSD/rc.d/xencommons libxl/xenlight.pc.in libxl/xlutil.pc.in"
+ac_config_files="$ac_config_files ../config/Tools.mk hotplug/FreeBSD/rc.d/xencommons hotplug/FreeBSD/rc.d/xendriverdomain hotplug/Linux/init.d/sysconfig.xencommons hotplug/Linux/init.d/xen-watchdog hotplug/Linux/init.d/xencommons hotplug/Linux/init.d/xendomains hotplug/Linux/init.d/xendriverdomain hotplug/Linux/vif-setup hotplug/Linux/xen-hotplug-common.sh hotplug/Linux/xendomains hotplug/NetBSD/rc.d/xencommons hotplug/NetBSD/rc.d/xendriverdomain libxl/xenlight.pc.in libxl/xlutil.pc.in"
 
 ac_config_headers="$ac_config_headers config.h"
 
@@ -10045,14 +10045,17 @@ do
   case $ac_config_target in
     "../config/Tools.mk") CONFIG_FILES="$CONFIG_FILES ../config/Tools.mk" ;;
     "hotplug/FreeBSD/rc.d/xencommons") CONFIG_FILES="$CONFIG_FILES hotplug/FreeBSD/rc.d/xencommons" ;;
+    "hotplug/FreeBSD/rc.d/xendriverdomain") CONFIG_FILES="$CONFIG_FILES hotplug/FreeBSD/rc.d/xendriverdomain" ;;
     "hotplug/Linux/init.d/sysconfig.xencommons") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/init.d/sysconfig.xencommons" ;;
     "hotplug/Linux/init.d/xen-watchdog") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/init.d/xen-watchdog" ;;
     "hotplug/Linux/init.d/xencommons") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/init.d/xencommons" ;;
     "hotplug/Linux/init.d/xendomains") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/init.d/xendomains" ;;
+    "hotplug/Linux/init.d/xendriverdomain") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/init.d/xendriverdomain" ;;
     "hotplug/Linux/vif-setup") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/vif-setup" ;;
     "hotplug/Linux/xen-hotplug-common.sh") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/xen-hotplug-common.sh" ;;
     "hotplug/Linux/xendomains") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/xendomains" ;;
     "hotplug/NetBSD/rc.d/xencommons") CONFIG_FILES="$CONFIG_FILES hotplug/NetBSD/rc.d/xencommons" ;;
+    "hotplug/NetBSD/rc.d/xendriverdomain") CONFIG_FILES="$CONFIG_FILES hotplug/NetBSD/rc.d/xendriverdomain" ;;
     "libxl/xenlight.pc.in") CONFIG_FILES="$CONFIG_FILES libxl/xenlight.pc.in" ;;
     "libxl/xlutil.pc.in") CONFIG_FILES="$CONFIG_FILES libxl/xlutil.pc.in" ;;
     "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
tools/configure.ac +3 -0
index 8bfdfcb..f6a79c2 100644
@@ -8,14 +8,17 @@ AC_CONFIG_SRCDIR([libxl/libxl.c])
 AC_CONFIG_FILES([
 ../config/Tools.mk
 hotplug/FreeBSD/rc.d/xencommons
+hotplug/FreeBSD/rc.d/xendriverdomain
 hotplug/Linux/init.d/sysconfig.xencommons
 hotplug/Linux/init.d/xen-watchdog
 hotplug/Linux/init.d/xencommons
 hotplug/Linux/init.d/xendomains
+hotplug/Linux/init.d/xendriverdomain
 hotplug/Linux/vif-setup
 hotplug/Linux/xen-hotplug-common.sh
 hotplug/Linux/xendomains
 hotplug/NetBSD/rc.d/xencommons
+hotplug/NetBSD/rc.d/xendriverdomain
 libxl/xenlight.pc.in
 libxl/xlutil.pc.in
 ])
tools/hotplug/FreeBSD/Makefile +1 -1
index 8dfc90a..10fce4f 100644
@@ -6,7 +6,7 @@ XEN_SCRIPTS = vif-bridge
 
 XEN_SCRIPT_DATA =
 
-XEN_RCD_PROG = rc.d/xencommons
+XEN_RCD_PROG = rc.d/xencommons rc.d/xendriverdomain
 
 .PHONY: all
 all:
tools/hotplug/FreeBSD/rc.d/xendriverdomain.in new file +48 -0
new file mode 100644
index 0000000..25e3edd
@@ -0,0 +1,48 @@
+#!/bin/sh
+#
+# PROVIDE: xendriverdomain
+# REQUIRE: DAEMON
+#
+# Should be run in a driver domain, but not in domain 0.
+
+. /etc/rc.subr
+
+. /etc/xen/scripts/hotplugpath.sh
+
+LD_LIBRARY_PATH="${libdir}"
+export LD_LIBRARY_PATH
+
+name="xendriverdomain"
+start_precmd="xendriverdomain_precmd"
+start_cmd="xendriverdomain_startcmd"
+stop_cmd="xendriverdomain_stop"
+extra_commands=""
+
+XLDEVD_PIDFILE="/var/run/xldevd.pid"
+
+xendriverdomain_precmd()
+{
+	:
+}
+
+xendriverdomain_startcmd()
+{
+	printf "Starting xenservices: xl devd."
+
+	${sbindir}/xl devd --pidfile=$XLDEVD_PIDFILE ${XLDEVD_ARGS}
+
+	printf "\n"
+}
+
+xendriverdomain_stop()
+{
+	printf "Stopping xl devd.\n"
+
+	rc_pid=$(check_pidfile ${XLDEVD_PIDFILE} ${sbindir}/xl)
+
+	kill -${sig_stop:-TERM} $rc_pids
+	wait_for_pids $rc_pids
+}
+
+load_rc_config $name
+run_rc_command "$1"
tools/hotplug/Linux/Makefile +3 -0
index bc8ee5e..6e10118 100644
@@ -9,6 +9,8 @@ XENDOMAINS_SYSCONFIG = init.d/sysconfig.xendomains
 XENCOMMONS_INITD = init.d/xencommons
 XENCOMMONS_SYSCONFIG = init.d/sysconfig.xencommons
 
+XENDRIVERDOMAIN_INITD = init.d/xendriverdomain
+
 # Xen script dir and scripts to go there.
 XEN_SCRIPTS = vif-bridge
 XEN_SCRIPTS += vif-route
@@ -53,6 +55,7 @@ install-initd:
 	$(INSTALL_DATA) $(XENDOMAINS_SYSCONFIG) $(DESTDIR)$(SYSCONFIG_DIR)/xendomains
 	$(INSTALL_PROG) $(XENCOMMONS_INITD) $(DESTDIR)$(INITD_DIR)
 	$(INSTALL_DATA) $(XENCOMMONS_SYSCONFIG) $(DESTDIR)$(SYSCONFIG_DIR)/xencommons
+	$(INSTALL_PROG) $(XENDRIVERDOMAIN_INITD) $(DESTDIR)$(INITD_DIR)
 	$(INSTALL_PROG) init.d/xen-watchdog $(DESTDIR)$(INITD_DIR)
 
 .PHONY: install-scripts
tools/hotplug/Linux/init.d/xendriverdomain.in new file +77 -0
new file mode 100644
index 0000000..2ea1113
@@ -0,0 +1,77 @@
+
+#!/bin/bash
+#
+# xendriverdomain    Script to start services needed in a Xen driver domain
+#
+# NOTE: This initscript is not needed on dom0.
+
+# chkconfig: 2345 70 10
+# description: Starts and stops xen driver domain daemon
+### BEGIN INIT INFO
+# Provides:          xendevd
+# Required-Start:    $syslog $remote_fs
+# Should-Start:
+# Required-Stop:     $syslog $remote_fs
+# Should-Stop:
+# Default-Start:     2 3 5
+# Default-Stop:      0 1 6
+# Short-Description: Start/stop xen driver domain daemon
+# Description:       Starts and stops the daemons neeeded for a xen driver domain
+### END INIT INFO
+
+. @XEN_SCRIPT_DIR@/hotplugpath.sh
+
+xendriverdomain_config=@CONFIG_DIR@/@CONFIG_LEAF_DIR@
+
+test -f $xendriverdomain_config/xendriverdomain && . $xendriverdomain_config/xendriverdomain
+
+XLDEVD_PIDFILE=/var/run/xldevd.pid
+
+# not running in Xen dom0 or domU
+if ! test -d /proc/xen ; then
+	exit 0
+fi
+
+# mount xenfs in dom0 or domU with a pv_ops kernel
+if test "x$1" = xstart && \
+   ! test -f /proc/xen/capabilities && \
+   ! grep '^xenfs ' /proc/mounts >/dev/null;
+then
+	mount -t xenfs xenfs /proc/xen
+fi
+
+do_start () {
+	echo Starting xl devd...
+	${sbindir}/xl devd --pidfile=$XLDEVD_PIDFILE $XLDEVD_ARGS
+}
+do_stop () {
+        echo Stopping xl devd...
+	if read 2>/dev/null <$XLDEVD_PIDFILE pid; then
+		kill $pid
+		while kill -9 $pid >/dev/null 2>&1; do sleep 0.1; done
+		rm -f $XLDEVD_PIDFILE
+	fi
+}
+
+case "$1" in
+  start)
+	do_start
+	;;
+  stop)
+	do_stop
+	;;
+  reload)
+	echo >&2 'Reload not available; use force-reload'; exit 1
+	;;
+  force-reload|restart)
+        do_stop
+	do_start
+	;;
+  *)
+	# do not advertise unreasonable commands that there is no reason
+	# to use with this device
+	echo $"Usage: $0 {start|stop|restart|force-reload}"
+	exit 1
+esac
+
+exit $?
tools/hotplug/NetBSD/Makefile +1 -1
index 4e609e3..d01aabf 100644
@@ -8,7 +8,7 @@ XEN_SCRIPTS += vif-bridge
 XEN_SCRIPTS += vif-ip
 
 XEN_SCRIPT_DATA =
-XEN_RCD_PROG = rc.d/xencommons rc.d/xendomains rc.d/xen-watchdog
+XEN_RCD_PROG = rc.d/xencommons rc.d/xendomains rc.d/xen-watchdog rc.d/xendriverdomain
 
 .PHONY: all
 all:
tools/hotplug/NetBSD/rc.d/xendriverdomain.in new file +49 -0
new file mode 100644
index 0000000..5062a71
@@ -0,0 +1,49 @@
+#!/bin/sh
+#
+# PROVIDE: xendriverdomain
+# REQUIRE: DAEMON
+#
+# Should be run in a driver domain, but not in domain 0.
+
+. /etc/rc.subr
+
+DIR=$(dirname "$0")
+. "${DIR}/xen-hotplugpath.sh"
+
+LD_LIBRARY_PATH="${libdir}"
+export LD_LIBRARY_PATH
+
+name="xendriverdomain"
+start_precmd="xendriverdomain_precmd"
+start_cmd="xendriverdomain_startcmd"
+stop_cmd="xendriverdomain_stop"
+extra_commands=""
+
+XLDEVD_PIDFILE="/var/run/xldevd.pid"
+
+xendriverdomain_precmd()
+{
+	:
+}
+
+xendriverdomain_startcmd()
+{
+	printf "Starting xenservices: xl devd."
+
+	${sbindir}/xl devd --pidfile=$XLDEVD_PIDFILE ${XLDEVD_ARGS}
+
+	printf "\n"
+}
+
+xendriverdomain_stop()
+{
+	printf "Stopping xl devd.\n"
+
+	rc_pid=$(check_pidfile ${XLDEVD_PIDFILE} ${sbindir}/xl)
+
+	kill -${sig_stop:-TERM} $rc_pids
+	wait_for_pids $rc_pids
+}
+
+load_rc_config $name
+run_rc_command "$1"
tools/libxl/xl_cmdimpl.c +38 -4
index 5f7a712..17e6e7d 100644
@@ -445,7 +445,7 @@ out:
     flush_stream(fh);
 }
 
-static int do_daemonize(char *name)
+static int do_daemonize(char *name, const char *pidfile)
 {
     char *fullname;
     pid_t child1;
@@ -477,6 +477,31 @@ static int do_daemonize(char *name)
 
     CHK_SYSCALL(daemon(0, 1));
 
+    if (pidfile) {
+        int fd = open(pidfile, O_RDWR | O_CREAT, S_IRUSR|S_IWUSR);
+        char *pid = NULL;
+
+        if (fd == -1) {
+            perror("Unable to open pidfile");
+            exit(1);
+        }
+
+        if (asprintf(&pid, "%ld\n", (long)getpid()) == -1) {
+            perror("Formatting pid");
+            exit(1);
+        }
+
+        if (write(fd, pid, strlen(pid)) < 0) {
+            perror("Writing pid");
+            exit(1);
+        }
+
+        if ( close(fd) < 0 ) {
+            perror("Closing pidfile");
+            exit(1);
+        }
+    }
+
 out:
     return ret;
 }
@@ -2798,7 +2823,7 @@ start:
             LOG("Failed to allocate memory in asprintf");
             exit(1);
         }
-        ret = do_daemonize(name);
+        ret = do_daemonize(name, NULL);
         free(name);
         if (ret) {
             ret = (ret == 1) ? domid : ret;
@@ -7972,15 +7997,24 @@ int main_remus(int argc, char **argv)
 int main_devd(int argc, char **argv)
 {
     int ret = 0, opt = 0, daemonize = 1;
+    const char *pidfile = NULL;
+    static const struct option opts[] = {
+        {"pidfile", 1, 0, 'p'},
+        COMMON_LONG_OPTS,
+        {0, 0, 0, 0}
+    };
 
-    SWITCH_FOREACH_OPT(opt, "F", NULL, "devd", 0) {
+    SWITCH_FOREACH_OPT(opt, "Fp:", opts, "devd", 0) {
     case 'F':
         daemonize = 0;
         break;
+    case 'p':
+        pidfile = optarg;
+        break;
     }
 
     if (daemonize) {
-        ret = do_daemonize("xldevd");
+        ret = do_daemonize("xldevd", pidfile);
         if (ret) {
             ret = (ret == 1) ? 0 : ret;
             goto out;
tools/libxl/xl_cmdtable.c +0 -0
index 54dbecc..0071f12 100644

tools/libxl/xl_cmdtable.c struct cmd_spec cmd_table[] = { · line 513

Quoted 9 lines
tools/libxl/xl_cmdtable.c +2 -1
@@ -506,7 +506,8 @@ struct cmd_spec cmd_table[] = {
       &main_devd, 0, 1,
       "Daemon that listens for devices and launches backends",
       "[options]",
-      "-F                      Run in the foreground",
+      "-F                      Run in the foreground.\n"
+      "-p, --pidfile [FILE]    Write PID to pidfile when daemonizing.",
     },
 #ifdef LIBXL_HAVE_PSR_CMT
     { "psr-hwinfo",

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

#15 lore raw

Re: [PATCH for-4.6] tools/hotplug: Add an initscript to start "xl devd" in a driver domain

In reply to Ian Campbell

Ian Campbell writes ("[PATCH for-4.6] tools/hotplug: Add an initscript to start "xl devd" in a driver domain"):

Quoted 2 lines

The removal of the udev rules highlighted that although it has been replaced by "xl devd" there isn't an initscript to replace it.

Despite

Quoted 1 line

+# NOTE: This initscript is not needed on dom0.

I didn't see anything which would stop it running on dom0. I don't think running it on dom0 is a good idea; it might fight with libxl.

Ian.

#16 lore raw

Re: [PATCH for-4.6] tools/hotplug: Add an initscript to start "xl devd" in a driver domain

Quoted 10 lines · Ian Jackson

Ian Campbell writes ("[PATCH for-4.6] tools/hotplug: Add an initscript to start "xl devd" in a driver domain"):

Quoted 2 lines

The removal of the udev rules highlighted that although it has been replaced by "xl devd" there isn't an initscript to replace it.

Despite

Quoted 1 line

+# NOTE: This initscript is not needed on dom0.

I didn't see anything which would stop it running on dom0. I don't think running it on dom0 is a good idea; it might fight with libxl.

I think Ian's idea was that the admin should know not to run it in dom0, and only enable it in driver domains.

Do you think we should do something to actively prevent it running in dom0? Do we have a good way to determine whether we're in dom0 or not?
(Or more apropos, whether we're running in the toolstack domain?)

-George

#17 lore raw

Re: [PATCH for-4.6] tools/hotplug: Add an initscript to start "xl devd" in a driver domain

Quoted 11 lines · George Dunlap
Quoted 10 lines · Ian Jackson

Ian Campbell writes ("[PATCH for-4.6] tools/hotplug: Add an initscript to start "xl devd" in a driver domain"):

Quoted 2 lines

The removal of the udev rules highlighted that although it has been replaced by "xl devd" there isn't an initscript to replace it.

Despite

Quoted 1 line

+# NOTE: This initscript is not needed on dom0.

I didn't see anything which would stop it running on dom0. I don't think running it on dom0 is a good idea; it might fight with libxl.

Good point.

Quoted 6 lines

I think Ian's idea was that the admin should know not to run it in dom0, and only enable it in driver domains.

Do you think we should do something to actively prevent it running in dom0? Do we have a good way to determine whether we're in dom0 or not?
(Or more apropos, whether we're running in the toolstack domain?)

Actually, when I cribbed from xencommons I removed the test for "am I in dom0". I think what I should have done was invert it...

I don't know of an equivalent test for the *BSDs.

Ian.

#18 lore raw

PATCH v2 1/1 tools/hotplug: Add an initscript to start "xl devd" in a driver domain

In reply to Ian Campbell

The removal of the udev rules highlighted that although it has been replaced by "xl devd" there isn't an initscript to replace it.

To enable this add a --pidfile option to xl devd.

Tested on Linux by running the script in dom0 and checking the daemon was started/stopped, but not in an actual driver domain environment since I don't have one conveniently available. I also checked that running without the --pidfile option still works.

Scripts mainly cribbed from the xencommons for each platform.

Cc Roger Pau Monné <[email protected]>
Cc Konrad Rzeszutek Wilk <[email protected]>
Cc George Dunlap <[email protected]>

---
For 4.6: I think having removed the udev rules we ought to include this, it's basically zero risk to normal operation.

Nothing seems to start xl devd for domain 0 in *BSD, nor is xenbackend started. Is that correct?

v2: Check in Linux script that we don't start on dom0. I don't know the equivalent for *BSD.

---
 .gitignore                                    |  3 +
 tools/configure                               |  5 +-
 tools/configure.ac                            |  3 +
 tools/hotplug/FreeBSD/Makefile                |  2 +-
 tools/hotplug/FreeBSD/rc.d/xendriverdomain.in | 48 +++++++++++++++
 tools/hotplug/Linux/Makefile                  |  3 +
 tools/hotplug/Linux/init.d/xendriverdomain.in | 85 +++++++++++++++++++++++++++
 tools/hotplug/NetBSD/Makefile                 |  2 +-
 tools/hotplug/NetBSD/rc.d/xendriverdomain.in  | 49 +++++++++++++++
 tools/libxl/xl_cmdimpl.c                      | 42 +++++++++++--
 tools/libxl/xl_cmdtable.c                     |  3 +-
 11 files changed, 237 insertions(+), 8 deletions(-)
 create mode 100644 tools/hotplug/FreeBSD/rc.d/xendriverdomain.in
 create mode 100644 tools/hotplug/Linux/init.d/xendriverdomain.in
 create mode 100644 tools/hotplug/NetBSD/rc.d/xendriverdomain.in
.gitignore +3 -0
index 464f3f4..f6ddb00 100644
@@ -133,10 +133,12 @@ tools/flask/utils/flask-set-bool
 tools/flask/utils/flask-label-pci
 tools/hotplug/common/hotplugpath.sh
 tools/hotplug/FreeBSD/rc.d/xencommons
+tools/hotplug/FreeBSD/rc.d/xendriverdomain
 tools/hotplug/Linux/init.d/sysconfig.xencommons
 tools/hotplug/Linux/init.d/xen-watchdog
 tools/hotplug/Linux/init.d/xencommons
 tools/hotplug/Linux/init.d/xendomains
+tools/hotplug/Linux/init.d/xendriverdomain
 tools/hotplug/Linux/systemd/*.conf
 tools/hotplug/Linux/systemd/*.mount
 tools/hotplug/Linux/systemd/*.socket
@@ -146,6 +148,7 @@ tools/hotplug/Linux/xen-backend.rules
 tools/hotplug/Linux/xen-hotplug-common.sh
 tools/hotplug/Linux/xendomains
 tools/hotplug/NetBSD/rc.d/xencommons
+tools/hotplug/NetBSD/rc.d/xendriverdomain
 tools/include/xen/*
 tools/include/xen-xsm/*
 tools/include/xen-foreign/*.(c|h|size)
tools/configure +4 -1
index 5138f3d..d90db47 100755
@@ -2403,7 +2403,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
-ac_config_files="$ac_config_files ../config/Tools.mk hotplug/FreeBSD/rc.d/xencommons hotplug/Linux/init.d/sysconfig.xencommons hotplug/Linux/init.d/xen-watchdog hotplug/Linux/init.d/xencommons hotplug/Linux/init.d/xendomains hotplug/Linux/vif-setup hotplug/Linux/xen-hotplug-common.sh hotplug/Linux/xendomains hotplug/NetBSD/rc.d/xencommons libxl/xenlight.pc.in libxl/xlutil.pc.in"
+ac_config_files="$ac_config_files ../config/Tools.mk hotplug/FreeBSD/rc.d/xencommons hotplug/FreeBSD/rc.d/xendriverdomain hotplug/Linux/init.d/sysconfig.xencommons hotplug/Linux/init.d/xen-watchdog hotplug/Linux/init.d/xencommons hotplug/Linux/init.d/xendomains hotplug/Linux/init.d/xendriverdomain hotplug/Linux/vif-setup hotplug/Linux/xen-hotplug-common.sh hotplug/Linux/xendomains hotplug/NetBSD/rc.d/xencommons hotplug/NetBSD/rc.d/xendriverdomain libxl/xenlight.pc.in libxl/xlutil.pc.in"
 
 ac_config_headers="$ac_config_headers config.h"
 
@@ -10045,14 +10045,17 @@ do
   case $ac_config_target in
     "../config/Tools.mk") CONFIG_FILES="$CONFIG_FILES ../config/Tools.mk" ;;
     "hotplug/FreeBSD/rc.d/xencommons") CONFIG_FILES="$CONFIG_FILES hotplug/FreeBSD/rc.d/xencommons" ;;
+    "hotplug/FreeBSD/rc.d/xendriverdomain") CONFIG_FILES="$CONFIG_FILES hotplug/FreeBSD/rc.d/xendriverdomain" ;;
     "hotplug/Linux/init.d/sysconfig.xencommons") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/init.d/sysconfig.xencommons" ;;
     "hotplug/Linux/init.d/xen-watchdog") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/init.d/xen-watchdog" ;;
     "hotplug/Linux/init.d/xencommons") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/init.d/xencommons" ;;
     "hotplug/Linux/init.d/xendomains") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/init.d/xendomains" ;;
+    "hotplug/Linux/init.d/xendriverdomain") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/init.d/xendriverdomain" ;;
     "hotplug/Linux/vif-setup") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/vif-setup" ;;
     "hotplug/Linux/xen-hotplug-common.sh") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/xen-hotplug-common.sh" ;;
     "hotplug/Linux/xendomains") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/xendomains" ;;
     "hotplug/NetBSD/rc.d/xencommons") CONFIG_FILES="$CONFIG_FILES hotplug/NetBSD/rc.d/xencommons" ;;
+    "hotplug/NetBSD/rc.d/xendriverdomain") CONFIG_FILES="$CONFIG_FILES hotplug/NetBSD/rc.d/xendriverdomain" ;;
     "libxl/xenlight.pc.in") CONFIG_FILES="$CONFIG_FILES libxl/xenlight.pc.in" ;;
     "libxl/xlutil.pc.in") CONFIG_FILES="$CONFIG_FILES libxl/xlutil.pc.in" ;;
     "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
tools/configure.ac +3 -0
index 8bfdfcb..f6a79c2 100644
@@ -8,14 +8,17 @@ AC_CONFIG_SRCDIR([libxl/libxl.c])
 AC_CONFIG_FILES([
 ../config/Tools.mk
 hotplug/FreeBSD/rc.d/xencommons
+hotplug/FreeBSD/rc.d/xendriverdomain
 hotplug/Linux/init.d/sysconfig.xencommons
 hotplug/Linux/init.d/xen-watchdog
 hotplug/Linux/init.d/xencommons
 hotplug/Linux/init.d/xendomains
+hotplug/Linux/init.d/xendriverdomain
 hotplug/Linux/vif-setup
 hotplug/Linux/xen-hotplug-common.sh
 hotplug/Linux/xendomains
 hotplug/NetBSD/rc.d/xencommons
+hotplug/NetBSD/rc.d/xendriverdomain
 libxl/xenlight.pc.in
 libxl/xlutil.pc.in
 ])
tools/hotplug/FreeBSD/Makefile +1 -1
index 8dfc90a..10fce4f 100644
@@ -6,7 +6,7 @@ XEN_SCRIPTS = vif-bridge
 
 XEN_SCRIPT_DATA =
 
-XEN_RCD_PROG = rc.d/xencommons
+XEN_RCD_PROG = rc.d/xencommons rc.d/xendriverdomain
 
 .PHONY: all
 all:
tools/hotplug/FreeBSD/rc.d/xendriverdomain.in new file +48 -0

48 lines not on this page · raw message

tools/hotplug/Linux/Makefile +3 -0
index bc8ee5e..6e10118 100644
@@ -9,6 +9,8 @@ XENDOMAINS_SYSCONFIG = init.d/sysconfig.xendomains
 XENCOMMONS_INITD = init.d/xencommons
 XENCOMMONS_SYSCONFIG = init.d/sysconfig.xencommons
 
+XENDRIVERDOMAIN_INITD = init.d/xendriverdomain
+
 # Xen script dir and scripts to go there.
 XEN_SCRIPTS = vif-bridge
 XEN_SCRIPTS += vif-route
@@ -53,6 +55,7 @@ install-initd:
 	$(INSTALL_DATA) $(XENDOMAINS_SYSCONFIG) $(DESTDIR)$(SYSCONFIG_DIR)/xendomains
 	$(INSTALL_PROG) $(XENCOMMONS_INITD) $(DESTDIR)$(INITD_DIR)
 	$(INSTALL_DATA) $(XENCOMMONS_SYSCONFIG) $(DESTDIR)$(SYSCONFIG_DIR)/xencommons
+	$(INSTALL_PROG) $(XENDRIVERDOMAIN_INITD) $(DESTDIR)$(INITD_DIR)
 	$(INSTALL_PROG) init.d/xen-watchdog $(DESTDIR)$(INITD_DIR)
 
 .PHONY: install-scripts
tools/hotplug/Linux/init.d/xendriverdomain.in new file +85 -0

85 lines not on this page · raw message

tools/hotplug/NetBSD/Makefile +1 -1
index 4e609e3..d01aabf 100644
@@ -8,7 +8,7 @@ XEN_SCRIPTS += vif-bridge
 XEN_SCRIPTS += vif-ip
 
 XEN_SCRIPT_DATA =
-XEN_RCD_PROG = rc.d/xencommons rc.d/xendomains rc.d/xen-watchdog
+XEN_RCD_PROG = rc.d/xencommons rc.d/xendomains rc.d/xen-watchdog rc.d/xendriverdomain
 
 .PHONY: all
 all:
tools/hotplug/NetBSD/rc.d/xendriverdomain.in new file +49 -0

49 lines not on this page · raw message

tools/libxl/xl_cmdimpl.c +38 -4

73 lines not on this page · raw message

tools/libxl/xl_cmdtable.c +2 -1
index 54dbecc..0071f12 100644
@@ -506,7 +506,8 @@ struct cmd_spec cmd_table[] = {
       &main_devd, 0, 1,
       "Daemon that listens for devices and launches backends",
       "[options]",
-      "-F                      Run in the foreground",
+      "-F                      Run in the foreground.\n"
+      "-p, --pidfile [FILE]    Write PID to pidfile when daemonizing.",
     },
 #ifdef LIBXL_HAVE_PSR_CMT
     { "psr-hwinfo",
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Acked-by on v2 1/1
#19 lore raw

Re: [PATCH for-4.6 v2] tools/hotplug: Add an initscript to start "xl devd" in a driver domain

Ian Campbell writes ("[PATCH for-4.6 v2] tools/hotplug: Add an initscript to start "xl devd" in a driver domain"):

Quoted 2 lines

The removal of the udev rules highlighted that although it has been replaced by "xl devd" there isn't an initscript to replace it.

Acked-by on v2 1/1
#20 lore raw

Re: [PATCH for-4.6 v2] tools/hotplug: Add an initscript to start "xl devd" in a driver domain

In reply to Ian Campbell
Quoted 10 lines · Ian Campbell

The removal of the udev rules highlighted that although it has been replaced by "xl devd" there isn't an initscript to replace it.

To enable this add a --pidfile option to xl devd.

Tested on Linux by running the script in dom0 and checking the daemon was started/stopped, but not in an actual driver domain environment since I don't have one conveniently available. I also checked that running without the --pidfile option still works.

Quoted 6 lines

Scripts mainly cribbed from the xencommons for each platform.

Cc Roger Pau Monné <[email protected]>
Cc Konrad Rzeszutek Wilk <[email protected]>
Cc George Dunlap <[email protected]>
#21 lore raw

Re: [PATCH for-4.6 v2] tools/hotplug: Add an initscript to start "xl devd" in a driver domain

In reply to Ian Campbell
Quoted 16 lines · Ian Campbell

The removal of the udev rules highlighted that although it has been replaced by "xl devd" there isn't an initscript to replace it.

To enable this add a --pidfile option to xl devd.

Tested on Linux by running the script in dom0 and checking the daemon was started/stopped, but not in an actual driver domain environment since I don't have one conveniently available. I also checked that running without the --pidfile option still works.

Scripts mainly cribbed from the xencommons for each platform.

Cc Roger Pau Monné <[email protected]>
Cc Konrad Rzeszutek Wilk <[email protected]>
Cc George Dunlap <[email protected]>
Quoted 7 lines

---
For 4.6: I think having removed the udev rules we ought to include this, it's basically zero risk to normal operation.

Nothing seems to start xl devd for domain 0 in *BSD, nor is xenbackend started. Is that correct?

With my RM hat on:

Applied
#22 lore raw

Re: [PATCH for-4.6 v2] tools/hotplug: Add an initscript to start "xl devd" in a driver domain

Quoted 21 lines · Wei Liu
Quoted 20 lines · Ian Campbell

The removal of the udev rules highlighted that although it has been replaced by "xl devd" there isn't an initscript to replace it.

To enable this add a --pidfile option to xl devd.

Tested on Linux by running the script in dom0 and checking the daemon was started/stopped, but not in an actual driver domain environment since I don't have one conveniently available. I also checked that running without the --pidfile option still works.

Scripts mainly cribbed from the xencommons for each platform.

Cc Roger Pau Monné <[email protected]>
Cc Konrad Rzeszutek Wilk <[email protected]>
Cc George Dunlap <[email protected]>

---
For 4.6: I think having removed the udev rules we ought to include this, it's basically zero risk to normal operation.

Quoted 7 lines
Quoted 3 lines

Nothing seems to start xl devd for domain 0 in *BSD, nor is xenbackend started. Is that correct?

With my RM hat on:

Applied, thanks,

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

#23 lore raw

Re: [PATCH for-4.6 v2] tools/hotplug: Add an initscript to start "xl devd" in a driver domain

In reply to Ian Campbell

El 16/07/15 a les 18.58, Ian Campbell ha escrit:

Quoted 20 lines

The removal of the udev rules highlighted that although it has been replaced by "xl devd" there isn't an initscript to replace it.

To enable this add a --pidfile option to xl devd.

Tested on Linux by running the script in dom0 and checking the daemon was started/stopped, but not in an actual driver domain environment since I don't have one conveniently available. I also checked that running without the --pidfile option still works.

Scripts mainly cribbed from the xencommons for each platform.

Cc Roger Pau Monné <[email protected]>
Cc Konrad Rzeszutek Wilk <[email protected]>
Cc George Dunlap <[email protected]>

---
For 4.6: I think having removed the udev rules we ought to include this, it's basically zero risk to normal operation.

Quoted 5 lines

Nothing seems to start xl devd for domain 0 in *BSD, nor is xenbackend started. Is that correct?

v2: Check in Linux script that we don't start on dom0. I don't know the equivalent for *BSD.

At least on FreeBSD there's no easy way to know if we are running on Dom0 from userspace (unless we start using hypercalls with privcmd).

I could add a dummy device (let's say /dev/xen/control) that's only present if we are running on Dom0, does that sound reasonable?

Another option would be to add a small C program that can use hypercalls and privcmd to detect if we are running on Dom0 or not, but that seems over engineering it.

[...]

Quoted 6 lines
tools/hotplug/FreeBSD/rc.d/xendriverdomain.in new file +0 -0
new file mode 100644
index 0000000..25e3edd

tools/hotplug/FreeBSD/rc.d/xendriverdomain.in line 10

Quoted 10 lines
tools/hotplug/FreeBSD/rc.d/xendriverdomain.in new file +10 -0
@@ -0,0 +1,48 @@
+#!/bin/sh
+#
+# PROVIDE: xendriverdomain
+# REQUIRE: DAEMON
+#
+# Should be run in a driver domain, but not in domain 0.
+
+. /etc/rc.subr
+
+. /etc/xen/scripts/hotplugpath.sh

This should have been:

. @XEN_SCRIPT_DIR@/hotplugpath.sh

I will send a patch ASAP to fix it.

[...]

Quoted 27 lines
tools/libxl/xl_cmdimpl.c +11 -1
index df89777..483eb71 100644
@@ -477,7 +477,7 @@ out:
     flush_stream(fh);
 }
 
-static int do_daemonize(char *name)
+static int do_daemonize(char *name, const char *pidfile)
 {
     char *fullname;
     pid_t child1;
@@ -509,6 +509,31 @@ static int do_daemonize(char *name)
 
     CHK_SYSCALL(daemon(0, 1));
 
+    if (pidfile) {
+        int fd = open(pidfile, O_RDWR | O_CREAT, S_IRUSR|S_IWUSR);
+        char *pid = NULL;
+
+        if (fd == -1) {
+            perror("Unable to open pidfile");
+            exit(1);
+        }
+
+        if (asprintf(&pid, "%ld\n", (long)getpid()) == -1) {

tools/libxl/xl_cmdimpl.c static int do_daemonize(char *name) · line 531

Quoted 10 lines
tools/libxl/xl_cmdimpl.c +10 -0
+            perror("Formatting pid");
+            exit(1);
+        }
+
+        if (write(fd, pid, strlen(pid)) < 0) {
+            perror("Writing pid");
+            exit(1);
+        }
+
+        if ( close(fd) < 0 ) {

<pedantic>
The line above doesn't follow libxl coding style.
</pedantic>

Roger.

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

#24 lore raw

Re: [PATCH for-4.6 v2] tools/hotplug: Add an initscript to start "xl devd" in a driver domain

Quoted 24 lines · Roger Pau Monné

El 16/07/15 a les 18.58, Ian Campbell ha escrit:

Quoted 23 lines

The removal of the udev rules highlighted that although it has been replaced by "xl devd" there isn't an initscript to replace it.

To enable this add a --pidfile option to xl devd.

Tested on Linux by running the script in dom0 and checking the daemon was started/stopped, but not in an actual driver domain environment since I don't have one conveniently available. I also checked that running without the --pidfile option still works.

Scripts mainly cribbed from the xencommons for each platform.

Cc Roger Pau Monné <[email protected]>
Cc Konrad Rzeszutek Wilk <[email protected]>
Cc George Dunlap <[email protected]>

---
For 4.6: I think having removed the udev rules we ought to include this, it's basically zero risk to normal operation.

Nothing seems to start xl devd for domain 0 in *BSD, nor is xenbackend started. Is that correct?

Quoted 8 lines
Quoted 2 lines

v2: Check in Linux script that we don't start on dom0. I don't know the equivalent for *BSD.

At least on FreeBSD there's no easy way to know if we are running on Dom0 from userspace (unless we start using hypercalls with privcmd).

I could add a dummy device (let's say /dev/xen/control) that's only present if we are running on Dom0, does that sound reasonable?

FWIW on Linux there is a capabilities "device" (actually procfs thing, close enough) which contains "control_d" in dom0. Not sure if that is helpful to follow?

Quoted 3 lines

Another option would be to add a small C program that can use hypercalls and privcmd to detect if we are running on Dom0 or not, but that seems over engineering it.

Agreed.

Quoted 21 lines

[...]

Quoted 6 lines
tools/hotplug/FreeBSD/rc.d/xendriverdomain.in new file +0 -0
new file mode 100644
index 0000000..25e3edd

tools/hotplug/FreeBSD/rc.d/xendriverdomain.in line 10

Quoted 10 lines
tools/hotplug/FreeBSD/rc.d/xendriverdomain.in new file +10 -0
@@ -0,0 +1,48 @@
+#!/bin/sh
+#
+# PROVIDE: xendriverdomain
+# REQUIRE: DAEMON
+#
+# Should be run in a driver domain, but not in domain 0.
+
+. /etc/rc.subr
+
+. /etc/xen/scripts/hotplugpath.sh

This should have been:

Quoted 3 lines

. @XEN_SCRIPT_DIR@/hotplugpath.sh

I will send a patch ASAP to fix it.

Sorry, and please do, thanks.

Quoted 7 lines

[...]

Quoted 1 line

+ if ( close(fd) < 0 ) {

<pedantic>
The line above doesn't follow libxl coding style.
</pedantic>

Damn, sorry.

Ian.

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

#25 lore raw

PATCH 3/6 tools: Add a block-tap script for setting up tapdisks via tap-ctl

In reply to George Dunlap

The blocktap library isn't really necessary; all the necessary functionality is available via the tap-ctl binary.

To use:

script=block-tap,vdev=[whatever],target=vhd:/path/to/file.vhd

script=block-tap,vdev=[whatever],target=aio:/path/to/file.raw

---
CC: Ian Campbell <[email protected]>
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monne <[email protected]>
CC: Felipe Franciosi <[email protected]>
CC: Dave Scott <[email protected]>
CC: Jonathan Ludlam <[email protected]>

---
 tools/hotplug/Linux/Makefile  |   1 +
 tools/hotplug/Linux/block-tap | 123 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 124 insertions(+)
tools/hotplug/Linux/Makefile +1 -0
index 8bb2316..bc8ee5e 100644
@@ -23,6 +23,7 @@ XEN_SCRIPTS += xen-hotplug-cleanup
 XEN_SCRIPTS += external-device-migrate
 XEN_SCRIPTS += vscsi
 XEN_SCRIPTS += block-iscsi
+XEN_SCRIPTS += block-tap
 XEN_SCRIPTS += block-drbd-probe
 XEN_SCRIPTS += $(XEN_SCRIPTS-y)
 
tools/hotplug/Linux/block-tap new file +123 -0

123 lines not on this page · raw message

Signature · 7 lines
1.9.1


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#26 lore raw

Re: [PATCH 3/6] tools: Add a block-tap script for setting up tapdisks via tap-ctl

Quoted 9 lines · George Dunlap

The blocktap library isn't really necessary; all the necessary functionality is available via the tap-ctl binary.

To use:

script=block-tap,vdev=[whatever],target=vhd:/path/to/file.vhd

script=block-tap,vdev=[whatever],target=aio:/path/to/file.raw

Is "scirpt=block-tap" the only change required for current syntax?

Does this still supports deprecated syntax like

vhd:disk.img,hda,rw

I'm assuming in later patch you will massage relevant bits into parameter string to this script.

Wei.

Acked-by
#27 lore raw

Re: [PATCH 3/6] tools: Add a block-tap script for setting up tapdisks via tap-ctl

Quoted 11 lines · Wei Liu
Quoted 9 lines · George Dunlap

The blocktap library isn't really necessary; all the necessary functionality is available via the tap-ctl binary.

To use:

script=block-tap,vdev=[whatever],target=vhd:/path/to/file.vhd

script=block-tap,vdev=[whatever],target=aio:/path/to/file.raw

Quoted 9 lines

Is "scirpt=block-tap" the only change required for current syntax?

Does this still supports deprecated syntax like

vhd:disk.img,hda,rw

I'm assuming in later patch you will massage relevant bits into parameter string to this script.

And yes, you actually did that in later patch.

Quoted 1 line

Wei.

#28 lore raw

PATCH 4/6 libxl: Use the block-tap script for LIBXL_DISK_BACKEND_TAP

In reply to George Dunlap

The block-tap script can now do everything needed for libxl; no need to link against the blktap library.

To do this:

* Set disk->script to "block-tap" and dev to "format:pdev_path" in device_disk_add for LIBXL_DISK_BACKEND_TAP

* Remove libxl_blktap2.o and libxl_noblktap2.o and all code depending on them

---
CC: Ian Campbell <[email protected]>
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>
CC: Dave Scott <[email protected]>
CC: Jonathan Ludlam <[email protected]>
CC: Wen Congyang <[email protected]>
CC: Yang Hongyang <[email protected]>
CC: Felipe Franciosi <[email protected]>

Note: This is broken for HVM domains at the moment because all block scripts are broken for HVM domains. That is a bug which should be a blocker for the 4.6 release. As such, I think there is justification for checking in this "feature" (enabling use of a 'system' blktap) with the assumption that the FIXME will go away before the release.

That will technically break bisectability; but only for users of blktap (which does not include osstest).

---
 tools/libxl/Makefile          |  5 ---
 tools/libxl/libxl.c           | 28 ++++---------
 tools/libxl/libxl_blktap2.c   | 93 -------------------------------------------
 tools/libxl/libxl_device.c    | 14 -------
 tools/libxl/libxl_dm.c        |  5 ++-
 tools/libxl/libxl_internal.h  | 26 ------------
 tools/libxl/libxl_noblktap2.c | 42 -------------------
 7 files changed, 11 insertions(+), 202 deletions(-)
tools/libxl/Makefile +0 -5
index cc9c152..43ab243 100644
@@ -44,11 +44,6 @@ LIBXL_LIBS += $(LIBXL_LIBS-y)
 LIBXLU_LIBS = libxenlight.so
 
 LIBXL_OBJS-y = osdeps.o libxl_paths.o libxl_bootloader.o flexarray.o
-ifeq ($(LIBXL_BLKTAP),y)
-LIBXL_OBJS-y += libxl_blktap2.o
-else
-LIBXL_OBJS-y += libxl_noblktap2.o
-endif
 
 ifeq ($(CONFIG_REMUS_NETBUF),y)
 LIBXL_OBJS-y += libxl_netbuffer.o
tools/libxl/libxl.c +8 -20
index 3a83903..2aab0c2 100644
@@ -2469,13 +2469,10 @@ static void device_disk_add(libxl__egc *egc, uint32_t domid,
         switch (disk->backend) {
             case LIBXL_DISK_BACKEND_PHY:
                 dev = disk->pdev_path;
-
-        do_backend_phy:
-                flexarray_append(back, "params");
-                flexarray_append(back, dev);
-
                 script = libxl__abs_path(gc, disk->script?: "block",
                                          libxl__xen_script_dir_path());
+        do_backend_phy:
+                flexarray_append_pair(back, "params", dev);
                 flexarray_append_pair(back, "script", script);
 
                 /* If the user did not supply a block script then we
@@ -2497,25 +2494,16 @@ static void device_disk_add(libxl__egc *egc, uint32_t domid,
                 break;
 
             case LIBXL_DISK_BACKEND_TAP:
-                if (dev == NULL) {
-                    dev = libxl__blktap_devpath(gc, disk->pdev_path,
-                                                disk->format);
-                    if (!dev) {
-                        LOG(ERROR, "failed to get blktap devpath for %p\n",
-                            disk->pdev_path);
-                        rc = ERROR_FAIL;
-                        goto out;
-                    }
-                }
-                flexarray_append(back, "tapdisk-params");
-                flexarray_append(back, libxl__sprintf(gc, "%s:%s",
-                    libxl__device_disk_string_of_format(disk->format),
-                    disk->pdev_path));
-
                 /* tap backends with scripts are rejected by
                  * libxl__device_disk_set_backend */
                 assert(!disk->script);
 
+                script = libxl__abs_path(gc, "block-tap",
+                                         libxl__xen_script_dir_path());
+                dev = libxl__sprintf(gc, "%s:%s",
+                             libxl__device_disk_string_of_format(disk->format),
+                             disk->pdev_path);
+ 
                 /* now create a phy device to export the device to the guest */
                 goto do_backend_phy;
             case LIBXL_DISK_BACKEND_QDISK:
tools/libxl/libxl_blktap2.c deleted +0 -93

93 lines not on this page · raw message

tools/libxl/libxl_device.c +0 -14
index 8209629..c1ca07b 100644
@@ -223,11 +223,6 @@ static int disk_try_backend(disk_try_backend_args *a,
                        a->disk->vdev);
             return 0;
         }
-        if (!libxl__blktap_enabled(a->gc)) {
-            LOG(DEBUG, "Disk vdev=%s, backend tap unsuitable because blktap "
-                       "not available", a->disk->vdev);
-            return 0;
-        }
         if (!(a->disk->format == LIBXL_DISK_FORMAT_RAW ||
               a->disk->format == LIBXL_DISK_FORMAT_VHD)) {
             goto bad_format;
@@ -572,8 +567,6 @@ int libxl__device_destroy(libxl__gc *gc, libxl__device *dev)
 {
     const char *be_path = libxl__device_backend_path(gc, dev);
     const char *fe_path = libxl__device_frontend_path(gc, dev);
-    const char *tapdisk_path = GCSPRINTF("%s/%s", be_path, "tapdisk-params");
-    const char *tapdisk_params;
     xs_transaction_t t = 0;
     int rc;
     uint32_t domid;
@@ -585,10 +578,6 @@ int libxl__device_destroy(libxl__gc *gc, libxl__device *dev)
         rc = libxl__xs_transaction_start(gc, &t);
         if (rc) goto out;
 
-        /* May not exist if this is not a tap device */
-        rc = libxl__xs_read_checked(gc, t, tapdisk_path, &tapdisk_params);
-        if (rc) goto out;
-
         if (domid == LIBXL_TOOLSTACK_DOMID) {
             /*
              * The toolstack domain is in charge for removing both the
@@ -609,9 +598,6 @@ int libxl__device_destroy(libxl__gc *gc, libxl__device *dev)
         if (rc < 0) goto out;
     }
 
-    if (tapdisk_params)
-        rc = libxl__device_destroy_tapdisk(gc, tapdisk_params);
-
 out:
     libxl__xs_transaction_abort(gc, &t);
     return rc;
tools/libxl/libxl_dm.c +3 -2
index 317a8eb..9ac6029 100644
@@ -856,8 +856,9 @@ static int libxl__build_device_model_args_new(libxl__gc *gc,
 
                 if (disks[i].backend == LIBXL_DISK_BACKEND_TAP) {
                     format = qemu_disk_format_string(LIBXL_DISK_FORMAT_RAW);
-                    pdev_path = libxl__blktap_devpath(gc, disks[i].pdev_path,
-                                                      disks[i].format);
+                    /* FIXME This won't work at the moment, because
+                     * all block scripts are broken for qemu */
+                    pdev_path = disks[i].pdev_path;
                 } else {
                     pdev_path = disks[i].pdev_path;
                 }
tools/libxl/libxl_internal.h +0 -26
index 7129aee..0d15397 100644
@@ -1615,32 +1615,6 @@ struct libxl__cpuid_policy {
     char *policy[4];
 };
 
-/*
- * blktap2 support
- */
-
-/* libxl__blktap_enabled:
- *    return true if blktap/blktap2 support is available.
- */
-_hidden int libxl__blktap_enabled(libxl__gc *gc);
-
-/* libxl__blktap_devpath:
- *    Argument: path and disk image as specified in config file.
- *      The type specifies whether this is aio, qcow, qcow2, etc.
- *    returns device path xenstore wants to have. returns NULL
- *      if no device corresponds to the disk.
- */
-_hidden char *libxl__blktap_devpath(libxl__gc *gc,
-                                    const char *disk,
-                                    libxl_disk_format format);
-
-/* libxl__device_destroy_tapdisk:
- *   Destroys any tapdisk process associated with the backend represented
- *   by be_path.
- *   Always logs on failure.
- */
-_hidden int libxl__device_destroy_tapdisk(libxl__gc *gc, const char *params);
-
 _hidden int libxl__device_from_disk(libxl__gc *gc, uint32_t domid,
                                    libxl_device_disk *disk,
                                    libxl__device *device);
tools/libxl/libxl_noblktap2.c deleted +0 -42

42 lines not on this page · raw message

Signature · 1 line
1.9.1
#29 lore raw

Re: [PATCH 4/6] libxl: Use the block-tap script for LIBXL_DISK_BACKEND_TAP

Quoted 45 lines · George Dunlap

The block-tap script can now do everything needed for libxl; no need to link against the blktap library.

To do this:

* Set disk->script to "block-tap" and dev to "format:pdev_path" in device_disk_add for LIBXL_DISK_BACKEND_TAP

* Remove libxl_blktap2.o and libxl_noblktap2.o and all code depending on them

---
CC: Ian Campbell <[email protected]>
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>
CC: Dave Scott <[email protected]>
CC: Jonathan Ludlam <[email protected]>
CC: Wen Congyang <[email protected]>
CC: Yang Hongyang <[email protected]>
CC: Felipe Franciosi <[email protected]>

Note: This is broken for HVM domains at the moment because all block scripts are broken for HVM domains. That is a bug which should be a blocker for the 4.6 release. As such, I think there is justification for checking in this "feature" (enabling use of a 'system' blktap) with the assumption that the FIXME will go away before the release.

That will technically break bisectability; but only for users of blktap (which does not include osstest).

---
 tools/libxl/Makefile          |  5 ---
 tools/libxl/libxl.c           | 28 ++++---------
 tools/libxl/libxl_blktap2.c   | 93 -------------------------------------------
 tools/libxl/libxl_device.c    | 14 -------
 tools/libxl/libxl_dm.c        |  5 ++-
 tools/libxl/libxl_internal.h  | 26 ------------
 tools/libxl/libxl_noblktap2.c | 42 -------------------
 7 files changed, 11 insertions(+), 202 deletions(-)
tools/libxl/Makefile +0 -0
index cc9c152..43ab243 100644

tools/libxl/Makefile LIBXL_LIBS += $(LIBXL_LIBS-y) · line 47

Quoted 4 lines
tools/libxl/Makefile +0 -1
@@ -44,11 +44,6 @@ LIBXL_LIBS += $(LIBXL_LIBS-y)
 LIBXLU_LIBS = libxenlight.so
 
 LIBXL_OBJS-y = osdeps.o libxl_paths.o libxl_bootloader.o flexarray.o
-ifeq ($(LIBXL_BLKTAP),y)

You will also want to remove reference to LIBXL_BLKTAP from Rules.mk

~Andrew

#30 lore raw

Re: [PATCH 4/6] libxl: Use the block-tap script for LIBXL_DISK_BACKEND_TAP

Quoted 48 lines · Andrew Cooper
Quoted 47 lines · George Dunlap

The block-tap script can now do everything needed for libxl; no need to link against the blktap library.

To do this:

* Set disk->script to "block-tap" and dev to "format:pdev_path" in device_disk_add for LIBXL_DISK_BACKEND_TAP

* Remove libxl_blktap2.o and libxl_noblktap2.o and all code depending on them

---
CC: Ian Campbell <[email protected]>
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>
CC: Dave Scott <[email protected]>
CC: Jonathan Ludlam <[email protected]>
CC: Wen Congyang <[email protected]>
CC: Yang Hongyang <[email protected]>
CC: Felipe Franciosi <[email protected]>

Note: This is broken for HVM domains at the moment because all block scripts are broken for HVM domains. That is a bug which should be a blocker for the 4.6 release. As such, I think there is justification for checking in this "feature" (enabling use of a 'system' blktap) with the assumption that the FIXME will go away before the release.

That will technically break bisectability; but only for users of blktap (which does not include osstest).

---
 tools/libxl/Makefile          |  5 ---
 tools/libxl/libxl.c           | 28 ++++---------
 tools/libxl/libxl_blktap2.c   | 93 -------------------------------------------
 tools/libxl/libxl_device.c    | 14 -------
 tools/libxl/libxl_dm.c        |  5 ++-
 tools/libxl/libxl_internal.h  | 26 ------------
 tools/libxl/libxl_noblktap2.c | 42 -------------------
 7 files changed, 11 insertions(+), 202 deletions(-)
tools/libxl/Makefile +0 -0
index cc9c152..43ab243 100644
@@ -44,11 +44,6 @@ LIBXL_LIBS += $(LIBXL_LIBS-y)
 LIBXLU_LIBS = libxenlight.so
 
Quoted 4 lines

tools/libxl/Makefile LIBXL_LIBS += $(LIBXL_LIBS-y) · line 47

Quoted 2 lines
tools/libxl/Makefile +0 -1
 LIBXL_OBJS-y = osdeps.o libxl_paths.o libxl_bootloader.o flexarray.o
-ifeq ($(LIBXL_BLKTAP),y)

You will also want to remove reference to LIBXL_BLKTAP from Rules.mk

Indeed, there is quite a bit I seem to have missed... I'll add a patch exising the configure- and make-related bits, separately from both this patch and the rm -rf tools/blktap2 patch.

-George

#31 lore raw

Re: [PATCH 4/6] libxl: Use the block-tap script for LIBXL_DISK_BACKEND_TAP

In reply to George Dunlap
Quoted 22 lines · George Dunlap

The block-tap script can now do everything needed for libxl; no need to link against the blktap library.

To do this:

* Set disk->script to "block-tap" and dev to "format:pdev_path" in device_disk_add for LIBXL_DISK_BACKEND_TAP

* Remove libxl_blktap2.o and libxl_noblktap2.o and all code depending on them

---
CC: Ian Campbell <[email protected]>
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>
CC: Dave Scott <[email protected]>
CC: Jonathan Ludlam <[email protected]>
CC: Wen Congyang <[email protected]>
CC: Yang Hongyang <[email protected]>
CC: Felipe Franciosi <[email protected]>

Quoted 3 lines

Note: This is broken for HVM domains at the moment because all block scripts are broken for HVM domains. That is a bug which should be a blocker for the 4.6 release. As such, I think there is justification

This bug is partially fixed by this particular patch. I think making things partially work is better than having it not work at all.

Quoted 3 lines

for checking in this "feature" (enabling use of a 'system' blktap) with the assumption that the FIXME will go away before the release.

I have the impression that to make QEMU work with block script (the FIXME) would require us to devise a way to get back the path of block device node. Am I right? How much work do you envisage is needed to make that FIXME go away?

On the flip side we're not making anything worse than before so we can probably get by by writing that down in known issues section of release note.

Wei.

#32 lore raw

Re: [PATCH 4/6] libxl: Use the block-tap script for LIBXL_DISK_BACKEND_TAP

Quoted 30 lines · Wei Liu
Quoted 22 lines · George Dunlap

The block-tap script can now do everything needed for libxl; no need to link against the blktap library.

To do this:

* Set disk->script to "block-tap" and dev to "format:pdev_path" in device_disk_add for LIBXL_DISK_BACKEND_TAP

* Remove libxl_blktap2.o and libxl_noblktap2.o and all code depending on them

---
CC: Ian Campbell <[email protected]>
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>
CC: Dave Scott <[email protected]>
CC: Jonathan Ludlam <[email protected]>
CC: Wen Congyang <[email protected]>
CC: Yang Hongyang <[email protected]>
CC: Felipe Franciosi <[email protected]>

Quoted 3 lines

Note: This is broken for HVM domains at the moment because all block scripts are broken for HVM domains. That is a bug which should be a blocker for the 4.6 release. As such, I think there is justification

This bug is partially fixed by this particular patch. I think making things partially work is better than having it not work at all.

Quoted 8 lines
Quoted 3 lines

for checking in this "feature" (enabling use of a 'system' blktap) with the assumption that the FIXME will go away before the release.

I have the impression that to make QEMU work with block script (the FIXME) would require us to devise a way to get back the path of block device node. Am I right? How much work do you envisage is needed to make that FIXME go away?

For block scripts where dom0 is the backend, I *think* we should in theory be able change block-common to store a pathname to the device node in xenstore and hand it to qemu. Alternately, we could fish the existing major:minor numbers out of xenstore and make our own node to pass to qemu.

Quoted 3 lines

On the flip side we're not making anything worse than before so we can probably get by by writing that down in known issues section of release note.

We do technically cause a regression at the moment. Before this patch, someone who has access to the blktap kernel module, and is using the in-tree blktap, will be able to use a blktap backend with HVM guests. Once this patch is accepted, blktap will work for PV guests, but not for HVM guests -- at least until we fix the bug with local block scripts.

-George

#33 lore raw

Re: [PATCH 4/6] libxl: Use the block-tap script for LIBXL_DISK_BACKEND_TAP

Quoted 50 lines · George Dunlap
Quoted 30 lines · Wei Liu
Quoted 22 lines · George Dunlap

The block-tap script can now do everything needed for libxl; no need to link against the blktap library.

To do this:

* Set disk->script to "block-tap" and dev to "format:pdev_path" in device_disk_add for LIBXL_DISK_BACKEND_TAP

* Remove libxl_blktap2.o and libxl_noblktap2.o and all code depending on them

---
CC: Ian Campbell <[email protected]>
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>
CC: Dave Scott <[email protected]>
CC: Jonathan Ludlam <[email protected]>
CC: Wen Congyang <[email protected]>
CC: Yang Hongyang <[email protected]>
CC: Felipe Franciosi <[email protected]>

Quoted 3 lines

Note: This is broken for HVM domains at the moment because all block scripts are broken for HVM domains. That is a bug which should be a blocker for the 4.6 release. As such, I think there is justification

This bug is partially fixed by this particular patch. I think making things partially work is better than having it not work at all.

Quoted 8 lines
Quoted 3 lines

for checking in this "feature" (enabling use of a 'system' blktap) with the assumption that the FIXME will go away before the release.

I have the impression that to make QEMU work with block script (the FIXME) would require us to devise a way to get back the path of block device node. Am I right? How much work do you envisage is needed to make that FIXME go away?

For block scripts where dom0 is the backend, I *think* we should in theory be able change block-common to store a pathname to the device node in xenstore and hand it to qemu. Alternately, we could fish the existing major:minor numbers out of xenstore and make our own node to pass to qemu.

Quoted 3 lines

On the flip side we're not making anything worse than before so we can probably get by by writing that down in known issues section of release note.

Quoted 5 lines

We do technically cause a regression at the moment. Before this patch, someone who has access to the blktap kernel module, and is using the in-tree blktap, will be able to use a blktap backend with HVM guests. Once this patch is accepted, blktap will work for PV guests, but not for HVM guests -- at least until we fix the bug with local block scripts.

Unfortunately that does sound like something which needs to be fixed before we accept this patch, doesn't it?

#34 lore raw

Re: [PATCH 4/6] libxl: Use the block-tap script for LIBXL_DISK_BACKEND_TAP

Quoted 51 lines · Ian Campbell
Quoted 50 lines · George Dunlap
Quoted 30 lines · Wei Liu
Quoted 22 lines · George Dunlap

The block-tap script can now do everything needed for libxl; no need to link against the blktap library.

To do this:

* Set disk->script to "block-tap" and dev to "format:pdev_path" in device_disk_add for LIBXL_DISK_BACKEND_TAP

* Remove libxl_blktap2.o and libxl_noblktap2.o and all code depending on them

---
CC: Ian Campbell <[email protected]>
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>
CC: Dave Scott <[email protected]>
CC: Jonathan Ludlam <[email protected]>
CC: Wen Congyang <[email protected]>
CC: Yang Hongyang <[email protected]>
CC: Felipe Franciosi <[email protected]>

Quoted 3 lines

Note: This is broken for HVM domains at the moment because all block scripts are broken for HVM domains. That is a bug which should be a blocker for the 4.6 release. As such, I think there is justification

This bug is partially fixed by this particular patch. I think making things partially work is better than having it not work at all.

Quoted 8 lines
Quoted 3 lines

for checking in this "feature" (enabling use of a 'system' blktap) with the assumption that the FIXME will go away before the release.

I have the impression that to make QEMU work with block script (the FIXME) would require us to devise a way to get back the path of block device node. Am I right? How much work do you envisage is needed to make that FIXME go away?

For block scripts where dom0 is the backend, I *think* we should in theory be able change block-common to store a pathname to the device node in xenstore and hand it to qemu. Alternately, we could fish the existing major:minor numbers out of xenstore and make our own node to pass to qemu.

Quoted 3 lines

On the flip side we're not making anything worse than before so we can probably get by by writing that down in known issues section of release note.

Quoted 8 lines
Quoted 5 lines

We do technically cause a regression at the moment. Before this patch, someone who has access to the blktap kernel module, and is using the in-tree blktap, will be able to use a blktap backend with HVM guests. Once this patch is accepted, blktap will work for PV guests, but not for HVM guests -- at least until we fix the bug with local block scripts.

Unfortunately that does sound like something which needs to be fixed before we accept this patch, doesn't it?

Since the bug is in block scripts in general, and should (I think) be a blocker, it can go in after the feature freeze. This being a new feature, it can't (or at least, that's how I was doing my calculations).
So I didn't want to block the thing I can't work on during the feature
freeze for the thing I can.

On the other hand, there's always a risk that the fix will be somewhat complicated, and we may decide that since nobody has been shouting about it so far, we could just put the fix off until 4.6.1 -- or at least, if we don't have any visible regressions, we could do that. Checking this in might burn our bridges somewhat.

I think that risk is small, so I'm still in favor of checking it in, but I could certainly see the the argument against it.

-George

#35 lore raw

PATCH 5/6 tools: Remove in-tree blktap2

In reply to George Dunlap

Now that libxl has been configured to use a block script for tapdisk, we can remove the in-tree blktap and let the user build an out-of-tree blktap.

---
CC: Ian Campbell <[email protected]>
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>
CC: Dave Scott <[email protected]>
CC: Jonathan Ludlam <[email protected]>
CC: Wen Congyang <[email protected]>
CC: Yang Hongyang <[email protected]>
---

[Patch trimmed]

Acked-by on v1 5/6
#36 lore raw

Re: [PATCH 5/6] tools: Remove in-tree blktap2

Quoted 6 lines · George Dunlap

Now that libxl has been configured to use a block script for tapdisk, we can remove the in-tree blktap and let the user build an out-of-tree blktap.

Quoted 11 lines

---
CC: Ian Campbell <[email protected]>
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>
CC: Dave Scott <[email protected]>
CC: Jonathan Ludlam <[email protected]>
CC: Wen Congyang <[email protected]>
CC: Yang Hongyang <[email protected]>
---

[Patch trimmed]

#37 lore raw

PATCH 6/6 libxl: Add more logging to hotplug script path

In reply to George Dunlap

This was useful in tracking down bugs.

---
CC: Ian Campbell <[email protected]>
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>

---
 tools/libxl/libxl_device.c | 20 +++++++++++++++++---
 tools/libxl/libxl_linux.c  |  5 +++++
 2 files changed, 22 insertions(+), 3 deletions(-)
tools/libxl/libxl_device.c +17 -3
index c1ca07b..d2ae42f 100644
@@ -920,11 +920,13 @@ static void device_backend_callback(libxl__egc *egc, libxl__ev_devstate *ds,
     libxl__ao_device *aodev = CONTAINER_OF(ds, *aodev, backend_ds);
     STATE_AO_GC(aodev->ao);
 
+    LOG(DEBUG, "calling device_backend_cleanup");
     device_backend_cleanup(gc, aodev);
 
     if (rc == ERROR_TIMEDOUT &&
         aodev->action == LIBXL__DEVICE_ACTION_REMOVE &&
         !aodev->force) {
+        LOG(DEBUG, "Timeout reached, initiating forced remove");
         aodev->force = 1;
         libxl__initiate_device_remove(egc, aodev);
         return;
@@ -967,10 +969,18 @@ static void device_hotplug(libxl__egc *egc, libxl__ao_device *aodev)
      * hotplug scripts
      */
     rc = libxl__get_domid(gc, &domid);
-    if (rc) goto out;
+    if (rc) {
+        LOG(ERROR, "Failed to get domid");
+        goto out;
+    }
     if (aodev->dev->backend_domid != domid) {
-        if (aodev->action != LIBXL__DEVICE_ACTION_REMOVE)
+        LOG(DEBUG, "Backend domid %d, domid %d, assuming driver domains", 
+            aodev->dev->backend_domid, domid);
+
+        if (aodev->action != LIBXL__DEVICE_ACTION_REMOVE) {
+            LOG(DEBUG, "Not a remove, not executing hotplug scripts");
             goto out;
+        }
 
         aodev->xswait.ao = ao;
         aodev->xswait.what = "removal of backend path";
@@ -978,8 +988,11 @@ static void device_hotplug(libxl__egc *egc, libxl__ao_device *aodev)
         aodev->xswait.timeout_ms = LIBXL_DESTROY_TIMEOUT * 1000;
         aodev->xswait.callback = device_destroy_be_watch_cb;
         rc = libxl__xswait_start(gc, &aodev->xswait);
-        if (rc)
+        if (rc) {
+            LOG(ERROR, "Setup of backend removal watch failed (path %s)", be_path);
             goto out;
+        }
+
         return;
     }
 
@@ -991,6 +1004,7 @@ static void device_hotplug(libxl__egc *egc, libxl__ao_device *aodev)
     switch (hotplug) {
     case 0:
         /* no hotplug script to execute */
+        LOG(DEBUG, "No hotplug script to execute");
         goto out;
     case 1:
         /* execute hotplug script */
tools/libxl/libxl_linux.c +5 -0
index 512d2c9..4fbcba1 100644
@@ -214,6 +214,7 @@ static int libxl__hotplug_disk(libxl__gc *gc, libxl__device *dev,
 
     *env = get_hotplug_env(gc, script, dev);
     if (!*env) {
+        LOG(ERROR, "Failed to get hotplug environment");
         rc = ERROR_FAIL;
         goto error;
     }
@@ -225,6 +226,7 @@ static int libxl__hotplug_disk(libxl__gc *gc, libxl__device *dev,
     (*args)[nr++] = NULL;
     assert(nr == arraysize);
 
+    LOG(DEBUG, "Args and environment ready");
     rc = 1;
 
 error:
@@ -241,6 +243,7 @@ int libxl__get_hotplug_script_info(libxl__gc *gc, libxl__device *dev,
     switch (dev->backend_kind) {
     case LIBXL__DEVICE_KIND_VBD:
         if (num_exec != 0) {
+            LOG(DEBUG, "num_exec %d, not running hotplug scripts\n", num_exec);
             rc = 0;
             goto out;
         }
@@ -253,6 +256,7 @@ int libxl__get_hotplug_script_info(libxl__gc *gc, libxl__device *dev,
          */
         if ((num_exec > 1) ||
             (libxl_get_stubdom_id(CTX, dev->domid) && num_exec)) {
+            LOG(DEBUG, "num_exec %d, not running hotplug scripts\n", num_exec);
             rc = 0;
             goto out;
         }
@@ -260,6 +264,7 @@ int libxl__get_hotplug_script_info(libxl__gc *gc, libxl__device *dev,
         break;
     default:
         /* No need to execute any hotplug scripts */
+        LOG(DEBUG, "backend_kind %d, no need to execute scripts", dev->backend_kind);
         rc = 0;
         break;
     }
Signature · 1 line
1.9.1
#39 lore raw
In reply to George Dunlap
Quoted 7 lines · George Dunlap

George Dunlap (6):
libxl: Make local_initiate_attach more rational
libxl: Remove linux udev rules
tools: Add a block-tap script for setting up tapdisks via tap-ctl
libxl: Use the block-tap script for LIBXL_DISK_BACKEND_TAP
tools: Remove in-tree blktap2
libxl: Add more logging to hotplug script path

Could some subset of this series safely go in now? I'm thinking in particular of:
libxl: Make local_initiate_attach more rational
libxl: Add more logging to hotplug script path

Which look useful and standalone, assuming the first doesn't need any of the rest.

I'm not sure if the udev stuff makes sense without the blktap script stuff (which appears to need a little more discussion if nothing else). I'll take it if you say it is safe to do so...

Ian.

#40 lore raw
Quoted 15 lines · Ian Campbell
Quoted 7 lines · George Dunlap

George Dunlap (6):
libxl: Make local_initiate_attach more rational
libxl: Remove linux udev rules
tools: Add a block-tap script for setting up tapdisks via tap-ctl
libxl: Use the block-tap script for LIBXL_DISK_BACKEND_TAP
tools: Remove in-tree blktap2
libxl: Add more logging to hotplug script path

Could some subset of this series safely go in now? I'm thinking in particular of:
libxl: Make local_initiate_attach more rational
libxl: Add more logging to hotplug script path

Quoted 6 lines

Which look useful and standalone, assuming the first doesn't need any of the rest.

I'm not sure if the udev stuff makes sense without the blktap script stuff (which appears to need a little more discussion if nothing else). I'll take it if you say it is safe to do so...

The first three can go in without any regressions, and I think would be useful. The udev stuff fixes a bug for *all* block scripts -- including, block-iscsi and block-nbd.

-George

#41 lore raw
Quoted 16 lines · George Dunlap
Quoted 15 lines · Ian Campbell
Quoted 7 lines · George Dunlap

George Dunlap (6):
libxl: Make local_initiate_attach more rational
libxl: Remove linux udev rules
tools: Add a block-tap script for setting up tapdisks via tap-ctl
libxl: Use the block-tap script for LIBXL_DISK_BACKEND_TAP
tools: Remove in-tree blktap2
libxl: Add more logging to hotplug script path

Could some subset of this series safely go in now? I'm thinking in particular of:
libxl: Make local_initiate_attach more rational
libxl: Add more logging to hotplug script path

Quoted 8 lines
Quoted 6 lines

Which look useful and standalone, assuming the first doesn't need any of the rest.

I'm not sure if the udev stuff makes sense without the blktap script stuff (which appears to need a little more discussion if nothing else). I'll take it if you say it is safe to do so...

The first three can go in without any regressions,

ITYM the first two and sixth? i.e.

b1882a4 libxl: Make local_initiate_attach more rational 2ba368d libxl: Remove linux udev rules
eff228d libxl: Add more logging to hotplug script path

So that is what I'm in the middle of applying...

Ian.

#42 lore raw
Quoted 26 lines · Ian Campbell
Quoted 16 lines · George Dunlap
Quoted 15 lines · Ian Campbell
Quoted 7 lines · George Dunlap

George Dunlap (6):
libxl: Make local_initiate_attach more rational
libxl: Remove linux udev rules
tools: Add a block-tap script for setting up tapdisks via tap-ctl
libxl: Use the block-tap script for LIBXL_DISK_BACKEND_TAP
tools: Remove in-tree blktap2
libxl: Add more logging to hotplug script path

Could some subset of this series safely go in now? I'm thinking in particular of:
libxl: Make local_initiate_attach more rational
libxl: Add more logging to hotplug script path

Quoted 8 lines
Quoted 6 lines

Which look useful and standalone, assuming the first doesn't need any of the rest.

I'm not sure if the udev stuff makes sense without the blktap script stuff (which appears to need a little more discussion if nothing else). I'll take it if you say it is safe to do so...

The first three can go in without any regressions,

Quoted 7 lines

ITYM the first two and sixth? i.e.

b1882a4 libxl: Make local_initiate_attach more rational 2ba368d libxl: Remove linux udev rules
eff228d libxl: Add more logging to hotplug script path

So that is what I'm in the middle of applying...

Well actually I meant the first three. :-)

To quote myself from the cover letter:

"The third patch (tools: Add a block-tap script for setting up tapdisks via tap-ctl) can also be checked in independently from the fourth and fifth, as it allows someone to disable blktap support in configure but still use externally-built tap-ctl binaries (albeit with a different disk string)."

-George

#43 lore raw
Quoted 37 lines · George Dunlap
Quoted 26 lines · Ian Campbell
Quoted 16 lines · George Dunlap
Quoted 15 lines · Ian Campbell
Quoted 7 lines · George Dunlap

George Dunlap (6):
libxl: Make local_initiate_attach more rational
libxl: Remove linux udev rules
tools: Add a block-tap script for setting up tapdisks via tap-ctl
libxl: Use the block-tap script for LIBXL_DISK_BACKEND_TAP
tools: Remove in-tree blktap2
libxl: Add more logging to hotplug script path

Could some subset of this series safely go in now? I'm thinking in particular of:
libxl: Make local_initiate_attach more rational
libxl: Add more logging to hotplug script path

Quoted 8 lines
Quoted 6 lines

Which look useful and standalone, assuming the first doesn't need any of the rest.

I'm not sure if the udev stuff makes sense without the blktap script stuff (which appears to need a little more discussion if nothing else). I'll take it if you say it is safe to do so...

The first three can go in without any regressions,

Quoted 7 lines

ITYM the first two and sixth? i.e.

b1882a4 libxl: Make local_initiate_attach more rational 2ba368d libxl: Remove linux udev rules
eff228d libxl: Add more logging to hotplug script path

So that is what I'm in the middle of applying...

Well actually I meant the first three. :-)

Quoted 7 lines

To quote myself from the cover letter:

"The third patch (tools: Add a block-tap script for setting up tapdisks via tap-ctl) can also be checked in independently from the fourth and fifth, as it allows someone to disable blktap support in configure but still use externally-built tap-ctl binaries (albeit with a different disk string)."

Sorry, I was getting confused between this and the next patch.

I'll apply the three above plus the third one.

Ian.

Applied
#44 lore raw
In reply to George Dunlap
Quoted 4 lines · George Dunlap

George Dunlap (6):
libxl: Make local_initiate_attach more rational
libxl: Remove linux udev rules
tools: Add a block-tap script for setting up tapdisks via tap-ctl

[...snip 2 patches...]

Quoted 1 line

libxl: Add more logging to hotplug script path

Applied these 4, thanks.