aboutsummaryrefslogtreecommitdiff
path: root/hw/device-hotplug.c
diff options
context:
space:
mode:
authorAlexander Graf <agraf@suse.de>2010-08-23 23:43:10 +0200
committerAlexander Graf <agraf@suse.de>2012-01-04 02:48:14 +0100
commitdd97aa8adc9a15fa509d5a0196002d309f6d21fd (patch)
treebf9cbdf4884f56effa7926332502af0d14595f6b /hw/device-hotplug.c
parent963d83c85420b39eb4ab6ae1ebdcd7f818221402 (diff)
Add generic drive hotplugging
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. All pci specific code can then be handled in a pci specific function. Signed-off-by: Alexander Graf <agraf@suse.de> --- v1 -> v2: - align generic drive_add to pci specific one - rework to split between generic and pci code v2 -> v3: - remove comment
Diffstat (limited to 'hw/device-hotplug.c')
-rw-r--r--hw/device-hotplug.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/hw/device-hotplug.c b/hw/device-hotplug.c
index 8b2ed7a492..2bdc615b49 100644
--- a/hw/device-hotplug.c
+++ b/hw/device-hotplug.c
@@ -26,6 +26,9 @@
#include "boards.h"
#include "net.h"
#include "blockdev.h"
+#include "qemu-config.h"
+#include "sysemu.h"
+#include "monitor.h"
DriveInfo *add_init_drive(const char *optstr)
{
@@ -44,3 +47,47 @@ DriveInfo *add_init_drive(const char *optstr)
return dinfo;
}
+
+#if !defined(TARGET_I386)
+int pci_drive_hot_add(Monitor *mon, const QDict *qdict,
+ DriveInfo *dinfo, int type)
+{
+ /* On non-x86 we don't do PCI hotplug */
+ monitor_printf(mon, "Can't hot-add drive to type %d\n", type);
+ return -1;
+}
+#endif
+
+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:
+ if (pci_drive_hot_add(mon, qdict, dinfo, type)) {
+ goto err;
+ }
+ }
+ return;
+
+err:
+ if (dinfo) {
+ drive_put_ref(dinfo);
+ }
+ return;
+}