qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Pavel Hrdina <phrdina@redhat.com>
Cc: qemu-devel@nongnu.org, phrdina@redhat.c0m, lcapitulino@redhat.com
Subject: Re: [Qemu-devel] [PATCH 13/13] vm-snapshot-save: add force parameter
Date: Wed, 09 Jan 2013 15:47:00 -0700	[thread overview]
Message-ID: <50EDF364.80905@redhat.com> (raw)
In-Reply-To: <ff0fc38e29e321f5799c1a57a179df7d4d4fdb1d.1357741229.git.phrdina@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 3903 bytes --]

On 01/09/2013 08:18 AM, Pavel Hrdina wrote:
> HMP command "savevm" now takes extra optional force parameter to specifi whether

s/specifi/specify/

> replace existing snapshot or not.
> 
> QMP command "vm-snapshot-save" has also extra optional force parameter and
> name parameter isn't optional anymore.

The qcow2 format lets 'name' be optional; why are we insisting at the
QMP layer that we cannot use this feature?  It may be a change worth
making, but you'll need more arguments in the commit message; and you'll
still need to make sure that qemu can handle an arbitrary qcow2 file
that has an existing snapshot created by older qemu when name was still
optional.

> 
> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> ---
>  hmp-commands.hx  | 15 ++++++++-------
>  hmp.c            | 25 ++++++++++++++++++++++++-
>  qapi-schema.json |  9 ++++++---
>  qmp-commands.hx  | 15 +++++++++------
>  savevm.c         | 36 ++++++++++++++----------------------
>  5 files changed, 61 insertions(+), 39 deletions(-)
> 

> +@item savevm [@var{-f}] @var{tag}|@var{id}
>  @findex savevm
> -Create a snapshot of the whole virtual machine. If @var{tag} is
> -provided, it is used as human readable identifier. If there is already
> -a snapshot with the same @var{tag} or @var{id}, it is replaced. More info at
> +Create a snapshot of the whole virtual machine. Paramtere "name" is optional.

s/Paramtere/Parameter/

> +++ b/hmp.c
> @@ -1340,8 +1340,31 @@ void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict)
>  void hmp_vm_snapshot_save(Monitor *mon, const QDict *qdict)
>  {
>      const char *name = qdict_get_try_str(qdict, "name");
> +    char new_name[256];
> +    bool force = qdict_get_try_bool(qdict, "force", 0);
>      Error *err = NULL;
> +#ifdef _WIN32
> +    struct _timeb tb;
> +    struct tm *ptm;
> +#else
> +    struct timeval tv;
> +    struct tm tm;
> +#endif
> +
> +    if (!name) {
> +#ifdef _WIN32
> +        time_t t = tb.time;
> +        ptm = localtime(&t);
> +        strftime(new_name, sizeof(new_name), "vm-%Y%m%d%H%M%S", ptm);

It feels like lots of pending patches are trying to touch this same area
of code; make sure you coordinate the efforts (for example,
http://patchwork.ozlabs.org/patch/210250/ should go in first).

> +++ b/qapi-schema.json
> @@ -3023,15 +3023,18 @@
>  #
>  # Create a snapshot of the whole virtual machine. If tag is provided as @name,
>  # it is used as human readable identifier. If there is already a snapshot
> -# with the same tag or ID, it is replaced.
> +# with the same tag or id, the force argument needs to be true to replace it.
>  #
>  # The VM is automatically stopped and resumed and saving a snapshot can take
>  # a long time.
>  #
> -# @name: #optional tag of new snapshot or tag|id of existing snapshot
> +# @name: tag of new snapshot or tag|id of existing snapshot

It feels like you are doing too much in this commit.  Either name should
never have been optional earlier in the series, or the change to make
name mandatory should be its own commit (since nothing in the one-line
summary mentions making name mandatory).

> +    if (ret >= 0) {
> +        if (has_force && force) {
>              pstrcpy(sn->name, sizeof(sn->name), old_sn->name);
>              pstrcpy(sn->id_str, sizeof(sn->id_str), old_sn->id_str);
> +
> +            /* Delete old snapshots of the same name */
> +            if (del_existing_snapshots(name, &local_err) < 0) {
> +                error_propagate(errp, local_err);
> +                goto the_end;
> +            }
>          } else {
> -            pstrcpy(sn->name, sizeof(sn->name), name);
> +            error_setg(errp, "Snapshot '%s' exist. For override add "

s/exist/exists/

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

  reply	other threads:[~2013-01-09 22:47 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-09 15:17 [Qemu-devel] [PATCH 00/13] convert savevm to use qapi and introduce qmp command Pavel Hrdina
2013-01-09 15:17 ` [Qemu-devel] [PATCH 01/13] block: add error parameter to bdrv_snapshot_create() and related functions Pavel Hrdina
2013-01-09 15:17 ` [Qemu-devel] [PATCH 02/13] block: add error parameter to del_existing_snapshots() Pavel Hrdina
2013-01-09 15:17 ` [Qemu-devel] [PATCH 03/13] savevm: add error parameter to qemu_savevm_state_begin() Pavel Hrdina
2013-01-09 15:17 ` [Qemu-devel] [PATCH 04/13] savevm: add error parameter to qemu_savevm_state_iterate() Pavel Hrdina
2013-01-09 15:17 ` [Qemu-devel] [PATCH 05/13] savevm: add error parameter to qemu_savevm_state_complete() Pavel Hrdina
2013-01-09 15:18 ` [Qemu-devel] [PATCH 06/13] savevm: add error parameter to qemu_savevm_state() Pavel Hrdina
2013-01-09 15:18 ` [Qemu-devel] [PATCH 07/13] qapi: Convert savevm Pavel Hrdina
2013-01-09 22:32   ` Eric Blake
2013-01-10  5:50     ` Wenchao Xia
2013-01-09 15:18 ` [Qemu-devel] [PATCH 08/13] qemu-img: introduce qemu_img_handle_error Pavel Hrdina
2013-01-09 15:18 ` [Qemu-devel] [PATCH 09/13] block: update return value from bdrv_snapshot_create Pavel Hrdina
2013-01-09 15:18 ` [Qemu-devel] [PATCH 10/13] savevm: update return value from qemu_savevm_state_begin Pavel Hrdina
2013-01-09 15:18 ` [Qemu-devel] [PATCH 11/13] savevm: update return value from qemu_savevm_state_complete Pavel Hrdina
2013-01-09 15:18 ` [Qemu-devel] [PATCH 12/13] savevm: update return value from qemu_savevm_state Pavel Hrdina
2013-01-09 22:39   ` Eric Blake
2013-01-10 10:35     ` Pavel Hrdina
2013-01-09 15:18 ` [Qemu-devel] [PATCH 13/13] vm-snapshot-save: add force parameter Pavel Hrdina
2013-01-09 22:47   ` Eric Blake [this message]
2013-01-10 11:54     ` Pavel Hrdina
2013-01-09 15:34 ` [Qemu-devel] [PATCH 00/13] convert savevm to use qapi and introduce qmp command Pavel Hrdina

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=50EDF364.80905@redhat.com \
    --to=eblake@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=phrdina@redhat.c0m \
    --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).