Commit Graph

9891 Commits (12c09b8ce22d74f78ff50f95676cbe4f501752ae)

Author SHA1 Message Date
Kevin Wolf 12c09b8ce2 qemu-img: There is more than one host device driver
I haven't heard yet of anyone using qemu-img to copy an image to a real floppy,
but it's a valid use case.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 11:45:50 -06:00
Kevin Wolf 702ef63f3e qcow2: Fix some more qemu_malloc fallout
Oh joy...

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 11:45:50 -06:00
Kevin Wolf e1c7f0e3f9 qcow2: Store exact backing format length
Currently qcow2 unnecessarily rounds up the length of the backing format string
to the next multiple of 8. At the same time, the array in BlockDriverState can
only hold 15 characters, so in effect backing formats with 9 characters or more
don't work (e.g. host_device).

Save the real string length and things start to work for all valid image format
names.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 11:45:49 -06:00
Kevin Wolf f35d68f0e7 virtio-blk: Implement rerror option
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 11:45:49 -06:00
Kevin Wolf ce4b6522f7 ide: Implement rerror option
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 11:45:49 -06:00
Kevin Wolf e9b2e81889 Introduce rerror option for drives
rerror controls the action to be taken when an error occurs while accessing the
guest image file. It corresponds to werror which already controls the action
take for write errors.

This purely introduces parsing rerror command line option into the right
structures, real support for it in the device emulation is added in the
following patches.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 11:45:49 -06:00
Kevin Wolf f785009961 Rename DriveInfo.onerror to on_write_error
Either rename variables and functions to refer to write errors (which is what
they actually do) or introduce a parameter to distinguish reads and writes.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 11:45:49 -06:00
Jan Kiszka 843079386e ram migration: Properly reset statistics
As we may do more than one migration (cancellation, live backup), reset
bytes_transferred on stage 1.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 11:45:49 -06:00
Jan Kiszka b09417b9bc qemu-opts: Release id on deletion
The opts id is always allocated via qemu_strdup, so it need not be
const, but it has to be released on opts deletion.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 11:45:49 -06:00
Jan Kiszka 90697be889 live migration: Serialize vmstate saving in stage 2
The effect of this patch with current block migration is that its stage
2, ie. the first full walk-through of the block devices will be
performed completely before RAM migration starts. This ensures that
continuously changing RAM pages are not re-synchronized all the time
while block migration is not completed.

Future versions of block migration which will respect the specified
downtime will generate a different pattern: After RAM migration has
started as well, block migration may also continue to inject dirty
blocks into the RAM stream once it detects that the number of pending
blocks would extend the downtime unacceptably.

Note that all this relies on the current registration order: block
before RAM migration.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 11:45:49 -06:00
Jan Kiszka 792773b225 block migration: Skip zero-sized disks
No need to migrate emptiness (risking divide by zero later on).

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 11:45:39 -06:00
Jan Kiszka 23bd90d2f9 block migration: Increase dirty chunk size to 1M
4K is too small for efficiently saving and restoring multi-GB block
devices.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 10:48:54 -06:00
Jan Kiszka 01e61e2d16 block migration: Add support for restore progress reporting
Inject progress report in percentage into the block live stream. This
can be read out and displayed easily on restore.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 10:48:54 -06:00
Jan Kiszka 25f236433f block migration: Report progress also via info migration
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 10:48:53 -06:00
Jan Kiszka 7184049ee6 block migration: Fix outgoing progress output
Report progress of an outgoing live migration to the monitor instead of
stdout.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 10:48:53 -06:00
Jan Kiszka f327aa0c60 live migration: Propagate output monitor to callback handler
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-12-03 10:48:53 -06:00
Jan Kiszka 82801d8f4f block migration: Report overall migration progress
So far progress reporting only works for the first block device. Fix
this by keeping an overall sum of sectors to be migratated, calculating
the sum of all processed sectors, and finally basing the progress
display on those values.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 10:48:53 -06:00
Jan Kiszka 4ec7fcc7da live migration: Allow cleanup after cancellation or error
Introduce qemu_savevm_state_cancel and inject a stage -1 to cancel a
live migration. This gives the involved subsystems a chance to clean up
dynamically allocated resources. Namely, the block migration layer can
now free its device descriptors and pending blocks.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 10:48:53 -06:00
Jan Kiszka 9a743e5ba3 ram migration: Stop loading on error
Besides catching real errors, this also allows to interrrupt the qemu
process during restore.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 10:48:53 -06:00
Jan Kiszka 4b640365c7 block migration: Add error handling/propagation
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 10:48:53 -06:00
Jan Kiszka 13f0b67fd3 block migration: Consolidate block transmission
Based on the original patch by Pierre Riteau: Use a common blk_send
function to transmit a block.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 10:48:53 -06:00
Jan Kiszka 57cce12d54 block migration: Consolidate mig_read_device_bulk into mig_save_device_bulk
Both functions share a lot of code, so make them one.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 10:48:53 -06:00
Jan Kiszka b1d10856d6 block migration: Clean up use of total_sectors
We already save total_sectors in BlkMigDevState, let's use this value
during the migration and avoid to recalculate it needlessly.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 10:48:53 -06:00
Jan Kiszka 69d63a97a1 block migration: Initialize remaining BlkMigState fields
In case we restart a migration, submitted, read_done, transferred, and
print_completion need to be reinitialized to 0.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 10:48:52 -06:00
Jan Kiszka 5e5328be14 block migration: Switch device and block lists to QSIMPLEQ
Based on the original patch by Pierre Riteau.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 10:48:52 -06:00
Pierre Riteau c616bbe1fd Import a simple queue implementation from NetBSD
Signed-off-by: Pierre Riteau <Pierre.Riteau@irisa.fr>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 10:48:52 -06:00
Jan Kiszka 3c095c3f80 block migration: Drop dead code
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 10:48:52 -06:00
Jan Kiszka d11ecd3dd5 block migration: Avoid indirection of block_mig_state
No need to push block_mig_state to the heap and, thus, establish an
indirection.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 10:48:52 -06:00
Jan Kiszka 575a58d763 block migration: Avoid large stack buffer
Move a potentially large buffer from stack to heap.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 10:48:52 -06:00
Jan Kiszka c6d2283068 block migration: Cleanup dirty tracking code
This switches the dirty bitmap to a true bitmap, reducing its footprint
(specifically in caches). It moreover fixes off-by-one bugs in
set_dirty_bitmap (nb_sectors+1 were marked) and bdrv_get_dirty (limit
check allowed one sector behind end of drive). And is drops redundant
dirty_tracking field from BlockDriverState.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 10:48:52 -06:00
Jan Kiszka 6ea44308b0 block migration: Rework constants API
Instead of duplicating the definition of constants or introducing
trivial retrieval functions move the SECTOR constants into the public
block API. This also obsoletes sector_per_block in BlkMigState.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 10:48:52 -06:00
Jan Kiszka a55eb92c22 block migration: Fix coding style and whitespaces
No functional changes.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 10:48:52 -06:00
Jan Kiszka 1302425d73 migration: Catch multiple start commands
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 10:48:51 -06:00
Jan Kiszka 5d39c799c3 migration: Fix use of file after release
qemu_fclose frees the passed file structure, but do_migrate_set_speed
may access it later on. Fix it by setting file NULL in
migrate_fd_cleanup and checking for this.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 10:48:51 -06:00
Juan Quintela be73cfe2be savevm: Port to qdev.vmsd all devices that have qdev
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 10:05:58 -06:00
Juan Quintela 70cca6d872 qdev: enable vmstate_unregister() support
Now vmstate_unregister have the right type

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 10:04:55 -06:00
Juan Quintela 5084bca17f pci: vmstate_register() already assign consecutive numbers starting at 0
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 10:04:55 -06:00
Juan Quintela 33599e2a61 vmstate: Add support for multiplying size for a constant
When the size that we want to transmit is in another field, but in an
unit different that bytes

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 10:04:54 -06:00
Juan Quintela bfb811ade5 vmstate: remove usused VMSTATE_STRUCT_ARRAY_SIZE_UINT8
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 10:04:54 -06:00
Juan Quintela 2fee40782c vmstate: Introduce UINT16_TEST support
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 10:04:54 -06:00
Juan Quintela 543fc7b27a vmstate: Introduce VMSTATE_STRUCT_POINTER_TEST
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 10:04:54 -06:00
Juan Quintela 11fe0e6e0e vmstate: Introduce VMSTATE_STRUCT_TEST
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 10:04:54 -06:00
Juan Quintela e61a1e0a11 vmstate: Add support for VBUFFERS
Support for buffer that are pointed by a pointer (i.e. not embedded)
where the size that we want to use is a field in the state.
We also need a new place to store where to start in the middle of the
buffer, as now it is a pointer, not the offset of the 1st field.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 10:04:54 -06:00
Juan Quintela 8595387e3e vmstate: fix missing ARRAY_OF_POINTERS support on save state
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 10:04:53 -06:00
Jan Kiszka d9494b19e3 vmstate: Fix info field of VMSTATE_MACADDR
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 10:04:53 -06:00
Jan Kiszka 21174c34b6 vmstate: Avoid seeking
Seeking on vmstate save/load does not work if the underlying file is a
stream. We could try to make all QEMUFile* forward-seek-aware, but first
attempts in this direction indicated that it's saner to convert the few
qemu_fseek-on-vmstates users to plain reads/writes.

This fixes various subtle vmstate corruptions where unused fields were
involved.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 10:04:53 -06:00
Laszlo Ast e560125e26 lsi53c895a: Implement IRQ on reselection
The critical part of this change is how to deal with simultaneaous
generation of interrupts. The only (normal) case when this happens in
the emulation is near simultaneous reselection + selection. If selection
comes first, there is no problem, since the target attempting
reselection loses the arbitration (in the emulation it only means that
the reselect function will not be started). In the worst case the host
adapter is reselected, but the device driver already started a
selection, so we jump to the alternative address to handle the
situation.

The SCRIPTS code can trigger another interrupt to notify the driver that
the new task has to be postponed. I suppose that on real hardware there
is enough time after the reselection interrupt to set the SIP bit before
the next interrupt comes, so it would result in 2 stacked interrupts (a
SCSI and a DMA one). However, in the emulation there is no interrupt
stacking, so there is a good chance that the 2 interrupts will get to
the interrupt handler at the same time.

Nevertheless, it should not make a big difference in interrupt handling,
since in both cases both interrupts have to be fetched first, and after
that the new task (that failed during the selection phase) has to be
prepared/reset for a later restart, and the reconnected device has to be
serviced.

The changes do not modify the host adapter's behavior if this interrupt
is not enabled.

See also LSI53C895A technical manual, SCID and SIEN0.

Signed-off-by: Laszlo Ast <laszlo.ast@siemens-enterprise.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 09:41:41 -06:00
Laszlo Ast 38f5b2b88c lsi53c895a: Use alternative address when already reselected
See SCRIPTS, 3.2.17 SELECT.

Signed-off-by: Laszlo Ast <laszlo.ast@siemens-enterprise.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 09:41:41 -06:00
Laszlo Ast 07a1bea883 lsi53c895a: Fix SDID in SELECT ID command
See SCRIPTS Programming Guide, 3.2.17 SELECT.

Signed-off-by: Laszlo Ast <laszlo.ast@siemens-enterprise.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 09:41:40 -06:00
Laszlo Ast 77203ea00b lsi53c895a: Fix message code of DISCONNECT
See SCSI-2, 6.5 Message system description/message codes.

Signed-off-by: Laszlo Ast <laszlo.ast@siemens-enterprise.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 09:41:40 -06:00