All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pavel Hrdina <phrdina@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: aliguori@us.ibm.com, stefanha@gmail.com, qemu-devel@nongnu.org,
	lcapitulino@redhat.com, pbonzini@redhat.com,
	Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Subject: Re: [Qemu-devel] [PATCH V3 07/11] block: export function bdrv_find_snapshot()
Date: Tue, 15 Jan 2013 14:18:16 +0100	[thread overview]
Message-ID: <50F55718.8030307@redhat.com> (raw)
In-Reply-To: <87fw22hcyw.fsf@blackfin.pond.sub.org>

On 01/15/2013 01:01 PM, Markus Armbruster wrote:
> Eric Blake <eblake@redhat.com> writes:
>
>> On 01/14/2013 12:09 AM, Wenchao Xia wrote:
>>>    This patch move it from savevm.c to block.c and export it.
>>>
>>> Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
>>> ---
>>>   block.c               |   23 +++++++++++++++++++++++
>>>   include/block/block.h |    2 ++
>>>   savevm.c              |   22 ----------------------
>>>   3 files changed, 25 insertions(+), 22 deletions(-)
>>>
>>> diff --git a/block.c b/block.c
>>> index 8192d8e..b7d2f03 100644
>>> --- a/block.c
>>> +++ b/block.c
>>> @@ -3351,6 +3351,29 @@ int bdrv_snapshot_load_tmp(BlockDriverState *bs,
>>>       return -ENOTSUP;
>>>   }
>>>
>>> +int bdrv_snapshot_find(BlockDriverState *bs, QEMUSnapshotInfo *sn_info,
>>> +                       const char *name)
>>> +{
>>> +    QEMUSnapshotInfo *sn_tab, *sn;
>>> +    int nb_sns, i, ret;
>>> +
>>> +    ret = -ENOENT;
>>> +    nb_sns = bdrv_snapshot_list(bs, &sn_tab);
>>> +    if (nb_sns < 0) {
>>> +        return ret;
>>> +    }
>>> +    for (i = 0; i < nb_sns; i++) {
>>> +        sn = &sn_tab[i];
>>> +        if (!strcmp(sn->id_str, name) || !strcmp(sn->name, name)) {
>>
>> It is possible (albeit probably stupid) to create a qcow2 file where
>> snapshot names are merely numeric strings.  In fact, just to see what
>> would happen, I once[1] created a file where:
>>
>> snapshot id '1' was named '2'
>> snapshot id '2' was named 'foo'
>>
>> 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, and probably worth making sure that all code
>> that looks up a snapshot by name or id goes through this function so
>> that we get the same behavior everywhere.  My experiment was done
>> several months ago, but my recollection was that at the time, there was
>> an inconsistency where 'qemu-img snapshot' picked a different snapshot
>> for the request of '2' than the online 'delvm' monitor command of qemu;
>> making it unsafe to rely on either behavior in that version of qemu
>> source code.
>>
>> [1]https://bugzilla.redhat.com/show_bug.cgi?id=733143
>
> In QemuOpts, we restricted IDs to [[:alpha:]][[:alnum:]-._]*, see
> id_wellformed().  I'd recommend the same for new interfaces.  But this
> is an old one, and we shouldn't make existing snapshots inaccessible
> just because their names were chosen unwisely.
>

There is my proposal for handling snapshots id and name.

http://lists.gnu.org/archive/html/qemu-devel/2013-01/msg01551.html

In general, we will have two options for operation with snapshots, an 
'id' option and a 'name' option. You could choose one of them or both to 
specify which snapshot you want to load/delete/create/modify.

This behaviour should be the same for online and offline snapshots even 
for vm-snapshots or block-snapshots.

With these modifications old snapshots should also works.

Pavel

  reply	other threads:[~2013-01-15 13:24 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
2013-01-15 12:01     ` Markus Armbruster
2013-01-15 13:18       ` Pavel Hrdina [this message]
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=50F55718.8030307@redhat.com \
    --to=phrdina@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=armbru@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    --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.