@@ -526,6 +526,17 @@ void bdrv_close(BlockDriverState *bs)
}
}
+void bdrv_close_all(void)
+{
+ BlockDriverState *bs, *n;
+
+ for (bs = bdrv_first, n = bs->next; bs; bs = n, n = bs ? bs->next : NULL) {
+ if (bs && bs->drv && bs->drv->bdrv_close) {
+ bs->drv->bdrv_close(bs);
+ }
+ }
+}
+
void bdrv_delete(BlockDriverState *bs)
{
BlockDriverState **pbs;
@@ -123,6 +123,7 @@ BlockDriverAIOCB *bdrv_aio_ioctl(BlockDriverState *bs,
/* Ensure contents are flushed to disk. */
void bdrv_flush(BlockDriverState *bs);
void bdrv_flush_all(void);
+void bdrv_close_all(void);
int bdrv_is_allocated(BlockDriverState *bs, int64_t sector_num, int nb_sectors,
int *pnum);
@@ -845,6 +845,7 @@ static void do_info_cpu_stats(Monitor *mon)
*/
static void do_quit(Monitor *mon, const QDict *qdict, QObject **ret_data)
{
+ bdrv_close_all();
exit(0);
}
@@ -4205,6 +4205,7 @@ static void main_loop(void)
vm_stop(r);
}
}
+ bdrv_close_all();
pause_all_vcpus();
}