From 4256737227c92d3c9a3139392c2ac56afe0339f4 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 8 Mar 2022 15:23:19 +0000 Subject: [PATCH] lib: Remove drive hotplugging support This was a feature that allowed you to add drives to the appliance after launching it. It was complicated to implement, and only worked for the libvirt backend (not "direct", which is the default backend). It also turned out to be a bad idea. The original concept was that appliance creation was slow, so to examine multiple guests you should launch the handle once then hot-add the disks from each guest in turn to manipulate them. However this is terrible from a security point of view, especially for multi-tenant, because the drives from one guest might compromise the appliance and thus the filesystems/drives from subsequent guests. It also turns out that hotplugging is very slow. Nowadays appliance creation should be faster than hotplugging. The main use case for this was virt-df, but virt-df no longer uses it after we discovered the problems outlined above. --- daemon/Makefile.am | 1 - daemon/hotplug.c | 158 ------------------------- docs/C_SOURCE_FILES | 1 - docs/guestfs-faq.pod | 4 +- generator/actions_core.ml | 53 +-------- generator/actions_core_deprecated.ml | 9 ++ generator/proc_nr.ml | 3 - lib/drives.c | 90 +------------- lib/guestfs-internal.h | 10 +- lib/guestfs.pod | 42 +------ lib/launch-direct.c | 3 - lib/launch-libvirt.c | 125 ------------------- tests/Makefile.am | 8 -- tests/hotplug/test-hot-add.pl | 63 ---------- tests/hotplug/test-hot-remove.pl | 85 ------------- tests/hotplug/test-hotplug-repeated.pl | 56 --------- 16 files changed, 18 insertions(+), 693 deletions(-) delete mode 100644 daemon/hotplug.c delete mode 100755 tests/hotplug/test-hot-add.pl delete mode 100755 tests/hotplug/test-hot-remove.pl delete mode 100755 tests/hotplug/test-hotplug-repeated.pl diff --git a/daemon/Makefile.am b/daemon/Makefile.am index 7322bfa5d..bbd49f9ea 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -136,7 +136,6 @@ guestfsd_SOURCES = \ guestfsd.c \ headtail.c \ hexdump.c \ - hotplug.c \ hivex.c \ htonl.c \ initrd.c \ diff --git a/daemon/hotplug.c b/daemon/hotplug.c deleted file mode 100644 index 193a5ffb9..000000000 --- a/daemon/hotplug.c +++ /dev/null @@ -1,158 +0,0 @@ -/* libguestfs - the guestfsd daemon - * Copyright (C) 2012 Red Hat Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include - -#include -#include -#include -#include -#include -#include - -#include "guestfs_protocol.h" -#include "daemon.h" -#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/