From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=37748 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Onf6E-00029O-Ex for qemu-devel@nongnu.org; Mon, 23 Aug 2010 18:02:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Onf6A-0000ba-NH for qemu-devel@nongnu.org; Mon, 23 Aug 2010 18:02:38 -0400 Received: from cantor.suse.de ([195.135.220.2]:56242 helo=mx1.suse.de) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Onf6A-0000bF-CD for qemu-devel@nongnu.org; Mon, 23 Aug 2010 18:02:34 -0400 From: Alexander Graf Date: Tue, 24 Aug 2010 00:02:30 +0200 Message-Id: <1282600951-30803-5-git-send-email-agraf@suse.de> In-Reply-To: <1282600951-30803-1-git-send-email-agraf@suse.de> References: <1282600951-30803-1-git-send-email-agraf@suse.de> Subject: [Qemu-devel] [PATCH 4/5] Add generic drive hotplugging List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel List Cc: Gerd Hoffmann , Markus Armbruster , Aurelien Jarno , Luiz Capitulino The monitor command for hotplugging is in i386 specific code. This is just plain wrong, as S390 just learned how to do hotplugging too and needs to get drives for that. So let's add a generic copy to generic code that handles drive_add in a way that doesn't have pci dependencies. I'm not fully happy with the patch as is. IMHO there should only be a single target agnostic drive_hot_add function available. How we could potentially fit IF_SCSI in there I don't know though. Signed-off-by: Alexander Graf --- hw/device-hotplug.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 43 insertions(+), 0 deletions(-) diff --git a/hw/device-hotplug.c b/hw/device-hotplug.c index c1a9a56..f311c7f 100644 --- a/hw/device-hotplug.c +++ b/hw/device-hotplug.c @@ -25,6 +25,9 @@ #include "hw.h" #include "boards.h" #include "net.h" +#include "qemu-config.h" +#include "sysemu.h" +#include "monitor.h" DriveInfo *add_init_drive(const char *optstr) { @@ -44,3 +47,43 @@ DriveInfo *add_init_drive(const char *optstr) return dinfo; } + +#if !defined(TARGET_I386) + +/* + * This version of drive_hot_add does not know anything about PCI specifics. + * It is used as fallback on architectures that don't implement pci-hotplug. + */ +void drive_hot_add(Monitor *mon, const QDict *qdict) +{ + int type; + DriveInfo *dinfo = NULL; + const char *opts = qdict_get_str(qdict, "opts"); + + dinfo = add_init_drive(opts); + if (!dinfo) + goto err; + if (dinfo->devaddr) { + monitor_printf(mon, "Parameter addr not supported\n"); + goto err; + } + type = dinfo->type; + + switch (type) { + case IF_NONE: + monitor_printf(mon, "OK\n"); + break; + default: + monitor_printf(mon, "Can't hot-add drive to type %d\n", type); + goto err; + } + return; + +err: + if (dinfo) + drive_uninit(dinfo); + return; +} + +#endif /* !defined(TARGET_I386) */ + -- 1.6.0.2