From nobody Sun Dec 14 06:32:18 2025 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=1667863501; cv=none; d=zohomail.com; s=zohoarc; b=MdbK4mBwX11OU6kfY8LDaexjoUKWEX9lVBCZiaL7/KUP0xqyh7uj3ZBCsNm/7Q2Li+9EGlLVEWxqs1G1eoKIA3mnGD1d0ds64twoW3V066yf/qMNTngSp7tIuE8UwuY3DA1fYQlfzCG0URLF+5PVZFuFd4/JHPzz4J4fBgUTOhI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1667863501; h=Content-Type: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=wH9In1dsmo/cnU0MTw9nPlthORSI2VXK6ZI0gdJrLTs=; b=BHneunO5/NlZP71vr5NmNW4w2TAkOW9EJ/HS9dfHoKL2zA8cMG/ibQivhgXl71paQ5Jp5qzOkNFCcZ9NsFtMMK85ZD/fvwc1XQdg2zB1k9nZ6b0w/UcGpOGjkjMxhqGQ2KPmQ+Nu+RIhU9dJxrdHv+0gPIFNgzdvEjp17KhF1A0= 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 1667863501957750.8596426805794; Mon, 7 Nov 2022 15:25:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1osB0N-0005qW-4N; Mon, 07 Nov 2022 17:54:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1osB0H-0005lP-Bc for qemu-devel@nongnu.org; Mon, 07 Nov 2022 17:54:05 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1osB09-0004FB-G8 for qemu-devel@nongnu.org; Mon, 07 Nov 2022 17:54:05 -0500 Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-605-X0wlfUMVMJKeCNzcKKugWQ-1; Mon, 07 Nov 2022 17:53:55 -0500 Received: by mail-qv1-f71.google.com with SMTP id b2-20020a0cfe62000000b004bbfb15297dso8593342qvv.19 for ; Mon, 07 Nov 2022 14:53:55 -0800 (PST) Received: from redhat.com ([87.249.138.11]) by smtp.gmail.com with ESMTPSA id z10-20020ac87caa000000b003a50d92f9b4sm6992931qtv.1.2022.11.07.14.53.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Nov 2022 14:53:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667861636; 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: in-reply-to:in-reply-to:references:references; bh=wH9In1dsmo/cnU0MTw9nPlthORSI2VXK6ZI0gdJrLTs=; b=gWa3ymFFuzgOxA3iOLCqqYIFkP9oP+e4qpgiXwtu/3QZQ6cQfr0VELzQIhM8P0g+CM7FlG 7otLa1qDIZg74MxDo8Ae7oubp8/NmYBMV+Ovq7JNlLL3eevywL1/jkU+vJKIgOUMdd+LF0 g4jSodNaMGjucTvzQs6c9Otjml6uTyE= X-MC-Unique: X0wlfUMVMJKeCNzcKKugWQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=wH9In1dsmo/cnU0MTw9nPlthORSI2VXK6ZI0gdJrLTs=; b=OP+1enzXGNEXaGUw7hwt7P9VvnIm0qaujmreZ/biVx3UQ31rvJa5UBP3Q0ML4DgDXC kuQ6GEfZ293x/QJCAB2mcfmkGYGDUZmB2Jp503I8r+3b17MsIMuJaGG3SaUuLkKyJ49R 1WB98E6eZNIMPKaw+T50NXTAe1m6nrE+kEHr2ppxBJF03qgZBVIt76lTtO0oslXspUxF wjkJuzMgEY40J/xrpJeh21K1SA2WpHH2bu9E5GyWNloFe6Utx3ykQn7iL3Kf8WiUGtWM AGp1acLXjcNdXSiiPSAYHPnCyYOj6mUQnGXnqsQ51Cutx+S47YN5hPX6Uwmx4x9ZWwi4 tymQ== X-Gm-Message-State: ACrzQf0yCIGT5qUU1jtSnM9BEjSYa7xF+mL078S5coaxXmIRpHLE0/AK TaNudvssSKhVCoOV+YAXjdCRp1MqZiAEnX5Aw7uSHPJIK+Jv8sCF733qRJfAbNBxaiBPeY1raEN MJserBPtxwWTK7pf3uWoipnfnyALwxPPTFD8dRU+74fy7S0CxmQDafAofHVkQ X-Received: by 2002:a37:53c7:0:b0:6fa:4b14:e071 with SMTP id h190-20020a3753c7000000b006fa4b14e071mr25893808qkb.230.1667861634809; Mon, 07 Nov 2022 14:53:54 -0800 (PST) X-Google-Smtp-Source: AMsMyM7aMeXtkN3tHIiQctKYfL5VqnCnMzZ2Tll6VvO6dknsN5+s/8/jGYSPMPhtn2lP+rxqzAVOKQ== X-Received: by 2002:a37:53c7:0:b0:6fa:4b14:e071 with SMTP id h190-20020a3753c7000000b006fa4b14e071mr25893785qkb.230.1667861634492; Mon, 07 Nov 2022 14:53:54 -0800 (PST) Date: Mon, 7 Nov 2022 17:53:49 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Yajun Wu , Parav Pandit , Raphael Norwitz , Kevin Wolf , Hanna Reitz , Jason Wang , qemu-block@nongnu.org Subject: [PULL v4 75/83] vhost: Change the sequence of device start Message-ID: <20221107224600.934080-76-mst@redhat.com> References: <20221107224600.934080-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221107224600.934080-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1667863504114100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Yajun Wu This patch is part of adding vhost-user vhost_dev_start support. The motivation is to improve backend configuration speed and reduce live migration VM downtime. Moving the device start routines after finishing all the necessary device and VQ configuration, further aligning to the virtio specification for "device initialization sequence". Following patch will add vhost-user vhost_dev_start support. Signed-off-by: Yajun Wu Acked-by: Parav Pandit Message-Id: <20221017064452.1226514-2-yajunw@nvidia.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/block/vhost-user-blk.c | 18 +++++++++++------- hw/net/vhost_net.c | 11 +++++------ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 13bf5cc47a..28409c90f7 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -168,13 +168,6 @@ static int vhost_user_blk_start(VirtIODevice *vdev, Er= ror **errp) goto err_guest_notifiers; } =20 - ret =3D vhost_dev_start(&s->dev, vdev); - if (ret < 0) { - error_setg_errno(errp, -ret, "Error starting vhost"); - goto err_guest_notifiers; - } - s->started_vu =3D true; - /* guest_notifier_mask/pending not used yet, so just unmask * everything here. virtio-pci will do the right thing by * enabling/disabling irqfd. @@ -183,9 +176,20 @@ static int vhost_user_blk_start(VirtIODevice *vdev, Er= ror **errp) vhost_virtqueue_mask(&s->dev, vdev, i, false); } =20 + s->dev.vq_index_end =3D s->dev.nvqs; + ret =3D vhost_dev_start(&s->dev, vdev); + if (ret < 0) { + error_setg_errno(errp, -ret, "Error starting vhost"); + goto err_guest_notifiers; + } + s->started_vu =3D true; + return ret; =20 err_guest_notifiers: + for (i =3D 0; i < s->dev.nvqs; i++) { + vhost_virtqueue_mask(&s->dev, vdev, i, true); + } k->set_guest_notifiers(qbus->parent, s->dev.nvqs, false); err_host_notifiers: vhost_dev_disable_notifiers(&s->dev, vdev); diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 53b2fac4f6..feda448878 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -389,21 +389,20 @@ int vhost_net_start(VirtIODevice *dev, NetClientState= *ncs, } else { peer =3D qemu_get_peer(ncs, n->max_queue_pairs); } - r =3D vhost_net_start_one(get_vhost_net(peer), dev); - - if (r < 0) { - goto err_start; - } =20 if (peer->vring_enable) { /* restore vring enable state */ r =3D vhost_set_vring_enable(peer, peer->vring_enable); =20 if (r < 0) { - vhost_net_stop_one(get_vhost_net(peer), dev); goto err_start; } } + + r =3D vhost_net_start_one(get_vhost_net(peer), dev); + if (r < 0) { + goto err_start; + } } =20 return 0; --=20 MST