[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH V3 07/11] block: export function bdrv_find_snaps
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH V3 07/11] block: export function bdrv_find_snapshot() |
Date: |
Tue, 15 Jan 2013 10:57:54 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 |
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.
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.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- [Qemu-devel] [PATCH V3 05/11] block: rename bdrv_query_info to bdrv_query_block_info, (continued)
- [Qemu-devel] [PATCH V3 05/11] block: rename bdrv_query_info to bdrv_query_block_info, Wenchao Xia, 2013/01/14
- [Qemu-devel] [PATCH V3 03/11] block: add snapshot and image info query function, Wenchao Xia, 2013/01/14
- [Qemu-devel] [PATCH V3 04/11] qemu-img: switch image retrieving function, Wenchao Xia, 2013/01/14
- [Qemu-devel] [PATCH V3 07/11] block: export function bdrv_find_snapshot(), Wenchao Xia, 2013/01/14
- Re: [Qemu-devel] [PATCH V3 07/11] block: export function bdrv_find_snapshot(), Markus Armbruster, 2013/01/15
- Re: [Qemu-devel] [PATCH V3 07/11] block: export function bdrv_find_snapshot(), Pavel Hrdina, 2013/01/15
[Qemu-devel] [PATCH V3 06/11] qmp: add interface query-images., Wenchao Xia, 2013/01/14
[Qemu-devel] [PATCH V3 11/11] hmp: show snapshot on single block device, Wenchao Xia, 2013/01/14