aboutsummaryrefslogtreecommitdiff
path: root/migration-tcp.c
AgeCommit message (Collapse)Author
2014-05-05Coverity: Fix failure path for qemu_accept in migrationDr. David Alan Gilbert
Coverity defects 1005733 & 1005734 complain about passing a negative value to closesocket in the error paths on incoming migration. Stash the error value and print it in the message (previously we gave no indication of the reason for the failure) Use error_report Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com>
2013-08-22aio / timers: Untangle include filesAlex Bligh
include/qemu/timer.h has no need to include main-loop.h and doing so causes an issue for the next patch. Unfortunately various files assume including timers.h will pull in main-loop.h. Untangle this mess. Signed-off-by: Alex Bligh <alex@alex.org.uk> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-03-11migration: eliminate s->migration_filePaolo Bonzini
The indirection is useless now. Backends can open s->file directly. Reviewed-by: Orit Wasserman <owasserm@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com>
2013-03-11migration: use QEMUFile for writing outgoing migration dataPaolo Bonzini
Second, drop the file descriptor indirection, and write directly to the QEMUFile. Reviewed-by: Orit Wasserman <owasserm@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com>
2013-03-11migration: use QEMUFile for migration channel lifetimePaolo Bonzini
As a start, use QEMUFile to store the destination and close it. qemu_get_fd gets a file descriptor that will be used by the write callbacks. Reviewed-by: Orit Wasserman <owasserm@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com>
2013-03-11qemu-file: add writable socket QEMUFilePaolo Bonzini
Reviewed-by: Orit Wasserman <owasserm@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com>
2012-12-20migration: make writes blockingJuan Quintela
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>
2012-12-20migration: include qemu-file.hJuan Quintela
They don't use/know anything about buffered-file. Signed-off-by: Juan Quintela <quintela@redhat.com>
2012-12-19misc: move include files to include/qemu/Paolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19migration: move include files to include/migration/Paolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19block: move include files to include/block/Paolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19janitor: do not include qemu-char everywherePaolo Bonzini
Touching char/char.h basically causes the whole of QEMU to be rebuilt. Avoid this, it is usually unnecessary. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-11-02migration: move qemu_fclose to process_incoming_migrationPaolo Bonzini
The common suffix is now just process_incoming_migration. Reviewed-by: Orit Wasserman <owasserm@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-11-02migration: close socket QEMUFile from socket_closePaolo Bonzini
The common suffix now is process_incoming_migration+qemu_fclose. Reviewed-by: Orit Wasserman <owasserm@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-11-02migration: xxx_close will only be called oncePaolo Bonzini
No need to test s->fd again, it is tested in the caller. Reviewed-by: Orit Wasserman <owasserm@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-11-02migration: use closesocket, not closePaolo Bonzini
Windows requires this. Migration does not quite work under Windows but let's be uniform across QEMU. Reviewed-by: Orit Wasserman <owasserm@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-11-02migration: clean up server sockets and handlers before invoking ↵Paolo Bonzini
process_incoming_migration A first step towards making a common "suffix" for all migration protocols, and moving it to process_incoming_migration. Reviewed-by: Orit Wasserman <owasserm@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-10-23migration (incoming): add error propagation to fd and exec protocolsPaolo Bonzini
And remove the superfluous integer return value. Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-10-23migration (outgoing): add error propagation for all protocolsPaolo Bonzini
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>
2012-10-23migration: centralize call to migrate_fd_error()Paolo Bonzini
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>
2012-10-23migration: avoid using error_is_set and thus relying on errp != NULLPaolo Bonzini
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>
2012-09-25Fix address handling in inet_nonblocking_connectOrit Wasserman
getaddrinfo can give us a list of addresses, but we only try to connect to the first one. If that fails we never proceed to the next one. This is common on desktop setups that often have ipv6 configured but not actually working. To fix this make inet_connect_nonblocking retry connection with a different address. callers on inet_nonblocking_connect register a callback function that will be called when connect opertion completes, in case of failure the fd will have a negative value Signed-off-by: Orit Wasserman <owasserm@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-09-25Separate inet_connect into inet_connect (blocking) and inet_nonblocking_connectOrit Wasserman
No need to add non blocking parameters to the blocking inet_connect add block parameter for inet_connect_opts instead of using QemuOpt "block". Signed-off-by: Orit Wasserman <owasserm@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-08-13migration: don't rely on any QERR_SOCKET_*Luiz Capitulino
Use the in_progress argument for QERR_SOCKET_CONNECT_IN_PROGRESS. The other errors are handled the same by checking if the error is set and then calling migrate_fd_error() if it's. It's also necessary to change inet_connect_opts() not to set QERR_SOCKET_CONNECT_IN_PROGRESS. This error is only used by tcp_start_outgoing_migration() and not changing it along with the usage of in_progress would break migration. Furthermore this commit fixes a bug. Today, there's a spurious error report when migration succeeds: (qemu) migrate tcp:0:4444 migrate: Connection can not be completed immediately (qemu) After this commit no spurious error is reported anymore. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com>
2012-08-13net: inet_connect(), inet_connect_opts(): add in_progress argumentLuiz Capitulino
It's used to indicate the special case where a valid file-descriptor is returned (ie. success) but the connection can't be completed w/o blocking. This is needed because QERR_SOCKET_CONNECT_IN_PROGRESS is not treated like an error and a future commit will drop it. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com>
2012-05-10use inet_listen()/inet_connect() to support ipv6 migrationAmos Kong
Use help functions in qemu-socket.c for tcp migration, which already support ipv6 addresses. Currently errp will be set to UNDEFINED_ERROR when migration fails, qemu would output "migration failed: ...", and current user can see a message("An undefined error has occurred") in monitor. This patch changed tcp_start_outgoing_migration()/inet_connect() /inet_connect_opts(), socket error would be passed back, then current user can see a meaningful err message in monitor. Qemu will exit if listening fails, so output socket error to qemu stderr. For IPv6 brackets must be mandatory if you require a port. Referencing to RFC5952, the recommended format is: [2312::8274]:5200 test status: Successed listen side: qemu-kvm .... -incoming tcp:[2312::8274]:5200 client side: qemu-kvm ... (qemu) migrate -d tcp:[2312::8274]:5200 Signed-off-by: Amos Kong <akong@redhat.com> Reviewed-by: Orit Wasserman <owasserm@redhat.com> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-01-13prepare for future GPLv2+ relicensingPaolo Bonzini
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-12tcp_close(): check for close() errors too (v2)Eduardo Habkost
In case close() fails, we want to report the error back. Changes v1 -> v2: - Use braces on if statement to match coding style Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-20migration: make migration-{tcp,unix} consistentJuan Quintela
Files are almost identical in functionality, just remove the differences that make no sense. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-20migration: propagate error correctlyJuan Quintela
unix and tcp outgoing migration have error values, but didn't returned it. Make them return the error. Notice that EINPROGRESS & EWOULDBLOCK are not considered errors as call will be retry later. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-20migration: Don't use callback on file defining itJuan Quintela
Signed-off-by: Juan Quintela <quintela@redhat.com>
2011-10-20migration: move migrate_new to do_migrateJuan Quintela
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: Refactor MigrationState creationJuan Quintela
Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-20migration: Rename FdMigrationState MigrationStateJuan Quintela
Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-20migration: Fold MigrationState into FdMigrationStateJuan Quintela
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 Quintela
Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-20Use glib memory allocation and free functionsAnthony Liguori
qemu_malloc/qemu_free no longer exist after this commit. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-04-15Remove unused sysemu.h include directivesBlue Swirl
Remove unused sysemu.h include directives to speed up build with the following patches. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-03-20Fix conversions from pointer to int and vice versaStefan Weil
Here the int values fds[0], sigfd, s, sock and fd are converted to void pointers which are later converted back to an int value. These conversions should always use intptr_t instead of unsigned long. They are needed for environments where sizeof(long) != sizeof(void *). Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-07-25Close socket file descriptor when qemu_accept failsShahar Havivi
Signed-off-by: Shahar Havivi <shaharh@redhat.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-06-22Factorize common migration incoming codeJuan Quintela
Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-06-14migration-tcp: call migrate_fd_error() instead of close() and free().Yoshiaki Tamura
This patch fixes the following error report. When changing migration-tcp.c to call migrate_fd_error() instead of close() and free() by itself, monitor is resumed, and returns allocated mig_state is set to current_migration in migration.c allows us to print "info migrate". Reported-by: Cole Robinson <crobinso@redhat.com> Signed-off-by: Yoshiaki Tamura <tamura.yoshiaki@lab.ntt.co.jp> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-03-17migration: Clear fd also in error casesJuan Quintela
Not clearing the fd and closing the file makes qemu spin using 100%CPU after incoming migration error. See for instance bug: https://bugzilla.redhat.com/show_bug.cgi?id=518032 Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-07Do not use dprintfmalc
dprintf is already claimed by POSIX[1], and on at least one system is implemented as a macro [1] http://www.opengroup.org/onlinepubs/9699919799/functions/dprintf.html Signed-off-by: malc <av1474@comtv.ru>
2009-12-03Don't leak file descriptorsKevin Wolf
We're leaking file descriptors to child processes. Set FD_CLOEXEC on file descriptors that don't need to be passed to children to stop this misbehaviour. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03live migration: Propagate output monitor to callback handlerJan Kiszka
In order to allow proper progress reporting to the monitor that initiated the migration, forward the monitor reference through the migration layer down to SaveLiveStateHandler. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-17Block live migrationlirans@il.ibm.com
This patch introduces block migration called during live migration. Block are being copied to the destination in an async way. First the code will transfer the whole disk and then transfer all dirty blocks accumulted during the migration. Still need to improve transition from the iterative phase of migration to the end phase. For now transition will take place when all blocks transfered once, all the dirty blocks will be transfered during the end phase (guest is suspended). Changes from v4: - Global variabels moved to a global state structure allocated dynamically. - Minor coding style issues. - Poll block.c for tracking of dirty blocks instead of manage it here. Signed-off-by: Liran Schour <lirans@il.ibm.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-30fix migration to obey -SPaolo Bonzini
Since migration returns right away, starting the VM right after calling qemu_start_incoming_migration is wrong even if -S is not passed. We have to do this after migration has completed. Cc: Glauber Costa <glommer@redhat.com> Cc: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-16honor -S on incoming migrationPaolo Bonzini
-S is not honored by qemu on incoming migration. If a domain is migrated while paused, thus, it will start running on the remote machine; this is wrong. Given the trivial patch to fix this, it looks more like a thinko than anything else, probably dating back to the qemu-kvm merge. The interesting part is that the -S mechanism was in fact *used* when migrating (setting autostart = 0) and the incoming migration code was starting the VM at the end of the migration. Since I was removing the vm_start from there, I also corrected a related imprecision. The code was doing a vm_stop "just in case", but we can be sure that the VM is not running---the vm_start call in vl.c has not been reached yet. So the vm_stop is removed together with the vm_start. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-05-21Cast pointer arguments of get/setsockopt, send to void * to keep GCCmalc
from producing a warning about pointer type mismatches with Winsock Signed-off-by: malc <av1474@comtv.ru>