[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH 3/3] block: prohibit migration during transactions
From: |
John Snow |
Subject: |
[Qemu-block] [PATCH 3/3] block: prohibit migration during transactions |
Date: |
Thu, 1 Oct 2015 12:34:33 -0400 |
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 <address@hidden>
---
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