From nobody Tue Nov 11 08:50:24 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1569324826; cv=none; d=zoho.com; s=zohoarc; b=iX3YlwzJDZw1/yZX9hAcZvkR9/Sbx++c/UKvXuQYiKgXVUPWNSyIANsoGq7Q5/xGLE0+ykatJLkEIaP9K8bkX3J3XXtA3vVpIQdLSrFZ31T16gr7aNcxRj2Z9nU60LL5nkDEPRFYj9TWE4chwKX9c6cLXbue0oSZOtiHfybZZkU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569324826; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=UNpGceByRfh5Ii7U/gNtptf4rWtSJlB1XEfZc40eQwE=; b=iPSwP94YrN9+4S0NMHNNzv+7auoHPbkH5kFswf+ICxosy6f6NWY+JgoDJxhKwO45nOrI6o926jrMlxpIyHw9JNa6jAySTsD4lZNeC1A8kXofbCPm/nXxNUstbPrnvJB+haG+0wmO0lXao5wgYIDb1dBnP9d/HNvugs32UdMMf58= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1569324826108316.6264116271841; Tue, 24 Sep 2019 04:33:46 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCj2Q-000773-Qs; Tue, 24 Sep 2019 11:31:22 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCj2P-00075a-7E for xen-devel@lists.xenproject.org; Tue, 24 Sep 2019 11:31:21 +0000 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by localhost (Halon) with ESMTPS id d213735a-debe-11e9-9616-12813bfff9fa; Tue, 24 Sep 2019 11:31:16 +0000 (UTC) X-Inumbo-ID: d213735a-debe-11e9-9616-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1569324677; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=V2U8e+HabmdsYmqhlEYja60hkM+cXhexkTTFzMhph6o=; b=AzWRIHCzIw4jdoDl3yOfRrs5zF1grQ4fEFmi0lDvBWQaJSs/9xY6lPGF 8pk0/keOtsqXDS61mToqqyE2rx870l2xcrmK1l8fHPn+GjoUwYUHu0zXJ O6yoHH4X/CIJRXDgTtJtJtZUdcbMKaVUtluTcrPIk5CBmF5x4fACF9oSs o=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=anthony.perard@citrix.com; spf=Pass smtp.mailfrom=anthony.perard@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa2.hc3370-68.iphmx.com: no sender authenticity information available from domain of anthony.perard@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa2.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa2.hc3370-68.iphmx.com: domain of anthony.perard@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa2.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ~all" Received-SPF: None (esa2.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa2.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: dTgdXBjAfZSQKKdPxguNNicmHzVINOidnNlI99CdZGJ1no/tvOOLuQmjLrEzZW3UrwZjZXNHDh 3xCHu+LcGBgk0wjkYNN0lvqh558z5q4Z3nYwAX1PLxwe8ClA5hJk5iaboXAcQtDqaS0+S2q7ai 4TEfUC/jzkqydd//J0Nc6qKXVa8QoCAwHds6+I3rKNxJzIqeJXbHg5Z2yqxRuxaNwUKj+MfdOx XOCWFcHysxuivn1dt9Nzyg0eSim+ca6zKg1zjVJtNJgZH8SpZDDBS95XHtZUmauqP1p8uxlvPO 0xs= X-SBRS: 2.7 X-MesageID: 5977600 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,543,1559534400"; d="scan'208";a="5977600" From: Anthony PERARD To: Date: Tue, 24 Sep 2019 12:30:22 +0100 Message-ID: <20190924113026.255634-4-anthony.perard@citrix.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190924113026.255634-1-anthony.perard@citrix.com> References: <20190924113026.255634-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PULL 3/7] xen: introduce separate XenWatchList for XenDevice objects X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD , xen-devel@lists.xenproject.org, Peter Maydell Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Paul Durrant This patch uses the XenWatchList abstraction to add a separate watch list for each device. This is more scalable than walking a single notifier list for all watches and is also necessary to implement a bug-fix in a subsequent patch. Signed-off-by: Paul Durrant Reviewed-by: Anthony Perard Message-Id: <20190913082159.31338-3-paul.durrant@citrix.com> Signed-off-by: Anthony PERARD --- hw/xen/trace-events | 2 ++ hw/xen/xen-bus.c | 72 ++++++++++++++++++++++++++++++++-------- include/hw/xen/xen-bus.h | 2 ++ 3 files changed, 62 insertions(+), 14 deletions(-) diff --git a/hw/xen/trace-events b/hw/xen/trace-events index ac8d9c20d2..80ce3dafad 100644 --- a/hw/xen/trace-events +++ b/hw/xen/trace-events @@ -29,6 +29,8 @@ xen_device_backend_changed(const char *type, char *name) = "type: %s name: %s" xen_device_frontend_state(const char *type, char *name, const char *state)= "type: %s name: %s -> %s" xen_device_frontend_changed(const char *type, char *name) "type: %s name: = %s" xen_device_unplug(const char *type, char *name) "type: %s name: %s" +xen_device_add_watch(const char *type, char *name, const char *node, const= char *key) "type: %s name: %s node: %s key: %s" +xen_device_remove_watch(const char *type, char *name, const char *node, co= nst char *key) "type: %s name: %s node: %s key: %s" =20 # xen-bus-helper.c xs_node_create(const char *node) "%s" diff --git a/hw/xen/xen-bus.c b/hw/xen/xen-bus.c index 28efaccff2..810a4e2df3 100644 --- a/hw/xen/xen-bus.c +++ b/hw/xen/xen-bus.c @@ -235,11 +235,11 @@ static void watch_list_remove(XenWatchList *watch_lis= t, XenWatch *watch, =20 static XenWatch *xen_bus_add_watch(XenBus *xenbus, const char *node, const char *key, XenWatchHandler handle= r, - void *opaque, Error **errp) + Error **errp) { trace_xen_bus_add_watch(node, key); =20 - return watch_list_add(xenbus->watch_list, node, key, handler, opaque, + return watch_list_add(xenbus->watch_list, node, key, handler, xenbus, errp); } =20 @@ -433,7 +433,7 @@ static void xen_bus_realize(BusState *bus, Error **errp) =20 xenbus->backend_watch =3D xen_bus_add_watch(xenbus, "", /* domain root node */ - "backend", xen_bus_enumerate, xenbus, &local_err= ); + "backend", xen_bus_enumerate, &local_err); if (local_err) { /* This need not be treated as a hard error so don't propagate */ error_reportf_err(local_err, @@ -621,6 +621,31 @@ static void xen_device_backend_changed(void *opaque) } } =20 +static XenWatch *xen_device_add_watch(XenDevice *xendev, const char *node, + const char *key, + XenWatchHandler handler, + Error **errp) +{ + const char *type =3D object_get_typename(OBJECT(xendev)); + + trace_xen_device_add_watch(type, xendev->name, node, key); + + return watch_list_add(xendev->watch_list, node, key, handler, xendev, + errp); +} + +static void xen_device_remove_watch(XenDevice *xendev, XenWatch *watch, + Error **errp) +{ + const char *type =3D object_get_typename(OBJECT(xendev)); + + trace_xen_device_remove_watch(type, xendev->name, watch->node, + watch->key); + + watch_list_remove(xendev->watch_list, watch, errp); +} + + static void xen_device_backend_create(XenDevice *xendev, Error **errp) { XenBus *xenbus =3D XEN_BUS(qdev_get_parent_bus(DEVICE(xendev))); @@ -645,9 +670,9 @@ static void xen_device_backend_create(XenDevice *xendev= , Error **errp) } =20 xendev->backend_state_watch =3D - xen_bus_add_watch(xenbus, xendev->backend_path, - "state", xen_device_backend_changed, - xendev, &local_err); + xen_device_add_watch(xendev, xendev->backend_path, + "state", xen_device_backend_changed, + &local_err); if (local_err) { error_propagate_prepend(errp, local_err, "failed to watch backend state: "); @@ -655,9 +680,9 @@ static void xen_device_backend_create(XenDevice *xendev= , Error **errp) } =20 xendev->backend_online_watch =3D - xen_bus_add_watch(xenbus, xendev->backend_path, - "online", xen_device_backend_changed, - xendev, &local_err); + xen_device_add_watch(xendev, xendev->backend_path, + "online", xen_device_backend_changed, + &local_err); if (local_err) { error_propagate_prepend(errp, local_err, "failed to watch backend online: "); @@ -671,12 +696,12 @@ static void xen_device_backend_destroy(XenDevice *xen= dev) Error *local_err =3D NULL; =20 if (xendev->backend_online_watch) { - xen_bus_remove_watch(xenbus, xendev->backend_online_watch, NULL); + xen_device_remove_watch(xendev, xendev->backend_online_watch, NULL= ); xendev->backend_online_watch =3D NULL; } =20 if (xendev->backend_state_watch) { - xen_bus_remove_watch(xenbus, xendev->backend_state_watch, NULL); + xen_device_remove_watch(xendev, xendev->backend_state_watch, NULL); xendev->backend_state_watch =3D NULL; } =20 @@ -812,8 +837,8 @@ static void xen_device_frontend_create(XenDevice *xende= v, Error **errp) } =20 xendev->frontend_state_watch =3D - xen_bus_add_watch(xenbus, xendev->frontend_path, "state", - xen_device_frontend_changed, xendev, &local_err); + xen_device_add_watch(xendev, xendev->frontend_path, "state", + xen_device_frontend_changed, &local_err); if (local_err) { error_propagate_prepend(errp, local_err, "failed to watch frontend state: "); @@ -826,7 +851,8 @@ static void xen_device_frontend_destroy(XenDevice *xend= ev) Error *local_err =3D NULL; =20 if (xendev->frontend_state_watch) { - xen_bus_remove_watch(xenbus, xendev->frontend_state_watch, NULL); + xen_device_remove_watch(xendev, xendev->frontend_state_watch, + NULL); xendev->frontend_state_watch =3D NULL; } =20 @@ -1122,6 +1148,16 @@ static void xen_device_unrealize(DeviceState *dev, E= rror **errp) xendev->xgth =3D NULL; } =20 + if (xendev->watch_list) { + watch_list_destroy(xendev->watch_list); + xendev->watch_list =3D NULL; + } + + if (xendev->xsh) { + xs_close(xendev->xsh); + xendev->xsh =3D NULL; + } + g_free(xendev->name); xendev->name =3D NULL; } @@ -1164,6 +1200,14 @@ static void xen_device_realize(DeviceState *dev, Err= or **errp) =20 trace_xen_device_realize(type, xendev->name); =20 + xendev->xsh =3D xs_open(0); + if (!xendev->xsh) { + error_setg_errno(errp, errno, "failed xs_open"); + goto unrealize; + } + + xendev->watch_list =3D watch_list_create(xendev->xsh); + xendev->xgth =3D xengnttab_open(NULL, 0); if (!xendev->xgth) { error_setg_errno(errp, errno, "failed xengnttab_open"); diff --git a/include/hw/xen/xen-bus.h b/include/hw/xen/xen-bus.h index 88b84e29bb..0d198148f6 100644 --- a/include/hw/xen/xen-bus.h +++ b/include/hw/xen/xen-bus.h @@ -22,6 +22,8 @@ typedef struct XenDevice { DeviceState qdev; domid_t frontend_id; char *name; + struct xs_handle *xsh; + XenWatchList *watch_list; char *backend_path, *frontend_path; enum xenbus_state backend_state, frontend_state; Notifier exit; --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel