From nobody Sun May 19 00:47:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1560508767; cv=none; d=zoho.com; s=zohoarc; b=YAwjNr6Qqw8jA5Xxwe77hAAelv9K/0xzh9SGLHKCDUAEq4TdyX0orNk021QVT3ZjSGp0f+4RdBL8w/MBqxrX7Qe9iZlNIXadAAZi0OiPOEcLXia0u/ceXHOR5K5WucvNba25ykEWcKeUWuNcAuh5VbwiFqfBQdV0+FMcT/3VQ70= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560508767; 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=ajPoNmWTWv1HSsp3teL92u0+yTxAvOnDIwLmjcIQewc=; b=Q6JGkLanZXF4ifGkvLWAMQfbJhi/mFuX21FRYVRzB2+n6D87tZ7Mn5MVGoamz2PsIm6tk3ZFQsGEOrODgDfSD8KS28Fn5YLBIFFn82gAUwFdxm7mcDegFX+fQAj9AkA5bpa4yvUjsT0cnX4kSDlJ4rDeTfbXk2F9ISB9i2I0eF0= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1560508767361757.2600662478035; Fri, 14 Jun 2019 03:39:27 -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 1hbjb2-0002kn-Fi; Fri, 14 Jun 2019 10:38:12 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hbjb1-0002kK-1Y for xen-devel@lists.xenproject.org; Fri, 14 Jun 2019 10:38:11 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 80fb0cd5-8e90-11e9-8980-bc764e045a96; Fri, 14 Jun 2019 10:38:10 +0000 (UTC) X-Inumbo-ID: 80fb0cd5-8e90-11e9-8980-bc764e045a96 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: AVrirI8daXA0dQzAAXaa8NjaTk2d7Zm4mRxs89Tz7bdyoget3h9BBpycMUN8Czc8eC+Appupcl l++iHw++kOHAr+06CRbq8w6kDJEWtzUkI66YeAyjqwLBbZaHZU2UTSiavcDsB+2+u05FrN8aIm qXiTk/e7oep+/Jn2paj9ZvsWxrzfWg2PDVbJpzKphtWNkL30lII53dClkBfxus8RlD28okgI+T xTeMAz6ACg4zm9phlwT2PpptuVxbkQjs97tqkPMZ6DaPhvqXmtnrX7xpyOpLZRoX/pvyz2DbqI 5Wk= X-SBRS: 2.7 X-MesageID: 1752397 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.63,373,1557201600"; d="scan'208";a="1752397" From: Anthony PERARD To: Date: Fri, 14 Jun 2019 11:37:53 +0100 Message-ID: <20190614103801.22619-2-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190614103801.22619-1-anthony.perard@citrix.com> References: <20190614103801.22619-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2 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" 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 3be5c644c1..5f90c210af 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -2718,13 +2718,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 Sun May 19 00:47:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1560508761; cv=none; d=zoho.com; s=zohoarc; b=LxKgy9OMOrSmiv155YciEZ+Z4GzHNLRtFamoIhor7wgPQitN5nGC3293QGb11NkFoGfdlTczLikA6IcGH51o23Wz+PvD8eoIXl6d1rKmizOf5Wv5dEw2Z7dx3IW/l/bNm6eZmLtvA1JzOXqiFdYIevsfifzo8z9wfD/uP3R+v9E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560508761; 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=NB02djHq0lQ+hdb8sKRMXrF+gGTjPcGQlCFKsUvzOlQ=; b=eJBwn7CLY6YDjxLCIs8vxyG99ADqmKMStiNQ9jFNXE6XMpN22rZFdO3sp5OWkiD4MqowKD4I9XbQiOi0yFjv4c0H9QrYV+LrRXdknSD/JnOrzlBrrY89VE9Wd1WFQru2dq8EG0EzKkNWxQTwhZWPda3goe0FV/lbFIYQEV9r8UM= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1560508760963203.0363788477082; Fri, 14 Jun 2019 03:39:20 -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 1hbjay-0002jQ-1a; Fri, 14 Jun 2019 10:38:08 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hbjaw-0002j4-Lo for xen-devel@lists.xenproject.org; Fri, 14 Jun 2019 10:38:06 +0000 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 7db7f8c5-8e90-11e9-8980-bc764e045a96; Fri, 14 Jun 2019 10:38:05 +0000 (UTC) X-Inumbo-ID: 7db7f8c5-8e90-11e9-8980-bc764e045a96 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: G2+8im8D8GLUh+HlmedeiSbvtjFLzF55ecpzCFXra/mnNfU4QcuNDQLtt4NdyxU5Ccfk2mAyAe sCrr4pzQTaIoosZQK4EZClRmrb95XTDXlMhr5E/Fs7NIv/pzh92xiXAdwP6owtoIcBvPbBhZcn q4Wf35vOA6x6t2j6L2ratY2HYX7wr8Z326AwOX0jriwFdEb4o1PHeZAUBMtrGVE7YDTejWAcJu ZuDe/dABGktSx2riw10wFKSs698VpECmgztvQ+2M+t+SMyepGBR3uKjGd/heP4V7JBIOBdO8xV cbg= X-SBRS: 2.7 X-MesageID: 1749154 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.63,373,1557201600"; d="scan'208";a="1749154" From: Anthony PERARD To: Date: Fri, 14 Jun 2019 11:37:54 +0100 Message-ID: <20190614103801.22619-3-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190614103801.22619-1-anthony.perard@citrix.com> References: <20190614103801.22619-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2 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" 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 5f90c210af..ca7206aaac 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -4474,6 +4474,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 Sun May 19 00:47:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1560508761; cv=none; d=zoho.com; s=zohoarc; b=CJtkyOSd3R/qrVIFXdKGRpuHLvoJ1q5tsi3mNidBfcG29mKEhyPh+pcfEGgwgKrax0abG/GcepgbRBDFlBQ04UrcLqm24OPDmQMyWuhdGZaxO4eY46UxCBWKVniRAZg8o0bk8qU8f+AZEm++Gww/N1LNFfU9XvZQTWhenHRnn+s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560508761; 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=imPCwo0NbDpOyfk+TE1E7eia5hdmwTw2ejQkgMMRtn8=; b=L+WP7R8HqnI3QvS7Ev4PdPZQ72X0xvsiWSwB6R/ykiW2lkFByLbdb48CfqKHmeovaJFEKYFcJ9BF6YqDSnjrzrPa5b9mL+JYkh1S71z1G/m1OvJQRbXkPDXNjKZ0NPMChw5QS+ZgWelFb5nvGD78HFF9FS1ezsmQV0O6p5Q7J6I= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1560508761966756.1170370487914; Fri, 14 Jun 2019 03:39:21 -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 1hbjb4-0002ly-BE; Fri, 14 Jun 2019 10:38:14 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hbjb2-0002kw-R9 for xen-devel@lists.xenproject.org; Fri, 14 Jun 2019 10:38:12 +0000 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 816b857d-8e90-11e9-8980-bc764e045a96; Fri, 14 Jun 2019 10:38:10 +0000 (UTC) X-Inumbo-ID: 816b857d-8e90-11e9-8980-bc764e045a96 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: getYCXxD9POOaAOyC7G8S26zWJPs1CS8PJv96E8vEJWX7G38aNH7BdxzavYrRHX2cNcZ6mWyO8 j8Bi5I+tyLdukLL4/iURnhfbJAhOux2/WaQOimmEFZpF4ELNk0fgdowRjK7D1KmEMJ4BC9SXBF 7s+zOyWcflfg7683A7pLRI+KIC+hWW7vkeDYAbq1hmSe4fQE0m9UcZ9unm38aFCOdz8RpMdrO6 5KHdOVnxcdIXfhm90oCql0hKgNWakCMzmUs5zJlT4CXiKyhtbBGnRvALwZsKXM4Ay13n3Ny19F vuo= X-SBRS: 2.7 X-MesageID: 1722752 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.63,373,1557201600"; d="scan'208";a="1722752" From: Anthony PERARD To: Date: Fri, 14 Jun 2019 11:37:55 +0100 Message-ID: <20190614103801.22619-4-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190614103801.22619-1-anthony.perard@citrix.com> References: <20190614103801.22619-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2 3/9] libxl_internal: Introduce libxl__ev_lock 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" 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_lock_get will have CTX_UNLOCK before trying to grab the ev_lock. The callback is used to notify when the ev_lock have been acquired. Signed-off-by: Anthony PERARD --- Notes: Should libxl__ev_unlock() kill the child? =20 That would mean that we would need to handle the case where the process trying to grab the lock got impatient and decided that it was taking too long. =20 v2: - new patch, to replace 2 patch implement a different lock tools/libxl/libxl_internal.c | 174 +++++++++++++++++++++++++++++++++++ tools/libxl/libxl_internal.h | 76 ++++++++++++++- 2 files changed, 246 insertions(+), 4 deletions(-) diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c index f492dae5ff..3906a0512d 100644 --- a/tools/libxl/libxl_internal.c +++ b/tools/libxl/libxl_internal.c @@ -575,6 +575,180 @@ void libxl__update_domain_configuration(libxl__gc *gc, dst->b_info.video_memkb =3D src->b_info.video_memkb; } =20 +void libxl__ev_lock_init(libxl__ev_lock *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_lock *lock); +static void ev_lock_child_callback(libxl__egc *egc, libxl__ev_child *child, + pid_t pid, int status); + +void libxl__ev_lock_get(libxl__egc *egc, libxl__ev_lock *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_lock *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, = errno=3D%d", + lockfile, fd, errno); + 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_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_lock *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_unlock(gc, lock); + } + lock->callback(egc, lock, rc); +} + +void libxl__ev_unlock(libxl__gc *gc, libxl__ev_lock *lock) +{ + int r; + + assert(!libxl__ev_child_inuse(&lock->child)); + + /* It's important to unlink the file before releasing the lock to avoid + * the following race (if unlock/close before unlink): + * + * P1 LOCK P2 UNLOCK + * fd1 =3D open(lockfile) + * unlock(fd2) + * flock(fd1) + * fstat and stat check success + * unlink(lockfile) + * return lock + * + * In above case P1 thinks it has got hold of the lock but + * actually lock is released by P2 (lockfile unlinked). + */ + 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_lock_init(lock); +} + /* * Local variables: * mode: C diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index ca7206aaac..2c2476b55b 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_lock libxl__ev_lock; =20 typedef struct libxl__domain_create_state libxl__domain_create_state; typedef void libxl__domain_create_cb(struct libxl__egc *egc, @@ -2723,11 +2724,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) @@ -2742,6 +2743,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_lock) + * 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 @@ -4600,6 +4619,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_lock 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_lock: + * Undefined + * Might contain anything. + * Idle + * Struct contents are defined enough to pass to any + * libxl__ev_lock_* 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_unlock will need to be called to release the lock and the + * resources of libxl__ev_lock. + * + * libxl__ev_lock_init: Undefined/Idle -> Idle + * libxl__ev_lock_get: Idle -> Active + * May call callback synchronously. + * libxl__ev_unlock: LockAcquired/Idle -> Idle + * callback: When called: Active -> LockAcquired (on error: Idle) + * The callback is only called once. + */ +struct libxl__ev_lock { + /* filled by user */ + libxl__ao *ao; + libxl_domid domid; + void (*callback)(libxl__egc *, libxl__ev_lock *, int rc); + /* private to libxl__ev_lock* */ + libxl__ev_child child; + char *path; /* path of the lock file itself */ + int fd; + bool held; +}; +_hidden void libxl__ev_lock_init(libxl__ev_lock *); +_hidden void libxl__ev_lock_get(libxl__egc *, libxl__ev_lock *); +_hidden void libxl__ev_unlock(libxl__gc *, libxl__ev_lock *); + #endif =20 /* --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sun May 19 00:47:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1560508764; cv=none; d=zoho.com; s=zohoarc; b=QYDtAX6nlT+SC8qQ+Ur9Vjkc+WW8lTgbss4k1H8joUkRgSBXsrMNEkS0gH1aKJU2nezGcL4DxKgIzLMOv1BeNRfFJlFUfNBmaCpx8lzxAnTapJM0IFpIfOle0Wk2JeIdXpzgCkAQpwUPubEAKgYoJOxDdiSlN7ck6z7kcDskIj8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560508764; 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=N40Qvywdc//p6nFBcb/1xuVIbLvkRHt4gSTtaIYx8Oc=; b=nS6hF9WPiEtLzziNTeGmqeuiZY1H+ug/KORIdi4Uz/jLTOtF2sOB8CBobGCCnu614ZobSEbpfzxPRKHucRMshDfISrCiSN56yufViz2XwzgjDuRWG+u6D5wmNxpI4wEBevajQuGuwxfrtu92gL515Wno/vPiXbFwkQidRFb49lc= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1560508764819499.6141184051713; Fri, 14 Jun 2019 03:39:24 -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 1hbjay-0002ja-BT; Fri, 14 Jun 2019 10:38:08 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hbjaw-0002jE-TL for xen-devel@lists.xenproject.org; Fri, 14 Jun 2019 10:38:06 +0000 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 7e76ebf3-8e90-11e9-8980-bc764e045a96; Fri, 14 Jun 2019 10:38:06 +0000 (UTC) X-Inumbo-ID: 7e76ebf3-8e90-11e9-8980-bc764e045a96 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: 1tgsnfHyQGwgirMTouddCj7l0PPAPe3hObdBSC8YiGEtGJE3WZTB9uCDJQTe71LWisB3kFhHmj +WNvMAVq2Oh+B6iR5URwHBfOftBSVMS/qcH6led3zuFvJCNy332+hq0vdHkC40lTy8PHeSEqEZ DdDYim/iiu6K17vk8cpHXGo7W2q3P70ehgl2m9Bn0Dc0kARmGNFfBxXOR7GQbn0nsFskU+GzvX B5wNix9l7XITzpKV8h4bpJv9FdsEGd0bt0qZeTVvgfABq1VlYFWiZoc13Bh0MwqTVmPBb9dMbo mxA= X-SBRS: 2.7 X-MesageID: 1749155 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.63,373,1557201600"; d="scan'208";a="1749155" From: Anthony PERARD To: Date: Fri, 14 Jun 2019 11:37:56 +0100 Message-ID: <20190614103801.22619-5-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190614103801.22619-1-anthony.perard@citrix.com> References: <20190614103801.22619-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2 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" 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 6fdcbbddd6..4587a6fc9c 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 3906a0512d..fb1b9bfe52 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_lock *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 Sun May 19 00:47:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1560508762; cv=none; d=zoho.com; s=zohoarc; b=JutFyXt7lIynEZJhS0tw02ufvMlgiRYxrOu2Tk8pp/KWibVKzBOiB5YZVkcuLzVlu0NU4A63RHTZhH1ny561s7F5tHa24ChNzplEdzoYOwPmZA1jjFiDM8+Ubt/BTnuVg3WOU1W6Vus5cReoqsUimZGQcG8TMxUhlbftqtq8saI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560508762; 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=gTYgaVxqBRPK8rocmm43NyYO8NMD/RkLQ/i2TLt2MAs=; b=jIER33rYpKIoZCWxMN0njZmGqksICcd6Xq0GtoVOB03h5a/6iF1uTifEXxuO9Q4i2fRnCZJLp4HQHUhlM1PEeAlZNo2UgjEVUkDCs5i9dzDlzd2uMor8opUPQkiG1yQGpYW0ilX+q1Qu3pjoCVjcJazgUuJbhZ3lvSmBbMN8NRo= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1560508762826134.47898365817593; Fri, 14 Jun 2019 03:39:22 -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 1hbjb2-0002l0-Rr; Fri, 14 Jun 2019 10:38:12 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hbjb1-0002kL-1a for xen-devel@lists.xenproject.org; Fri, 14 Jun 2019 10:38:11 +0000 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 80b8ba8b-8e90-11e9-8980-bc764e045a96; Fri, 14 Jun 2019 10:38:10 +0000 (UTC) X-Inumbo-ID: 80b8ba8b-8e90-11e9-8980-bc764e045a96 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: Y/hPiyKVrqZU/oDR72x6A/YeAN1mrD78w0H9sgSokHCb5VjCJFkmjwpf+QEwo6K6MMenzqISjP HTri5FEvc48KLcJDdsgE6KHA8LYhkwuPE5VUnXsjxH8O1DbrH7EvCBgPy1nJRczyySGL90lvKx cqLX9lqxrjcN+/bqZEs6YT9Wk6f65/8rA5NDiPwAP8jCfv13EydSqixYezp/eyUiwmx6YT1qTG 9/kc5HBrRFq8gVi0gkRBte/T7m3Dmtacagx62w7V/ckpNF0GqmXBAmjZeMkjcvTJIV3UhTtji3 4s8= X-SBRS: 2.7 X-MesageID: 1722751 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.63,373,1557201600"; d="scan'208";a="1722751" From: Anthony PERARD To: Date: Fri, 14 Jun 2019 11:37:57 +0100 Message-ID: <20190614103801.22619-6-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190614103801.22619-1-anthony.perard@citrix.com> References: <20190614103801.22619-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2 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" 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 bc9e2d5a74..45bf555061 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 Sun May 19 00:47:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1560508761; cv=none; d=zoho.com; s=zohoarc; b=T6nVpLMhwFaJ/XllfkjI2fktAAkKEGkRd3gBmwz8grWUuVHNSebgLp+fx1IEg7uU3/yUP/2hv4FiTUZiI5g2g5P0YBB13MhXhMqyO8VPYVi1eSnsUw5oA79o/IHFrYVkCbeyRdm/igj2o/IyMBUcxIhkLuJNgr/GGUN/G1UgZlg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560508761; 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=rW62qzWa+k5Nl8LDshJJD/YmOLajQQ5Z2HYJmusr2tg=; b=DaqKHAIsAaZ2glOn0bc7XthzyBmcxPBelrVtVQciS8Ix8TvSVW4jmdXrj/+G88p5QTwBhCPWX37eBXmHI6meLpdrpOI+OD0rKHveD0sowHc1qqQXJFa3jHcAOE+Y9J8cGzjDbFDGAauK95j9jt9AsatozJEB7P2Lcw540zTUee0= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1560508761134732.8251846362455; Fri, 14 Jun 2019 03:39:21 -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 1hbjb5-0002mR-2D; Fri, 14 Jun 2019 10:38:15 +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 1hbjb3-0002la-DJ for xen-devel@lists.xenproject.org; Fri, 14 Jun 2019 10:38:13 +0000 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 817943e4-8e90-11e9-a75c-0f081994aedc; Fri, 14 Jun 2019 10:38:11 +0000 (UTC) X-Inumbo-ID: 817943e4-8e90-11e9-a75c-0f081994aedc 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: 0qVhVYaT2jvmX7RtBgudh/cq9gDSB3xQ8GnS8dWit037PN9fRcvBUU6+jE1bW7fhS93LScEAbE Ryq2VrO+zL01YJ02mbQ9OF7mDj1GqbY/wD+GvWmv404HoYz2x6hofEBm7TNCiRqeL+q9OhKVoH dSrHbTdpBWcwvrb4WFVYzvWUVzDmcC/bDsNlQ1G8GqUrvryEBkiPcxSC7MOiMwfQRnPB2ePNez 1OzVpcwNHfnNOYkEc1D7qNxfBdST4io7YEWPxvSIMH3vwPGerKL9Sm/o+BUMQWpySthK45Lyc+ Buw= X-SBRS: 2.7 X-MesageID: 1722753 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.63,373,1557201600"; d="scan'208";a="1722753" From: Anthony PERARD To: Date: Fri, 14 Jun 2019 11:37:58 +0100 Message-ID: <20190614103801.22619-7-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190614103801.22619-1-anthony.perard@citrix.com> References: <20190614103801.22619-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2 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" .. 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 45bf555061..5f13a622f9 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_lock qmp_lock; + int dm_ver; +} libxl__cdrom_insert_state; + +static void cdrom_insert_lock_acquired(libxl__egc *, libxl__ev_lock *, + 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_lock_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_lock_get(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_lock *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_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 Sun May 19 00:47:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1560508766; cv=none; d=zoho.com; s=zohoarc; b=Scyb/+kC2v7ajsE0MWRuom+jTR46ljA35SnpUPYYAmz/nEEubil8RfLUvRcqiqwM6p7TtOyztUfoIDZBj0ajeZ5UVeZF1s5Ktygj7BDs4iMcMjEdUfdbKpvHtQWeNM3qINqI+jhAbOM0T6TlCd/Xw1IF0/ZOXUZCuQYXtCE42fc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560508766; 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=yOT0xETUtHfhkcbc4niSgtAfXftY8U4eS1Y5EFRJjaI=; b=dwnhVw7cRqgEc4cR2bnOX3pLjE+l7Vmh/j7bplF6OFjm0mCL3+U+Mepnhvvm3L0xaa+XttkmCktGm0hC8U64PjoNLcLBKoBJt1tzZOBcri1cGRi1qaKw3adg128D1+HGGe3zol1FgQxhD5E5mjdGFbnqXsx4gOGeYT/3QVZZ5Lc= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1560508766087176.42823881512095; Fri, 14 Jun 2019 03:39:26 -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 1hbjax-0002jJ-P8; Fri, 14 Jun 2019 10:38:07 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hbjaw-0002j5-LO for xen-devel@lists.xenproject.org; Fri, 14 Jun 2019 10:38:06 +0000 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 7dff395f-8e90-11e9-8980-bc764e045a96; Fri, 14 Jun 2019 10:38:05 +0000 (UTC) X-Inumbo-ID: 7dff395f-8e90-11e9-8980-bc764e045a96 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: 5gtorxkl8LYECn1Ov2NnvxxUI8ASWkI7WAs/qOhio6tJEYHT287iy7rhRr/LWIwaUSoDZQwvg9 Fns3B8LV8jbDApbXU8AkVaJtgLR03jS5LmfNWWUzBNDRQJxcX6fzxEetDYQFbrcH4Rso1eqwDC wY+HDaNXSbZF+9BI7d3rX4D3+4YuuJ0ZVt27kow9WbBK8Am/wmRDCAcwsN8Y9Lm8CcYKpbgmLx 87axoCjgxSWc8SIY3AlIE8H+dIDOmJiNov2SPDUudckY4zLbMStFeNH4zEJ0dKbSBxfaMFCDhc kUQ= X-SBRS: 2.7 X-MesageID: 1736049 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.63,373,1557201600"; d="scan'208";a="1736049" From: Anthony PERARD To: Date: Fri, 14 Jun 2019 11:37:59 +0100 Message-ID: <20190614103801.22619-8-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190614103801.22619-1-anthony.perard@citrix.com> References: <20190614103801.22619-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2 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" 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 5f13a622f9..7328a03e8a 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_lock qmp_lock; int dm_ver; + libxl__ev_time time; } libxl__cdrom_insert_state; =20 static void cdrom_insert_lock_acquired(libxl__egc *, libxl__ev_lock *, @@ -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_lock_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_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 Sun May 19 00:47:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1560508766; cv=none; d=zoho.com; s=zohoarc; b=L6XpcBC/G9tjo3XSyBgXt4n4EwpPETYIDiijMvg597h9JcBpFDf0zFLFbrkjI+9KG0ozR5yTgiXFdepLgN6gJWYhg4J2sV2288NW9NHeO9uFFCH7lEPIJH02qZ5b3O5RsQeppIBd2B2lfPRVs0Fnt2J4BsLTojAeUoiZvFLgqw4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560508766; 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=3xf3FMcVUeJ+XQHtM38WVN54e507PjezSjF4NUK4szE=; b=LBYz5VNr8t1uPRK7AiDVexhU6Kih2T6OFXYJx5vI/Yxz8IVjxyBY7koFivS2hSjtvJjeWVw0JqfKCzr4597b4OEa5sOf9trccJo6TdjOzbp5uRYnkbk3nwYsoELxvxk9bxJjXsPBjw2bB4zJrRo+R2UB0w7oihUBEzbdXQnMYeA= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1560508766163995.6095063813734; Fri, 14 Jun 2019 03:39:26 -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 1hbjb4-0002m9-M5; Fri, 14 Jun 2019 10:38:14 +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 1hbjb3-0002lG-6J for xen-devel@lists.xenproject.org; Fri, 14 Jun 2019 10:38:13 +0000 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 813336ec-8e90-11e9-85da-3b146665613f; Fri, 14 Jun 2019 10:38:11 +0000 (UTC) X-Inumbo-ID: 813336ec-8e90-11e9-85da-3b146665613f 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: LQ3Xs+FckjuDEppubsJzf4Ia8O+hxAZzOWIu6xNCHdQmtS/wNlPORRnkjlKFTFhxlUtVjRsPa1 ec5Cd0t0e191qEFJ00JgtCTVNW0HbryO+and2yQE2nTYGhzaN+aSjIGb34dO8HB6nZSx7GE+mL ed0phQx6mZTxGFtiL7BtaA1U2pYk4ph77E6R+tX9uvw3e5bNCFwsjMMdhjR51rWMc8DXEhoQ1F ORXaR4BqFnszp4IUbc17zxvV/ZvdN7qy+TqdcPbp0f1BFs2esXXj3NEAbQlOPiy5QE+zM7mFii pp4= X-SBRS: 2.7 X-MesageID: 1744469 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.63,373,1557201600"; d="scan'208";a="1744469" From: Anthony PERARD To: Date: Fri, 14 Jun 2019 11:38:00 +0100 Message-ID: <20190614103801.22619-9-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190614103801.22619-1-anthony.perard@citrix.com> References: <20190614103801.22619-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2 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" .. 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 2c2476b55b..2dc5a31755 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 42c8ab8d8d..b6a691d9fc 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 */ @@ -943,7 +940,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); @@ -965,10 +962,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)); @@ -984,7 +981,7 @@ int libxl__qmp_pci_add(libxl__gc *gc, int domid, libxl_= 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); @@ -1001,7 +998,7 @@ static int qmp_device_del(libxl__gc *gc, int domid, ch= ar *id) { libxl__json_object *args =3D NULL; =20 - qmp_parameters_add_string(gc, &args, "id", id); + libxl__qmp_param_add_string(gc, &args, "id", id); return qmp_run_command(gc, domid, "device_del", args, NULL, NULL); } =20 @@ -1023,7 +1020,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); @@ -1035,10 +1032,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, @@ -1056,7 +1053,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); @@ -1073,8 +1070,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); } @@ -1084,7 +1081,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); } @@ -1142,10 +1139,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); @@ -1157,8 +1154,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); } @@ -1167,8 +1164,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); } @@ -1189,8 +1186,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); } @@ -1205,11 +1202,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); } @@ -1246,7 +1243,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); @@ -1383,7 +1380,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 Sun May 19 00:47:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1560508762; cv=none; d=zoho.com; s=zohoarc; b=i05bGVKvbByj84Bi2LdRyUJXreAT3tOL5ok3DVXwI4sfw/L0JbTgE2kt5cyOuXhydXQ/g3ghaQlPgVty6sqbPO8AUG48RnCUGpL8HfCahN3dxgzOLYuEHfnmwuhZjDc8oEpTIwlItPWzwFv4nXzTnPyamCrrflhzG79NQ8ouo9w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560508762; 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=HY1KQG5gtVfv96igFvwuoayBQ0DfZPgz9dvvz0wm3Wc=; b=C1/WUN5aqxOpLY5I3vvAFEi4lP2J8Vl7GwQ4QrXCHIrYoqAux9layg+dhd9ZylC0Wj+d6/ztOKLd/54VQTRFz5Ph5b/LzS8wDSpLwfzJKo20ub+tOI4tLuFtFeMyD662TL5NDWDdpwb1NU/xkGJ4tQlz6X4Onyc0TNkyASppC/M= ARC-Authentication-Results: i=1; mx.zoho.com; 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 1560508762611576.0807882050937; Fri, 14 Jun 2019 03:39:22 -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 1hbjb0-0002kC-Qz; Fri, 14 Jun 2019 10:38:10 +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 1hbjb0-0002k1-9D for xen-devel@lists.xenproject.org; Fri, 14 Jun 2019 10:38:10 +0000 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 7e2a21ea-8e90-11e9-8996-737f2de5437e; Fri, 14 Jun 2019 10:38:06 +0000 (UTC) X-Inumbo-ID: 7e2a21ea-8e90-11e9-8996-737f2de5437e Authentication-Results: esa6.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 (esa6.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=esa6.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa6.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=esa6.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 (esa6.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=esa6.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: nFUn7MFjgfH5kGe3PNVOKKkei7j2EdVaGtNVvGHhLvxD1ETbLUJxXEHEN8k8Noejjv0aXc8tpJ U0TuvFGhxOS9ZDYGeyXpqAX17gSuj6IPeLl9DqH9/0a0RtgNv1560pIHk5F7bRpTC0iZvKIbly ofvFME2kSwRT9mxRQ7r1ayrVSzkWZ39fhal5UdLJdVK0ben5iuxT2b1yMlHWnLR+vo24gJexfL lkxYXFGVooi4QSobcsRvwYh17o2Lz3YRJz2lkAo3QgaJHNkPlcGMcSgJ2IaUbr6al1NjWBFF3K YWA= X-SBRS: 2.7 X-MesageID: 1725156 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.63,373,1557201600"; d="scan'208";a="1725156" From: Anthony PERARD To: Date: Fri, 14 Jun 2019 11:38:01 +0100 Message-ID: <20190614103801.22619-10-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190614103801.22619-1-anthony.perard@citrix.com> References: <20190614103801.22619-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2 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" 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 7328a03e8a..a95719ce9e 100644 --- a/tools/libxl/libxl_disk.c +++ b/tools/libxl/libxl_disk.c @@ -650,14 +650,17 @@ typedef struct { libxl__ev_lock 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_lock *, 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_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 2dc5a31755..9361db0e2c 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1959,7 +1959,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 b6a691d9fc..25d3764f18 100644 --- a/tools/libxl/libxl_qmp.c +++ b/tools/libxl/libxl_qmp.c @@ -1059,24 +1059,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