Check migration enabled features on both sides
cover Check migration enabled features on both sides
Hi
This was part of my multifd series, it just "requires" that migartion features being enabled on both sides.
- XBZRLE: libvirt only enables it on source, so we don't test it
- compression threads: we check at reception when we receive a compression page that we have compression threads enabled. Otherwise we exit with one error.
- Now that we check if compression threads are enabled, we don't create the threads if they are not enabled.
It makes debugging much easier, because I have less threads on destination to search where things are hang up.
Please review,
Thanks, Juan.
Juan Quintela (2):
migration: Test for disabled features on reception
migration: Don't create decompression threads if not enabled
migration/ram.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)
Signature · 1 line
2.9.4
PATCH 1/2 migration: Test for disabled features on reception
Right now, if we receive a compressed page while this features are disabled, Bad Things (TM) can happen. Just add a test for them.
--
I had XBZRLE here also, but it don't need extra resources on destination, only on source. Additionally libvirt don't enable it on destination, so don't put it here.
--- migration/ram.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
migration/ram.c +15 -1
@@ -2477,7 +2477,7 @@ static int ram_load_postcopy(QEMUFile *f)static int ram_load (QEMUFile *f,void *opaque,int version_id) { -int flags =0 , ret =0 ; +int flags =0 , ret =0 , invalid_flags;static uint64_t seq_iter;int len =0 ;/*
@@ -2494,6 +2494,11 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id) ret = -EINVAL ; } + invalid_flags =0 ; + +if (!migrate_use_compression ()) { + invalid_flags |=RAM_SAVE_FLAG_COMPRESS_PAGE ; + }/* This RCU critical section can be very long running. * When RCU reclaims in the code start to become numerous, * it will be necessary to reduce the granularity of this
@@ -2514,6 +2519,15 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id) flags = addr & ~TARGET_PAGE_MASK ; addr &=TARGET_PAGE_MASK ; +if (flags & invalid_flags) { +if (flags & invalid_flags &RAM_SAVE_FLAG_COMPRESS_PAGE ) { +error_report ("Received an unexpected compressed page" ); + } + + ret = -EINVAL ; +break ; + } +if (flags & (RAM_SAVE_FLAG_ZERO |RAM_SAVE_FLAG_PAGE |RAM_SAVE_FLAG_COMPRESS_PAGE |RAM_SAVE_FLAG_XBZRLE )) {RAMBlock *block =ram_block_from_stream (f, flags);
Signature · 1 line
2.9.4
Re: [Qemu-devel] [PATCH 1/2] migration: Test for disabled features on reception
Quoted 5 lines · * Juan Quintela ([email protected]) wrote:
Right now, if we receive a compressed page while this features are disabled, Bad Things (TM) can happen. Just add a test for them.
Signed-off-by Juan Quintela <[email protected]>Reviewed-by Dr. David Alan Gilbert <[email protected]>
Yes, my R-b stands, there could be someone somewhere driving this by hand who might get caught out, but seems saner this way.
Quoted 23 lines
--
I had XBZRLE here also, but it don't need extra resources on destination, only on source. Additionally libvirt don't enable it on destination, so don't put it here.
--- migration/ram.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)migration/ram.c +1
-1@@ -2477,7 +2477,7 @@ static int ram_load_postcopy(QEMUFile *f)static int ram_load (QEMUFile *f,void *opaque,int version_id) { -int flags =0 , ret =0 ; +int flags =0 , ret =0 , invalid_flags;static uint64_t seq_iter;int len =0 ;/*
migration/ram.c static int ram_load(QEMUFile *f, void *opaque, int version_id) · line 2497
Quoted 4 lines
migration/ram.c +1
-0@@ -2494,6 +2494,11 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id) ret = -EINVAL ; } + invalid_flags =0 ;
why didn't you use = 0 in the declaration like the rest of the flags? (Only minor)
Dave
Quoted 26 lines
migration/ram.c +13
-0+ +if (!migrate_use_compression ()) { + invalid_flags |=RAM_SAVE_FLAG_COMPRESS_PAGE ; + }/* This RCU critical section can be very long running. * When RCU reclaims in the code start to become numerous, * it will be necessary to reduce the granularity of this @@ -2514,6 +2519,15 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id) flags = addr & ~TARGET_PAGE_MASK ; addr &=TARGET_PAGE_MASK ; +if (flags & invalid_flags) { +if (flags & invalid_flags &RAM_SAVE_FLAG_COMPRESS_PAGE ) { +error_report ("Received an unexpected compressed page" ); + } + + ret = -EINVAL ; +break ; + } +if (flags & (RAM_SAVE_FLAG_ZERO |RAM_SAVE_FLAG_PAGE |RAM_SAVE_FLAG_COMPRESS_PAGE |RAM_SAVE_FLAG_XBZRLE )) {RAMBlock *block =ram_block_from_stream (f, flags);Signature · 1 line
2.9.4
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Re: [Qemu-devel] [PATCH 1/2] migration: Test for disabled features on reception
Quoted 36 lines · Dr. David Alan Gilbert
Quoted 5 lines · * Juan Quintela ([email protected]) wrote:
Right now, if we receive a compressed page while this features are disabled, Bad Things (TM) can happen. Just add a test for them.
Signed-off-by Juan Quintela <[email protected]>Reviewed-by Dr. David Alan Gilbert <[email protected]>Yes, my R-b stands, there could be someone somewhere driving this by hand who might get caught out, but seems saner this way.
Quoted 26 lines
--
I had XBZRLE here also, but it don't need extra resources on destination, only on source. Additionally libvirt don't enable it on destination, so don't put it here.
--- migration/ram.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)migration/ram.c +1
-1@@ -2477,7 +2477,7 @@ static int ram_load_postcopy(QEMUFile *f)static int ram_load (QEMUFile *f,void *opaque,int version_id) { -int flags =0 , ret =0 ; +int flags =0 , ret =0 , invalid_flags;static uint64_t seq_iter;int len =0 ;/* @@ -2494,6 +2494,11 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id) ret = -EINVAL ; }
Quoted 4 lines
migration/ram.c static int ram_load(QEMUFile *f, void *opaque, int version_id) · line 2497
Quoted 1 line
migration/ram.c +1
-0+ invalid_flags =0 ;why didn't you use = 0 in the declaration like the rest of the flags? (Only minor)
Costume :-(
Changed to common style there.
Thanks, Juan.
Re: [Qemu-devel] [PATCH 1/2] migration: Test for disabled features on reception
In reply to Juan QuintelaQuoted 29 lines · Juan Quintela
Right now, if we receive a compressed page while this features are disabled, Bad Things (TM) can happen. Just add a test for them.
Signed-off-by Juan Quintela <[email protected]>Reviewed-by Dr. David Alan Gilbert <[email protected]>--
I had XBZRLE here also, but it don't need extra resources on destination, only on source. Additionally libvirt don't enable it on destination, so don't put it here.
--- migration/ram.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)migration/ram.c +1
-1@@ -2477,7 +2477,7 @@ static int ram_load_postcopy(QEMUFile *f)static int ram_load (QEMUFile *f,void *opaque,int version_id) { -int flags =0 , ret =0 ; +int flags =0 , ret =0 , invalid_flags;static uint64_t seq_iter;int len =0 ;/*
migration/ram.c static int ram_load(QEMUFile *f, void *opaque, int version_id) · line 2497
Quoted 4 lines
migration/ram.c +1
-0@@ -2494,6 +2494,11 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id) ret = -EINVAL ; } + invalid_flags =0 ;
Nit: set zero when declare (just like flags, ret)?
migration/ram.c static int ram_load(QEMUFile *f, void *opaque, int version_id) · line 2523
Quoted 13 lines
migration/ram.c +6
-0+ +if (!migrate_use_compression ()) { + invalid_flags |=RAM_SAVE_FLAG_COMPRESS_PAGE ; + }/* This RCU critical section can be very long running. * When RCU reclaims in the code start to become numerous, * it will be necessary to reduce the granularity of this @@ -2514,6 +2519,15 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id) flags = addr & ~TARGET_PAGE_MASK ; addr &=TARGET_PAGE_MASK ; +if (flags & invalid_flags) { +if (flags & invalid_flags &RAM_SAVE_FLAG_COMPRESS_PAGE ) {
^
Nit: one extra space -------------------+
Quoted 13 lines
migration/ram.c +7
-0+error_report ("Received an unexpected compressed page" ); + } + + ret = -EINVAL ; +break ; + } +if (flags & (RAM_SAVE_FLAG_ZERO |RAM_SAVE_FLAG_PAGE |RAM_SAVE_FLAG_COMPRESS_PAGE |RAM_SAVE_FLAG_XBZRLE )) {RAMBlock *block =ram_block_from_stream (f, flags);Signature · 1 line
2.9.4
Besides the nits:
Signature · 1 line
Peter Xu
Re: [Qemu-devel] [PATCH 1/2] migration: Test for disabled features on reception
Quoted 33 lines · Peter Xu
Quoted 32 lines · Juan Quintela
Right now, if we receive a compressed page while this features are disabled, Bad Things (TM) can happen. Just add a test for them.
Signed-off-by Juan Quintela <[email protected]>Reviewed-by Dr. David Alan Gilbert <[email protected]>--
I had XBZRLE here also, but it don't need extra resources on destination, only on source. Additionally libvirt don't enable it on destination, so don't put it here.
--- migration/ram.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)migration/ram.c +1
-1@@ -2477,7 +2477,7 @@ static int ram_load_postcopy(QEMUFile *f)static int ram_load (QEMUFile *f,void *opaque,int version_id) { -int flags =0 , ret =0 ; +int flags =0 , ret =0 , invalid_flags;static uint64_t seq_iter;int len =0 ;/* @@ -2494,6 +2494,11 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id) ret = -EINVAL ; }
Quoted 3 lines
migration/ram.c static int ram_load(QEMUFile *f, void *opaque, int version_id) · line 2497
Quoted 1 line
migration/ram.c +1
-0+ invalid_flags =0 ;Nit: set zero when declare (just like flags, ret)?
Fixed.
As answered to dave, I use to do it that way. But here it is more consistant to do it the other way.
Quoted 11 lines
Quoted 11 lines
migration/ram.c +4
-0+ +if (!migrate_use_compression ()) { + invalid_flags |=RAM_SAVE_FLAG_COMPRESS_PAGE ; + }/* This RCU critical section can be very long running. * When RCU reclaims in the code start to become numerous, * it will be necessary to reduce the granularity of this @@ -2514,6 +2519,15 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id) flags = addr & ~TARGET_PAGE_MASK ; addr &=TARGET_PAGE_MASK ;
Quoted 4 lines
migration/ram.c static int ram_load(QEMUFile *f, void *opaque, int version_id) · line 2523
Quoted 2 lines
migration/ram.c +2
-0+if (flags & invalid_flags) { +if (flags & invalid_flags &RAM_SAVE_FLAG_COMPRESS_PAGE ) {^Nit: one extra space -------------------+
Fixed.
Quoted 16 lines
Quoted 13 lines
migration/ram.c +7
-0+error_report ("Received an unexpected compressed page" ); + } + + ret = -EINVAL ; +break ; + } +if (flags & (RAM_SAVE_FLAG_ZERO |RAM_SAVE_FLAG_PAGE |RAM_SAVE_FLAG_COMPRESS_PAGE |RAM_SAVE_FLAG_XBZRLE )) {RAMBlock *block =ram_block_from_stream (f, flags);Signature · 1 line
2.9.4Besides the nits:
Quoted 1 line
Reviewed-by Peter Xu <[email protected]>
Thanks.
PATCH 2/2 migration: Don't create decompression threads if not enabled
In reply to Juan Quintela--
I removed the [HACK] part because previous patch just check that compression pages are not received.
--- migration/ram.c | 6 ++++++ 1 file changed, 6 insertions(+)
migration/ram.c +6 -0
@@ -2234,6 +2234,9 @@ static void compress_threads_load_setup(void) {int i, thread_count; +if (!migrate_use_compression ()) { +return ; + } thread_count =migrate_decompress_threads (); decompress_threads =g_new0 (QemuThread, thread_count); decomp_param =g_new0 (DecompressParam, thread_count);
@@ -2255,6 +2258,9 @@ static void compress_threads_load_cleanup(void) {int i, thread_count; +if (!migrate_use_compression ()) { +return ; + } thread_count =migrate_decompress_threads ();for (i =0 ; i < thread_count; i++) {qemu_mutex_lock (&decomp_param[i].mutex);
Signature · 1 line
2.9.4
Re: [Qemu-devel] [PATCH 2/2] migration: Don't create decompression threads if not enabled
migration/ram.c static void compress_threads_load_setup(void)
Quoted 16 lines · Juan Quintela
Signed-off-by Juan Quintela <[email protected]>Reviewed-by Dr. David Alan Gilbert <[email protected]>--
I removed the [HACK] part because previous patch just check that compression pages are not received.
--- migration/ram.c | 6 ++++++ 1 file changed, 6 insertions(+)migration/ram.c +0
-0@@ -2234,6 +2234,9 @@ static void compress_threads_load_setup(void)
I cannot find compress_threads_load_setup() in my repo, but migrate_decompress_threads_create()?
Thanks,
Quoted 22 lines
migration/ram.c +6
-0{int i, thread_count; +if (!migrate_use_compression ()) { +return ; + } thread_count =migrate_decompress_threads (); decompress_threads =g_new0 (QemuThread, thread_count); decomp_param =g_new0 (DecompressParam, thread_count);@@ -2255,6 +2258,9 @@ static void compress_threads_load_cleanup(void) {int i, thread_count; +if (!migrate_use_compression ()) { +return ; + } thread_count =migrate_decompress_threads ();for (i =0 ; i < thread_count; i++) {qemu_mutex_lock (&decomp_param[i].mutex);Signature · 1 line
2.9.4
Signature · 1 line
Peter Xu
Re: [Qemu-devel] [PATCH 2/2] migration: Don't create decompression threads if not enabled
Quoted 12 lines · Peter Xu
Quoted 11 lines · Juan Quintela
Signed-off-by Juan Quintela <[email protected]>Reviewed-by Dr. David Alan Gilbert <[email protected]>--
I removed the [HACK] part because previous patch just check that compression pages are not received.
--- migration/ram.c | 6 ++++++ 1 file changed, 6 insertions(+)
Quoted 8 lines
migration/ram.c static void compress_threads_load_setup(void)
Quoted 5 lines
migration/ram.c +0
-0@@ -2234,6 +2234,9 @@ static void compress_threads_load_setup(void)I cannot find
compress_threads_load_setup()in my repo, butmigrate_decompress_threads_create()?
Sorry, this patches are on top of load_setup/cleanup series.
Later, Juan.
Quoted 25 lines
Thanks,
Quoted 22 lines
migration/ram.c +6
-0{int i, thread_count; +if (!migrate_use_compression ()) { +return ; + } thread_count =migrate_decompress_threads (); decompress_threads =g_new0 (QemuThread, thread_count); decomp_param =g_new0 (DecompressParam, thread_count);@@ -2255,6 +2258,9 @@ static void compress_threads_load_cleanup(void) {int i, thread_count; +if (!migrate_use_compression ()) { +return ; + } thread_count =migrate_decompress_threads ();for (i =0 ; i < thread_count; i++) {qemu_mutex_lock (&decomp_param[i].mutex);Signature · 1 line
2.9.4
Peter Xu
Reviewed-byRe: [Qemu-devel] [PATCH 2/2] migration: Don't create decompression threads if not enabled
Quoted 23 lines · Juan Quintela
Quoted 12 lines · Peter Xu
Quoted 11 lines · Juan Quintela
Signed-off-by Juan Quintela <[email protected]>Reviewed-by Dr. David Alan Gilbert <[email protected]>--
I removed the [HACK] part because previous patch just check that compression pages are not received.
--- migration/ram.c | 6 ++++++ 1 file changed, 6 insertions(+)Quoted 8 lines
migration/ram.c static void compress_threads_load_setup(void)
Quoted 5 lines
migration/ram.c +0
-0@@ -2234,6 +2234,9 @@ static void compress_threads_load_setup(void)I cannot find
compress_threads_load_setup()in my repo, butmigrate_decompress_threads_create()?
Quoted 1 line
Sorry, this patches are on top of load_setup/cleanup series.
Got it. After all the content of the patch looks good to me, so please take my r-b as long as the patch can apply cleanly and correctly on where it should be based:
Thanks,
Signature · 1 line
Peter Xu