From: Jeff Cody <jcody@redhat.com>
To: Supriya Kannery <supriyak@linux.vnet.ibm.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
Shrinidhi Joshi <spjoshi31@gmail.com>,
Stefan Hajnoczi <stefanha@gmail.com>,
qemu-devel@nongnu.org, Luiz Capitulino <lcapitulino@redhat.com>,
Christoph Hellwig <hch@lst.de>
Subject: Re: [Qemu-devel] [v2 Patch 1/9]block: Framework for reopening image files safely
Date: Wed, 08 Aug 2012 17:13:50 -0400 [thread overview]
Message-ID: <5022D68E.40308@redhat.com> (raw)
In-Reply-To: <20120730213422.21536.81486.sendpatchset@skannery.in.ibm.com>
On 07/30/2012 05:34 PM, Supriya Kannery wrote:
> Struct BDRVReopenState along with three reopen related functions
> introduced for handling reopening of images safely. This can be
> extended by each of the block drivers to reopen respective
> image files.
>
> Signed-off-by: Supriya Kannery <supriyak@linux.vnet.ibm.com>
>
> ---
> Index: qemu/block.c
> ===================================================================
> --- qemu.orig/block.c
> +++ qemu/block.c
> @@ -859,6 +859,60 @@ unlink_and_fail:
> return ret;
> }
>
> +int bdrv_reopen_prepare(BlockDriverState *bs, BDRVReopenState **prs, int flags)
> +{
> + BlockDriver *drv = bs->drv;
> +
> + return drv->bdrv_reopen_prepare(bs, prs, flags);
> +}
> +
> +void bdrv_reopen_commit(BlockDriverState *bs, BDRVReopenState *rs)
> +{
> + BlockDriver *drv = bs->drv;
> +
> + drv->bdrv_reopen_commit(bs, rs);
> +}
> +
> +void bdrv_reopen_abort(BlockDriverState *bs, BDRVReopenState *rs)
> +{
> + BlockDriver *drv = bs->drv;
> +
> + drv->bdrv_reopen_abort(bs, rs);
> +}
> +
> +void bdrv_reopen(BlockDriverState *bs, int bdrv_flags, Error **errp)
> +{
> + BlockDriver *drv = bs->drv;
> + int ret = 0;
> + BDRVReopenState *reopen_state = NULL;
> +
> + /* Quiesce IO for the given block device */
> + bdrv_drain_all();
> + ret = bdrv_flush(bs);
> + if (ret != 0) {
> + error_set(errp, QERR_IO_ERROR);
> + return;
> + }
> +
> + /* Use driver specific reopen() if available */
> + if (drv->bdrv_reopen_prepare) {
> + ret = bdrv_reopen_prepare(bs, &reopen_state, bdrv_flags);
> + if (ret < 0) {
> + bdrv_reopen_abort(bs, reopen_state);
> + error_set(errp, QERR_OPEN_FILE_FAILED, bs->filename);
> + return;
> + }
> +
> + bdrv_reopen_commit(bs, reopen_state);
> + bs->open_flags = bdrv_flags;
You also need to set bs->read_only here, like so:
bs->read_only = !(bdrv_flags & BDRV_O_RDWR);
> + } else {
> + error_set(errp, QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED,
> + drv->format_name, bs->device_name,
> + "reopening of file");
> + return;
> + }
> +}
> +
> void bdrv_close(BlockDriverState *bs)
> {
> bdrv_flush(bs);
> Index: qemu/block_int.h
> ===================================================================
> --- qemu.orig/block_int.h
> +++ qemu/block_int.h
> @@ -136,6 +136,14 @@ struct BlockDriver {
> int instance_size;
> int (*bdrv_probe)(const uint8_t *buf, int buf_size, const char *filename);
> int (*bdrv_probe_device)(const char *filename);
> +
> + /* For handling image reopen for split or non-split files */
> + int (*bdrv_reopen_prepare)(BlockDriverState *bs,
> + BDRVReopenState **prs,
> + int flags);
> + void (*bdrv_reopen_commit)(BlockDriverState *bs, BDRVReopenState *rs);
> + void (*bdrv_reopen_abort)(BlockDriverState *bs, BDRVReopenState *rs);
> +
> int (*bdrv_open)(BlockDriverState *bs, int flags);
> int (*bdrv_file_open)(BlockDriverState *bs, const char *filename, int flags);
> int (*bdrv_read)(BlockDriverState *bs, int64_t sector_num,
> @@ -335,6 +343,10 @@ struct BlockDriverState {
> BlockJob *job;
> };
>
> +struct BDRVReopenState {
> + BlockDriverState *bs;
> +};
> +
> int get_tmp_filename(char *filename, int size);
>
> void bdrv_set_io_limits(BlockDriverState *bs,
> Index: qemu/block.h
> ===================================================================
> --- qemu.orig/block.h
> +++ qemu/block.h
> @@ -129,6 +129,10 @@ int bdrv_parse_cache_flags(const char *m
> int bdrv_file_open(BlockDriverState **pbs, const char *filename, int flags);
> int bdrv_open(BlockDriverState *bs, const char *filename, int flags,
> BlockDriver *drv);
> +void bdrv_reopen(BlockDriverState *bs, int bdrv_flags, Error **errp);
> +int bdrv_reopen_prepare(BlockDriverState *bs, BDRVReopenState **prs, int flags);
> +void bdrv_reopen_commit(BlockDriverState *bs, BDRVReopenState *rs);
> +void bdrv_reopen_abort(BlockDriverState *bs, BDRVReopenState *rs);
> void bdrv_close(BlockDriverState *bs);
> int bdrv_attach_dev(BlockDriverState *bs, void *dev);
> void bdrv_attach_dev_nofail(BlockDriverState *bs, void *dev);
> Index: qemu/qemu-common.h
> ===================================================================
> --- qemu.orig/qemu-common.h
> +++ qemu/qemu-common.h
> @@ -223,6 +223,7 @@ typedef struct NICInfo NICInfo;
> typedef struct HCIInfo HCIInfo;
> typedef struct AudioState AudioState;
> typedef struct BlockDriverState BlockDriverState;
> +typedef struct BDRVReopenState BDRVReopenState;
> typedef struct DriveInfo DriveInfo;
> typedef struct DisplayState DisplayState;
> typedef struct DisplayChangeListener DisplayChangeListener;
>
>
next prev parent reply other threads:[~2012-08-08 21:14 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-30 21:34 [Qemu-devel] [v2 Patch 0/9]block: Image file reopen and dynamic host pagecache change Supriya Kannery
2012-07-30 21:34 ` [Qemu-devel] [v2 Patch 1/9]block: Framework for reopening image files safely Supriya Kannery
2012-08-01 15:51 ` Stefan Hajnoczi
2012-08-02 20:19 ` Luiz Capitulino
2012-08-14 8:54 ` Supriya Kannery
2012-08-08 21:13 ` Jeff Cody [this message]
2012-08-14 9:21 ` Supriya Kannery
2012-08-09 4:26 ` Jeff Cody
2012-08-09 9:20 ` Kevin Wolf
2012-08-09 13:02 ` Jeff Cody
2012-08-14 10:24 ` Supriya Kannery
2012-07-30 21:34 ` [Qemu-devel] [v2 Patch 2/9]block: raw-posix image file reopen Supriya Kannery
2012-07-31 17:17 ` Eric Blake
2012-08-01 6:18 ` Kevin Wolf
2012-08-03 22:32 ` Jeff Cody
2012-08-14 10:53 ` Supriya Kannery
2012-08-09 4:26 ` Jeff Cody
2012-08-10 13:45 ` Corey Bryant
2012-08-14 11:13 ` Supriya Kannery
2012-08-14 11:35 ` Kevin Wolf
2012-07-30 21:34 ` [Qemu-devel] [v2 Patch 3/9]block: raw-win32 " Supriya Kannery
2012-07-30 21:35 ` [Qemu-devel] [v2 Patch 4/9]block: vmdk " Supriya Kannery
2012-07-31 17:43 ` Eric Blake
2012-07-30 21:35 ` [Qemu-devel] [v2 Patch 5/9]block: qcow2 " Supriya Kannery
2012-08-09 4:26 ` Jeff Cody
2012-08-09 9:37 ` Kevin Wolf
2012-07-30 21:35 ` [Qemu-devel] [v2 Patch 7/9]block: qed " Supriya Kannery
2012-07-30 21:36 ` [Qemu-devel] [v2 Patch 9/9]block: Enhance "info block" to display host cache setting Supriya Kannery
2012-07-31 17:47 ` Eric Blake
2012-07-31 20:33 ` [Qemu-devel] [v2 Patch 0/9]block: Image file reopen and dynamic host pagecache change Jeff Cody
2012-08-01 17:11 ` Supriya Kannery
2012-08-01 18:36 ` [Qemu-devel] [v2 Patch 6/9]block: qcow image file reopen Supriya Kannery
2012-08-01 18:44 ` [Qemu-devel] [v2 Patch 8/9]block: Cmd "block_set_hostcache" for dynamic cache change Supriya Kannery
2012-08-01 19:21 ` Eric Blake
2012-08-02 20:36 ` Luiz Capitulino
2012-08-31 19:32 ` Jeff Cody
2012-08-09 4:26 ` [Qemu-devel] [v2 Patch 0/9]block: Image file reopen and dynamic host pagecache change Jeff Cody
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=5022D68E.40308@redhat.com \
--to=jcody@redhat.com \
--cc=hch@lst.de \
--cc=kwolf@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=spjoshi31@gmail.com \
--cc=stefanha@gmail.com \
--cc=supriyak@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.