qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Julio Faracco <jcfaracco@gmail.com>
To: qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, kwolf@redhat.com,
	Julio Faracco <jcfaracco@gmail.com>
Subject: [Qemu-devel] [PATCH 2/2] qcow2-snapshot: Fixing bug of creating snapshots with the same name.
Date: Thu, 22 Jan 2015 23:53:41 -0200	[thread overview]
Message-ID: <1421978021-3609-2-git-send-email-jcfaracco@gmail.com> (raw)
In-Reply-To: <1421978021-3609-1-git-send-email-jcfaracco@gmail.com>

This commit fixes the bug #1396497. You can create multiple snapshots with
the same name using 'qemu-img'. When you want to delete someone passing the
name, it will remove the first occurence of the snapshot with that name.
This commit fixes it.

Before:
$ qemu-img snapshot -c foo debian.qcow2
$ qemu-img snapshot -c foo debian.qcow2
$ qemu-img snapshot -c foo debian.qcow2
$ qemu-img snapshot -l debian.qcow2
ID        TAG                 VM SIZE                DATE       VM CLOCK
1         foo                    220M 2015-01-21 16:22:41   00:02:50.862
2         foo                    130M 2015-01-22 11:14:55   00:00:40.132
3         foo                     65M 2015-01-22 11:16:32   00:01:13.414

Now:
$ qemu-img snapshot -c foo debian.qcow2
$ qemu-img snapshot -c foo debian.qcow2
qemu-img: Could not create snapshot 'foo': -17 (File exists)
$ qemu-img snapshot -l debian.qcow2
ID        TAG                 VM SIZE                DATE       VM CLOCK
1         foo                    220M 2015-01-21 16:22:41   00:02:50.862

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
---
 block/qcow2-snapshot.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c
index c7d4cfe..873ac49 100644
--- a/block/qcow2-snapshot.c
+++ b/block/qcow2-snapshot.c
@@ -356,8 +356,9 @@ int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
         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_or_name(bs, sn_info->id_str) >= 0) {
+    /* Check that the ID and Name is unique */
+    if (find_snapshot_by_id_or_name(bs, sn_info->id_str) >= 0 ||
+        find_snapshot_by_id_or_name(bs, sn_info->name) >= 0 ) {
         return -EEXIST;
     }
 
-- 
1.9.1

  reply	other threads:[~2015-01-23  1:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-23  1:53 [Qemu-devel] [PATCH 1/2] qcow2-snapshot: Change filter function to avoid NULL parameter when a snapshot will be created Julio Faracco
2015-01-23  1:53 ` Julio Faracco [this message]
2015-01-23 15:21   ` [Qemu-devel] [PATCH 2/2] qcow2-snapshot: Fixing bug of creating snapshots with the same name Max Reitz
2015-01-27 16:42     ` Julio Faracco

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=1421978021-3609-2-git-send-email-jcfaracco@gmail.com \
    --to=jcfaracco@gmail.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    /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).