From nobody Mon Feb 9 12:47:35 2026 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=1568891155; cv=none; d=zoho.com; s=zohoarc; b=fSPG8RWm74bQ3IIXMORjHu+3mDcc1A0HplHbK2AaPbKDTGaTUOQG2Dpyi9HGQfYhk4rMGzgjrhgFVvMYl28A9ul2pnf2+EbIfMm2Sa/TbjP2TvdPo3fMd9F9mpZ0jTXJMlHhn9vO4GhVjhPFYEX9eSF0sFWHXCVgM38zc8/LZIM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568891155; 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=3ivRIY5xWRSJ8qceQozDe67tgonf2TQceQCzlvTXxLQ=; b=Uy/XvGPu4T0ItaAxYlliwWTn+f8haDzpiVDfI547t88q2o/rgulq9ssdNSdhIzU0BefS+oV7/mC0ZXy5IFKBXLIvPrrwuizJM00zcANWJxaQBLj1TW/6hbt4zxWOo2TjcNSzICFtHfhwl9ja3pNaCiYj4mhe3ij2Tfi5ohaPFyE= 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 1568891155012665.9609324612957; Thu, 19 Sep 2019 04:05:55 -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 1iAuF3-00037t-A6; Thu, 19 Sep 2019 11:04:53 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iAuF2-00037N-0p for xen-devel@lists.xenproject.org; Thu, 19 Sep 2019 11:04:52 +0000 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 4ac876a6-dacd-11e9-b76c-bc764e2007e4; Thu, 19 Sep 2019 11:04:47 +0000 (UTC) X-Inumbo-ID: 4ac876a6-dacd-11e9-b76c-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1568891087; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=i+v4FFNS5LSgTV17QujL1d9bwkzUvxKQvjAdyIy2DVA=; b=aqmXwJOev81sA0eL4bhDDPzZ1/z0JE64d/Uu3xN4qQ2R/khZnB9QTydM vkj4AsQedMwmW64eOJCES09J1qiJ1gLf+DvXUrSfkeGoHf9jdwMFXe/Fb B3gyBgWcLXV9zT7daoRuDed1QLlLt6/0dScvJWvh4ald5YVefjSjQuMbt Y=; Authentication-Results: esa3.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 (esa3.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=esa3.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa3.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=esa3.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 (esa3.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=esa3.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: sdBpOHnkd/enjFQxwa63ywNuhc5XI6TXJl4psaOS+EjU+Vb1ryZ4AYnvlrVH969g1dT1A+utA+ QwAiW44gw0drdHFSiTVOLjmrXsf/f0R/mymg6jkweOuOe0UWMour7OIt9/AMyqHjpV/afo5Tjk 5DTxEkQWV9tfmSZHJ7Yfqta3Zz5jh+M0iNWEhNvqHUM76IK6zl3/Ldz3IPieQDMQV5ZlvrX/2Q OCmwsqy79yBz9LAzizt9xfycZMbIVTQxJO/akfIYgEbrM0+r9+OHE8m7psfVN/3+d2BbgjqIEm hsA= X-SBRS: 2.7 X-MesageID: 5782654 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,523,1559534400"; d="scan'208";a="5782654" From: Anthony PERARD To: Date: Thu, 19 Sep 2019 12:04:35 +0100 Message-ID: <20190919110443.817594-2-anthony.perard@citrix.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190919110443.817594-1-anthony.perard@citrix.com> References: <20190919110443.817594-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 1/9] libxl_internal: Remove lost comment 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 , Wei Liu , Ian Jackson , Wei Liu 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) That comment as been separated from the function it defines by 4197d3abbb3055d3798254eb7ba239bfb5824360, but then was not useful anymore when the libxl__device_disk_add() prototype was removed by 22ea8ad02e465e32cd40887c750b55c3a997a288. Signed-off-by: Anthony PERARD Acked-by: Wei Liu Acked-by: Ian Jackson --- tools/libxl/libxl_internal.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index e7d977793082..a3e4b907b7c9 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -2719,13 +2719,6 @@ struct libxl__multidev { * DONE. */ =20 -/* AO operation to connect a disk device, called by - * libxl_device_disk_add and libxl__add_disks. This function calls - * libxl__wait_device_connection to wait for the device to - * finish the connection (might involve executing hotplug scripts). - * - * Once finished, aodev->callback will be executed. - */ /* * As of Xen 4.5 we maintain various information, including hotplug * device information, in JSON files, so that we can use this JSON --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Feb 9 12:47:35 2026 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=1568891161; cv=none; d=zoho.com; s=zohoarc; b=HfUM505J1Mz95hX8ZZw9tDnBfjU7C/X9e3ROCoXt5yssqIYeYvFLRwCzliRwct7h5/3Z1gSZJrDvhyCDCyHrIm6Cj/KUenLcy47+9Pu2iYk0Hc5mlgLQ9zlRxiPi+MWqEZacQ/VQ04T2omCvJlUUPi3p2wuOZV/Gb8rszA3Fvfw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568891161; 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=nTFZWiZT1LHKePyCV4ZDiutG55gaC0x+lUov12Gi2Tc=; b=Q46MEL86N6hmA+0TY1auHPg1kIWxI/RoRRQFGsDDTy1NOpAfTuIHVeTul0vR0m7nv3WSGH9CFD0AG1LuWHcHMzi5sEzQK/Tlh3745v9YZnFdfc5Ia1IL4UNtgWpNKNZ88VyrhcayjwZyFo8lh55vBZEizs1/24qxfhFhF3XRUpo= 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 156889116152192.52229633970853; Thu, 19 Sep 2019 04:06:01 -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 1iAuF8-0003Ab-6u; Thu, 19 Sep 2019 11:04:58 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iAuF7-00039q-20 for xen-devel@lists.xenproject.org; Thu, 19 Sep 2019 11:04:57 +0000 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 4ad232f4-dacd-11e9-978d-bc764e2007e4; Thu, 19 Sep 2019 11:04:47 +0000 (UTC) X-Inumbo-ID: 4ad232f4-dacd-11e9-978d-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1568891087; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mrsRuwynkbymOCcoesCdW4GjkY00KLS1YUIo7f9zr98=; b=PS1A9cAZzFi7O/52R8m25JW/j1qzreSkutNhxu1E4v7tBMlnm/TAsd8P 9SQ80og2EI6axW3FCpEBYFzFF1zBnMeF+cF42B6hbS3suu/w6Q5gDKHGi EhzohlQXO6rvQKWXA1w58LuIRxAEN1TUZ3uDQtkGD0VmFKxo6/Vk+i8NR Q=; Authentication-Results: esa3.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 (esa3.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=esa3.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa3.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=esa3.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 (esa3.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=esa3.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: 30G5kPlXesu8YAIC8wwTlqpgVzjqFg2OdYLE34R8OiE4El2VUV9UTarfKjbPXlUpEujqiywbNB sKUYQC0TQEmCNoy3Fq2BqI60mtwjde7txms6AyrK2l6sFAXLyva4vbDiOhwhsSPipwa5WoVi+W QWdME3A40RyrFWKKycAEDvuMw9R9QMFwPhnnY1/yA3vynUVYK4xqv1bwJhFCmzJsqz+Hw/UKop C7WDUKutjI6AkJQoqMra8rCeBBi3Ku/pIdNn+OxDvZQhs5imA8d0scoTU/2vLzuiUEedtiS/Wb ENg= X-SBRS: 2.7 X-MesageID: 5782655 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,523,1559534400"; d="scan'208";a="5782655" From: Anthony PERARD To: Date: Thu, 19 Sep 2019 12:04:36 +0100 Message-ID: <20190919110443.817594-3-anthony.perard@citrix.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190919110443.817594-1-anthony.perard@citrix.com> References: <20190919110443.817594-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 2/9] libxl: Pointer on usage of libxl__domain_userdata_lock 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 , Ian Jackson , Wei Liu 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) It is currently difficult to know how/when/why the userdata lock is supposed to be used. Add some pointers to the hotplug comments. Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- tools/libxl/libxl_internal.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index a3e4b907b7c9..03e086480ca3 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -4477,6 +4477,12 @@ void libxl__unlock_domain_userdata(libxl__domain_use= rdata_lock *lock); * data store. The registry entry in libxl private data store * is "libxl-json". * Caller must hold user data lock. + * + * Other names used for this lock throughout the libxl code are json_lock, + * libxl__domain_userdata_lock, "libxl-json", data store lock. + * + * See the comment for libxl__ao_device, and "Algorithm for handling device + * removal", for information about using the libxl-json lock / json_lock. */ int libxl__get_domain_configuration(libxl__gc *gc, uint32_t domid, libxl_domain_config *d_config); --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Feb 9 12:47:35 2026 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=1568891171; cv=none; d=zoho.com; s=zohoarc; b=hDdSIxN19YFUyZuTp3VnCNFyqf/SdY1N3V13iCqcPm3XFPwwx6NTFAmWgOTtpWvQzHFghR1+vhEYG37zjH21ZOs2GhtDsC+2lgRwSRKeoNimnD2qu9ygwHjvrprFFEDPqEG+7N20cMbj1kPKIrvx6qEgAsXpaMQ9bdcwWaT35iE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568891171; 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=Ga/MR3EvkSUZlBy5jXyPcG3gBO1EEEvF1Co/yfslsmQ=; b=Q3uYjvytuFydeV1TC0MniJeFUgK6MiwdGBJbWvKtwBFkgRqGj96j6NwV34EjMtL2nU3AnIkElknexgwtsjaRFxx9PsjX1UrRcvORUQJ+C/mWSd9oiKZ+mBGuFxYEgOkOYN16DN1ojR9EYzYMMY2dKtgarlvRBBjadCkqL0+QqKs= 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 1568891171103220.44598908749947; Thu, 19 Sep 2019 04:06:11 -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 1iAuFE-0003G3-H7; Thu, 19 Sep 2019 11:05:04 +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 1iAuFC-0003Ek-NE for xen-devel@lists.xenproject.org; Thu, 19 Sep 2019 11:05:02 +0000 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 4d563458-dacd-11e9-9656-12813bfff9fa; Thu, 19 Sep 2019 11:04:51 +0000 (UTC) X-Inumbo-ID: 4d563458-dacd-11e9-9656-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1568891091; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AJMmAYEqyRooJeKHzVCA8PJ0DcCsBrHvXRZS/oznQNI=; b=bm0JJ5RDV5DP+OBxQbYGvMhp89Nv8ME27ZfvMTGXWa/2fOxv6To8RBX6 OrwtdOIgtw9MD9qVa9r9Wf3Pll/PfYwuwZtR0qviGtuTuayb9o0Ga1+RQ YGU1V/EZ/oazqB31eGVcFbTv1Eg3dkMQbeN4NW4EDMay85GHHDjR7CQ1d o=; Authentication-Results: esa5.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 (esa5.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=esa5.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa5.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=esa5.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 (esa5.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=esa5.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: 30rZysVDmeYvhpXMYE5h4RWfLqcCQrN+bv7XTI37/BoUAhNZl9Mn13lEyUJ7nG00AYqeZSBYd1 XLS0PcRTR5/Mdp9JnHqUYe+raUKWa4ovXeI8k8xZ4LBSm45amFQTNJk2C2NnDsCb+yKkS2I3o+ bMWilgg3PZVLSwJp+jTu+IkezZroHl2xhtGurUEr/PF+icX/dnsOTVQU7FietGNWBZM3BqAtzI xwLk+GmhmCuTmtWoMHGwNMmB7U1F3gexvMyhpiUtMmUqfOpdQDveLjI6ECkSTGIeNlFJ/Weul8 ZFI= X-SBRS: 2.7 X-MesageID: 5984932 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,523,1559534400"; d="scan'208";a="5984932" From: Anthony PERARD To: Date: Thu, 19 Sep 2019 12:04:37 +0100 Message-ID: <20190919110443.817594-4-anthony.perard@citrix.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190919110443.817594-1-anthony.perard@citrix.com> References: <20190919110443.817594-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 3/9] libxl_internal: Introduce libxl__ev_devlock for devices hotplug via QMP 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 , Ian Jackson , Wei Liu 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) The current lock `domain_userdata_lock' can't be used when modification to a guest is done by sending command to QEMU, this is a slow process and requires to call CTX_UNLOCK, which is not possible while holding the `domain_userdata_lock'. To resolve this issue, we create a new lock which can take over part of the job of the json_lock. This lock is outside CTX_LOCK in the lock hierarchy. libxl__ev_devlock_lock will have CTX_UNLOCK before trying to grab the ev_devlock. The callback is used to notify when the ev_devlock have been acquired. Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- Notes: v3: - fix use of LOGED where errno numeric value was printed. - change comment in libxl__ev_unlock to refer to the one in libxl__unlock_domain_userdata() instead of making a copy of it. - rename ev_lock to ev_devlock. (And _get to _lock.) =20 v2: - new patch, to replace 2 patch implement a different lock tools/libxl/libxl_internal.c | 163 +++++++++++++++++++++++++++++++++++ tools/libxl/libxl_internal.h | 76 +++++++++++++++- 2 files changed, 235 insertions(+), 4 deletions(-) diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c index f492dae5ff70..28a126ccc342 100644 --- a/tools/libxl/libxl_internal.c +++ b/tools/libxl/libxl_internal.c @@ -575,6 +575,169 @@ void libxl__update_domain_configuration(libxl__gc *gc, dst->b_info.video_memkb =3D src->b_info.video_memkb; } =20 +void libxl__ev_devlock_init(libxl__ev_devlock *lock) +{ + libxl__ev_child_init(&lock->child); + lock->path =3D NULL; + lock->fd =3D -1; + lock->held =3D false; +} + +static void ev_lock_prepare_fork(libxl__egc *egc, libxl__ev_devlock *lock); +static void ev_lock_child_callback(libxl__egc *egc, libxl__ev_child *child, + pid_t pid, int status); + +void libxl__ev_devlock_lock(libxl__egc *egc, libxl__ev_devlock *lock) +{ + STATE_AO_GC(lock->ao); + const char *lockfile; + + lockfile =3D libxl__userdata_path(gc, lock->domid, + "libxl-device-changes-lock", "l"); + if (!lockfile) goto out; + lock->path =3D libxl__strdup(NOGC, lockfile); + + ev_lock_prepare_fork(egc, lock); + return; +out: + lock->callback(egc, lock, ERROR_LOCK_FAIL); +} + +static void ev_lock_prepare_fork(libxl__egc *egc, libxl__ev_devlock *lock) +{ + STATE_AO_GC(lock->ao); + pid_t pid; + int fd; + + /* Convenience aliases */ + libxl_domid domid =3D lock->domid; + const char *lockfile =3D lock->path; + + lock->fd =3D open(lockfile, O_RDWR|O_CREAT, 0666); + if (lock->fd < 0) { + LOGED(ERROR, domid, "cannot open lockfile %s", lockfile); + goto out; + } + fd =3D lock->fd; + + pid =3D libxl__ev_child_fork(gc, &lock->child, ev_lock_child_callback); + if (pid < 0) + goto out; + if (!pid) { + /* child */ + int exit_val =3D 0; + + /* Lock the file in exclusive mode, wait indefinitely to + * acquire the lock */ + while (flock(fd, LOCK_EX)) { + switch (errno) { + case EINTR: + /* Signal received, retry */ + continue; + default: + /* All other errno: EBADF, EINVAL, ENOLCK, EWOULDBLOCK */ + LOGED(ERROR, domid, + "unexpected error while trying to lock %s, fd=3D%d", + lockfile, fd); + exit_val =3D 1; + break; + } + } + _exit(exit_val); + } + + /* Now that the child has the fd, set cloexec in the parent to prevent + * more leakage than necessary */ + libxl_fd_set_cloexec(CTX, fd, 1); + return; +out: + libxl__ev_devlock_unlock(gc, lock); + lock->callback(egc, lock, ERROR_LOCK_FAIL); +} + +static void ev_lock_child_callback(libxl__egc *egc, libxl__ev_child *child, + pid_t pid, int status) +{ + EGC_GC; + libxl__ev_devlock *lock =3D CONTAINER_OF(child, *lock, child); + struct stat stab, fstab; + int rc =3D ERROR_LOCK_FAIL; + + /* Convenience aliases */ + int fd =3D lock->fd; + const char *lockfile =3D lock->path; + libxl_domid domid =3D lock->domid; + + if (status) { + libxl_report_child_exitstatus(CTX, XTL_ERROR, "flock child", + pid, status); + goto out; + } + + if (fstat(fd, &fstab)) { + LOGED(ERROR, domid, "cannot fstat %s, fd=3D%d", lockfile, fd); + goto out; + } + if (stat(lockfile, &stab)) { + if (errno !=3D ENOENT) { + LOGED(ERROR, domid, "cannot stat %s", lockfile); + goto out; + } + } else { + if (stab.st_dev =3D=3D fstab.st_dev && stab.st_ino =3D=3D fstab.st= _ino) { + /* We held the lock */ + lock->held =3D true; + rc =3D 0; + goto out; + } + } + + /* We didn't grab the lock, let's try again */ + flock(lock->fd, LOCK_UN); + close(lock->fd); + lock->fd =3D -1; + ev_lock_prepare_fork(egc, lock); + return; + +out: + if (lock->held) { + /* Check the domain is still there, if not we should release the + * lock and clean up. */ + if (libxl_domain_info(CTX, NULL, domid)) + rc =3D ERROR_LOCK_FAIL; + } + if (rc) { + LOGD(ERROR, domid, "Failed to grab qmp-lock"); + libxl__ev_devlock_unlock(gc, lock); + } + lock->callback(egc, lock, rc); +} + +void libxl__ev_devlock_unlock(libxl__gc *gc, libxl__ev_devlock *lock) +{ + int r; + + assert(!libxl__ev_child_inuse(&lock->child)); + + /* See the rationale in libxl__unlock_domain_userdata() + * about why we do unlink() before unlock(). */ + + if (lock->path && lock->held) + unlink(lock->path); + + if (lock->fd >=3D 0) { + /* We need to call unlock as the fd may have leaked into other + * processes */ + r =3D flock(lock->fd, LOCK_UN); + if (r) + LOGED(ERROR, lock->domid, "failed to unlock fd=3D%d, path=3D%s= ", + lock->fd, lock->path); + close(lock->fd); + } + free(lock->path); + libxl__ev_devlock_init(lock); +} + /* * Local variables: * mode: C diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 03e086480ca3..c7bcde5edae7 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -194,6 +194,7 @@ typedef struct libxl__osevent_hook_nexus libxl__osevent= _hook_nexus; typedef struct libxl__osevent_hook_nexi libxl__osevent_hook_nexi; typedef struct libxl__json_object libxl__json_object; typedef struct libxl__carefd libxl__carefd; +typedef struct libxl__ev_devlock libxl__ev_devlock; =20 typedef struct libxl__domain_create_state libxl__domain_create_state; typedef void libxl__domain_create_cb(struct libxl__egc *egc, @@ -2724,11 +2725,11 @@ struct libxl__multidev { * device information, in JSON files, so that we can use this JSON * file as a template to reconstruct domain configuration. * - * In essense there are now two views of device state, one is xenstore, - * the other is JSON file. We use xenstore as primary reference. + * In essense there are now two views of device state, one is the + * primary config (xenstore or QEMU), the other is JSON file. * - * Here we maintain one invariant: every device in xenstore must have - * an entry in JSON file. + * Here we maintain one invariant: every device in the primary config + * must have an entry in JSON file. * * All device hotplug routines should comply to following pattern: * lock json config (json_lock) @@ -2743,6 +2744,24 @@ struct libxl__multidev { * end for loop * unlock json config * + * Or in case QEMU is the primary config, this pattern can be use: + * qmp_lock (libxl__ev_devlock) + * lock json config (json_lock) + * read json config + * update in-memory json config with new entry, replacing + * any stale entry + * unlock json config + * apply new config to primary config + * lock json config (json_lock) + * read json config + * update in-memory json config with new entry, replacing + * any stale entry + * write in-memory json config to disk + * unlock json config + * unlock qmp_lock + * (CTX_LOCK can be acquired and released several time while holding the + * qmp_lock) + * * Device removal routines are not touched. * * Here is the proof that we always maintain that invariant and we @@ -4603,6 +4622,55 @@ 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 *); + #endif =20 /* --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Feb 9 12:47:35 2026 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=1568891166; cv=none; d=zoho.com; s=zohoarc; b=mB2vsf4vKPoaEd9XANPeHj/3+SGujsGCjEZgVrYnl/pvU3Dk4QXuACI7xwXp4rjC8cqx3wBtnvFJt61Xw8NmWMvH7td/T2aVTuq1HTXGvjfZ6bWNG9mn/OP5DMOoxc9rlcGogemVnciRuIQU+JEQV+biu/GthcA692CG+vgNTWc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568891166; 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=g8PJENVUiaEAlCc9c2alvXBREOz6rkk7L9Owj6Fgh9s=; b=JCrGZOQqEurQhUsSS39Ea3rrZmqNSnj690yT48FVBFmTbWfFBQ501L+/EFuc/qb48MKM/EQLwm0XjsXOJkh2hsO5rK7cbFoCZksr4t5s7hV1AqBagm6Pf3ENokHjIJF9uLpAvaknZTk0KotUL7f5zpaILWjDRZmhW2oi83/uFAw= 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 156889116607175.92424155912045; Thu, 19 Sep 2019 04:06:06 -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 1iAuFE-0003Fb-54; Thu, 19 Sep 2019 11:05:04 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iAuFC-0003E2-17 for xen-devel@lists.xenproject.org; Thu, 19 Sep 2019 11:05:02 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 4ad7a34c-dacd-11e9-978d-bc764e2007e4; Thu, 19 Sep 2019 11:04:47 +0000 (UTC) X-Inumbo-ID: 4ad7a34c-dacd-11e9-978d-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1568891088; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fHoVEVSkXhSzI0FXEPwiA7EymZytSRCNOJViXlquIBY=; b=MvGmJiCCV6+p1Wa2XM7im2A/U3ONJxkDD1ZzLu/cb8k8PIlca888oiFX TW0iEarSA9yTph+7viH9dHpkeHbUyDMYbVc16WzDcm6UYABuEWTGM3M21 k1n1bn4L8Eo+w4fxiK7pSZ5ih8TiKetm7s6HA8qJlayJJTSQTmOhFhEYb 8=; 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 (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 (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 ~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: b3mOAUbssE1nLUrHlgC6tF3e/1GbGZYplUh1f5b2WAR6Etw1u6qOEqeNWfXgq57nyJGKN1NE9I KZb6ZTpQLrV5AZx/cszib1024+LXc9kjYWNUOz7ymHqRoiwtsIWBAvn9FN4aNwOICv9zzrz0XD vu0nXgiK8Vdu4eCNeJSCpPieyuUrgJue9kt2e9JDHONreA7tFLVCxbdVrxIEF0sRHWcBf4fpMf /MYfHT2RBLFHxLAj/tN8KiOoMf/GOAG6//9V05Vl/wN/AuizgSRwVmXzs3IvLgf7TBd1AK8N90 6+A= X-SBRS: 2.7 X-MesageID: 5840081 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.64,523,1559534400"; d="scan'208";a="5840081" From: Anthony PERARD To: Date: Thu, 19 Sep 2019 12:04:38 +0100 Message-ID: <20190919110443.817594-5-anthony.perard@citrix.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190919110443.817594-1-anthony.perard@citrix.com> References: <20190919110443.817594-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 4/9] libxl: Add optimisation to ev_lock 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 , Ian Jackson , Wei Liu 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) It will often be the case that the lock is free to grab. So we first try to grab it before we have to fork. Even though in this case the locks are grabbed in the wrong order in the lock hierarchy (ev_lock should be outside of CTX_LOCK), it is fine to try without blocking. If that failed, we will release CTX_LOCK and try to grab both lock again in the right order. That optimisation is only enabled in releases (debug=3Dn) so the more complicated code with fork is actually exercised. Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- Notes: v2: - new patch tools/libxl/Makefile | 3 +++ tools/libxl/libxl_internal.c | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile index 6fdcbbddd6b6..4587a6fc9c65 100644 --- a/tools/libxl/Makefile +++ b/tools/libxl/Makefile @@ -35,6 +35,9 @@ ifeq ($(CONFIG_LIBNL),y) CFLAGS_LIBXL +=3D $(LIBNL3_CFLAGS) endif CFLAGS_LIBXL +=3D -Wshadow +ifeq ($(debug),y) +CFLAGS_LIBXL +=3D -DCONFIG_DEBUG +endif =20 LIBXL_LIBS-$(CONFIG_ARM) +=3D -lfdt =20 diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c index 28a126ccc342..a7a4d546c47a 100644 --- a/tools/libxl/libxl_internal.c +++ b/tools/libxl/libxl_internal.c @@ -620,6 +620,25 @@ static void ev_lock_prepare_fork(libxl__egc *egc, libx= l__ev_devlock *lock) } fd =3D lock->fd; =20 + /* Enable this optimisation only in releases, so the fork code is + * exercised while libxl is built with debug=3Dy. */ +#ifndef CONFIG_DEBUG + /* + * We try to grab the lock before forking as it is likely to be free. + * Even though we are supposed to CTX_UNLOCK before attempting to grab + * the ev_lock, it is fine to do a non-blocking request now with the + * CTX_LOCK held as if that fails we'll try again in a fork (CTX_UNLOCK + * will be called in libxl), that will avoid deadlocks. + */ + int r =3D flock(fd, LOCK_EX | LOCK_NB); + if (!r) { + libxl_fd_set_cloexec(CTX, fd, 1); + /* We held a lock, no need to fork but we need to check it. */ + ev_lock_child_callback(egc, &lock->child, 0, 0); + return; + } +#endif + pid =3D libxl__ev_child_fork(gc, &lock->child, ev_lock_child_callback); if (pid < 0) goto out; --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Feb 9 12:47:35 2026 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=1568891176; cv=none; d=zoho.com; s=zohoarc; b=PvetKJai+8EbYm561KynS5eHtZZgHMmC03+f/GpSDuJyqkiIu+5sLhy3SSdnW4hz2/TeietMpOdMVLwmrEWAqhi2oQPae+jaKfF/3uxbQPA2RQes6VLmSs2xMS15oF8XexH3YveCgLN4aKZw9XP9LrqL5myT2o6aMYk8Tj3YaBA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568891176; 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=Tsyr9xaq0jPxRqjX2mw8DOIJFqpHEwzNsib5kkFPqak=; b=NBnK6tWRL3jt3bBWiHanzorZ8cgJlLlFqpZtOmwZPIWSMf5mUnEwMXUWqj+QPl/lkmpSCTsSaTvHSTJBk2u0ve1g9UZtNbAP54GdUGQLdVv2Q1M3DbSL7ZR8x7NaX6OULUcmrbxNmC5aFYyFLrFu5HWSEIkABaRlflucH2RrOo4= 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 15688911767321000.623661077828; Thu, 19 Sep 2019 04:06:16 -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 1iAuFM-0003Of-Ip; Thu, 19 Sep 2019 11:05:12 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iAuFM-0003O1-1b for xen-devel@lists.xenproject.org; Thu, 19 Sep 2019 11:05:12 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 4bed6f82-dacd-11e9-978d-bc764e2007e4; Thu, 19 Sep 2019 11:04:49 +0000 (UTC) X-Inumbo-ID: 4bed6f82-dacd-11e9-978d-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1568891089; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WPGPd+U3DwPsd1GZMMH/6DxaE93zWxQ3yiYCslf+xeM=; b=hkmFGLMeMI/7jCARPjbCZTJHZudMZG3kdhN+9Tc2JO/tWl6wW9qMsS2A byavZnnat2xDjLlwitkWK/DV12tx3c+Km+Xs3EqQlZ0mYCfLWCW8y5pBW M2tphvLg217O6VvLqxCFJq4CPNS0f4ncQiP8uXEHfyZZAHi44dI6JC59F E=; 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 (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 (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 ~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: FPX8ygMcS1Xv95JRazkHa2B9OBNE7MprPCrM4JNwrNqd3YroZho6EIzgKdoT0EDim4R3WjX+UH zv+i4GpVICSVEPgzreAlw247HcRQV3jbkWlEl+DkbMHGgCotl08KYYevhXLfFyKj4a2kY8pnWO eh/3NNlxcxpDeonfKo+yiqm1w7+CgQnk1RyPNnsFDspCPDvbWgTatYn34VmTrUX8yTH3Bv+yL8 IJE5k/rAZhzeJzIqeYIRWaNHX1QgP4TNm2Tdwy/7niVf8EhukvfrEZWhuKyOzt5uEzokl9yJtC mvY= X-SBRS: 2.7 X-MesageID: 5840082 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.64,523,1559534400"; d="scan'208";a="5840082" From: Anthony PERARD To: Date: Thu, 19 Sep 2019 12:04:39 +0100 Message-ID: <20190919110443.817594-6-anthony.perard@citrix.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190919110443.817594-1-anthony.perard@citrix.com> References: <20190919110443.817594-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 5/9] libxl_disk: Reorganise libxl_cdrom_insert 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 , Ian Jackson , Wei Liu 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) This is in preparation of cutting libxl_cdrom_insert into several functions to allow asynchronous callbacks. No functional changes. Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- tools/libxl/libxl_disk.c | 58 ++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/tools/libxl/libxl_disk.c b/tools/libxl/libxl_disk.c index bc9e2d5a74e2..45bf555061df 100644 --- a/tools/libxl/libxl_disk.c +++ b/tools/libxl/libxl_disk.c @@ -647,7 +647,7 @@ int libxl_cdrom_insert(libxl_ctx *ctx, uint32_t domid, = libxl_device_disk *disk, { AO_CREATE(ctx, domid, ao_how); int num =3D 0, i; - libxl_device_disk *disks =3D NULL, disk_saved, disk_empty; + libxl_device_disk *disks =3D NULL, disk_saved; libxl_domain_config d_config; int rc, dm_ver; libxl__device device; @@ -658,16 +658,9 @@ int libxl_cdrom_insert(libxl_ctx *ctx, uint32_t domid,= libxl_device_disk *disk, flexarray_t *insert =3D NULL, *empty =3D NULL; =20 libxl_domain_config_init(&d_config); - libxl_device_disk_init(&disk_empty); libxl_device_disk_init(&disk_saved); libxl_device_disk_copy(ctx, &disk_saved, disk); =20 - disk_empty.format =3D LIBXL_DISK_FORMAT_EMPTY; - disk_empty.vdev =3D libxl__strdup(NOGC, disk->vdev); - disk_empty.pdev_path =3D libxl__strdup(NOGC, ""); - disk_empty.is_cdrom =3D 1; - libxl__device_disk_setdefault(gc, domid, &disk_empty, false); - libxl_domain_type type =3D libxl__domain_type(gc, domid); if (type =3D=3D LIBXL_DOMAIN_TYPE_INVALID) { rc =3D ERROR_FAIL; @@ -721,23 +714,6 @@ int libxl_cdrom_insert(libxl_ctx *ctx, uint32_t domid,= libxl_device_disk *disk, be_path =3D libxl__device_backend_path(gc, &device); libxl_path =3D libxl__device_libxl_path(gc, &device); =20 - insert =3D flexarray_make(gc, 4, 1); - - flexarray_append_pair(insert, "type", - libxl__device_disk_string_of_backend(disk->backe= nd)); - if (disk->format !=3D LIBXL_DISK_FORMAT_EMPTY) - flexarray_append_pair(insert, "params", - GCSPRINTF("%s:%s", - libxl__device_disk_string_of_format(disk->form= at), - disk->pdev_path)); - else - flexarray_append_pair(insert, "params", ""); - - empty =3D flexarray_make(gc, 4, 1); - flexarray_append_pair(empty, "type", - libxl__device_disk_string_of_backend(disk->backe= nd)); - flexarray_append_pair(empty, "params", ""); - /* Note: CTX lock is already held at this point so lock hierarchy * is maintained. */ @@ -750,11 +726,27 @@ int libxl_cdrom_insert(libxl_ctx *ctx, uint32_t domid= , libxl_device_disk *disk, /* We need to eject the original image first. This is implemented * by inserting empty media. JSON is not updated. */ + if (dm_ver =3D=3D LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN) { + libxl_device_disk disk_empty; + + libxl_device_disk_init(&disk_empty); + disk_empty.format =3D LIBXL_DISK_FORMAT_EMPTY; + disk_empty.vdev =3D libxl__strdup(NOGC, disk->vdev); + disk_empty.pdev_path =3D libxl__strdup(NOGC, ""); + disk_empty.is_cdrom =3D 1; + libxl__device_disk_setdefault(gc, domid, &disk_empty, false); + rc =3D libxl__qmp_insert_cdrom(gc, domid, &disk_empty); + libxl_device_disk_dispose(&disk_empty); if (rc) goto out; } =20 + empty =3D flexarray_make(gc, 4, 1); + flexarray_append_pair(empty, "type", + libxl__device_disk_string_of_backend(disk->backe= nd)); + flexarray_append_pair(empty, "params", ""); + for (;;) { rc =3D libxl__xs_transaction_start(gc, &t); if (rc) goto out; @@ -781,6 +773,10 @@ int libxl_cdrom_insert(libxl_ctx *ctx, uint32_t domid,= libxl_device_disk *disk, if (rc < 0) goto out; } =20 + /* + * Now that the drive is empty, we can insert the new media. + */ + rc =3D libxl__get_domain_configuration(gc, domid, &d_config); if (rc) goto out; =20 @@ -794,6 +790,17 @@ int libxl_cdrom_insert(libxl_ctx *ctx, uint32_t domid,= libxl_device_disk *disk, if (rc) goto out; } =20 + insert =3D flexarray_make(gc, 4, 1); + flexarray_append_pair(insert, "type", + libxl__device_disk_string_of_backend(disk->backend)); + if (disk->format !=3D LIBXL_DISK_FORMAT_EMPTY) + flexarray_append_pair(insert, "params", + GCSPRINTF("%s:%s", + libxl__device_disk_string_of_format(disk->format), + disk->pdev_path)); + else + flexarray_append_pair(insert, "params", ""); + for (;;) { rc =3D libxl__xs_transaction_start(gc, &t); if (rc) goto out; @@ -831,7 +838,6 @@ int libxl_cdrom_insert(libxl_ctx *ctx, uint32_t domid, = libxl_device_disk *disk, out: libxl__xs_transaction_abort(gc, &t); libxl__device_list_free(&libxl__disk_devtype, disks, num); - libxl_device_disk_dispose(&disk_empty); libxl_device_disk_dispose(&disk_saved); libxl_domain_config_dispose(&d_config); =20 --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Feb 9 12:47:35 2026 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=1568891160; cv=none; d=zoho.com; s=zohoarc; b=OTU+wGYoLoSXOQkOzxl/chZcisel4nZHF1NtuCqW1tq/GEmQj0zgU9kUwm/BaoEBHiPjKpaWnVSZ+WY1RZ0krYxA3cpG/49a+v1VWGrwyO/iNdjk0tgFz1FUvmHzLyrIoUqhXcKcw/WIM5oxK2pXUe7rd+Wghd6QYzHaAdsVebA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568891160; 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=y9ahk4D+TpkFqFvCDlPazgrcSJZpK8v0+CPw/+/xH/c=; b=F+dsWD4yT/ulhNRdLBVRtWv6+s9swjL+jL+hP6X9L7yC2Pb2gE/x7gizClmTC1Nsn5BcK65c/PS/mGrxAjuE07KZs0MAagQBjbeI1/zjahO6w2osfi1ZhHMqrRwDXCnQ2eWy+8lvrTJJSorSXISuKPBbUqtsSZ78hg0RQr3on+8= 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 1568891160140446.38960488678913; Thu, 19 Sep 2019 04:06:00 -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 1iAuF8-0003B1-I5; Thu, 19 Sep 2019 11:04:58 +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 1iAuF7-0003AJ-Mx for xen-devel@lists.xenproject.org; Thu, 19 Sep 2019 11:04:57 +0000 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 4a8b99ea-dacd-11e9-9656-12813bfff9fa; Thu, 19 Sep 2019 11:04:47 +0000 (UTC) X-Inumbo-ID: 4a8b99ea-dacd-11e9-9656-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1568891088; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=c/X1kAtunOTd0Rp883uPK6Xt10M+dQzHralPJlY9zws=; b=LDqYBLmMqWOdwy5s5wXXHnm7wIYDFzXUMf9APUYJc5DVE87f514/TVmY PWKY3jITL61IST00UyDRklENRRtvZhBxwPQZPL38bB3b/Y8R2wLjxjGJr TZPV+NSGMsvMoJeZDeruPK57On9ygc1gBJNetef9CT0v1ueZV9CUJISvG g=; 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: ysXiLdwkv5v76d55sl3LorW8/e3qU83mlkaLYiOkyK/eKnXbtUDlOefHsNWDCdp597II/b94Z2 KBwu0riujcTWXZw6w7Y1c5BEircF6JaZwFznry6ZYCzxp9zMxUZS5Q6xUBYQye+wtKmtWyPRmK 5SINhAIIll6aegyFBu23p26YuEophLuDpsp0fkvG6qV1GGyQhwNYvh9ENIKhKzPPyt4aP37a0/ 4zYBM6bU7Oc8Cz7Vt3NysGlnWfTUM+NZrgPf2mXoWOsas4bCcOrO8rt6V+7i0s8cs7cnCxDb0G UWM= X-SBRS: 2.7 X-MesageID: 5777958 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,523,1559534400"; d="scan'208";a="5777958" From: Anthony PERARD To: Date: Thu, 19 Sep 2019 12:04:40 +0100 Message-ID: <20190919110443.817594-7-anthony.perard@citrix.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190919110443.817594-1-anthony.perard@citrix.com> References: <20190919110443.817594-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 6/9] libxl_disk: Cut libxl_cdrom_insert into steps .. 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 , Ian Jackson , Wei Liu 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) .. and use a new "slow" lock to avoid holding the userdata lock across several functions. This patch cuts libxl_cdrom_insert into different step/function but there are still called synchronously. (Taking the ev_lock is the only step that might be asynchronous.) A later patch will call them asynchronously when QMP is involved. Thee userdata lock (json_lock) use to protect against concurrent change of cdrom is replaced by an ev_lock which can be held across different CTX_LOCK sections. The json_lock is still used when reading/modifying the domain userdata (mandatory) and update xenstore (mostly because it's updated as the same time as the userdata). Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- Notes: v2: - rewrite patch description - rework use of the new lock tools/libxl/libxl_disk.c | 196 +++++++++++++++++++++++++++++++-------- 1 file changed, 155 insertions(+), 41 deletions(-) diff --git a/tools/libxl/libxl_disk.c b/tools/libxl/libxl_disk.c index 45bf555061df..98023f169ce6 100644 --- a/tools/libxl/libxl_disk.c +++ b/tools/libxl/libxl_disk.c @@ -642,24 +642,43 @@ int libxl_device_disk_getinfo(libxl_ctx *ctx, uint32_= t domid, return rc; } =20 +typedef struct { + libxl__ao *ao; + libxl_domid domid; + libxl_device_disk *disk; + libxl_device_disk disk_saved; + libxl__ev_devlock qmp_lock; + int dm_ver; +} libxl__cdrom_insert_state; + +static void cdrom_insert_lock_acquired(libxl__egc *, libxl__ev_devlock *, + int rc); +static void cdrom_insert_ejected(libxl__egc *egc, + libxl__cdrom_insert_state *cis); +static void cdrom_insert_inserted(libxl__egc *egc, + libxl__cdrom_insert_state *cis); +static void cdrom_insert_done(libxl__egc *egc, + libxl__cdrom_insert_state *cis, + int rc); + int libxl_cdrom_insert(libxl_ctx *ctx, uint32_t domid, libxl_device_disk *= disk, const libxl_asyncop_how *ao_how) { AO_CREATE(ctx, domid, ao_how); int num =3D 0, i; - libxl_device_disk *disks =3D NULL, disk_saved; - libxl_domain_config d_config; - int rc, dm_ver; - libxl__device device; - const char *be_path, *libxl_path; - char * tmp; - libxl__domain_userdata_lock *lock =3D NULL; - xs_transaction_t t =3D XBT_NULL; - flexarray_t *insert =3D NULL, *empty =3D NULL; - - libxl_domain_config_init(&d_config); - libxl_device_disk_init(&disk_saved); - libxl_device_disk_copy(ctx, &disk_saved, disk); + libxl_device_disk *disks =3D NULL; + int rc; + libxl__cdrom_insert_state *cis; + + GCNEW(cis); + cis->ao =3D ao; + cis->domid =3D domid; + cis->disk =3D disk; + libxl_device_disk_init(&cis->disk_saved); + libxl_device_disk_copy(ctx, &cis->disk_saved, disk); + libxl__ev_devlock_init(&cis->qmp_lock); + cis->qmp_lock.ao =3D ao; + cis->qmp_lock.domid =3D domid; =20 libxl_domain_type type =3D libxl__domain_type(gc, domid); if (type =3D=3D LIBXL_DOMAIN_TYPE_INVALID) { @@ -678,8 +697,8 @@ int libxl_cdrom_insert(libxl_ctx *ctx, uint32_t domid, = libxl_device_disk *disk, goto out; } =20 - dm_ver =3D libxl__device_model_version_running(gc, domid); - if (dm_ver =3D=3D -1) { + cis->dm_ver =3D libxl__device_model_version_running(gc, domid); + if (cis->dm_ver =3D=3D -1) { LOGD(ERROR, domid, "Cannot determine device model version"); rc =3D ERROR_FAIL; goto out; @@ -708,40 +727,82 @@ int libxl_cdrom_insert(libxl_ctx *ctx, uint32_t domid= , libxl_device_disk *disk, disk->format =3D LIBXL_DISK_FORMAT_EMPTY; } =20 - rc =3D libxl__device_from_disk(gc, domid, disk, &device); - if (rc) goto out; +out: + libxl__device_list_free(&libxl__disk_devtype, disks, num); + if (rc) { + cdrom_insert_done(egc, cis, rc); /* must be last */ + } else { + cis->qmp_lock.callback =3D cdrom_insert_lock_acquired; + libxl__ev_devlock_lock(egc, &cis->qmp_lock); /* must be last */ + } + return AO_INPROGRESS; +} =20 - be_path =3D libxl__device_backend_path(gc, &device); - libxl_path =3D libxl__device_libxl_path(gc, &device); +static void cdrom_insert_lock_acquired(libxl__egc *egc, + libxl__ev_devlock *lock, + int rc) +{ + libxl__cdrom_insert_state *cis =3D CONTAINER_OF(lock, *cis, qmp_lock); + STATE_AO_GC(cis->ao); =20 - /* Note: CTX lock is already held at this point so lock hierarchy - * is maintained. - */ - lock =3D libxl__lock_domain_userdata(gc, domid); - if (!lock) { - rc =3D ERROR_LOCK_FAIL; - goto out; - } + if (rc) goto out; =20 /* We need to eject the original image first. This is implemented * by inserting empty media. JSON is not updated. */ =20 - if (dm_ver =3D=3D LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN) { + if (cis->dm_ver =3D=3D LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN) { libxl_device_disk disk_empty; =20 libxl_device_disk_init(&disk_empty); disk_empty.format =3D LIBXL_DISK_FORMAT_EMPTY; - disk_empty.vdev =3D libxl__strdup(NOGC, disk->vdev); + disk_empty.vdev =3D libxl__strdup(NOGC, cis->disk->vdev); disk_empty.pdev_path =3D libxl__strdup(NOGC, ""); disk_empty.is_cdrom =3D 1; - libxl__device_disk_setdefault(gc, domid, &disk_empty, false); + libxl__device_disk_setdefault(gc, cis->domid, &disk_empty, false); =20 - rc =3D libxl__qmp_insert_cdrom(gc, domid, &disk_empty); + rc =3D libxl__qmp_insert_cdrom(gc, cis->domid, &disk_empty); libxl_device_disk_dispose(&disk_empty); if (rc) goto out; } =20 + cdrom_insert_ejected(egc, cis); /* must be last */ + return; + +out: + cdrom_insert_done(egc, cis, rc); /* must be last */ +} + +static void cdrom_insert_ejected(libxl__egc *egc, + libxl__cdrom_insert_state *cis) +{ + EGC_GC; + int rc; + libxl__domain_userdata_lock *data_lock =3D NULL; + libxl__device device; + const char *be_path, *libxl_path; + flexarray_t *empty =3D NULL; + xs_transaction_t t =3D XBT_NULL; + char *tmp; + libxl_domain_config d_config; + + /* convenience aliases */ + libxl_domid domid =3D cis->domid; + libxl_device_disk *disk =3D cis->disk; + + libxl_domain_config_init(&d_config); + + rc =3D libxl__device_from_disk(gc, domid, disk, &device); + if (rc) goto out; + be_path =3D libxl__device_backend_path(gc, &device); + libxl_path =3D libxl__device_libxl_path(gc, &device); + + data_lock =3D libxl__lock_domain_userdata(gc, domid); + if (!data_lock) { + rc =3D ERROR_LOCK_FAIL; + goto out; + } + empty =3D flexarray_make(gc, 4, 1); flexarray_append_pair(empty, "type", libxl__device_disk_string_of_backend(disk->backe= nd)); @@ -780,16 +841,66 @@ int libxl_cdrom_insert(libxl_ctx *ctx, uint32_t domid= , libxl_device_disk *disk, rc =3D libxl__get_domain_configuration(gc, domid, &d_config); if (rc) goto out; =20 - device_add_domain_config(gc, &d_config, &libxl__disk_devtype, &disk_sa= ved); + device_add_domain_config(gc, &d_config, &libxl__disk_devtype, + &cis->disk_saved); =20 rc =3D libxl__dm_check_start(gc, &d_config, domid); if (rc) goto out; =20 - if (dm_ver =3D=3D LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN) { + if (cis->dm_ver =3D=3D LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN) { rc =3D libxl__qmp_insert_cdrom(gc, domid, disk); if (rc) goto out; } =20 + rc =3D 0; + +out: + libxl__xs_transaction_abort(gc, &t); + libxl_domain_config_dispose(&d_config); + if (data_lock) libxl__unlock_domain_userdata(data_lock); + if (rc) { + cdrom_insert_done(egc, cis, rc); /* must be last */ + } else { + cdrom_insert_inserted(egc, cis); /* must be last */ + } +} + +static void cdrom_insert_inserted(libxl__egc *egc, + libxl__cdrom_insert_state *cis) +{ + EGC_GC; + int rc; + libxl__domain_userdata_lock *data_lock =3D NULL; + libxl_domain_config d_config; + flexarray_t *insert =3D NULL; + xs_transaction_t t =3D XBT_NULL; + libxl__device device; + const char *be_path, *libxl_path; + char *tmp; + + /* convenience aliases */ + libxl_domid domid =3D cis->domid; + libxl_device_disk *disk =3D cis->disk; + + libxl_domain_config_init(&d_config); + + rc =3D libxl__device_from_disk(gc, domid, disk, &device); + if (rc) goto out; + be_path =3D libxl__device_backend_path(gc, &device); + libxl_path =3D libxl__device_libxl_path(gc, &device); + + data_lock =3D libxl__lock_domain_userdata(gc, domid); + if (!data_lock) { + rc =3D ERROR_LOCK_FAIL; + goto out; + } + + rc =3D libxl__get_domain_configuration(gc, domid, &d_config); + if (rc) goto out; + + device_add_domain_config(gc, &d_config, &libxl__disk_devtype, + &cis->disk_saved); + insert =3D flexarray_make(gc, 4, 1); flexarray_append_pair(insert, "type", libxl__device_disk_string_of_backend(disk->backend)); @@ -830,21 +941,24 @@ int libxl_cdrom_insert(libxl_ctx *ctx, uint32_t domid= , libxl_device_disk *disk, if (rc < 0) goto out; } =20 - /* success, no actual async */ - libxl__ao_complete(egc, ao, 0); - rc =3D 0; =20 out: libxl__xs_transaction_abort(gc, &t); - libxl__device_list_free(&libxl__disk_devtype, disks, num); - libxl_device_disk_dispose(&disk_saved); libxl_domain_config_dispose(&d_config); + if (data_lock) libxl__unlock_domain_userdata(data_lock); + cdrom_insert_done(egc, cis, rc); /* must be last */ +} =20 - if (lock) libxl__unlock_domain_userdata(lock); +static void cdrom_insert_done(libxl__egc *egc, + libxl__cdrom_insert_state *cis, + int rc) +{ + EGC_GC; =20 - if (rc) return AO_CREATE_FAIL(rc); - return AO_INPROGRESS; + libxl__ev_devlock_unlock(gc, &cis->qmp_lock); + libxl_device_disk_dispose(&cis->disk_saved); + libxl__ao_complete(egc, cis->ao, rc); } =20 /* libxl__alloc_vdev only works on the local domain, that is the domain --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Feb 9 12:47:35 2026 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=1568891155; cv=none; d=zoho.com; s=zohoarc; b=SJz9xQJ/K/E2RGW6U2On4CZLzF0zMfdKAwSh+fpPs/wvyRC6xsfdJtE8elFnhVf8+vYuuYv8/Rc6sWD+EHbj76559N+09iltoAF4vSt7g0kHsUmy6QYPgLoEKY2vGAbxWKcL9M9KbmWgBPQM9AqwHeiDauI07+EMT+F3hxgUD3Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568891155; 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=6c5B5P7gnd+Giwmmh/r78bdxWYs5zr82vgWgjinC948=; b=E/8BkSyfX60+MksWhhgt3DRFKnXCUVNyVzBiT/Vz6E1rWz5Wpr0VmGNrxCZ/+prVVrPvqQamC8zQkrOTcike9kbEOIb1ySPZ0Hp597C5JLyjUlWFBZHTmxbFuK+hORDJxPev4rTtMd1dptZJbQA+JzRGPdGlbHUt3WeekY7ga38= 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 1568891155464536.4010943077487; Thu, 19 Sep 2019 04:05:55 -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 1iAuEy-00036Z-W0; Thu, 19 Sep 2019 11:04:48 +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 1iAuEx-000363-Qa for xen-devel@lists.xenproject.org; Thu, 19 Sep 2019 11:04:47 +0000 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 4a8b99e8-dacd-11e9-9656-12813bfff9fa; Thu, 19 Sep 2019 11:04:47 +0000 (UTC) X-Inumbo-ID: 4a8b99e8-dacd-11e9-9656-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1568891087; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mfUZwIzuuuh/8WmQvMze2vYPiSlJtD/slSslvGjSweM=; b=SMBHNn37t/rpggUBx8K7wbHIpXIKNIeNoIS60YUqqvbY69M1vqierRAV TjXqdPdSGIVIXrwLZzCNmAK8y00tqaOTnRqYNqNm8HZdok95kPMLhjzOz ATD47zWkY8O0hrRDrp5DDyaODLP5GTi8J4c5qx0zfNLPZbECnJp4hC++Q U=; 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: oZGbtYrxfOMH/DQrRI8r+nhGdBJo4BpUFeg83EMa7GMgJR9EmtOk1l7AZg0Wl3RmMsAWBtaLFj weWuPRLcmmtPIKUL2YSJX9MQMfwP5HSOPuDw72x/PYt8/XwwYh1eHKslpMUf8femkFE5jrjqye Prtj975t0iyXe4JFWl9xjIfeJdNLYsOmvjOnX+pOIxMTfGmiLzqrDwZ0OZSGiCEUn7nBzLS2k5 C9ZRazGRetfolDsW4pg52zQ/03cjDKvXc64E93BEj5qm2y7ZHT7qqUD+fIw/Wm/0IPllcO7dVP IyU= X-SBRS: 2.7 X-MesageID: 5777957 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,523,1559534400"; d="scan'208";a="5777957" From: Anthony PERARD To: Date: Thu, 19 Sep 2019 12:04:41 +0100 Message-ID: <20190919110443.817594-8-anthony.perard@citrix.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190919110443.817594-1-anthony.perard@citrix.com> References: <20190919110443.817594-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 7/9] libxl_disk: Implement missing timeout for libxl_cdrom_insert 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 , Ian Jackson , Wei Liu 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) After the patch "libxl_disk: Use ev_qmp in libxl_cdrom_insert" there will not be any kind of timeout, add one back. Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- Notes: Ian, in this patch, the timeout is setup after we have aquired the lock. Should we change that to also have a timeout waiting for the lock to be released? =20 v2: - patch move earlier in the series to keep bisectability. tools/libxl/libxl_disk.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tools/libxl/libxl_disk.c b/tools/libxl/libxl_disk.c index 98023f169ce6..5cc215906fcc 100644 --- a/tools/libxl/libxl_disk.c +++ b/tools/libxl/libxl_disk.c @@ -649,6 +649,7 @@ typedef struct { libxl_device_disk disk_saved; libxl__ev_devlock qmp_lock; int dm_ver; + libxl__ev_time time; } libxl__cdrom_insert_state; =20 static void cdrom_insert_lock_acquired(libxl__egc *, libxl__ev_devlock *, @@ -657,6 +658,9 @@ static void cdrom_insert_ejected(libxl__egc *egc, libxl__cdrom_insert_state *cis); static void cdrom_insert_inserted(libxl__egc *egc, libxl__cdrom_insert_state *cis); +static void cdrom_insert_timout(libxl__egc *egc, libxl__ev_time *ev, + const struct timeval *requested_abs, + int rc); static void cdrom_insert_done(libxl__egc *egc, libxl__cdrom_insert_state *cis, int rc); @@ -679,6 +683,7 @@ int libxl_cdrom_insert(libxl_ctx *ctx, uint32_t domid, = libxl_device_disk *disk, libxl__ev_devlock_init(&cis->qmp_lock); cis->qmp_lock.ao =3D ao; cis->qmp_lock.domid =3D domid; + libxl__ev_time_init(&cis->time); =20 libxl_domain_type type =3D libxl__domain_type(gc, domid); if (type =3D=3D LIBXL_DOMAIN_TYPE_INVALID) { @@ -747,6 +752,11 @@ static void cdrom_insert_lock_acquired(libxl__egc *egc, =20 if (rc) goto out; =20 + rc =3D libxl__ev_time_register_rel(ao, &cis->time, + cdrom_insert_timout, + LIBXL_HOTPLUG_TIMEOUT * 1000); + if (rc) goto out; + /* We need to eject the original image first. This is implemented * by inserting empty media. JSON is not updated. */ @@ -950,12 +960,23 @@ static void cdrom_insert_inserted(libxl__egc *egc, cdrom_insert_done(egc, cis, rc); /* must be last */ } =20 +static void cdrom_insert_timout(libxl__egc *egc, libxl__ev_time *ev, + const struct timeval *requested_abs, + int rc) +{ + EGC_GC; + libxl__cdrom_insert_state *cis =3D CONTAINER_OF(ev, *cis, time); + LOGD(ERROR, cis->domid, "cdrom insertion timed out"); + cdrom_insert_done(egc, cis, rc); +} + static void cdrom_insert_done(libxl__egc *egc, libxl__cdrom_insert_state *cis, int rc) { EGC_GC; =20 + libxl__ev_time_deregister(gc, &cis->time); libxl__ev_devlock_unlock(gc, &cis->qmp_lock); libxl_device_disk_dispose(&cis->disk_saved); libxl__ao_complete(egc, cis->ao, rc); --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Feb 9 12:47:35 2026 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=1568891168; cv=none; d=zoho.com; s=zohoarc; b=g4D7bUBxvEsQ9dhBmn78vri89Oi0fr4IVe6zD4ZbGKRIOtyWJMVSNd7cp6UbJdeZi+Ek0eO2vcIqbWBmwE/czfwKxZ4ljE9PeAp/18vOUXszAJwjwUDTWLkJFkIFQ+RInsCjMN2ht9dgp7m6G5lEN8LE6NV1oFsKviIyF6BqOYs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568891168; 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=TNpvw+XM6XZ7Lt0KAVTixpO6FAc8S52gqy9Vn16+qgk=; b=fFu4ZH12aovfTCPlFuKNHjwnwtq9n08/NfijdYRhtTVrVhZcPrjC8pzxBJYiBQaQ4TpKuEgBQzEdje+SxOf2Gkh1cP4SfkwMshy+d21ue1Mx6J59oYlQiorw1sZOIfvBZqC4jNW2kw/fXwlye63nPx9UGaC1Aez8c4d4xgiYsho= 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 1568891168863181.41342767987294; Thu, 19 Sep 2019 04:06:08 -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 1iAuF3-00038A-Lp; Thu, 19 Sep 2019 11:04:53 +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 1iAuF2-00037U-Me for xen-devel@lists.xenproject.org; Thu, 19 Sep 2019 11:04:52 +0000 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 4b30d16a-dacd-11e9-9656-12813bfff9fa; Thu, 19 Sep 2019 11:04:48 +0000 (UTC) X-Inumbo-ID: 4b30d16a-dacd-11e9-9656-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1568891088; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UeKCQHWeJOASb8rxm9HLX6TfIzx2QFYCoa+K6Ntx9wE=; b=GG4WoFjW1UQq4QbCSXnDnwS3U1nvieVGu0fLf44kR/Lag075o6wfWSnC AaRnyD0p5zBXu0SBT4BxinO+kPiuT+mh/300GVbMWf/YEAXzVz6oRkU+u jogNYT4hJYxGlvwjHJ7hk504fkTY5Wts9fQmSdat8nDcqlJnKmDRHg9DO c=; 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: 4ov39xbBXkBANKPfsPrLPvnx1FlUbvXQ6cS8VvY0RLC/HO7lxFakUaTFrrrHO6G4bbwOZtCA3J UExGUUVGis3ju0Oq5dDYOLgStknca1fixcUn7j8QWoRaHjqqk8YrkuHaNK43d7AtDx5gsk6/EW GmFbZpnIqdfXT0bcCT9z72yeBumibdA/O+OWWrDI+GqkjW3sWSdvnJPIhAl+Z0bcKeVg14i/B7 +ZeFpcCau40EaA7n/iprYUfN+1pTEBd2/ELA6s/Mkq/5vWsZIjWfmvBB+h+eVlB9VNN6EfrlvT wnU= X-SBRS: 2.7 X-MesageID: 5777960 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,523,1559534400"; d="scan'208";a="5777960" From: Anthony PERARD To: Date: Thu, 19 Sep 2019 12:04:42 +0100 Message-ID: <20190919110443.817594-9-anthony.perard@citrix.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190919110443.817594-1-anthony.perard@citrix.com> References: <20190919110443.817594-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 8/9] libxl: Move qmp_parameters_* prototypes to libxl_internal.h 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 , Ian Jackson , Wei Liu 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) .. and rename them to libxl__qmp_param_*. This is to allow other files than libxl_qmp.c to make QMP calls with parameters. Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- tools/libxl/libxl_internal.h | 15 ++++++++ tools/libxl/libxl_qmp.c | 75 +++++++++++++++++------------------- 2 files changed, 51 insertions(+), 39 deletions(-) diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index c7bcde5edae7..e85547e67672 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -470,6 +470,21 @@ struct libxl__ev_qmp { int msg_id; }; =20 +/* QMP parameters helpers */ + +_hidden void libxl__qmp_param_add_string(libxl__gc *gc, + libxl__json_object **param, + const char *name, const char *s); +_hidden void libxl__qmp_param_add_bool(libxl__gc *gc, + libxl__json_object **param, + const char *name, bool b); +_hidden void libxl__qmp_param_add_integer(libxl__gc *gc, + libxl__json_object **param, + const char *name, const int i); +#define QMP_PARAMETERS_SPRINTF(args, name, format, ...) \ + libxl__qmp_param_add_string(gc, args, name, \ + GCSPRINTF(format, __VA_ARGS__)) + =20 /* * evgen structures, which are the state we use for generating diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c index 9c4480a2b15f..693c5d705720 100644 --- a/tools/libxl/libxl_qmp.c +++ b/tools/libxl/libxl_qmp.c @@ -752,9 +752,9 @@ static void qmp_parameters_common_add(libxl__gc *gc, flexarray_append((*param)->u.map, arg); } =20 -static void qmp_parameters_add_string(libxl__gc *gc, - libxl__json_object **param, - const char *name, const char *argume= nt) +void libxl__qmp_param_add_string(libxl__gc *gc, + libxl__json_object **param, + const char *name, const char *argument) { libxl__json_object *obj; =20 @@ -764,9 +764,9 @@ static void qmp_parameters_add_string(libxl__gc *gc, qmp_parameters_common_add(gc, param, name, obj); } =20 -static void qmp_parameters_add_bool(libxl__gc *gc, - libxl__json_object **param, - const char *name, bool b) +void libxl__qmp_param_add_bool(libxl__gc *gc, + libxl__json_object **param, + const char *name, bool b) { libxl__json_object *obj; =20 @@ -775,9 +775,9 @@ static void qmp_parameters_add_bool(libxl__gc *gc, qmp_parameters_common_add(gc, param, name, obj); } =20 -static void qmp_parameters_add_integer(libxl__gc *gc, - libxl__json_object **param, - const char *name, const int i) +void libxl__qmp_param_add_integer(libxl__gc *gc, + libxl__json_object **param, + const char *name, const int i) { libxl__json_object *obj; =20 @@ -787,9 +787,6 @@ static void qmp_parameters_add_integer(libxl__gc *gc, qmp_parameters_common_add(gc, param, name, obj); } =20 -#define QMP_PARAMETERS_SPRINTF(args, name, format, ...) \ - qmp_parameters_add_string(gc, args, name, GCSPRINTF(format, __VA_ARGS_= _)) - /* * API */ @@ -975,7 +972,7 @@ int libxl__qmp_run_command_flexarray(libxl__gc *gc, int= domid, for (i =3D 0; i < array->count; i +=3D 2) { flexarray_get(array, i, &name); flexarray_get(array, i + 1, &value); - qmp_parameters_add_string(gc, &args, (char *)name, (char *)value); + libxl__qmp_param_add_string(gc, &args, (char *)name, (char *)value= ); } =20 return qmp_run_command(gc, domid, cmd, args, NULL, NULL); @@ -997,10 +994,10 @@ int libxl__qmp_pci_add(libxl__gc *gc, int domid, libx= l_device_pci *pcidev) if (!hostaddr) return -1; =20 - qmp_parameters_add_string(gc, &args, "driver", "xen-pci-passthrough"); + libxl__qmp_param_add_string(gc, &args, "driver", "xen-pci-passthrough"= ); QMP_PARAMETERS_SPRINTF(&args, "id", PCI_PT_QDEV_ID, pcidev->bus, pcidev->dev, pcidev->func); - qmp_parameters_add_string(gc, &args, "hostaddr", hostaddr); + libxl__qmp_param_add_string(gc, &args, "hostaddr", hostaddr); if (pcidev->vdevfn) { QMP_PARAMETERS_SPRINTF(&args, "addr", "%x.%x", PCI_SLOT(pcidev->vdevfn), PCI_FUNC(pcidev->= vdevfn)); @@ -1016,7 +1013,7 @@ int libxl__qmp_pci_add(libxl__gc *gc, int domid, libx= l_device_pci *pcidev) * reason to set the flag so this is ok. */ if (pcidev->permissive) - qmp_parameters_add_bool(gc, &args, "permissive", true); + libxl__qmp_param_add_bool(gc, &args, "permissive", true); =20 rc =3D qmp_synchronous_send(qmp, "device_add", args, NULL, NULL, qmp->timeout); @@ -1039,7 +1036,7 @@ static int qmp_device_del(libxl__gc *gc, int domid, c= har *id) if (!qmp) return ERROR_FAIL; =20 - qmp_parameters_add_string(gc, &args, "id", id); + libxl__qmp_param_add_string(gc, &args, "id", id); rc =3D qmp_synchronous_send(qmp, "device_del", args, NULL, NULL, qmp->timeout); if (rc =3D=3D 0) { @@ -1082,7 +1079,7 @@ int libxl__qmp_restore(libxl__gc *gc, int domid, cons= t char *state_file) { libxl__json_object *args =3D NULL; =20 - qmp_parameters_add_string(gc, &args, "filename", state_file); + libxl__qmp_param_add_string(gc, &args, "filename", state_file); =20 return qmp_run_command(gc, domid, "xen-load-devices-state", args, NULL, NULL); @@ -1094,10 +1091,10 @@ static int qmp_change(libxl__gc *gc, libxl__qmp_han= dler *qmp, libxl__json_object *args =3D NULL; int rc =3D 0; =20 - qmp_parameters_add_string(gc, &args, "device", device); - qmp_parameters_add_string(gc, &args, "target", target); + libxl__qmp_param_add_string(gc, &args, "device", device); + libxl__qmp_param_add_string(gc, &args, "target", target); if (arg) { - qmp_parameters_add_string(gc, &args, "arg", arg); + libxl__qmp_param_add_string(gc, &args, "arg", arg); } =20 rc =3D qmp_synchronous_send(qmp, "change", args, @@ -1115,7 +1112,7 @@ int libxl__qmp_set_global_dirty_log(libxl__gc *gc, in= t domid, bool enable) { libxl__json_object *args =3D NULL; =20 - qmp_parameters_add_bool(gc, &args, "enable", enable); + libxl__qmp_param_add_bool(gc, &args, "enable", enable); =20 return qmp_run_command(gc, domid, "xen-set-global-dirty-log", args, NULL, NULL); @@ -1132,8 +1129,8 @@ int libxl__qmp_insert_cdrom(libxl__gc *gc, int domid, if (disk->format =3D=3D LIBXL_DISK_FORMAT_EMPTY) { return qmp_run_command(gc, domid, "eject", args, NULL, NULL); } else { - qmp_parameters_add_string(gc, &args, "target", disk->pdev_path); - qmp_parameters_add_string(gc, &args, "arg", + libxl__qmp_param_add_string(gc, &args, "target", disk->pdev_path); + libxl__qmp_param_add_string(gc, &args, "arg", libxl__qemu_disk_format_string(disk->format)); return qmp_run_command(gc, domid, "change", args, NULL, NULL); } @@ -1143,7 +1140,7 @@ int libxl__qmp_cpu_add(libxl__gc *gc, int domid, int = idx) { libxl__json_object *args =3D NULL; =20 - qmp_parameters_add_integer(gc, &args, "id", idx); + libxl__qmp_param_add_integer(gc, &args, "id", idx); =20 return qmp_run_command(gc, domid, "cpu-add", args, NULL, NULL); } @@ -1201,10 +1198,10 @@ int libxl__qmp_nbd_server_start(libxl__gc *gc, int = domid, * } * } */ - qmp_parameters_add_string(gc, &data, "host", host); - qmp_parameters_add_string(gc, &data, "port", port); + libxl__qmp_param_add_string(gc, &data, "host", host); + libxl__qmp_param_add_string(gc, &data, "port", port); =20 - qmp_parameters_add_string(gc, &addr, "type", "inet"); + libxl__qmp_param_add_string(gc, &addr, "type", "inet"); qmp_parameters_common_add(gc, &addr, "data", data); =20 qmp_parameters_common_add(gc, &args, "addr", addr); @@ -1216,8 +1213,8 @@ int libxl__qmp_nbd_server_add(libxl__gc *gc, int domi= d, const char *disk) { libxl__json_object *args =3D NULL; =20 - qmp_parameters_add_string(gc, &args, "device", disk); - qmp_parameters_add_bool(gc, &args, "writable", true); + libxl__qmp_param_add_string(gc, &args, "device", disk); + libxl__qmp_param_add_bool(gc, &args, "writable", true); =20 return qmp_run_command(gc, domid, "nbd-server-add", args, NULL, NULL); } @@ -1226,8 +1223,8 @@ int libxl__qmp_start_replication(libxl__gc *gc, int d= omid, bool primary) { libxl__json_object *args =3D NULL; =20 - qmp_parameters_add_bool(gc, &args, "enable", true); - qmp_parameters_add_bool(gc, &args, "primary", primary); + libxl__qmp_param_add_bool(gc, &args, "enable", true); + libxl__qmp_param_add_bool(gc, &args, "primary", primary); =20 return qmp_run_command(gc, domid, "xen-set-replication", args, NULL, N= ULL); } @@ -1248,8 +1245,8 @@ int libxl__qmp_stop_replication(libxl__gc *gc, int do= mid, bool primary) { libxl__json_object *args =3D NULL; =20 - qmp_parameters_add_bool(gc, &args, "enable", false); - qmp_parameters_add_bool(gc, &args, "primary", primary); + libxl__qmp_param_add_bool(gc, &args, "enable", false); + libxl__qmp_param_add_bool(gc, &args, "primary", primary); =20 return qmp_run_command(gc, domid, "xen-set-replication", args, NULL, N= ULL); } @@ -1264,11 +1261,11 @@ int libxl__qmp_x_blockdev_change(libxl__gc *gc, int= domid, const char *parent, { libxl__json_object *args =3D NULL; =20 - qmp_parameters_add_string(gc, &args, "parent", parent); + libxl__qmp_param_add_string(gc, &args, "parent", parent); if (child) - qmp_parameters_add_string(gc, &args, "child", child); + libxl__qmp_param_add_string(gc, &args, "child", child); if (node) - qmp_parameters_add_string(gc, &args, "node", node); + libxl__qmp_param_add_string(gc, &args, "node", node); =20 return qmp_run_command(gc, domid, "x-blockdev-change", args, NULL, NUL= L); } @@ -1305,7 +1302,7 @@ int libxl__qmp_hmp(libxl__gc *gc, int domid, const ch= ar *command_line, { libxl__json_object *args =3D NULL; =20 - qmp_parameters_add_string(gc, &args, "command-line", command_line); + libxl__qmp_param_add_string(gc, &args, "command-line", command_line); =20 return qmp_run_command(gc, domid, "human-monitor-command", args, hmp_callback, output); @@ -1442,7 +1439,7 @@ static void dm_state_fd_ready(libxl__egc *egc, libxl_= _ev_qmp *ev, * the save operation is for a live migration rather than for taking a * snapshot. */ if (qmp_ev_qemu_compare_version(ev, 2, 11, 0) >=3D 0) - qmp_parameters_add_bool(gc, &args, "live", dsps->live); + libxl__qmp_param_add_bool(gc, &args, "live", dsps->live); QMP_PARAMETERS_SPRINTF(&args, "filename", "/dev/fdset/%d", fdset); rc =3D libxl__ev_qmp_send(gc, ev, "xen-save-devices-state", args); if (rc) --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Feb 9 12:47:35 2026 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=1568891173; cv=none; d=zoho.com; s=zohoarc; b=VyXz09Vo7yu+VEkygf/6gpK2rAtq7RPPTtH3dTTMviQ13YY0LpowXsswaKhrPWPBWgGYz+qU++Hevhd/GhkJujY5LyRAUJqhWM9V0aYlvj4kNmyacVChxSRlKdhkh0gXhAP/fhTHaAMzGyG1eLuc9fxAUJcU9ywyaToo0N512QQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568891173; 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=Er9a3ck0i9IOntUAqVqQwDZROyTACN0UUF2s8LKQePg=; b=VE8l8e+bw4RjYB+/RU+d4BPxYbs5opGaiSv/ZXKoh06dfTQM1OJPwkdMYF+DhroMwmxU+Bpa5Np5xFOZGYrdZRG5T5Vy6e1hgdyAc9lc2A+4YlLJ/7pxEzEvoE3TTCKv5Yfe4UPY4Ng05HFEeSfbr3NblqpTPUPWBuFkty8goiY= 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 15688911739841023.3298660236884; Thu, 19 Sep 2019 04:06:13 -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 1iAuFI-0003KZ-Vv; Thu, 19 Sep 2019 11:05:08 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iAuFH-0003Ii-1n for xen-devel@lists.xenproject.org; Thu, 19 Sep 2019 11:05:07 +0000 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 4acd6d32-dacd-11e9-978d-bc764e2007e4; Thu, 19 Sep 2019 11:04:47 +0000 (UTC) X-Inumbo-ID: 4acd6d32-dacd-11e9-978d-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1568891087; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KqTbJKINiIo+431UahBxtuHEzMV3isaEDu1HbAroc3E=; b=D1wG/hu+sWCk+qA0R7sfo3SpC/KNcBPufoHElSleDqAnQVg5Lk+8eA94 +YJqZWY97hkMNKA9/m2+6uIjKkP3iNu0+g4NhOByL+YwJvpkaEGv+RDJL dZBdQ5Ya7X81t/CdC/g5QbsWXgOzH2QNwuDOK/CIyfj7I4v3xhvKt7peo 8=; Authentication-Results: esa4.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 (esa4.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=esa4.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa4.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=esa4.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 (esa4.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=esa4.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: kQ77wTU15pPUH71gH2pfGXj4GZs9LGzoo37uPjO2O4Zs4uNON8WgCaqIajagEb18viYl0zi9XS 9EQc2YiFOADB17OoJORaa6hd3WIL3HEclPQB6ViaVuz+3Hfahg3GkkwZWVowq9M9v9+1N9ZrM6 3GFFtoGVmGoJ4dzJvEZV1MKfYnY5bFmxBh8NBOwYc97HzlBt4aQLedRI8Px5HtMFUqeCi6YeeN p7d3h1xlIEK3EHJJ9XNPCfuEy6ugwOqyxP2uaB+CaPSABjZZ9cWNujv+taerIzuded1vwn0zvY 6b0= X-SBRS: 2.7 X-MesageID: 6097789 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,523,1559534400"; d="scan'208";a="6097789" From: Anthony PERARD To: Date: Thu, 19 Sep 2019 12:04:43 +0100 Message-ID: <20190919110443.817594-10-anthony.perard@citrix.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190919110443.817594-1-anthony.perard@citrix.com> References: <20190919110443.817594-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 9/9] libxl_disk: Use ev_qmp in libxl_cdrom_insert 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 , Ian Jackson , Wei Liu 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) Make libxl_cdrom_insert asynchronous when QEMU is involved. And have the cdrom opened by libxl, sending a file descriptor to QEMU. The "opaque" parameter of the "add-fd" can help to figure out what a fdset in QEMU is used for. It can be queried by "query-fdsets". Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- Notes: v2: - acked - assert that there's no payload_fd before openning a cdrom file - renamed flag `asynchronous_callback' -> `has_callback' tools/libxl/libxl_disk.c | 126 +++++++++++++++++++++++++++-------- tools/libxl/libxl_internal.h | 1 - tools/libxl/libxl_qmp.c | 18 ----- 3 files changed, 100 insertions(+), 45 deletions(-) diff --git a/tools/libxl/libxl_disk.c b/tools/libxl/libxl_disk.c index 5cc215906fcc..05dc9c51f306 100644 --- a/tools/libxl/libxl_disk.c +++ b/tools/libxl/libxl_disk.c @@ -650,14 +650,17 @@ typedef struct { libxl__ev_devlock qmp_lock; int dm_ver; libxl__ev_time time; + libxl__ev_qmp qmp; } libxl__cdrom_insert_state; =20 static void cdrom_insert_lock_acquired(libxl__egc *, libxl__ev_devlock *, int rc); -static void cdrom_insert_ejected(libxl__egc *egc, - libxl__cdrom_insert_state *cis); -static void cdrom_insert_inserted(libxl__egc *egc, - libxl__cdrom_insert_state *cis); +static void cdrom_insert_ejected(libxl__egc *egc, libxl__ev_qmp *, + const libxl__json_object *, int rc); +static void cdrom_insert_addfd_cb(libxl__egc *egc, libxl__ev_qmp *, + const libxl__json_object *, int rc); +static void cdrom_insert_inserted(libxl__egc *egc, libxl__ev_qmp *, + const libxl__json_object *, int rc); static void cdrom_insert_timout(libxl__egc *egc, libxl__ev_time *ev, const struct timeval *requested_abs, int rc); @@ -684,6 +687,10 @@ int libxl_cdrom_insert(libxl_ctx *ctx, uint32_t domid,= libxl_device_disk *disk, cis->qmp_lock.ao =3D ao; cis->qmp_lock.domid =3D domid; libxl__ev_time_init(&cis->time); + libxl__ev_qmp_init(&cis->qmp); + cis->qmp.ao =3D ao; + cis->qmp.domid =3D domid; + cis->qmp.payload_fd =3D -1; =20 libxl_domain_type type =3D libxl__domain_type(gc, domid); if (type =3D=3D LIBXL_DOMAIN_TYPE_INVALID) { @@ -757,26 +764,22 @@ static void cdrom_insert_lock_acquired(libxl__egc *eg= c, LIBXL_HOTPLUG_TIMEOUT * 1000); if (rc) goto out; =20 - /* We need to eject the original image first. This is implemented - * by inserting empty media. JSON is not updated. + /* We need to eject the original image first. + * JSON is not updated. */ =20 if (cis->dm_ver =3D=3D LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN) { - libxl_device_disk disk_empty; - - libxl_device_disk_init(&disk_empty); - disk_empty.format =3D LIBXL_DISK_FORMAT_EMPTY; - disk_empty.vdev =3D libxl__strdup(NOGC, cis->disk->vdev); - disk_empty.pdev_path =3D libxl__strdup(NOGC, ""); - disk_empty.is_cdrom =3D 1; - libxl__device_disk_setdefault(gc, cis->domid, &disk_empty, false); + libxl__json_object *args =3D NULL; + int devid =3D libxl__device_disk_dev_number(cis->disk->vdev, + NULL, NULL); =20 - rc =3D libxl__qmp_insert_cdrom(gc, cis->domid, &disk_empty); - libxl_device_disk_dispose(&disk_empty); + QMP_PARAMETERS_SPRINTF(&args, "device", "ide-%i", devid); + cis->qmp.callback =3D cdrom_insert_ejected; + rc =3D libxl__ev_qmp_send(gc, &cis->qmp, "eject", args); if (rc) goto out; + } else { + cdrom_insert_ejected(egc, &cis->qmp, NULL, 0); /* must be last */ } - - cdrom_insert_ejected(egc, cis); /* must be last */ return; =20 out: @@ -784,10 +787,12 @@ static void cdrom_insert_lock_acquired(libxl__egc *eg= c, } =20 static void cdrom_insert_ejected(libxl__egc *egc, - libxl__cdrom_insert_state *cis) + libxl__ev_qmp *qmp, + const libxl__json_object *response, + int rc) { EGC_GC; - int rc; + libxl__cdrom_insert_state *cis =3D CONTAINER_OF(qmp, *cis, qmp); libxl__domain_userdata_lock *data_lock =3D NULL; libxl__device device; const char *be_path, *libxl_path; @@ -795,6 +800,7 @@ static void cdrom_insert_ejected(libxl__egc *egc, xs_transaction_t t =3D XBT_NULL; char *tmp; libxl_domain_config d_config; + bool has_callback =3D false; =20 /* convenience aliases */ libxl_domid domid =3D cis->domid; @@ -802,6 +808,8 @@ static void cdrom_insert_ejected(libxl__egc *egc, =20 libxl_domain_config_init(&d_config); =20 + if (rc) goto out; + rc =3D libxl__device_from_disk(gc, domid, disk, &device); if (rc) goto out; be_path =3D libxl__device_backend_path(gc, &device); @@ -857,9 +865,29 @@ static void cdrom_insert_ejected(libxl__egc *egc, rc =3D libxl__dm_check_start(gc, &d_config, domid); if (rc) goto out; =20 - if (cis->dm_ver =3D=3D LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN) { - rc =3D libxl__qmp_insert_cdrom(gc, domid, disk); + if (cis->dm_ver =3D=3D LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN && + disk->format !=3D LIBXL_DISK_FORMAT_EMPTY) { + libxl__json_object *args =3D NULL; + + assert(qmp->payload_fd =3D=3D -1); + qmp->payload_fd =3D open(disk->pdev_path, O_RDONLY); + if (qmp->payload_fd < 0) { + LOGED(ERROR, domid, "Failed to open cdrom file %s", + disk->pdev_path); + rc =3D ERROR_FAIL; + goto out; + } + + /* This free form parameter is not use by QEMU or libxl. */ + QMP_PARAMETERS_SPRINTF(&args, "opaque", "%s:%s", + libxl_disk_format_to_string(disk->format), + disk->pdev_path); + qmp->callback =3D cdrom_insert_addfd_cb; + rc =3D libxl__ev_qmp_send(gc, qmp, "add-fd", args); if (rc) goto out; + has_callback =3D true; + } else { + has_callback =3D false; } =20 rc =3D 0; @@ -870,16 +898,58 @@ static void cdrom_insert_ejected(libxl__egc *egc, if (data_lock) libxl__unlock_domain_userdata(data_lock); if (rc) { cdrom_insert_done(egc, cis, rc); /* must be last */ - } else { - cdrom_insert_inserted(egc, cis); /* must be last */ + } else if (!has_callback) { + /* Only called if no asynchronous callback are set. */ + cdrom_insert_inserted(egc, qmp, NULL, 0); /* must be last */ + } +} + +static void cdrom_insert_addfd_cb(libxl__egc *egc, + libxl__ev_qmp *qmp, + const libxl__json_object *response, + int rc) +{ + EGC_GC; + libxl__cdrom_insert_state *cis =3D CONTAINER_OF(qmp, *cis, qmp); + libxl__json_object *args =3D NULL; + const libxl__json_object *o; + int devid; + int fdset; + + /* convenience aliases */ + libxl_device_disk *disk =3D cis->disk; + + close(qmp->payload_fd); + qmp->payload_fd =3D -1; + + if (rc) goto out; + + o =3D libxl__json_map_get("fdset-id", response, JSON_INTEGER); + if (!o) { + rc =3D ERROR_FAIL; + goto out; } + fdset =3D libxl__json_object_get_integer(o); + + devid =3D libxl__device_disk_dev_number(disk->vdev, NULL, NULL); + QMP_PARAMETERS_SPRINTF(&args, "device", "ide-%i", devid); + QMP_PARAMETERS_SPRINTF(&args, "target", "/dev/fdset/%d", fdset); + libxl__qmp_param_add_string(gc, &args, "arg", + libxl__qemu_disk_format_string(disk->format)); + qmp->callback =3D cdrom_insert_inserted; + rc =3D libxl__ev_qmp_send(gc, qmp, "change", args); +out: + if (rc) + cdrom_insert_done(egc, cis, rc); /* must be last */ } =20 static void cdrom_insert_inserted(libxl__egc *egc, - libxl__cdrom_insert_state *cis) + libxl__ev_qmp *qmp, + const libxl__json_object *response, + int rc) { EGC_GC; - int rc; + libxl__cdrom_insert_state *cis =3D CONTAINER_OF(qmp, *cis, qmp); libxl__domain_userdata_lock *data_lock =3D NULL; libxl_domain_config d_config; flexarray_t *insert =3D NULL; @@ -894,6 +964,8 @@ static void cdrom_insert_inserted(libxl__egc *egc, =20 libxl_domain_config_init(&d_config); =20 + if (rc) goto out; + rc =3D libxl__device_from_disk(gc, domid, disk, &device); if (rc) goto out; be_path =3D libxl__device_backend_path(gc, &device); @@ -977,6 +1049,8 @@ static void cdrom_insert_done(libxl__egc *egc, EGC_GC; =20 libxl__ev_time_deregister(gc, &cis->time); + libxl__ev_qmp_dispose(gc, &cis->qmp); + if (cis->qmp.payload_fd >=3D 0) close(cis->qmp.payload_fd); libxl__ev_devlock_unlock(gc, &cis->qmp_lock); libxl_device_disk_dispose(&cis->disk_saved); libxl__ao_complete(egc, cis->ao, rc); diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index e85547e67672..93bf65ee9af8 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1960,7 +1960,6 @@ _hidden int libxl__qmp_resume(libxl__gc *gc, int domi= d); _hidden int libxl__qmp_restore(libxl__gc *gc, int domid, const char *filen= ame); /* Set dirty bitmap logging status */ _hidden int libxl__qmp_set_global_dirty_log(libxl__gc *gc, int domid, bool= enable); -_hidden int libxl__qmp_insert_cdrom(libxl__gc *gc, int domid, const libxl_= device_disk *disk); /* Add a virtual CPU */ _hidden int libxl__qmp_cpu_add(libxl__gc *gc, int domid, int index); /* Query the bitmap of CPUs */ diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c index 693c5d705720..20d9eed8ddc8 100644 --- a/tools/libxl/libxl_qmp.c +++ b/tools/libxl/libxl_qmp.c @@ -1118,24 +1118,6 @@ int libxl__qmp_set_global_dirty_log(libxl__gc *gc, i= nt domid, bool enable) NULL, NULL); } =20 -int libxl__qmp_insert_cdrom(libxl__gc *gc, int domid, - const libxl_device_disk *disk) -{ - libxl__json_object *args =3D NULL; - int dev_number =3D libxl__device_disk_dev_number(disk->vdev, NULL, NUL= L); - - QMP_PARAMETERS_SPRINTF(&args, "device", "ide-%i", dev_number); - - if (disk->format =3D=3D LIBXL_DISK_FORMAT_EMPTY) { - return qmp_run_command(gc, domid, "eject", args, NULL, NULL); - } else { - libxl__qmp_param_add_string(gc, &args, "target", disk->pdev_path); - libxl__qmp_param_add_string(gc, &args, "arg", - libxl__qemu_disk_format_string(disk->format)); - return qmp_run_command(gc, domid, "change", args, NULL, NULL); - } -} - int libxl__qmp_cpu_add(libxl__gc *gc, int domid, int idx) { libxl__json_object *args =3D NULL; --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel