diff options
author | Kevin Wolf <kwolf@redhat.com> | 2013-09-18 15:14:47 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2013-10-11 16:50:01 +0200 |
commit | 2d246f01d374c1a10c48c45aa931aa18f0a56634 (patch) | |
tree | 05ab336e82b1862554ad1ddfdf7f699ed0b67f4c /blockdev.c | |
parent | 622f557f5aaea1326c94ca4cddfa4eafeade3723 (diff) | |
download | qemu-2d246f01d374c1a10c48c45aa931aa18f0a56634.tar.gz qemu-2d246f01d374c1a10c48c45aa931aa18f0a56634.tar.bz2 qemu-2d246f01d374c1a10c48c45aa931aa18f0a56634.zip |
blockdev: Introduce DriveInfo.enable_auto_del
BlockDriverStates shouldn't be affected by an unplugged guest device,
except if created with the legacy -drive command line option or the
drive_add HMP command.
Make the automatic deletion as well as cancelling of jobs conditional on
an enable_auto_del boolean that is only set in drive_init().
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Diffstat (limited to 'blockdev.c')
-rw-r--r-- | blockdev.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/blockdev.c b/blockdev.c index ab79df7bff..52996eada3 100644 --- a/blockdev.c +++ b/blockdev.c @@ -89,6 +89,10 @@ void blockdev_mark_auto_del(BlockDriverState *bs) { DriveInfo *dinfo = drive_get_by_blockdev(bs); + if (dinfo && !dinfo->enable_auto_del) { + return; + } + if (bs->job) { block_job_cancel(bs->job); } @@ -746,6 +750,7 @@ static void qemu_opt_rename(QemuOpts *opts, const char *from, const char *to) DriveInfo *drive_init(QemuOpts *all_opts, BlockInterfaceType block_default_type) { const char *value; + DriveInfo *dinfo; /* Change legacy command line options into QMP ones */ qemu_opt_rename(all_opts, "iops", "throttling.iops-total"); @@ -794,7 +799,17 @@ DriveInfo *drive_init(QemuOpts *all_opts, BlockInterfaceType block_default_type) qemu_opt_unset(all_opts, "cache"); } - return blockdev_init(all_opts, block_default_type); + /* Actual block device init: Functionality shared with blockdev-add */ + dinfo = blockdev_init(all_opts, block_default_type); + if (dinfo == NULL) { + goto fail; + } + + /* Set legacy DriveInfo fields */ + dinfo->enable_auto_del = true; + +fail: + return dinfo; } void do_commit(Monitor *mon, const QDict *qdict) |