qemu-e2k/hw
Liran Alon b3e89c941a vhost-scsi: Allow user to enable migration
In order to perform a valid migration of a vhost-scsi device,
the following requirements must be met:
(1) The virtio-scsi device state needs to be saved & loaded.
(2) The vhost backend must be stopped before virtio-scsi device state
is saved:
  (2.1) Sync vhost backend state to virtio-scsi device state.
  (2.2) No further I/O requests are made by vhost backend to target
        SCSI device.
  (2.3) No further guest memory access takes place after VM is stopped.
(3) Requests in-flight to target SCSI device are completed before
    migration handover.
(4) Target SCSI device state needs to be saved & loaded into the
    destination host target SCSI device.

Previous commit ("vhost-scsi: Add VMState descriptor")
add support to save & load the device state using VMState.
This meets requirement (1).

When VM is stopped by migration thread (On Pre-Copy complete), the
following code path is executed:
migration_completion() -> vm_stop_force_state() -> vm_stop() ->
do_vm_stop().

do_vm_stop() calls first pause_all_vcpus() which pause all guest
vCPUs and then call vm_state_notify().
In case of vhost-scsi device, this will lead to the following code path
to be executed:
vm_state_notify() -> virtio_vmstate_change() ->
virtio_set_status() -> vhost_scsi_set_status() -> vhost_scsi_stop().
vhost_scsi_stop() then calls vhost_scsi_clear_endpoint() and
vhost_scsi_common_stop().

vhost_scsi_clear_endpoint() sends VHOST_SCSI_CLEAR_ENDPOINT ioctl to
vhost backend which will reach kernel's vhost_scsi_clear_endpoint()
which process all pending I/O requests and wait for them to complete
(vhost_scsi_flush()). This meets requirement (3).

vhost_scsi_common_stop() will stop the vhost backend.
As part of this stop, dirty-bitmap is synced and vhost backend state is
synced with virtio-scsi device state. As at this point guest vCPUs are
already paused, this meets requirement (2).

At this point we are left with requirement (4) which is target SCSI
device specific and therefore cannot be done by QEMU. Which is the main
reason why vhost-scsi adds a migration blocker.
However, as this can be handled either by an external orchestrator or
by using shared-storage (i.e. iSCSI), there is no reason to limit the
orchestrator from being able to explictly specify it wish to enable
migration even when VM have a vhost-scsi device.

Considering all the above, this commit allows orchestrator to explictly
specify that it is responsbile for taking care of requirement (4) and
therefore vhost-scsi should not add a migration blocker.

Reviewed-by: Nir Weiner <nir.weiner@oracle.com>
Reviewed-by: Bijan Mottahedeh <bijan.mottahedeh@oracle.com>
Signed-off-by: Liran Alon <liran.alon@oracle.com>
Message-Id: <20190416125912.44001-4-liran.alon@oracle.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
2019-06-02 21:32:06 -04:00
..
9pfs trace-events: Fix attribution of trace points to source 2019-03-22 16:18:07 +00:00
acpi acpi: pci: use build_append_foo() API to construct MCFG 2019-05-29 18:00:57 -04:00
adc kconfig: introduce kconfig files 2019-03-07 21:45:53 +01:00
alpha * Kconfig improvements (msi_nonbroken, imply for default PCI devices) 2019-03-28 09:18:53 +00:00
arm hw/acpi: Consolidate build_mcfg to pci.c 2019-05-29 18:00:57 -04:00
audio Revert "audio: fix pc speaker init" 2019-04-01 08:53:40 +02:00
block vhost-user-blk: Add support to reconnect backend 2019-05-20 18:40:02 -04:00
bt kconfig: introduce kconfig files 2019-03-07 21:45:53 +01:00
char Mostly bugfixes and cleanups, the most important being 2019-05-17 16:17:34 +01:00
core hw: report invalid disable-legacy|modern usage for virtio-1-only devs 2019-05-20 18:40:02 -04:00
cpu kconfig: introduce kconfig files 2019-03-07 21:45:53 +01:00
cris cris-softmmu.mak: express dependencies with Kconfig 2019-03-07 21:46:19 +01:00
display hw/display/ramfb: initialize fw-config space with xres/ yres 2019-05-24 09:10:29 +02:00
dma hw/dma: Compile the bcm2835_dma device as common object 2019-04-29 17:36:03 +01:00
gpio Pull request 2019-03-25 17:01:10 +00:00
hppa * Kconfig improvements (msi_nonbroken, imply for default PCI devices) 2019-03-28 09:18:53 +00:00
hyperv hyperv: express dependencies with kconfig 2019-03-07 21:45:53 +01:00
i2c hw/arm: Express dependencies of realview, versatile and vexpress with Kconfig 2019-05-13 09:36:31 +02:00
i386 hw/acpi: Consolidate build_mcfg to pci.c 2019-05-29 18:00:57 -04:00
ide Kconfig settings for the Arm machines 2019-05-13 16:52:56 +01:00
input hw/input: Add a CONFIG_PS2 switch for the ps2.c file 2019-05-15 11:56:53 +02:00
intc hw/intc/nvic: Use object_initialize_child for correct reference counting 2019-05-24 15:29:02 -03:00
ipack build: convert pci.mak to Kconfig 2019-03-07 21:45:53 +01:00
ipmi ipmi: express dependencies with kconfig 2019-03-07 21:45:53 +01:00
isa hw/i386/acpi: Add object_resolve_type_unambiguous to improve modularity 2019-05-17 15:19:24 +02:00
lm32 pflash: Clean up after commit 368a354f02, part 2 2019-03-11 22:53:44 +01:00
m68k m68k-softmmu.mak: express dependencies with Kconfig 2019-03-07 21:46:19 +01:00
mem trace-events: Shorten file names in comments 2019-03-22 16:18:07 +00:00
microblaze hw/microblaze/zynqmp: Use object_initialize_child for correct ref. counting 2019-05-24 15:29:02 -03:00
mips Various testing updates 2019-05-28 17:38:32 +01:00
misc hw/misc/macio: Use object_initialize_child for correct ref. counting 2019-05-24 15:29:02 -03:00
moxie moxie-softmmu.mak: express dependencies with Kconfig 2019-03-07 21:46:19 +01:00
net Mostly bugfixes and cleanups, the most important being 2019-05-17 16:17:34 +01:00
nios2 Add generic Nios II board. 2019-04-29 16:09:51 +01:00
nvram hw/nvram/fw_cfg: Store 'reboot-timeout' as little endian 2019-05-23 14:10:31 +02:00
openrisc target/openrisc: Fix LGPL information in the file headers 2019-05-08 17:45:54 +02:00
pci pci: Fold pci_get_bus_devfn() into its sole caller 2019-05-29 18:00:57 -04:00
pci-bridge pci: Make is_bridge a bool 2019-05-29 18:00:57 -04:00
pci-host hw/pci-host: Use object_initialize_child for correct reference counting 2019-05-02 16:56:33 +02:00
pcmcia kconfig: introduce kconfig files 2019-03-07 21:45:53 +01:00
ppc pcie: Simplify pci_adjust_config_limit() 2019-05-29 18:00:57 -04:00
rdma Clean up header guards that don't match their file name 2019-05-13 08:58:55 +02:00
riscv riscv: spike: Add a generic spike machine 2019-05-24 12:09:24 -07:00
s390x s390/css: handle CCW_FLAG_SKIP 2019-05-17 08:16:02 +02:00
scsi vhost-scsi: Allow user to enable migration 2019-06-02 21:32:06 -04:00
sd Clean up header guards that don't match their file name 2019-05-13 08:58:55 +02:00
semihosting semihosting: enable chardev backed output for console 2019-05-28 10:28:50 +01:00
sh4 hw/usb/hcd-ohci: Move PCI-related code into a separate file 2019-05-02 08:42:17 +02:00
smbios kconfig: introduce kconfig files 2019-03-07 21:45:53 +01:00
sparc hw/sparc: Implement fw_cfg_arch_key_name() 2019-05-23 14:10:31 +02:00
sparc64 hw/sparc64: Implement fw_cfg_arch_key_name() 2019-05-23 14:10:31 +02:00
ssi hw/ssi/xilinx_spips: Avoid variable length array 2019-04-29 17:35:57 +01:00
timer grlib, gptimer: get rid of the old-style create function 2019-05-17 09:17:11 +01:00
tpm Clean up ill-advised or unusual header guards 2019-05-13 08:58:55 +02:00
tricore - qtest fixes 2019-03-08 16:31:34 +00:00
unicore32 unicore32-softmmu.mak: express dependencies with Kconfig 2019-03-07 21:46:19 +01:00
usb hw/usb: avoid format truncation warning when formatting port name 2019-05-03 08:56:58 +02:00
vfio hw/display/ramfb: initialize fw-config space with xres/ yres 2019-05-24 09:10:29 +02:00
virtio vhost: fix incorrect print type 2019-05-29 18:00:57 -04:00
watchdog trace-events: Fix attribution of trace points to source 2019-03-22 16:18:07 +00:00
xen trace-events: Shorten file names in comments 2019-03-22 16:18:07 +00:00
xenpv xen: Replace few mentions of xend by libxl 2019-01-14 13:45:40 +00:00
xtensa Clean up ill-advised or unusual header guards 2019-05-13 08:58:55 +02:00
Kconfig semihosting: introduce CONFIG_SEMIHOSTING 2019-05-28 10:28:50 +01:00
Makefile.objs semihosting: move semihosting configuration into its own directory 2019-05-28 10:28:50 +01:00