[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 44/61] blockdev: Introduce DriveInfo.enable_auto_del
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 44/61] blockdev: Introduce DriveInfo.enable_auto_del |
Date: |
Fri, 11 Oct 2013 17:05:34 +0200 |
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 <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Wenchao Xia <address@hidden>
---
blockdev.c | 17 ++++++++++++++++-
include/sysemu/blockdev.h | 1 +
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/blockdev.c b/blockdev.c
index ab79df7..52996ea 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)
diff --git a/include/sysemu/blockdev.h b/include/sysemu/blockdev.h
index 804ec88..1082091 100644
--- a/include/sysemu/blockdev.h
+++ b/include/sysemu/blockdev.h
@@ -37,6 +37,7 @@ struct DriveInfo {
int bus;
int unit;
int auto_del; /* see blockdev_mark_auto_del() */
+ bool enable_auto_del; /* Only for legacy drive_init() */
int media_cd;
int cyls, heads, secs, trans;
QemuOpts *opts;
--
1.8.1.4
- [Qemu-devel] [PULL 34/61] blkdebug: Employ error parameter, (continued)
- [Qemu-devel] [PULL 34/61] blkdebug: Employ error parameter, Kevin Wolf, 2013/10/11
- [Qemu-devel] [PULL 35/61] blkverify: Employ error parameter, Kevin Wolf, 2013/10/11
- [Qemu-devel] [PULL 36/61] qemu-iotests: move blank lines of output in case 059, Kevin Wolf, 2013/10/11
- [Qemu-devel] [PULL 37/61] block/raw-posix: Employ error parameter, Kevin Wolf, 2013/10/11
- [Qemu-devel] [PULL 38/61] tests: build the helper program by default, Kevin Wolf, 2013/10/11
- [Qemu-devel] [PULL 39/61] build: add command check-clean, Kevin Wolf, 2013/10/11
- [Qemu-devel] [PULL 42/61] qapi-types/visit.py: Pass whole expr dict for structs, Kevin Wolf, 2013/10/11
- [Qemu-devel] [PULL 40/61] vmdk: convert error code to use errp, Kevin Wolf, 2013/10/11
- [Qemu-devel] [PULL 43/61] qapi-types/visit.py: Inheritance for structs, Kevin Wolf, 2013/10/11
- [Qemu-devel] [PULL 41/61] vmdk: refuse enabling zeroed grain with flat images, Kevin Wolf, 2013/10/11
- [Qemu-devel] [PULL 44/61] blockdev: Introduce DriveInfo.enable_auto_del,
Kevin Wolf <=
- [Qemu-devel] [PULL 45/61] blockdev: 'blockdev-add' QMP command, Kevin Wolf, 2013/10/11
- [Qemu-devel] [PULL 47/61] blockdev: Pass QDict to blockdev_init(), Kevin Wolf, 2013/10/11
- [Qemu-devel] [PULL 46/61] blockdev: Separate ID generation from DriveInfo creation, Kevin Wolf, 2013/10/11
- [Qemu-devel] [PULL 48/61] blockdev: Move parsing of 'media' option to drive_init, Kevin Wolf, 2013/10/11
- [Qemu-devel] [PULL 49/61] blockdev: Move parsing of 'if' option to drive_init, Kevin Wolf, 2013/10/11
- [Qemu-devel] [PULL 50/61] blockdev: Moving parsing of geometry options to drive_init, Kevin Wolf, 2013/10/11
- [Qemu-devel] [PULL 51/61] blockdev: Move parsing of 'boot' option to drive_init, Kevin Wolf, 2013/10/11
- [Qemu-devel] [PULL 52/61] blockdev: Move bus/unit/index processing to drive_init, Kevin Wolf, 2013/10/11
- [Qemu-devel] [PULL 53/61] blockdev: Move virtio-blk device creation to drive_init, Kevin Wolf, 2013/10/11
- [Qemu-devel] [PULL 54/61] blockdev: Remove IF_* check for read-only blockdev_init, Kevin Wolf, 2013/10/11