@@ -61,6 +61,7 @@
#include "qemu/cutils.h"
#include "qemu/help_option.h"
#include "qemu/throttle-options.h"
+#include "hw/boards.h"
static QTAILQ_HEAD(, BlockDriverState) monitor_bdrv_states =
QTAILQ_HEAD_INITIALIZER(monitor_bdrv_states);
@@ -3044,12 +3045,20 @@ BlockDirtyBitmapSha256 *qmp_x_debug_block_dirty_bitmap_sha256(const char *node,
void hmp_drive_del(Monitor *mon, const QDict *qdict)
{
+ MachineState *ms = MACHINE(current_machine);
const char *id = qdict_get_str(qdict, "id");
BlockBackend *blk;
BlockDriverState *bs;
AioContext *aio_context;
Error *local_err = NULL;
+#ifdef CONFIG_MPQEMU
+ if (g_hash_table_lookup(ms->remote_devs, id)) {
+ hmp_rdrive_del(mon, qdict);
+ return;
+ }
+#endif
+
bs = bdrv_find_node(id);
if (bs) {
qmp_blockdev_del(id, &local_err);
@@ -41,6 +41,7 @@
#include "qapi/error.h"
#include "io/proxy-link.h"
#include "sysemu/sysemu.h"
+#include "sysemu/blockdev.h"
/*
* TODO: Is there a callback where the allocated memory for QMP could be free'd
@@ -229,3 +230,28 @@ void hmp_rdrive_add(Monitor *mon, const QDict *qdict)
g_free(data);
}
+
+void hmp_rdrive_del(Monitor *mon, const QDict *qdict)
+{
+ MachineState *ms = MACHINE(current_machine);
+ Error *local_err = NULL;
+ PCIProxyDev *pdev = NULL;
+ const char *id;
+ int ret;
+
+ pdev = get_proxy_device((QDict *)qdict, "id", &local_err);
+ if (local_err) {
+ monitor_printf(mon, "rdrive_del error: %s\n",
+ error_get_pretty(local_err));
+ error_free(local_err);
+ return;
+ }
+
+ id = qdict_get_str(qdict, "id");
+
+ ret = send_monitor_msg(pdev, DRIVE_DEL, strlen(id), (uint8_t *)id);
+
+ if (!ret) {
+ (void)g_hash_table_remove(ms->remote_devs, (gpointer)id);
+ }
+}
@@ -63,6 +63,7 @@ typedef struct ProxyLinkState ProxyLinkState;
* DEVICE_ADD QMP/HMP command to hotplug device
* DEVICE_DEL QMP/HMP command to hot-unplug device
* DRIVE_ADD HMP command to hotplug drive
+ * DRIVE_DEL HMP command to hot-unplug drive
*
*/
typedef enum {
@@ -78,6 +79,7 @@ typedef enum {
DEVICE_ADD,
DEVICE_DEL,
DRIVE_ADD,
+ DRIVE_DEL,
PROXY_PING,
MAX,
} proc_cmd_t;
@@ -61,4 +61,5 @@ DriveInfo *drive_new(QemuOpts *arg, BlockInterfaceType block_default_type,
void hmp_commit(Monitor *mon, const QDict *qdict);
void hmp_drive_del(Monitor *mon, const QDict *qdict);
+void hmp_rdrive_del(Monitor *mon, const QDict *qdict);
#endif
@@ -257,6 +257,21 @@ static void process_drive_add_msg(ProcMsg *msg)
PUT_REMOTE_WAIT(wait);
}
+static void process_drive_del_msg(ProcMsg *msg)
+{
+ const char *idstr = (const char *)msg->data2;
+ int wait = msg->fds[0];
+ QDict *qdict = qdict_new();
+
+ qdict_put_str(qdict, "id", idstr);
+
+ hmp_drive_del(NULL, qdict);
+
+ notify_proxy(wait, 1);
+
+ PUT_REMOTE_WAIT(wait);
+}
+
static int init_drive(QDict *rqdict, Error **errp)
{
QemuOpts *opts;
@@ -459,6 +474,9 @@ static void process_msg(GIOCondition cond)
case DRIVE_ADD:
process_drive_add_msg(msg);
break;
+ case DRIVE_DEL:
+ process_drive_del_msg(msg);
+ break;
case PROXY_PING:
wait = msg->fds[0];
notify_proxy(wait, (uint32_t)getpid());
@@ -6,6 +6,7 @@
#include "qapi/qapi-types-misc.h"
#include "qapi/qapi-commands-misc.h"
#include "monitor/qdev.h"
+#include "sysemu/blockdev.h"
__thread Monitor *cur_mon;
@@ -55,3 +56,7 @@ void qmp_rdevice_add(QDict *qdict, QObject **ret_data, Error **errp)
void qmp_rdevice_del(const char *id, Error **errp)
{
}
+
+void hmp_rdrive_del(Monitor *mon, const QDict *qdict)
+{
+}