On Thu, 27 Nov 2025 22:55:25 +0000 Alireza Sanaee <[email protected]> wrote:
> Add tag based removal, in which alias tear down must be done properly. I'd add the status check as as separate patch. Aim to keep the addition of the removal command super simple. I'm not sure how this interacts with the older handling. Maybe it's worth adding a release by tag before all the rest of the series? Seems like a useful thing on it's own - as is the status check though I think that interface may need some more thought. Jonathan > > Signed-off-by: Alireza Sanaee <[email protected]> > --- > hw/mem/cxl_type3.c | 119 +++++++++++++++++++++++++++++++++++++++++++++ > qapi/cxl.json | 46 ++++++++++++++++++ > 2 files changed, 165 insertions(+) > > diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c > index d3ea62ef3f..29355792da 100644 > --- a/hw/mem/cxl_type3.c > +++ b/hw/mem/cxl_type3.c > @@ -2186,6 +2186,61 @@ void qmp_cxl_add_dynamic_capacity(const char *path, > uint16_t host_id, > } > } > > +static void qmp_cxl_process_dynamic_capacity_tag_based(const char *path, > + uint16_t hid, CXLDCEventType type, uint8_t rid, const char *tag, > + CxlDynamicCapacityExtentList *records, Error **errp) { Check style... I don't remember qemu doing { on that line. > + > + Object *obj; > + CXLType3Dev *dcd; > + CXLDCExtentList *list = NULL; > + CXLDCExtent *ent; > + g_autofree CXLDCExtentRaw *extents = NULL; > + > + obj = object_resolve_path_type(path, TYPE_CXL_TYPE3, NULL); > + if (!obj) { > + error_setg(errp, "Unable to resolve CXL type 3 device"); > + return; > + } > + > + dcd = CXL_TYPE3(obj); > + if (!dcd->dc.num_regions) { > + error_setg(errp, "No dynamic capacity support from the device"); > + return; > + } > + > + if (rid >= dcd->dc.num_regions) { > + error_setg(errp, "region id is too large"); > + return; > + } > + > + QemuUUID uuid_req; > + qemu_uuid_parse(tag, &uuid_req); > + > + list = &dcd->dc.extents; > + size_t cap = 8, n = 0; > + extents = g_new0(CXLDCExtentRaw, cap); > + QTAILQ_FOREACH(ent, list, node) { > + QemuUUID uuid_ext; > + memcpy(&uuid_ext.data, ent->tag, sizeof(ent->tag)); > + if (!qemu_uuid_is_equal(&uuid_req, &uuid_ext)) { > + continue; > + } > + > + if (n == cap) { > + cap = cap < 8 ? 8 : cap * 2; > + extents = g_renew(CXLDCExtentRaw, extents, cap); > + } > + > + extents[n++] = (CXLDCExtentRaw){ .start_dpa = ent->start_dpa, > + .len = ent->len, > + .shared_seq = 0 }; > + } > + > + extents = g_renew(CXLDCExtentRaw, extents, n); > + cxl_create_dc_event_records_for_extents(dcd, type, extents, n); > + return; > +} > +
