From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43203) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zhgoe-0008BU-Mp for qemu-devel@nongnu.org; Thu, 01 Oct 2015 12:34:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zhgoe-0005CR-0U for qemu-devel@nongnu.org; Thu, 01 Oct 2015 12:34:44 -0400 From: John Snow Date: Thu, 1 Oct 2015 12:34:33 -0400 Message-Id: <1443717273-5280-4-git-send-email-jsnow@redhat.com> In-Reply-To: <1443717273-5280-1-git-send-email-jsnow@redhat.com> References: <1443717273-5280-1-git-send-email-jsnow@redhat.com> Subject: [Qemu-devel] [PATCH 3/3] block: prohibit migration during transactions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org Cc: kwolf@redhat.com, jcody@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, John Snow Similarly to BlockJobs, prohibit migration at least during the synchronous phase of a transaction. In particular, this guards internal and external snapshots, which are implemented via transaction actions through blockdev_do_action. Signed-off-by: John Snow --- blockdev.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/blockdev.c b/blockdev.c index 32b04b4..231dcf6 100644 --- a/blockdev.c +++ b/blockdev.c @@ -49,6 +49,7 @@ #include "qmp-commands.h" #include "trace.h" #include "sysemu/arch_init.h" +#include "migration/migration.h" static const char *const if_name[IF_COUNT] = { [IF_NONE] = "none", @@ -1759,6 +1760,14 @@ void qmp_transaction(TransactionActionList *dev_list, Error **errp) TransactionActionList *dev_entry = dev_list; BlkTransactionState *state, *next; Error *local_err = NULL; + Error *blocker = NULL; + int ret; + + error_setg(&blocker, "Block device(s) are in use by a Block Transaction"); + ret = migrate_add_blocker(blocker, errp); + if (ret < 0) { + goto cleanup_mig; + } QSIMPLEQ_HEAD(snap_bdrv_states, BlkTransactionState) snap_bdrv_states; QSIMPLEQ_INIT(&snap_bdrv_states); @@ -1814,6 +1823,9 @@ exit: } g_free(state); } + cleanup_mig: + migrate_del_blocker(blocker); + error_free(blocker); } -- 2.4.3