Add MigrationParams structure

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Add save_block_hdr function

Signed-off-by: Benoit Hudzia <benoit.hudzia@sap.com>
Signed-off-by: Petter Svard <petters@cs.umu.se>
Signed-off-by: Aidan Shribman <aidan.shribman@sap.com>
Signed-off-by: Orit Wasserman <owasserm@redhat.com>
Add debugging infrastructure

Signed-off-by: Orit Wasserman <owasserm@redhat.com>
Add migration_end function

Signed-off-by: Orit Wasserman <owasserm@redhat.com>
Add spent time for migration

We add time spent for migration to the output of "info migrate"
command.  'total_time' means time since the start fo migration if
migration is 'active', and total time of migration if migration is
completed.  As we are also interested in transferred ram when
migration completes, adding all ram statistics

Signed-off-by: Juan Quintela <quintela@redhat.com>
Add tracepoints for savevm section start/end

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>
No need to iterate if we already are over the limit

If buffers are full, don't iterate, just exit.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Only TCG needs TLB handling

Refactor the code that is only needed for tcg to an static function.
Call that only when tcg is enabled.  We can't refactor to a dummy
function in the kvm case, as qemu can be compiled at the same time
with tcg and kvm.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Only calculate expected_time for stage 2

ram_save_remaining() is an expensive operation when there is a lot of memory.
So we only call the function when we need it.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Exit loop if we have been there too long

Checking each 64 pages is a random magic number as good as any other.
We don't want to test too many times, but on the other hand,
qemu_get_clock_ns() is not so expensive either.  We want to be sure
that we spent less than 50ms (half of buffered_file timer), if we
spent more than 100ms, all the accounting got wrong.

Signed-off-by: Juan Quintela <quintela@redhat.com>
dirty bitmap: abstract its use

Always use accessors to read/set the dirty bitmap.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Maintain the number of dirty pages

Calculate the number of dirty pages takes a lot on hosts with lots
of memory.  Just maintain how many pages are dirty.

Signed-off-by: Juan Quintela <quintela@redhat.com>
kvm: Don't abort on kvm_irqchip_add_msi_route()

Anyone using these functions has to be prepared that irqchip
support may not be present.  It shouldn't be up to the core
code to determine whether this is a fatal error.  Currently
code written as:

virq = kvm_irqchip_add_msi_route(...)
if (virq < 0) {
    <slow path>
} else {
    <fast path>
}

works on x86 with and without kvm irqchip enabled, works
without kvm support compiled in, but aborts() on !x86 with
kvm support.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Acked-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
scsi: simplify handling of the VPD page length field

The last four bytes of the thin provisioning page were cut out.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
scsi: add a qdev property for the disk's WWN

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
atapi: implement READ DISC INFORMATION

This command is not necessary for CD-ROM and DVD-ROM, but some versions of
udev trip on its absence.

Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
scsi-disk: implement READ DISC INFORMATION

This command is not necessary for CD-ROM and DVD-ROM, but some versions of
udev trip on its absence.

Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
ISCSI: Add SCSI passthrough via scsi-generic to libiscsi

Update iscsi to allow passthrough of SG_IO scsi commands when the iscsi
device is forced to be scsi-generic.

Implement both bdrv_ioctl() and bdrv_aio_ioctl() in the iscsi backend,
emulate the SG_IO ioctl and pass the SCSI commands across to the
iscsi target.

This allows end-to-end passthrough of SCSI all the way from the guest,
to qemu, via scsi-generic, then libiscsi all the way to the iscsi target.

To activate this you need to specify that the iscsi lun should be treated
as a scsi-generic device.

Example:
    -device lsi -device scsi-generic,drive=MyISCSI \
    -drive file=iscsi://10.1.1.125/iqn.ronnie.test/1,if=none,id=MyISCSI

Note, you can currently not boot a qemu guest from a scsi device.

Note,
This only works when the host is linux, since the emulation relies on
definitions of SG_IO from the scsi-generic implementation in the
linux kernel.
It should be fairly easy to re-implement some structures similar enough
for non-linux hosts to do the same style of passthrough via a fake
scsi generic layer and libiscsi if need be.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
ISCSI: force use of sg for SMC and SSC devices

If the device we open is a SMC or SSC device, then force the use of sg. We
dont have any medium changer or tape emulation so only passthrough via
real sg or scsi-generic via iscsi would work anyway.

Forcing sg also makes qemu skip trying to read from the device to guess
the image format by reading from the device (find_image_format()).
SMC devices do not implement READ6/10/12/16 so it is not possible to
read from them (SSC have different CDBs).

With this patch I can successfully manage a SMC device wiht iscsi in
passthrough mode.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
[Added TYPE_TAPE handling - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
megasas: Add header file

This patch adds the header file for megasas.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>