From: Alireza Sanaee via qemu development <qemu-devel@nongnu.org>
To: <qemu-devel@nongnu.org>
Cc: <anisa.su@samsung.com>, <armbru@redhat.com>,
<berrange@redhat.com>, <eblake@redhat.com>,
<jonathan.cameron@huawei.com>, <linux-cxl@vger.kernel.org>,
<linuxarm@huawei.com>, <lizhijian@fujitsu.com>, <mst@redhat.com>,
<pbonzini@redhat.com>, <gourry@gourry.net>, <nifan.cxl@gmail.com>,
<me@linux.beauty>
Subject: [PATCH 9/9] hw/cxl: Add QMP status query for dynamic-capacity extent release
Date: Wed, 25 Mar 2026 18:42:57 +0000 [thread overview]
Message-ID: <20260325184259.366-10-alireza.sanaee@huawei.com> (raw)
In-Reply-To: <20260325184259.366-1-alireza.sanaee@huawei.com>
Add a small status query so orchestration layers can check whether a tagged
extent is still pending, committed, or no longer present after a release
request.
Introduce the ExtentStatus QAPI struct and the
cxl-release-dynamic-capacity-status command.
Signed-off-by: Alireza Sanaee <alireza.sanaee@huawei.com>
---
hw/mem/cxl_type3.c | 85 ++++++++++++++++++++++++++++++++++++++++
hw/mem/cxl_type3_stubs.c | 10 +++++
qapi/cxl.json | 46 ++++++++++++++++++++++
3 files changed, 141 insertions(+)
diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c
index d5fa8a530a..8999b36e61 100644
--- a/hw/mem/cxl_type3.c
+++ b/hw/mem/cxl_type3.c
@@ -2635,6 +2635,91 @@ void cxl_remove_memory_alias(CXLType3Dev *dcd, struct CXLFixedWindow *fw,
dcd->dc.direct_mr_bitmap &= ~(1u << hdm_id);
}
+/*
+ * This function allows for a simple check to make sure that
+ * our extent is removed. It can be used by an orchestration layer.
+ */
+ExtentStatus *
+qmp_cxl_release_dynamic_capacity_status(const char *path,
+ uint16_t hid, uint8_t rid,
+ const char *tag,
+ Error **errp)
+{
+ Object *obj;
+ CXLType3Dev *dcd;
+ CXLDCExtentList *list = NULL;
+ CXLDCExtent *ent;
+ QemuUUID uuid_req;
+ ExtentStatus *res;
+
+ obj = object_resolve_path_type(path, TYPE_CXL_TYPE3, NULL);
+ if (!obj) {
+ error_setg(errp, "Unable to resolve CXL type 3 device");
+ return NULL;
+ }
+
+ dcd = CXL_TYPE3(obj);
+ if (!dcd->dc.num_regions) {
+ error_setg(errp, "No dynamic capacity support from the device");
+ return NULL;
+ }
+
+ if (rid >= dcd->dc.num_regions) {
+ error_setg(errp, "Region id is too large");
+ return NULL;
+ }
+
+ if (!tag) {
+ error_setg(errp, "Tag must be valid");
+ return NULL;
+ }
+
+ list = &dcd->dc.extents;
+ qemu_uuid_parse(tag, &uuid_req);
+ res = g_new0(ExtentStatus, 1);
+
+ /* Check committed extents */
+ QTAILQ_FOREACH(ent, list, node) {
+ QemuUUID uuid_ext;
+ g_autofree char *uuid_str = NULL;
+ memcpy(&uuid_ext.data, ent->tag, sizeof(ent->tag));
+ if (qemu_uuid_is_equal(&uuid_req, &uuid_ext)) {
+ uuid_str = qemu_uuid_unparse_strdup(&uuid_ext);
+ res->status = g_strdup("Committed");
+ res->message =
+ g_strdup_printf("Found committed extent with tag %s dpa 0x%"
+ PRIx64 " len 0x%" PRIx64,
+ uuid_str, ent->start_dpa, ent->len);
+ return res;
+ }
+ }
+
+ /* Check pending extents (not yet committed by kernel) */
+ {
+ CXLDCExtentGroup *group;
+ QTAILQ_FOREACH(group, &dcd->dc.extents_pending, node) {
+ QTAILQ_FOREACH(ent, &group->list, node) {
+ QemuUUID uuid_ext;
+ g_autofree char *uuid_str = NULL;
+ memcpy(&uuid_ext.data, ent->tag, sizeof(ent->tag));
+ if (qemu_uuid_is_equal(&uuid_req, &uuid_ext)) {
+ uuid_str = qemu_uuid_unparse_strdup(&uuid_ext);
+ res->status = g_strdup("Pending");
+ res->message =
+ g_strdup_printf("Found pending extent with tag %s"
+ " dpa 0x%" PRIx64 " len 0x%" PRIx64,
+ uuid_str, ent->start_dpa, ent->len);
+ return res;
+ }
+ }
+ }
+ }
+
+ res->status = g_strdup("Released");
+ res->message = g_strdup_printf("Tag %s released or not found", tag);
+ return res;
+}
+
static void ct3_class_init(ObjectClass *oc, const void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
diff --git a/hw/mem/cxl_type3_stubs.c b/hw/mem/cxl_type3_stubs.c
index 98292a931c..17f9414142 100644
--- a/hw/mem/cxl_type3_stubs.c
+++ b/hw/mem/cxl_type3_stubs.c
@@ -127,3 +127,13 @@ void qmp_cxl_release_dynamic_capacity(const char *path, uint16_t host_id,
{
error_setg(errp, "CXL Type 3 support is not compiled in");
}
+
+ExtentStatus *qmp_cxl_release_dynamic_capacity_status(const char *path,
+ uint16_t host_id,
+ uint8_t region,
+ const char *tag,
+ Error **errp)
+{
+ error_setg(errp, "CXL Type 3 support is not compiled in");
+ return NULL;
+}
diff --git a/qapi/cxl.json b/qapi/cxl.json
index 81d6198ba0..53325ba530 100644
--- a/qapi/cxl.json
+++ b/qapi/cxl.json
@@ -636,3 +636,49 @@
},
'features': [ 'unstable' ]
}
+
+##
+# @ExtentStatus:
+# This is an object that describes the status of an extent.
+#
+# @status: String indicating the overall result, e.g. "success".
+# @message: Human-readable description of the outcome.
+#
+# Since: 9.1
+##
+{ 'struct': 'ExtentStatus',
+ 'data': { 'status': 'str', 'message': 'str' }
+}
+
+##
+# @cxl-release-dynamic-capacity-status:
+#
+# This commands checks if an extent tag has been released or not.
+#
+# @path: path to the CXL Dynamic Capacity Device in the QOM tree.
+#
+# @host-id: The "Host ID" field as defined in Compute Express Link
+# (CXL) Specification, Revision 3.1, Table 7-71.
+#
+# @region: The "Region Number" field as defined in Compute Express
+# Link Specification, Revision 3.1, Table 7-71. Valid range
+# is from 0-7.
+#
+# @tag: The "Tag" field as defined in Compute Express Link (CXL)
+# Specification, Revision 3.1, Table 7-71.
+#
+# Features:
+#
+# @unstable: For now this command is subject to change.
+#
+# Since: 9.1
+##
+{ 'command': 'cxl-release-dynamic-capacity-status',
+ 'data': { 'path': 'str',
+ 'host-id': 'uint16',
+ 'region': 'uint8',
+ 'tag': 'str'
+ },
+ 'features': [ 'unstable' ],
+ 'returns': 'ExtentStatus'
+}
--
2.50.1 (Apple Git-155)
prev parent reply other threads:[~2026-03-25 18:48 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-25 18:42 [QEMU PATCH 0/9] Application Specific Tagged Memory Support in CXL Type 3 Devices Alireza Sanaee via qemu development
2026-03-25 18:42 ` [PATCH 1/9] hw/mem: Add tag support to generic host memory backends Alireza Sanaee via qemu development
2026-03-26 10:42 ` Markus Armbruster
2026-03-26 11:29 ` Alireza Sanaee via qemu development
2026-03-26 13:01 ` Markus Armbruster
2026-03-26 13:04 ` Alireza Sanaee via qemu development
2026-03-25 18:42 ` [PATCH 2/9] hw/cxl: Allow initializing type3 device with no backing device Alireza Sanaee via qemu development
2026-03-25 18:42 ` [PATCH 3/9] hw/cxl: Hook up tagged host memory backends at runtime for DC extents Alireza Sanaee via qemu development
2026-03-25 18:42 ` [PATCH 4/9] hw/cxl: Carry backend metadata in DC extent records Alireza Sanaee via qemu development
2026-03-25 18:42 ` [PATCH 5/9] hw/cxl: Map lazy memory backend after host acceptance Alireza Sanaee via qemu development
2026-03-25 18:42 ` [PATCH 6/9] hw/cxl: Create direct fixed-window aliases for accepted extents Alireza Sanaee via qemu development
2026-03-25 18:42 ` [PATCH 7/9] hw/cxl: Add release-time teardown for direct-mapped extents Alireza Sanaee via qemu development
2026-03-25 18:42 ` [PATCH 8/9] hw/cxl: Add tag-based dynamic-capacity release support Alireza Sanaee via qemu development
2026-03-25 18:42 ` Alireza Sanaee via qemu development [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260325184259.366-10-alireza.sanaee@huawei.com \
--to=qemu-devel@nongnu.org \
--cc=alireza.sanaee@huawei.com \
--cc=anisa.su@samsung.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=eblake@redhat.com \
--cc=gourry@gourry.net \
--cc=jonathan.cameron@huawei.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=lizhijian@fujitsu.com \
--cc=me@linux.beauty \
--cc=mst@redhat.com \
--cc=nifan.cxl@gmail.com \
--cc=pbonzini@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox