All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Pavel Hrdina <phrdina@redhat.com>
Cc: kwolf@redhat.com, xiawenc@linux.vnet.ibm.com,
	lcapitulino@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2 04/12] qapi: Convert delvm
Date: Wed, 24 Apr 2013 16:54:36 -0600	[thread overview]
Message-ID: <517862AC.3030500@redhat.com> (raw)
In-Reply-To: <2d4c5e75a5fa710d73fa4ffae03f4c143ba66519.1366817130.git.phrdina@redhat.com>

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

On 04/24/2013 09:32 AM, Pavel Hrdina wrote:
> QMP command vm-snapshot-delete takes two parameters: name and id. They are
> optional, but one of the name or id must be provided. If both are provided they
> will match only the snapshot with the same name and id. The command returns
> SnapshotInfo only if the snapshot exists, otherwise it returns an error message.
> 
> HMP command delvm now uses the new vm-snapshot-delete, but behave slightly

s/but behave/and behaves/

> different. The delvm takes one optional flag -i and one parameter name. If you
> provide only the name parameter, it will match only snapshots with that name.
> If you also provide the flag, it will match only snapshots with name as id.
> Information about successfully deleted snapshot will be printed, otherwise
> an error message will be printed.
> 
> These improves behavior of the command to be more strict on selecting snapshots
> because actual behavior is wrong. Now if you want to delete snapshot with name '2'
> but there is no snapshot with that name it could delete snapshot with id '2' and
> that isn't what you want.
> 
> There is also small hack to ensure that in each block device with different
> driver type the correct snapshot is deleted. The 'qcow2' and 'sheepdog' internally
> search at first for id but 'rbd' has only name and therefore search only for name.
> 
> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> ---
>  hmp-commands.hx         | 14 +++++-----
>  hmp.c                   | 33 +++++++++++++++++++++++
>  hmp.h                   |  1 +
>  include/sysemu/sysemu.h |  1 -
>  qapi-schema.json        | 17 ++++++++++++
>  qmp-commands.hx         | 38 +++++++++++++++++++++++++++
>  savevm.c                | 69 +++++++++++++++++++++++++++++++++++++++----------
>  7 files changed, 153 insertions(+), 20 deletions(-)
> 

> +void hmp_vm_snapshot_delete(Monitor *mon, const QDict *qdict)
> +{
> +    const char *name = qdict_get_try_str(qdict, "name");
> +    const bool id = qdict_get_try_bool(qdict, "id", false);

Don't know that the 'const' is really needed here, but doesn't hurt.

> +    Error *local_err = NULL;
> +    SnapshotInfo *info;
> +
> +    if (id) {
> +        info = qmp_vm_snapshot_delete(false, NULL, true, name, &local_err);
> +    } else {
> +        info = qmp_vm_snapshot_delete(true, name, false, NULL, &local_err);
> +    }
> +
> +    if (info) {
> +        char buf[256];

I know this fixed-size buffer is just a copy-and-paste from other code
that displays snapshot information, but I really hate it. On the other
hand, I can tolerate if we have it as an intermediate step between two
series that both land in the same release.

If your series goes in first, Wenchao's series that cleans up the
fixed-size buffer will need to be rebased to tweak this additional spot.
 If Wenchao's patches go in first, then you will have a bit of rebase
work to do.  Since we are already deferring this series into 1.6, I
think it would be nice to post a unified series of the best of both
authors, rather than continuing to waffle on what should go in first.
[And if I keep saying that often enough, I may end up getting my hands
dirty and becoming the person that posts such a unified patch, although
generally I don't like forcefully taking over someone else's initial work.]

> +++ b/qapi-schema.json
> @@ -3505,3 +3505,20 @@
>      '*asl_compiler_rev':  'uint32',
>      '*file':              'str',
>      '*data':              'str' }}
> +
> +##
> +# @vm-snapshot-delete:
> +#
> +# Delete a snapshot identified by name or id or both. One of the name or id
> +# is required. It will returns SnapshotInfo of successfully deleted snapshot.

s/returns/return/

> +#
> +# @name: #optional tag of an existing snapshot
> +#
> +# @id: #optional id of an existing snapshot
> +#
> +# Returns: SnapshotInfo on success
> +#
> +# Since: 1.5

1.6, now that we are deferring.

> +##
> +{ 'command': 'vm-snapshot-delete', 'data': {'*name': 'str', '*id': 'str'},
> +  'returns': 'SnapshotInfo' }
> diff --git a/qmp-commands.hx b/qmp-commands.hx
> index 4d65422..9b15cb4 100644
> --- a/qmp-commands.hx
> +++ b/qmp-commands.hx
> @@ -1423,6 +1423,44 @@ Example:
>  
>  EQMP
>      {
> +        .name       = "vm-snapshot-delete",
> +        .args_type  = "name:s?,id:s?",
> +        .params     = "[tag] [id]",
> +        .help       = "delete a VM snapshot from its tag or id",

Sounds slightly better if you do s/from/based on/

> +        .mhandler.cmd_new = qmp_marshal_input_vm_snapshot_delete
> +    },
> +
> +SQMP
> +vm-snapshot-delete
> +------
> +
> +Delete a snapshot identified by name or id or both. One of the name or id
> +is required. It will returns SnapshotInfo of successfully deleted snapshot.

s/returns/return/

> @@ -2556,31 +2557,73 @@ int load_vmstate(const char *name)
>      return 0;
>  }
>  
> -void do_delvm(Monitor *mon, const QDict *qdict)
> +SnapshotInfo *qmp_vm_snapshot_delete(const bool has_name, const char *name,
> +                                     const bool has_id, const char *id,
> +                                     Error **errp)

Actual function looks right to me.

-- 
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: 621 bytes --]

  reply	other threads:[~2013-04-24 22:54 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-24 15:31 [Qemu-devel] [PATCH v2 00/12] covert savevm, loadvm and delvm into qapi Pavel Hrdina
2013-04-24 15:31 ` [Qemu-devel] [PATCH v2 01/12] qemu-img: introduce qemu_img_handle_error() Pavel Hrdina
2013-04-24 16:44   ` Eric Blake
2013-04-25  2:53     ` Wenchao Xia
2013-04-25  3:00       ` Eric Blake
2013-04-24 15:32 ` [Qemu-devel] [PATCH v2 02/12] block: update error reporting for bdrv_snapshot_delete() and related functions Pavel Hrdina
2013-04-24 20:05   ` Eric Blake
2013-04-25  3:19   ` Wenchao Xia
2013-04-25 13:42   ` Stefan Hajnoczi
2013-05-03  9:53   ` Kevin Wolf
2013-04-24 15:32 ` [Qemu-devel] [PATCH v2 03/12] savevm: update bdrv_snapshot_find() to find snapshot by id or name and add error parameter Pavel Hrdina
2013-04-24 21:26   ` Eric Blake
2013-04-25  6:46     ` Pavel Hrdina
2013-04-25  8:18       ` Pavel Hrdina
2013-04-25  6:31   ` Wenchao Xia
2013-04-25  6:52     ` Pavel Hrdina
2013-04-25 12:16     ` Eric Blake
2013-04-26  2:37       ` Wenchao Xia
2013-05-03 10:24   ` Kevin Wolf
2013-04-24 15:32 ` [Qemu-devel] [PATCH v2 04/12] qapi: Convert delvm Pavel Hrdina
2013-04-24 22:54   ` Eric Blake [this message]
2013-04-25  6:58     ` Wenchao Xia
2013-04-25 12:21       ` Eric Blake
2013-04-26  2:39         ` Wenchao Xia
2013-05-03 10:50   ` Kevin Wolf
2013-04-24 15:32 ` [Qemu-devel] [PATCH v2 05/12] block: update error reporting for bdrv_snapshot_goto() and related functions Pavel Hrdina
2013-04-25 17:06   ` Eric Blake
2013-05-03 11:03   ` Kevin Wolf
2013-04-24 15:32 ` [Qemu-devel] [PATCH v2 06/12] block: update error reporting for bdrv_snapshot_list() " Pavel Hrdina
2013-04-25 18:55   ` Eric Blake
2013-04-24 15:32 ` [Qemu-devel] [PATCH v2 07/12] savevm: update error reporting for qemu_loadvm_state() Pavel Hrdina
2013-05-03 11:17   ` Kevin Wolf
2013-04-24 15:32 ` [Qemu-devel] [PATCH v2 08/12] qapi: Convert loadvm Pavel Hrdina
2013-05-03 11:31   ` Kevin Wolf
2013-04-24 15:32 ` [Qemu-devel] [PATCH v2 09/12] block: update error reporting for bdrv_snapshot_create() and related functions Pavel Hrdina
2013-04-24 15:32 ` [Qemu-devel] [PATCH v2 10/12] savevm: update error reporting of qemu_savevm_state() " Pavel Hrdina
2013-05-03 12:40   ` Kevin Wolf
2013-04-24 15:32 ` [Qemu-devel] [PATCH v2 11/12] qapi: Convert savevm Pavel Hrdina
2013-05-03 12:52   ` Kevin Wolf
2013-04-24 15:32 ` [Qemu-devel] [PATCH v2 12/12] savevm: remove backward compatibility from bdrv_snapshot_find() Pavel Hrdina
2013-05-03 12:55   ` Kevin Wolf
2013-04-24 16:15 ` [Qemu-devel] [PATCH v2 00/12] covert savevm, loadvm and delvm into qapi Eric Blake
2013-04-24 17:12   ` Luiz Capitulino
2013-04-25 13:34 ` Stefan Hajnoczi

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=517862AC.3030500@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=phrdina@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=xiawenc@linux.vnet.ibm.com \
    /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.