qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: amit.shah@redhat.com, wang.yi59@zte.com.cn,
	Yi Wang <up2wing@gmail.com>,
	qemu-devel@nongnu.org, quintela@redhat.com
Subject: Re: [Qemu-devel] [PATCH] savevm: create snapshot failed when id_str already exits
Date: Tue, 10 Mar 2015 14:48:46 +0100	[thread overview]
Message-ID: <20150310134846.GE3770@noname.str.redhat.com> (raw)
In-Reply-To: <20150310132858.GB19057@stefanha-thinkpad.redhat.com>

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

Am 10.03.2015 um 14:28 hat Stefan Hajnoczi geschrieben:
> On Mon, Mar 09, 2015 at 09:32:47PM +0800, Yi Wang wrote:
> > This will trigger the problem: 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"!
> > 
> > This shows the condition:
> > # qemu-img snapshot -l win7.img.1
> > Snapshot list:
> > ID TAG VM SIZE DATE VM CLOCK
> > 1 s1 534M 2015-03-09 10:28:54 00:03:54.504
> > 
> > # qemu-img snapshot -l win7.append
> > Snapshot list:
> > ID TAG VM SIZE DATE VM CLOCK
> > 1 s2 0 2015-03-05 10:29:21 00:00:00.000
> > 
> > # virsh snapshot-create-as win7 s1
> > error: operation failed: Failed to take snapshot: Error while creating
> > snapshot on 'drive-virtio-disk1'
> 
> Then we've arrived at changing the behavior of 'savevm' so it always
> generates IDs.
> 
> Kevin: What do you think about changing savevm semantics to always
> generate IDs?

Sounds reasonable. We're free to set whatever ID we want.

However, I wouldn't set id_str = "" like in the patch below, but remove
the check qcow2_snapshot_create() and call find_new_snapshot_id()
unconditionally.

Kevin

> diff --git a/savevm.c b/savevm.c
> index ce2b6a2..bee2143 100644
> --- a/savevm.c
> +++ b/savevm.c
> @@ -1141,7 +1141,6 @@ void hmp_savevm(Monitor *mon, const QDict *qdict)
>          ret = bdrv_snapshot_find(bs, old_sn, name);
>          if (ret >= 0) {
>              pstrcpy(sn->name, sizeof(sn->name), old_sn->name);
> -            pstrcpy(sn->id_str, sizeof(sn->id_str), old_sn->id_str);
>          } else {
>              pstrcpy(sn->name, sizeof(sn->name), name);
>          }
> @@ -1178,6 +1177,12 @@ void hmp_savevm(Monitor *mon, const QDict *qdict)
>          if (bdrv_can_snapshot(bs1)) {
>              /* Write VM state size only to the image that contains the state */
>              sn->vm_state_size = (bs == bs1 ? vm_state_size : 0);
> +
> +            /* Force ID generation for each image since there could be naming
> +             * collisions.
> +             */
> +            sn->id_str[0] = '\0';
> +
>              ret = bdrv_snapshot_create(bs1, sn);
>              if (ret < 0) {
>                  monitor_printf(mon, "Error while creating snapshot on '%s'\n",



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

  reply	other threads:[~2015-03-10 13:48 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 [this message]
2015-03-11 12:57                 ` Stefan Hajnoczi
2015-03-12 15:29                   ` Yi Wang
2015-03-24 11:41                     ` Stefan Hajnoczi

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=20150310134846.GE3770@noname.str.redhat.com \
    --to=kwolf@redhat.com \
    --cc=amit.shah@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 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).