{"id":2225211,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2225211/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260420161958.584407-2-vsementsov@yandex-team.ru/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/1.1/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260420161958.584407-2-vsementsov@yandex-team.ru>","date":"2026-04-20T16:19:51","name":"[v14,1/8] net/tap: move vhost-net open() calls to tap_parse_vhost_fds()","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"36abaaf78f242dfcfa520530134f70937e42535c","submitter":{"id":84116,"url":"http://patchwork.ozlabs.org/api/1.1/people/84116/?format=json","name":"Vladimir Sementsov-Ogievskiy","email":"vsementsov@yandex-team.ru"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260420161958.584407-2-vsementsov@yandex-team.ru/mbox/","series":[{"id":500626,"url":"http://patchwork.ozlabs.org/api/1.1/series/500626/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=500626","date":"2026-04-20T16:19:57","name":"virtio-net: live-TAP local migration","version":14,"mbox":"http://patchwork.ozlabs.org/series/500626/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2225211/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2225211/checks/","tags":{},"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=yandex-team.ru header.i=@yandex-team.ru\n header.a=rsa-sha256 header.s=default header.b=RR4otRRX;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists1p.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)","mail-nwsmtp-smtp-corp-main-68.klg.yp-c.yandex.net;\n dkim=pass header.i=@yandex-team.ru"],"Received":["from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fzrMm1glwz1yD4\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 21 Apr 2026 02:21:24 +1000 (AEST)","from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists1p.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1wErM6-0005VJ-Th; Mon, 20 Apr 2026 12:20:14 -0400","from eggs.gnu.org ([2001:470:142:3::10])\n by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <vsementsov@yandex-team.ru>)\n id 1wErM3-0005Sh-Cc\n for qemu-devel@nongnu.org; Mon, 20 Apr 2026 12:20:11 -0400","from forwardcorp1d.mail.yandex.net\n ([2a02:6b8:c41:1300:1:45:d181:df01])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <vsementsov@yandex-team.ru>)\n id 1wErM0-0003Eo-Jl\n for qemu-devel@nongnu.org; Mon, 20 Apr 2026 12:20:11 -0400","from mail-nwsmtp-smtp-corp-main-68.klg.yp-c.yandex.net\n (mail-nwsmtp-smtp-corp-main-68.klg.yp-c.yandex.net\n [IPv6:2a02:6b8:c42:94a9:0:640:a3fa:0])\n by forwardcorp1d.mail.yandex.net (Yandex) with ESMTPS id 06F2C8070F;\n Mon, 20 Apr 2026 19:20:06 +0300 (MSK)","from vsementsov-lin (unknown [2a02:6bf:8080:54b::1:34])\n by mail-nwsmtp-smtp-corp-main-68.klg.yp-c.yandex.net (smtpcorp) with ESMTPSA\n id 0KUTY10KuKo0-wiufnFRp; Mon, 20 Apr 2026 19:20:05 +0300"],"Precedence":"bulk","X-Yandex-Fwd":"1","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru;\n s=default; t=1776702005;\n bh=PFuhyYkEyooqO79Vl1qyb3FEMTAfJe+RGQkcyMKm/mo=;\n h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From;\n b=RR4otRRXzwqSQDmetSJxuEADKvBbwto2HXZpJM7624gSHSuYO2P2G0HgVesjXTA48\n 6AJLPACO0TLfPCGpC6Ku5TZSwB05mMUHTupQCv0kg51cPDfI/U3NYcBE5fRgPjentz\n CQ093498WWRTFkgqNKRQFKpoGfUPXvK2IOZqYrvk=","From":"Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>","To":"jasowang@redhat.com,\n\tmst@redhat.com","Cc":"armbru@redhat.com, peterx@redhat.com, farosas@suse.de,\n raphael.s.norwitz@gmail.com, bchaney@akamai.com, vsementsov@yandex-team.ru,\n qemu-devel@nongnu.org, berrange@redhat.com, pbonzini@redhat.com,\n yc-core@yandex-team.ru","Subject":"[PATCH v14 1/8] net/tap: move vhost-net open() calls to\n tap_parse_vhost_fds()","Date":"Mon, 20 Apr 2026 19:19:51 +0300","Message-ID":"<20260420161958.584407-2-vsementsov@yandex-team.ru>","X-Mailer":"git-send-email 2.52.0","In-Reply-To":"<20260420161958.584407-1-vsementsov@yandex-team.ru>","References":"<20260420161958.584407-1-vsementsov@yandex-team.ru>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Received-SPF":"pass client-ip=2a02:6b8:c41:1300:1:45:d181:df01;\n envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1d.mail.yandex.net","X-Spam_score_int":"-20","X-Spam_score":"-2.1","X-Spam_bar":"--","X-Spam_report":"(-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,\n DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001,\n SPF_PASS=-0.001 autolearn=ham autolearn_force=no","X-Spam_action":"no action","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.29","List-Id":"qemu development <qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<https://lists.nongnu.org/archive/html/qemu-devel>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"},"content":"1. Simplify code path: get vhostfds for all cases in one function.\n\n2. Prepare for further tap-fd-migraton feature, when we'll need to\npostpone vhost initialization up to post-load stage.\n\nSigned-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>\n---\n net/tap.c | 39 ++++++++++++++++++++++-----------------\n 1 file changed, 22 insertions(+), 17 deletions(-)","diff":"diff --git a/net/tap.c b/net/tap.c\nindex 57ffb09885c..d941c67895e 100644\n--- a/net/tap.c\n+++ b/net/tap.c\n@@ -736,8 +736,7 @@ static bool net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,\n         }\n     }\n \n-    if (tap->has_vhost ? tap->vhost :\n-        (vhostfd != -1) || (tap->has_vhostforce && tap->vhostforce)) {\n+    if (vhostfd != -1) {\n         VhostNetOptions options;\n \n         options.backend_type = VHOST_BACKEND_TYPE_KERNEL;\n@@ -747,17 +746,6 @@ static bool net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,\n         } else {\n             options.busyloop_timeout = 0;\n         }\n-\n-        if (vhostfd == -1) {\n-            vhostfd = open(\"/dev/vhost-net\", O_RDWR);\n-            if (vhostfd < 0) {\n-                error_setg_file_open(errp, errno, \"/dev/vhost-net\");\n-                goto failed;\n-            }\n-            if (!qemu_set_blocking(vhostfd, false, errp)) {\n-                goto failed;\n-            }\n-        }\n         options.opaque = (void *)(uintptr_t)vhostfd;\n         options.nvqs = 2;\n         options.feature_bits = kernel_feature_bits;\n@@ -843,14 +831,31 @@ static int tap_parse_fds_and_queues(const NetdevTapOptions *tap, int **fds,\n static bool tap_parse_vhost_fds(const NetdevTapOptions *tap, int **vhost_fds,\n                                 int queues, Error **errp)\n {\n-    if (!(tap->vhostfd || tap->vhostfds)) {\n+    bool need_vhost = tap->has_vhost ? tap->vhost :\n+        ((tap->vhostfd || tap->vhostfds) ||\n+         (tap->has_vhostforce && tap->vhostforce));\n+\n+    if (!need_vhost) {\n         *vhost_fds = NULL;\n         return true;\n     }\n \n-    if (net_parse_fds(tap->vhostfd ?: tap->vhostfds,\n-                      vhost_fds, queues, errp) < 0) {\n-        return false;\n+    if (tap->vhostfd || tap->vhostfds) {\n+        if (net_parse_fds(tap->vhostfd ?: tap->vhostfds,\n+                          vhost_fds, queues, errp) < 0) {\n+            return false;\n+        }\n+    } else {\n+        *vhost_fds = g_new(int, queues);\n+        for (int i = 0; i < queues; i++) {\n+            int vhostfd = open(\"/dev/vhost-net\", O_RDWR);\n+            if (vhostfd < 0) {\n+                error_setg_file_open(errp, errno, \"/dev/vhost-net\");\n+                net_free_fds(*vhost_fds, i);\n+                return false;\n+            }\n+            (*vhost_fds)[i] = vhostfd;\n+        }\n     }\n \n     if (!unblock_fds(*vhost_fds, queues, errp)) {\n","prefixes":["v14","1/8"]}