From: Stefan Hajnoczi <stefanha@gmail.com>
To: riegamaths@gmail.com
Cc: qemu-trivial <qemu-trivial@nongnu.org>,
qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [Qemu-trivial] [PATCH] block: output more error messages if failed to create temporary snapshot
Date: Wed, 5 Sep 2012 10:40:03 +0100 [thread overview]
Message-ID: <20120905094003.GD4786@stefanha-thinkpad.localdomain> (raw)
In-Reply-To: <1346833574-26193-1-git-send-email-riegamaths@gmail.com>
On Wed, Sep 05, 2012 at 04:26:14PM +0800, riegamaths@gmail.com wrote:
> From: Dunrong Huang <riegamaths@gmail.com>
>
> 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.
>
> Signed-off-by: Dunrong Huang <riegamaths@gmail.com>
> ---
> block.c | 2 ++
> 1 个文件被修改,插入 2 行(+)
>
> diff --git a/block.c b/block.c
> index 470bdcc..c9e5140 100644
> --- a/block.c
> +++ b/block.c
> @@ -434,6 +434,8 @@ int get_tmp_filename(char *filename, int size)
> }
> fd = mkstemp(filename);
> if (fd < 0 || close(fd)) {
> + fprintf(stderr, "Could not create temporary snapshot in %s directory: "
> + "%s\n", tmpdir, strerror(errno));
The error message is fine for fd < 0 but not for close(0) != 0. Also,
close(2) is allowed to change errno (even on success) so this is not
portable and could clobber the errno value.
Please split into:
if (fd < 0) {
...
}
if (close(fd) != 0) {
...
}
Stefan
next prev parent reply other threads:[~2012-09-05 9:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-05 8:26 [Qemu-devel] [PATCH] block: output more error messages if failed to create temporary snapshot riegamaths
2012-09-05 9:40 ` Stefan Hajnoczi [this message]
2012-09-05 10:35 ` [Qemu-devel] [Qemu-trivial] " Kevin Wolf
2012-09-05 12:52 ` Dunrong Huang
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=20120905094003.GD4786@stefanha-thinkpad.localdomain \
--to=stefanha@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=riegamaths@gmail.com \
/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).