: Migration fixes
Anthony,
The following migration fixes have been sent to the list some time ago but have not been applied yet. They fix important bugs and seem good to me (I've tested them too).
The changes (since 96638e706cd431528690cf611adcb04e1bc3255d) are available in the following repository:
git://repo.or.cz/qemu/qmp-unstable.git patches-for-0.13
Please, also note that they should be applied in master too (except for the 'cont' one).
Alex Williamson (1):
savevm: Reset last block info at beginning of each save
Amit Shah (1):
migration: Accept 'cont' only after successful incoming migration
Avi Kivity (1):
QEMUFileBuffered: indicate that we're ready when the underlying file is ready
Marcelo Tosatti (1):
set proper migration status on ->write error (v5)
arch_init.c | 7 +++++-- buffered_file.c | 12 +++++++++++- migration.c | 10 +++++++++- monitor.c | 4 ++++ qerror.c | 4 ++++ qerror.h | 3 +++ sysemu.h | 1 + vl.c | 2 ++ 8 files changed, 39 insertions(+), 4 deletions(-)
PATCH 1/4 set proper migration status on ->write error (v5)
From: Marcelo Tosatti <[email protected]>
If ->write fails, declare migration status as MIG_STATE_ERROR.
Also, in buffered_file.c, ->close the object in case of an error.
Fixes "migrate -d "exec:dd of=file", where dd fails to open file.
--- buffered_file.c | 4 +++- migration.c | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-)
buffered_file.c +3 -1
@@ -222,8 +222,10 @@ static void buffered_rate_tick(void *opaque) {QEMUFileBuffered *s = opaque; -if (s->has_error) +if (s->has_error) { +buffered_close (s);return ; + }qemu_mod_timer (s->timer,qemu_get_clock (rt_clock) +100 );
migration.c +7 -1
@@ -314,8 +314,14 @@ ssize_t migrate_fd_put_buffer(void *opaque, const void *data, size_t size)if (ret ==-1 ) ret = -(s->get_error (s)); -if (ret == -EAGAIN ) +if (ret == -EAGAIN ) {qemu_set_fd_handler2 (s->fd,NULL ,NULL , migrate_fd_put_notify, s); + }else if (ret <0 ) { +if (s->mon) { +monitor_resume (s->mon); + } + s->state =MIG_STATE_ERROR ; + }return ret; }
Signature · 1 line
1.7.2.1.97.g3235b
Anthony Liguori
AppliedRe: [Qemu-devel] [PATCH 1/4] set proper migration status on ->write error (v5)
Quoted 4 lines · Luiz Capitulino
From: Marcelo Tosatti<[email protected]>
If ->write fails, declare migration status as
MIG_STATE_ERROR.
Quoted 8 lines
Also, in
buffered_file.c, ->close the object in case of an error.Fixes "migrate -d "exec:dd of=file", where dd fails to open file.
Signed-off-by Marcelo Tosatti<[email protected]>Signed-off-by Luiz Capitulino<[email protected]>
Applied. Thanks.
Regards,
Anthony Liguori
Quoted 42 lines
--- buffered_file.c | 4 +++- migration.c | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-)buffered_file.c +3
-1@@ -222,8 +222,10 @@ static void buffered_rate_tick(void *opaque) {QEMUFileBuffered *s = opaque; -if (s->has_error) +if (s->has_error) { +buffered_close (s);return ; + }qemu_mod_timer (s->timer,qemu_get_clock (rt_clock) +100 );migration.c +7
-1@@ -314,8 +314,14 @@ ssize_t migrate_fd_put_buffer(void *opaque, const void *data, size_t size)if (ret ==-1 ) ret = -(s->get_error (s)); -if (ret == -EAGAIN ) +if (ret == -EAGAIN ) {qemu_set_fd_handler2 (s->fd,NULL ,NULL , migrate_fd_put_notify, s); + }else if (ret<0 ) { +if (s->mon) { +monitor_resume (s->mon); + } + s->state =MIG_STATE_ERROR ; + }return ret; }
PATCH 2/4 QEMUFileBuffered: indicate that we're ready when the underlying file is ready
In reply to Luiz CapitulinoFrom: Avi Kivity <[email protected]>
QEMUFileBuffered stops writing when the underlying QEMUFile is not ready, and tells its producer so. However, when the underlying QEMUFile becomes ready, it neglects to pass that information along, resulting in stoppage of all data until the next tick (a tenths of a second).
Usually this doesn't matter, because most QEMUFiles used with QEMUFileBuffered are almost always ready, but in the case of exec: migration this is not true, due to the small pipe buffers used to connect to the target process. The result is very slow migration.
Fix by detecting the readiness notification and propagating it. The detection is a little ugly since QEMUFile overloads put_buffer() to send it, but that's the suject for a different patch.
--- buffered_file.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
buffered_file.c +8 -0
@@ -156,6 +156,14 @@ static int buffered_put_buffer(void *opaque, const uint8_t *buf, int64_t pos, in offset = size; } +if (pos ==0 && size ==0 ) { +DPRINTF ("file is ready\n" ); +if (s->bytes_xfer <= s->xfer_limit) { +DPRINTF ("notifying client\n" ); + s->put_ready (s->opaque); + } + } +return offset; }
Signature · 1 line
1.7.2.1.97.g3235b
PATCH 3/4 migration: Accept 'cont' only after successful incoming migration
In reply to Luiz CapitulinoFrom: Amit Shah <[email protected]>
When a 'cont' is issued on a VM that's just waiting for an incoming migration, the VM reboots and boots into the guest, possibly corrupting its storage since it could be shared with another VM running elsewhere.
Ensure that a VM started with '-incoming' is only run when an incoming migration successfully completes.
A new qerror, QERR_MIGRATION_EXPECTED, is added to signal that 'cont' failed due to no incoming migration has been attempted yet.
--- migration.c | 2 ++ monitor.c | 4 ++++ qerror.c | 4 ++++ qerror.h | 3 +++ sysemu.h | 1 + vl.c | 2 ++ 6 files changed, 16 insertions(+), 0 deletions(-)
migration.c +2 -0
@@ -67,6 +67,8 @@ void process_incoming_migration(QEMUFile *f)qemu_announce_self ();DPRINTF ("successfully loaded vm state\n" ); + incoming_expected = false; +if (autostart)vm_start (); }
monitor.c +4 -0
@@ -1056,6 +1056,10 @@ static int do_cont(Monitor *mon, const QDict *qdict, QObject **ret_data) {struct bdrv_iterate_context context = { mon,0 }; +if (incoming_expected) { +qerror_report (QERR_MIGRATION_EXPECTED ); +return -1 ; + }bdrv_iterate (encrypted_bdrv_it, &context);/* only resume the vm if all keys are set and valid */ if (!context.err) {
qerror.c +4 -0
@@ -141,6 +141,10 @@ static const QErrorStringTable qerror_table[] = { .desc = "Using KVM without %(capability), %(feature) unavailable", }, { + .error_fmt = QERR_MIGRATION_EXPECTED, + .desc = "An incoming migration is expected before this command can be executed", + }, + { .error_fmt = QERR_MISSING_PARAMETER, .desc = "Parameter '%(name)' is missing", },
qerror.h +3 -0
@@ -121,6 +121,9 @@ QError *qobject_to_qerror(const QObject *obj);#define QERR_KVM_MISSING_CAP \ "{ 'class': 'KVMMissingCap', 'data': { 'capability': %s, 'feature': %s } }" +#define QERR_MIGRATION_EXPECTED \ + "{ 'class': 'MigrationExpected', 'data': {} }" +#define QERR_MISSING_PARAMETER \ "{ 'class': 'MissingParameter', 'data': { 'name': %s } }"
sysemu.h +1 -0
@@ -99,6 +99,7 @@ typedef enum DisplayType } DisplayType;extern int autostart; +extern int incoming_expected;extern int bios_size; typedef enum {
vl.c +2 -0
@@ -182,6 +182,7 @@ int nb_nics;NICInfo nd_table[MAX_NICS ];int vm_running;int autostart; +int incoming_expected;/* Started with -incoming and waiting for incoming */ static int rtc_utc =1 ;static int rtc_date_offset =-1 ;/* -1 means no change */ QEMUClock *rtc_clock;
@@ -2557,6 +2558,7 @@ int main(int argc, char **argv, char **envp)break ;case QEMU_OPTION_incoming: incoming = optarg; + incoming_expected = true;break ;case QEMU_OPTION_nodefaults: default_serial =0 ;
Signature · 1 line
1.7.2.1.97.g3235b
PATCH 4/4 savevm: Reset last block info at beginning of each save
In reply to Luiz CapitulinoFrom: Alex Williamson <[email protected]>
If we save more than once we need to reset the last block info or else only the first save has the actual block info and each subsequent save will only use continue flags, making them unloadable independently.
--- arch_init.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-)
arch_init.c +5 -2
@@ -104,10 +104,11 @@ static int is_dup_page(uint8_t *page, uint8_t ch)return 1 ; } +static RAMBlock *last_block; +static ram_addr_t last_offset; +static int ram_save_block (QEMUFile *f) { -static RAMBlock *last_block =NULL ; -static ram_addr_t last_offset =0 ;RAMBlock *block = last_block;ram_addr_t offset = last_offset;ram_addr_t current_addr;
@@ -231,6 +232,8 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque)if (stage ==1 ) {RAMBlock *block; bytes_transferred =0 ; + last_block =NULL ; + last_offset =0 ;/* Make sure all dirty bits are set */ QLIST_FOREACH(block, &ram_list.blocks, next) {
Signature · 1 line
1.7.2.1.97.g3235b
Anthony Liguori
AppliedRe: [Qemu-devel] [PATCH 4/4] savevm: Reset last block info at beginning of each save
Quoted 11 lines · Luiz Capitulino
From: Alex Williamson<[email protected]>
If we save more than once we need to reset the last block info or else only the first save has the actual block info and each subsequent save will only use continue flags, making them unloadable independently.
Signed-off-by Alex Williamson<[email protected]>Acked-by Glauber Costa<[email protected]>Signed-off-by Luiz Capitulino<[email protected]>
Applied. Thanks.
Regards,
Anthony Liguori
Quoted 32 lines
--- arch_init.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-)arch_init.c +5
-2@@ -104,10 +104,11 @@ static int is_dup_page(uint8_t *page, uint8_t ch)return 1 ; } +static RAMBlock *last_block; +static ram_addr_t last_offset; +static int ram_save_block (QEMUFile *f) { -static RAMBlock *last_block =NULL ; -static ram_addr_t last_offset =0 ;RAMBlock *block = last_block;ram_addr_t offset = last_offset;ram_addr_t current_addr;@@ -231,6 +232,8 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque)if (stage ==1 ) {RAMBlock *block; bytes_transferred =0 ; + last_block =NULL ; + last_offset =0 ;/* Make sure all dirty bits are set */ QLIST_FOREACH(block,&ram_list.blocks, next) {
Quoted 6 lines · Luiz Capitulino
Anthony,
The following migration fixes have been sent to the list some time ago but have not been applied yet. They fix important bugs and seem good to me (I've tested them too).
Quoted 8 lines
The changes (since
96638e706cd431528690cf611adcb04e1bc3255d) are available in the following repository:git://repo.or.cz/qemu/qmp-unstable.git patches-for-0.13Please, also note that they should be applied in master too (except for the 'cont' one).
Things need to be applied to master first, and then applied to stable-0.13 via a cherry pick.
Why should the 'cont' one be applied to stable but not master?
Regards,
Anthony Liguori
Quoted 22 lines
Alex Williamson (1):
savevm: Reset last block info at beginning of each saveAmit Shah (1):
migration: Accept 'cont' only after successful incoming migrationAvi Kivity (1):
QEMUFileBuffered: indicate that we're ready when the underlying file is readyMarcelo Tosatti (1):
set proper migration status on ->write error (v5)arch_init.c | 7 +++++-- buffered_file.c | 12 +++++++++++- migration.c | 10 +++++++++- monitor.c | 4 ++++ qerror.c | 4 ++++ qerror.h | 3 +++ sysemu.h | 1 + vl.c | 2 ++ 8 files changed, 39 insertions(+), 4 deletions(-)
Quoted 10 lines · On Thu, 19 Aug 2010 08:44:09 -0500 Anthony Liguori…
Quoted 9 lines · Luiz Capitulino
Anthony,
The following migration fixes have been sent to the list some time ago but have not been applied yet. They fix important bugs and seem good to me (I've tested them too).
The changes (since
96638e706cd431528690cf611adcb04e1bc3255d) are available in the following repository:
Quoted 8 lines
Quoted 5 lines
git://repo.or.cz/qemu/qmp-unstable.git patches-for-0.13Please, also note that they should be applied in master too (except for the 'cont' one).
Things need to be applied to master first, and then applied to stable-0.13 via a cherry pick.
Can you do so then please? I've added the 'STABLE 0.13' tag just to make sure they are not forgotten for 0.13.
Quoted 1 line
Why should the 'cont' one be applied to stable but not master?
It's already applied there.
Quoted 17 lines · Luiz Capitulino
Quoted 13 lines · On Thu, 19 Aug 2010 08:44:09 -0500 Anthony…
Quoted 11 lines · Luiz Capitulino
Anthony,
The following migration fixes have been sent to the list some time ago but have not been applied yet. They fix important bugs and seem good to me (I've tested them too).
The changes (since
96638e706cd431528690cf611adcb04e1bc3255d) are available in the following repository:git://repo.or.cz/qemu/qmp-unstable.git patches-for-0.13
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
Please, also note that they should be applied in master too (except for the 'cont' one).
Things need to be applied to master first, and then applied to stable-0.13 via a cherry pick.
Can you do so then please?
Yup, doing it right now along with the backlog of other patches.
Regards,
Anthony Liguori
Quoted 8 lines
I've added the 'STABLE 0.13' tag just to
make sure they are not forgotten for 0.13.Quoted 2 lines
Why should the 'cont' one be applied to stable but not master?
It's already applied there.