From nobody Tue Sep 22 03:48:17 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1784043882; cv=none; d=zohomail.com; s=zohoarc; b=T0/aWOCBlXXiRoHvwsSUlB2K9kRjPU+LRBJrMTLpYbNFRODipvhRkJdX5Kk8RBxCYJWf3yjxU16FdLcTuhsHrFRVk3rixf30Wc8s+PmtjDv/IycWoINaBckRp0+9N78NJhzNnKYKRY3xC9X2cowBbV7O1Ab2XIDgdPU9WdzQNnY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784043882; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=1PX2vBoRGZeYNspGNRll0bOioKyDsX3GvadATn1+q6U=; b=j42SwO3K0OLvo1lXE5xstxzylpOfqSTdWGEmcoLB4ZY526EsA41wBHA9KransvN/3QhH1fMmhDdKLiHh6qfpWZM/vzzcW9bLq2t1wE1Y2wq0CmlmAUG7xnJwGaW319Y237V700kaKtqxkr2/jARqJy4XhfW/VZKwt+03b9T/Bws= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178404388265331.821436422433294; Tue, 14 Jul 2026 08:44:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wjfHm-0001Oo-N1; Tue, 14 Jul 2026 11:43:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wjfHi-0001M0-A0 for qemu-devel@nongnu.org; Tue, 14 Jul 2026 11:43:02 -0400 Received: from forwardcorp1b.mail.yandex.net ([2a02:6b8:c02:900:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wjfHg-00084l-L4 for qemu-devel@nongnu.org; Tue, 14 Jul 2026 11:43:02 -0400 Received: from mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net (mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net [IPv6:2a02:6b8:c1b:16:0:640:bc52:0]) by forwardcorp1b.mail.yandex.net (postfix) with ESMTPS id 535F680B08; Tue, 14 Jul 2026 18:42:59 +0300 (MSK) Received: from i115954770.yandex-team.ru (unknown [2a02:6bf:8080:c5a::1:8]) by mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net (smtpcorp) with ESMTPSA id lgRdV71YDKo0-ary5JxKO; Tue, 14 Jul 2026 18:42:58 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1784043778; bh=1PX2vBoRGZeYNspGNRll0bOioKyDsX3GvadATn1+q6U=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=GoTjSqOtn37922OdgWdDxAckohfp4SB7C+a5eAyMThsdbFy7B6jccHqW+CEh/C63Y x1IFxUY2WbX5jtZk1h2X6JcIRXFA4qvT5A0j13pMaDz3OuBxSxbOUEq5j1Wm7RxQKu h9brrDMGvgQSQjFvcoW85Z1nLZquIdRe6JJrO3l0= Authentication-Results: mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: jasowang@redhat.com, mst@redhat.com Cc: armbru@redhat.com, peterx@redhat.com, farosas@suse.de, raphael.s.norwitz@gmail.com, bchaney@akamai.com, vsementsov@yandex-team.ru, qemu-devel@nongnu.org, berrange@redhat.com, pbonzini@redhat.com, yc-core@yandex-team.ru, mark.caveayland@nutanix.com, Jason Wang Subject: [PATCH v19 12/15] net/tap: disable read polling for stopped VM Date: Tue, 14 Jul 2026 18:42:40 +0300 Message-ID: <20260714154246.1242856-13-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260714154246.1242856-1-vsementsov@yandex-team.ru> References: <20260714154246.1242856-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a02:6b8:c02:900:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1b.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, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1784043884768158500 Content-Type: text/plain; charset="utf-8" Polling when VM is stopped doesn't make real sense, as stopped VM can't handle incoming traffic anyway. And it's critical for introduction of local TAP migration feature in the next commit: the TAP device will be transferred to the target (open fd will be passed through migration channel), and if we continue polling on source, we may get a package, which we'll never handle on source (already stopped), it will be lost. Better is save this package for target VM to handle. Signed-off-by: Vladimir Sementsov-Ogievskiy --- net/tap.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/net/tap.c b/net/tap.c index 95bcfaaf1ea..2bd4b089573 100644 --- a/net/tap.c +++ b/net/tap.c @@ -36,6 +36,7 @@ #include "net/net.h" #include "clients.h" #include "monitor/monitor.h" +#include "system/runstate.h" #include "system/system.h" #include "qapi/error.h" #include "qemu/cutils.h" @@ -92,6 +93,8 @@ struct TAPState { Notifier exit; =20 int queue_index; + bool read_poll_detached; + VMChangeStateEntry *vmstate; }; =20 static void launch_script(const char *setup_script, const char *ifname, @@ -150,6 +153,23 @@ static void tap_read_poll(TAPState *s, bool enable) tap_update_fd_handler(s); } =20 +static void tap_vm_state_change(void *opaque, bool running, RunState state) +{ + TAPState *s =3D opaque; + + if (running) { + if (s->read_poll_detached) { + tap_read_poll(s, true); + s->read_poll_detached =3D false; + } + } else if (state =3D=3D RUN_STATE_FINISH_MIGRATE) { + if (s->read_poll) { + s->read_poll_detached =3D true; + tap_read_poll(s, false); + } + } +} + static void tap_write_poll(TAPState *s, bool enable) { s->write_poll =3D enable; @@ -380,6 +400,11 @@ static void tap_cleanup(NetClientState *nc) s->exit.notify =3D NULL; } =20 + if (s->vmstate) { + qemu_del_vm_change_state_handler(s->vmstate); + s->vmstate =3D NULL; + } + tap_read_poll(s, false); tap_write_poll(s, false); close(s->fd); @@ -819,6 +844,9 @@ static bool net_init_tap_one(const NetdevTapOptions *ta= p, NetClientState *peer, int sndbuf =3D (tap->has_sndbuf && tap->sndbuf) ? MIN(tap->sndbuf, INT_MAX) : INT= _MAX; =20 + s->read_poll_detached =3D false; + s->vmstate =3D qemu_add_vm_change_state_handler(tap_vm_state_change, s= ); + if (!tap_set_sndbuf(fd, sndbuf, sndbuf_required ? errp : NULL) && sndbuf_required) { goto failed; --=20 2.43.0