summaryrefslogtreecommitdiff
path: root/migration.c
AgeCommit message (Collapse)AuthorFilesLines
2012-01-13prepare for future GPLv2+ relicensingPaolo Bonzini1-0/+2
All files under GPLv2 will get GPLv2+ changes starting tomorrow. event_notifier.c and exec-obsolete.h were only ever touched by Red Hat employees and can be relicensed now. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-12-12migrate_fd_cleanup: accept any negative qemu_fclose() value as errorEduardo Habkost1-3/+1
Also, we now return the qemu_fclose() value unchanged to the caller. For reference, the migrate_fd_cleanup() callers are the following: - migrate_fd_completed(): any negative value is considered an error, so the change is OK. - migrate_fd_error(): doesn't check the migrate_fd_cleanup() return value - migrate_fd_cancel(): doesn't check the migrate_fd_cleanup() return value Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-12-06qapi: Convert migrate_set_speedLuiz Capitulino1-8/+4
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-12-06qapi: Convert migrate_set_downtimeLuiz Capitulino1-9/+4
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-12-06qapi: Convert migrate_cancelLuiz Capitulino1-2/+1
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-11-21block: allow migration to work with image files (v3)Anthony Liguori1-0/+3
Image files have two types of data: immutable data that describes things like image size, backing files, etc. and mutable data that includes offset and reference count tables. Today, image formats aggressively cache mutable data to improve performance. In some cases, this happens before a guest even starts. When dealing with live migration, since a file is open on two machines, the caching of meta data can lead to data corruption. This patch addresses this by introducing a mechanism to invalidate any cached mutable data a block driver may have which is then used by the live migration code. NB, this still requires coherent shared storage. Addressing migration without coherent shared storage (i.e. NFS) requires additional work. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-11-21migrate: add migration blockersAnthony Liguori1-0/+18
This lets different subsystems register an Error that is thrown whenever migration is attempted. This works nicely because it gracefully supports things like hotplug. Right now, if multiple errors are registered, only one of them is reported. I expect that for 1.1, we'll extend query-migrate to return all of the reasons why migration is disabled at any given point in time. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-11-11migration: fix detached migration with fdJuan Quintela1-2/+10
Migration with fd uses s->mon to pass the fd. But we only assign the s->mon for !detached migration. Fix it. Once there add a comment indicating that s->mon has two uses. Bug reported by: Wen Congyang <wency@cn.fujitsu.com> Signed-off-by: Juan Quintela <quintela@redhat.com> CC: Wen Congyang <wency@cn.fujitsu.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-11-01Fix segfault on migration completionLuiz Capitulino1-1/+1
A simple migration reproduces it: 1. Start the source VM with: # qemu [...] -S 2. Start the destination VM with: # qemu <source VM cmd-line> -incoming tcp:0:4444 3. In the source VM: (qemu) migrate -d tcp:0:4444 4. The source VM will segfault as soon as migration completes (might not happen in the first try) What is happening here is that qemu_file_put_notify() can end up closing 's->file' (in which case it's also set to NULL). The call stack is rather complex, but Eduardo helped tracking it to: select loop -> migrate_fd_put_notify() -> qemu_file_put_notify() -> buffered_put_buffer() -> migrate_fd_put_ready() -> migrate_fd_completed() -> migrate_fd_cleanup(). To be honest, it's not completely clear to me in which cases 's->file' is not closed (on error maybe)? But I doubt this fix will make anything worse. Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Acked-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-31Merge remote-tracking branch 'qmp/queue/qmp' into stagingAnthony Liguori1-59/+23
Conflicts: ui/spice-core.c
2011-10-27qapi: Convert query-migrateLuiz Capitulino1-59/+23
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-10-25migration: add status query functionsGerd Hoffmann1-0/+11
Add migration_is_active and migration_has_failed functions to query migration state. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-10-20Merge remote-tracking branch 'quintela/migration-pull' into stagingAnthony Liguori1-212/+227
2011-10-20migration: Make state definitions localJuan Quintela1-0/+8
Signed-off-by: Juan Quintela <quintela@redhat.com>
2011-10-20migration: Export a function that tells if the migration has finished correctlyJuan Quintela1-2/+2
This will allow us to hide the state values. Signed-off-by: Juan Quintela <quintela@redhat.com>
2011-10-20migration: Pass MigrationState in migration notifiersJuan Quintela1-4/+4
Signed-off-by: Juan Quintela <quintela@redhat.com>
2011-10-20migration: Use bandwidth_limit directlyJuan Quintela1-7/+8
Now that current_migration always exist, there is no reason for max_throotle variable. Signed-off-by: Juan Quintela <quintela@redhat.com>
2011-10-20migration: create accessor for current_migrationJuan Quintela1-61/+55
Signed-off-by: Juan Quintela <quintela@redhat.com>
2011-10-20migration: Move exported functions to the end of the fileJuan Quintela1-96/+91
This means we can remove the two forward declarations. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-20migration: Remove migration cancel() callbackJuan Quintela1-5/+4
It is used only in one place Signed-off-by: Juan Quintela <quintela@redhat.com>
2011-10-20migration: Remove get_status() accessorJuan Quintela1-11/+5
It is only used inside migration.c, and fields on that struct are accessed all around the place on that file. Signed-off-by: Juan Quintela <quintela@redhat.com>
2011-10-20migration: Our release callback was just freeJuan Quintela1-18/+1
We called it from a single place, and always with state != MIG_STATE_ACTIVE. Just remove the whole callback. For users of the notifier, notice that this is exactly the case where they don't care, we are just freeing the state from previous failed migration (it can't be a sucessful one, otherwise we would not be running on that machine in the first place). Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-20migration: Introduce migrate_fd_completed() for consistencyJuan Quintela1-7/+13
This function is a bit different of the others that change the state, in the sense that if migrate_fd_cleanup() returns an error, it set the status to error, not completed. Signed-off-by: Juan Quintela <quintela@redhat.com>
2011-10-20migration: Refactor and simplify error checking in migrate_fd_put_readyJuan Quintela1-11/+10
Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-20migration: Introduce MIG_STATE_SETUPJuan Quintela1-1/+5
Use MIG_STATE_ACTIVE only when migration has really started. Use this new state to setup migration parameters. Change defines for an anonymous struct. Signed-off-by: Juan Quintela <quintela@redhat.com>
2011-10-20migration: move migrate_new to do_migrateJuan Quintela1-13/+19
Once there, remove all parameters that don't need to be passed to *start_outgoing_migration() functions Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-20migration: Make all posible migration functions staticJuan Quintela1-36/+36
I have to move two functions postions to avoid forward declarations Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-20migration: Refactor MigrationState creationJuan Quintela1-4/+25
Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-20migration: Rename FdMigrationState MigrationStateJuan Quintela1-17/+17
Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-20migration: Fold MigrationState into FdMigrationStateJuan Quintela1-8/+6
Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-20migration: Use FdMigrationState instead of MigrationState when possibleJuan Quintela1-18/+16
Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-20migration: Make *start_outgoing_migration return FdMigrationStateJuan Quintela1-2/+2
Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-20migration: rename qemu_file_has_error to qemu_file_get_errorJuan Quintela1-1/+1
Now the function returned errno, so it is better the new name. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-20migration: return real error codeJuan Quintela1-1/+5
make functions propagate errno, instead of just using -EIO. Add a comment about what are the return value of qemu_savevm_state_iterate(). Signed-off-by: Juan Quintela <quintela@redhat.com>
2011-10-20migration: change has_error to contain errno valuesJuan Quintela1-1/+1
We normally already have an errno value. When not, abuse EIO. Signed-off-by: Juan Quintela <quintela@redhat.com>
2011-10-20migration: set error if select return one errorJuan Quintela1-0/+4
Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-20migration: don't "write" when migration is not activeJuan Quintela1-0/+4
If migration is not active, just ignore writes. Signed-off-by: Juan Quintela <quintela@redhat.com>
2011-10-20migration: add error handling to migrate_fd_put_notify().Yoshiaki Tamura1-3/+3
Although migrate_fd_put_buffer() sets MIG_STATE_ERROR if it failed, since migrate_fd_put_notify() isn't checking error of underlying QEMUFile, those resources are kept open. This patch checks it and calls migrate_fd_error() in case of error. Signed-off-by: Yoshiaki Tamura <tamura.yoshiaki@lab.ntt.co.jp> Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-20migration: Check that migration is active before cancel itJuan Quintela1-2/+2
Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-20migration: simplify state assignmenteJuan Quintela1-7/+4
Once there, make sure that if we already know that there is one error, just call migration_fd_cleanup() with the ERROR state. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-19runstate: Allow user to migrate twiceLuiz Capitulino1-1/+1
It should be a matter of allowing the transition POSTMIGRATE -> FINISH_MIGRATE, but it turns out that the VM won't do the transition the second time because it's already stopped. So this commit also adds vm_stop_force_state() which performs the transition even if the VM is already stopped. While there also allow other states to migrate. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-10-04RunState: Rename enum values as generated by the QAPILuiz Capitulino1-3/+3
Next commit will convert the query-status command to use the RunState type as generated by the QAPI. In order to "transparently" replace the current enum by the QAPI one, we have to make some changes to some enum values. As the changes are simple renames, I'll do them in one shot. The changes are: - Rename the prefix from RSTATE_ to RUN_STATE_ - RUN_STATE_SAVEVM to RUN_STATE_SAVE_VM - RUN_STATE_IN_MIGRATE to RUN_STATE_INMIGRATE - RUN_STATE_PANICKED to RUN_STATE_INTERNAL_ERROR - RUN_STATE_POST_MIGRATE to RUN_STATE_POSTMIGRATE - RUN_STATE_PRE_LAUNCH to RUN_STATE_PRELAUNCH - RUN_STATE_PRE_MIGRATE to RUN_STATE_PREMIGRATE - RUN_STATE_RESTORE to RUN_STATE_RESTORE_VM - RUN_STATE_PRE_MIGRATE to RUN_STATE_FINISH_MIGRATE Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-09-15Drop the vm_running global variableLuiz Capitulino1-1/+1
Use runstate_is_running() instead, which is introduced by this commit. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-09-15Drop the incoming_expected global variableLuiz Capitulino1-2/+0
Test against RSTATE_IN_MIGRATE instead. Please, note that the RSTATE_IN_MIGRATE state is only set when all the initial VM setup is done, while 'incoming_expected' was set right in the beginning when parsing command-line options. Shouldn't be a problem as far as I could check. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-09-15RunState: Add additional statesLuiz Capitulino1-1/+7
Currently, only vm_start() and vm_stop() change the VM state. That's, the state is only changed when starting or stopping the VM. This commit adds the runstate_set() function, which makes it possible to also do state transitions when the VM is stopped or running. Additional states are also added and the current state is stored. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-09-15Replace the VMSTOP macros with a proper state typeLuiz Capitulino1-1/+1
Today, when notifying a VM state change with vm_state_notify(), we pass a VMSTOP macro as the 'reason' argument. This is not ideal because the VMSTOP macros tell why qemu stopped and not exactly what the current VM state is. One example to demonstrate this problem is that vm_start() calls vm_state_notify() with reason=0, which turns out to be VMSTOP_USER. This commit fixes that by replacing the VMSTOP macros with a proper state type called RunState. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-08-20Use glib memory allocation and free functionsAnthony Liguori1-1/+1
qemu_malloc/qemu_free no longer exist after this commit. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-05Reorganize and fix monitor resume after migrationJan Kiszka1-10/+9
If migration failed in migrate_fd_put_buffer, the monitor may have been resumed not only in the error path of that function but also once again in migrate_fd_put_ready which is called unconditionally by migrate_fd_connect. Fix this by establishing a cleaner policy: the monitor shall be resumed when the migration file is closed, either via callback (migrate_fd_close) or in migrate_fd_cleanup if no file is open (i.e. no callback invoked). Reported-By: Michael Tokarev <mjt@tls.msk.ru> Tested-By: Michael Tokarev <mjt@tls.msk.ru> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-07-23notifier: Pass data argument to callbackJan Kiszka1-6/+6
This allows to pass additional information to the notifier callback which is useful if sender and receiver do not share any other distinct data structure. Will be used first for the clock reset notifier. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-02-14Improve vm_stop reason declarationsJan Kiszka1-1/+1
Define and use dedicated constants for vm_stop reasons, they actually have nothing to do with the EXCP_* defines used so far. At this chance, specify more detailed reasons so that VM state change handlers can evaluate them. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>