Skip to contentSkip to conversation

multi-process: HMP command to add drive to the remote device

RFC PATCH Superseded [email protected] 1 participant 1 message Mar 7, 2019

v1 of 15 Superseded Latest is v15 →

lore
Share & tools
lore
#0 lore raw

RFC PATCH 33/37 multi-process: HMP command to add drive to the remote device

From: Jagannathan Raman <[email protected]>

Add rdrive_add HMP command to hot-plug drive to the remote device.

---
 hmp-commands.hx         | 16 ++++++++++++++++
 hw/proxy/monitor.c      | 45 +++++++++++++++++++++++++++++++++++++++++++++
 include/io/proxy-link.h |  2 ++
 include/sysemu/sysemu.h |  1 +
 remote/machine.c        |  8 ++++++++
 remote/remote-main.c    | 31 +++++++++++++++++++++++++++++++
 6 files changed, 103 insertions(+)
hmp-commands.hx +16 -0
index 7f121b4..3829203 100644
@@ -1401,6 +1401,22 @@ STEXI
 Add drive to PCI storage controller.
 ETEXI
 
+#if defined(CONFIG_MPQEMU)
+    {
+        .name       = "rdrive_add",
+        .args_type  = "rdev_id:s,id:s,opts:s",
+        .params     = "rdev_id opts",
+        .help       = "add drive to remote PCI storage controller",
+        .cmd        = hmp_rdrive_add,
+    },
+
+STEXI
+@item rdrive_add
+@findex rdrive_add
+Add drive to remote PCI storage controller.
+ETEXI
+#endif
+
     {
         .name       = "pcie_aer_inject_error",
         .args_type  = "advisory_non_fatal:-a,correctable:-c,"
hw/proxy/monitor.c +45 -0

54 lines not on this page · raw message

include/io/proxy-link.h +2 -0
index af451e8..3ef16f1 100644
@@ -62,6 +62,7 @@ typedef struct ProxyLinkState ProxyLinkState;
  *                  from remote device
  * DEVICE_ADD       QMP/HMP command to hotplug device
  * DEVICE_DEL       QMP/HMP command to hot-unplug device
+ * DRIVE_ADD        HMP command to hotplug drive
  *
  */
 typedef enum {
@@ -76,6 +77,7 @@ typedef enum {
     DRIVE_OPTS,
     DEVICE_ADD,
     DEVICE_DEL,
+    DRIVE_ADD,
     PROXY_PING,
     MAX,
 } proc_cmd_t;
include/sysemu/sysemu.h +1 -0
index 82622be..0c51fe0 100644
@@ -138,6 +138,7 @@ extern unsigned int nb_prom_envs;
 
 /* generic hotplug */
 void hmp_drive_add(Monitor *mon, const QDict *qdict);
+void hmp_rdrive_add(Monitor *mon, const QDict *qdict);
 
 /* pcie aer error injection */
 void hmp_pcie_aer_inject_error(Monitor *mon, const QDict *qdict);
remote/machine.c +8 -0
index c1c7b77..c6801ca 100644
@@ -74,6 +74,8 @@ static void remote_machine_init(Object *obj)
     MemoryRegion *system_memory, *system_io, *pci_memory;
     PCIHostState *pci_host;
     PCIDevice *pci_dev;
+    MachineState *ms;
+    MachineClass *mc;
 
     Error *error_abort = NULL;
 
@@ -116,6 +118,12 @@ static void remote_machine_init(Object *obj)
 
     pci_bus_irqs(pci_host->bus, remote_iohub_set_irq, remote_iohub_map_irq,
                  s->iohub, REMOTE_IOHUB_NB_PIRQS);
+
+    ms = MACHINE(s);
+
+    mc = MACHINE_GET_CLASS(ms);
+
+    mc->block_default_type = IF_IDE;
 }
 
 static const TypeInfo remote_machine = {
remote/remote-main.c +31 -0
index 1e45105..4c52d30 100644
@@ -234,6 +234,29 @@ fail:
     PUT_REMOTE_WAIT(wait);
 }
 
+static void process_drive_add_msg(ProcMsg *msg)
+{
+    Error *local_err = NULL;
+    const char *optstr = (const char *)msg->data2;
+    int wait = msg->fds[0];
+    QemuOpts *opts;
+    MachineClass *mc;
+
+    opts = drive_def(optstr);
+    assert(opts);
+
+    mc = MACHINE_GET_CLASS(current_machine);
+    (void)drive_new(opts, mc->block_default_type, &local_err);
+
+    if (local_err) {
+        error_report_err(local_err);
+    }
+
+    notify_proxy(wait, 1);
+
+    PUT_REMOTE_WAIT(wait);
+}
+
 static int init_drive(QDict *rqdict, Error **errp)
 {
     QemuOpts *opts;
@@ -419,6 +442,9 @@ static void process_msg(GIOCondition cond)
     case DEVICE_DEL:
         process_device_del_msg(msg);
         break;
+    case DRIVE_ADD:
+        process_drive_add_msg(msg);
+        break;
     case PROXY_PING:
         wait = msg->fds[0];
         notify_proxy(wait, (uint32_t)getpid());
@@ -462,6 +488,11 @@ int main(int argc, char *argv[])
     bdrv_init_with_whitelist();
 
     qemu_add_opts(&qemu_device_opts);
+    qemu_add_opts(&qemu_drive_opts);
+    qemu_add_drive_opts(&qemu_legacy_drive_opts);
+    qemu_add_drive_opts(&qemu_common_drive_opts);
+    qemu_add_drive_opts(&qemu_drive_opts);
+    qemu_add_drive_opts(&bdrv_runtime_opts);
 
     if (qemu_init_main_loop(&err)) {
         error_report_err(err);
Signature · 1 line
1.8.3.1