Revision a2736526 block/raw-win32.c

b/block/raw-win32.c
36 36
#define FTYPE_CD     1
37 37
#define FTYPE_HARDDISK 2
38 38

  
39
static QEMUWin32AIOState *aio;
40

  
39 41
typedef struct RawWin32AIOData {
40 42
    BlockDriverState *bs;
41 43
    HANDLE hfile;
......
50 52
    HANDLE hfile;
51 53
    int type;
52 54
    char drive_path[16]; /* format: "d:\" */
55
    QEMUWin32AIOState *aio;
53 56
} BDRVRawState;
54 57

  
55 58
/*
......
208 211
    }
209 212

  
210 213
    *overlapped = FILE_ATTRIBUTE_NORMAL;
214
    if (flags & BDRV_O_NATIVE_AIO) {
215
        *overlapped |= FILE_FLAG_OVERLAPPED;
216
    }
211 217
    if (flags & BDRV_O_NOCACHE) {
212 218
        *overlapped |= FILE_FLAG_NO_BUFFERING;
213 219
    }
......
222 228
    s->type = FTYPE_FILE;
223 229

  
224 230
    raw_parse_flags(flags, &access_flags, &overlapped);
231
    
232
    if ((flags & BDRV_O_NATIVE_AIO) && aio == NULL) {
233
        aio = win32_aio_init();
234
        if (aio == NULL) {
235
            return -EINVAL;
236
        }
237
    }
225 238

  
226 239
    s->hfile = CreateFile(filename, access_flags,
227 240
                          FILE_SHARE_READ, NULL,
......
231 244

  
232 245
        if (err == ERROR_ACCESS_DENIED)
233 246
            return -EACCES;
234
        return -1;
247
        return -EINVAL;
248
    }
249

  
250
    if (flags & BDRV_O_NATIVE_AIO) {
251
        int ret = win32_aio_attach(aio, s->hfile);
252
        if (ret < 0) {
253
            CloseHandle(s->hfile);
254
            return ret;
255
        }
256
        s->aio = aio;
235 257
    }
236 258
    return 0;
237 259
}
......
241 263
                         BlockDriverCompletionFunc *cb, void *opaque)
242 264
{
243 265
    BDRVRawState *s = bs->opaque;
244
    return paio_submit(bs, s->hfile, sector_num, qiov, nb_sectors,
245
                       cb, opaque, QEMU_AIO_READ);
266
    if (s->aio) {
267
        return win32_aio_submit(bs, s->aio, s->hfile, sector_num, qiov,
268
                                nb_sectors, cb, opaque, QEMU_AIO_READ); 
269
    } else {
270
        return paio_submit(bs, s->hfile, sector_num, qiov, nb_sectors,
271
                           cb, opaque, QEMU_AIO_READ);
272
    }
246 273
}
247 274

  
248 275
static BlockDriverAIOCB *raw_aio_writev(BlockDriverState *bs,
......
250 277
                          BlockDriverCompletionFunc *cb, void *opaque)
251 278
{
252 279
    BDRVRawState *s = bs->opaque;
253
    return paio_submit(bs, s->hfile, sector_num, qiov, nb_sectors,
254
                       cb, opaque, QEMU_AIO_WRITE);
280
    if (s->aio) {
281
        return win32_aio_submit(bs, s->aio, s->hfile, sector_num, qiov,
282
                                nb_sectors, cb, opaque, QEMU_AIO_WRITE); 
283
    } else {
284
        return paio_submit(bs, s->hfile, sector_num, qiov, nb_sectors,
285
                           cb, opaque, QEMU_AIO_WRITE);
286
    }
255 287
}
256 288

  
257 289
static BlockDriverAIOCB *raw_aio_flush(BlockDriverState *bs,

Also available in: Unified diff