From nobody Sun Feb 8 17:20:39 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1553486801532365.3913300480258; Sun, 24 Mar 2019 21:06:41 -0700 (PDT) Received: from localhost ([127.0.0.1]:35913 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h8Gsd-0005A6-47 for importer@patchew.org; Mon, 25 Mar 2019 00:06:35 -0400 Received: from eggs.gnu.org ([209.51.188.92]:41058) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h8Gqu-0003oN-0K for qemu-devel@nongnu.org; Mon, 25 Mar 2019 00:04:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h8Git-0007Wk-2K for qemu-devel@nongnu.org; Sun, 24 Mar 2019 23:56:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40340) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h8Gin-0007QW-Ga for qemu-devel@nongnu.org; Sun, 24 Mar 2019 23:56:27 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8DC14308A946; Mon, 25 Mar 2019 03:56:22 +0000 (UTC) Received: from jason-ThinkPad-X1-Carbon-6th.redhat.com (ovpn-12-36.pek2.redhat.com [10.72.12.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id BD73060BF7; Mon, 25 Mar 2019 03:56:18 +0000 (UTC) From: Jason Wang To: qemu-devel@nongnu.org, mst@redhat.com, jasowang@redhat.com, yuri.benditovich@daynix.com Date: Mon, 25 Mar 2019 11:56:13 +0800 Message-Id: <20190325035613.18192-1-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Mon, 25 Mar 2019 03:56:22 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH V2 RFT] vhost_net: don't set backend for the uninitialized virtqueue X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" Content-Type: text/plain; charset="utf-8" We used to set backend unconditionally, this won't work for some guests (e.g windows driver) who may not initialize all virtqueues. For kernel backend, this will fail since it may try to validate the rings during setting backend. Fixing this by simply skipping the backend set when we find desc is not ready. Signed-off-by: Jason Wang --- hw/net/vhost_net.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index be3cc88370..04fd924d15 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -221,6 +221,7 @@ static int vhost_net_start_one(struct vhost_net *net, VirtIODevice *dev) { struct vhost_vring_file file =3D { }; + hwaddr a; int r; =20 net->dev.nvqs =3D 2; @@ -244,6 +245,13 @@ static int vhost_net_start_one(struct vhost_net *net, qemu_set_fd_handler(net->backend, NULL, NULL, NULL); file.fd =3D net->backend; for (file.index =3D 0; file.index < net->dev.nvqs; ++file.index) { + a =3D virtio_queue_get_desc_addr(dev, + net->dev.vq_index + + file.index); + if (a =3D=3D 0) { + /* Queue might not be ready for start */ + continue; + } r =3D vhost_net_set_backend(&net->dev, &file); if (r < 0) { r =3D -errno; @@ -256,6 +264,13 @@ fail: file.fd =3D -1; if (net->nc->info->type =3D=3D NET_CLIENT_DRIVER_TAP) { while (file.index-- > 0) { + a =3D virtio_queue_get_desc_addr(dev, + net->dev.vq_index + + file.index); + if (a =3D=3D 0) { + /* Queue might not be ready for start */ + continue; + } int r =3D vhost_net_set_backend(&net->dev, &file); assert(r >=3D 0); } --=20 2.19.1