summaryrefslogtreecommitdiff
path: root/savevm.c
AgeCommit message (Collapse)AuthorFilesLines
2012-07-20savevm: split save_live into stage2 and stage3Juan Quintela1-5/+5
We split it into 2 functions, foo_live_iterate, and foo_live_complete. At this point, we only remove the bits that are for the other stage, functionally this is equivalent to previous code. Signed-off-by: Juan Quintela <quintela@redhat.com>
2012-07-20savevm: split save_live_setup from save_live_stateJuan Quintela1-2/+2
This patch splits stage 1 to its own function for both save_live users, ram and block. It is just a copy of the function, removing the parts of the other stages. Optimizations would came later. Signed-off-by: Juan Quintela <quintela@redhat.com>
2012-07-20savevm: introduce is_active methodJuan Quintela1-0/+15
Enable the creation of a method to tell migration if that section is active and should be migrate. We use it for blk-migration, that is normally not active. We don't create the method for RAM, as setups without RAM are very strange O:-) Signed-off-by: Juan Quintela <quintela@redhat.com>
2012-07-20savevm: Refactor cancel operation in its own operationJuan Quintela1-2/+2
Intead of abusing stage with value -1. Signed-off-by: Juan Quintela <quintela@redhat.com>
2012-07-20savevm: Live migration handlers register the struct directlyJuan Quintela1-11/+7
Notice that the live migration users never unregister, so no problem about freeing the ops structure. Signed-off-by: Juan Quintela <quintela@redhat.com>
2012-07-20savevm: Use a struct to pass all handlersJuan Quintela1-29/+25
This would make easier to add more operations in the next patches. Signed-off-by: Juan Quintela <quintela@redhat.com>
2012-06-29No need to iterate if we already are over the limitJuan Quintela1-0/+3
If buffers are full, don't iterate, just exit. Signed-off-by: Juan Quintela <quintela@redhat.com>
2012-06-29Add tracepoints for savevm section start/endJuan Quintela1-0/+8
This allows to know how long each section takes to save. An awk script like this tells us sections that takes more that 10ms $1 ~ /savevm_state_iterate_end/ { /* Print savevm_section_end line when > 10ms duration */ if ($2 > 10000) { printf("%s times_missing=%u\n", $0, times_missing++); } } Signed-off-by: Juan Quintela <quintela@redhat.com> fix ws tracepoints Signed-off-by: Juan Quintela <quintela@redhat.com>
2012-06-29Add MigrationParams structureIsaku Yamahata1-4/+9
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
2012-06-18Merge remote-tracking branch 'afaerber-or/qom-next-2' into stagingAnthony Liguori1-6/+6
* afaerber-or/qom-next-2: (22 commits) qom: Push error reporting to object_property_find() qdev: Remove qdev_prop_exists() qbus: Initialize in standard way qbus: Make child devices links qdev: Connect busses with their parent devices qdev: Convert busses to QEMU Object Model qdev: Move SysBus initialization to sysbus.c qdev: Use wrapper for qdev_get_path qdev: Remove qdev_prop_set_defaults qdev: Clean up global properties qdev: Move bus properties to abstract superclasses qdev: Move bus properties to a separate global qdev: Push "type" property up to Object arm_l2x0: Rename "type" property to "cache-type" m48t59: Rename "type" property to "model" qom: Assert that public types have a non-NULL parent field qom: Drop type_register_static_alias() macro qom: Make Object a type qom: Add class_base_init qom: Add object_child_foreach() ...
2012-06-18qdev: Use wrapper for qdev_get_pathAnthony Liguori1-6/+6
This makes it easier to remove it from BusInfo. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> [AF: Drop now unnecessary NULL initialization in scsibus_get_dev_path()] Signed-off-by: Andreas Färber <afaerber@suse.de>
2012-06-15savevm: flush after saving vm statePaolo Bonzini1-1/+1
Writing vm state uses bdrv_pwrite, so it will automatically get flushes in writethrough mode. But doing a flush at the end in writeback mode is probably a good idea anyway. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-04-15w64: Fix time conversion for some versions of MinGW-w64Stefan Weil1-1/+2
tb.time is a time value, but not necessarily of the same size as time_t: while time_t is 64 bit for w64, tb.time still is 32 bit only. Therefore we need en explicit conversion. Signed-off-by: Stefan Weil <sw@weilnetz.de>
2012-03-19Merge remote-tracking branch 'sstabellini/saverestore-8' into stagingAnthony Liguori1-0/+71
* sstabellini/saverestore-8: xen: do not allocate RAM during INMIGRATE runstate xen mapcache: check if memory region has moved. xen: record physmap changes to xenstore Set runstate to INMIGRATE earlier Introduce "xen-save-devices-state" cirrus_vga: do not reset videoram Conflicts: qapi-schema.json Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-03-19Introduce "xen-save-devices-state"Stefano Stabellini1-0/+71
- add an "is_ram" flag to SaveStateEntry; - register_savevm_live sets is_ram for live_savevm devices; - introduce a "xen-save-devices-state" QAPI command that can be used to save the state of all devices, but not the RAM or the block devices of the VM. Changes in v8: - rename save-devices-state to xen-save-devices-state. Changes in v7: - rename save_devices to save-devices-state. Changes in v6: - remove the is_ram parameter from register_savevm_live and sets is_ram if the device is a live_savevm device; - introduce save_devices as a QAPI command, write a better description for it; - fix CODING_STYLE; - introduce a new doc to explain the save format used by save_devices. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
2012-03-19Merge remote-tracking branch 'qemu-kvm/memory/urgent' into stagingAnthony Liguori1-0/+2
* qemu-kvm/memory/urgent: (42 commits) memory: check for watchpoints when getting code ram_addr exec: fix write tlb entry misused as iotlb Sparc: avoid AREG0 wrappers for memory access helpers Sparc: avoid AREG0 for memory access helpers TCG: add 5 arg helpers to def-helper.h softmmu templates: optionally pass CPUState to memory access functions i386: Remove REGPARM sparc64: implement PCI and ISA irqs sparc: reset CPU state on reset apb: use normal PCI device header for PBM device w64: Fix data type of next_tb and tcg_qemu_tb_exec softfloat: fix for C99 vmstate: fix varrays with uint32_t indexes Fix large memory chunks allocation with tcg_malloc. hw/pxa2xx.c: Fix handling of pxa2xx_i2c variable offset within region hw/pxa2xx_lcd.c: drop target_phys_addr_t usage in device state hw/pxa2xx_dma.c: drop target_phys_addr_t usage in device state ARM: Remove unnecessary subpage workarounds malta: Fix display for LED array malta: Use symbolic hardware addresses ...
2012-03-17vmstate: fix varrays with uint32_t indexesAmos Kong1-0/+2
VMSTATE_VARRAY_UINT32() is used in hw/ds1225y.c, and we checked VMS_VARRAY_UINT32 bit of field->flags in vmstate_load_state(), but we don't check this bit in vmstate_save_state(). Signed-off-by: Amos Kong <akong@redhat.com> Acked-by: Juan Quintela <quintela@redhat.com> Acked-by: Hervé Poussineau <hpoussin@reactos.org> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-03-15qapi: Convert migrateLuiz Capitulino1-7/+6
The migrate command is one of those commands where HMP and QMP completely mix up together. This made the conversion to the QAPI (which separates the command into QMP and HMP parts) a bit difficult. The first important change to be noticed is that this commit completes the removal of the Monitor object from migration code, started by the previous commit. Another important and tricky change is about supporting the non-detached mode. That is, if the user doesn't pass '-d' the migrate command will lock the monitor and will only release it when migration is finished. To support this in the new HMP command (hmp_migrate()), it is necessary to create a timer which runs every second and checks if the migration is still active. If it is, the timer callback will re-schedule itself to run one second in the future. If the migration has already finished, the monitor lock is released and the user can use it normally. All these changes should be transparent to the user. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2012-03-15Purge migration of (almost) everything to do with monitorsLuiz Capitulino1-15/+14
The Monitor object is passed back and forth within the migration/savevm code so that it can print errors and progress to the user. However, that approach assumes a HMP monitor, being completely invalid in QMP. This commit drops almost every single usage of the Monitor object, all monitor_printf() calls have been converted into DPRINTF() ones. There are a few remaining Monitor objects, those are going to be dropped by the next commit. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2012-01-08Fix vmstate_register_ram() for rom/device regionsAvi Kivity1-1/+1
rom/device regions have a ram_addr that is composed of both an I/O handler (low bits) and RAM region (high bits); but qemu_ram_set_idstr() expects just a RAM region. Mask the I/O handler to make it happy. Tested-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Avi Kivity <avi@redhat.com>
2012-01-04vmstate, memory: decouple vmstate from memory APIAvi Kivity1-0/+17
Currently creating a memory region automatically registers it for live migration. This differs from other state (which is enumerated in a VMStateDescription structure) and ties the live migration code into the memory core. Decouple the two by introducing a separate API, vmstate_register_ram(), for registering a RAM block for migration. Currently the same implementation is reused, but later it can be moved into a separate list, and registrations can be moved to VMStateDescription blocks. Signed-off-by: Avi Kivity <avi@redhat.com>
2011-12-15qcow2: Allow >4 GB VM stateKevin Wolf1-1/+1
This is a compatible extension to the snapshot header format that allows saving a 64 bit VM state size. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-12-12stdio_fclose: return -errno on errors (v2)Eduardo Habkost1-2/+5
This is what qemu_fclose() expects. Changes v1 -> v2: - Add braces to if statement to match coding style Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-12-12stdio_pclose: return -errno on error (v3)Eduardo Habkost1-0/+3
This is what qemu_fclose() expects. Changes v1 -> v2: - On success, keep returning pclose() return value, instead of always 0. Changes v2 -> v3: - Add braces on if statements to match coding style Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-12-12qemu_fclose: return last_error if set (v3)Eduardo Habkost1-3/+48
This will make sure no error will be missed as long as callers always check for qemu_fclose() return value. For reference, this is the complete list of qemu_fclose() callers: - exec_close(): already fixed to check for negative values, not -1 - migrate_fd_cleanup(): already fixed to consider only negative values as error, not any non-zero value - exec_accept_incoming_migration(): no return value check (yet) - fd_accept_incoming_migration(): no return value check (yet) - tcp_accept_incoming_migration(): no return value check (yet) - unix_accept_incoming_migration(): no return value check (yet) - do_savevm(): no return value check (yet) - load_vmstate(): no return value check (yet) Changes v1 -> v2: - Add small comment about the need to return previously-spotted errors Changes v2 -> v3: - Add braces to "if" statements to match coding style Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-12-12savevm: use qemu_file_set_error() instead of setting last_error directlyEduardo Habkost1-2/+2
Some code uses qemu_file_set_error() already, so use it everywhere when setting last_error, for consistency. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-12-05Merge remote-tracking branch 'kwolf/for-anthony' into stagingAnthony Liguori1-1/+1
2011-12-05block: convert qemu_aio_flush() calls to bdrv_drain_all()Stefan Hajnoczi1-1/+1
Many places in QEMU call qemu_aio_flush() to complete all pending asynchronous I/O. Most of these places actually want to drain all block requests but there is no block layer API to do so. This patch introduces the bdrv_drain_all() API to wait for requests across all BlockDriverStates to complete. As a bonus we perform checks after qemu_aio_wait() to ensure that requests really have finished. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-12-02fix spelling in main directoryDong Xu Wang1-1/+1
Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-11-21ivshmem: use migration blockers to prevent live migration in peer mode (v2)Anthony Liguori1-25/+0
Now when you try to migrate with ivshmem, you get a proper QMP error: (qemu) migrate tcp:localhost:1025 Migration is disabled when using feature 'peer mode' in device 'ivshmem' (qemu) Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-11-01savevm: qemu_fille_buffer() used to return one error for reads of size 0.Juan Quintela1-0/+2
Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-21qemu-timer: move more stuff out of qemu-timer.cPaolo Bonzini1-0/+25
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2011-10-20Merge remote-tracking branch 'quintela/migration-pull' into stagingAnthony Liguori1-83/+139
2011-10-20migration: make *save_live return errorsJuan Quintela1-3/+11
Make *save_live() return negative values when there is one error, and updates all callers to check for the error. Signed-off-by: Juan Quintela <quintela@redhat.com>
2011-10-20migration: use qemu_file_get_error() return value when possibleJuan Quintela1-2/+2
Signed-off-by: Juan Quintela <quintela@redhat.com>
2011-10-20savevm: Rename has_error to last_error fieldJuan Quintela1-8/+8
Now the field contains the last error name, so rename acordingly. 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-6/+7
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-18/+21
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-4/+4
We normally already have an errno value. When not, abuse EIO. Signed-off-by: Juan Quintela <quintela@redhat.com>
2011-10-20Revert "savevm: fix corruption in vmstate_subsection_load()."Juan Quintela1-9/+1
This reverts commit eb60260de0b050a5e8ab725e84d377d0b44c43ae. Conflicts: savevm.c We changed qemu_peek_byte() prototype, just fixed the rejects. Signed-off-by: Juan Quintela<quintela@redhat.com> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-20savevm: improve subsections detection on loadJuan Quintela1-35/+75
We add qemu_peek_buffer, that is identical to qemu_get_buffer, just that it don't update f->buf_index. We add a paramenter to qemu_peek_byte() to be able to peek more than one byte. Once this is done, to see if we have a subsection we look: - 1st byte is QEMU_VM_SUBSECTION - 2nd byte is a length, and is bigger than section name - 3rd element is a string that starts with section_name So, we shouldn't have false positives (yes, content could still get us wrong but probabilities are really low). v2: - Alex Williamsom found that we could get negative values on index. - Rework code to fix that part. - Rewrite qemu_get_buffer() using qemu_peek_buffer() v3: - return "done" on error case v4: - fix qemu_file_skip() off by one. Signed-off-by: Juan Quintela <quintela@redhat.com>
2011-10-20savevm: define qemu_get_byte() using qemu_peek_byte()Juan Quintela1-9/+6
Signed-off-by: Juan Quintela<quintela@redhat.com>
2011-10-20savevm: some coding style cleanupsJuan Quintela1-7/+14
This patch will make moving code on next patches and having checkpatch happy easier. Signed-off-by: Juan Quintela<quintela@redhat.com> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-20savevm: teach qemu_fill_buffer to do partial refillsJuan Quintela1-3/+11
We will need on next patch to be able to lookahead on next patch v2: rename "used" to "pending" (Alex Williams) Signed-off-by: Juan Quintela<quintela@redhat.com> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-19savevm: qemu_savevm_state(): Drop stop VM logicLuiz Capitulino1-7/+0
qemu_savevm_state() has some logic to stop the VM and to (or not to) resume it. But this seems to be a big noop, as qemu_savevm_state() is only called by do_savevm() when the VM is already stopped. So, let's drop qemu_savevm_state()'s stop VM logic. Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-10-04RunState: Rename enum values as generated by the QAPILuiz Capitulino1-2/+2
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-2/+2
Use runstate_is_running() instead, which is introduced by this commit. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-09-15Replace the VMSTOP macros with a proper state typeLuiz Capitulino1-2/+2
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-09-06savevm: Include writable devices with removable mediaMarkus Armbruster1-2/+2
savevm and loadvm silently ignore block devices with removable media, such as floppies and SD cards. Rolling back a VM to a previous checkpoint will *not* roll back writes to block devices with removable media. Moreover, bdrv_is_removable() is a confused mess, and wrong in at least one case: it considers "-drive if=xen,media=cdrom -M xenpv" removable. It'll be cleaned up later in this series. Read-only block devices are also ignored, but that's okay. Fix by ignoring only read-only block devices and empty block devices. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-08-20Use glib memory allocation and free functionsAnthony Liguori1-29/+29
qemu_malloc/qemu_free no longer exist after this commit. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>