[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [v1 Patch 5/10]Qemu: raw-posix image file reopen
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [v1 Patch 5/10]Qemu: raw-posix image file reopen |
Date: |
Fri, 15 Jun 2012 16:11:21 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 |
On 06/15/2012 02:48 PM, Supriya Kannery wrote:
> raw-posix driver changes for bdrv_reopen_xx functions to
> safely reopen image files. Reopening of image files while
> changing hostcache dynamically is handled here.
>
> Signed-off-by: Supriya Kannery <address@hidden>
>
>
> +static int raw_reopen_prepare(BlockDriverState *bs, BDRVReopenState **prs,
> + int flags)
> +{
> + BDRVRawReopenState *raw_rs = g_malloc0(sizeof(BDRVRawReopenState));
> + BDRVRawState *s = bs->opaque;
> + int ret = 0;
> +
> + raw_rs->reopen_state.bs = bs;
> +
> + /* stash state before reopen */
> + raw_rs->stash_s = g_malloc0(sizeof(BDRVRawState));
> +/* memcpy(raw_rs->stash_s, s, sizeof(BDRVRawState)); */
Why the comment?
> + raw_stash_state(raw_rs->stash_s, s);
> + s->fd = dup(raw_rs->stash_s->fd);
Needs to handle O_CLOEXEC open flag, which means using
fcntl(F_DUPFD_CLOEXEC) when available for atomic support, and a fallback
to fcntl(F_GETFD/F_SETFD) if not.
> +
> + *prs = &(raw_rs->reopen_state);
> +
> + /* Flags that can be set using fcntl */
> + int fcntl_flags = BDRV_O_NOCACHE;
> +
> + if ((bs->open_flags & ~fcntl_flags) == (flags & ~fcntl_flags)) {
> + if ((flags & BDRV_O_NOCACHE)) {
> + s->open_flags |= O_DIRECT;
> + } else {
> + s->open_flags &= ~O_DIRECT;
> + }
> + ret = fcntl_setfl(s->fd, s->open_flags);
> + } else {
> +
> + /* close and reopen using new flags */
> + bs->drv->bdrv_close(bs);
> + ret = bs->drv->bdrv_file_open(bs, bs->filename, flags);
Is this a case where Paolo's proposed bdrv_swap command would be useful?
> + /* revert to stashed state */
> + if (s->fd != -1) {
> + close(s->fd);
> + }
> +/* memcpy(s, raw_rs->stash_s, sizeof(BDRVRawState)); */
Why the comment?
--
Eric Blake address@hidden +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- [Qemu-devel] [v1 Patch 0/10]Qemu: Dynamic host pagecache change and image file reopen, Supriya Kannery, 2012/06/15
- [Qemu-devel] [v1 Patch 1/10]Qemu: Enhance "info block" to display host cache setting, Supriya Kannery, 2012/06/15
- [Qemu-devel] [v1 Patch 3/10]Qemu: Cmd "block_set_hostcache" for dynamic cache change, Supriya Kannery, 2012/06/15
- [Qemu-devel] [v1 Patch 4/10]Qemu: Framework for reopening image files safely, Supriya Kannery, 2012/06/15
- [Qemu-devel] [v1 Patch 2/10]Qemu: Error classes for hostcache setting and data sync failures, Supriya Kannery, 2012/06/15
- [Qemu-devel] [v1 Patch 6/10]Qemu: raw-win32 image file reopen, Supriya Kannery, 2012/06/15
- [Qemu-devel] [v1 Patch 5/10]Qemu: raw-posix image file reopen, Supriya Kannery, 2012/06/15
- Re: [Qemu-devel] [v1 Patch 5/10]Qemu: raw-posix image file reopen,
Eric Blake <=
- [Qemu-devel] [v1 Patch 7/10]Qemu: vmdk image file reopen, Supriya Kannery, 2012/06/15
- [Qemu-devel] [v1 Patch 8/10]Qemu: qcow2 image file reopen, Supriya Kannery, 2012/06/15
- [Qemu-devel] [v1 Patch 9/10]Qemu: qcow image file reopen, Supriya Kannery, 2012/06/15
- [Qemu-devel] [v1 Patch 10/10]Qemu: qed image file reopen, Supriya Kannery, 2012/06/15