From patchwork Thu Jan 5 09:15:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 639245 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp130718pvb; Thu, 5 Jan 2023 01:25:21 -0800 (PST) X-Google-Smtp-Source: AMrXdXuiSH8quRytqtjGUHn+WxcSTY7Klb+OJXyZBghU4WTn735Ja3wNfxm+1r8NxwoJ41wtgYJ7 X-Received: by 2002:ac8:73c3:0:b0:3a5:c851:29ff with SMTP id v3-20020ac873c3000000b003a5c85129ffmr72154834qtp.23.1672910721628; Thu, 05 Jan 2023 01:25:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672910721; cv=none; d=google.com; s=arc-20160816; b=iFFBqbvpgbTagII+hh4GYvCxzG1M1jrOfWMLF09w+rAzW2jhl4uL0w5G4gNyOC1D3M LqWpLYfBzwcRV7m5NqE+VcPM6xv5NX85yrydILwd+Eagd+1rwZExgIeK+LhfJKNEaycj LIhLe5X6DiKde5ZT3RkXRf+ycS9XuNOqGGRt4bFTpn7k8sLEQ+t9OTysspYgZTTrFLSf vr6IpdI+taIYaiZ0TtKoPr9cuF6cXBOD2zamZPJmpjpw5TrxW5larGKNuyhjesd/bA5U shJUyb+782ZpO3WSE5FGXHnGS2StWfX26jJhlDERp5zAqguHvFn2JhatHAShoDRG8v2U zn6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=gyeI9n00srHT95Wf05HcVdwfoBiIPp7caNy4o1qIx1E=; b=MYEQAs37Bilb+nFEwSXamqab7AHpnn/JHdTAqk/gundz9UCsbzPhJThcrpXQ/fYN7y OkPgox9K5GRTYIth9T6xS+Zi/3tn/1UdfGuavLkoFMNlvi5O8NDRi+NosWFDM69sgpRQ y2qEF1L0ECz+fFY5kmmznidjZgtVTa4d76wFyuDl/Crme22hIbKW1ukJA20fEu6p0aLE Oq5DdXxh9+v+6RnsJuXxkg7/4+9V0etIXd7Ac8spOg8FY/i6IHECznOXnmeMHQR0vkIZ ukWs44JxTicmVhNDT9DzCW5gR9HxnW1qGJ0His5BnVqsTnscuWpJbIw+1ZoyOk4UKYmt cGpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="CNlSQq/r"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id cr16-20020a05622a429000b003abbc0ba92esi5624271qtb.31.2023.01.05.01.25.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 05 Jan 2023 01:25:21 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="CNlSQq/r"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pDMLo-0002cg-FF; Thu, 05 Jan 2023 04:15:52 -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 1pDMLf-0002PP-Eq for qemu-devel@nongnu.org; Thu, 05 Jan 2023 04:15:43 -0500 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 1pDMLd-0007Ax-Ut for qemu-devel@nongnu.org; Thu, 05 Jan 2023 04:15:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672910141; 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=gyeI9n00srHT95Wf05HcVdwfoBiIPp7caNy4o1qIx1E=; b=CNlSQq/rwIm+sbeB+8c0d6bprV9b6sf9AeBJa4ptyd38QizEC5NnY6m+eTY+GUyrImDown +Xb4xqGShTz4b5OVEmbT1iBfQ1vlmEtC8gjRxf76h/TVvUDT6cfEgL/Ueos49vjwbLkPO4 9rYGc3Yy5JG3XVCYDLKKKo8Pxt5l/K8= 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_128_GCM_SHA256) id us-mta-246-NzLio1BAMIqyk9l9lA8vtA-1; Thu, 05 Jan 2023 04:15:39 -0500 X-MC-Unique: NzLio1BAMIqyk9l9lA8vtA-1 Received: by mail-wr1-f69.google.com with SMTP id o14-20020adfa10e000000b002631c56fe26so4630492wro.1 for ; Thu, 05 Jan 2023 01:15:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=gyeI9n00srHT95Wf05HcVdwfoBiIPp7caNy4o1qIx1E=; b=0PWtCBvRPC3ehh5TI30sE/XlcBuXlOde98+F5Zov/RBtd5I97gDpbPcLc7mA9Hp5M9 4Cvp+nSgBLUuLYnkxdgSEbdI8KL9W3GR5mhprYAtvRMtV4dpyb6jJglfNQGDe5Xby0h6 Eh1yhPCKmwHB4HUOXlfpNfkbUzFMBCZxvSiBf0+MG1QbvcUZFkyebz1M3TLBCan8GNum vOsG4oIt/B4DRuB3+BstD22HwXxaOXmIFsCmU/hQP4HRVuR2iw6M3EFPDSvU/JUFHX3e kk5EoVM5N73xoWoKRNk80clrbdw5EhXS5miuHDnUE8ibbEa8T9foCTPzIKS6/wraXCD5 lHrw== X-Gm-Message-State: AFqh2kpou8dCSntvUd3vhUQ8muWNZ+uHJVCbwxO7h4+00efAbBsec7e7 CSZe0xI1vhXc3NGobbmP07K9rBHl6dRaH2osrgbTOgAS28OrWbspouGM18NFg9u8oNkmjYOVUAF JNakqMI1fVit5RwbS3R9ljt3Ip6DiinoHV35l9JQ0/LSY/SQX5vrtw/iYT/rT X-Received: by 2002:a05:600c:4f55:b0:3cf:7197:e67c with SMTP id m21-20020a05600c4f5500b003cf7197e67cmr34440618wmq.25.1672910138227; Thu, 05 Jan 2023 01:15:38 -0800 (PST) X-Received: by 2002:a05:600c:4f55:b0:3cf:7197:e67c with SMTP id m21-20020a05600c4f5500b003cf7197e67cmr34440605wmq.25.1672910137952; Thu, 05 Jan 2023 01:15:37 -0800 (PST) Received: from redhat.com ([2.52.151.85]) by smtp.gmail.com with ESMTPSA id v16-20020a05600c445000b003c6c3fb3cf6sm1860155wmn.18.2023.01.05.01.15.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Jan 2023 01:15:37 -0800 (PST) Date: Thu, 5 Jan 2023 04:15:35 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Philippe =?utf-8?q?Mathieu-Dau?= =?utf-8?q?d=C3=A9?= Subject: [PULL 25/51] hw/virtio: Rename virtio_device_find() -> qmp_find_virtio_device() Message-ID: <20230105091310.263867-26-mst@redhat.com> References: <20230105091310.263867-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230105091310.263867-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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_H2=-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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Philippe Mathieu-Daudé To emphasize this function is QMP related, rename it. Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20221222080005.27616-2-philmd@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 6ff797e1cf..e08443e3bf 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -3855,7 +3855,7 @@ VirtioInfoList *qmp_x_query_virtio(Error **errp) return list; } -static VirtIODevice *virtio_device_find(const char *path) +static VirtIODevice *qmp_find_virtio_device(const char *path) { VirtIODevice *vdev; @@ -3896,7 +3896,7 @@ VirtioStatus *qmp_x_query_virtio_status(const char *path, Error **errp) VirtIODevice *vdev; VirtioStatus *status; - vdev = virtio_device_find(path); + vdev = qmp_find_virtio_device(path); if (vdev == NULL) { error_setg(errp, "Path %s is not a VirtIODevice", path); return NULL; @@ -3972,7 +3972,7 @@ VirtVhostQueueStatus *qmp_x_query_virtio_vhost_queue_status(const char *path, VirtIODevice *vdev; VirtVhostQueueStatus *status; - vdev = virtio_device_find(path); + vdev = qmp_find_virtio_device(path); if (vdev == NULL) { error_setg(errp, "Path %s is not a VirtIODevice", path); return NULL; @@ -4016,7 +4016,7 @@ VirtQueueStatus *qmp_x_query_virtio_queue_status(const char *path, VirtIODevice *vdev; VirtQueueStatus *status; - vdev = virtio_device_find(path); + vdev = qmp_find_virtio_device(path); if (vdev == NULL) { error_setg(errp, "Path %s is not a VirtIODevice", path); return NULL; @@ -4109,7 +4109,7 @@ VirtioQueueElement *qmp_x_query_virtio_queue_element(const char *path, VirtQueue *vq; VirtioQueueElement *element = NULL; - vdev = virtio_device_find(path); + vdev = qmp_find_virtio_device(path); if (vdev == NULL) { error_setg(errp, "Path %s is not a VirtIO device", path); return NULL; From patchwork Thu Jan 5 09:15:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 639244 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp128096pvb; Thu, 5 Jan 2023 01:17:07 -0800 (PST) X-Google-Smtp-Source: AMrXdXsZdjOI+6dF/cYElxIUZVZCYJgqunXLRDj3Qz9+Eog8Klpdmvtt8+8p4TKvprt+v5piJNJk X-Received: by 2002:a0c:9124:0:b0:531:b490:d387 with SMTP id q33-20020a0c9124000000b00531b490d387mr26368434qvq.48.1672910227695; Thu, 05 Jan 2023 01:17:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672910227; cv=none; d=google.com; s=arc-20160816; b=ZQq1ir5td/O0foxjfzlq17IZ5f72fxf4WpJV5du206s9WYsapw0YFZyET2teFTO8k7 NcpkAJ4pDWP+rtWoW9iSLH5wIZcGmykrQl5PvpT/DsgSXX17WRg3GrZw8pr4DE0NkzK4 /8RAPLVbxjrkZCwvWnFwRVjRYkYIYBN7RD8RAcGz1x76DpPcW3mv+J7kWG6gS2jzU/0Y fRZbLylscLJ7imeFKoPdPWvwu159uRjRy8WoZX+vO2DfclYw/2zgcjSFE4L4bKCW0B/1 5hRv2Cc2HTaluYxNSXpJxaedtYatxlJhzLxBP2Snr58yOYr5EKPhiDis45kcyFcC9pZX uxJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=8rdjip+25b1dwiqpkqVWxqDvIT7eKP5F+F/OwUaW8Q0=; b=PFJeHS/qL9jdH1MLWQdF4t/5uHDLJjJrNgBjvOYZzQha5DY2AVxmSRzvBsSs0YbGH0 iiP1CsEBB4hWXKEaYwEoMjV28ZhhNbmqhN3fWw4D7IJgHqe1QUNCblTa6/uhfgJoKXf4 f7NZ52R+tdGV5WELkNBVwyZlR4m/PbMMk05eNFFJwCKViSMdnZcJanUK3BmFQHnNVNZT oIIUAnitnbG931dMnTj72XWCTFEgkF8l/LaGiQ1XkEi4Uk19fvGnod6dxfMNGyvSBY6O E1mk6jfHSjbSf7vEmsgqbV2m7VcBkVuxc9/5dRdOvHryo7YGaN/VpwDrlaTvpntCwB29 IoeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=O7veVVb4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id kf10-20020a056214524a00b004bb60c76ffcsi17468200qvb.189.2023.01.05.01.17.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 05 Jan 2023 01:17:07 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=O7veVVb4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pDMLp-0002eM-B6; Thu, 05 Jan 2023 04:15:53 -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 1pDMLk-0002Wt-6r for qemu-devel@nongnu.org; Thu, 05 Jan 2023 04:15:48 -0500 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 1pDMLg-0007BT-SY for qemu-devel@nongnu.org; Thu, 05 Jan 2023 04:15:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672910144; 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=8rdjip+25b1dwiqpkqVWxqDvIT7eKP5F+F/OwUaW8Q0=; b=O7veVVb437OnACdA0auaR1aDEI0cPvzGfexs4/cx+mPlpnAEFb1nxEkPsJGH8x10eIonDN +G4zhebAMDKDasX+IJZwSorEfZ/cKyL/wSpSlrkEDhfxKwBMcJHF/TvXVEoy1W1ZOBcKk0 NfuSSrf1IrThPZwFLCC1vNKThAr9HOQ= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-170-te4Zt1DOPReUXqlICbzfOw-1; Thu, 05 Jan 2023 04:15:43 -0500 X-MC-Unique: te4Zt1DOPReUXqlICbzfOw-1 Received: by mail-wr1-f71.google.com with SMTP id g18-20020adfa492000000b0027174820fdbso4531335wrb.4 for ; Thu, 05 Jan 2023 01:15:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=8rdjip+25b1dwiqpkqVWxqDvIT7eKP5F+F/OwUaW8Q0=; b=njH5K6+9ymZjq2lSxWNCL3h5Dvd3Ni5PuAdyZYo1ArraBE6tt1wqRAChudokzJCQdP PR2ZsIgAhf5x5LaA5xTN7rcYRWyuHsQ5fF9oBUIc+3jH3Q27Gx5V6SuzAaGcOOFjdUQr Xp9TT4urqcj4uKrNi9n17vKsKvxoIOsoXGsSe/dkqSqpiZbCMTWeHDtTVLVktA2WzcZJ 9PJtWmwdgha3Mi1Qj9eolIdL4u/l3s7OR4qxPVtVO3fhPT9SOpd34ApJmLQJxVyDgVhN P+4hwNTmKp/DO932C7J68ewZuCT0X7gqkVp40DiFGzY8jZphyUnc+rbk/62Wuudzcp+w l4ow== X-Gm-Message-State: AFqh2krou5a6pOrK7rD5ySZ+gX+4+YxMioTBrIcqk03fwBqvDzzBncPy KHBTPK6apxFjKAgc0j+pmzADShr2a+rjeXfqcZ8neK7WZ2Ml7pggsfpuEcZBVjucMKHIqgep8Bp l141ycTIsjJMZXJV6lVbo1d9iHDAdWioobX6TDTO50hQ76a8gXp7/tyh2bfBR X-Received: by 2002:a05:600c:1ca5:b0:3d1:d746:7bca with SMTP id k37-20020a05600c1ca500b003d1d7467bcamr36003033wms.4.1672910141291; Thu, 05 Jan 2023 01:15:41 -0800 (PST) X-Received: by 2002:a05:600c:1ca5:b0:3d1:d746:7bca with SMTP id k37-20020a05600c1ca500b003d1d7467bcamr36003012wms.4.1672910140932; Thu, 05 Jan 2023 01:15:40 -0800 (PST) Received: from redhat.com ([2.52.151.85]) by smtp.gmail.com with ESMTPSA id g19-20020a05600c4ed300b003d978f8f255sm2371959wmq.27.2023.01.05.01.15.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Jan 2023 01:15:40 -0800 (PST) Date: Thu, 5 Jan 2023 04:15:38 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Philippe =?utf-8?q?Mathieu-Dau?= =?utf-8?q?d=C3=A9?= , Jonah Palmer Subject: [PULL 26/51] hw/virtio: Extract QMP QOM-specific functions to virtio-qmp.c Message-ID: <20230105091310.263867-27-mst@redhat.com> References: <20230105091310.263867-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230105091310.263867-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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_H2=-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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Philippe Mathieu-Daudé virtio.c is big enough, extract more QMP related code to virtio-qmp.c. To do so, expose qmp_find_virtio_device() and declar virtio_list in the internal virtio-qmp.h header. Note we have to leave qmp_x_query_virtio_queue_status() and qmp_x_query_virtio_queue_element(), because they access VirtQueue internal fields, and VirtQueue is only declared within virtio.c. Suggested-by: Jonah Palmer Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20221222080005.27616-3-philmd@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-qmp.h | 9 ++ hw/virtio/virtio-qmp.c | 192 ++++++++++++++++++++++++++++++++++++++++- hw/virtio/virtio.c | 191 +--------------------------------------- 3 files changed, 201 insertions(+), 191 deletions(-) diff --git a/hw/virtio/virtio-qmp.h b/hw/virtio/virtio-qmp.h index 075fc27030..59681082e5 100644 --- a/hw/virtio/virtio-qmp.h +++ b/hw/virtio/virtio-qmp.h @@ -12,7 +12,16 @@ #define HW_VIRTIO_QMP_H #include "qapi/qapi-types-virtio.h" +#include "hw/virtio/virtio.h" +#include "qemu/queue.h" + +typedef QTAILQ_HEAD(QmpVirtIODeviceList, VirtIODevice) QmpVirtIODeviceList; + +/* QAPI list of realized VirtIODevices */ +extern QmpVirtIODeviceList virtio_list; + +VirtIODevice *qmp_find_virtio_device(const char *path); VirtioDeviceStatus *qmp_decode_status(uint8_t bitmap); VhostDeviceProtocols *qmp_decode_protocols(uint64_t bitmap); VirtioDeviceFeatures *qmp_decode_features(uint16_t device_id, uint64_t bitmap); diff --git a/hw/virtio/virtio-qmp.c b/hw/virtio/virtio-qmp.c index 8e7282658f..e4d4bece2d 100644 --- a/hw/virtio/virtio-qmp.c +++ b/hw/virtio/virtio-qmp.c @@ -10,9 +10,14 @@ */ #include "qemu/osdep.h" -#include "hw/virtio/virtio.h" #include "virtio-qmp.h" +#include "qapi/error.h" +#include "qapi/qapi-commands-virtio.h" +#include "qapi/qapi-commands-qom.h" +#include "qapi/qmp/qobject.h" +#include "qapi/qmp/qjson.h" + #include "standard-headers/linux/virtio_ids.h" #include "standard-headers/linux/vhost_types.h" #include "standard-headers/linux/virtio_blk.h" @@ -657,3 +662,188 @@ VirtioDeviceFeatures *qmp_decode_features(uint16_t device_id, uint64_t bitmap) return features; } + +VirtioInfoList *qmp_x_query_virtio(Error **errp) +{ + VirtioInfoList *list = NULL; + VirtioInfoList *node; + VirtIODevice *vdev; + + QTAILQ_FOREACH(vdev, &virtio_list, next) { + DeviceState *dev = DEVICE(vdev); + Error *err = NULL; + QObject *obj = qmp_qom_get(dev->canonical_path, "realized", &err); + + if (err == NULL) { + GString *is_realized = qobject_to_json_pretty(obj, true); + /* virtio device is NOT realized, remove it from list */ + if (!strncmp(is_realized->str, "false", 4)) { + QTAILQ_REMOVE(&virtio_list, vdev, next); + } else { + node = g_new0(VirtioInfoList, 1); + node->value = g_new(VirtioInfo, 1); + node->value->path = g_strdup(dev->canonical_path); + node->value->name = g_strdup(vdev->name); + QAPI_LIST_PREPEND(list, node->value); + } + g_string_free(is_realized, true); + } + qobject_unref(obj); + } + + return list; +} + +VirtIODevice *qmp_find_virtio_device(const char *path) +{ + VirtIODevice *vdev; + + QTAILQ_FOREACH(vdev, &virtio_list, next) { + DeviceState *dev = DEVICE(vdev); + + if (strcmp(dev->canonical_path, path) != 0) { + continue; + } + + Error *err = NULL; + QObject *obj = qmp_qom_get(dev->canonical_path, "realized", &err); + if (err == NULL) { + GString *is_realized = qobject_to_json_pretty(obj, true); + /* virtio device is NOT realized, remove it from list */ + if (!strncmp(is_realized->str, "false", 4)) { + g_string_free(is_realized, true); + qobject_unref(obj); + QTAILQ_REMOVE(&virtio_list, vdev, next); + return NULL; + } + g_string_free(is_realized, true); + } else { + /* virtio device doesn't exist in QOM tree */ + QTAILQ_REMOVE(&virtio_list, vdev, next); + qobject_unref(obj); + return NULL; + } + /* device exists in QOM tree & is realized */ + qobject_unref(obj); + return vdev; + } + return NULL; +} + +VirtioStatus *qmp_x_query_virtio_status(const char *path, Error **errp) +{ + VirtIODevice *vdev; + VirtioStatus *status; + + vdev = qmp_find_virtio_device(path); + if (vdev == NULL) { + error_setg(errp, "Path %s is not a VirtIODevice", path); + return NULL; + } + + status = g_new0(VirtioStatus, 1); + status->name = g_strdup(vdev->name); + status->device_id = vdev->device_id; + status->vhost_started = vdev->vhost_started; + status->guest_features = qmp_decode_features(vdev->device_id, + vdev->guest_features); + status->host_features = qmp_decode_features(vdev->device_id, + vdev->host_features); + status->backend_features = qmp_decode_features(vdev->device_id, + vdev->backend_features); + + switch (vdev->device_endian) { + case VIRTIO_DEVICE_ENDIAN_LITTLE: + status->device_endian = g_strdup("little"); + break; + case VIRTIO_DEVICE_ENDIAN_BIG: + status->device_endian = g_strdup("big"); + break; + default: + status->device_endian = g_strdup("unknown"); + break; + } + + status->num_vqs = virtio_get_num_queues(vdev); + status->status = qmp_decode_status(vdev->status); + status->isr = vdev->isr; + status->queue_sel = vdev->queue_sel; + status->vm_running = vdev->vm_running; + status->broken = vdev->broken; + status->disabled = vdev->disabled; + status->use_started = vdev->use_started; + status->started = vdev->started; + status->start_on_kick = vdev->start_on_kick; + status->disable_legacy_check = vdev->disable_legacy_check; + status->bus_name = g_strdup(vdev->bus_name); + status->use_guest_notifier_mask = vdev->use_guest_notifier_mask; + + if (vdev->vhost_started) { + VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev); + struct vhost_dev *hdev = vdc->get_vhost(vdev); + + status->vhost_dev = g_new0(VhostStatus, 1); + status->vhost_dev->n_mem_sections = hdev->n_mem_sections; + status->vhost_dev->n_tmp_sections = hdev->n_tmp_sections; + status->vhost_dev->nvqs = hdev->nvqs; + status->vhost_dev->vq_index = hdev->vq_index; + status->vhost_dev->features = + qmp_decode_features(vdev->device_id, hdev->features); + status->vhost_dev->acked_features = + qmp_decode_features(vdev->device_id, hdev->acked_features); + status->vhost_dev->backend_features = + qmp_decode_features(vdev->device_id, hdev->backend_features); + status->vhost_dev->protocol_features = + qmp_decode_protocols(hdev->protocol_features); + status->vhost_dev->max_queues = hdev->max_queues; + status->vhost_dev->backend_cap = hdev->backend_cap; + status->vhost_dev->log_enabled = hdev->log_enabled; + status->vhost_dev->log_size = hdev->log_size; + } + + return status; +} + +VirtVhostQueueStatus *qmp_x_query_virtio_vhost_queue_status(const char *path, + uint16_t queue, + Error **errp) +{ + VirtIODevice *vdev; + VirtVhostQueueStatus *status; + + vdev = qmp_find_virtio_device(path); + if (vdev == NULL) { + error_setg(errp, "Path %s is not a VirtIODevice", path); + return NULL; + } + + if (!vdev->vhost_started) { + error_setg(errp, "Error: vhost device has not started yet"); + return NULL; + } + + VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev); + struct vhost_dev *hdev = vdc->get_vhost(vdev); + + if (queue < hdev->vq_index || queue >= hdev->vq_index + hdev->nvqs) { + error_setg(errp, "Invalid vhost virtqueue number %d", queue); + return NULL; + } + + status = g_new0(VirtVhostQueueStatus, 1); + status->name = g_strdup(vdev->name); + status->kick = hdev->vqs[queue].kick; + status->call = hdev->vqs[queue].call; + status->desc = (uintptr_t)hdev->vqs[queue].desc; + status->avail = (uintptr_t)hdev->vqs[queue].avail; + status->used = (uintptr_t)hdev->vqs[queue].used; + status->num = hdev->vqs[queue].num; + status->desc_phys = hdev->vqs[queue].desc_phys; + status->desc_size = hdev->vqs[queue].desc_size; + status->avail_phys = hdev->vqs[queue].avail_phys; + status->avail_size = hdev->vqs[queue].avail_size; + status->used_phys = hdev->vqs[queue].used_phys; + status->used_size = hdev->vqs[queue].used_size; + + return status; +} diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index e08443e3bf..02a49d9fa1 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -13,10 +13,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" -#include "qapi/qmp/qdict.h" #include "qapi/qapi-commands-virtio.h" -#include "qapi/qapi-commands-qom.h" -#include "qapi/qmp/qjson.h" #include "trace.h" #include "qemu/error-report.h" #include "qemu/log.h" @@ -47,8 +44,7 @@ #include "standard-headers/linux/virtio_mem.h" #include "standard-headers/linux/virtio_vsock.h" -/* QAPI list of realized VirtIODevices */ -static QTAILQ_HEAD(, VirtIODevice) virtio_list; +QmpVirtIODeviceList virtio_list; /* * Maximum size of virtio device config space @@ -3824,191 +3820,6 @@ bool virtio_device_ioeventfd_enabled(VirtIODevice *vdev) return virtio_bus_ioeventfd_enabled(vbus); } -VirtioInfoList *qmp_x_query_virtio(Error **errp) -{ - VirtioInfoList *list = NULL; - VirtioInfoList *node; - VirtIODevice *vdev; - - QTAILQ_FOREACH(vdev, &virtio_list, next) { - DeviceState *dev = DEVICE(vdev); - Error *err = NULL; - QObject *obj = qmp_qom_get(dev->canonical_path, "realized", &err); - - if (err == NULL) { - GString *is_realized = qobject_to_json_pretty(obj, true); - /* virtio device is NOT realized, remove it from list */ - if (!strncmp(is_realized->str, "false", 4)) { - QTAILQ_REMOVE(&virtio_list, vdev, next); - } else { - node = g_new0(VirtioInfoList, 1); - node->value = g_new(VirtioInfo, 1); - node->value->path = g_strdup(dev->canonical_path); - node->value->name = g_strdup(vdev->name); - QAPI_LIST_PREPEND(list, node->value); - } - g_string_free(is_realized, true); - } - qobject_unref(obj); - } - - return list; -} - -static VirtIODevice *qmp_find_virtio_device(const char *path) -{ - VirtIODevice *vdev; - - QTAILQ_FOREACH(vdev, &virtio_list, next) { - DeviceState *dev = DEVICE(vdev); - - if (strcmp(dev->canonical_path, path) != 0) { - continue; - } - - Error *err = NULL; - QObject *obj = qmp_qom_get(dev->canonical_path, "realized", &err); - if (err == NULL) { - GString *is_realized = qobject_to_json_pretty(obj, true); - /* virtio device is NOT realized, remove it from list */ - if (!strncmp(is_realized->str, "false", 4)) { - g_string_free(is_realized, true); - qobject_unref(obj); - QTAILQ_REMOVE(&virtio_list, vdev, next); - return NULL; - } - g_string_free(is_realized, true); - } else { - /* virtio device doesn't exist in QOM tree */ - QTAILQ_REMOVE(&virtio_list, vdev, next); - qobject_unref(obj); - return NULL; - } - /* device exists in QOM tree & is realized */ - qobject_unref(obj); - return vdev; - } - return NULL; -} - -VirtioStatus *qmp_x_query_virtio_status(const char *path, Error **errp) -{ - VirtIODevice *vdev; - VirtioStatus *status; - - vdev = qmp_find_virtio_device(path); - if (vdev == NULL) { - error_setg(errp, "Path %s is not a VirtIODevice", path); - return NULL; - } - - status = g_new0(VirtioStatus, 1); - status->name = g_strdup(vdev->name); - status->device_id = vdev->device_id; - status->vhost_started = vdev->vhost_started; - status->guest_features = qmp_decode_features(vdev->device_id, - vdev->guest_features); - status->host_features = qmp_decode_features(vdev->device_id, - vdev->host_features); - status->backend_features = qmp_decode_features(vdev->device_id, - vdev->backend_features); - - switch (vdev->device_endian) { - case VIRTIO_DEVICE_ENDIAN_LITTLE: - status->device_endian = g_strdup("little"); - break; - case VIRTIO_DEVICE_ENDIAN_BIG: - status->device_endian = g_strdup("big"); - break; - default: - status->device_endian = g_strdup("unknown"); - break; - } - - status->num_vqs = virtio_get_num_queues(vdev); - status->status = qmp_decode_status(vdev->status); - status->isr = vdev->isr; - status->queue_sel = vdev->queue_sel; - status->vm_running = vdev->vm_running; - status->broken = vdev->broken; - status->disabled = vdev->disabled; - status->use_started = vdev->use_started; - status->started = vdev->started; - status->start_on_kick = vdev->start_on_kick; - status->disable_legacy_check = vdev->disable_legacy_check; - status->bus_name = g_strdup(vdev->bus_name); - status->use_guest_notifier_mask = vdev->use_guest_notifier_mask; - - if (vdev->vhost_started) { - VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev); - struct vhost_dev *hdev = vdc->get_vhost(vdev); - - status->vhost_dev = g_new0(VhostStatus, 1); - status->vhost_dev->n_mem_sections = hdev->n_mem_sections; - status->vhost_dev->n_tmp_sections = hdev->n_tmp_sections; - status->vhost_dev->nvqs = hdev->nvqs; - status->vhost_dev->vq_index = hdev->vq_index; - status->vhost_dev->features = - qmp_decode_features(vdev->device_id, hdev->features); - status->vhost_dev->acked_features = - qmp_decode_features(vdev->device_id, hdev->acked_features); - status->vhost_dev->backend_features = - qmp_decode_features(vdev->device_id, hdev->backend_features); - status->vhost_dev->protocol_features = - qmp_decode_protocols(hdev->protocol_features); - status->vhost_dev->max_queues = hdev->max_queues; - status->vhost_dev->backend_cap = hdev->backend_cap; - status->vhost_dev->log_enabled = hdev->log_enabled; - status->vhost_dev->log_size = hdev->log_size; - } - - return status; -} - -VirtVhostQueueStatus *qmp_x_query_virtio_vhost_queue_status(const char *path, - uint16_t queue, - Error **errp) -{ - VirtIODevice *vdev; - VirtVhostQueueStatus *status; - - vdev = qmp_find_virtio_device(path); - if (vdev == NULL) { - error_setg(errp, "Path %s is not a VirtIODevice", path); - return NULL; - } - - if (!vdev->vhost_started) { - error_setg(errp, "Error: vhost device has not started yet"); - return NULL; - } - - VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev); - struct vhost_dev *hdev = vdc->get_vhost(vdev); - - if (queue < hdev->vq_index || queue >= hdev->vq_index + hdev->nvqs) { - error_setg(errp, "Invalid vhost virtqueue number %d", queue); - return NULL; - } - - status = g_new0(VirtVhostQueueStatus, 1); - status->name = g_strdup(vdev->name); - status->kick = hdev->vqs[queue].kick; - status->call = hdev->vqs[queue].call; - status->desc = (uintptr_t)hdev->vqs[queue].desc; - status->avail = (uintptr_t)hdev->vqs[queue].avail; - status->used = (uintptr_t)hdev->vqs[queue].used; - status->num = hdev->vqs[queue].num; - status->desc_phys = hdev->vqs[queue].desc_phys; - status->desc_size = hdev->vqs[queue].desc_size; - status->avail_phys = hdev->vqs[queue].avail_phys; - status->avail_size = hdev->vqs[queue].avail_size; - status->used_phys = hdev->vqs[queue].used_phys; - status->used_size = hdev->vqs[queue].used_size; - - return status; -} - VirtQueueStatus *qmp_x_query_virtio_queue_status(const char *path, uint16_t queue, Error **errp)