Commit 979b67ad863aaa11172f5de781f53c77a392d64c
1 parent
83f64091
some compilation fixes
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2076 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
16 additions
and
10 deletions
block-raw.c
| @@ -207,10 +207,11 @@ typedef struct RawAIOCB { | @@ -207,10 +207,11 @@ typedef struct RawAIOCB { | ||
| 207 | 207 | ||
| 208 | static int aio_sig_num = SIGUSR2; | 208 | static int aio_sig_num = SIGUSR2; |
| 209 | static BlockDriverAIOCB *first_aio; /* AIO issued */ | 209 | static BlockDriverAIOCB *first_aio; /* AIO issued */ |
| 210 | +static int aio_initialized = 0; | ||
| 210 | 211 | ||
| 211 | -#ifndef QEMU_TOOL | ||
| 212 | static void aio_signal_handler(int signum) | 212 | static void aio_signal_handler(int signum) |
| 213 | { | 213 | { |
| 214 | +#ifndef QEMU_TOOL | ||
| 214 | CPUState *env = cpu_single_env; | 215 | CPUState *env = cpu_single_env; |
| 215 | if (env) { | 216 | if (env) { |
| 216 | /* stop the currently executing cpu because a timer occured */ | 217 | /* stop the currently executing cpu because a timer occured */ |
| @@ -221,11 +222,14 @@ static void aio_signal_handler(int signum) | @@ -221,11 +222,14 @@ static void aio_signal_handler(int signum) | ||
| 221 | } | 222 | } |
| 222 | #endif | 223 | #endif |
| 223 | } | 224 | } |
| 225 | +#endif | ||
| 224 | } | 226 | } |
| 225 | 227 | ||
| 226 | void qemu_aio_init(void) | 228 | void qemu_aio_init(void) |
| 227 | { | 229 | { |
| 228 | struct sigaction act; | 230 | struct sigaction act; |
| 231 | + | ||
| 232 | + aio_initialized = 1; | ||
| 229 | 233 | ||
| 230 | sigfillset(&act.sa_mask); | 234 | sigfillset(&act.sa_mask); |
| 231 | act.sa_flags = 0; /* do not restart syscalls to interrupt select() */ | 235 | act.sa_flags = 0; /* do not restart syscalls to interrupt select() */ |
| @@ -242,7 +246,6 @@ void qemu_aio_init(void) | @@ -242,7 +246,6 @@ void qemu_aio_init(void) | ||
| 242 | aio_init(&ai); | 246 | aio_init(&ai); |
| 243 | } | 247 | } |
| 244 | } | 248 | } |
| 245 | -#endif /* !QEMU_TOOL */ | ||
| 246 | 249 | ||
| 247 | void qemu_aio_poll(void) | 250 | void qemu_aio_poll(void) |
| 248 | { | 251 | { |
| @@ -293,6 +296,9 @@ static sigset_t wait_oset; | @@ -293,6 +296,9 @@ static sigset_t wait_oset; | ||
| 293 | void qemu_aio_wait_start(void) | 296 | void qemu_aio_wait_start(void) |
| 294 | { | 297 | { |
| 295 | sigset_t set; | 298 | sigset_t set; |
| 299 | + | ||
| 300 | + if (!aio_initialized) | ||
| 301 | + qemu_aio_init(); | ||
| 296 | sigemptyset(&set); | 302 | sigemptyset(&set); |
| 297 | sigaddset(&set, aio_sig_num); | 303 | sigaddset(&set, aio_sig_num); |
| 298 | sigprocmask(SIG_BLOCK, &set, &wait_oset); | 304 | sigprocmask(SIG_BLOCK, &set, &wait_oset); |
| @@ -570,7 +576,7 @@ static int raw_open(BlockDriverState *bs, const char *filename, int flags) | @@ -570,7 +576,7 @@ static int raw_open(BlockDriverState *bs, const char *filename, int flags) | ||
| 570 | } else { | 576 | } else { |
| 571 | access_flags = GENERIC_READ; | 577 | access_flags = GENERIC_READ; |
| 572 | } | 578 | } |
| 573 | - if (flags & BDRV_O_CREATE) { | 579 | + if (flags & BDRV_O_CREAT) { |
| 574 | create_flags = CREATE_ALWAYS; | 580 | create_flags = CREATE_ALWAYS; |
| 575 | } else { | 581 | } else { |
| 576 | create_flags = OPEN_EXISTING; | 582 | create_flags = OPEN_EXISTING; |
| @@ -632,15 +638,17 @@ static int raw_aio_new(BlockDriverAIOCB *acb) | @@ -632,15 +638,17 @@ static int raw_aio_new(BlockDriverAIOCB *acb) | ||
| 632 | if (!acb1) | 638 | if (!acb1) |
| 633 | return -ENOMEM; | 639 | return -ENOMEM; |
| 634 | acb->opaque = acb1; | 640 | acb->opaque = acb1; |
| 635 | - s->hevent = CreateEvent(NULL, TRUE, FALSE, NULL); | ||
| 636 | - if (!s->hevent) | 641 | + s->hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); |
| 642 | + if (!s->hEvent) | ||
| 637 | return -ENOMEM; | 643 | return -ENOMEM; |
| 638 | return 0; | 644 | return 0; |
| 639 | } | 645 | } |
| 640 | 646 | ||
| 641 | static void raw_aio_cb(void *opaque) | 647 | static void raw_aio_cb(void *opaque) |
| 642 | { | 648 | { |
| 643 | - BlockDriverAIOCB *acb = acb1; | 649 | + BlockDriverAIOCB *acb = opaque; |
| 650 | + BlockDriverState *bs = acb->bs; | ||
| 651 | + BDRVRawState *s = bs->opaque; | ||
| 644 | RawAIOCB *acb1 = acb->opaque; | 652 | RawAIOCB *acb1 = acb->opaque; |
| 645 | DWORD ret_count; | 653 | DWORD ret_count; |
| 646 | int ret; | 654 | int ret; |
| @@ -659,7 +667,6 @@ static int raw_aio_read(BlockDriverAIOCB *acb, int64_t sector_num, | @@ -659,7 +667,6 @@ static int raw_aio_read(BlockDriverAIOCB *acb, int64_t sector_num, | ||
| 659 | BlockDriverState *bs = acb->bs; | 667 | BlockDriverState *bs = acb->bs; |
| 660 | BDRVRawState *s = bs->opaque; | 668 | BDRVRawState *s = bs->opaque; |
| 661 | RawAIOCB *acb1 = acb->opaque; | 669 | RawAIOCB *acb1 = acb->opaque; |
| 662 | - DWORD ret_count; | ||
| 663 | int ret; | 670 | int ret; |
| 664 | int64_t offset; | 671 | int64_t offset; |
| 665 | 672 | ||
| @@ -682,7 +689,6 @@ static int raw_aio_write(BlockDriverAIOCB *acb, int64_t sector_num, | @@ -682,7 +689,6 @@ static int raw_aio_write(BlockDriverAIOCB *acb, int64_t sector_num, | ||
| 682 | BlockDriverState *bs = acb->bs; | 689 | BlockDriverState *bs = acb->bs; |
| 683 | BDRVRawState *s = bs->opaque; | 690 | BDRVRawState *s = bs->opaque; |
| 684 | RawAIOCB *acb1 = acb->opaque; | 691 | RawAIOCB *acb1 = acb->opaque; |
| 685 | - DWORD ret_count; | ||
| 686 | int ret; | 692 | int ret; |
| 687 | int64_t offset; | 693 | int64_t offset; |
| 688 | 694 | ||
| @@ -734,8 +740,8 @@ static int raw_truncate(BlockDriverState *bs, int64_t offset) | @@ -734,8 +740,8 @@ static int raw_truncate(BlockDriverState *bs, int64_t offset) | ||
| 734 | BDRVRawState *s = bs->opaque; | 740 | BDRVRawState *s = bs->opaque; |
| 735 | DWORD low, high; | 741 | DWORD low, high; |
| 736 | 742 | ||
| 737 | - low = length; | ||
| 738 | - high = length >> 32; | 743 | + low = offset; |
| 744 | + high = offset >> 32; | ||
| 739 | if (!SetFilePointer(s->hfile, low, &high, FILE_BEGIN)) | 745 | if (!SetFilePointer(s->hfile, low, &high, FILE_BEGIN)) |
| 740 | return -EIO; | 746 | return -EIO; |
| 741 | if (!SetEndOfFile(s->hfile)) | 747 | if (!SetEndOfFile(s->hfile)) |