From: Maxim Levitsky <mlevitsk@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
Maxim Levitsky <mlevitsk@redhat.com>,
qemu-block@nongnu.org, Markus Armbruster <armbru@redhat.com>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
Gerd Hoffmann <kraxel@redhat.com>, Max Reitz <mreitz@redhat.com>
Subject: [PATCH v4 11/11] monitor/hmp: Move hmp_drive_add_node to block-hmp-cmds.c
Date: Thu, 30 Jan 2020 14:34:48 +0200 [thread overview]
Message-ID: <20200130123448.21093-12-mlevitsk@redhat.com> (raw)
In-Reply-To: <20200130123448.21093-1-mlevitsk@redhat.com>
Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
block/monitor/block-hmp-cmds.c | 30 ++++++++++++++++++++++++
blockdev.c | 42 +++++++---------------------------
include/block/block_int.h | 5 ++--
3 files changed, 41 insertions(+), 36 deletions(-)
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
index 2ee96f3258..67098e3d51 100644
--- a/block/monitor/block-hmp-cmds.c
+++ b/block/monitor/block-hmp-cmds.c
@@ -54,6 +54,36 @@
#include "block/block-hmp-cmds.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)
{
Error *err = NULL;
diff --git a/blockdev.c b/blockdev.c
index f2c5ea8a87..d422ac4fe3 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -64,7 +64,7 @@
#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);
static int do_open_tray(const char *blk_name, const char *qdev_id,
@@ -75,6 +75,11 @@ static void blockdev_insert_medium(bool has_device, const char *device,
bool has_id, const char *id,
const char *node_name, Error **errp);
+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",
@@ -652,7 +657,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;
@@ -4232,37 +4237,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;
@@ -4292,7 +4266,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);
diff --git a/include/block/block_int.h b/include/block/block_int.h
index dd033d0b37..10df257a61 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -1217,8 +1217,6 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
BlockCompletionFunc *cb, void *opaque,
JobTxn *txn, Error **errp);
-void hmp_drive_add_node(Monitor *mon, const char *optstr);
-
BdrvChild *bdrv_root_attach_child(BlockDriverState *child_bs,
const char *child_name,
const BdrvChildRole *child_role,
@@ -1320,4 +1318,7 @@ int coroutine_fn bdrv_co_copy_range_to(BdrvChild *src, uint64_t src_offset,
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 */
--
2.17.2
next prev parent reply other threads:[~2020-01-30 12:41 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-30 12:34 [PATCH v4 00/11] RFC: [for 5.0]: HMP monitor handlers refactoring Maxim Levitsky
2020-01-30 12:34 ` [PATCH v4 01/11] usb/dev-storage: remove unused include Maxim Levitsky
2020-01-30 12:34 ` [PATCH v4 02/11] monitor/hmp: uninline add_init_drive Maxim Levitsky
2020-03-03 17:10 ` Kevin Wolf
2020-03-04 8:12 ` Maxim Levitsky
2020-01-30 12:34 ` [PATCH v4 03/11] monitor/hmp: rename device-hotplug.c to block/monitor/block-hmp-cmds.c Maxim Levitsky
2020-01-30 12:34 ` [PATCH v4 04/11] monitor/hmp: move hmp_drive_del and hmp_commit to block-hmp-cmds.c Maxim Levitsky
2020-01-30 12:34 ` [PATCH v4 05/11] monitor/hmp: move hmp_drive_mirror and hmp_drive_backup to block-hmp-cmds.c Moved code was added after 2012-01-13, thus under GPLv2+ Maxim Levitsky
2020-01-30 12:34 ` [PATCH v4 06/11] monitor/hmp: move hmp_block_job* to block-hmp-cmds.c Maxim Levitsky
2020-01-30 12:34 ` [PATCH v4 07/11] monitor/hmp: move hmp_snapshot_* to block-hmp-cmds.c hmp_snapshot_blkdev is from GPLv2 version of the hmp-cmds.c thus have to change the licence to GPLv2 Maxim Levitsky
2020-03-03 17:15 ` Kevin Wolf
2020-03-04 8:13 ` Maxim Levitsky
2020-01-30 12:34 ` [PATCH v4 08/11] monitor/hmp: move hmp_nbd_server* to block-hmp-cmds.c Maxim Levitsky
2020-01-30 12:34 ` [PATCH v4 09/11] monitor/hmp: move remaining hmp_block* functions " Maxim Levitsky
2020-01-30 12:34 ` [PATCH v4 10/11] monitor/hmp: move hmp_info_block* " Maxim Levitsky
2020-01-30 12:34 ` Maxim Levitsky [this message]
2020-02-03 19:57 ` [PATCH v4 00/11] RFC: [for 5.0]: HMP monitor handlers refactoring Dr. David Alan Gilbert
2020-02-04 8:15 ` Maxim Levitsky
2020-02-07 18:28 ` Dr. David Alan Gilbert
2020-02-20 17:06 ` Maxim Levitsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200130123448.21093-12-mlevitsk@redhat.com \
--to=mlevitsk@redhat.com \
--cc=armbru@redhat.com \
--cc=dgilbert@redhat.com \
--cc=kraxel@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).