summaryrefslogtreecommitdiffstats
path: root/savevm.c
Commit message (Collapse)AuthorAgeFilesLines
* vmstate: Make vmstate_register() static inlineAndreas Färber2013-03-121-7/+0
| | | | | | | | | This avoids adding a duplicate stub for CONFIG_USER_ONLY. Suggested-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
* migration: move rate limiting to QEMUFilePaolo Bonzini2013-03-111-14/+17
| | | | | | | | | | | | | | Rate limiting is now simply a byte counter; client call qemu_file_rate_limit() manually to determine if they have to exit. So it is possible and simple to move the functionality to QEMUFile. This makes the remaining functionality of s->file redundant; in the next patch we can remove it and write directly to s->migration_file. 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>
* migration: use QEMUFile for migration channel lifetimePaolo Bonzini2013-03-111-0/+1
| | | | | | | | | | | 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>
* qemu-file: simplify and export qemu_ftellPaolo Bonzini2013-03-111-12/+8
| | | | | | | | | | Force a flush when qemu_ftell is called. This simplifies the buffer magic (it also breaks qemu_ftell for input QEMUFiles, but we never use it). 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>
* qemu-file: add writable socket QEMUFilePaolo Bonzini2013-03-111-2/+31
| | | | | | | 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>
* qemu-file: check exit status when closing a pipe QEMUFilePaolo Bonzini2013-03-111-0/+3
| | | | | | | | | This is what exec_close does. Move this to the underlying 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>
* qemu-file: fsync a writable stdio QEMUFilePaolo Bonzini2013-03-111-0/+18
| | | | | | | | | This is what fd_close does. Prepare for switching to a 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>
* migration: merge qemu_popen_cmd with qemu_popenPaolo Bonzini2013-03-111-14/+8
| | | | | | | | | | | There is no reason for outgoing exec migration to do popen manually anymore (the reason used to be that we needed the FILE* to make it non-blocking). Use qemu_popen_cmd. 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>
* qemu-file: make qemu_fflush and qemu_file_set_error private againPaolo Bonzini2013-03-111-2/+2
| | | | | | | 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>
* migration: yay, buffering is gonePaolo Bonzini2013-03-111-0/+1
| | | | | | | | | | | | | Buffering was needed because blocking writes could take a long time and starve other threads seeking to grab the big QEMU mutex. Now that all writes (except within _complete callbacks) are done outside the big QEMU mutex, we do not need buffering at all. 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>
* migration: run setup callbacks out of big lockPaolo Bonzini2013-03-111-0/+3
| | | | | | | | | Only the migration_bitmap_sync() call needs the iothread lock. 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>
* qemu-file: temporarily expose qemu_file_set_error and qemu_fflushPaolo Bonzini2013-03-111-2/+2
| | | | | | | | | | | | | | | | | | Right now, migration cannot entirely rely on QEMUFile's automatic drop of I/O after an error, because it does its "real" I/O outside the put_buffer callback. To fix this until buffering is gone, expose qemu_file_set_error which we will use in buffered_flush. Similarly, buffered_flush is not a complete flush because some data may still reside in the QEMUFile's own buffer. This somewhat complicates the process of closing the migration thread. Again, when buffering is gone buffered_flush will disappear and calling qemu_fflush will not be needed; in the meanwhile, we expose the function for use in migration.c. 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>
* migration: use qemu_file_set_error to pass error codes back to qemu_savevm_statePaolo Bonzini2013-03-111-26/+18
| | | | | | | 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>
* qemu-file: pass errno from qemu_fflush via f->last_errorPaolo Bonzini2013-03-111-13/+12
| | | | | | | | | | This is done by almost all callers of qemu_fflush, move the code directly to qemu_fflush. 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>
* migration: push qemu_savevm_state_cancel out of qemu_savevm_state_*Paolo Bonzini2013-03-111-11/+4
| | | | | | | | | | This is useful, because it lets us keep the cancellation callbacks inside the big lock while pushing the others out. 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>
* migration: make qemu_ftell() public and support writable filesStefan Hajnoczi2013-02-121-2/+7
| | | | | | | | | | | | | | | Migration .save_live_iterate() functions return the number of bytes transferred. The easiest way of doing this is by calling qemu_ftell(f) at the beginning and end of the function to calculate the difference. Make qemu_ftell() public so that block-migration will be able to use it. Also adjust the ftell calculation for writable files where buf_offset does not include buf_size. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Message-id: 1360661835-28663-2-git-send-email-stefanha@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* migration: restrict scope of incoming fd read handlerStefan Hajnoczi2013-02-111-4/+30
| | | | | | | | | | | | | | | | | | | | | 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>
* net: introduce qemu_get_queue()Jason Wang2013-02-011-1/+1
| | | | | | | | | To support multiqueue, the patch introduce a helper qemu_get_queue() which is used to get the NetClientState of a device. The following patches would refactor this helper to support multiqueue. Signed-off-by: Jason Wang <jasowang@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Move XBZRLE encoding code to a separate file to allow testingOrit Wasserman2013-02-011-159/+0
| | | | | | | | Signed-off-by: Orit Wasserman <owasserm@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
* Merge remote-tracking branch 'quintela/thread.next' into stagingAnthony Liguori2013-01-211-5/+7
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | # By Juan Quintela (7) and Paolo Bonzini (6) # Via Juan Quintela * quintela/thread.next: migration: remove argument to qemu_savevm_state_cancel migration: Only go to the iterate stage if there is anything to send migration: unfold rest of migrate_fd_put_ready() into thread migration: move exit condition to migration thread migration: Add buffered_flush error handling migration: move beginning stage to the migration thread qemu-file: Only set last_error if it is not already set migration: fix off-by-one in buffered_rate_limit migration: remove double call to migrate_fd_close migration: make function static use XFER_LIMIT_RATIO consistently Protect migration_bitmap_sync() with the ramlist lock Unlock ramlist lock also in error case
| * migration: remove argument to qemu_savevm_state_cancelJuan Quintela2013-01-171-4/+4
| | | | | | | | | | | | | | Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
| * qemu-file: Only set last_error if it is not already setJuan Quintela2013-01-171-1/+3
| | | | | | | | | | | | | | Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
* | HMP: add QDict to info callback handlerWenchao Xia2013-01-171-1/+1
|/ | | | | | | | | This patch change all info call back function to take additional QDict * parameter, which allow those command take parameter. Now it is set to NULL at default case. Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* savevm: Remove MinGW specific code which is no longer neededStefan Weil2013-01-111-28/+2
| | | | | | | | QEMU provides a portable function qemu_gettimeofday instead of gettimeofday and also an implementation of localtime_r for MinGW. Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* savevm.c: cleanup system includesMichael Tokarev2013-01-021-39/+1
| | | | | | | | | | | | | | | | | | | | | | savevm.c suffers from the same problem as some other files. Some years ago savevm.c was created from vl.c, moving some code from there into a separate file. At that time, all includes were just copied from vl.c to savevm.c, without checking which ones are needed and which are not. But actually most of that stuff is _not_ needed. More, some stuff is wrong, for example, *BSD #ifdef'ery around <util.h> vs <libutil.h> - for one, it fails to build on Debian/kFreebsd. Just remove all this. Maybe there's a possibility to clean it up further - like removing <windows.h> (and maybe including winsock.h for htons etc), and maybe it's possible to remove some internal #includes too, but I didn't check this. While at it, remove duplicate #include of qemu/timer.h. Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* savevm: New save live migration method: pendingJuan Quintela2012-12-201-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: make writes blockingJuan Quintela2012-12-201-5/+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>
* softmmu: move include files to include/sysemu/Paolo Bonzini2012-12-191-2/+2
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* misc: move include files to include/qemu/Paolo Bonzini2012-12-191-5/+5
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* migration: move include files to include/migration/Paolo Bonzini2012-12-191-1/+1
| | | | 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>
* exec: move include files to include/exec/Paolo Bonzini2012-12-191-1/+1
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* net: reorganize headersPaolo Bonzini2012-12-191-1/+1
| | | | | | | | | Move public headers to include/net, and leave private headers in net/. Put the virtio headers in include/net/tap.h, removing the multiple copies that existed. Leave include/net/tap.h as the interface for NICs, and net/tap_int.h as the interface for OS-specific parts of the tap backend. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* janitor: do not include qemu-char everywherePaolo Bonzini2012-12-191-1/+0
| | | | | | | 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>
* migration: handle EAGAIN while reading QEMUFilePaolo Bonzini2012-11-021-6/+24
| | | | | | | | | | | | | This will never happen right now (the assertion would fail). The next patch will set the socket or pipe in non-blocking mode, thus enabling this part of the code. Coroutines can just stop whenever they want with qemu_coroutine_yield. As soon as select tells the main loop that the migration stream is readable, the coroutine is re-entered directly in qemu_get_buffer, where it will read more data and pass it to the loading routines. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* migration: close socket QEMUFile from socket_closePaolo Bonzini2012-11-021-0/+1
| | | | | | | 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>
* migration: replace qemu_stdio_fd with qemu_get_fdPaolo Bonzini2012-11-021-11/+0
| | | | | Reviewed-by: Orit Wasserman <owasserm@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* migration: add qemu_get_fdPaolo Bonzini2012-11-021-0/+27
| | | | | Reviewed-by: Orit Wasserman <owasserm@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* migration: consolidate QEMUFile methods in a single QEMUFileOps structPaolo Bonzini2012-11-021-48/+60
| | | | | Reviewed-by: Orit Wasserman <owasserm@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* migration: unify stdio-based QEMUFile operationsPaolo Bonzini2012-11-021-17/+2
| | | | | | | | | | Now that qemu_fseek does not exist anymore, there is no reason to do an fseek before fread/fwrite when operating on an stdio file. Thus, unify the get/put_buffer callbacks used by qemu_fopen with those used for pipes. Reviewed-by: Orit Wasserman <owasserm@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* vmstate: Add support for saving/loading bitmapsPeter Maydell2012-10-301-0/+41
| | | | | | | | Add support for saving/loading bitmap.h bitmaps in vmstate. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Tested-by: Igor Mitsyanko <i.mitsyanko@samsung.com> Reviewed-by: Juan Quintela <quintela@redhat.com>
* savevm: make qemu_file_put_notify() return errorsJuan Quintela2012-10-171-2/+2
| | | | | | Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
* savevm: un-export qemu_file_set_error()Juan Quintela2012-10-171-1/+1
| | | | | | Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
* savevm: Only qemu_fflush() can generate errorsJuan Quintela2012-10-171-17/+18
| | | | | | | | | Move the error check to the beggining of the callers. Once this is fixed qemu_file_set_if_error() is not used anymore, so remove it. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
* savevm: make qemu_fill_buffer() be consistentJuan Quintela2012-10-171-1/+1
| | | | | | | | It was setting last_error directly once, and with the helper the other time. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
* savevm: unexport qemu_ftell()Juan Quintela2012-10-171-1/+1
| | | | | | It was unused out of savevm.c. Signed-off-by: Juan Quintela <quintela@redhat.com>
* savevm: unfold qemu_fclose_internal()Juan Quintela2012-10-171-20/+6
| | | | | | | | | It was used only one, and was only one if. It makes error handling saner. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
* savevm: make qemu_fflush() return an error codeJuan Quintela2012-10-171-16/+23
| | | | | | | | | Adjust all the callers. We moved the set of last_error from inside qemu_fflush() to all the callers. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
* savevm: Remove qemu_fseek()Juan Quintela2012-10-171-21/+0
| | | | | | | | It has no users, and is only half implemented. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
* savevm: unexport qemu_fflushJuan Quintela2012-10-171-1/+1
| | | | | | | | It is not used outside of savevm.c Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
OpenPOWER on IntegriCloud