[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 03/16] Add generic drive hotplugging
From: |
Alexander Graf |
Subject: |
[Qemu-devel] [PATCH 03/16] Add generic drive hotplugging |
Date: |
Fri, 11 Nov 2011 18:49:10 +0100 |
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 <address@hidden>
---
v1 -> v2:
- align generic drive_add to pci specific one
- rework to split between generic and pci code
v2 -> v3:
- remove comment
---
hw/device-hotplug.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
hw/pci-hotplug.c | 24 ++++--------------------
sysemu.h | 6 +++++-
3 files changed, 56 insertions(+), 21 deletions(-)
diff --git a/hw/device-hotplug.c b/hw/device-hotplug.c
index 8b2ed7a..2bdc615 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;
+}
diff --git a/hw/pci-hotplug.c b/hw/pci-hotplug.c
index b59be2a..f08d367 100644
--- a/hw/pci-hotplug.c
+++ b/hw/pci-hotplug.c
@@ -103,24 +103,13 @@ static int scsi_hot_add(Monitor *mon, DeviceState
*adapter,
return 0;
}
-void drive_hot_add(Monitor *mon, const QDict *qdict)
+int pci_drive_hot_add(Monitor *mon, const QDict *qdict,
+ DriveInfo *dinfo, int type)
{
int dom, pci_bus;
unsigned slot;
- int type;
PCIDevice *dev;
- DriveInfo *dinfo = NULL;
const char *pci_addr = qdict_get_str(qdict, "pci_addr");
- 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_SCSI:
@@ -137,19 +126,14 @@ void drive_hot_add(Monitor *mon, const QDict *qdict)
goto err;
}
break;
- 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;
+ return 0;
err:
- if (dinfo)
- drive_put_ref(dinfo);
- return;
+ return -1;
}
static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon,
diff --git a/sysemu.h b/sysemu.h
index 22cd720..bfd9505 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -143,9 +143,13 @@ extern unsigned int nb_prom_envs;
/* pci-hotplug */
void pci_device_hot_add(Monitor *mon, const QDict *qdict);
-void drive_hot_add(Monitor *mon, const QDict *qdict);
+int pci_drive_hot_add(Monitor *mon, const QDict *qdict,
+ DriveInfo *dinfo, int type);
void do_pci_device_hot_remove(Monitor *mon, const QDict *qdict);
+/* generic hotplug */
+void drive_hot_add(Monitor *mon, const QDict *qdict);
+
/* pcie aer error injection */
void pcie_aer_inject_error_print(Monitor *mon, const QObject *data);
int do_pcie_aer_inejct_error(Monitor *mon,
--
1.6.0.2
- [Qemu-devel] [PULL 00/16] s390 patch queue 2011-11-11 for 1.0, Alexander Graf, 2011/11/11
- [Qemu-devel] [PATCH 02/16] Compile device-hotplug on all targets, Alexander Graf, 2011/11/11
- [Qemu-devel] [PATCH 05/16] s390x: add ldeb instruction, Alexander Graf, 2011/11/11
- [Qemu-devel] [PATCH 04/16] Expose drive_add on all architectures, Alexander Graf, 2011/11/11
- [Qemu-devel] [PATCH 06/16] s390x: make ipte 31-bit aware, Alexander Graf, 2011/11/11
- [Qemu-devel] [PATCH 13/16] s390x: Add shutdown for TCG s390-virtio machine, Alexander Graf, 2011/11/11
- [Qemu-devel] [PATCH 07/16] s390x: update R and C bits in storage key, Alexander Graf, 2011/11/11
- [Qemu-devel] [PATCH 14/16] tcg: Standardize on TCGReg as the enum for hard registers, Alexander Graf, 2011/11/11
- [Qemu-devel] [PATCH 09/16] s390x: implement SIGP restart and shutdown, Alexander Graf, 2011/11/11
- [Qemu-devel] [PATCH 03/16] Add generic drive hotplugging,
Alexander Graf <=
- [Qemu-devel] [PATCH 10/16] s390: fix reset hypercall to reset the status, Alexander Graf, 2011/11/11
- [Qemu-devel] [PATCH 16/16] s390x: initialize virtio dev region, Alexander Graf, 2011/11/11
- [Qemu-devel] [PATCH 12/16] s390: Fix cpu shutdown for KVM, Alexander Graf, 2011/11/11
- [Qemu-devel] [PATCH 01/16] [S390] Add hotplug support, Alexander Graf, 2011/11/11
- [Qemu-devel] [PATCH 11/16] s390: fix short kernel command lines, Alexander Graf, 2011/11/11
- [Qemu-devel] [PATCH 15/16] tcg: Use TCGReg for standard tcg-target entry points., Alexander Graf, 2011/11/11
- [Qemu-devel] [PATCH 08/16] s390x: implement rrbe instruction properly, Alexander Graf, 2011/11/11
- Re: [Qemu-devel] [PULL 00/16] s390 patch queue 2011-11-11 for 1.0, Blue Swirl, 2011/11/13