From nobody Tue Feb 10 00:00:58 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664267021; cv=none; d=zohomail.com; s=zohoarc; b=NRysWfMBhiPfQ6VShCHqs0+iy0AsBgY5D1i6RYn0PDO+XllYwhrT5HfAYvDmWcDBRPtQxYutggG7ok16f7JKLdIyuc0DqSw6lvpV/5EqvG/Jb1bHEUXGVK1stN8POmxQwv4+kIGuusTFEFKzj4L1XFpyHsj6kgC+cZrxJMEcLP8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664267021; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=72fe6pmcOVLG6dRHQG+0/KXd+hhvMVZPBOsQRMmfl+g=; b=RwGIOc1HR1g+0NlTEkrJ8zbHe7rngaHpr3w76CB4Q5IsVveMHuPSZ8gMjKFtMU/1wA9OFlHogfKUPMDWiz1P2KKVpUBxuk87RDfArNjxdhdveLuM2Q8CdiY6NWKu6tUs15JCLC43yJCpmLwQbxZGF/V/siM/EqY8AxXv5KI+ZFU= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1664267021972180.27367088065932; Tue, 27 Sep 2022 01:23:41 -0700 (PDT) Received: from localhost ([::1]:56236 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od5sR-0002n5-VC for importer@patchew.org; Tue, 27 Sep 2022 04:23:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34710) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od53V-000440-LR for qemu-devel@nongnu.org; Tue, 27 Sep 2022 03:31:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:45400) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od53T-0001l7-2M for qemu-devel@nongnu.org; Tue, 27 Sep 2022 03:31:01 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-269-VUBc3d7jMxqVjuPrVf7U7w-1; Tue, 27 Sep 2022 03:30:54 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 789431C0BDE8; Tue, 27 Sep 2022 07:30:54 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-192.pek2.redhat.com [10.72.13.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 661A52166B26; Tue, 27 Sep 2022 07:30:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664263858; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=72fe6pmcOVLG6dRHQG+0/KXd+hhvMVZPBOsQRMmfl+g=; b=XB6kmKls72jRjA9FKIhV8GF04sn3rgiw7ULrkYUmloV4jJZWvZW5CUNAz+lyd3nH7uk0qZ Qbrr8TnHUwC9Usp4jr0YSbAv5kVvsdgsN8P/zi36svpw0+PG2LWh4V+bY3Q1wRj9o/2KWR bmPhXxhZ02Uq8NsuzOiv1qgs+OwNcaI= X-MC-Unique: VUBc3d7jMxqVjuPrVf7U7w-1 From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org, stefanha@redhat.com Cc: lu zhipeng , Jason Wang Subject: [PULL 8/8] virtio: del net client if net_init_tap_one failed Date: Tue, 27 Sep 2022 15:30:22 +0800 Message-Id: <20220927073022.28378-9-jasowang@redhat.com> In-Reply-To: <20220927073022.28378-1-jasowang@redhat.com> References: <20220927073022.28378-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664267023219100001 Content-Type: text/plain; charset="utf-8" From: lu zhipeng If the net tap initializes successful, but failed during network card hot-plugging, the net-tap will remains, so cleanup. Signed-off-by: lu zhipeng Signed-off-by: Jason Wang --- net/tap.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/net/tap.c b/net/tap.c index b3ddfd4..e203d07 100644 --- a/net/tap.c +++ b/net/tap.c @@ -686,7 +686,7 @@ static void net_init_tap_one(const NetdevTapOptions *ta= p, NetClientState *peer, tap_set_sndbuf(s->fd, tap, &err); if (err) { error_propagate(errp, err); - return; + goto failed; } =20 if (tap->has_fd || tap->has_fds) { @@ -726,12 +726,12 @@ static void net_init_tap_one(const NetdevTapOptions *= tap, NetClientState *peer, } else { warn_report_err(err); } - return; + goto failed; } if (!g_unix_set_fd_nonblocking(vhostfd, true, NULL)) { error_setg_errno(errp, errno, "%s: Can't use file descript= or %d", name, fd); - return; + goto failed; } } else { vhostfd =3D open("/dev/vhost-net", O_RDWR); @@ -743,11 +743,11 @@ static void net_init_tap_one(const NetdevTapOptions *= tap, NetClientState *peer, warn_report("tap: open vhost char device failed: %s", strerror(errno)); } - return; + goto failed; } if (!g_unix_set_fd_nonblocking(vhostfd, true, NULL)) { error_setg_errno(errp, errno, "Failed to set FD nonblockin= g"); - return; + goto failed; } } options.opaque =3D (void *)(uintptr_t)vhostfd; @@ -760,11 +760,17 @@ static void net_init_tap_one(const NetdevTapOptions *= tap, NetClientState *peer, } else { warn_report(VHOST_NET_INIT_FAILED); } - return; + goto failed; } } else if (vhostfdname) { error_setg(errp, "vhostfd(s)=3D is not valid without vhost"); + goto failed; } + + return; + +failed: + qemu_del_net_client(&s->nc); } =20 static int get_fds(char *str, char *fds[], int max) --=20 2.7.4