All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: Yi Wang <up2wing@gmail.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
	wang.yi59@zte.com.cn, quintela@redhat.com, qemu-devel@nongnu.org,
	Stefan Hajnoczi <stefanha@redhat.com>,
	amit.shah@redhat.com
Subject: Re: [Qemu-devel] [PATCH] savevm: create snapshot failed when id_str already exits
Date: Tue, 24 Mar 2015 11:41:20 +0000	[thread overview]
Message-ID: <20150324114120.GE13011@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <CAN35MuS0XLhWa5FzkeK9OybjwNWAm+1MXFrM=1A7C7u4WmHfQQ@mail.gmail.com>

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

On Thu, Mar 12, 2015 at 11:29:38PM +0800, Yi Wang wrote:
> How about this?
> 
> From 913cf2cd04167b7f6b892ac1ab405a617d886b97 Mon Sep 17 00:00:00 2001
> From: Yi Wang <up2wing@gmail.com>
> Date: Thu, 12 Mar 2015 22:54:42 +0800
> Subject: [PATCH] savevm: create snapshot failed when id_str already exists
> 
> The command "virsh create" will fail in such condition: vm has two
> disks: vda and vdb. vda has snapshot s1 with id "1", vdb doesn't have
> s1 but has snapshot s2 with id "1"。When we want to run command "virsh
> create s1", del_existing_snapshots() only deletes s1 in vda, and
> bdrv_snapshot_create() tries to create vdb's snapshot s1 with id "1",
> but id "1" alreay exists in vdb with name "s2"!
> 
> The simplest way is call find_new_snapshot_id() unconditionally.
> 
> Signed-off-by: Yi Wang <up2wing@gmail.com>
> ---
>  block/qcow2-snapshot.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c
> index 5b3903c..cb00f56 100644
> --- a/block/qcow2-snapshot.c
> +++ b/block/qcow2-snapshot.c
> @@ -351,10 +351,8 @@ int qcow2_snapshot_create(BlockDriverState *bs,
> QEMUSnapshotInfo *sn_info)
> 
>      memset(sn, 0, sizeof(*sn));
> 
> -    /* Generate an ID if it wasn't passed */
> -    if (sn_info->id_str[0] == '\0') {
> -        find_new_snapshot_id(bs, sn_info->id_str, sizeof(sn_info->id_str));
> -    }
> +    /* Generate an ID */
> +    find_new_snapshot_id(bs, sn_info->id_str, sizeof(sn_info->id_str));
> 
>      /* Check that the ID is unique */
>      if (find_snapshot_by_id_and_name(bs, sn_info->id_str, NULL) >= 0) {
> -- 
> 1.9.5.msysgit.0

Thanks, I've applied the patch to the block-next branch for QEMU 2.4:
https://github.com/stefanha/qemu/commits/block-next

Please send future patches as separate top-level email threads using
git-send-email(1).  I missed this reply since it was not a new email
thread.  git-am(1) refuses to apply the patch because of line-wrapping
in your email, I had to fix that manually.

Also, please stick to ASCII characters when possible.  Your patch
description uses the Chinese full stop (句號).  I had to manually edit
the patch because git-am(1) refuses to apply a copy-pasted patch without
explicit character encoding information.

Stefan

[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]

      reply	other threads:[~2015-03-24 11:41 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-11 17:12 [Qemu-devel] [PATCH] savevm: create snapshot failed when id_str already exits Yi Wang
2015-02-23 10:38 ` Amit Shah
2015-02-25  9:41 ` Stefan Hajnoczi
2015-03-05 13:05   ` Yi Wang
2015-03-05 17:40     ` Stefan Hajnoczi
2015-03-06 14:35       ` Yi Wang
2015-03-06 15:50         ` Stefan Hajnoczi
2015-03-09 13:32           ` Yi Wang
2015-03-10 13:28             ` Stefan Hajnoczi
2015-03-10 13:48               ` Kevin Wolf
2015-03-11 12:57                 ` Stefan Hajnoczi
2015-03-12 15:29                   ` Yi Wang
2015-03-24 11:41                     ` Stefan Hajnoczi [this message]

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=20150324114120.GE13011@stefanha-thinkpad.redhat.com \
    --to=stefanha@gmail.com \
    --cc=amit.shah@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=stefanha@redhat.com \
    --cc=up2wing@gmail.com \
    --cc=wang.yi59@zte.com.cn \
    /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.