All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Maxim Levitsky <mlevitsk@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
	qemu-block@nongnu.org, Markus Armbruster <armbru@redhat.com>,
	qemu-devel@nongnu.org, Max Reitz <mreitz@redhat.com>,
	Gerd Hoffmann <kraxel@redhat.com>
Subject: Re: [PATCH v3 11/13] monitor: Move hmp_drive_add_node to block-hmp-cmds.c
Date: Tue, 28 Jan 2020 19:03:37 +0000	[thread overview]
Message-ID: <20200128190337.GF3215@work-vm> (raw)
In-Reply-To: <20200127103647.17761-12-mlevitsk@redhat.com>

* Maxim Levitsky (mlevitsk@redhat.com) wrote:
> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>

Looks OK to me, I'm not clear on the name for 'bdrv_set_monitor_owned'
I'd want a block person to OK that, but:


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 a4b1604aee..7bbe4e3814 100644
> --- a/block/monitor/block-hmp-cmds.c
> +++ b/block/monitor/block-hmp-cmds.c
> @@ -33,6 +33,36 @@
>  #include "monitor/hmp.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 df43e0aaef..63805f34b5 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;
>  
> @@ -4201,37 +4206,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;
> @@ -4261,7 +4235,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
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



  reply	other threads:[~2020-01-28 19:49 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-27 10:36 [PATCH v3 00/13] RFC: [for 5.0]: HMP monitor handlers cleanups Maxim Levitsky
2020-01-27 10:36 ` [PATCH v3 01/13] usb/dev-storage: remove unused include Maxim Levitsky
2020-01-27 10:49   ` Philippe Mathieu-Daudé
2020-01-27 10:49     ` Philippe Mathieu-Daudé
2020-01-27 10:36 ` [PATCH v3 02/13] monitor/hmp: uninline add_init_drive Maxim Levitsky
2020-01-27 10:36 ` [PATCH v3 03/13] monitor/hmp: rename device-hotplug.c to block/monitor/block-hmp-cmds.c Maxim Levitsky
2020-01-28 16:56   ` Dr. David Alan Gilbert
2020-01-28 19:28     ` Maxim Levitsky
2020-01-29 10:19       ` Markus Armbruster
2020-01-29 11:31         ` Maxim Levitsky
2020-01-27 10:36 ` [PATCH v3 04/13] monitor/hmp: move hmp_drive_del and hmp_commit to block-hmp-cmds.c Maxim Levitsky
2020-01-28 17:51   ` Dr. David Alan Gilbert
2020-01-28 19:29     ` Maxim Levitsky
2020-01-27 10:36 ` [PATCH v3 05/13] monitor/hmp: move hmp_drive_mirror and hmp_drive_backup " Maxim Levitsky
2020-01-28 17:59   ` Dr. David Alan Gilbert
2020-01-27 10:36 ` [PATCH v3 06/13] monitor/hmp: move hmp_block_job* " Maxim Levitsky
2020-01-28 18:11   ` Dr. David Alan Gilbert
2020-01-28 18:15   ` Dr. David Alan Gilbert
2020-01-27 10:36 ` [PATCH v3 07/13] monitor/hmp: move hmp_snapshot_* " Maxim Levitsky
2020-01-28 18:53   ` Dr. David Alan Gilbert
2020-01-27 10:36 ` [PATCH v3 08/13] monitor/hmp: move hmp_nbd_server* " Maxim Levitsky
2020-01-28 18:56   ` Dr. David Alan Gilbert
2020-01-28 20:05     ` Eric Blake
2020-01-27 10:36 ` [PATCH v3 09/13] monitor/hmp: move remaining hmp_block* functions " Maxim Levitsky
2020-01-28 18:45   ` Dr. David Alan Gilbert
2020-01-28 18:51   ` Dr. David Alan Gilbert
2020-01-27 10:36 ` [PATCH v3 10/13] monitor/hmp: move hmp_info_block* " Maxim Levitsky
2020-01-28 19:00   ` Dr. David Alan Gilbert
2020-01-27 10:36 ` [PATCH v3 11/13] monitor: Move hmp_drive_add_node " Maxim Levitsky
2020-01-28 19:03   ` Dr. David Alan Gilbert [this message]
2020-01-28 19:30     ` Maxim Levitsky
2020-01-27 10:36 ` [PATCH v3 12/13] add 'error' prefix to vreport Maxim Levitsky
2020-01-28 19:30   ` Maxim Levitsky
2020-01-29 10:38     ` Markus Armbruster
2020-01-29 10:58       ` Maxim Levitsky
2020-01-27 10:36 ` [PATCH v3 13/13] monitor/hmp: Prefer to use hmp_handle_error for error reporting in block hmp commands Maxim Levitsky
2020-01-28 19:31   ` Maxim Levitsky
2020-01-29 10:27     ` Markus Armbruster
2020-01-29 11:05       ` Maxim Levitsky
2020-01-27 10:55 ` [PATCH v3 00/13] RFC: [for 5.0]: HMP monitor handlers cleanups no-reply
2020-01-27 10:59   ` Maxim Levitsky
2020-01-27 19:39 ` John Snow
2020-01-27 20:43   ` Peter Krempa
2020-01-27 21:01     ` John Snow
2020-01-28  9:13       ` Ján Tomko
2020-01-28 16:47       ` Dr. David Alan Gilbert
2020-02-05 23:25         ` John Snow
2020-02-06  9:35           ` Dr. David Alan Gilbert
2020-01-28  8:17     ` Markus Armbruster

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=20200128190337.GF3215@work-vm \
    --to=dgilbert@redhat.com \
    --cc=armbru@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mlevitsk@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.