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>
This commit is contained in:
parent
6e9963d521
commit
38cbd1be35
94
vhost-user-scsi-add-support-for-SPDK-hot-upgrade.patch
Normal file
94
vhost-user-scsi-add-support-for-SPDK-hot-upgrade.patch
Normal file
@ -0,0 +1,94 @@
|
||||
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…
x
Reference in New Issue
Block a user