代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/qemu 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 8c52233c08fe66b2e5c79fd514d4f804aa6fe427 Mon Sep 17 00:00:00 2001
From: Jinhua Cao <caojinhua1@huawei.com>
Date: Fri, 11 Feb 2022 20:13:50 +0800
Subject: [PATCH] vhost-user-scsi: add support for SPDK hot upgrade
In the hot upgrade scenario, the reconnection mechanism of qemu and SPDK after upgrade
Signed-off-by: Jinhua Cao <caojinhua1@huawei.com>
---
hw/scsi/vhost-user-scsi.c | 42 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 41 insertions(+), 1 deletion(-)
diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c
index 1b2f7eed98..052740a76e 100644
--- a/hw/scsi/vhost-user-scsi.c
+++ b/hw/scsi/vhost-user-scsi.c
@@ -29,6 +29,9 @@
#include "hw/virtio/virtio-access.h"
#include "chardev/char-fe.h"
#include "sysemu/sysemu.h"
+#include "qemu/log.h"
+
+#define VHOST_USER_SCSI_RECONNECT_TIME 3
/* Features supported by the host application */
static const int user_feature_bits[] = {
@@ -59,7 +62,7 @@ static void vhost_user_scsi_set_status(VirtIODevice *vdev, uint8_t status)
ret = vhost_scsi_common_start(vsc);
if (ret < 0) {
error_report("unable to start vhost-user-scsi: %s", strerror(-ret));
- exit(1);
+ return;
}
} else {
vhost_scsi_common_stop(vsc);
@@ -89,11 +92,43 @@ static void vhost_dummy_handle_output(VirtIODevice *vdev, VirtQueue *vq)
{
}
+static void vhost_user_scsi_event(void *opaque, QEMUChrEvent event)
+{
+ int ret;
+ VHostUserSCSI *s = (VHostUserSCSI *)opaque;
+ VHostSCSICommon *vsc = VHOST_SCSI_COMMON(s);
+ VirtIODevice *vdev = VIRTIO_DEVICE(s);
+
+ qemu_log("event:%d, vdev status:%d\n", event, vdev->status);
+
+ /* if CHR_EVENT_CLOSED, do nothing */
+ if (event != CHR_EVENT_OPENED) {
+ return;
+ };
+
+ /* if status of vdev is not DRIVER_OK, just waiting.
+ * vsc should start when status change to DRIVER_OK */
+ if (!(vdev->status & VIRTIO_CONFIG_S_DRIVER_OK)) {
+ return;
+ }
+
+ /* vsc may not fully start because of vhost app stopping */
+ if (vsc->dev.started) {
+ vhost_scsi_common_stop(vsc);
+ }
+
+ ret = vhost_scsi_common_start(vsc);
+ if (ret < 0) {
+ qemu_log("unable to start vhost-user-scsi: %s\n", strerror(-ret));
+ }
+}
+
static void vhost_user_scsi_realize(DeviceState *dev, Error **errp)
{
VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(dev);
VHostUserSCSI *s = VHOST_USER_SCSI(dev);
VHostSCSICommon *vsc = VHOST_SCSI_COMMON(s);
+ Chardev *chr;
struct vhost_virtqueue *vqs = NULL;
Error *err = NULL;
int ret;
@@ -132,6 +167,11 @@ static void vhost_user_scsi_realize(DeviceState *dev, Error **errp)
vsc->lun = 0;
vsc->target = vs->conf.boot_tpgt;
+ chr = qemu_chr_fe_get_driver(&vs->conf.chardev);
+ qemu_chr_set_reconnect_time(chr, VHOST_USER_SCSI_RECONNECT_TIME);
+ qemu_chr_fe_set_handlers(&vs->conf.chardev, NULL, NULL,
+ vhost_user_scsi_event, NULL, s, NULL, true);
+
return;
free_vhost:
--
2.27.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。