sdk/emulator/qemu.git
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>
14 years agonet: convert etrax to NICState
Mark McLoughlin [Wed, 25 Nov 2009 18:49:18 +0000 (18:49 +0000)]
net: convert etrax to NICState

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

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

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

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

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

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

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

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

Common state for all NICs.

The opaque member will replace the opaque member in VLANClientState
since only NICs need it.

The conf member will allow us to iterate over NICs, access the MAC
addr for the NIC and send a packet from each NIC in qemu_announce_self().

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

aliguori: fix uninitialized use of pcap_len

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

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

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

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

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

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
14 years agoqdev: move DO_UPCAST() into osdep.h
Mark McLoughlin [Wed, 25 Nov 2009 18:49:03 +0000 (18:49 +0000)]
qdev: move DO_UPCAST() into osdep.h

Nothing qdev specific about this, make it available throughtout.

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

A replacement for qemu_new_vlan_client(), using NetClientInfo to
replace most arguments.

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

This structure holds data which is common to all instances of a given
net client type/model.

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

Was used by hot-unplug, but not anymore.

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

Since 1cc33683, this field is not set for most devices, so just
remove it and its remaining few uses.

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