From nobody Fri Apr 26 12:55:12 2024 Delivered-To: importer@patchew.org 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; 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=1561710726; cv=none; d=zoho.com; s=zohoarc; b=nMiXsmZgsR/LaCblpmh52FNs5ajDY1fBRxcUbNmwPTOb6x5yBTCwaxHoaLq0DJzoFQo89pmjVaeTknzMRoW+MXGHNuEZEwLZtXLZ6gbhSj9xhWDNHyBVZdJRK1yEr3+XzbrAgs7c3WnYXqlfVHAgN+1OBbwuShmrtUHbY4Ut7Ps= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561710726; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=yjFKNlvmumGZz7o+2xBUMugj+IcY1gE54Dn4KVzn2Lo=; b=QqIUEa6fm431zGYntOXTvXwWgijfy4DhFTGPP4o982y9oq0rzHzAR87T5S4Dtvu2heDxbjrYAVH5JQCAxBKeEUu5j6knFfC4QrulT/K8fiXM62sgsmz/vuL/apAODbmbl6dMVCyYznOWqXQSgmzx0XX3n/VXv8v0gV/gi+PpBBU= 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 1561710726028707.6880069707803; Fri, 28 Jun 2019 01:32:06 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hgmHN-0008Sn-1A; Fri, 28 Jun 2019 08:30:45 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hgmHM-0008Si-2g for xen-devel@lists.xenproject.org; Fri, 28 Jun 2019 08:30:44 +0000 Received: from gandi.net (unknown [217.70.182.73]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 03ba0433-997f-11e9-8980-bc764e045a96; Fri, 28 Jun 2019 08:30:42 +0000 (UTC) Received: from diconico07.dev (unknown [IPv6:2001:4b98:beef:a:e7c:1fb4:ff55:f4a9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by gandi.net (Postfix) with ESMTPSA id D8E991604AA; Fri, 28 Jun 2019 08:30:40 +0000 (UTC) X-Inumbo-ID: 03ba0433-997f-11e9-8980-bc764e045a96 From: Nicolas Belouin To: xen-devel@lists.xenproject.org Date: Fri, 28 Jun 2019 10:25:08 +0200 Message-Id: <20190628082508.32509-1-nicolas.belouin@gandi.net> X-Mailer: git-send-email 2.22.0 MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2] golang/xenlight: Add libxl_utils support 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: Ian Jackson , Nicolas Belouin , George Dunlap , 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 Go bindings for libxl miss functions from libxl_utils, let's start with the simple libxl_domid_to_name and its counterpart libxl_name_to_domid. Signed-off-by: Nicolas Belouin Reviewed-by: George Dunlap --- tools/golang/xenlight/xenlight_utils.go | 55 +++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 tools/golang/xenlight/xenlight_utils.go diff --git a/tools/golang/xenlight/xenlight_utils.go b/tools/golang/xenligh= t/xenlight_utils.go new file mode 100644 index 0000000000..da1636842d --- /dev/null +++ b/tools/golang/xenlight/xenlight_utils.go @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2019 Nicolas Belouin, Gandi SAS + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; If not, see . + */ +package xenlight + +/* +#cgo LDFLAGS: -lxenlight -lyajl -lxentoollog +#include +#include +*/ +import "C" + +import ( + "unsafe" +) + +//char* libxl_domid_to_name(libxl_ctx *ctx, uint32_t domid); +func (Ctx *Context) DomidToName(id Domid) (name string) { + cDomName :=3D C.libxl_domid_to_name(Ctx.ctx, C.uint32_t(id)) + defer C.free(unsafe.Pointer(cDomName)) + + name =3D C.GoString(cDomName) + return +} + +//int libxl_name_to_domid(libxl_ct *ctx, const char *name, uint32_t *domid) +func (Ctx *Context) NameToDomid(name string) (id Domid, err error) { + cname :=3D C.CString(name) + defer C.free(unsafe.Pointer(cname)) + + var cDomId C.uint32_t + + ret :=3D C.libxl_name_to_domid(Ctx.ctx, cname, &cDomId) + if ret !=3D 0 { + err =3D Error(-ret) + return + } + + id =3D Domid(cDomId) + + return +} --=20 2.22.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel