Projects
Eulaceura:Mainline:GA
qemu
_service:obs_scm:vhost-user-quit-infinite-loop-...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:obs_scm:vhost-user-quit-infinite-loop-while-used-memslots-is.patch of Package qemu
From 90d4333d4bbde45a10892bf9004979d239d39e28 Mon Sep 17 00:00:00 2001 From: Jinhua Cao <caojinhua1@huawei.com> Date: Fri, 11 Feb 2022 19:24:30 +0800 Subject: [PATCH] vhost-user: quit infinite loop while used memslots is more than the backend limit When used memslots is more than the backend limit, the vhost-user netcard would attach fail and quit infinite loop. Signed-off-by: Jinhua Cao <caojinhua1@huawei.com> --- hw/virtio/vhost.c | 10 ++++++++++ include/hw/virtio/vhost.h | 1 + net/vhost-user.c | 5 +++++ 3 files changed, 16 insertions(+) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index a8adc149ad..038ac37dd0 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -56,6 +56,8 @@ static unsigned int used_shared_memslots; static QLIST_HEAD(, vhost_dev) vhost_devices = QLIST_HEAD_INITIALIZER(vhost_devices); +bool used_memslots_exceeded; + unsigned int vhost_get_max_memslots(void) { unsigned int max = UINT_MAX; @@ -1569,8 +1571,11 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque, error_setg(errp, "vhost backend memory slots limit (%d) is less" " than current number of used (%d) and reserved (%d)" " memory slots for memory devices.", limit, used, reserved); + used_memslots_exceeded = true; r = -EINVAL; goto fail_busyloop; + } else { + used_memslots_exceeded = false; } return 0; @@ -2405,3 +2410,8 @@ fail: return ret; } + +bool used_memslots_is_exceeded(void) +{ + return used_memslots_exceeded; +} diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 02477788df..444ca0ad42 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -340,6 +340,7 @@ int vhost_dev_set_inflight(struct vhost_dev *dev, struct vhost_inflight *inflight); int vhost_dev_get_inflight(struct vhost_dev *dev, uint16_t queue_size, struct vhost_inflight *inflight); +bool used_memslots_is_exceeded(void); bool vhost_dev_has_iommu(struct vhost_dev *dev); #ifdef CONFIG_VHOST diff --git a/net/vhost-user.c b/net/vhost-user.c index 51fa8c678f..86fd5056ab 100644 --- a/net/vhost-user.c +++ b/net/vhost-user.c @@ -20,6 +20,7 @@ #include "qemu/error-report.h" #include "qemu/option.h" #include "trace.h" +#include "include/hw/virtio/vhost.h" #define VHOST_USER_RECONNECT_TIME (3) @@ -373,6 +374,10 @@ static int net_vhost_user_init(NetClientState *peer, const char *device, qemu_chr_fe_set_handlers(&s->chr, NULL, NULL, net_vhost_user_event, NULL, nc0->name, NULL, true); + if (used_memslots_is_exceeded()) { + error_report("used memslots exceeded the backend limit, quit loop"); + goto err; + } } while (!s->started); assert(s->vhost_net); -- 2.27.0
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2