Commit 979b67ad863aaa11172f5de781f53c77a392d64c

Authored by bellard
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 207  
208 208 static int aio_sig_num = SIGUSR2;
209 209 static BlockDriverAIOCB *first_aio; /* AIO issued */
  210 +static int aio_initialized = 0;
210 211  
211   -#ifndef QEMU_TOOL
212 212 static void aio_signal_handler(int signum)
213 213 {
  214 +#ifndef QEMU_TOOL
214 215 CPUState *env = cpu_single_env;
215 216 if (env) {
216 217 /* stop the currently executing cpu because a timer occured */
... ... @@ -221,11 +222,14 @@ static void aio_signal_handler(int signum)
221 222 }
222 223 #endif
223 224 }
  225 +#endif
224 226 }
225 227  
226 228 void qemu_aio_init(void)
227 229 {
228 230 struct sigaction act;
  231 +
  232 + aio_initialized = 1;
229 233  
230 234 sigfillset(&act.sa_mask);
231 235 act.sa_flags = 0; /* do not restart syscalls to interrupt select() */
... ... @@ -242,7 +246,6 @@ void qemu_aio_init(void)
242 246 aio_init(&ai);
243 247 }
244 248 }
245   -#endif /* !QEMU_TOOL */
246 249  
247 250 void qemu_aio_poll(void)
248 251 {
... ... @@ -293,6 +296,9 @@ static sigset_t wait_oset;
293 296 void qemu_aio_wait_start(void)
294 297 {
295 298 sigset_t set;
  299 +
  300 + if (!aio_initialized)
  301 + qemu_aio_init();
296 302 sigemptyset(&set);
297 303 sigaddset(&set, aio_sig_num);
298 304 sigprocmask(SIG_BLOCK, &set, &wait_oset);
... ... @@ -570,7 +576,7 @@ static int raw_open(BlockDriverState *bs, const char *filename, int flags)
570 576 } else {
571 577 access_flags = GENERIC_READ;
572 578 }
573   - if (flags & BDRV_O_CREATE) {
  579 + if (flags & BDRV_O_CREAT) {
574 580 create_flags = CREATE_ALWAYS;
575 581 } else {
576 582 create_flags = OPEN_EXISTING;
... ... @@ -632,15 +638,17 @@ static int raw_aio_new(BlockDriverAIOCB *acb)
632 638 if (!acb1)
633 639 return -ENOMEM;
634 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 643 return -ENOMEM;
638 644 return 0;
639 645 }
640 646  
641 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 652 RawAIOCB *acb1 = acb->opaque;
645 653 DWORD ret_count;
646 654 int ret;
... ... @@ -659,7 +667,6 @@ static int raw_aio_read(BlockDriverAIOCB *acb, int64_t sector_num,
659 667 BlockDriverState *bs = acb->bs;
660 668 BDRVRawState *s = bs->opaque;
661 669 RawAIOCB *acb1 = acb->opaque;
662   - DWORD ret_count;
663 670 int ret;
664 671 int64_t offset;
665 672  
... ... @@ -682,7 +689,6 @@ static int raw_aio_write(BlockDriverAIOCB *acb, int64_t sector_num,
682 689 BlockDriverState *bs = acb->bs;
683 690 BDRVRawState *s = bs->opaque;
684 691 RawAIOCB *acb1 = acb->opaque;
685   - DWORD ret_count;
686 692 int ret;
687 693 int64_t offset;
688 694  
... ... @@ -734,8 +740,8 @@ static int raw_truncate(BlockDriverState *bs, int64_t offset)
734 740 BDRVRawState *s = bs->opaque;
735 741 DWORD low, high;
736 742  
737   - low = length;
738   - high = length >> 32;
  743 + low = offset;
  744 + high = offset >> 32;
739 745 if (!SetFilePointer(s->hfile, low, &high, FILE_BEGIN))
740 746 return -EIO;
741 747 if (!SetEndOfFile(s->hfile))
... ...