From nobody Mon Feb 9 16:18:55 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578416199; cv=none; d=zohomail.com; s=zohoarc; b=iMTHlc/64ZPj12CiROZ9X8CmQSFuPhkuX/c25m2Gf6+v79pCCqy4CUK5IGPPkQ+Z1bFnx0CT3za1eIZuYOetBkgljn8t2W6zJgup2bvqLXJHpzBSCXkbMUqLl9k4tW6albTIi0VrpDb0WI9apOAdRGNR021H/PzHg/T0sUS+PXY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578416199; 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=51WDbq+PBwGZb4DLRjFJvXY/baMy4xbXgzhN6b6J6AM=; b=PuLJ83+jr7KzENSnEKd04H+tQjEBqMHzZ4eYDNiLX7fY6oDGkmyZD5Rq4cuu0F+WCXeTVZ3q5GnBBGITp23K89uzgNQCLHa7SYppptb3DaDzoy+srONgj8Fac7ZVNHRcjdvcMcRjWnY3CpExYKlkfey4s6NB05oDiVhioGxCK1Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1578416199680378.01136003077056; Tue, 7 Jan 2020 08:56:39 -0800 (PST) Received: from localhost ([::1]:53140 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ios9m-00046z-2u for importer@patchew.org; Tue, 07 Jan 2020 11:56:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46909) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iorlK-00087c-TU for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iorlJ-0005a1-Hp for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:22 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:30980 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iorlJ-0005Zs-EC for qemu-devel@nongnu.org; Tue, 07 Jan 2020 11:31:21 -0500 Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-105-llPQ_F3pNdGVWtCvFgerog-1; Tue, 07 Jan 2020 11:31:19 -0500 Received: by mail-qk1-f199.google.com with SMTP id a6so146781qkl.7 for ; Tue, 07 Jan 2020 08:31:19 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id k21sm86403qtp.92.2020.01.07.08.31.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 08:31:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578414681; 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=51WDbq+PBwGZb4DLRjFJvXY/baMy4xbXgzhN6b6J6AM=; b=HJ+cvGS68koGnjViu5vJkd3C0pa+xNEA4XyRdBJULnD1s97QjK8er9kH7HvCDpAaec/ZXw bg4yNbM9I6DQO9Ar3aWmVq/QMnlsStdfpDFmsqqxhS3Bbejv0hYfH17O+FGo9eVrH3PvKk vn8/082rag17yChSEDKEm99CKfSZOsI= 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=o8odu1UwTWT4bWPiNG9EYA27yURxcpg5mIlh0CMeiVA=; b=rTnw+N4+9XCcTawH/95c+6cCRw+1Iu2WbsgvxPsZFgXJyPZFHMKNUiwjhLkHNG0Nl5 acH8jSNVgx0BhgV9y/AzbBwnQfiajnlKawA9DcRFSdSms9r1TAkXkgHUXrkMhqaXrUWd rRcfP9LyTmL1w95wi519VYwWOZzF0gK+UZ1FN84meJPQjkVBxhqZX/AqEaanpgMAm30k 9ZtJElBVS/CLL8uCxanDxA0nX0KWA5K/3O83dVTlW0ojBlG+JQlhBu6plFpkNyCge7TS 13LNEYzKkr0ngscRjWwY3UIekE1ajuYl48XV1nsB/Ps2/08xNoJm81utqq1jOS8H34Zr rQlw== X-Gm-Message-State: APjAAAVzLLqAC27dWyY3i0G+I0GxmCQ+ez/tBZ4DHxo9Zaz9wSaKheyI R88o0jUxX1WhSan4fEeMc5IJDtpjNDYzobGCMIQJNncSSnByI7pyK271vpIHhBBvJ3ippkW4457 QDROPYUg0xVjmDcQ= X-Received: by 2002:a05:620a:1112:: with SMTP id o18mr156917qkk.126.1578414678526; Tue, 07 Jan 2020 08:31:18 -0800 (PST) X-Google-Smtp-Source: APXvYqxmywUj3AsUnzO3uXL9nzho3iWKp5JeLqWA/UAPzNxC2KFRx8VTRf6uKaHbHj3STvDbb80h8A== X-Received: by 2002:a05:620a:1112:: with SMTP id o18mr156894qkk.126.1578414678252; Tue, 07 Jan 2020 08:31:18 -0800 (PST) Date: Tue, 7 Jan 2020 11:31:14 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 23/32] vhost-user: add VHOST_USER_RESET_DEVICE to reset devices Message-ID: <20200107162850.411448-24-mst@redhat.com> References: <20200107162850.411448-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107162850.411448-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: llPQ_F3pNdGVWtCvFgerog-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable 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.81 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 , David Vrabel , Raphael Norwitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Raphael Norwitz Add a VHOST_USER_RESET_DEVICE message which will reset the vhost user backend. Disabling all rings, and resetting all internal state, ready for the backend to be reinitialized. A backend has to report it supports this features with the VHOST_USER_PROTOCOL_F_RESET_DEVICE protocol feature bit. If it does so, the new message is used instead of sending a RESET_OWNER which has had inconsistent implementations. Signed-off-by: David Vrabel Signed-off-by: Raphael Norwitz Message-Id: <1572385083-5254-2-git-send-email-raphael.norwitz@nutanix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-user.c | 8 +++++++- docs/interop/vhost-user.rst | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 02a9b25199..d27a10fcc6 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -58,6 +58,7 @@ enum VhostUserProtocolFeature { VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD =3D 10, VHOST_USER_PROTOCOL_F_HOST_NOTIFIER =3D 11, VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD =3D 12, + VHOST_USER_PROTOCOL_F_RESET_DEVICE =3D 13, VHOST_USER_PROTOCOL_F_MAX }; =20 @@ -98,6 +99,7 @@ typedef enum VhostUserRequest { VHOST_USER_GET_INFLIGHT_FD =3D 31, VHOST_USER_SET_INFLIGHT_FD =3D 32, VHOST_USER_GPU_SET_SOCKET =3D 33, + VHOST_USER_RESET_DEVICE =3D 34, VHOST_USER_MAX } VhostUserRequest; =20 @@ -890,10 +892,14 @@ static int vhost_user_set_owner(struct vhost_dev *dev) static int vhost_user_reset_device(struct vhost_dev *dev) { VhostUserMsg msg =3D { - .hdr.request =3D VHOST_USER_RESET_OWNER, .hdr.flags =3D VHOST_USER_VERSION, }; =20 + msg.hdr.request =3D virtio_has_feature(dev->protocol_features, + VHOST_USER_PROTOCOL_F_RESET_DEVIC= E) + ? VHOST_USER_RESET_DEVICE + : VHOST_USER_RESET_OWNER; + if (vhost_user_write(dev, &msg, NULL, 0) < 0) { return -1; } diff --git a/docs/interop/vhost-user.rst b/docs/interop/vhost-user.rst index 015ac08177..5f8b3a456b 100644 --- a/docs/interop/vhost-user.rst +++ b/docs/interop/vhost-user.rst @@ -785,6 +785,7 @@ Protocol features #define VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD 10 #define VHOST_USER_PROTOCOL_F_HOST_NOTIFIER 11 #define VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD 12 + #define VHOST_USER_PROTOCOL_F_RESET_DEVICE 13 =20 Master message types -------------------- @@ -1190,6 +1191,20 @@ Master message types ancillary data. The GPU protocol is used to inform the master of rendering state and updates. See vhost-user-gpu.rst for details. =20 +``VHOST_USER_RESET_DEVICE`` + :id: 34 + :equivalent ioctl: N/A + :master payload: N/A + :slave payload: N/A + + Ask the vhost user backend to disable all rings and reset all + internal device state to the initial state, ready to be + reinitialized. The backend retains ownership of the device + throughout the reset operation. + + Only valid if the ``VHOST_USER_PROTOCOL_F_RESET_DEVICE`` protocol + feature is set by the backend. + Slave message types ------------------- =20 --=20 MST