Commit 6192bc374ff3fb8d7dfc8723dee28559488dfff5
1 parent
a917d384
Flush IO requests before savevm (original patch by Blue Swirl).
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2140 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
3 changed files
with
18 additions
and
0 deletions
block-raw.c
@@ -247,6 +247,17 @@ void qemu_aio_poll(void) | @@ -247,6 +247,17 @@ void qemu_aio_poll(void) | ||
247 | the_end: ; | 247 | the_end: ; |
248 | } | 248 | } |
249 | 249 | ||
250 | +/* Wait for all IO requests to complete. */ | ||
251 | +void qemu_aio_flush(void) | ||
252 | +{ | ||
253 | + qemu_aio_wait_start(); | ||
254 | + qemu_aio_poll(); | ||
255 | + while (first_aio) { | ||
256 | + qemu_aio_wait(); | ||
257 | + } | ||
258 | + qemu_aio_wait_end(); | ||
259 | +} | ||
260 | + | ||
250 | /* wait until at least one AIO was handled */ | 261 | /* wait until at least one AIO was handled */ |
251 | static sigset_t wait_oset; | 262 | static sigset_t wait_oset; |
252 | 263 |
vl.c
@@ -4551,6 +4551,9 @@ void do_savevm(const char *name) | @@ -4551,6 +4551,9 @@ void do_savevm(const char *name) | ||
4551 | return; | 4551 | return; |
4552 | } | 4552 | } |
4553 | 4553 | ||
4554 | + /* ??? Should this occur after vm_stop? */ | ||
4555 | + qemu_aio_flush(); | ||
4556 | + | ||
4554 | saved_vm_running = vm_running; | 4557 | saved_vm_running = vm_running; |
4555 | vm_stop(0); | 4558 | vm_stop(0); |
4556 | 4559 | ||
@@ -4641,6 +4644,9 @@ void do_loadvm(const char *name) | @@ -4641,6 +4644,9 @@ void do_loadvm(const char *name) | ||
4641 | return; | 4644 | return; |
4642 | } | 4645 | } |
4643 | 4646 | ||
4647 | + /* Flush all IO requests so they don't interfere with the new state. */ | ||
4648 | + qemu_aio_flush(); | ||
4649 | + | ||
4644 | saved_vm_running = vm_running; | 4650 | saved_vm_running = vm_running; |
4645 | vm_stop(0); | 4651 | vm_stop(0); |
4646 | 4652 |
vl.h
@@ -580,6 +580,7 @@ void bdrv_aio_cancel(BlockDriverAIOCB *acb); | @@ -580,6 +580,7 @@ void bdrv_aio_cancel(BlockDriverAIOCB *acb); | ||
580 | 580 | ||
581 | void qemu_aio_init(void); | 581 | void qemu_aio_init(void); |
582 | void qemu_aio_poll(void); | 582 | void qemu_aio_poll(void); |
583 | +void qemu_aio_flush(void); | ||
583 | void qemu_aio_wait_start(void); | 584 | void qemu_aio_wait_start(void); |
584 | void qemu_aio_wait(void); | 585 | void qemu_aio_wait(void); |
585 | void qemu_aio_wait_end(void); | 586 | void qemu_aio_wait_end(void); |