Block migration when streaming block jobs are running
v3 cover Block migration when streaming block jobs are running
From: Benoît Canet <[email protected]>
This patchset is designed to avoid starting a live migration while one or more streaming block jobs are running.
Tested with the following sequence:
QEMU 1.1.50 monitor - type 'help' for more information (qemu) block_stream virtio0 1k
(qemu) migrate tcp:localhost:4444
migrate: Migration is blocked by streaming (qemu) block_job_cancel virtio0
(qemu) migrate tcp:localhost:4444
migrate: Connection can not be completed immediately (qemu)
=> migration then succeed
in v2:
stefanha: Rename bdrv_have_block_jobs() to bdrv_are_busy() and make it return -EBUSY.
paolo: remove spurious bdrv_close()
in v3
pm215: rewrite confusing error message
Benoît Canet (3):
block: Add bdrv_are_busy()
qerror: Add error telling that streaming blocks migration
migration: block migration when streaming block jobs are running.
block.c | 13 +++++++++++++ block.h | 2 ++ migration.c | 5 +++++ qerror.c | 4 ++++ qerror.h | 3 +++ 5 files changed, 27 insertions(+)
Signature · 1 line
1.7.9.5
PATCH v3 1/3 block: Add bdrv_are_busy()
From: Benoît Canet <[email protected]>
bdrv_are_busy will be used to check if any of the bs are in use or if one of them have a running block job.
The first user will be qmp_migrate().
--- block.c | 13 +++++++++++++ block.h | 2 ++ 2 files changed, 15 insertions(+)
block.c +13 -0
@@ -4027,6 +4027,19 @@ out:return ret; } +int bdrv_are_busy (void ) +{ +BlockDriverState *bs; + + QTAILQ_FOREACH(bs, &bdrv_states, list) { +if (bs->job ||bdrv_in_use (bs)) { +return -EBUSY ; + } + } + +return 0 ; +} +void *block_job_create (const BlockJobType *job_type,BlockDriverState *bs,int64_t speed,BlockDriverCompletionFunc *cb,void *opaque,Error **errp)
block.h +2 -0
@@ -337,6 +337,8 @@ void bdrv_disable_copy_on_read(BlockDriverState *bs);void bdrv_set_in_use (BlockDriverState *bs,int in_use);int bdrv_in_use (BlockDriverState *bs); +int bdrv_are_busy (void ); +enum BlockAcctType {BDRV_ACCT_READ ,BDRV_ACCT_WRITE ,
Signature · 1 line
1.7.9.5
PATCH v3 2/3 qerror: Add error telling that streaming blocks migration
In reply to [email protected]From: Benoît Canet <[email protected]>
--- qerror.c | 4 ++++ qerror.h | 3 +++ 2 files changed, 7 insertions(+)
qerror.c +4 -0
@@ -283,6 +283,10 @@ static const QErrorStringTable qerror_table[] = { .desc = "Could not set password", }, { + .error_fmt = QERR_MIGRATION_BLOCKED_BY_STREAMING, + .desc = "Migration is blocked by streaming", + }, + { .error_fmt = QERR_TOO_MANY_FILES, .desc = "Too many open files", },
qerror.h +3 -0
@@ -233,6 +233,9 @@ QError *qobject_to_qerror(const QObject *obj);#define QERR_SET_PASSWD_FAILED \ "{ 'class': 'SetPasswdFailed', 'data': {} }" +#define QERR_MIGRATION_BLOCKED_BY_STREAMING \ + "{ 'class': 'MigrationBlockedByStreaming', 'data': {} }" +#define QERR_TOO_MANY_FILES \ "{ 'class': 'TooManyFiles', 'data': {} }"
Signature · 1 line
1.7.9.5
Re: [Qemu-devel] [PATCH V3 2/3] qerror: Add error telling that streaming blocks migration
Quoted 13 lines · On Mon, Jul 23, 2012 at 2:06 PM, <[email protected]> wrote:
From: Benoît Canet <[email protected]>
Signed-off-by Benoit Canet <[email protected]>--- qerror.c | 4 ++++ qerror.h | 3 +++ 2 files changed, 7 insertions(+)qerror.c +0
-0
qerror.c static const QErrorStringTable qerror_table[] = { · line 287
Quoted 5 lines
qerror.c +2
-0@@ -283,6 +283,10 @@ static const QErrorStringTable qerror_table[] = { .desc = "Could not set password", }, { + .error_fmt = QERR_MIGRATION_BLOCKED_BY_STREAMING, + .desc = "Migration is blocked by streaming",
bdrv_in_use() is general and the error message should be too. There may be other operations besides streaming that prevent migration.
Stefan
PATCH v3 3/3 migration: block migration when streaming block jobs are running.
In reply to [email protected]From: Benoît Canet <[email protected]>
--- migration.c | 5 +++++ 1 file changed, 5 insertions(+)
migration.c +5 -0
@@ -425,6 +425,11 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,return ; } +if (bdrv_are_busy ()) { +error_set (errp,QERR_MIGRATION_BLOCKED_BY_STREAMING ); +return ; + } + s =migrate_init (¶ms);if (strstart (uri,"tcp:" , &p)) {
Signature · 1 line
1.7.9.5