From nobody Thu Mar 28 11:03:14 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=1561545101; cv=none; d=zoho.com; s=zohoarc; b=IKS1VCJ6HdGdaDrSPKe3m/Lxp/tbp/B9ECHyVJqyRJgQOXehueMULZrHqcPc7uQ3CwvmMTJ2uaKCEA0YWqRTIBf1kBHE1w4FmEAPMCGjnqjGzTljPBP8lxTTkw4y76uzO/QxbL0EQW6ODSkJlwBKFU6otpT1jNYo4GOt6KYD9oo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561545101; 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=/BfONzVcGTzIZqoZqTFgVMS0NEMRlY7E7jQZAXQILYM=; b=ZpG2dlLD3MzD+ld0qV2LpdIn21cjRI4b6svZd7HbJpWRZBC5YMRSjvo+D+EIr6gNstxkGwNI59OlnN4S0K4i+UL8YcvuckmZKeEoKoAofnKpPl+mu5GPc4Ho2B4ReOOp0wWVY9I1c91mkBgntDCHIMVo0yH4ZyCiwtHSARlsUrw= 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 156154510145698.3809237890406; Wed, 26 Jun 2019 03:31:41 -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 1hg5C7-0007cC-BV; Wed, 26 Jun 2019 10:30:27 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hg59b-00071Z-0l for xen-devel@lists.xenproject.org; Wed, 26 Jun 2019 10:27:51 +0000 Received: from gandi.net (unknown [2001:4b98:dc4:5:ae1f:6bff:fe2d:9fdc]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 0b4f39bb-97fd-11e9-8980-bc764e045a96; Wed, 26 Jun 2019 10:27:49 +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 E4AE216042D; Wed, 26 Jun 2019 10:27:47 +0000 (UTC) X-Inumbo-ID: 0b4f39bb-97fd-11e9-8980-bc764e045a96 From: Nicolas Belouin To: xen-devel@lists.xenproject.org Date: Wed, 26 Jun 2019 12:27:32 +0200 Message-Id: <20190626102732.27872-1-nicolas.belouin@gandi.net> X-Mailer: git-send-email 2.22.0 MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 26 Jun 2019 10:30:26 +0000 Subject: [Xen-devel] [PATCH] 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 , 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, lets start with the simple libxl_domid_to_name and its counterpart libxl_name_to_domid. Signed-off-by: Nicolas Belouin --- tools/golang/xenlight/xenlight_utils.go | 61 +++++++++++++++++++++++++ 1 file changed, 61 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..ab7a585ec7 --- /dev/null +++ b/tools/golang/xenlight/xenlight_utils.go @@ -0,0 +1,61 @@ +/* + * 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" + +/* + * Other flags that may be needed at some point: + * -lnl-route-3 -lnl-3 + * + * To get back to static linking: + * #cgo LDFLAGS: -lxenlight -lyajl_s -lxengnttab -lxenstore -lxenguest -lx= entoollog -lxenevtchn -lxenctrl -lxenforeignmemory -lxencall -lz -luuid -lu= til + */ + +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)) + 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