qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Luiz Capitulino <lcapitulino@redhat.com>
To: Pavel Hrdina <phrdina@redhat.com>
Cc: kwolf@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2] qapi: converted commit
Date: Fri, 15 Jun 2012 10:58:25 -0300	[thread overview]
Message-ID: <20120615105825.08ec0945@doriath.home> (raw)
In-Reply-To: <806c66b2f071f03bec0b7d45a71512e394386885.1339617170.git.phrdina@redhat.com>

On Thu, 14 Jun 2012 09:35:21 +0200
Pavel Hrdina <phrdina@redhat.com> wrote:

> 
> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> ---
> Please ignore previous patch, I forget to change 'Since' version.
> 
>  blockdev.c       |    9 ++++-----
>  blockdev.h       |    1 -
>  hmp-commands.hx  |    2 +-
>  hmp.c            |    9 +++++++++
>  hmp.h            |    1 +
>  qapi-schema.json |   15 +++++++++++++++
>  qmp-commands.hx  |   24 ++++++++++++++++++++++++
>  7 files changed, 54 insertions(+), 7 deletions(-)
> 
> diff --git a/blockdev.c b/blockdev.c
> index 622ecba..d78af31 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -631,27 +631,26 @@ err:
>      return NULL;
>  }
>  
> -void do_commit(Monitor *mon, const QDict *qdict)
> +void qmp_commit(const char *device, Error **errp)
>  {
> -    const char *device = qdict_get_str(qdict, "device");
>      BlockDriverState *bs;
>      int ret;
>  
>      if (!strcmp(device, "all")) {

This 'all' functionality should be moved to hmp_commit(). You can call
qmp_query_block() and loop through the list of devices calling qmp_commit()
on them.

Note that we should do this even if we go for Jeff's block-commit.

>          ret = bdrv_commit_all();
>          if (ret == -EBUSY) {
> -            qerror_report(QERR_DEVICE_IN_USE, device);
> +            error_set(errp, QERR_DEVICE_IN_USE, device);
>              return;
>          }
>      } else {
>          bs = bdrv_find(device);
>          if (!bs) {
> -            qerror_report(QERR_DEVICE_NOT_FOUND, device);
> +            error_set(errp, QERR_DEVICE_NOT_FOUND, device);
>              return;
>          }
>          ret = bdrv_commit(bs);
>          if (ret == -EBUSY) {
> -            qerror_report(QERR_DEVICE_IN_USE, device);
> +            error_set(errp, QERR_DEVICE_IN_USE, device);
>              return;
>          }

bdrv_commit() can return more errors, but this will ignore them and
report success instead. We want to return qerrors for all possible
bdrv_commit() errors. But it's a good idea to wait to see if we'll use
Jeff's block-commit before making changed to this patch.

>      }
> diff --git a/blockdev.h b/blockdev.h
> index 260e16b..c2e52bb 100644
> --- a/blockdev.h
> +++ b/blockdev.h
> @@ -60,6 +60,5 @@ DriveInfo *add_init_drive(const char *opts);
>  
>  void qmp_change_blockdev(const char *device, const char *filename,
>                           bool has_format, const char *format, Error **errp);
> -void do_commit(Monitor *mon, const QDict *qdict);
>  int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data);
>  #endif
> diff --git a/hmp-commands.hx b/hmp-commands.hx
> index f5d9d91..53d2c34 100644
> --- a/hmp-commands.hx
> +++ b/hmp-commands.hx
> @@ -28,7 +28,7 @@ ETEXI
>          .args_type  = "device:B",
>          .params     = "device|all",
>          .help       = "commit changes to the disk images (if -snapshot is used) or backing files",
> -        .mhandler.cmd = do_commit,
> +        .mhandler.cmd = hmp_commit,
>      },
>  
>  STEXI
> diff --git a/hmp.c b/hmp.c
> index 2ce8cb9..176defa 100644
> --- a/hmp.c
> +++ b/hmp.c
> @@ -999,3 +999,12 @@ void hmp_netdev_del(Monitor *mon, const QDict *qdict)
>      qmp_netdev_del(id, &err);
>      hmp_handle_error(mon, &err);
>  }
> +
> +void hmp_commit(Monitor *mon, const QDict *qdict)
> +{
> +    const char *device = qdict_get_str(qdict, "device");
> +    Error *err = NULL;
> +
> +    qmp_commit(device, &err);
> +    hmp_handle_error(mon, &err);
> +}
> diff --git a/hmp.h b/hmp.h
> index 79d138d..99d57c0 100644
> --- a/hmp.h
> +++ b/hmp.h
> @@ -64,5 +64,6 @@ void hmp_device_del(Monitor *mon, const QDict *qdict);
>  void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict);
>  void hmp_netdev_add(Monitor *mon, const QDict *qdict);
>  void hmp_netdev_del(Monitor *mon, const QDict *qdict);
> +void hmp_commit(Monitor *mon, const QDict *qdict);
>  
>  #endif
> diff --git a/qapi-schema.json b/qapi-schema.json
> index 3b6e346..10cb22b 100644
> --- a/qapi-schema.json
> +++ b/qapi-schema.json
> @@ -1169,6 +1169,21 @@
>  { 'command': 'block_resize', 'data': { 'device': 'str', 'size': 'int' }}
>  
>  ##
> +# @commit
> +#
> +# Commit changes to the disk images (if -snapshot is used) or backing files.
> +#
> +# @device: the name of the device or the "all" to commit all devices
> +#
> +# Returns: nothing on success
> +#          If @device is not a valid block device, DeviceNotFound
> +#          If a long-running operation is using the device, DeviceInUse
> +#
> +# Since: 1.2
> +##
> +{ 'command': 'commit', 'data': { 'device': 'str' }}
> +
> +##
>  # @NewImageMode
>  #
>  # An enumeration that tells QEMU how to set the backing file path in
> diff --git a/qmp-commands.hx b/qmp-commands.hx
> index 2e1a38e..8b6bfbc 100644
> --- a/qmp-commands.hx
> +++ b/qmp-commands.hx
> @@ -714,6 +714,30 @@ Example:
>  -> { "execute": "block_resize", "arguments": { "device": "scratch", "size": 1073741824 } }
>  <- { "return": {} }
>  
> +
> +EQMP
> +
> +    {
> +        .name       = "commit",
> +        .args_type  = "device:B",
> +        .mhandler.cmd_new = qmp_marshal_input_commit,
> +    },
> +
> +SQMP
> +commit
> +------
> +
> +Commit changes to the disk images (if -snapshot is used) or backing files.
> +
> +Arguments:
> +
> +- "device": the device's ID, or all (json-string)
> +
> +Example:
> +
> +-> { "execute": "commit", "arguments": { "device": "all" } }
> +<- { "return": {} }
> +
>  EQMP
>  
>      {

      parent reply	other threads:[~2012-06-15 13:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-14  7:32 [Qemu-devel] [PATCH] qapi: converted commit Pavel Hrdina
2012-06-14 12:18 ` [Qemu-devel] [PATCH v2] " Eric Blake
2012-06-14 14:56   ` Pavel Hrdina
2012-06-14 15:04     ` Eric Blake
2012-06-14 15:21       ` Pavel Hrdina
2012-06-15 14:02         ` Luiz Capitulino
2012-06-15 14:11           ` Jeff Cody
2012-06-15 14:44             ` Luiz Capitulino
2012-06-15 15:35               ` Jeff Cody
2012-06-15 13:58 ` Luiz Capitulino [this message]

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=20120615105825.08ec0945@doriath.home \
    --to=lcapitulino@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=phrdina@redhat.com \
    --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).