summaryrefslogtreecommitdiffstats
path: root/migration.c
Commit message (Collapse)AuthorAgeFilesLines
* migration: restrict scope of incoming fd read handlerStefan Hajnoczi2013-02-111-8/+0
| | | | | | | | | | | | | | | | | | | | | The incoming migration is processed in a coroutine and uses an fd read handler to enter the yielded coroutine when data becomes available. The read handler was set too broadly, so that spurious coroutine entries were be triggered if other coroutine users yielded (like the block layer's bdrv_write() function). Install the fd read only only when yielding for more data to become available. This prevents spurious coroutine entries which break code that assumes only a specific set of places can re-enter the coroutine. This patch fixes crashes in block/raw-posix.c that are triggered with "migrate -b" when qiov becomes a dangling pointer due to a spurious coroutine entry that frees qiov early. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-id: 1360598505-5512-1-git-send-email-stefanha@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* error: Strip trailing '\n' from error string arguments (again)Markus Armbruster2013-02-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 6daf194d and be62a2eb got rid of a bunch, but they keep coming back. Tracked down with this Coccinelle semantic patch: @r@ expression err, eno, cls, fmt; position p; @@ ( error_report(fmt, ...)@p | error_set(err, cls, fmt, ...)@p | error_set_errno(err, eno, cls, fmt, ...)@p | error_setg(err, fmt, ...)@p | error_setg_errno(err, eno, fmt, ...)@p ) @script:python@ fmt << r.fmt; p << r.p; @@ if "\\n" in str(fmt): print "%s:%s:%s:%s" % (p[0].file, p[0].line, p[0].column, fmt) Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-id: 1360354939-10994-4-git-send-email-armbru@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* migration: remove argument to qemu_savevm_state_cancelJuan Quintela2013-01-171-1/+1
| | | | | | | Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
* migration: Only go to the iterate stage if there is anything to sendJuan Quintela2013-01-171-1/+1
| | | | | | | | Signed-off-by: Orit Wasserman <owasserm@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
* migration: unfold rest of migrate_fd_put_ready() into threadJuan Quintela2013-01-171-54/+41
| | | | | | | | | This will allow us finer control in next patches. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
* migration: move exit condition to migration threadJuan Quintela2013-01-171-6/+8
| | | | | | | Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
* migration: Add buffered_flush error handlingJuan Quintela2013-01-171-1/+2
| | | | | | | | | | Now that we have error handling we can do proper handling of buffered_flush(). Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
* migration: move beginning stage to the migration threadJuan Quintela2013-01-171-13/+15
| | | | | | | Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
* migration: fix off-by-one in buffered_rate_limitPaolo Bonzini2013-01-171-1/+1
| | | | | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Reviewed-by: Eric Blake <eblake@redhat.com>
* migration: remove double call to migrate_fd_closePaolo Bonzini2013-01-171-1/+0
| | | | | | | | | | The call in buffered_close is enough, because buffered_close is called already by migrate_fd_cleanup. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Reviewed-by: Eric Blake <eblake@redhat.com>
* migration: make function staticPaolo Bonzini2013-01-171-2/+2
| | | | | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Reviewed-by: Eric Blake <eblake@redhat.com>
* use XFER_LIMIT_RATIO consistentlyPaolo Bonzini2013-01-171-1/+1
| | | | | | | | | | | commit 5b4e1eb769eee892b44d3f6b2369b05196442f59 missed this use. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Reviewed-by: Eric Blake <eblake@redhat.com>
* migration: merge QEMUFileBuffered into MigrationStateJuan Quintela2012-12-201-38/+25
| | | | | | | | | Avoid splitting the state of outgoing migration, more or less arbitrarily, between two data structures. QEMUFileBuffered anyway is used only during migration. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com>
* migration: fix qemu_get_fd for BufferedFilePaolo Bonzini2012-12-201-1/+1
| | | | | | | Not really used, but nice to have it correct. :) Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com>
* migration: move migration notifierJuan Quintela2012-12-201-2/+1
| | | | | | | At this point, it is waranteed that state is ACTIVE. Old position didn't assured hat. Signed-off-by: Juan Quintela <quintela@redhat.com>
* migration: Inline qemu_fopen_ops_buffered into migrate_fd_connectJuan Quintela2012-12-201-8/+3
| | | | Signed-off-by: Juan Quintela <quintela@redhat.com>
* migration: move migration_fd_put_ready()Juan Quintela2012-12-201-65/+65
| | | | | | Put it near its use and un-export it. Signed-off-by: Juan Quintela <quintela@redhat.com>
* migration: add XFER_LIMIT_RATIOJuan Quintela2012-12-201-4/+6
| | | | | | | | The "magic" divisions by 10 are there because of the value of BUFFER_DELAY. Introduce a constant to explain them better. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com>
* migration: move buffered_file.c code into migration.cJuan Quintela2012-12-201-1/+232
| | | | | | | This only moves the code (also from buffered_file.h to migration.h). Fix whitespace until checkpatch is happy. Signed-off-by: Juan Quintela <quintela@redhat.com>
* savevm: New save live migration method: pendingJuan Quintela2012-12-201-7/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Code just now does (simplified for clarity) if (qemu_savevm_state_iterate(s->file) == 1) { vm_stop_force_state(RUN_STATE_FINISH_MIGRATE); qemu_savevm_state_complete(s->file); } Problem here is that qemu_savevm_state_iterate() returns 1 when it knows that remaining memory to sent takes less than max downtime. But this means that we could end spending 2x max_downtime, one downtime in qemu_savevm_iterate, and the other in qemu_savevm_state_complete. Changed code to: pending_size = qemu_savevm_state_pending(s->file, max_size); DPRINTF("pending size %lu max %lu\n", pending_size, max_size); if (pending_size >= max_size) { ret = qemu_savevm_state_iterate(s->file); } else { vm_stop_force_state(RUN_STATE_FINISH_MIGRATE); qemu_savevm_state_complete(s->file); } So what we do is: at current network speed, we calculate the maximum number of bytes we can sent: max_size. Then we ask every save_live section how much they have pending. If they are less than max_size, we move to complete phase, otherwise we do an iterate one. This makes things much simpler, because now individual sections don't have to caluclate the bandwidth (it was implossible to do right from there). Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
* migration: just lock migrate_fd_put_readyJuan Quintela2012-12-201-0/+5
| | | | Signed-off-by: Juan Quintela <quintela@redhat.com>
* migration: remove unfreeze logicJuan Quintela2012-12-201-23/+0
| | | | | | | | Now that we have a thread, and blocking writes, we don't need it. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
* migration: make writes blockingJuan Quintela2012-12-201-17/+0
| | | | | | | | Move all the writes to the migration_thread, and make writings blocking. Notice that are still using the iothread for everything that we do. Signed-off-by: Juan Quintela <quintela@redhat.com>
* migration: move migration thread init code to migrate_fd_put_readyJuan Quintela2012-12-201-12/+17
| | | | | | | This way everything related with migration is run on the migration thread and no locking is needed. Signed-off-by: Juan Quintela <quintela@redhat.com>
* migration: make qemu_fopen_ops_buffered() return voidJuan Quintela2012-12-201-1/+1
| | | | | | | | | We want the file assignment to happen before the thread is created to avoid locking, so we just do it before creating the thread. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Orit Wasserman <owasserm@redhat.com>
* migration: remove double call to migrate_fd_closePaolo Bonzini2012-12-201-1/+1
| | | | | | | | The call in buffered_close is enough, because buffered_close is called already by migrate_fd_cleanup. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com>
* softmmu: move include files to include/sysemu/Paolo Bonzini2012-12-191-1/+1
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* misc: move include files to include/qemu/Paolo Bonzini2012-12-191-1/+1
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* migration: move include files to include/migration/Paolo Bonzini2012-12-191-2/+2
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* monitor: move include files to include/monitor/Paolo Bonzini2012-12-191-1/+1
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* block: move include files to include/block/Paolo Bonzini2012-12-191-1/+1
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* migration: move process_incoming_migration to a coroutinePaolo Bonzini2012-11-021-1/+20
| | | | | | | | The final part of incoming migration, which now consists of process_incoming_migration for all protocols, is thus made non-blocking. Reviewed-by: Orit Wasserman <owasserm@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* migration: move qemu_fclose to process_incoming_migrationPaolo Bonzini2012-11-021-1/+5
| | | | | | | The common suffix is now just process_incoming_migration. Reviewed-by: Orit Wasserman <owasserm@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* migration: use migrate_fd_close in migrate_fd_cleanupPaolo Bonzini2012-11-021-11/+8
| | | | | | | | | | | migrate_fd_cleanup will usually close the file descriptor via buffered_file_close's call to migrate_fd_close. However, in the case of s->file == NULL it is "inlining" migrate_fd_close (almost: there is a direct close() instead of using s->close(s)). To fix the inconsistency and clean up the code, allow multiple calls to migrate_fd_close and use the function in migrate_fd_cleanup. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* Merge branch 'queue/qmp' of git://repo.or.cz/qemu/qmp-unstableAurelien Jarno2012-10-291-1/+1
|\ | | | | | | | | | | | | * 'queue/qmp' of git://repo.or.cz/qemu/qmp-unstable: migration: go to paused state after finishing incoming migration with -S qmp: handle stop/cont in INMIGRATE state hmp: fix info cpus for sparc targets
| * migration: go to paused state after finishing incoming migration with -SPaolo Bonzini2012-10-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | At the end of migration the machine has started already, and cannot be destroyed without losing the guest's data. Hence, prelaunch is the wrong state. Go to the paused state instead. QEMU would reach that state anyway (after running the guest for the blink of an eye) if the "stop" command had been received after the start of migration. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* | migration (incoming): add error propagation to fd and exec protocolsPaolo Bonzini2012-10-231-9/+6
| | | | | | | | | | | | | | And remove the superfluous integer return value. Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* | migration (outgoing): add error propagation for all protocolsPaolo Bonzini2012-10-231-11/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Error propagation is already there for socket backends. Add it to other protocols, simplifying code that tests for errors that will never happen. With all protocols understanding Error, the code can be simplified further by removing the return value. Unfortunately, the quality of error messages varies depending on where the error is detected, because no Error is passed to the NonBlockingConnectHandler. Thus, the exact error message still cannot be sent to the user if the OS reports it asynchronously via SO_ERROR. If NonBlockingConnectHandler received an Error**, we could for example report the error class and/or message via a new field of the query-migration command even if it is reported asynchronously. Before: (qemu) migrate fd:ffff migrate: An undefined error has occurred (qemu) info migrate (qemu) After: (qemu) migrate fd:ffff migrate: File descriptor named 'ffff' has not been found (qemu) info migrate capabilities: xbzrle: off Migration status: failed total time: 0 milliseconds Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* | migration: use qemu-sockets to establish Unix socketsPaolo Bonzini2012-10-231-2/+2
| | | | | | | | | | | | | | This makes migration-unix.c again a cut-and-paste job from migration-tcp.c, exactly as it was in the beginning. :) Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* | migration: centralize call to migrate_fd_error()Paolo Bonzini2012-10-231-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The call to migrate_fd_error() was missing for non-socket backends, so centralize it in qmp_migrate(). Before: (qemu) migrate fd:ffff migrate: An undefined error has occurred (qemu) info migrate (qemu) After: (qemu) migrate fd:ffff migrate: An undefined error has occurred (qemu) info migrate capabilities: xbzrle: off Migration status: failed total time: 0 milliseconds (The awful error message will be fixed later in the series). Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* | migration: avoid using error_is_set and thus relying on errp != NULLPaolo Bonzini2012-10-231-6/+7
|/ | | | | | | | | | | The migration code is using errp to detect "internal" errors, this means that it relies on errp being non-NULL. No impact so far because our only QMP clients (the QMP marshaller and HMP) never pass a NULL Error **. But if we had others, this patch would make sure that migration can work with a NULL Error **. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* savevm: make qemu_file_put_notify() return errorsJuan Quintela2012-10-171-2/+3
| | | | | | Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
* migration: make migrate_fd_wait_for_unfreeze() return errorsJuan Quintela2012-10-171-3/+4
| | | | | | | | Adjust all callers Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
* buffered_file: We can access directly to bandwidth_limitJuan Quintela2012-10-171-1/+1
| | | | | | Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
* buffered_file: unfold migrate_fd_closeJuan Quintela2012-10-171-6/+2
| | | | | | We only used it once, just remove the callback indirection. Signed-off-by: Juan Quintela <quintela@redhat.com>
* buffered_file: unfold migrate_fd_wait_for_unfreezeJuan Quintela2012-10-171-3/+1
| | | | | | We only used it once, just remove the callback indirection. Signed-off-by: Juan Quintela <quintela@redhat.com>
* buffered_file: unfold migrate_fd_put_readyJuan Quintela2012-10-171-3/+1
| | | | | | | | We only use it once, just remove the callback indirection. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
* buffered_file: unfold migrate_fd_put_bufferJuan Quintela2012-10-171-4/+2
| | | | | | | | We only used it once, just remove the callback indirection Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
* migration: Add dirty_pages_rate to query migrate outputJuan Quintela2012-10-171-0/+2
| | | | | | It indicates how many pages were dirtied during the last second. Signed-off-by: Juan Quintela <quintela@redhat.com>
* migration: print expected downtime in info migrateJuan Quintela2012-10-171-0/+2
| | | | Signed-off-by: Juan Quintela <quintela@redhat.com>
OpenPOWER on IntegriCloud