Patchwork Disk images deleted with -snapshot

login
register
mail settings
Submitter Blue Swirl
Date July 23, 2010, 6:14 p.m.
Message ID <AANLkTik6jAFQfxo8SwuM8vyAEfbPCKLiA4Ng+NjTbFEK@mail.gmail.com>
Download mbox | patch
Permalink /patch/59827/
State New
Headers show

Comments

Blue Swirl - July 23, 2010, 6:14 p.m.
Somehow, one of my CD images disappeared after use. It seems to be a
horrible bug with -snapshot:

$ touch image.iso image2.iso
$ qemu -cdrom image.iso -monitor stdio
QEMU 0.12.50 monitor - type 'help' for more information
(qemu) change ide1-cd0 image2.iso
(qemu) change ide1-cd0 image.iso
(qemu) q
$ qemu -snapshot -cdrom image.iso -monitor stdio
unlink(/tmp/vl.E5vyzl) in /src/qemu/block.c:466
QEMU 0.12.50 monitor - type 'help' for more information
(qemu) change ide1-cd0 image2.iso
unlink(image2.iso) in /src/qemu/block.c:466
(qemu) change ide1-cd0 image.iso
unlink(image.iso) in /src/qemu/block.c:466
Could not open 'image.iso'
(qemu) q
$ ls image*.iso
ls: cannot access image*.iso: No such file or directory

 #endif
@@ -628,6 +629,7 @@ int bdrv_open(BlockDriverState *bs, const char
*filename, int flags,

 unlink_and_fail:
     if (bs->is_temporary) {
+        fprintf(stderr, "unlink(%s) in %s:%d\n", filename, __FILE__, __LINE__);
         unlink(filename);
     }
     return ret;
@@ -647,6 +649,7 @@ void bdrv_close(BlockDriverState *bs)
         qemu_free(bs->opaque);
 #ifdef _WIN32
         if (bs->is_temporary) {
+            fprintf(stderr, "unlink(%s) in %s:%d\n", filename,
__FILE__, __LINE__);
             unlink(bs->filename);
         }
 #endif

Patch

diff --git a/block.c b/block.c
index f837876..21d5352 100644
--- a/block.c
+++ b/block.c
@@ -463,6 +463,7 @@  static int bdrv_open_common(BlockDriverState *bs,
const char *filename,

 #ifndef _WIN32
     if (bs->is_temporary) {
+        fprintf(stderr, "unlink(%s) in %s:%d\n", filename, __FILE__, __LINE__);
         unlink(filename);
     }