qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Supriya Kannery <supriyak@linux.vnet.ibm.com>
Cc: Stefan Hajnoczi <stefanha@gmail.com>,
	Christoph Hellwig <hch@lst.de>,
	qemu-devel@nongnu.org, Luiz Capitulino <lcapitulino@redhat.com>
Subject: Re: [Qemu-devel] [RFC Patch 6/7]Qemu: raw-win32 image file reopen
Date: Wed, 08 Feb 2012 16:02:55 +0100	[thread overview]
Message-ID: <4F328E9F.1040106@redhat.com> (raw)
In-Reply-To: <20120201030726.2990.68290.sendpatchset@skannery.in.ibm.com>

Am 01.02.2012 04:07, schrieb Supriya Kannery:
> win32  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 <supriyak@linux.vnet.ibm.com>
> 
> Index: qemu/block/raw-win32.c
> ===================================================================
> --- qemu.orig/block/raw-win32.c
> +++ qemu/block/raw-win32.c
> @@ -26,18 +26,27 @@
>  #include "block_int.h"
>  #include "module.h"
>  #include <windows.h>
> +#include <winbase.h>
>  #include <winioctl.h>
>  
>  #define FTYPE_FILE 0
>  #define FTYPE_CD     1
>  #define FTYPE_HARDDISK 2
> +#define WINDOWS_VISTA 6
>  
>  typedef struct BDRVRawState {
>      HANDLE hfile;
>      int type;
>      char drive_path[16]; /* format: "d:\" */
> +    DWORD overlapped;
>  } BDRVRawState;
>  
> +typedef struct BDRVRawReopenState {
> +    BDRVReopenState reopen_state;
> +    HANDLE stash_hfile;
> +    DWORD  stash_overlapped;
> +} BDRVRawReopenState;
> +
>  int qemu_ftruncate64(int fd, int64_t length)
>  {
>      LARGE_INTEGER li;
> @@ -106,9 +115,96 @@ static int raw_open(BlockDriverState *bs
>              return -EACCES;
>          return -1;
>      }
> +    s->overlapped = overlapped;
>      return 0;
>  }
>  
> +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;
> +    OSVERSIONINFO osvi;
> +    BOOL bIsWindowsVistaorLater;
> +
> +    raw_rs->bs = bs;
> +    raw_rs->stash_hfile = s->hfile;
> +    raw_rs->stash_overlapped = s->overlapped;
> +    *prs = raw_rs;
> +
> +    if (flags & BDRV_O_NOCACHE) {
> +        s->overlapped |= FILE_FLAG_NO_BUFFERING;
> +    } else {
> +        s->overlapped &= ~FILE_FLAG_NO_BUFFERING;
> +    }
> +
> +    if (!(flags & BDRV_O_CACHE_WB)) {
> +        s->overlapped |= FILE_FLAG_WRITE_THROUGH;
> +    } else {
> +        s->overlapped &= ~FILE_FLAG_WRITE_THROUGH;
> +    }
> +
> +    ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
> +    osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
> +
> +    GetVersionEx(&osvi);
> +
> +    if (osvi.dwMajorVersion >= WINDOWS_VISTA) {
> +        s->hfile = ReOpenFile(raw_rs->stash_hfile, 0, FILE_SHARE_READ,
> +                              overlapped);
> +        if (s->hfile == INVALID_HANDLE_VALUE) {
> +            int err = GetLastError();
> +            if (err == ERROR_ACCESS_DENIED) {
> +                ret = -EACCES;
> +            } else {
> +                ret = -1;

Returning -1 where -errno is expected is bad (turns out as -EPERM on
Linux, which is misleading). Maybe -EIO here.

Kevin

  reply	other threads:[~2012-02-08 15:01 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-01  3:05 [Qemu-devel] [RFC Patch 0/7]Qemu: Dynamic host pagecache change Supriya Kannery
2012-02-01  3:06 ` [Qemu-devel] [RFC Patch 1/7]Qemu: Enhance "info block" to display host cache setting Supriya Kannery
2012-02-08 12:00   ` Luiz Capitulino
2012-02-13 13:19     ` Supriya Kannery
2012-02-01  3:06 ` [Qemu-devel] [RFC Patch 2/7]Qemu: Error classes for file reopen and data sync failure Supriya Kannery
2012-02-07  7:56   ` Stefan Hajnoczi
2012-02-13 13:13     ` Supriya Kannery
2012-02-01  3:06 ` [Qemu-devel] [RFC Patch 3/7]Qemu: Cmd "block_set_hostcache" for dynamic cache change Supriya Kannery
2012-02-02  0:09   ` Michael Roth
2012-02-02 10:14     ` Kevin Wolf
2012-02-08 12:07   ` Luiz Capitulino
2012-02-13 13:21     ` Supriya Kannery
2012-02-01  3:06 ` [Qemu-devel] [RFC Patch 4/7]Qemu: Framework for reopening image files safely Supriya Kannery
2012-02-07 10:08   ` Stefan Hajnoczi
2012-02-14 13:34     ` Supriya Kannery
2012-02-08 15:07   ` Kevin Wolf
2012-02-13 13:49     ` Supriya Kannery
2012-02-01  3:07 ` [Qemu-devel] [RFC Patch 5/7]Qemu: raw-posix image file reopen Supriya Kannery
2012-02-02  0:15   ` Michael Roth
2012-02-13 13:12     ` Supriya Kannery
2012-02-07 10:17   ` Stefan Hajnoczi
2012-02-14 13:36     ` Supriya Kannery
2012-02-08 14:54   ` Kevin Wolf
2012-02-13 13:28     ` Supriya Kannery
2012-02-01  3:07 ` [Qemu-devel] [RFC Patch 6/7]Qemu: raw-win32 " Supriya Kannery
2012-02-08 15:02   ` Kevin Wolf [this message]
2012-02-13 13:29     ` Supriya Kannery
2012-02-01  3:07 ` [Qemu-devel] [RFC Patch 7/7]Qemu: vmdk " Supriya Kannery
2012-02-01 22:41 ` [Qemu-devel] [RFC Patch 0/7]Qemu: Dynamic host pagecache change Eric Blake
2012-02-02  9:12   ` 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=4F328E9F.1040106@redhat.com \
    --to=kwolf@redhat.com \
    --cc=hch@lst.de \
    --cc=lcapitulino@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --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 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).