qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 4/5] Add generic drive hotplugging


From: Anthony Liguori
Subject: Re: [Qemu-devel] [PATCH 4/5] Add generic drive hotplugging
Date: Mon, 23 Aug 2010 17:21:33 -0500
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.11) Gecko/20100713 Lightning/1.0b1 Thunderbird/3.0.6

On 08/23/2010 05:02 PM, Alexander Graf wrote:
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<address@hidden>

I think you really want device_add plus a blockdev_add.

Regards,

Anthony Liguori

---
  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) */
+




reply via email to

[Prev in Thread] Current Thread [Next in Thread]