From: Maxime Coquelin <maxime.coquelin@redhat.com>
To: dev@dpdk.org, david.marchand@redhat.com, chenbox@nvidia.com
Cc: Maxime Coquelin <maxime.coquelin@redhat.com>
Subject: [PATCH v3 5/6] vhost: fix and refactor VDUSE reconnect log check
Date: Thu, 24 Oct 2024 11:44:05 +0200 [thread overview]
Message-ID: <20241024094406.3826637-6-maxime.coquelin@redhat.com> (raw)
In-Reply-To: <20241024094406.3826637-1-maxime.coquelin@redhat.com>
This patch fixes missing error handling in checking the
reconnect log version, and takes the opportunity to move
all the checks into a dedicated function to simply VDUSE
device creation code.
Fixes: da79cc7fda76 ("vhost: add reconnection support to VDUSE")
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
lib/vhost/vduse.c | 51 ++++++++++++++++++++++++++++-------------------
1 file changed, 31 insertions(+), 20 deletions(-)
diff --git a/lib/vhost/vduse.c b/lib/vhost/vduse.c
index aae20dfc55..c18692f834 100644
--- a/lib/vhost/vduse.c
+++ b/lib/vhost/vduse.c
@@ -533,6 +533,35 @@ vduse_reconnect_log_map(const char *dev_name, struct vhost_reconnect_data **reco
return ret;
}
+static int
+vduse_reconnect_log_check(struct vhost_reconnect_data *reco_log,
+ const char *dev_name,
+ uint64_t features, uint32_t total_queues)
+{
+ if (reco_log->version != VHOST_RECONNECT_VERSION) {
+ VHOST_CONFIG_LOG(dev_name, ERR,
+ "Version mismatch between backend (0x%x) & reconnection file (0x%x)",
+ VHOST_RECONNECT_VERSION, reco_log->version);
+ return -1;
+ }
+
+ if ((reco_log->features & features) != reco_log->features) {
+ VHOST_CONFIG_LOG(dev_name, ERR,
+ "Features mismatch between backend (0x%" PRIx64 ") & reconnection file (0x%" PRIx64 ")",
+ features, reco_log->features);
+ return -1;
+ }
+
+ if (reco_log->nr_vrings != total_queues) {
+ VHOST_CONFIG_LOG(dev_name, ERR,
+ "Queues number mismatch between backend (%u) and reconnection file (%u)",
+ total_queues, reco_log->nr_vrings);
+ return -1;
+ }
+
+ return 0;
+}
+
static void
vduse_reconnect_handler(int fd, void *arg, int *remove)
{
@@ -648,27 +677,9 @@ vduse_device_create(const char *path, bool compliant_ol_flags)
if (ret < 0)
goto out_dev_close;
- if (reconnect_log->version != VHOST_RECONNECT_VERSION) {
- VHOST_CONFIG_LOG(name, ERR,
- "Version mismatch between backend (0x%x) & reconnection file (0x%x)",
- VHOST_RECONNECT_VERSION, reconnect_log->version);
- }
-
- if ((reconnect_log->features & features) != reconnect_log->features) {
- VHOST_CONFIG_LOG(name, ERR,
- "Features mismatch between backend (0x%" PRIx64 ") & reconnection file (0x%" PRIx64 ")",
- features, reconnect_log->features);
- ret = -1;
- goto out_log_unmap;
- }
-
- if (reconnect_log->nr_vrings != total_queues) {
- VHOST_CONFIG_LOG(name, ERR,
- "Queues number mismatch between backend (%u) and reconnection file (%u)",
- total_queues, reconnect_log->nr_vrings);
- ret = -1;
+ ret = vduse_reconnect_log_check(reconnect_log, name, features, total_queues);
+ if (ret < 0)
goto out_log_unmap;
- }
} else if (errno == ENOENT) {
struct vduse_dev_config *dev_config;
--
2.46.2
next prev parent reply other threads:[~2024-10-24 9:44 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-24 9:44 [PATCH v3 0/6] VDUSE reconnection fixes and cleanup Maxime Coquelin
2024-10-24 9:44 ` [PATCH v3 1/6] vhost: fix VDUSE device creation error handling Maxime Coquelin
2024-10-24 10:03 ` David Marchand
2024-10-24 9:44 ` [PATCH v3 2/6] vhost: fix possible TOCTOU in VDUSE dev creation Maxime Coquelin
2024-10-24 9:44 ` [PATCH v3 3/6] vhost: fix VDUSE reconnect device start failure Maxime Coquelin
2024-10-24 10:04 ` David Marchand
2024-10-24 9:44 ` [PATCH v3 4/6] vhost: refactor VDUSE reconnection log mapping Maxime Coquelin
2024-10-24 10:04 ` David Marchand
2024-10-24 9:44 ` Maxime Coquelin [this message]
2024-10-24 10:04 ` [PATCH v3 5/6] vhost: fix and refactor VDUSE reconnect log check David Marchand
2024-10-24 9:44 ` [PATCH v3 6/6] vhost: move VDUSE reconnection after device is created Maxime Coquelin
2024-10-24 10:04 ` David Marchand
2024-10-24 11:42 ` [PATCH v3 0/6] VDUSE reconnection fixes and cleanup Maxime Coquelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241024094406.3826637-6-maxime.coquelin@redhat.com \
--to=maxime.coquelin@redhat.com \
--cc=chenbox@nvidia.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).