qemu/hw/char
Haoqian He bc85aae420 vhost-user: return failure if backend crash when live migration
Live migration should be terminated if the vhost-user backend crashes
before the migration completes.

Specifically, since the vhost device will be stopped when VM is stopped
before the end of the live migration, in current implementation if the
backend crashes, vhost-user device set_status() won't return failure,
live migration won't perceive the disconnection between QEMU and the
backend.

When the VM is migrated to the destination, the inflight IO will be
resubmitted, and if the IO was completed out of order before, it will
cause IO error.

To fix this issue:
1. Add the return value to set_status() for VirtioDeviceClass.
  a. For the vhost-user device, return failure when the backend crashes.
  b. For other virtio devices, always return 0.
2. Return failure if vhost_dev_stop() failed for vhost-user device.

If QEMU loses connection with the vhost-user backend, virtio set_status()
can return failure to the upper layer, migration_completion() can handle
the error, terminate the live migration, and restore the VM, so that
inflight IO can be completed normally.

Signed-off-by: Haoqian He <haoqian.he@smartx.com>
Message-Id: <20250416024729.3289157-4-haoqian.he@smartx.com>
Tested-by: Lei Yang <leiyang@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2025-05-14 05:39:15 -04:00
..
avr_usart.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
bcm2835_aux.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
cadence_uart.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
cmsdk-apb-uart.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
debugcon.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
digic-uart.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
diva-gsp.c hw/char/serial: Remove unused prog_if compat property 2025-05-02 21:49:32 +02:00
escc.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
exynos4210_uart.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
goldfish_tty.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
grlib_apbuart.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
ibex_uart.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
imx_serial.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
ipoctal232.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
Kconfig rust: Kconfig: Factor out whether PL011 is Rust or C 2025-03-20 09:23:18 +01:00
mcf_uart.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
mchp_pfsoc_mmuart.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
meson.build rust: Kconfig: Factor out whether PL011 is Rust or C 2025-03-20 09:23:18 +01:00
nrf51_uart.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
omap_uart.c include/system: Move exec/address-spaces.h to system/address-spaces.h 2025-04-23 14:08:21 -07:00
parallel-isa.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
parallel.c qom: Make InterfaceInfo[] uses const 2025-04-25 17:00:41 +02:00
pl011.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
renesas_sci.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
riscv_htif.c include/system: Move exec/address-spaces.h to system/address-spaces.h 2025-04-23 14:08:21 -07:00
sclpconsole-lm.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
sclpconsole.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
serial-isa.c qom: Make InterfaceInfo[] uses const 2025-04-25 17:00:41 +02:00
serial-mm.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
serial-pci-multi.c hw/char/serial: Remove unused prog_if compat property 2025-05-02 21:49:32 +02:00
serial-pci.c hw/char/serial: Remove unused prog_if compat property 2025-05-02 21:49:32 +02:00
serial.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
sh_serial.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
shakti_uart.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
sifive_uart.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
spapr_vty.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
stm32f2xx_usart.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
stm32l4x5_usart.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
terminal3270.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
trace-events hw/char/pl011: Improve RX flow tracing events 2025-03-04 14:45:34 +01:00
trace.h trace: switch position of headers to what Meson requires 2020-08-21 06:18:24 -04:00
virtio-console.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
virtio-serial-bus.c vhost-user: return failure if backend crash when live migration 2025-05-14 05:39:15 -04:00
xen_console.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00
xilinx_uartlite.c qom: Have class_init() take a const data argument 2025-04-25 17:00:41 +02:00