Diff for /qemu/block-raw-win32.c between versions 1.1.1.1 and 1.1.1.2

version 1.1.1.1, 2018/04/24 16:47:32 version 1.1.1.2, 2018/04/24 16:50:53
Line 22 Line 22
  * THE SOFTWARE.   * THE SOFTWARE.
  */   */
 #include "qemu-common.h"  #include "qemu-common.h"
 #ifndef QEMU_IMG  
 #include "qemu-timer.h"  #include "qemu-timer.h"
 #include "exec-all.h"  
 #endif  
 #include "block_int.h"  #include "block_int.h"
 #include <assert.h>  #include <assert.h>
 #include <winioctl.h>  #include <winioctl.h>
   
   //#define WIN32_AIO
   
 #define FTYPE_FILE 0  #define FTYPE_FILE 0
 #define FTYPE_CD     1  #define FTYPE_CD     1
 #define FTYPE_HARDDISK 2  #define FTYPE_HARDDISK 2
Line 100  static int raw_open(BlockDriverState *bs Line 99  static int raw_open(BlockDriverState *bs
     } else {      } else {
         create_flags = OPEN_EXISTING;          create_flags = OPEN_EXISTING;
     }      }
 #ifdef QEMU_IMG  #ifdef WIN32_AIO
     overlapped = FILE_ATTRIBUTE_NORMAL;  
 #else  
     overlapped = FILE_FLAG_OVERLAPPED;      overlapped = FILE_FLAG_OVERLAPPED;
   #else
       overlapped = FILE_ATTRIBUTE_NORMAL;
 #endif  #endif
     if (flags & BDRV_O_DIRECT)      if ((flags & BDRV_O_NOCACHE))
         overlapped |= FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH;          overlapped |= FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH;
       else if (!(flags & BDRV_O_CACHE_WB))
           overlapped |= FILE_FLAG_WRITE_THROUGH;
     s->hfile = CreateFile(filename, access_flags,      s->hfile = CreateFile(filename, access_flags,
                           FILE_SHARE_READ, NULL,                            FILE_SHARE_READ, NULL,
                           create_flags, overlapped, NULL);                            create_flags, overlapped, NULL);
Line 133  static int raw_pread(BlockDriverState *b Line 134  static int raw_pread(BlockDriverState *b
     ov.OffsetHigh = offset >> 32;      ov.OffsetHigh = offset >> 32;
     ret = ReadFile(s->hfile, buf, count, &ret_count, &ov);      ret = ReadFile(s->hfile, buf, count, &ret_count, &ov);
     if (!ret) {      if (!ret) {
   #ifdef WIN32_AIO
         ret = GetOverlappedResult(s->hfile, &ov, &ret_count, TRUE);          ret = GetOverlappedResult(s->hfile, &ov, &ret_count, TRUE);
         if (!ret)          if (!ret)
             return -EIO;              return -EIO;
         else          else
   #endif
             return ret_count;              return ret_count;
     }      }
     return ret_count;      return ret_count;
Line 155  static int raw_pwrite(BlockDriverState * Line 158  static int raw_pwrite(BlockDriverState *
     ov.OffsetHigh = offset >> 32;      ov.OffsetHigh = offset >> 32;
     ret = WriteFile(s->hfile, buf, count, &ret_count, &ov);      ret = WriteFile(s->hfile, buf, count, &ret_count, &ov);
     if (!ret) {      if (!ret) {
   #ifdef WIN32_AIO
         ret = GetOverlappedResult(s->hfile, &ov, &ret_count, TRUE);          ret = GetOverlappedResult(s->hfile, &ov, &ret_count, TRUE);
         if (!ret)          if (!ret)
             return -EIO;              return -EIO;
         else          else
   #endif
             return ret_count;              return ret_count;
     }      }
     return ret_count;      return ret_count;
 }  }
   
 #if 0  #ifdef WIN32_AIO
 #ifndef QEMU_IMG  
 static void raw_aio_cb(void *opaque)  static void raw_aio_cb(void *opaque)
 {  {
     RawAIOCB *acb = opaque;      RawAIOCB *acb = opaque;
Line 181  static void raw_aio_cb(void *opaque) Line 185  static void raw_aio_cb(void *opaque)
         acb->common.cb(acb->common.opaque, 0);          acb->common.cb(acb->common.opaque, 0);
     }      }
 }  }
 #endif  
   
 static RawAIOCB *raw_aio_setup(BlockDriverState *bs,  static RawAIOCB *raw_aio_setup(BlockDriverState *bs,
         int64_t sector_num, uint8_t *buf, int nb_sectors,          int64_t sector_num, uint8_t *buf, int nb_sectors,
Line 204  static RawAIOCB *raw_aio_setup(BlockDriv Line 207  static RawAIOCB *raw_aio_setup(BlockDriv
     acb->ov.OffsetHigh = offset >> 32;      acb->ov.OffsetHigh = offset >> 32;
     acb->ov.hEvent = acb->hEvent;      acb->ov.hEvent = acb->hEvent;
     acb->count = nb_sectors * 512;      acb->count = nb_sectors * 512;
 #ifndef QEMU_IMG  
     qemu_add_wait_object(acb->ov.hEvent, raw_aio_cb, acb);      qemu_add_wait_object(acb->ov.hEvent, raw_aio_cb, acb);
 #endif  
     return acb;      return acb;
 }  }
   
Line 226  static BlockDriverAIOCB *raw_aio_read(Bl Line 227  static BlockDriverAIOCB *raw_aio_read(Bl
         qemu_aio_release(acb);          qemu_aio_release(acb);
         return NULL;          return NULL;
     }      }
 #ifdef QEMU_IMG  
     qemu_aio_release(acb);      qemu_aio_release(acb);
 #endif  
     return (BlockDriverAIOCB *)acb;      return (BlockDriverAIOCB *)acb;
 }  }
   
Line 248  static BlockDriverAIOCB *raw_aio_write(B Line 247  static BlockDriverAIOCB *raw_aio_write(B
         qemu_aio_release(acb);          qemu_aio_release(acb);
         return NULL;          return NULL;
     }      }
 #ifdef QEMU_IMG  
     qemu_aio_release(acb);      qemu_aio_release(acb);
 #endif  
     return (BlockDriverAIOCB *)acb;      return (BlockDriverAIOCB *)acb;
 }  }
   
 static void raw_aio_cancel(BlockDriverAIOCB *blockacb)  static void raw_aio_cancel(BlockDriverAIOCB *blockacb)
 {  {
 #ifndef QEMU_IMG  
     RawAIOCB *acb = (RawAIOCB *)blockacb;      RawAIOCB *acb = (RawAIOCB *)blockacb;
     BlockDriverState *bs = acb->common.bs;      BlockDriverState *bs = acb->common.bs;
     BDRVRawState *s = bs->opaque;      BDRVRawState *s = bs->opaque;
Line 265  static void raw_aio_cancel(BlockDriverAI Line 261  static void raw_aio_cancel(BlockDriverAI
     /* XXX: if more than one async I/O it is not correct */      /* XXX: if more than one async I/O it is not correct */
     CancelIo(s->hfile);      CancelIo(s->hfile);
     qemu_aio_release(acb);      qemu_aio_release(acb);
 #endif  
 }  }
 #endif /* #if 0 */  #endif /* #if WIN32_AIO */
   
 static void raw_flush(BlockDriverState *bs)  static void raw_flush(BlockDriverState *bs)
 {  {
Line 346  static int raw_create(const char *filena Line 341  static int raw_create(const char *filena
     return 0;      return 0;
 }  }
   
 void qemu_aio_init(void)  
 {  
 }  
   
 void qemu_aio_poll(void)  
 {  
 }  
   
 void qemu_aio_flush(void)  
 {  
 }  
   
 void qemu_aio_wait_start(void)  
 {  
 }  
   
 void qemu_aio_wait(void)  
 {  
 #ifndef QEMU_IMG  
     qemu_bh_poll();  
 #endif  
 }  
   
 void qemu_aio_wait_end(void)  
 {  
 }  
   
 BlockDriver bdrv_raw = {  BlockDriver bdrv_raw = {
     "raw",      "raw",
     sizeof(BDRVRawState),      sizeof(BDRVRawState),
Line 384  BlockDriver bdrv_raw = { Line 352  BlockDriver bdrv_raw = {
     raw_create,      raw_create,
     raw_flush,      raw_flush,
   
 #if 0  #ifdef WIN32_AIO
     .bdrv_aio_read = raw_aio_read,      .bdrv_aio_read = raw_aio_read,
     .bdrv_aio_write = raw_aio_write,      .bdrv_aio_write = raw_aio_write,
     .bdrv_aio_cancel = raw_aio_cancel,      .bdrv_aio_cancel = raw_aio_cancel,
     .aiocb_size = sizeof(RawAIOCB);      .aiocb_size = sizeof(RawAIOCB);
 #endif  #endif
     .protocol_name = "file",  
     .bdrv_pread = raw_pread,      .bdrv_pread = raw_pread,
     .bdrv_pwrite = raw_pwrite,      .bdrv_pwrite = raw_pwrite,
     .bdrv_truncate = raw_truncate,      .bdrv_truncate = raw_truncate,
Line 470  static int hdev_open(BlockDriverState *b Line 437  static int hdev_open(BlockDriverState *b
     }      }
     create_flags = OPEN_EXISTING;      create_flags = OPEN_EXISTING;
   
 #ifdef QEMU_IMG  #ifdef WIN32_AIO
     overlapped = FILE_ATTRIBUTE_NORMAL;  
 #else  
     overlapped = FILE_FLAG_OVERLAPPED;      overlapped = FILE_FLAG_OVERLAPPED;
   #else
       overlapped = FILE_ATTRIBUTE_NORMAL;
 #endif  #endif
     if (flags & BDRV_O_DIRECT)      if ((flags & BDRV_O_NOCACHE))
         overlapped |= FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH;          overlapped |= FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH;
       else if (!(flags & BDRV_O_CACHE_WB))
           overlapped |= FILE_FLAG_WRITE_THROUGH;
     s->hfile = CreateFile(filename, access_flags,      s->hfile = CreateFile(filename, access_flags,
                           FILE_SHARE_READ, NULL,                            FILE_SHARE_READ, NULL,
                           create_flags, overlapped, NULL);                            create_flags, overlapped, NULL);
Line 536  BlockDriver bdrv_host_device = { Line 505  BlockDriver bdrv_host_device = {
     NULL,      NULL,
     raw_flush,      raw_flush,
   
 #if 0  #ifdef WIN32_AIO
     .bdrv_aio_read = raw_aio_read,      .bdrv_aio_read = raw_aio_read,
     .bdrv_aio_write = raw_aio_write,      .bdrv_aio_write = raw_aio_write,
     .bdrv_aio_cancel = raw_aio_cancel,      .bdrv_aio_cancel = raw_aio_cancel,

Removed from v.1.1.1.1  
changed lines
  Added in v.1.1.1.2


unix.superglobalmegacorp.com