monitor/hmp: Move hmp_drive_add_node to block-hmp-cmds.c
Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Message-Id: <20200308092440.23564-12-mlevitsk@redhat.com> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
This commit is contained in:
parent
2bcad73c4b
commit
89802d5ae7
|
@ -56,6 +56,36 @@
|
||||||
#include "block/block-hmp-cmds.h"
|
#include "block/block-hmp-cmds.h"
|
||||||
#include "qemu-io.h"
|
#include "qemu-io.h"
|
||||||
|
|
||||||
|
static 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
bdrv_set_monitor_owned(bs);
|
||||||
|
out:
|
||||||
|
qemu_opts_del(opts);
|
||||||
|
}
|
||||||
|
|
||||||
void hmp_drive_add(Monitor *mon, const QDict *qdict)
|
void hmp_drive_add(Monitor *mon, const QDict *qdict)
|
||||||
{
|
{
|
||||||
Error *err = NULL;
|
Error *err = NULL;
|
||||||
|
|
43
blockdev.c
43
blockdev.c
|
@ -64,9 +64,14 @@
|
||||||
#include "qemu/main-loop.h"
|
#include "qemu/main-loop.h"
|
||||||
#include "qemu/throttle-options.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);
|
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] = {
|
static const char *const if_name[IF_COUNT] = {
|
||||||
[IF_NONE] = "none",
|
[IF_NONE] = "none",
|
||||||
[IF_IDE] = "ide",
|
[IF_IDE] = "ide",
|
||||||
|
@ -640,7 +645,7 @@ err_no_opts:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Takes the ownership of bs_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;
|
int bdrv_flags = 0;
|
||||||
|
|
||||||
|
@ -3719,38 +3724,6 @@ out:
|
||||||
aio_context_release(aio_context);
|
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)
|
void qmp_blockdev_add(BlockdevOptions *options, Error **errp)
|
||||||
{
|
{
|
||||||
BlockDriverState *bs;
|
BlockDriverState *bs;
|
||||||
|
@ -3780,7 +3753,7 @@ void qmp_blockdev_add(BlockdevOptions *options, Error **errp)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
QTAILQ_INSERT_TAIL(&monitor_bdrv_states, bs, monitor_list);
|
bdrv_set_monitor_owned(bs);
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
visit_free(v);
|
visit_free(v);
|
||||||
|
|
|
@ -1216,8 +1216,6 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
|
||||||
BlockCompletionFunc *cb, void *opaque,
|
BlockCompletionFunc *cb, void *opaque,
|
||||||
JobTxn *txn, Error **errp);
|
JobTxn *txn, Error **errp);
|
||||||
|
|
||||||
void hmp_drive_add_node(Monitor *mon, const char *optstr);
|
|
||||||
|
|
||||||
BdrvChild *bdrv_root_attach_child(BlockDriverState *child_bs,
|
BdrvChild *bdrv_root_attach_child(BlockDriverState *child_bs,
|
||||||
const char *child_name,
|
const char *child_name,
|
||||||
const BdrvChildRole *child_role,
|
const BdrvChildRole *child_role,
|
||||||
|
@ -1322,4 +1320,7 @@ int coroutine_fn bdrv_co_copy_range_to(BdrvChild *src, uint64_t src_offset,
|
||||||
|
|
||||||
int refresh_total_sectors(BlockDriverState *bs, int64_t hint);
|
int refresh_total_sectors(BlockDriverState *bs, int64_t hint);
|
||||||
|
|
||||||
|
void bdrv_set_monitor_owned(BlockDriverState *bs);
|
||||||
|
BlockDriverState *bds_tree_init(QDict *bs_opts, Error **errp);
|
||||||
|
|
||||||
#endif /* BLOCK_INT_H */
|
#endif /* BLOCK_INT_H */
|
||||||
|
|
Loading…
Reference in New Issue