1 Star 0 Fork 131

XuFei/src_openeuler_qemu

forked from src-openEuler/qemu 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
vhost-user-scsi-add-support-for-SPDK-hot-upgrade.patch 2.97 KB
一键复制 编辑 原始数据 按行查看 历史
KuhnChen 提交于 2022-02-11 20:13 +08:00 . vhost-user-scsi: add support for SPDK hot upgrade
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
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/flyking001/src_openeuler_qemu.git
git@gitee.com:flyking001/src_openeuler_qemu.git
flyking001
src_openeuler_qemu
src_openeuler_qemu
master

搜索帮助