]> git.proxmox.com Git - qemu.git/log
qemu.git
14 years agoqcow2: Fix some more qemu_malloc fallout
Kevin Wolf [Fri, 27 Nov 2009 16:35:55 +0000 (17:35 +0100)]
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>
14 years agoqcow2: Store exact backing format length
Kevin Wolf [Thu, 26 Nov 2009 13:03:42 +0000 (14:03 +0100)]
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>
14 years agovirtio-blk: Implement rerror option
Kevin Wolf [Fri, 27 Nov 2009 12:25:39 +0000 (13:25 +0100)]
virtio-blk: Implement rerror option

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoide: Implement rerror option
Kevin Wolf [Fri, 27 Nov 2009 12:25:38 +0000 (13:25 +0100)]
ide: Implement rerror option

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoIntroduce rerror option for drives
Kevin Wolf [Fri, 27 Nov 2009 12:25:37 +0000 (13:25 +0100)]
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>
14 years agoRename DriveInfo.onerror to on_write_error
Kevin Wolf [Fri, 27 Nov 2009 12:25:36 +0000 (13:25 +0100)]
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>
14 years agoram migration: Properly reset statistics
Jan Kiszka [Wed, 2 Dec 2009 10:29:38 +0000 (11:29 +0100)]
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>
14 years agoqemu-opts: Release id on deletion
Jan Kiszka [Tue, 1 Dec 2009 14:24:18 +0000 (15:24 +0100)]
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>
14 years agolive migration: Serialize vmstate saving in stage 2
Jan Kiszka [Tue, 1 Dec 2009 14:19:55 +0000 (15:19 +0100)]
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>
14 years agoblock migration: Skip zero-sized disks
Jan Kiszka [Mon, 30 Nov 2009 19:34:55 +0000 (20:34 +0100)]
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>
14 years agoblock migration: Increase dirty chunk size to 1M
Jan Kiszka [Mon, 30 Nov 2009 17:21:22 +0000 (18:21 +0100)]
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>
14 years agoblock migration: Add support for restore progress reporting
Jan Kiszka [Tue, 1 Dec 2009 14:20:17 +0000 (15:20 +0100)]
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>
14 years agoblock migration: Report progress also via info migration
Jan Kiszka [Mon, 30 Nov 2009 17:21:21 +0000 (18:21 +0100)]
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>
14 years agoblock migration: Fix outgoing progress output
Jan Kiszka [Mon, 30 Nov 2009 17:21:21 +0000 (18:21 +0100)]
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>
14 years agolive migration: Propagate output monitor to callback handler
Jan Kiszka [Mon, 30 Nov 2009 17:21:21 +0000 (18:21 +0100)]
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>
14 years agoblock migration: Report overall migration progress
Jan Kiszka [Mon, 30 Nov 2009 17:21:21 +0000 (18:21 +0100)]
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>
14 years agolive migration: Allow cleanup after cancellation or error
Jan Kiszka [Mon, 30 Nov 2009 17:21:21 +0000 (18:21 +0100)]
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>
14 years agoram migration: Stop loading on error
Jan Kiszka [Mon, 30 Nov 2009 17:21:21 +0000 (18:21 +0100)]
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>
14 years agoblock migration: Add error handling/propagation
Jan Kiszka [Mon, 30 Nov 2009 17:21:21 +0000 (18:21 +0100)]
block migration: Add error handling/propagation

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoblock migration: Consolidate block transmission
Jan Kiszka [Mon, 30 Nov 2009 17:21:21 +0000 (18:21 +0100)]
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>
14 years agoblock migration: Consolidate mig_read_device_bulk into mig_save_device_bulk
Jan Kiszka [Mon, 30 Nov 2009 17:21:20 +0000 (18:21 +0100)]
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>
14 years agoblock migration: Clean up use of total_sectors
Jan Kiszka [Mon, 30 Nov 2009 17:21:20 +0000 (18:21 +0100)]
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>
14 years agoblock migration: Initialize remaining BlkMigState fields
Jan Kiszka [Mon, 30 Nov 2009 17:21:20 +0000 (18:21 +0100)]
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>
14 years agoblock migration: Switch device and block lists to QSIMPLEQ
Jan Kiszka [Mon, 30 Nov 2009 17:21:20 +0000 (18:21 +0100)]
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>
14 years agoImport a simple queue implementation from NetBSD
Pierre Riteau [Mon, 30 Nov 2009 17:21:20 +0000 (18:21 +0100)]
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>
14 years agoblock migration: Drop dead code
Jan Kiszka [Mon, 30 Nov 2009 17:21:20 +0000 (18:21 +0100)]
block migration: Drop dead code

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoblock migration: Avoid indirection of block_mig_state
Jan Kiszka [Mon, 30 Nov 2009 17:21:20 +0000 (18:21 +0100)]
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>
14 years agoblock migration: Avoid large stack buffer
Jan Kiszka [Mon, 30 Nov 2009 17:21:20 +0000 (18:21 +0100)]
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>
14 years agoblock migration: Cleanup dirty tracking code
Jan Kiszka [Mon, 30 Nov 2009 17:21:20 +0000 (18:21 +0100)]
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>
14 years agoblock migration: Rework constants API
Jan Kiszka [Mon, 30 Nov 2009 17:21:19 +0000 (18:21 +0100)]
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>
14 years agoblock migration: Fix coding style and whitespaces
Jan Kiszka [Mon, 30 Nov 2009 17:21:19 +0000 (18:21 +0100)]
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>
14 years agomigration: Catch multiple start commands
Jan Kiszka [Mon, 30 Nov 2009 17:21:19 +0000 (18:21 +0100)]
migration: Catch multiple start commands

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agomigration: Fix use of file after release
Jan Kiszka [Mon, 30 Nov 2009 17:21:19 +0000 (18:21 +0100)]
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>
14 years agosavevm: Port to qdev.vmsd all devices that have qdev
Juan Quintela [Wed, 2 Dec 2009 11:36:46 +0000 (12:36 +0100)]
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>
14 years agoqdev: enable vmstate_unregister() support
Juan Quintela [Wed, 2 Dec 2009 11:36:45 +0000 (12:36 +0100)]
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>
14 years agopci: vmstate_register() already assign consecutive numbers starting at 0
Juan Quintela [Wed, 2 Dec 2009 11:36:44 +0000 (12:36 +0100)]
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>
14 years agovmstate: Add support for multiplying size for a constant
Juan Quintela [Wed, 2 Dec 2009 11:36:43 +0000 (12:36 +0100)]
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>
14 years agovmstate: remove usused VMSTATE_STRUCT_ARRAY_SIZE_UINT8
Juan Quintela [Wed, 2 Dec 2009 11:36:42 +0000 (12:36 +0100)]
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>
14 years agovmstate: Introduce UINT16_TEST support
Juan Quintela [Wed, 2 Dec 2009 11:36:41 +0000 (12:36 +0100)]
vmstate: Introduce UINT16_TEST support

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovmstate: Introduce VMSTATE_STRUCT_POINTER_TEST
Juan Quintela [Wed, 2 Dec 2009 11:36:40 +0000 (12:36 +0100)]
vmstate: Introduce VMSTATE_STRUCT_POINTER_TEST

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovmstate: Introduce VMSTATE_STRUCT_TEST
Juan Quintela [Wed, 2 Dec 2009 11:36:39 +0000 (12:36 +0100)]
vmstate: Introduce VMSTATE_STRUCT_TEST

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agovmstate: Add support for VBUFFERS
Juan Quintela [Wed, 2 Dec 2009 11:36:38 +0000 (12:36 +0100)]
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>
14 years agovmstate: fix missing ARRAY_OF_POINTERS support on save state
Juan Quintela [Wed, 2 Dec 2009 11:36:37 +0000 (12:36 +0100)]
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>
14 years agovmstate: Fix info field of VMSTATE_MACADDR
Jan Kiszka [Wed, 2 Dec 2009 11:36:36 +0000 (12:36 +0100)]
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>
14 years agovmstate: Avoid seeking
Jan Kiszka [Wed, 2 Dec 2009 11:36:35 +0000 (12:36 +0100)]
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>
14 years agolsi53c895a: Implement IRQ on reselection
Laszlo Ast [Thu, 19 Nov 2009 10:07:12 +0000 (11:07 +0100)]
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>
14 years agolsi53c895a: Use alternative address when already reselected
Laszlo Ast [Thu, 19 Nov 2009 10:07:12 +0000 (11:07 +0100)]
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>
14 years agolsi53c895a: Fix SDID in SELECT ID command
Laszlo Ast [Thu, 19 Nov 2009 10:07:12 +0000 (11:07 +0100)]
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>
14 years agolsi53c895a: Fix message code of DISCONNECT
Laszlo Ast [Thu, 19 Nov 2009 10:07:12 +0000 (11:07 +0100)]
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>
14 years agolsi53c895a: Add support for LSI53C700 Family Compatibility bit
Laszlo Ast [Thu, 19 Nov 2009 10:07:12 +0000 (11:07 +0100)]
lsi53c895a: Add support for LSI53C700 Family Compatibility bit

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>
14 years agolsi53c895a: Whitespace and typo fixes
Laszlo Ast [Thu, 19 Nov 2009 10:07:12 +0000 (11:07 +0100)]
lsi53c895a: Whitespace and typo fixes

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>
14 years agoscsi: add read/write 16 commands.
Gerd Hoffmann [Thu, 26 Nov 2009 14:34:16 +0000 (15:34 +0100)]
scsi: add read/write 16 commands.

Add READ_16 + friends to scsi-defs.h, scsi_command_name() and the
request parsing helper functions.

Use them in scsi-disk.c too.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoscsi-disk: restruct emulation: VERIFY
Gerd Hoffmann [Thu, 26 Nov 2009 14:34:15 +0000 (15:34 +0100)]
scsi-disk: restruct emulation: VERIFY

Move VERIFY emulation from scsi_send_command() to
scsi_disk_emulate_command().

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoscsi-disk: restruct emulation: REPORT_LUNS
Gerd Hoffmann [Thu, 26 Nov 2009 14:34:14 +0000 (15:34 +0100)]
scsi-disk: restruct emulation: REPORT_LUNS

Move REPORT_LUNS emulation from scsi_send_command() to
scsi_disk_emulate_command().

Also add REPORT_LUNS to scsi-defs.h and scsi_command_name().

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoscsi-disk: restruct emulation: SERVICE_ACTION_IN
Gerd Hoffmann [Thu, 26 Nov 2009 14:34:13 +0000 (15:34 +0100)]
scsi-disk: restruct emulation: SERVICE_ACTION_IN

Move SERVICE_ACTION_IN emulation from scsi_send_command() to
scsi_disk_emulate_command().

Also add SERVICE_ACTION_IN to scsi-defs.h and scsi_command_name().

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoscsi-disk: restruct emulation: GET_CONFIGURATION
Gerd Hoffmann [Thu, 26 Nov 2009 14:34:12 +0000 (15:34 +0100)]
scsi-disk: restruct emulation: GET_CONFIGURATION

Move GET_CONFIGURATION emulation from scsi_send_command() to
scsi_disk_emulate_command().

Also add GET_CONFIGURATION to scsi-defs.h and scsi_command_name().

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoscsi-disk: restruct emulation: READ_TOC
Gerd Hoffmann [Thu, 26 Nov 2009 14:34:11 +0000 (15:34 +0100)]
scsi-disk: restruct emulation: READ_TOC

Move READ_TOC emulation from scsi_send_command() to
scsi_disk_emulate_command().  Add scsi_disk_emulate_read_toc() function
which holds the longisch READ_TOC emulation code.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoscsi-disk: restruct emulation: SYNCHRONIZE_CACHE
Gerd Hoffmann [Thu, 26 Nov 2009 14:34:10 +0000 (15:34 +0100)]
scsi-disk: restruct emulation: SYNCHRONIZE_CACHE

Move SYNCHRONIZE_CACHE emulation from scsi_send_command() to
scsi_disk_emulate_command().

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoscsi-disk: restruct emulation: READ_CAPACITY
Gerd Hoffmann [Thu, 26 Nov 2009 14:34:09 +0000 (15:34 +0100)]
scsi-disk: restruct emulation: READ_CAPACITY

Move READ_CAPACITY emulation from scsi_send_command() to
scsi_disk_emulate_command().

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoscsi-disk: restruct emulation: ALLOW_MEDIUM_REMOVAL
Gerd Hoffmann [Thu, 26 Nov 2009 14:34:08 +0000 (15:34 +0100)]
scsi-disk: restruct emulation: ALLOW_MEDIUM_REMOVAL

Move ALLOW_MEDIUM_REMOVAL emulation from scsi_send_command() to
scsi_disk_emulate_command().

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoscsi-disk: restruct emulation: START_STOP
Gerd Hoffmann [Thu, 26 Nov 2009 14:34:07 +0000 (15:34 +0100)]
scsi-disk: restruct emulation: START_STOP

Move START_STOP emulation from scsi_send_command() to
scsi_disk_emulate_command().

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoscsi-disk: restruct emulation: MODE_SENSE
Gerd Hoffmann [Thu, 26 Nov 2009 14:34:06 +0000 (15:34 +0100)]
scsi-disk: restruct emulation: MODE_SENSE

Move MODE_SENSE emulation from scsi_send_command() to
scsi_disk_emulate_command().  Create two helper functions:
mode_sense_page() which writes the actual mode pages and
scsi_disk_emulate_mode_sense() which holds the longish MODE_SENSE
emulation code, calling into mode_sense_page() as needed.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoscsi-disk: restruct emulation: RESERVE+RELEASE
Gerd Hoffmann [Thu, 26 Nov 2009 14:34:05 +0000 (15:34 +0100)]
scsi-disk: restruct emulation: RESERVE+RELEASE

Move RESERVE+RELEASE emulation from scsi_send_command() to
scsi_disk_emulate_command().

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoscsi-disk: restruct emulation: INQUIRY
Gerd Hoffmann [Thu, 26 Nov 2009 14:34:04 +0000 (15:34 +0100)]
scsi-disk: restruct emulation: INQUIRY

Move INQUIRY emulation from scsi_send_command() to
scsi_disk_emulate_command().  Also split the longish INQUITY emulation
code into the new scsi_disk_emulate_inquiry() function.  Serial number
handling is slightly changed, we don't copy it any more but look it up
directly in DriveInfo which we have at hand anyway.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoscsi-disk: restruct emulation: REQUEST_SENSE
Gerd Hoffmann [Thu, 26 Nov 2009 14:34:03 +0000 (15:34 +0100)]
scsi-disk: restruct emulation: REQUEST_SENSE

Move REQUEST_SENSE emulation from scsi_send_command() to
scsi_disk_emulate_command().

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoscsi-disk: restruct emulation: core + TEST_UNIT_READY.
Gerd Hoffmann [Thu, 26 Nov 2009 14:34:02 +0000 (15:34 +0100)]
scsi-disk: restruct emulation: core + TEST_UNIT_READY.

Add new scsi_disk_emulate_command() function, which will -- when
finished -- handle all scsi disk command emulation except actual I/O
(READ+WRITE commands) which goes to the block layer.  The function
builds on top of the new SCSIRequest struct.

SCSI command emulation code is moved over from scsi_send_command() in
steps to ease review and make it easier to pin down regressions (if any)
using bisect.  This patch moves over TEST_UNIT_READY only.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoscsi: add scsi_req_print()
Gerd Hoffmann [Thu, 26 Nov 2009 14:34:01 +0000 (15:34 +0100)]
scsi: add scsi_req_print()

Handy for debugging.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoscsi: move status to SCSIRequest.
Gerd Hoffmann [Thu, 26 Nov 2009 14:34:00 +0000 (15:34 +0100)]
scsi: move status to SCSIRequest.

Also add and use the scsi_req_complete() helper function for calling the
completion callback.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoscsi: move dinfo to SCSIDevice
Gerd Hoffmann [Thu, 26 Nov 2009 14:33:59 +0000 (15:33 +0100)]
scsi: move dinfo to SCSIDevice

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoscsi: move sense to SCSIDevice, create SCSISense struct.
Gerd Hoffmann [Thu, 26 Nov 2009 14:33:58 +0000 (15:33 +0100)]
scsi: move sense to SCSIDevice, create SCSISense struct.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoscsi: add xfer mode
Gerd Hoffmann [Thu, 26 Nov 2009 14:33:57 +0000 (15:33 +0100)]
scsi: add xfer mode

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoscsi: use command defines in scsi-disk.c
Gerd Hoffmann [Thu, 26 Nov 2009 14:33:56 +0000 (15:33 +0100)]
scsi: use command defines in scsi-disk.c

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoscsi: add request parsing helpers to common code.
Gerd Hoffmann [Thu, 26 Nov 2009 14:33:55 +0000 (15:33 +0100)]
scsi: add request parsing helpers to common code.

Add helper functions for scsi request parsing to common code.  Getting
command length, transfer size, and linear block address is handled.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoscsi: move type from SCSIGenericState to SCSIDevice
Gerd Hoffmann [Thu, 26 Nov 2009 14:33:54 +0000 (15:33 +0100)]
scsi: move type from SCSIGenericState to SCSIDevice

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoscsi: add scsi-defs.h
Gerd Hoffmann [Thu, 26 Nov 2009 14:33:53 +0000 (15:33 +0100)]
scsi: add scsi-defs.h

Largely based on <scsi/scsi.h> from linux.  Added into the tree so we
can use the defines everywhere, not just in scsi-generic.c (which is
linux-specific).

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoscsi: move blocksize from SCSIGenericState to SCSIDevice
Gerd Hoffmann [Thu, 26 Nov 2009 14:33:52 +0000 (15:33 +0100)]
scsi: move blocksize from SCSIGenericState to SCSIDevice

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoscsi: move scsi command buffer from SCSIGenericReq to SCSIRequest.
Gerd Hoffmann [Thu, 26 Nov 2009 14:33:51 +0000 (15:33 +0100)]
scsi: move scsi command buffer from SCSIGenericReq to SCSIRequest.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoscsi: move SCSIRequest management to common code.
Gerd Hoffmann [Thu, 26 Nov 2009 14:33:50 +0000 (15:33 +0100)]
scsi: move SCSIRequest management to common code.

Create generic functions to allocate, find and release SCSIRequest
structs.  Make scsi-disk and scsi-generic use them.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoscsi: move request lists to QTAILQ.
Gerd Hoffmann [Thu, 26 Nov 2009 14:33:49 +0000 (15:33 +0100)]
scsi: move request lists to QTAILQ.

Changes:
 * Move from open-coded lists to QTAILQ macros.
 * Move the struct elements to the common data structures
   (SCSIDevice + SCSIRequest).
 * Drop free request pools.
 * Fix request cleanup in the destroy callback.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoscsi: create common SCSIRequest structure.
Gerd Hoffmann [Thu, 26 Nov 2009 14:33:48 +0000 (15:33 +0100)]
scsi: create common SCSIRequest structure.

Rename the SCSIRequest structs in scsi-disk.c and scsi-generic.c to
SCSIDiskReq and SCSIGenericReq.  Create a SCSIRequest struct and move
the common elements over.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoscsi: add/fix header protection.
Gerd Hoffmann [Thu, 26 Nov 2009 14:33:47 +0000 (15:33 +0100)]
scsi: add/fix header protection.

Also delete the leftover and unused scsi-disk.h file.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agonet: fix vnet_hdr handling in solaris tap code
Mark McLoughlin [Wed, 25 Nov 2009 18:49:37 +0000 (18:49 +0000)]
net: fix vnet_hdr handling in solaris tap code

Print an error if the user specifies vnet_hdr=1 on the cmdline.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agonet: initialize vnet_hdr in net_init_tap()
Mark McLoughlin [Wed, 25 Nov 2009 18:49:36 +0000 (18:49 +0000)]
net: initialize vnet_hdr in net_init_tap()

net_tap_init() always sets vnet_hdr using qemu_opt_get_bool(), but
initialize it in net_init_tap() just to reduce confusion.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agonet: check for TUNSETOFFLOAD support before trying to enable offload features
Pierre Riteau [Wed, 25 Nov 2009 18:49:35 +0000 (18:49 +0000)]
net: check for TUNSETOFFLOAD support before trying to enable offload features

This avoids the "TUNSETOFFLOAD ioctl() failed: Invalid argument" message
on kernels without TUNSETOFFLOAD support.

Signed-off-by: Pierre Riteau <Pierre.Riteau@irisa.fr>
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agonet: fix TAP networking on host kernels without IFF_VNET_HDR support
Pierre Riteau [Wed, 25 Nov 2009 18:49:34 +0000 (18:49 +0000)]
net: fix TAP networking on host kernels without IFF_VNET_HDR support

vnet_hdr is initialized at 1 by default. We need to reset it to 0 if
the kernel doesn't support IFF_VNET_HDR.

Signed-off-by: Pierre Riteau <Pierre.Riteau@irisa.fr>
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agonet: print correct error for '-netdev ""'
Mark McLoughlin [Wed, 25 Nov 2009 18:49:33 +0000 (18:49 +0000)]
net: print correct error for '-netdev ""'

Reported-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agonet: fix qemu_announce_self()
Mark McLoughlin [Wed, 25 Nov 2009 18:49:32 +0000 (18:49 +0000)]
net: fix qemu_announce_self()

Now that we have a way to iterate NICs.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agonet: add qemu_foreach_nic()
Mark McLoughlin [Wed, 25 Nov 2009 18:49:31 +0000 (18:49 +0000)]
net: add qemu_foreach_nic()

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agonet: remove VLANClientState members now in NetClientInfo
Mark McLoughlin [Wed, 25 Nov 2009 18:49:30 +0000 (18:49 +0000)]
net: remove VLANClientState members now in NetClientInfo

Add a NetClientInfo pointer to VLANClientState and use that
for the typecode and function pointers.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agonet: remove qemu_new_vlan_client()
Mark McLoughlin [Wed, 25 Nov 2009 18:49:29 +0000 (18:49 +0000)]
net: remove qemu_new_vlan_client()

... and VLANClientState::opaque and qemu_find_vlan_client().

All of these are now unused

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agonet: convert xen to NICState
Mark McLoughlin [Wed, 25 Nov 2009 18:49:28 +0000 (18:49 +0000)]
net: convert xen to NICState

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agonet: move parse_macaddr() to net/util.[ch]
Mark McLoughlin [Wed, 25 Nov 2009 18:49:27 +0000 (18:49 +0000)]
net: move parse_macaddr() to net/util.[ch]

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agonet: convert xilinx_ethlite to NICState
Mark McLoughlin [Wed, 25 Nov 2009 18:49:26 +0000 (18:49 +0000)]
net: convert xilinx_ethlite to NICState

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agonet: convert usb-net to NICState
Mark McLoughlin [Wed, 25 Nov 2009 18:49:25 +0000 (18:49 +0000)]
net: convert usb-net to NICState

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agonet: convert stellaris to NICState
Mark McLoughlin [Wed, 25 Nov 2009 18:49:24 +0000 (18:49 +0000)]
net: convert stellaris to NICState

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agonet: convert smc91c111 to NICState
Mark McLoughlin [Wed, 25 Nov 2009 18:49:23 +0000 (18:49 +0000)]
net: convert smc91c111 to NICState

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agonet: convert musicpal to NICState
Mark McLoughlin [Wed, 25 Nov 2009 18:49:22 +0000 (18:49 +0000)]
net: convert musicpal to NICState

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agonet: convert mipsnet to NICState
Mark McLoughlin [Wed, 25 Nov 2009 18:49:21 +0000 (18:49 +0000)]
net: convert mipsnet to NICState

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agonet: convert mcf_fec to NICState
Mark McLoughlin [Wed, 25 Nov 2009 18:49:20 +0000 (18:49 +0000)]
net: convert mcf_fec to NICState

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agonet: convert LAN9118 to NICState
Mark McLoughlin [Wed, 25 Nov 2009 18:49:19 +0000 (18:49 +0000)]
net: convert LAN9118 to NICState

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>