From 0a85fbc946d7838366c35c0425efddb1a91f593c Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 8 Oct 2012 17:26:53 +0100 Subject: Add support for hotplugging (removing disks). New API: remove-drive. Note because of a bug in fuser, this only works with psmisc >= 22.20. This also updates the hotplugging tests. --- daemon/hotplug.c | 101 +++++++++++++++++++++++++++++++-- generator/actions.ml | 39 +++++++++++++ src/MAX_PROC_NR | 2 +- src/guestfs-internal.h | 1 + src/guestfs.pod | 10 +++- src/launch-libvirt.c | 35 ++++++++++++ src/launch.c | 54 ++++++++++++++++++ tests/hotplug/Makefile.am | 6 +- tests/hotplug/test-hot-remove.pl | 88 ++++++++++++++++++++++++++++ tests/hotplug/test-hotplug-repeated.pl | 57 +++++++++++++++++++ 10 files changed, 383 insertions(+), 10 deletions(-) create mode 100755 tests/hotplug/test-hot-remove.pl create mode 100755 tests/hotplug/test-hotplug-repeated.pl diff --git a/daemon/hotplug.c b/daemon/hotplug.c index aae638e7..05367e3b 100644 --- a/daemon/hotplug.c +++ b/daemon/hotplug.c @@ -29,6 +29,17 @@ #include "actions.h" #define HOT_ADD_TIMEOUT 30 /* seconds */ +#define HOT_REMOVE_TIMEOUT HOT_ADD_TIMEOUT + +static void +hotplug_error (const char *op, const char *path, const char *verb, + int timeout) +{ + reply_with_error ("%s drive: '%s' did not %s after %d seconds: " + "this could mean that virtio-scsi (in qemu or kernel) " + "or udev is not working", + op, path, verb, timeout); +} /* Wait for /dev/disk/guestfs/