thebeanogamer / rpms / qemu-kvm

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