|
@@ -64,9 +64,14 @@
|
|
|
#include "qemu/main-loop.h"
|
|
|
#include "qemu/throttle-options.h"
|
|
|
|
|
|
-static QTAILQ_HEAD(, BlockDriverState) monitor_bdrv_states =
|
|
|
+QTAILQ_HEAD(, BlockDriverState) monitor_bdrv_states =
|
|
|
QTAILQ_HEAD_INITIALIZER(monitor_bdrv_states);
|
|
|
|
|
|
+void bdrv_set_monitor_owned(BlockDriverState *bs)
|
|
|
+{
|
|
|
+ QTAILQ_INSERT_TAIL(&monitor_bdrv_states, bs, monitor_list);
|
|
|
+}
|
|
|
+
|
|
|
static const char *const if_name[IF_COUNT] = {
|
|
|
[IF_NONE] = "none",
|
|
|
[IF_IDE] = "ide",
|
|
@@ -640,7 +645,7 @@ err_no_opts:
|
|
|
}
|
|
|
|
|
|
/* Takes the ownership of bs_opts */
|
|
|
-static BlockDriverState *bds_tree_init(QDict *bs_opts, Error **errp)
|
|
|
+BlockDriverState *bds_tree_init(QDict *bs_opts, Error **errp)
|
|
|
{
|
|
|
int bdrv_flags = 0;
|
|
|
|
|
@@ -3719,38 +3724,6 @@ out:
|
|
|
aio_context_release(aio_context);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-void hmp_drive_add_node(Monitor *mon, const char *optstr)
|
|
|
-{
|
|
|
- QemuOpts *opts;
|
|
|
- QDict *qdict;
|
|
|
- Error *local_err = NULL;
|
|
|
-
|
|
|
- opts = qemu_opts_parse_noisily(&qemu_drive_opts, optstr, false);
|
|
|
- if (!opts) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- qdict = qemu_opts_to_qdict(opts, NULL);
|
|
|
-
|
|
|
- if (!qdict_get_try_str(qdict, "node-name")) {
|
|
|
- qobject_unref(qdict);
|
|
|
- error_report("'node-name' needs to be specified");
|
|
|
- goto out;
|
|
|
- }
|
|
|
-
|
|
|
- BlockDriverState *bs = bds_tree_init(qdict, &local_err);
|
|
|
- if (!bs) {
|
|
|
- error_report_err(local_err);
|
|
|
- goto out;
|
|
|
- }
|
|
|
-
|
|
|
- QTAILQ_INSERT_TAIL(&monitor_bdrv_states, bs, monitor_list);
|
|
|
-
|
|
|
-out:
|
|
|
- qemu_opts_del(opts);
|
|
|
-}
|
|
|
-
|
|
|
void qmp_blockdev_add(BlockdevOptions *options, Error **errp)
|
|
|
{
|
|
|
BlockDriverState *bs;
|
|
@@ -3780,7 +3753,7 @@ void qmp_blockdev_add(BlockdevOptions *options, Error **errp)
|
|
|
goto fail;
|
|
|
}
|
|
|
|
|
|
- QTAILQ_INSERT_TAIL(&monitor_bdrv_states, bs, monitor_list);
|
|
|
+ bdrv_set_monitor_owned(bs);
|
|
|
|
|
|
fail:
|
|
|
visit_free(v);
|