From patchwork Wed Oct 30 18:07:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 11219905 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 053E0112B for ; Wed, 30 Oct 2019 18:08:48 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D40972087E for ; Wed, 30 Oct 2019 18:08:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="bzJMbg/A" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D40972087E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iPsNQ-0003Y1-3L; Wed, 30 Oct 2019 18:07:24 +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 1iPsNP-0003Xp-Hu for xen-devel@lists.xenproject.org; Wed, 30 Oct 2019 18:07:23 +0000 X-Inumbo-ID: 16110d55-fb40-11e9-9534-12813bfff9fa Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 16110d55-fb40-11e9-9534-12813bfff9fa; Wed, 30 Oct 2019 18:07:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1572458829; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rHTbEyyFGXRs3V4C/ACE/M6SEw7Tzko1DxlSGPJG0cU=; b=bzJMbg/AdPUA+tUk+D4umiquRXxOhBgJQpZADX5QH0UefDrTvlrkktMp GmjwRIqkgINWrafw2EMYiNnOQGRJ5DgUVmB5AcGZY6ATnNyf2beVb8OJS Ew8WZ3ymBloa4DbyUpBTblZh0KKf8OsDB2R3fNGkhAPUPJA0/A8u2KgmI 4=; Authentication-Results: esa1.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 (esa1.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=esa1.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.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=esa1.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 ip4:168.245.78.127 ~all" Received-SPF: None (esa1.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=esa1.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: GLP/2e+9Br9+UyLDrBqcFWnkH7bAzVCiUgPdzGYWwkVlZzyxekkiSJGDH77M5iM7h95J550iNY Ps+1PxJQ7s8pb/7yEqz3H1rocpY86Si7EAESRFgjUwXbqU6eosK1B364jTWpGdWXg7XkhtEqK/ jPAKrJgP+9q9CYKK2L6GfHjFCgcaLhjq9jbipjLX0LD5IViMiRv2EMx26FIbJxnBthaYx47p4n JuC6d7MU8KwkyYn3VQfSOAre1FH0FRYmRBxIJ3eqN0kxyt5bgPp6xMLgRfF4Q5K76ypPtKMZWh rR0= X-SBRS: 2.7 X-MesageID: 7739501 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.68,248,1569297600"; d="scan'208";a="7739501" From: Anthony PERARD To: Date: Wed, 30 Oct 2019 18:07:00 +0000 Message-ID: <20191030180704.261320-3-anthony.perard@citrix.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191030180704.261320-1-anthony.perard@citrix.com> References: <20191030180704.261320-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [XEN PATCH for-4.13 v2 2/6] libxl: Move libxl__ev_devlock declaration 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 , =?utf-8?b?SsO8cmdlbiBHcm8=?= =?utf-8?b?w58=?= , Ian Jackson , Wei Liu Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" We are going to want to include libxl__ev_devlock into libxl__ev_qmp. No functional changes. Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- Notes: New patch in v2: Move of the struct was done in "libxl_qmp: Have a lock for QMP socket access" before. tools/libxl/libxl_internal.h | 96 ++++++++++++++++++------------------ 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 4e433e110664..69d572c1866a 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -363,6 +363,54 @@ struct libxl__ev_child { LIBXL_LIST_ENTRY(struct libxl__ev_child) entry; }; +/* + * Lock for device hotplug, qmp_lock. + * + * libxl__ev_devlock implement a lock that is outside of CTX_LOCK in the + * lock hierarchy. It can be used when one want to make QMP calls to QEMU, + * which may take a significant amount time. + * It is to be acquired by an ao event callback. + * + * It is to be acquired when adding/removing devices or making changes + * to them when this is a slow operation and json_lock isn't appropriate. + * + * Possible states of libxl__ev_devlock: + * Undefined + * Might contain anything. + * Idle + * Struct contents are defined enough to pass to any + * libxl__ev_devlock_* function. + * The struct does not contain references to any allocated private + * resources so can be thrown away. + * Active + * Waiting to get a lock. + * Needs to wait until the callback is called. + * LockAcquired + * libxl__ev_devlock_unlock will need to be called to release the lock + * and the resources of libxl__ev_devlock. + * + * libxl__ev_devlock_init: Undefined/Idle -> Idle + * libxl__ev_devlock_lock: Idle -> Active + * May call callback synchronously. + * libxl__ev_devlock_unlock: LockAcquired/Idle -> Idle + * callback: When called: Active -> LockAcquired (on error: Idle) + * The callback is only called once. + */ +struct libxl__ev_devlock { + /* filled by user */ + libxl__ao *ao; + libxl_domid domid; + void (*callback)(libxl__egc *, libxl__ev_devlock *, int rc); + /* private to libxl__ev_devlock* */ + libxl__ev_child child; + char *path; /* path of the lock file itself */ + int fd; + bool held; +}; +_hidden void libxl__ev_devlock_init(libxl__ev_devlock *); +_hidden void libxl__ev_devlock_lock(libxl__egc *, libxl__ev_devlock *); +_hidden void libxl__ev_devlock_unlock(libxl__gc *, libxl__ev_devlock *); + /* * QMP asynchronous calls * @@ -4689,54 +4737,6 @@ static inline const char *libxl__qemu_qmp_path(libxl__gc *gc, int domid) return GCSPRINTF("%s/qmp-libxl-%d", libxl__run_dir_path(), domid); } -/* - * Lock for device hotplug, qmp_lock. - * - * libxl__ev_devlock implement a lock that is outside of CTX_LOCK in the - * lock hierarchy. It can be used when one want to make QMP calls to QEMU, - * which may take a significant amount time. - * It is to be acquired by an ao event callback. - * - * It is to be acquired when adding/removing devices or making changes - * to them when this is a slow operation and json_lock isn't appropriate. - * - * Possible states of libxl__ev_devlock: - * Undefined - * Might contain anything. - * Idle - * Struct contents are defined enough to pass to any - * libxl__ev_devlock_* function. - * The struct does not contain references to any allocated private - * resources so can be thrown away. - * Active - * Waiting to get a lock. - * Needs to wait until the callback is called. - * LockAcquired - * libxl__ev_devlock_unlock will need to be called to release the lock - * and the resources of libxl__ev_devlock. - * - * libxl__ev_devlock_init: Undefined/Idle -> Idle - * libxl__ev_devlock_lock: Idle -> Active - * May call callback synchronously. - * libxl__ev_devlock_unlock: LockAcquired/Idle -> Idle - * callback: When called: Active -> LockAcquired (on error: Idle) - * The callback is only called once. - */ -struct libxl__ev_devlock { - /* filled by user */ - libxl__ao *ao; - libxl_domid domid; - void (*callback)(libxl__egc *, libxl__ev_devlock *, int rc); - /* private to libxl__ev_devlock* */ - libxl__ev_child child; - char *path; /* path of the lock file itself */ - int fd; - bool held; -}; -_hidden void libxl__ev_devlock_init(libxl__ev_devlock *); -_hidden void libxl__ev_devlock_lock(libxl__egc *, libxl__ev_devlock *); -_hidden void libxl__ev_devlock_unlock(libxl__gc *, libxl__ev_devlock *); - /* Send control commands over xenstore and wait for an Ack. */ _hidden int libxl__domain_pvcontrol(libxl__egc *egc, libxl__xswait_state *pvcontrol,