From nobody Thu May 16 01:06:01 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=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1711737581; cv=none; d=zohomail.com; s=zohoarc; b=CMdujnFvmywmzCxBiGG3uCov0m5AemTdgQJANudz0HkfLFKkslMgFtevIwx1xQ59SbTb6MX4hHQPNIUq0zQP7Eo1/XnPAYLZJI7/5eJguxFj+p/iTK9m9jSbErkKXpPi4LQMLuZlT3qQPZA7OYqSaGu2cU9rsUOvHlj7bicHkak= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1711737581; h=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=L5rxMwIIpGLyB14vljKNg1rTNtf+X2c73o7+H0OgEoQ=; b=IDBNy7rX6rGX78LdK4Snuey5yAGn/CzJEAkABnYbljbg9NLVmITvLuSKYm7jb39G/7GTWGmCVucObLkKwz1cBwOjHrxDLhwreOBN835weOOaYPRqJmUDBtc9NIUda++qzM1i5WrUW7uU5XWkUrZ1JU8F/uTSSgmkX7oJFcEGwkg= 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 1711737580973768.0472356331293; Fri, 29 Mar 2024 11:39:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rqH7c-0002mG-GK; Fri, 29 Mar 2024 14:38:36 -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 1rqH7a-0002l5-KN; Fri, 29 Mar 2024 14:38:34 -0400 Received: from forwardcorp1c.mail.yandex.net ([2a02:6b8:c03:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rqH7Y-0007Wq-Es; Fri, 29 Mar 2024 14:38:34 -0400 Received: from mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:5428:0:640:7351:0]) by forwardcorp1c.mail.yandex.net (Yandex) with ESMTPS id 6CF09609F5; Fri, 29 Mar 2024 21:38:27 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6b8:b081:6509::1:4]) by mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id 2cTaY94Id8c0-yenlzc7v; Fri, 29 Mar 2024 21:38:26 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1711737506; bh=L5rxMwIIpGLyB14vljKNg1rTNtf+X2c73o7+H0OgEoQ=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=XZgEPo5snfjEDtZ2w95y6sKMKtJyPJdCexvjd9E1Gr1ptc/iEdhi28yW46hZ87DyS bBqoghlASGDNjmL5eTQv5TyyktTp8C+jbrwGmX86zJWujpttLNqA3IDGrfYHp4GHEw rU4OcZEq4hvScBOQKAbBNF+hDGVaVpgNa6VS2QQ8= Authentication-Results: mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org, raphael@enfabrica.net, mst@redhat.com Cc: kwolf@redhat.com, hreitz@redhat.com, pbonzini@redhat.com, berrange@redhat.com, eduardo@habkost.net, armbru@redhat.com, dave@treblig.org, eblake@redhat.com, qemu-devel@nongnu.org, vsementsov@yandex-team.ru, yc-core@yandex-team.ru, Raphael Norwitz Subject: [PATCH v3 1/5] vhost-user-blk: simplify and fix vhost_user_blk_handle_config_change Date: Fri, 29 Mar 2024 21:37:54 +0300 Message-Id: <20240329183758.3360733-2-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240329183758.3360733-1-vsementsov@yandex-team.ru> References: <20240329183758.3360733-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a02:6b8:c03:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1c.mail.yandex.net 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, 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 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 @yandex-team.ru) X-ZM-MESSAGEID: 1711737582046100002 Content-Type: text/plain; charset="utf-8" Let's not care about what was changed and update the whole config, reasons: 1. config->geometry should be updated together with capacity, so we fix a bug. 2. Vhost-user protocol doesn't say anything about config change limitation. Silent ignore of changes doesn't seem to be correct. 3. vhost-user-vsock reads the whole config 4. on realize we don't do any checks on retrieved config, so no reason to care here Comment "valid for resize only" exists since introduction the whole hw/block/vhost-user-blk.c in commit 00343e4b54ba0685e9ebe928ec5713b0cf7f1d1c "vhost-user-blk: introduce a new vhost-user-blk host device", seems it was just an extra limitation. Also, let's notify guest unconditionally: 1. So does vhost-user-vsock 2. We are going to reuse the functionality in new cases when we do want to notify the guest unconditionally. So, no reason to create extra branches in the logic. Signed-off-by: Vladimir Sementsov-Ogievskiy Acked-by: Raphael Norwitz --- hw/block/vhost-user-blk.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 6a856ad51a..9e6bbc6950 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -91,7 +91,6 @@ static void vhost_user_blk_set_config(VirtIODevice *vdev,= const uint8_t *config) static int vhost_user_blk_handle_config_change(struct vhost_dev *dev) { int ret; - struct virtio_blk_config blkcfg; VirtIODevice *vdev =3D dev->vdev; VHostUserBlk *s =3D VHOST_USER_BLK(dev->vdev); Error *local_err =3D NULL; @@ -100,19 +99,15 @@ static int vhost_user_blk_handle_config_change(struct = vhost_dev *dev) return 0; } =20 - ret =3D vhost_dev_get_config(dev, (uint8_t *)&blkcfg, + ret =3D vhost_dev_get_config(dev, (uint8_t *)&s->blkcfg, vdev->config_len, &local_err); if (ret < 0) { error_report_err(local_err); return ret; } =20 - /* valid for resize only */ - if (blkcfg.capacity !=3D s->blkcfg.capacity) { - s->blkcfg.capacity =3D blkcfg.capacity; - memcpy(dev->vdev->config, &s->blkcfg, vdev->config_len); - virtio_notify_config(dev->vdev); - } + memcpy(dev->vdev->config, &s->blkcfg, vdev->config_len); + virtio_notify_config(dev->vdev); =20 return 0; } --=20 2.34.1 From nobody Thu May 16 01:06:01 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=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1711737581; cv=none; d=zohomail.com; s=zohoarc; b=gOzhM3kvYrJpFrV15jSr8wr2qNWwOWUfBRWF3qymIm3n+CoBs5BYTlb690Gbb7isVRZaQUNSS+NRLAbDYKJ0aAqFgmLYnW0B0jMxjdoQOfdGeLn0nJ04gpzIbko/479NFH4a8itFOIJVtjr30CLUu+aFh2cfCzPvGfB0nXUhRQk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1711737581; h=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=7EzT71LTq/DekEyu4R1Kcwva3Cde8YCH520nF993tAg=; b=ftc4M8wf2wVvO+1gjtuVg2/1wtKM75KefyVGrMvFK99Alg1wc0lKFsiKFpkU4Jt8A3DAzSOptMbQWlFBqeNRIRD5uMYQXowGwNYJa9Wshhd1XqSQ7O//5yx2ufKfcRNvbhxYD8sLZQiCz2I55reZ5fP9GkWFzFpBtskmXfoh1Ko= 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 1711737581059186.12966661260634; Fri, 29 Mar 2024 11:39:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rqH7e-0002ne-7i; Fri, 29 Mar 2024 14:38:38 -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 1rqH7b-0002li-Pv; Fri, 29 Mar 2024 14:38:35 -0400 Received: from forwardcorp1c.mail.yandex.net ([178.154.239.200]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rqH7Y-0007Wr-NZ; Fri, 29 Mar 2024 14:38:35 -0400 Received: from mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:5428:0:640:7351:0]) by forwardcorp1c.mail.yandex.net (Yandex) with ESMTPS id 7AAD760A1E; Fri, 29 Mar 2024 21:38:28 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6b8:b081:6509::1:4]) by mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id 2cTaY94Id8c0-ygA45I9e; Fri, 29 Mar 2024 21:38:27 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1711737507; bh=7EzT71LTq/DekEyu4R1Kcwva3Cde8YCH520nF993tAg=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=x8NHxv+JdEhdeUdr/ePcFUygQMmtqZoZOy4T+yn3tx0JInF6J1a+eqo7aSaOJ2YOt lcOBugwPu+3SZfk0SD3QNiskNqrcUkOKal04cO1aaBNR//UpRmeikDK1F+wlDnEd4E ygnsHbZ5UvFgjsDyxaEV+Bq8IAn/JKzZQ6HdVWbY= Authentication-Results: mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org, raphael@enfabrica.net, mst@redhat.com Cc: kwolf@redhat.com, hreitz@redhat.com, pbonzini@redhat.com, berrange@redhat.com, eduardo@habkost.net, armbru@redhat.com, dave@treblig.org, eblake@redhat.com, qemu-devel@nongnu.org, vsementsov@yandex-team.ru, yc-core@yandex-team.ru Subject: [PATCH v3 2/5] qdev-monitor: fix error message in find_device_state() Date: Fri, 29 Mar 2024 21:37:55 +0300 Message-Id: <20240329183758.3360733-3-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240329183758.3360733-1-vsementsov@yandex-team.ru> References: <20240329183758.3360733-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=178.154.239.200; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1c.mail.yandex.net 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, 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 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 @yandex-team.ru) X-ZM-MESSAGEID: 1711737582035100001 Content-Type: text/plain; charset="utf-8" This "hotpluggable" here is misleading. Actually we check is object a device or not. Let's drop the word. Suggested-by: Markus Armbruster Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Markus Armbruster --- system/qdev-monitor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c index c1243891c3..840177d19f 100644 --- a/system/qdev-monitor.c +++ b/system/qdev-monitor.c @@ -891,7 +891,7 @@ static DeviceState *find_device_state(const char *id, E= rror **errp) =20 dev =3D (DeviceState *)object_dynamic_cast(obj, TYPE_DEVICE); if (!dev) { - error_setg(errp, "%s is not a hotpluggable device", id); + error_setg(errp, "%s is not a device", id); return NULL; } =20 --=20 2.34.1 From nobody Thu May 16 01:06:01 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=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1711737592; cv=none; d=zohomail.com; s=zohoarc; b=JYsYsppZIXE653NqycNUCkVMdiDcVIdO1NYWO8bV+4e7/F82uTRJlB9BGoF8MpeVeqS9hOKTbkUZ9D3iTgZ5/zI/ABWtG8cVWRnXjvBKW/gH24CpClJwjaQO0E1Tmk2fnbyhwb6h7TK44tzabpfcLu47RlNzEiqZnmVWJvqg34U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1711737592; h=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=dkAh7R9NLEfQKIK4Kt7lmSuiosgYWtpMTO9GN4dgGG4=; b=aIYh/TnAuI5wLckzEgyB2bWQcoKyFzh9wqn619IJOXrdawiZ8Sh74+nBtMdfkVSAvjgdz3tCdG4bmTomk3ojMxZYjRa4IyPkRo4/Gcc4wh+4fCUMEPiPT6jJUWe2yKTPdSpVD6BdXYXS0jxdl0oCknQOHEib/zONAMydkX/f+R4= 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 1711737592931732.167358133207; Fri, 29 Mar 2024 11:39:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rqH7e-0002o6-RM; Fri, 29 Mar 2024 14:38:38 -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 1rqH7b-0002lk-Sw; Fri, 29 Mar 2024 14:38:35 -0400 Received: from forwardcorp1c.mail.yandex.net ([178.154.239.200]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rqH7Y-0007X0-Nz; Fri, 29 Mar 2024 14:38:35 -0400 Received: from mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:5428:0:640:7351:0]) by forwardcorp1c.mail.yandex.net (Yandex) with ESMTPS id 53B3660A20; Fri, 29 Mar 2024 21:38:29 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6b8:b081:6509::1:4]) by mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id 2cTaY94Id8c0-ERZcZxeb; Fri, 29 Mar 2024 21:38:28 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1711737508; bh=dkAh7R9NLEfQKIK4Kt7lmSuiosgYWtpMTO9GN4dgGG4=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=NrEY8Gxgkk0QbJvVurYFvbe4Y44JvcPbTmVfNwAMWe/3eUZJARODPIQuX836vATKd RTk7JvAuDJypnnc/NW3YIN1NvxYohisWfYxN4QCAOH0sOOMdAahYMajbYq1DjKUbx5 VrMSpAsHf64Ufm+0yHI4/o5lPDsgIZq8+oVF56vk= Authentication-Results: mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org, raphael@enfabrica.net, mst@redhat.com Cc: kwolf@redhat.com, hreitz@redhat.com, pbonzini@redhat.com, berrange@redhat.com, eduardo@habkost.net, armbru@redhat.com, dave@treblig.org, eblake@redhat.com, qemu-devel@nongnu.org, vsementsov@yandex-team.ru, yc-core@yandex-team.ru Subject: [PATCH v3 3/5] qdev-monitor: add option to report GenericError from find_device_state Date: Fri, 29 Mar 2024 21:37:56 +0300 Message-Id: <20240329183758.3360733-4-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240329183758.3360733-1-vsementsov@yandex-team.ru> References: <20240329183758.3360733-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=178.154.239.200; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1c.mail.yandex.net 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, 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 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 @yandex-team.ru) X-ZM-MESSAGEID: 1711737593505100001 Content-Type: text/plain; charset="utf-8" Here we just prepare for the following patch, making possible to report GenericError as recommended. This patch doesn't aim to prevent further use of DeviceNotFound by future interfaces: - find_device_state() is used in blk_by_qdev_id() and qmp_get_blk() functions, which may lead to spread of DeviceNotFound anyway - also, nothing prevent simply copy-pasting find_device_state() calls with false argument Signed-off-by: Vladimir Sementsov-Ogievskiy --- system/qdev-monitor.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c index 840177d19f..7e075d91c1 100644 --- a/system/qdev-monitor.c +++ b/system/qdev-monitor.c @@ -878,13 +878,20 @@ void qmp_device_add(QDict *qdict, QObject **ret_data,= Error **errp) object_unref(OBJECT(dev)); } =20 -static DeviceState *find_device_state(const char *id, Error **errp) +/* + * Note that creating new APIs using error classes other than GenericError= is + * not recommended. Set use_generic_error=3Dtrue for new interfaces. + */ +static DeviceState *find_device_state(const char *id, bool use_generic_err= or, + Error **errp) { Object *obj =3D object_resolve_path_at(qdev_get_peripheral(), id); DeviceState *dev; =20 if (!obj) { - error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, + error_set(errp, + (use_generic_error ? + ERROR_CLASS_GENERIC_ERROR : ERROR_CLASS_DEVICE_NOT_FOUN= D), "Device '%s' not found", id); return NULL; } @@ -948,7 +955,7 @@ void qdev_unplug(DeviceState *dev, Error **errp) =20 void qmp_device_del(const char *id, Error **errp) { - DeviceState *dev =3D find_device_state(id, errp); + DeviceState *dev =3D find_device_state(id, false, errp); if (dev !=3D NULL) { if (dev->pending_deleted_event && (dev->pending_deleted_expires_ms =3D=3D 0 || @@ -1068,7 +1075,7 @@ BlockBackend *blk_by_qdev_id(const char *id, Error **= errp) =20 GLOBAL_STATE_CODE(); =20 - dev =3D find_device_state(id, errp); + dev =3D find_device_state(id, false, errp); if (dev =3D=3D NULL) { return NULL; } --=20 2.34.1 From nobody Thu May 16 01:06:01 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=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1711737596; cv=none; d=zohomail.com; s=zohoarc; b=JocGJVRdE+GENVDXSRYgHF0vBp8pgWVd+NyMhwcSJgXjKcpm66aiPI5jdbukUl2gM5pAV5HqDKkvt+nexDTu3glP54WUJuEk5oathf8LiFJvNBmkqyGPfUo0ctfKB6zsHwp2Xmo5tuesbViwhhFDv5fgtZWUoaUgBumG7lbbt5U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1711737596; h=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=YrCNM/esx2ItwVi57BFApSXbvJb7UknYXWMFwczrP7Q=; b=d1j21bGMu5hu1pQn2tzBacEh5hrYPXQjoUz/qoET35Je3NIqb6+nUCcWiDBQzY4qsVgQRUz4c8B2jUoMlsXePVIDHSjnOPrhmhuFCY+1xfNtZA/49AqMuTBj09hyU07Inv8FX4QHIkchLhBtaap/mvFwgVL6RyHDTQ9l0UkQLNM= 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 1711737596953798.3731545921328; Fri, 29 Mar 2024 11:39:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rqH7f-0002oj-KD; Fri, 29 Mar 2024 14:38:39 -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 1rqH7d-0002nM-Eq; Fri, 29 Mar 2024 14:38:37 -0400 Received: from forwardcorp1b.mail.yandex.net ([2a02:6b8:c02:900:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rqH7Z-0007XL-Aj; Fri, 29 Mar 2024 14:38:37 -0400 Received: from mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:5428:0:640:7351:0]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTPS id 9742E608F2; Fri, 29 Mar 2024 21:38:30 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6b8:b081:6509::1:4]) by mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id 2cTaY94Id8c0-2BqLNsDV; Fri, 29 Mar 2024 21:38:29 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1711737509; bh=YrCNM/esx2ItwVi57BFApSXbvJb7UknYXWMFwczrP7Q=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=p0epRlRHnCIAi0nuXYEdOuirOaw49nYHLoT+RPIndEjpPZBr88JPQliRYmpEw2Qyl HevxrZMnPYjXtoywguWX8WVdze3ePfsCvhgj+HesPOorfHOboDURU1IAmpbF5w+UrY YafUmI7di/fKWg8BHn3zlVc2rs8qP1BQH20uRf/w= Authentication-Results: mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org, raphael@enfabrica.net, mst@redhat.com Cc: kwolf@redhat.com, hreitz@redhat.com, pbonzini@redhat.com, berrange@redhat.com, eduardo@habkost.net, armbru@redhat.com, dave@treblig.org, eblake@redhat.com, qemu-devel@nongnu.org, vsementsov@yandex-team.ru, yc-core@yandex-team.ru Subject: [PATCH v3 4/5] qapi: introduce device-sync-config Date: Fri, 29 Mar 2024 21:37:57 +0300 Message-Id: <20240329183758.3360733-5-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240329183758.3360733-1-vsementsov@yandex-team.ru> References: <20240329183758.3360733-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a02:6b8:c02:900:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1b.mail.yandex.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, 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 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 @yandex-team.ru) X-ZM-MESSAGEID: 1711737597743100001 Content-Type: text/plain; charset="utf-8" Add command to sync config from vhost-user backend to the device. It may be helpful when VHOST_USER_SLAVE_CONFIG_CHANGE_MSG failed or not triggered interrupt to the guest or just not available (not supported by vhost-user server). Command result is racy if allow it during migration. Let's allow the sync only in RUNNING state. Signed-off-by: Vladimir Sementsov-Ogievskiy --- hw/block/vhost-user-blk.c | 27 ++++++++++++++++------ hw/virtio/virtio-pci.c | 9 ++++++++ include/hw/qdev-core.h | 3 +++ include/sysemu/runstate.h | 1 + qapi/qdev.json | 21 +++++++++++++++++ system/qdev-monitor.c | 47 +++++++++++++++++++++++++++++++++++++++ system/runstate.c | 5 +++++ 7 files changed, 106 insertions(+), 7 deletions(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 9e6bbc6950..2f301f380c 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -88,27 +88,39 @@ static void vhost_user_blk_set_config(VirtIODevice *vde= v, const uint8_t *config) s->blkcfg.wce =3D blkcfg->wce; } =20 +static int vhost_user_blk_sync_config(DeviceState *dev, Error **errp) +{ + int ret; + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VHostUserBlk *s =3D VHOST_USER_BLK(vdev); + + ret =3D vhost_dev_get_config(&s->dev, (uint8_t *)&s->blkcfg, + vdev->config_len, errp); + if (ret < 0) { + return ret; + } + + memcpy(vdev->config, &s->blkcfg, vdev->config_len); + virtio_notify_config(vdev); + + return 0; +} + static int vhost_user_blk_handle_config_change(struct vhost_dev *dev) { int ret; - VirtIODevice *vdev =3D dev->vdev; - VHostUserBlk *s =3D VHOST_USER_BLK(dev->vdev); Error *local_err =3D NULL; =20 if (!dev->started) { return 0; } =20 - ret =3D vhost_dev_get_config(dev, (uint8_t *)&s->blkcfg, - vdev->config_len, &local_err); + ret =3D vhost_user_blk_sync_config(DEVICE(dev->vdev), &local_err); if (ret < 0) { error_report_err(local_err); return ret; } =20 - memcpy(dev->vdev->config, &s->blkcfg, vdev->config_len); - virtio_notify_config(dev->vdev); - return 0; } =20 @@ -576,6 +588,7 @@ static void vhost_user_blk_class_init(ObjectClass *klas= s, void *data) =20 device_class_set_props(dc, vhost_user_blk_properties); dc->vmsd =3D &vmstate_vhost_user_blk; + dc->sync_config =3D vhost_user_blk_sync_config; set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); vdc->realize =3D vhost_user_blk_device_realize; vdc->unrealize =3D vhost_user_blk_device_unrealize; diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index eaaf86402c..92afbae71c 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -2501,6 +2501,14 @@ static void virtio_pci_dc_realize(DeviceState *qdev,= Error **errp) vpciklass->parent_dc_realize(qdev, errp); } =20 +static int virtio_pci_sync_config(DeviceState *dev, Error **errp) +{ + VirtIOPCIProxy *proxy =3D VIRTIO_PCI(dev); + VirtIODevice *vdev =3D virtio_bus_get_device(&proxy->bus); + + return qdev_sync_config(DEVICE(vdev), errp); +} + static void virtio_pci_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); @@ -2517,6 +2525,7 @@ static void virtio_pci_class_init(ObjectClass *klass,= void *data) device_class_set_parent_realize(dc, virtio_pci_dc_realize, &vpciklass->parent_dc_realize); rc->phases.hold =3D virtio_pci_bus_reset_hold; + dc->sync_config =3D virtio_pci_sync_config; } =20 static const TypeInfo virtio_pci_info =3D { diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 9228e96c87..87135bdcdf 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -95,6 +95,7 @@ typedef void (*DeviceUnrealize)(DeviceState *dev); typedef void (*DeviceReset)(DeviceState *dev); typedef void (*BusRealize)(BusState *bus, Error **errp); typedef void (*BusUnrealize)(BusState *bus); +typedef int (*DeviceSyncConfig)(DeviceState *dev, Error **errp); =20 /** * struct DeviceClass - The base class for all devices. @@ -162,6 +163,7 @@ struct DeviceClass { DeviceReset reset; DeviceRealize realize; DeviceUnrealize unrealize; + DeviceSyncConfig sync_config; =20 /** * @vmsd: device state serialisation description for @@ -546,6 +548,7 @@ bool qdev_hotplug_allowed(DeviceState *dev, Error **err= p); */ HotplugHandler *qdev_get_hotplug_handler(DeviceState *dev); void qdev_unplug(DeviceState *dev, Error **errp); +int qdev_sync_config(DeviceState *dev, Error **errp); void qdev_simple_device_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp); void qdev_machine_creation_done(void); diff --git a/include/sysemu/runstate.h b/include/sysemu/runstate.h index 0117d243c4..296af52322 100644 --- a/include/sysemu/runstate.h +++ b/include/sysemu/runstate.h @@ -5,6 +5,7 @@ #include "qemu/notify.h" =20 bool runstate_check(RunState state); +const char *current_run_state_str(void); void runstate_set(RunState new_state); RunState runstate_get(void); bool runstate_is_running(void); diff --git a/qapi/qdev.json b/qapi/qdev.json index facaa0bc6a..e8be79c3d5 100644 --- a/qapi/qdev.json +++ b/qapi/qdev.json @@ -161,3 +161,24 @@ ## { 'event': 'DEVICE_UNPLUG_GUEST_ERROR', 'data': { '*device': 'str', 'path': 'str' } } + +## +# @device-sync-config: +# +# Synchronize config from backend to the guest. The command notifies +# re-read the device config from the backend and notifies the guest +# to re-read the config. The command may be used to notify the guest +# about block device capcity change. Currently only vhost-user-blk +# device supports this. +# +# @id: the device's ID or QOM path +# +# Features: +# +# @unstable: The command is experimental. +# +# Since: 9.1 +## +{ 'command': 'device-sync-config', + 'features': [ 'unstable' ], + 'data': {'id': 'str'} } diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c index 7e075d91c1..cb35ea0b86 100644 --- a/system/qdev-monitor.c +++ b/system/qdev-monitor.c @@ -23,6 +23,7 @@ #include "monitor/monitor.h" #include "monitor/qdev.h" #include "sysemu/arch_init.h" +#include "sysemu/runstate.h" #include "qapi/error.h" #include "qapi/qapi-commands-qdev.h" #include "qapi/qmp/dispatch.h" @@ -969,6 +970,52 @@ void qmp_device_del(const char *id, Error **errp) } } =20 +int qdev_sync_config(DeviceState *dev, Error **errp) +{ + DeviceClass *dc =3D DEVICE_GET_CLASS(dev); + + if (!dc->sync_config) { + error_setg(errp, "device-sync-config is not supported for '%s'", + object_get_typename(OBJECT(dev))); + return -ENOTSUP; + } + + return dc->sync_config(dev, errp); +} + +void qmp_device_sync_config(const char *id, Error **errp) +{ + DeviceState *dev; + + /* + * During migration there is a race between syncing`config and + * migrating it, so let's just not allow it. + * + * Moreover, let's not rely on setting up interrupts in paused + * state, which may be a part of migration process. + */ + + if (migration_is_running()) { + error_setg(errp, "Config synchronization is not allowed " + "during migration."); + return; + } + + if (!runstate_is_running()) { + error_setg(errp, "Config synchronization allowed only in '%s' stat= e, " + "current state is '%s'", RunState_str(RUN_STATE_RUNNING= ), + current_run_state_str()); + return; + } + + dev =3D find_device_state(id, true, errp); + if (!dev) { + return; + } + + qdev_sync_config(dev, errp); +} + void hmp_device_add(Monitor *mon, const QDict *qdict) { Error *err =3D NULL; diff --git a/system/runstate.c b/system/runstate.c index d6ab860eca..8fd89172ae 100644 --- a/system/runstate.c +++ b/system/runstate.c @@ -189,6 +189,11 @@ bool runstate_check(RunState state) return current_run_state =3D=3D state; } =20 +const char *current_run_state_str(void) +{ + return RunState_str(current_run_state); +} + static void runstate_init(void) { const RunStateTransition *p; --=20 2.34.1 From nobody Thu May 16 01:06:01 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=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1711737593; cv=none; d=zohomail.com; s=zohoarc; b=em/sLCQ25MdOL4UDMpSmQk3NfLSWry4f5ynobw84qLVG56OTxjIHycp+p0tItARFtr66YBliv4EJE2vntmwBNFkIvICzczk98WSBo3/cKLNp4HDX1VROgNQ7Od2MflcFd8GszL1h9MRz4CZ0Qaq7//u7isVKbJIXpPsXspQFhbk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1711737593; h=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=rodd4cQDXNKTVi2PJTr9ctB4hME9Du9Rm9xT/9Dmhc8=; b=HiISspBFx9yhhEBUyuQa0dhcECbSfFJU3OgSVBg95IGj5ONNHEXZ0YmrO7QhVMaTFjFIC+AaejIJer97G6RzQ44pgL+6UPpsXV51P1cLyc5V3Wbh+VPEds0qCnDfAL84/tma1yAoxpCCxRQrt4gSA9zG5mBRTsbqNUwk5dyoyYA= 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 1711737593524496.55566428733084; Fri, 29 Mar 2024 11:39:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rqH7f-0002oW-Fz; Fri, 29 Mar 2024 14:38:39 -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 1rqH7c-0002mB-43; Fri, 29 Mar 2024 14:38:36 -0400 Received: from forwardcorp1c.mail.yandex.net ([2a02:6b8:c03:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rqH7Z-0007XQ-44; Fri, 29 Mar 2024 14:38:35 -0400 Received: from mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:5428:0:640:7351:0]) by forwardcorp1c.mail.yandex.net (Yandex) with ESMTPS id 858D760A0A; Fri, 29 Mar 2024 21:38:31 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6b8:b081:6509::1:4]) by mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id 2cTaY94Id8c0-N12gIxfX; Fri, 29 Mar 2024 21:38:30 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1711737510; bh=rodd4cQDXNKTVi2PJTr9ctB4hME9Du9Rm9xT/9Dmhc8=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=H9zqhEeeukl+8mM0lSHxakJzRp67Hd2Ln9KE9ivlqqY1ftA9UCMTnc6WrvSrNR08o EQpOSq0dZOJthH8jbzTL86Wf3co5ttp8g1WdFmEaSFsmy0EP40tA8LiZEiWTWJVGnC Ely50HS2jC9C751XU1fdxY9ssJ9BgADKEb8hJdSo= Authentication-Results: mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org, raphael@enfabrica.net, mst@redhat.com Cc: kwolf@redhat.com, hreitz@redhat.com, pbonzini@redhat.com, berrange@redhat.com, eduardo@habkost.net, armbru@redhat.com, dave@treblig.org, eblake@redhat.com, qemu-devel@nongnu.org, vsementsov@yandex-team.ru, yc-core@yandex-team.ru Subject: [PATCH v3 5/5] qapi: introduce CONFIG_READ event Date: Fri, 29 Mar 2024 21:37:58 +0300 Message-Id: <20240329183758.3360733-6-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240329183758.3360733-1-vsementsov@yandex-team.ru> References: <20240329183758.3360733-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a02:6b8:c03:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1c.mail.yandex.net 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, 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 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 @yandex-team.ru) X-ZM-MESSAGEID: 1711737595533100007 Content-Type: text/plain; charset="utf-8" Send a new event when guest reads virtio-pci config after virtio_notify_config() call. That's useful to check that guest fetched modified config, for example after resizing disk backend. Signed-off-by: Vladimir Sementsov-Ogievskiy --- hw/virtio/virtio-pci.c | 9 +++++++++ include/monitor/qdev.h | 2 ++ monitor/monitor.c | 1 + qapi/qdev.json | 33 +++++++++++++++++++++++++++++++++ stubs/qdev.c | 6 ++++++ system/qdev-monitor.c | 6 ++++++ 6 files changed, 57 insertions(+) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 92afbae71c..c0c158dae2 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -23,6 +23,7 @@ #include "hw/boards.h" #include "hw/virtio/virtio.h" #include "migration/qemu-file-types.h" +#include "monitor/qdev.h" #include "hw/pci/pci.h" #include "hw/pci/pci_bus.h" #include "hw/qdev-properties.h" @@ -530,6 +531,10 @@ static uint64_t virtio_pci_config_read(void *opaque, h= waddr addr, } addr -=3D config; =20 + if (vdev->generation > 0) { + qdev_virtio_config_read_event(DEVICE(proxy)); + } + switch (size) { case 1: val =3D virtio_config_readb(vdev, addr); @@ -1884,6 +1889,10 @@ static uint64_t virtio_pci_device_read(void *opaque,= hwaddr addr, return UINT64_MAX; } =20 + if (vdev->generation > 0) { + qdev_virtio_config_read_event(DEVICE(proxy)); + } + switch (size) { case 1: val =3D virtio_config_modern_readb(vdev, addr); diff --git a/include/monitor/qdev.h b/include/monitor/qdev.h index 1d57bf6577..fc9a834dca 100644 --- a/include/monitor/qdev.h +++ b/include/monitor/qdev.h @@ -36,4 +36,6 @@ DeviceState *qdev_device_add_from_qdict(const QDict *opts, */ const char *qdev_set_id(DeviceState *dev, char *id, Error **errp); =20 +void qdev_virtio_config_read_event(DeviceState *dev); + #endif diff --git a/monitor/monitor.c b/monitor/monitor.c index 01ede1babd..5b06146503 100644 --- a/monitor/monitor.c +++ b/monitor/monitor.c @@ -316,6 +316,7 @@ static MonitorQAPIEventConf monitor_qapi_event_conf[QAP= I_EVENT__MAX] =3D { [QAPI_EVENT_VSERPORT_CHANGE] =3D { 1000 * SCALE_MS }, [QAPI_EVENT_MEMORY_DEVICE_SIZE_CHANGE] =3D { 1000 * SCALE_MS }, [QAPI_EVENT_HV_BALLOON_STATUS_REPORT] =3D { 1000 * SCALE_MS }, + [QAPI_EVENT_VIRTIO_CONFIG_READ] =3D { 300 * SCALE_MS }, }; =20 /* diff --git a/qapi/qdev.json b/qapi/qdev.json index e8be79c3d5..29a4f47360 100644 --- a/qapi/qdev.json +++ b/qapi/qdev.json @@ -182,3 +182,36 @@ { 'command': 'device-sync-config', 'features': [ 'unstable' ], 'data': {'id': 'str'} } + +## +# @VIRTIO_CONFIG_READ: +# +# Emitted whenever guest reads virtio device configuration after +# configuration change. +# +# The event may be used in pair with device-sync-config. It shows +# that guest has re-read updated configuration. It doesn't +# guarantee that guest successfully handled it and updated the +# view of the device for the user, but still it's a kind of +# success indicator. +# +# @device: device name +# +# @path: device path +# +# Features: +# +# @unstable: The event is experimental. +# +# Since: 9.1 +# +# Example: +# +# <- { "event": "VIRTIO_CONFIG_READ", +# "data": { "device": "virtio-net-pci-0", +# "path": "/machine/peripheral/virtio-net-pci-0" }, +# "timestamp": { "seconds": 1265044230, "microseconds": 450486 } } +## +{ 'event': 'VIRTIO_CONFIG_READ', + 'features': [ 'unstable' ], + 'data': { '*device': 'str', 'path': 'str' } } diff --git a/stubs/qdev.c b/stubs/qdev.c index 6869f6f90a..ab6c4afe0b 100644 --- a/stubs/qdev.c +++ b/stubs/qdev.c @@ -26,3 +26,9 @@ void qapi_event_send_device_unplug_guest_error(const char= *device, { /* Nothing to do. */ } + +void qapi_event_send_virtio_config_read(const char *device, + const char *path) +{ + /* Nothing to do. */ +} diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c index cb35ea0b86..8a2ca77fde 100644 --- a/system/qdev-monitor.c +++ b/system/qdev-monitor.c @@ -26,6 +26,7 @@ #include "sysemu/runstate.h" #include "qapi/error.h" #include "qapi/qapi-commands-qdev.h" +#include "qapi/qapi-events-qdev.h" #include "qapi/qmp/dispatch.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qerror.h" @@ -1206,3 +1207,8 @@ bool qmp_command_available(const QmpCommand *cmd, Err= or **errp) } return true; } + +void qdev_virtio_config_read_event(DeviceState *dev) +{ + qapi_event_send_virtio_config_read(dev->id, dev->canonical_path); +} --=20 2.34.1