From: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
To: Li Zhi Hui <zhihuili@linux.vnet.ibm.com>
Cc: kwolf@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2] block: Use bdrv functions to replace file operation in cow.c
Date: Mon, 7 Nov 2011 08:34:36 +0000 [thread overview]
Message-ID: <20111107083435.GA8972@stefanha-thinkpad.localdomain> (raw)
In-Reply-To: <1320648737-22798-1-git-send-email-zhihuili@linux.vnet.ibm.com>
On Mon, Nov 07, 2011 at 02:52:17PM +0800, Li Zhi Hui wrote:
> @@ -260,10 +261,15 @@ static int cow_create(const char *filename, QEMUOptionParameter *options)
> options++;
> }
>
> - cow_fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
> - 0644);
> - if (cow_fd < 0)
> - return -errno;
> + ret = bdrv_create_file(filename, options);
> + if (ret < 0) {
> + return ret;
> + }
> +
> + ret = bdrv_file_open(&cow_bs, filename, BDRV_O_RDWR);
> + if (ret < 0) {
> + return ret;
> + }
> memset(&cow_header, 0, sizeof(cow_header));
> cow_header.magic = cpu_to_be32(COW_MAGIC);
> cow_header.version = cpu_to_be32(COW_VERSION);
> @@ -271,16 +277,16 @@ static int cow_create(const char *filename, QEMUOptionParameter *options)
> /* Note: if no file, we put a dummy mtime */
> cow_header.mtime = cpu_to_be32(0);
>
> - fd = open(image_filename, O_RDONLY | O_BINARY);
> - if (fd < 0) {
> - close(cow_fd);
> + ret = bdrv_file_open(&image_bs, image_filename, BDRV_O_RDWR);
> + if (ret < 0) {
> + bdrv_close(cow_bs);
This should be bdrv_delete() instead of bdrv_close() because
bdrv_file_open() does bdrv_new() to allocate the BlockDriverState - it
needs to be freed.
The same applies to the other hunks in this patch.
Stefan
next prev parent reply other threads:[~2011-11-07 9:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-07 6:52 [Qemu-devel] [PATCH v2] block: Use bdrv functions to replace file operation in cow.c Li Zhi Hui
2011-11-07 8:34 ` Stefan Hajnoczi [this message]
2011-11-07 11:27 ` Kevin Wolf
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=20111107083435.GA8972@stefanha-thinkpad.localdomain \
--to=stefanha@linux.vnet.ibm.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=zhihuili@linux.vnet.ibm.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).