From patchwork Wed Feb 26 09:07:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1244824 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=cmXg0BEO; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48S99D2gRGz9sNg for ; Wed, 26 Feb 2020 20:14:24 +1100 (AEDT) Received: from localhost ([::1]:40636 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6slq-00023F-7Q for incoming@patchwork.ozlabs.org; Wed, 26 Feb 2020 04:14:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59283) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6sfF-0005yM-Dn for qemu-devel@nongnu.org; Wed, 26 Feb 2020 04:07:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j6sfB-0000Yy-MT for qemu-devel@nongnu.org; Wed, 26 Feb 2020 04:07:33 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:27576 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j6sfB-0000Yh-Ig for qemu-devel@nongnu.org; Wed, 26 Feb 2020 04:07:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582708049; 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=GurCHGrxIX/gaMnymLT6OLHjIK8r0mHiQmdNJWYE8J8=; b=cmXg0BEOM01pwwRsk3ZxuYh40ypLKYO3wNVEUMuls/HyH+81gQzUJMab68HY2DP5J0qxQ8 N/AmJMa1g3VgGpd+YXXmPMgv8C2SfIehMKOBTmKKfshWoanWlP49DD60X9/ieP8by5Z40d bmjKJ4gVqDXsPeh76N8CKUP4a5xYu/A= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-299-ekhSTAi7PRCq5AMJola0nA-1; Wed, 26 Feb 2020 04:07:27 -0500 X-MC-Unique: ekhSTAi7PRCq5AMJola0nA-1 Received: by mail-wm1-f72.google.com with SMTP id p26so462236wmg.5 for ; Wed, 26 Feb 2020 01:07:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=HJYgPtUXb7oGIKTPBdg5GcKwNd69Hnwn26g3WEAmRrg=; b=tsnyxOLBMO48AD/u+ou4/ulxeUKXCny5PegOAJHZNe0ovVjfXKePLY2iJogYwY/qOs ypMKKQVAC+xCb6PCj0vwTqNMSqqERLZPuzhQ5a16YRUopE0TBoyTlsYKS+jcbtjun8RK IpjCAURzbPnMnC+hkKJMyamJB1suLbIlIwIlH0xYBr8ezRlVyrEhvHygLRrI1jAFd2TR 4zl6kproZ2ybolIn3l1wIK78DlaRELZMI0hKQYbVGLKef+5+jRHWxunQgyCU1DZeyifu 7ykR1wEs4Nq66ZokCH7GqbxoeB1Q1ke2PYwPJSWlqkP3NZ/LB1o36lvgG1CaXXIVXz+A j0NA== X-Gm-Message-State: APjAAAW0UZrG/pG0oEGFwx+8pEIGJWGbp/lFi3JD0gdw7sHVYH6MAGNO s5JZnLjKm0qNzL896yVKmQQXYP1mGmgpk1lYIgl3hsRl1WbFaokOrFrRnHT99CwpeNiBdC2KBvv s7BYBHuGRkvXPId8= X-Received: by 2002:a05:600c:2c48:: with SMTP id r8mr3067827wmg.183.1582708045885; Wed, 26 Feb 2020 01:07:25 -0800 (PST) X-Google-Smtp-Source: APXvYqzFQykJnIH25pjtAGYCmk9oYg+p4bokpoiJUy8Vi3wY/sWHuZ1bGzjpTozRUEpmyYSfWe6JHQ== X-Received: by 2002:a05:600c:2c48:: with SMTP id r8mr3067803wmg.183.1582708045619; Wed, 26 Feb 2020 01:07:25 -0800 (PST) Received: from redhat.com (bzq-79-178-2-214.red.bezeqint.net. [79.178.2.214]) by smtp.gmail.com with ESMTPSA id a62sm2088201wmh.33.2020.02.26.01.07.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Feb 2020 01:07:25 -0800 (PST) Date: Wed, 26 Feb 2020 04:07:24 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 22/30] libvhost-user: implement VHOST_USER_PROTOCOL_F_REPLY_ACK Message-ID: <20200226090010.708934-23-mst@redhat.com> References: <20200226090010.708934-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200226090010.708934-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Johannes Berg , Gerd Hoffmann , Stefan Hajnoczi , =?utf-8?q?Marc-Andr=C3=A9?= Lureau , Xie Yongji Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Johannes Berg This is really simple, since we know whether a response is already requested or not, so we can just send a (successful) response when there isn't one already. Given that, it's not all _that_ useful but the master can at least be sure the message was processed, and we can exercise more code paths using the example code. Reviewed-by: Stefan Hajnoczi Signed-off-by: Johannes Berg Message-Id: <20200123081708.7817-2-johannes@sipsolutions.net> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- contrib/libvhost-user/libvhost-user.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/contrib/libvhost-user/libvhost-user.c b/contrib/libvhost-user/libvhost-user.c index b89bf18501..533d55d82a 100644 --- a/contrib/libvhost-user/libvhost-user.c +++ b/contrib/libvhost-user/libvhost-user.c @@ -1199,7 +1199,8 @@ vu_get_protocol_features_exec(VuDev *dev, VhostUserMsg *vmsg) 1ULL << VHOST_USER_PROTOCOL_F_LOG_SHMFD | 1ULL << VHOST_USER_PROTOCOL_F_SLAVE_REQ | 1ULL << VHOST_USER_PROTOCOL_F_HOST_NOTIFIER | - 1ULL << VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD; + 1ULL << VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD | + 1ULL << VHOST_USER_PROTOCOL_F_REPLY_ACK; if (have_userfault()) { features |= 1ULL << VHOST_USER_PROTOCOL_F_PAGEFAULT; @@ -1581,13 +1582,20 @@ vu_dispatch(VuDev *dev) { VhostUserMsg vmsg = { 0, }; int reply_requested; - bool success = false; + bool need_reply, success = false; if (!vu_message_read(dev, dev->sock, &vmsg)) { goto end; } + need_reply = vmsg.flags & VHOST_USER_NEED_REPLY_MASK; + reply_requested = vu_process_message(dev, &vmsg); + if (!reply_requested && need_reply) { + vmsg_set_reply_u64(&vmsg, 0); + reply_requested = 1; + } + if (!reply_requested) { success = true; goto end;