[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: |
Mon, 14 Jan 2013 16:39:43 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 |
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 <address@hidden>
> ---
> 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
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- Re: [Qemu-devel] [PATCH V3 02/11] block: add bdrv_get_filename() function, (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(),
Eric Blake <=
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