qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
To: Eric Blake <eblake@redhat.com>
Cc: aliguori@us.ibm.com, phrdina@redhat.com, stefanha@gmail.com,
	qemu-devel@nongnu.org, lcapitulino@redhat.com,
	pbonzini@redhat.com, armbru@redhat.com
Subject: Re: [Qemu-devel] [PATCH V3 07/11] block: export function bdrv_find_snapshot()
Date: Wed, 16 Jan 2013 12:28:45 +0800	[thread overview]
Message-ID: <50F62C7D.5000008@linux.vnet.ibm.com> (raw)
In-Reply-To: <50F598A2.9070903@redhat.com>

于 2013-1-16 1:57, Eric Blake 写道:
> On 01/15/2013 03:24 AM, Wenchao Xia wrote:
>
>>>>
>>>> +int bdrv_snapshot_find(BlockDriverState *bs, QEMUSnapshotInfo *sn_info,
>>>> +                       const char *name)
>
>>>> +        if (!strcmp(sn->id_str, name) || !strcmp(sn->name, name)) {
>>>
>
>>>
>>> This code comparison favors ids over names; so if I request to delvm 2,
>>> I end up removing the second snapshot, not the first.  This is okay, but
>>> probably worth documenting,
>
>> how about:
>> /*  if id is not NULL, try find it with id, if not exist, return NULL
>>   *  if id is NULL and name is not NULL, try find it with name.
>>   */ if id and name is NULL, direct return fail.
>> int bdrv_snapshot_find(BlockDriverState *bs, QEMUSnapshotInfo *sn_info,
>>                         const char *id, const char *name)
>
> That would be pushing the burden onto the callers to decide whether they
> are doing an id lookup, a name lookup, or both.  In QMP terms, that
> means that your QMP command to delete a snapshot would now need an
> additional optional argument to decide whether the associated name is
> only an id, only a name, or can match either.  But I'm not sure you want
> that.
>
> What I was trying to get at is that given a single string "2", it does
> seem nicer to do both an id and a name lookup, and return the first hit;
> you just need to document that ids take preference over names (and thus,
> naming a snapshot "2" may make the snapshot become invisible by name,
> but not by id, if a later snapshot creation causes id 2 to be used).
> Then your QMP command for deleting a snapshot no longer needs to care
> whether "2" is an id or a name, just whether it matches.
>
   OK, I guess following is better and clear:

  /* Try to find the snapshot with @id and @name, @id have higher
   * priority in searching. Both @id and @name can be NULL.
   */
int bdrv_snapshot_find(BlockDriverState *bs, QEMUSnapshotInfo *sn_info,
                         const char *id, const char *name)

Then caller at hmp/qmp layer can decide how to use it. For info of
snapshot retrieving in this serial, things are simple. for create/delete
of snapshot in future, I think a check with id_wellformed() and an
interface like the proposal from Pavel is needed.
http://lists.gnu.org/archive/html/qemu-devel/2013-01/msg01551.html

> Hmm, while typing this, I thought of another snag.  Suppose you have a
> VM with two disks, but where only the first disk previously had a
> snapshot with id 1.  If I create a new snapshot across both disks, does
> that mean disk 1 gets id 2 while disk 2 gets id 1, or do both disks get
> id 2, even though that means disk 2 skips over id 1?  As long as the
> snapshot is named, you can refer to the name to get the same snapshot
> across both disks, regardless of what id it has.  But if the name is
> numeric, and id takes preference over name when doing a lookup, we could
> get ourselves into the situation where a snapshot created with name "2"
> can eventually never be restored in one piece, because the individual
> disks have different ids for the same snapshot name.  So maybe we DO
> need a way after all for QMP to specify whether a name lookup is for id,
> name, or both.
>


-- 
Best Regards

Wenchao Xia

  reply	other threads:[~2013-01-16  4:29 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-14  7:09 [Qemu-devel] [PATCH V3 00/11] add qmp/hmp interfaces for snapshot info Wenchao Xia
2013-01-14  7:09 ` [Qemu-devel] [PATCH V3 01/11] qemu-img: remove unused parameter in collect_image_info() Wenchao Xia
2013-01-14 17:08   ` Luiz Capitulino
2013-01-15  7:27     ` Wenchao Xia
2013-01-15  7:58       ` Wenchao Xia
2013-01-15 11:11         ` Luiz Capitulino
2013-01-16  3:10           ` Wenchao Xia
2013-01-16 17:56             ` Luiz Capitulino
2013-01-14  7:09 ` [Qemu-devel] [PATCH V3 02/11] block: add bdrv_get_filename() function Wenchao Xia
2013-01-14 17:08   ` Luiz Capitulino
2013-01-15  7:30     ` Wenchao Xia
2013-01-15  8:40       ` [Qemu-devel] IS_USER(s) in target-arm Shijesta Victor
2013-01-14  7:09 ` [Qemu-devel] [PATCH V3 03/11] block: add snapshot and image info query function Wenchao Xia
2013-01-14 17:22   ` Luiz Capitulino
2013-01-14  7:09 ` [Qemu-devel] [PATCH V3 04/11] qemu-img: switch image retrieving function Wenchao Xia
2013-01-14 11:25   ` Pavel Hrdina
2013-01-14 18:21     ` Luiz Capitulino
2013-01-15  2:37     ` Wenchao Xia
2013-01-14  7:09 ` [Qemu-devel] [PATCH V3 05/11] block: rename bdrv_query_info to bdrv_query_block_info Wenchao Xia
2013-01-14  7:09 ` [Qemu-devel] [PATCH V3 06/11] qmp: add interface query-images Wenchao Xia
2013-01-14 18:32   ` Luiz Capitulino
2013-01-15 10:27     ` Wenchao Xia
2013-01-14  7:09 ` [Qemu-devel] [PATCH V3 07/11] block: export function bdrv_find_snapshot() Wenchao Xia
2013-01-14 23:39   ` Eric Blake
2013-01-15 10:24     ` Wenchao Xia
2013-01-15 17:57       ` Eric Blake
2013-01-16  4:28         ` Wenchao Xia [this message]
2013-01-15 12:01     ` Markus Armbruster
2013-01-15 13:18       ` Pavel Hrdina
2013-01-14  7:09 ` [Qemu-devel] [PATCH V3 08/11] qmp: add interface query-snapshots Wenchao Xia
2013-01-14  7:09 ` [Qemu-devel] [PATCH V3 09/11] hmp: export function hmp_handle_error() Wenchao Xia
2013-01-14 18:38   ` Luiz Capitulino
2013-01-14  7:09 ` [Qemu-devel] [PATCH V3 10/11] hmp: retrieve info from qmp for snapshot info Wenchao Xia
2013-01-14  7:09 ` [Qemu-devel] [PATCH V3 11/11] hmp: show snapshot on single block device Wenchao Xia
2013-01-14 11:15   ` Pavel Hrdina
2013-01-14 18:56     ` Luiz Capitulino
2013-01-15  2:36     ` Wenchao Xia
2013-01-15 11:05       ` Luiz Capitulino
2013-01-16  2:51         ` Wenchao Xia
2013-01-14 18:56   ` Luiz Capitulino
2013-01-14 18:58 ` [Qemu-devel] [PATCH V3 00/11] add qmp/hmp interfaces for snapshot info Luiz Capitulino

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=50F62C7D.5000008@linux.vnet.ibm.com \
    --to=xiawenc@linux.vnet.ibm.com \
    --cc=aliguori@us.ibm.com \
    --cc=armbru@redhat.com \
    --cc=eblake@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=phrdina@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.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 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).