From nobody Wed Nov 27 16:43:02 2024 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=1697740424; cv=none; d=zohomail.com; s=zohoarc; b=PloH9UcEKcUEHHXMH3tcP8UfIqViDbkrLIOFTykScU5d0QDR7xkaCCzmRaHfAsscsHMVktdLNmiQIJE95QJGtykxhRa3tZ3zbMm3E2Dn4vZpXjXdcor31nR8CJIQPoKLOb1dCfq1fM85OCdWIfJ/a/D1jyyk4r24angOBz7nMEo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697740424; h=Content-Type: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=k3kB7c3/8mnVXhh3/qxXLsdRopBKANEVLkGnuRjvnEA=; b=IKGvvimcjDEYnukHC3H8F12PHo6xkrLakWGmCQbwWJFn/xFBRi2ejAoEMAb+v2/FMRFFkQYENhbWvLhZq7jodUbSZIgHbRMcETPCj7k0he87VhxjwaSWfRIF5D9izmiSVPid7epAfNl+e/MHcLOKEnR2pZFgUc8gPWo8LA+QgdQ= 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 1697740424497831.2426228505494; Thu, 19 Oct 2023 11:33:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtXhj-0001Wc-3n; Thu, 19 Oct 2023 14:25:07 -0400 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 1qtXfI-0006ab-VJ for qemu-devel@nongnu.org; Thu, 19 Oct 2023 14:22:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtXfH-0000mb-Cr for qemu-devel@nongnu.org; Thu, 19 Oct 2023 14:22:36 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-650-gFGwKE8dOq-ZdVJUa1RoNw-1; Thu, 19 Oct 2023 14:22:33 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-32d879cac50so5516f8f.0 for ; Thu, 19 Oct 2023 11:22:32 -0700 (PDT) Received: from redhat.com ([2a06:c701:73d2:bf00:e379:826:5137:6b23]) by smtp.gmail.com with ESMTPSA id f12-20020adfb60c000000b00318147fd2d3sm4970378wre.41.2023.10.19.11.22.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 11:22:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697739754; 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=k3kB7c3/8mnVXhh3/qxXLsdRopBKANEVLkGnuRjvnEA=; b=cpaxlEAU8VsPcS/yHW+LM0AAq8h+cwHq8K29XlyiMlceaNCVtpWeMLbthTTkssf3PaWYCQ cSy5xG66XXic9ja8rkyrUdTKj3GvFBpqUomNHoMY7KB8MbE73I9qt0nm4M2gQeu7I6Alhd 4Klw1mKAEk1KgpH5g+IpKT6BBm3ijhA= X-MC-Unique: gFGwKE8dOq-ZdVJUa1RoNw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697739751; x=1698344551; h=in-reply-to:content-transfer-encoding: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=k3kB7c3/8mnVXhh3/qxXLsdRopBKANEVLkGnuRjvnEA=; b=lqfF7Ken6vqpAesNEvJAnuSlFKX1rTN66i+2z4EZMDD0mc8jp9mUhuBdwU+LBaBpSG PsVLLevNYUjLeosyvvVoj1mvRlKd4vAtOp96Q5Djqxw6EbHSdCIZ9s0RFzP3ZdHzMTR8 KTFMQ0FuxOj38d7ADhuXi/pi4CG/sa2DLKPzsuJG8GjfhKvR7+wvvgTirBDsj/bnXTxI bgTxTIdChvoshE92tOc2iVj09UkqIb+oG3H3NP9Gu2cUBQsTujTyRUiLBjwh80flxKQD CgP01+Qfg5UOIIT5PZVn7zCrrKXzVcUUSC4joR3zK+Hmu2KLH8xvhNdlYlwBlkZOEptq /U/A== X-Gm-Message-State: AOJu0Yxtm9qOaORLVkdpwm3PwikkBzmMtHNzAFYhKJhmj6nd9xEzdYOv hFNZ33Il8rkg9ZxG4TQV69qYWUauw89rG0Ll5HiCHuMZD7XnOCDIF/vdktAfLkAY/8QoDiOsFU6 Hw5Lk2s9MGnxThRGS+uBuiGaWaLEhwbdw8ralspjfMYGGBM15PBe+X258mKm2CqH+s3TT X-Received: by 2002:a5d:6151:0:b0:32d:9fc9:d14c with SMTP id y17-20020a5d6151000000b0032d9fc9d14cmr2061791wrt.47.1697739751201; Thu, 19 Oct 2023 11:22:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IELmmBTIhz9rbfO/UiN7opCYS0ME9cXRVfL7eKbKJp5D1jQyoVwAvGHaI2JHbUxKfqedt2AzA== X-Received: by 2002:a5d:6151:0:b0:32d:9fc9:d14c with SMTP id y17-20020a5d6151000000b0032d9fc9d14cmr2061772wrt.47.1697739750907; Thu, 19 Oct 2023 11:22:30 -0700 (PDT) Date: Thu, 19 Oct 2023 14:22:28 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Laszlo Ersek , Eugenio Perez Martin , German Maglione , Liu Jiang , Sergio Lopez Pascual , Stefano Garzarella , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Albert Esteve Subject: [PULL v2 29/78] vhost-user: allow "vhost_set_vring" to wait for a reply Message-ID: <25e7564f205b1f0c7ccb81ca241014764e634f63.1697739629.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: 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.133.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, DKIMWL_WL_HIGH=-0.001, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1697740425267100005 From: Laszlo Ersek The "vhost_set_vring" function already centralizes the common parts of "vhost_user_set_vring_num", "vhost_user_set_vring_base" and "vhost_user_set_vring_enable". We'll want to allow some of those callers to wait for a reply. Therefore, rebase "vhost_set_vring" from just "vhost_user_write" to "vhost_user_write_sync", exposing the "wait_for_reply" parameter. This is purely refactoring -- there is no observable change. That's because: - all three callers pass in "false" for "wait_for_reply", which disables all logic in "vhost_user_write_sync" except the call to "vhost_user_write"; - the fds=3DNULL and fd_num=3D0 arguments of the original "vhost_user_write" call inside "vhost_set_vring" are hard-coded within "vhost_user_write_sync". Cc: "Michael S. Tsirkin" (supporter:vhost) Cc: Eugenio Perez Martin Cc: German Maglione Cc: Liu Jiang Cc: Sergio Lopez Pascual Cc: Stefano Garzarella Signed-off-by: Laszlo Ersek Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefano Garzarella Tested-by: Albert Esteve Reviewed-by: Eugenio P=C3=A9rez Message-Id: <20231002203221.17241-7-lersek@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-user.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 3c14947589..7e452849fa 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -1160,7 +1160,8 @@ static int vhost_user_write_sync(struct vhost_dev *de= v, VhostUserMsg *msg, =20 static int vhost_set_vring(struct vhost_dev *dev, unsigned long int request, - struct vhost_vring_state *ring) + struct vhost_vring_state *ring, + bool wait_for_reply) { VhostUserMsg msg =3D { .hdr.request =3D request, @@ -1169,13 +1170,13 @@ static int vhost_set_vring(struct vhost_dev *dev, .hdr.size =3D sizeof(msg.payload.state), }; =20 - return vhost_user_write(dev, &msg, NULL, 0); + return vhost_user_write_sync(dev, &msg, wait_for_reply); } =20 static int vhost_user_set_vring_num(struct vhost_dev *dev, struct vhost_vring_state *ring) { - return vhost_set_vring(dev, VHOST_USER_SET_VRING_NUM, ring); + return vhost_set_vring(dev, VHOST_USER_SET_VRING_NUM, ring, false); } =20 static void vhost_user_host_notifier_free(VhostUserHostNotifier *n) @@ -1206,7 +1207,7 @@ static void vhost_user_host_notifier_remove(VhostUser= HostNotifier *n, static int vhost_user_set_vring_base(struct vhost_dev *dev, struct vhost_vring_state *ring) { - return vhost_set_vring(dev, VHOST_USER_SET_VRING_BASE, ring); + return vhost_set_vring(dev, VHOST_USER_SET_VRING_BASE, ring, false); } =20 static int vhost_user_set_vring_enable(struct vhost_dev *dev, int enable) @@ -1224,7 +1225,7 @@ static int vhost_user_set_vring_enable(struct vhost_d= ev *dev, int enable) .num =3D enable, }; =20 - ret =3D vhost_set_vring(dev, VHOST_USER_SET_VRING_ENABLE, &state); + ret =3D vhost_set_vring(dev, VHOST_USER_SET_VRING_ENABLE, &state, = false); if (ret < 0) { /* * Restoring the previous state is likely infeasible, as well = as --=20 MST