Disable hotplug during migration
cover Disable hotplug during migration
Hi
This series disable hotplug/unplug during migration. Thank to Markus for explaining where I had to put the checks. Why? Because during migration we will fail if there are changes. For instance, in postcopy, if we add a memory region, we would failing. Same for other devices if they are not setup exactly the same on destination.
Iidea would be to disable it, andthen enable for the thing that we know that work.
This series are on top of my previous RAMState v2 serie.
Commets, please?
Thanks, Juan.
Juan Quintela (2):
migration: Disable hotplug/unplug during migration
ram: remove migration_bitmap_extend()
exec.c | 1 - hw/core/qdev.c | 5 +++++ include/exec/ram_addr.h | 2 -- migration/ram.c | 34 ---------------------------------- qdev-monitor.c | 7 ++++++- 5 files changed, 11 insertions(+), 38 deletions(-)
Signature · 1 line
2.9.3
PATCH 1/2 migration: Disable hotplug/unplug during migration
Until we have reviewed what can/can't be hotplug during migration, disable it. We can enable it later for the things that we know that work. For instance, memory hotplug during postcopy don't work currently.
--- hw/core/qdev.c | 5 +++++ qdev-monitor.c | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-)
hw/core/qdev.c +5 -0
@@ -277,6 +277,11 @@ void qdev_unplug(DeviceState *dev, Error **errp)HotplugHandler *hotplug_ctrl;HotplugHandlerClass *hdc; +if (!migration_is_idle ()) { +error_setg (errp,"device_add not allowed while migrating" ); +return ; + } +if (dev->parent_bus && !qbus_is_hotpluggable (dev->parent_bus)) {error_setg (errp,QERR_BUS_NO_HOTPLUG , dev->parent_bus->name);return ;
qdev-monitor.c +6 -1
@@ -29,7 +29,7 @@#include "qemu/error-report.h" #include "qemu/help_option.h" #include "sysemu/block-backend.h" - +#include "migration/migration.h" /* * Aliases were a bad idea from the start. Let's keep them * from spreading further.
@@ -566,6 +566,11 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **errp)BusState *bus =NULL ;Error *err =NULL ; +if (!migration_is_idle ()) { +error_setg (errp,"device_add not allowed while migrating" ); +return NULL ; + } + driver =qemu_opt_get (opts,"driver" );if (!driver) {error_setg (errp,QERR_MISSING_PARAMETER ,"driver" );
Signature · 1 line
2.9.3
Re: [Qemu-devel] [PATCH 1/2] migration: Disable hotplug/unplug during migration
Quoted 32 lines · Juan Quintela
Until we have reviewed what can/can't be hotplug during migration, disable it. We can enable it later for the things that we know that work. For instance, memory hotplug during postcopy don't work currently.
Signed-off-by Juan Quintela <[email protected]>--- hw/core/qdev.c | 5 +++++ qdev-monitor.c | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-)hw/core/qdev.c +5
-0@@ -277,6 +277,11 @@ void qdev_unplug(DeviceState *dev, Error **errp)HotplugHandler *hotplug_ctrl;HotplugHandlerClass *hdc; +if (!migration_is_idle ()) { +error_setg (errp,"device_add not allowed while migrating" ); +return ; + } +if (dev->parent_bus && !qbus_is_hotpluggable (dev->parent_bus)) {error_setg (errp,QERR_BUS_NO_HOTPLUG , dev->parent_bus->name);return ;qdev-monitor.c +0
-0
qdev-monitor.c line 35
Quoted 8 lines
qdev-monitor.c +1
-1@@ -29,7 +29,7 @@#include "qemu/error-report.h" #include "qemu/help_option.h" #include "sysemu/block-backend.h" - +#include "migration/migration.h" /* * Aliases were a bad idea from the start. Let's keep them * from spreading further.
Maybe better keep an empty line between the include statement and the comment?
Thomas
Quoted 13 lines
qdev-monitor.c +5
-0@@ -566,6 +566,11 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **errp)BusState *bus =NULL ;Error *err =NULL ; +if (!migration_is_idle ()) { +error_setg (errp,"device_add not allowed while migrating" ); +return NULL ; + } + driver =qemu_opt_get (opts,"driver" );if (!driver) {error_setg (errp,QERR_MISSING_PARAMETER ,"driver" );
Re: [Qemu-devel] [PATCH 1/2] migration: Disable hotplug/unplug during migration
Quoted 36 lines · Thomas Huth
Quoted 35 lines · Juan Quintela
Until we have reviewed what can/can't be hotplug during migration, disable it. We can enable it later for the things that we know that work. For instance, memory hotplug during postcopy don't work currently.
Signed-off-by Juan Quintela <[email protected]>--- hw/core/qdev.c | 5 +++++ qdev-monitor.c | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-)hw/core/qdev.c +5
-0@@ -277,6 +277,11 @@ void qdev_unplug(DeviceState *dev, Error **errp)HotplugHandler *hotplug_ctrl;HotplugHandlerClass *hdc; +if (!migration_is_idle ()) { +error_setg (errp,"device_add not allowed while migrating" ); +return ; + } +if (dev->parent_bus && !qbus_is_hotpluggable (dev->parent_bus)) {error_setg (errp,QERR_BUS_NO_HOTPLUG , dev->parent_bus->name);return ;qdev-monitor.c +0
-0@@ -29,7 +29,7 @@#include "qemu/error-report.h" #include "qemu/help_option.h" #include "sysemu/block-backend.h"
Quoted 8 lines
qdev-monitor.c line 35
Quoted 5 lines
qdev-monitor.c +1
-1- +#include "migration/migration.h" /* * Aliases were a bad idea from the start. Let's keep them * from spreading further. Maybe better keep an empty line between the include statement and the comment?
Oops, sure.
Quoted 17 lines
Thomas
Quoted 13 lines
qdev-monitor.c +5
-0@@ -566,6 +566,11 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **errp)BusState *bus =NULL ;Error *err =NULL ; +if (!migration_is_idle ()) { +error_setg (errp,"device_add not allowed while migrating" ); +return NULL ; + } + driver =qemu_opt_get (opts,"driver" );if (!driver) {error_setg (errp,QERR_MISSING_PARAMETER ,"driver" );
Re: [Qemu-devel] [PATCH 1/2] migration: Disable hotplug/unplug during migration
In reply to Juan QuintelaQuoted 16 lines · On Thu, 23 Mar 2017 21:50:24 +0100 Juan Quintela <[email protected]> wrote:
Until we have reviewed what can/can't be hotplug during migration, disable it. We can enable it later for the things that we know that work. For instance, memory hotplug during postcopy don't work currently.
Signed-off-by Juan Quintela <[email protected]>--- hw/core/qdev.c | 5 +++++ qdev-monitor.c | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-)hw/core/qdev.c +0
-0
hw/core/qdev.c void qdev_unplug(DeviceState *dev, Error **errp) · line 281
Quoted 5 lines
hw/core/qdev.c +2
-0@@ -277,6 +277,11 @@ void qdev_unplug(DeviceState *dev, Error **errp)HotplugHandler *hotplug_ctrl;HotplugHandlerClass *hdc; +if (!migration_is_idle ()) { +error_setg (errp,"device_add not allowed while migrating" );
s/device_add/device_del/
I'd put this check after "if (!dc->hotpluggable)" block, so error message won't hide wrong upluggable device error cases
Quoted 20 lines
hw/core/qdev.c +3
-0+return ; + } +if (dev->parent_bus && !qbus_is_hotpluggable (dev->parent_bus)) {error_setg (errp,QERR_BUS_NO_HOTPLUG , dev->parent_bus->name);return ;qdev-monitor.c +1
-1@@ -29,7 +29,7 @@#include "qemu/error-report.h" #include "qemu/help_option.h" #include "sysemu/block-backend.h" - +#include "migration/migration.h" /* * Aliases were a bad idea from the start. Let's keep them * from spreading further.
qdev-monitor.c DeviceState *qdev_device_add(QemuOpts *opts, Error **errp) · line 572
Quoted 7 lines
qdev-monitor.c +4
-0@@ -566,6 +566,11 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **errp)BusState *bus =NULL ;Error *err =NULL ; +if (!migration_is_idle ()) { +error_setg (errp,"device_add not allowed while migrating" ); +return NULL ; + }
the same here, do it right before "/* create device */"
Quoted 3 lines
qdev-monitor.c +0
-0driver =qemu_opt_get (opts,"driver" );if (!driver) {error_setg (errp,QERR_MISSING_PARAMETER ,"driver" );
Re: [Qemu-devel] [PATCH 1/2] migration: Disable hotplug/unplug during migration
Quoted 22 lines · Igor Mammedov
Quoted 19 lines · On Thu, 23 Mar 2017 21:50:24 +0100 Juan Quintela <[email protected]> wrote:
Until we have reviewed what can/can't be hotplug during migration, disable it. We can enable it later for the things that we know that work. For instance, memory hotplug during postcopy don't work currently.
Signed-off-by Juan Quintela <[email protected]>--- hw/core/qdev.c | 5 +++++ qdev-monitor.c | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-)hw/core/qdev.c +0
-0@@ -277,6 +277,11 @@ void qdev_unplug(DeviceState *dev, Error **errp)HotplugHandler *hotplug_ctrl;HotplugHandlerClass *hdc;
Quoted 7 lines
hw/core/qdev.c void qdev_unplug(DeviceState *dev, Error **errp) · line 281
Quoted 2 lines
hw/core/qdev.c +2
-0+if (!migration_is_idle ()) { +error_setg (errp,"device_add not allowed while migrating" );s/device_add/device_del/
I'd put this check after "if (!dc->hotpluggable)" block, so error message won't hide wrong upluggable device error cases
Thanks.
I did both changes. Not sure yet what *should* came 1st:
- device is not plugable/unplugable
- you can't do it while on migration
But I don't care, and as you seemed to preffer that other way, changed.
Later, Juan.
Quoted 32 lines
Quoted 20 lines
hw/core/qdev.c +3
-0+return ; + } +if (dev->parent_bus && !qbus_is_hotpluggable (dev->parent_bus)) {error_setg (errp,QERR_BUS_NO_HOTPLUG , dev->parent_bus->name);return ;qdev-monitor.c +1
-1@@ -29,7 +29,7 @@#include "qemu/error-report.h" #include "qemu/help_option.h" #include "sysemu/block-backend.h" - +#include "migration/migration.h" /* * Aliases were a bad idea from the start. Let's keep them * from spreading further. qdev-monitor.c DeviceState *qdev_device_add(QemuOpts *opts, Error **errp) · line 572
Quoted 7 lines
qdev-monitor.c +4
-0@@ -566,6 +566,11 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **errp)BusState *bus =NULL ;Error *err =NULL ; +if (!migration_is_idle ()) { +error_setg (errp,"device_add not allowed while migrating" ); +return NULL ; + }the same here, do it right before "/* create device */"
Quoted 3 lines
qdev-monitor.c +0
-0driver =qemu_opt_get (opts,"driver" );if (!driver) {error_setg (errp,QERR_MISSING_PARAMETER ,"driver" );
PATCH 2/2 ram: remove migration_bitmap_extend()
In reply to Juan QuintelaWe have disabled memory hotplug, so we don't need to handle migration_bitamp there.
--- exec.c | 1 - include/exec/ram_addr.h | 2 -- migration/ram.c | 34 ---------------------------------- 3 files changed, 37 deletions(-)
exec.c +0 -1
@@ -1758,7 +1758,6 @@ static void ram_block_add(RAMBlock *new_block, Error **errp) new_ram_size =MAX (old_ram_size, (new_block->offset + new_block->max_length) >>TARGET_PAGE_BITS );if (new_ram_size > old_ram_size) { -migration_bitmap_extend (old_ram_size, new_ram_size);dirty_memory_extend (old_ram_size, new_ram_size); }/* Keep the list sorted from biggest to smallest block. Unlike QTAILQ,
include/exec/ram_addr.h +0 -2
@@ -413,7 +413,5 @@ uint64_t cpu_physical_memory_sync_dirty_bitmap(unsigned long *dest,return num_dirty; } - -void migration_bitmap_extend (ram_addr_t old,ram_addr_t new);#endif #endif
migration/ram.c +0 -34
@@ -1494,40 +1494,6 @@ static void ram_state_reset(RAMState *rs)#define MAX_WAIT 50/* ms, half buffered_file limit */ -void migration_bitmap_extend (ram_addr_t old,ram_addr_t new) -{ -RAMState *rs = &ram_state; - -/* called in qemu main thread, so there is -* no writing race against this migration_bitmap -*/ -if (rs->ram_bitmap) { -RAMBitmap *old_bitmap = rs->ram_bitmap, *bitmap; - bitmap =g_new (RAMBitmap,1 ); - bitmap->bmap =bitmap_new (new); - -/* prevent migration_bitmap content from being set bit -* by migration_bitmap_sync_range() at the same time. -* it is safe to migration if migration_bitmap is cleared bit -* at the same time. -*/ -qemu_mutex_lock (&rs->bitmap_mutex); -bitmap_copy (bitmap->bmap, old_bitmap->bmap, old); -bitmap_set (bitmap->bmap, old, new - old); - -/* We don't have a way to safely extend the sentmap -* with RCU; so mark it as missing, entry to postcopy -* will fail. -*/ - bitmap->unsentmap =NULL ; - -atomic_rcu_set (&rs->ram_bitmap, bitmap); -qemu_mutex_unlock (&rs->bitmap_mutex); - rs->migration_dirty_pages += new - old; -call_rcu (old_bitmap, migration_bitmap_free, rcu); - } -} -/* * 'expected' is the value you expect the bitmap mostly to be full * of; it won't bother printing lines that are all this value.
Signature · 1 line
2.9.3
Quoted 8 lines · * Juan Quintela ([email protected]) wrote:
Hi
This series disable hotplug/unplug during migration. Thank to Markus for explaining where I had to put the checks. Why? Because during migration we will fail if there are changes. For instance, in postcopy, if we add a memory region, we would failing. Same for other devices if they are not setup exactly the same on destination.
Quoted 5 lines
Iidea would be to disable it, andthen enable for the thing that we know that work.
This series are on top of my previous RAMState v2 serie.
Commets, please?
So I think this is probably a good idea, but we should ask Li Zhijian who added migration_bitmap_extend if the reason for adding it was because they needed the hot add to work.
cc'd.
IMHO we really need a 'configuration change mutex' that you can take to stop any changes in the VM hardware, and that would probably reduce a lot of the places that hold the BQL for just stopping changes.
Dave
Quoted 8 lines
Thanks, Juan.
Juan Quintela (2):
migration: Disable hotplug/unplug during migration
ram: removemigration_bitmap_extend()
Quoted 11 lines
exec.c | 1 - hw/core/qdev.c | 5 +++++ include/exec/ram_addr.h | 2 -- migration/ram.c | 34 ---------------------------------- qdev-monitor.c | 7 ++++++- 5 files changed, 11 insertions(+), 38 deletions(-)Signature · 1 line
2.9.3
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Quoted 15 lines · Dr. David Alan Gilbert
Quoted 8 lines · * Juan Quintela ([email protected]) wrote:
Hi
This series disable hotplug/unplug during migration. Thank to Markus for explaining where I had to put the checks. Why? Because during migration we will fail if there are changes. For instance, in postcopy, if we add a memory region, we would failing. Same for other devices if they are not setup exactly the same on destination.
Quoted 5 lines
Iidea would be to disable it, andthen enable for the thing that we know that work.
This series are on top of my previous RAMState v2 serie.
Commets, please?
Quoted 8 lines
So I think this is probably a good idea, but we should ask Li Zhijian who added
migration_bitmap_extendif the reason for adding it was because they needed the hot add to work.
cc'd.IMHO we really need a 'configuration change mutex' that you can take to stop any changes in the VM hardware, and that would probably reduce a lot of the places that hold the BQL for just stopping changes.
That was the previous patch. With that one, you can't add/remove hardware during migration.
Later, Juan.
Quoted 11 lines · Dr. David Alan Gilbert
Quoted 10 lines · * Juan Quintela ([email protected]) wrote:
Hi
This series disable hotplug/unplug during migration. Thank to Markus for explaining where I had to put the checks. Why? Because during migration we will fail if there are changes. For instance, in postcopy, if we add a memory region, we would failing. Same for other devices if they are not setup exactly the same on destination.
Iidea would be to disable it, andthen enable for the thing that we know that work.
Quoted 8 lines
Quoted 3 lines
This series are on top of my previous RAMState v2 serie.
Commets, please?
So I think this is probably a good idea, but we should ask Li Zhijian who added
migration_bitmap_extendif the reason for adding it was because they needed the hot add to work.
cc'd.
I guess that the problem for them is that the bitmap size was wrong after memory resizing. But I don't know if this has ever worked.
Quoted 3 lines
IMHO we really need a 'configuration change mutex' that you can take to stop any changes in the VM hardware, and that would probably reduce a lot of the places that hold the BQL for just stopping changes.
That was the previous patch. With that one, you can't add/remove hardware during migration.
Later, Juan.