- vfio/migration: Add support for manual clear vfio dirty log - vfio: Maintain DMA mapping range for the container - linux-headers: update against 5.10 and manual clear vfio dirty log series - arm/acpi: Fix when make qemu-system-aarch64 at x86_64 host bios_tables_test fail reason: __aarch64__ macro let build_pptt at x86_64 and aarch64 host build different function that let bios_tables_test fail. - pl031: support rtc-timer property for pl031 - feature: Add logs for vm start and destroy - feature: Add log for each modules - log: Add log at boot & cpu init for aarch64 - bugfix: irq: Avoid covering object refcount of qemu_irq - i386: cache passthrough: Update AMD 8000_001D.EAX[25:14] based on vCPU topo - freeclock: set rtc_date_diff for X86 - freeclock: set rtc_date_diff for arm - freeclock: add qmp command to get time offset of vm in seconds - tests: Disable filemonitor testcase - shadow_dev: introduce shadow dev for virtio-net device - pl011: reset read FIFO when UARTTIMSC=0 & UARTICR=0xffff - tests: virt: Update expected ACPI tables for virt test(update BinDir) - arm64: Add the cpufreq device to show cpufreq info to guest - hw/arm64: add vcpu cache info support - tests: virt: Allow changes to PPTT test table - cpu: add Cortex-A72 processor kvm target support - cpu: add Kunpeng-920 cpu support - net: eepro100: validate various address valuesi(CVE-2021-20255) - ide: ahci: add check to avoid null dereference (CVE-2019-12067) - vdpa: set vring enable only if the vring address has already been set - docs: Add generic vhost-vdpa device documentation - vdpa: don't suspend/resume device when vdpa device not started - vdpa: correct param passed in when unregister save - vdpa: suspend function return 0 when the vdpa device is stopped - vdpa: support vdpa device suspend/resume - vdpa: move memory listener to the realize stage - vdpa: implement vdpa device migration - vhost: implement migration state notifier for vdpa device - vhost: implement post resume bh - vhost: implement savevm_handler for vdpa device - vhost: implement vhost_vdpa_device_suspend/resume - vhost: implement vhost-vdpa suspend/resume - vhost: add vhost_dev_suspend/resume_op - vhost: introduce bytemap for vhost backend logging - vhost-vdpa: add migration log ops for VhostOps - vhost-vdpa: add VHOST_BACKEND_F_BYTEMAPLOG - hw/usb: reduce the vpcu cost of UHCI when VNC disconnect - virtio-net: update the default and max of rx/tx_queue_size - virtio-net: set the max of queue size to 4096 - virtio-net: fix max vring buf size when set ring num - virtio-net: bugfix: do not delete netdev before virtio net - monitor: Discard BLOCK_IO_ERROR event when VM rebooted - vhost-user: add unregister_savevm when vhost-user cleanup - vhost-user: add vhost_set_mem_table when vm load_setup at destination - vhost-user: quit infinite loop while used memslots is more than the backend limit - fix qemu-core when vhost-user-net config with server mode - vhost-user: Add support reconnect vhost-user socket - vhost-user: Set the acked_features to vm's featrue - i6300esb watchdog: bugfix: Add a runstate transition - hw/net/rocker_of_dpa: fix double free bug of rocker device - net/dump.c: Suppress spurious compiler warning - pcie: Add pcie-root-port fast plug/unplug feature - pcie: Compat with devices which do not support Link Width, such as ioh3420 - qdev/monitors: Fix reundant error_setg of qdev_add_device - qemu-nbd: set timeout to qemu-nbd socket - qemu-nbd: make native as the default aio mode - nbd/server.c: fix invalid read after client was already free - virtio-scsi: bugfix: fix qemu crash for hotplug scsi disk with dataplane - virtio: bugfix: check the value of caches before accessing it - virtio: print the guest virtio_net features that host does not support - virtio: bugfix: add rcu_read_lock when vring_avail_idx is called - virtio: check descriptor numbers - migration: report multiFd related thread pid to libvirt - migration: report migration related thread pid to libvirt - cpu/features: fix bug for memory leakage - doc: Update multi-thread compression doc - migration: Add compress_level sanity check - migration: Add zstd support in multi-thread compression - migration: Add multi-thread compress ops - migration: Refactoring multi-thread compress migration - migration: Add multi-thread compress method - migration: skip cache_drop for bios bootloader and nvram template - oslib-posix: optimise vm startup time for 1G hugepage - monitor/qmp: drop inflight rsp if qmp client broken - ps2: fix oob in ps2 kbd - Currently, while kvm and qemu can not handle some kvm exit, qemu will do vm_stop, which will make vm in pause state. This action make vm unrecoverable, so send guest panic to libvirt instead. - vhost: cancel migration when vhost-user restarted during migraiton Signed-off-by: Jiabo Feng <fengjiabo1@huawei.com>
169 lines
5.5 KiB
Diff
169 lines
5.5 KiB
Diff
From 0bc608ab4117818b32d2a1aaf2d4f5c2aeb54af7 Mon Sep 17 00:00:00 2001
|
|
From: Jinhua Cao <caojinhua1@huawei.com>
|
|
Date: Fri, 11 Feb 2022 18:05:47 +0800
|
|
Subject: [PATCH] vhost-user: Add support reconnect vhost-user socket
|
|
|
|
Add support reconnect vhost-user socket, the reconnect time
|
|
is set to be 3 seconds.
|
|
|
|
Signed-off-by: Jinhua Cao <caojinhua1@huawei.com>
|
|
---
|
|
chardev/char-socket.c | 19 ++++++++++++++++++-
|
|
hw/net/vhost_net.c | 4 +++-
|
|
hw/virtio/vhost-user.c | 6 ++++++
|
|
include/chardev/char.h | 16 ++++++++++++++++
|
|
net/vhost-user.c | 3 +++
|
|
5 files changed, 46 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/chardev/char-socket.c b/chardev/char-socket.c
|
|
index 034840593d..9c60e15c8e 100644
|
|
--- a/chardev/char-socket.c
|
|
+++ b/chardev/char-socket.c
|
|
@@ -337,6 +337,22 @@ static GSource *tcp_chr_add_watch(Chardev *chr, GIOCondition cond)
|
|
return qio_channel_create_watch(s->ioc, cond);
|
|
}
|
|
|
|
+static void tcp_chr_set_reconnect_time(Chardev *chr,
|
|
+ int64_t reconnect_time)
|
|
+{
|
|
+ SocketChardev *s = SOCKET_CHARDEV(chr);
|
|
+ s->reconnect_time = reconnect_time;
|
|
+}
|
|
+
|
|
+void qemu_chr_set_reconnect_time(Chardev *chr, int64_t reconnect_time)
|
|
+{
|
|
+ ChardevClass *cc = CHARDEV_GET_CLASS(chr);
|
|
+
|
|
+ if (cc->chr_set_reconnect_time) {
|
|
+ cc->chr_set_reconnect_time(chr, reconnect_time);
|
|
+ }
|
|
+}
|
|
+
|
|
static void remove_hup_source(SocketChardev *s)
|
|
{
|
|
if (s->hup_source != NULL) {
|
|
@@ -537,7 +553,7 @@ static int tcp_chr_sync_read(Chardev *chr, const uint8_t *buf, int len)
|
|
if (s->state != TCP_CHARDEV_STATE_DISCONNECTED) {
|
|
qio_channel_set_blocking(s->ioc, false, NULL);
|
|
}
|
|
- if (size == 0) {
|
|
+ if (size == 0 && chr->chr_for_flag != CHR_FOR_VHOST_USER) {
|
|
/* connection closed */
|
|
tcp_chr_disconnect(chr);
|
|
}
|
|
@@ -1543,6 +1559,7 @@ static void char_socket_class_init(ObjectClass *oc, void *data)
|
|
cc->set_msgfds = tcp_set_msgfds;
|
|
cc->chr_add_client = tcp_chr_add_client;
|
|
cc->chr_add_watch = tcp_chr_add_watch;
|
|
+ cc->chr_set_reconnect_time = tcp_chr_set_reconnect_time;
|
|
cc->chr_update_read_handler = tcp_chr_update_read_handler;
|
|
|
|
object_class_property_add(oc, "addr", "SocketAddress",
|
|
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
|
|
index 1b08b02477..e48c373b14 100644
|
|
--- a/hw/net/vhost_net.c
|
|
+++ b/hw/net/vhost_net.c
|
|
@@ -459,7 +459,9 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs,
|
|
peer = qemu_get_peer(ncs, n->max_queue_pairs);
|
|
}
|
|
|
|
- if (peer->vring_enable) {
|
|
+ /* ovs needs to restore all states of vring */
|
|
+ if (peer->vring_enable ||
|
|
+ ncs[i].peer->info->type == NET_CLIENT_DRIVER_VHOST_USER) {
|
|
/* restore vring enable state */
|
|
r = vhost_set_vring_enable(peer, peer->vring_enable);
|
|
|
|
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
|
|
index f214df804b..05e14e1eff 100644
|
|
--- a/hw/virtio/vhost-user.c
|
|
+++ b/hw/virtio/vhost-user.c
|
|
@@ -2126,9 +2126,15 @@ static int vhost_user_backend_init(struct vhost_dev *dev, void *opaque,
|
|
struct vhost_user *u;
|
|
VhostUserState *vus = (VhostUserState *) opaque;
|
|
int err;
|
|
+ Chardev *chr;
|
|
|
|
assert(dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_USER);
|
|
|
|
+ chr = qemu_chr_fe_get_driver(((VhostUserState *)opaque)->chr);
|
|
+ if (chr) {
|
|
+ chr->chr_for_flag = CHR_FOR_VHOST_USER;
|
|
+ }
|
|
+
|
|
u = g_new0(struct vhost_user, 1);
|
|
u->user = vus;
|
|
u->dev = dev;
|
|
diff --git a/include/chardev/char.h b/include/chardev/char.h
|
|
index 01df55f9e8..f8bd469466 100644
|
|
--- a/include/chardev/char.h
|
|
+++ b/include/chardev/char.h
|
|
@@ -14,6 +14,8 @@
|
|
#define IAC_SB 250
|
|
#define IAC 255
|
|
|
|
+#define CHR_FOR_VHOST_USER 0x32a1
|
|
+
|
|
/* character device */
|
|
typedef struct CharBackend CharBackend;
|
|
|
|
@@ -70,6 +72,7 @@ struct Chardev {
|
|
GSource *gsource;
|
|
GMainContext *gcontext;
|
|
DECLARE_BITMAP(features, QEMU_CHAR_FEATURE_LAST);
|
|
+ int chr_for_flag;
|
|
};
|
|
|
|
/**
|
|
@@ -227,6 +230,16 @@ int qemu_chr_write(Chardev *s, const uint8_t *buf, int len, bool write_all);
|
|
#define qemu_chr_write_all(s, buf, len) qemu_chr_write(s, buf, len, true)
|
|
int qemu_chr_wait_connected(Chardev *chr, Error **errp);
|
|
|
|
+/**
|
|
+ * @qemu_chr_set_reconnect_time:
|
|
+ *
|
|
+ * Set reconnect time for char disconnect.
|
|
+ * Currently, only vhost user will call it.
|
|
+ *
|
|
+ * @reconnect_time the reconnect_time to be set
|
|
+ */
|
|
+void qemu_chr_set_reconnect_time(Chardev *chr, int64_t reconnect_time);
|
|
+
|
|
#define TYPE_CHARDEV "chardev"
|
|
OBJECT_DECLARE_TYPE(Chardev, ChardevClass, CHARDEV)
|
|
|
|
@@ -306,6 +319,9 @@ struct ChardevClass {
|
|
|
|
/* handle various events */
|
|
void (*chr_be_event)(Chardev *s, QEMUChrEvent event);
|
|
+
|
|
+ /* set reconnect time */
|
|
+ void (*chr_set_reconnect_time)(Chardev *chr, int64_t reconnect_time);
|
|
};
|
|
|
|
Chardev *qemu_chardev_new(const char *id, const char *typename,
|
|
diff --git a/net/vhost-user.c b/net/vhost-user.c
|
|
index 12555518e8..51fa8c678f 100644
|
|
--- a/net/vhost-user.c
|
|
+++ b/net/vhost-user.c
|
|
@@ -21,6 +21,8 @@
|
|
#include "qemu/option.h"
|
|
#include "trace.h"
|
|
|
|
+#define VHOST_USER_RECONNECT_TIME (3)
|
|
+
|
|
typedef struct NetVhostUserState {
|
|
NetClientState nc;
|
|
CharBackend chr; /* only queue index 0 */
|
|
@@ -292,6 +294,7 @@ static void net_vhost_user_event(void *opaque, QEMUChrEvent event)
|
|
trace_vhost_user_event(chr->label, event);
|
|
switch (event) {
|
|
case CHR_EVENT_OPENED:
|
|
+ qemu_chr_set_reconnect_time(chr, VHOST_USER_RECONNECT_TIME);
|
|
if (vhost_user_start(queues, ncs, s->vhost_user) < 0) {
|
|
qemu_chr_fe_disconnect(&s->chr);
|
|
return;
|
|
--
|
|
2.27.0
|
|
|