mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-27 04:13:53 -06:00

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>
50 lines
1.3 KiB
C
50 lines
1.3 KiB
C
/*
|
|
* vhost_scsi host device
|
|
*
|
|
* Copyright (c) 2016 Nutanix Inc. All rights reserved.
|
|
*
|
|
* Author:
|
|
* Felipe Franciosi <felipe@nutanix.com>
|
|
*
|
|
* This work is licensed under the terms of the GNU LGPL, version 2 or later.
|
|
* See the COPYING.LIB file in the top-level directory.
|
|
*
|
|
*/
|
|
|
|
#ifndef VHOST_SCSI_COMMON_H
|
|
#define VHOST_SCSI_COMMON_H
|
|
|
|
#include "hw/virtio/virtio-scsi.h"
|
|
#include "hw/virtio/vhost.h"
|
|
#include "hw/fw-path-provider.h"
|
|
#include "qom/object.h"
|
|
|
|
#define TYPE_VHOST_SCSI_COMMON "vhost-scsi-common"
|
|
OBJECT_DECLARE_SIMPLE_TYPE(VHostSCSICommon, VHOST_SCSI_COMMON)
|
|
|
|
struct VHostSCSICommon {
|
|
VirtIOSCSICommon parent_obj;
|
|
|
|
Error *migration_blocker;
|
|
|
|
struct vhost_dev dev;
|
|
const int *feature_bits;
|
|
int32_t bootindex;
|
|
int channel;
|
|
int target;
|
|
int lun;
|
|
uint64_t host_features;
|
|
bool migratable;
|
|
|
|
struct vhost_inflight *inflight;
|
|
};
|
|
|
|
int vhost_scsi_common_start(VHostSCSICommon *vsc, Error **errp);
|
|
int vhost_scsi_common_stop(VHostSCSICommon *vsc);
|
|
char *vhost_scsi_common_get_fw_dev_path(FWPathProvider *p, BusState *bus,
|
|
DeviceState *dev);
|
|
void vhost_scsi_common_set_config(VirtIODevice *vdev, const uint8_t *config);
|
|
uint64_t vhost_scsi_common_get_features(VirtIODevice *vdev, uint64_t features,
|
|
Error **errp);
|
|
|
|
#endif /* VHOST_SCSI_COMMON_H */
|