|
|
9ae3a8 |
From 543610e2a818c44591670da35107ae8d17406382 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
Date: Tue, 5 Nov 2013 14:08:59 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 46/87] blockdev: Introduce DriveInfo.enable_auto_del
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1383660558-32096-6-git-send-email-kwolf@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 55384
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.0 qemu-kvm PATCH 05/24] blockdev: Introduce DriveInfo.enable_auto_del
|
|
|
9ae3a8 |
Bugzilla: 978402
|
|
|
9ae3a8 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
BlockDriverStates shouldn't be affected by an unplugged guest device,
|
|
|
9ae3a8 |
except if created with the legacy -drive command line option or the
|
|
|
9ae3a8 |
drive_add HMP command.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Make the automatic deletion as well as cancelling of jobs conditional on
|
|
|
9ae3a8 |
an enable_auto_del boolean that is only set in drive_init().
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
9ae3a8 |
Reviewed-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
|
|
|
9ae3a8 |
(cherry picked from commit 2d246f01d374c1a10c48c45aa931aa18f0a56634)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
blockdev.c | 17 ++++++++++++++++-
|
|
|
9ae3a8 |
include/sysemu/blockdev.h | 1 +
|
|
|
9ae3a8 |
2 files changed, 17 insertions(+), 1 deletion(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
blockdev.c | 17 ++++++++++++++++-
|
|
|
9ae3a8 |
include/sysemu/blockdev.h | 1 +
|
|
|
9ae3a8 |
2 files changed, 17 insertions(+), 1 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/blockdev.c b/blockdev.c
|
|
|
9ae3a8 |
index 2fb6d83..e379a91 100644
|
|
|
9ae3a8 |
--- a/blockdev.c
|
|
|
9ae3a8 |
+++ b/blockdev.c
|
|
|
9ae3a8 |
@@ -89,6 +89,10 @@ void blockdev_mark_auto_del(BlockDriverState *bs)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
DriveInfo *dinfo = drive_get_by_blockdev(bs);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+ if (dinfo && !dinfo->enable_auto_del) {
|
|
|
9ae3a8 |
+ return;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
if (bs->job) {
|
|
|
9ae3a8 |
block_job_cancel(bs->job);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
@@ -747,6 +751,7 @@ static void qemu_opt_rename(QemuOpts *opts, const char *from, const char *to)
|
|
|
9ae3a8 |
DriveInfo *drive_init(QemuOpts *all_opts, BlockInterfaceType block_default_type)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
const char *value;
|
|
|
9ae3a8 |
+ DriveInfo *dinfo;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
/* Change legacy command line options into QMP ones */
|
|
|
9ae3a8 |
qemu_opt_rename(all_opts, "iops", "throttling.iops-total");
|
|
|
9ae3a8 |
@@ -784,7 +789,17 @@ DriveInfo *drive_init(QemuOpts *all_opts, BlockInterfaceType block_default_type)
|
|
|
9ae3a8 |
qemu_opt_unset(all_opts, "cache");
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- return blockdev_init(all_opts, block_default_type);
|
|
|
9ae3a8 |
+ /* Actual block device init: Functionality shared with blockdev-add */
|
|
|
9ae3a8 |
+ dinfo = blockdev_init(all_opts, block_default_type);
|
|
|
9ae3a8 |
+ if (dinfo == NULL) {
|
|
|
9ae3a8 |
+ goto fail;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ /* Set legacy DriveInfo fields */
|
|
|
9ae3a8 |
+ dinfo->enable_auto_del = true;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+fail:
|
|
|
9ae3a8 |
+ return dinfo;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
void do_commit(Monitor *mon, const QDict *qdict)
|
|
|
9ae3a8 |
diff --git a/include/sysemu/blockdev.h b/include/sysemu/blockdev.h
|
|
|
9ae3a8 |
index 804ec88..1082091 100644
|
|
|
9ae3a8 |
--- a/include/sysemu/blockdev.h
|
|
|
9ae3a8 |
+++ b/include/sysemu/blockdev.h
|
|
|
9ae3a8 |
@@ -37,6 +37,7 @@ struct DriveInfo {
|
|
|
9ae3a8 |
int bus;
|
|
|
9ae3a8 |
int unit;
|
|
|
9ae3a8 |
int auto_del; /* see blockdev_mark_auto_del() */
|
|
|
9ae3a8 |
+ bool enable_auto_del; /* Only for legacy drive_init() */
|
|
|
9ae3a8 |
int media_cd;
|
|
|
9ae3a8 |
int cyls, heads, secs, trans;
|
|
|
9ae3a8 |
QemuOpts *opts;
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.1
|
|
|
9ae3a8 |
|