Skip to contentSkip to conversation

block: output more error messages if failed to create temporary snapshot

PATCH In review [email protected] 3 participants 3 messages Sep 5, 2012 – Sep 7, 2012

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 block: output more error messages if failed to create temporary snapshot

From: Dunrong Huang <[email protected]>

If we failed to create temporary snapshot, the error message did not match with the error, for example:

$ TMPDIR=/tmp/bad_path qemu-system-x86_64 -enable-kvm debian.qcow2 -snapshot
qemu-system-x86_64: -enable-kvm: could not open disk image /home/mathslinux/Images/debian.qcow2: No such file or directory

Indeed, the file which cant be created is /tmp/bad_path/vl.xxxxxx, not debian.qcow2. so the error message makes users feel confused.

---
v1 -> v2:
Output error message only if fd < 0
v2 -> v3:
Output error message in the caller of get_tmp_filename()

 block.c | 2 ++

1 个文件被修改,插入 2 行(+)

block.c +2 -0
index 470bdcc..074987e 100644
@@ -764,6 +764,8 @@ int bdrv_open(BlockDriverState *bs, const char *filename, int flags,
 
         ret = get_tmp_filename(tmp_filename, sizeof(tmp_filename));
         if (ret < 0) {
+            fprintf(stderr, "Could not create temporary snapshot %s: %s\n",
+                    tmp_filename, strerror(errno));
             return ret;
         }
 
Signature · 1 line
1.7.12
#1 lore raw

Il 05/09/2012 15:24, [email protected] ha scritto:

Quoted 26 lines

From: Dunrong Huang <[email protected]>

If we failed to create temporary snapshot, the error message did not match with the error, for example:

$ TMPDIR=/tmp/bad_path qemu-system-x86_64 -enable-kvm debian.qcow2 -snapshot
qemu-system-x86_64: -enable-kvm: could not open disk image /home/mathslinux/Images/debian.qcow2: No such file or directory

Indeed, the file which cant be created is /tmp/bad_path/vl.xxxxxx, not debian.qcow2. so the error message makes users feel confused.

---
v1 -> v2:
Output error message only if fd < 0
v2 -> v3:
Output error message in the caller of get_tmp_filename()

 block.c | 2 ++

1 个文件被修改,插入 2 行(+)

block.c +0 -0
index 470bdcc..074987e 100644

block.c int bdrv_open(BlockDriverState *bs, const char *filename, int flags, · line 771

Quoted 8 lines
block.c +2 -0
@@ -764,6 +764,8 @@ int bdrv_open(BlockDriverState *bs, const char *filename, int flags,
 
         ret = get_tmp_filename(tmp_filename, sizeof(tmp_filename));
         if (ret < 0) {
+            fprintf(stderr, "Could not create temporary snapshot %s: %s\n",
+                    tmp_filename, strerror(errno));
             return ret;
         }
 

Looks good.

Paolo

#2 lore raw
In reply to [email protected]

Am 05.09.2012 15:24, schrieb [email protected]:

Quoted 25 lines

From: Dunrong Huang <[email protected]>

If we failed to create temporary snapshot, the error message did not match with the error, for example:

$ TMPDIR=/tmp/bad_path qemu-system-x86_64 -enable-kvm debian.qcow2 -snapshot
qemu-system-x86_64: -enable-kvm: could not open disk image /home/mathslinux/Images/debian.qcow2: No such file or directory

Indeed, the file which cant be created is /tmp/bad_path/vl.xxxxxx, not debian.qcow2. so the error message makes users feel confused.

---
v1 -> v2:
Output error message only if fd < 0
v2 -> v3:
Output error message in the caller of get_tmp_filename()

 block.c | 2 ++

1 个文件被修改,插入 2 行(+)

block.c +0 -0
index 470bdcc..074987e 100644

block.c int bdrv_open(BlockDriverState *bs, const char *filename, int flags, · line 768

Quoted 5 lines
block.c +2 -0
@@ -764,6 +764,8 @@ int bdrv_open(BlockDriverState *bs, const char *filename, int flags,
 
         ret = get_tmp_filename(tmp_filename, sizeof(tmp_filename));
         if (ret < 0) {
+            fprintf(stderr, "Could not create temporary snapshot %s: %s\n",
+                    tmp_filename, strerror(errno));

This should be strerror(-ret). Also consider using error_report() instead of fprintf().

block.c int bdrv_open(BlockDriverState *bs, const char *filename, int flags, · line 771

Quoted 3 lines
block.c +0 -0
             return ret;
         }
 

Kevin