From patchwork Fri Nov 15 19:44:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Rosbrook X-Patchwork-Id: 11247033 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2CC0913BD for ; Fri, 15 Nov 2019 19:46:55 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 092D32073A for ; Fri, 15 Nov 2019 19:46:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="vB2ga8TA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 092D32073A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iVhXS-0001fK-2n; Fri, 15 Nov 2019 19:45:50 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iVhXR-0001eq-Gs for xen-devel@lists.xenproject.org; Fri, 15 Nov 2019 19:45:49 +0000 X-Inumbo-ID: 6f557b6e-07e0-11ea-9631-bc764e2007e4 Received: from mail-qk1-x744.google.com (unknown [2607:f8b0:4864:20::744]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 6f557b6e-07e0-11ea-9631-bc764e2007e4; Fri, 15 Nov 2019 19:45:11 +0000 (UTC) Received: by mail-qk1-x744.google.com with SMTP id e2so9056849qkn.5 for ; Fri, 15 Nov 2019 11:45:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MJpUeWf0jnfsbS1osieBLxXWni5b06jpA8uSL+ymQ14=; b=vB2ga8TA5fppzTiacfu695HmOo4qOx1/uOwUDfs223dgo950m0ArARQudaDKoh+mRX lTkBHTflg6mjmfMz6aL2LvszVCbtR+NPbevZk08+RweZTdvPgBNqpxn9Mt4JyiYSYQX5 +0PL15G4nrQ3AKD/J/c7k6hlnT1tOUsQLE2diOBneOi+iTUIbZLCHCsAbdD/TegqnuDq wUEDBUQXetErpBx5vqK3F0t75VaJqlHsqtPbtYYfvGJ9pIdQQsFlOLsIY51JHdgQrWXK 3KLVWQhnIWBNeuy/uHJ/6R0ZiMzdYzbQn4OOij6LEE+u6NUaysnNWcR8y846ipBGDvSB 0a5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MJpUeWf0jnfsbS1osieBLxXWni5b06jpA8uSL+ymQ14=; b=FBiiQg8QXkWeQYxJ2zUEeNjhohG++A6KL0hchOgtuoDByagv/ajrPneCl/+0Zc3S0W v9IQ7d7cfiPcTppSCqDPdcWY5QfWaLMRN9cI+oN8n1P/1qnygDea9SYoT0Mzyw7r8+0+ 6G+G1v/gR0+W7qTDrqvwrlzRvGHZxGFJRYsePtpQ0bkH0cnyBgJdBHP/Nz73+4vjCgqq rYD04xq2ROJvN38toGytZ62Gsd7oOWoYg7xSZ9dKammfDcdp8r+6BlQzTu7lVnzk5igB RrOeIRsW67H4TXGdAhjdOrm+rOCfWJXUkQPdLx53y+J17XT45fPz2QibqJbq0jD0xafx B15A== X-Gm-Message-State: APjAAAX9dkVU1lGdb1FKTrCq8X402l6W1/6bGqpgjfcS1yJJE93Mquyd 69bHxpJZEyF4pvvXLMErxfcsZB8L X-Google-Smtp-Source: APXvYqz17k5Nv8me8SeZk/B7DEoddAipIg0iB1tbbCpNAj2RiYp/E26qlcYJlUYKPaVzKqCfGLoFaw== X-Received: by 2002:a37:3c8:: with SMTP id 191mr13726851qkd.77.1573847110324; Fri, 15 Nov 2019 11:45:10 -0800 (PST) Received: from five.crux.rad.ainfosec.com (209-217-208-226.northland.net. [209.217.208.226]) by smtp.googlemail.com with ESMTPSA id y10sm4649679qkb.55.2019.11.15.11.45.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2019 11:45:09 -0800 (PST) From: Nick Rosbrook To: xen-devel@lists.xenproject.org Date: Fri, 15 Nov 2019 14:44:17 -0500 Message-Id: X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2 10/22] golang/xenlight: define CpuidPolicyList builtin type 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: Nick Rosbrook , Ian Jackson , kerriganb@ainfosec.com, George Dunlap , Wei Liu Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Nick Rosbrook Define CpuidPolicyList as a string so that libxl_cpuid_parse_config can be used in the toC function. For now, fromC is a no-op since libxl does not support a way to read a policy, modify it,and then give it back to libxl. Signed-off-by: Nick Rosbrook Reviewed-by: George Dunlap --- Changes in v2: - Re-define CpuidPolicyList as string. - Make fromC a no-op. - Use libxl_cpuid_parse_config in toC function. tools/golang/xenlight/xenlight.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenlight.go index d57f780116..6f0a9278ad 100644 --- a/tools/golang/xenlight/xenlight.go +++ b/tools/golang/xenlight/xenlight.go @@ -249,6 +249,31 @@ type EvLink struct{} func (el *EvLink) fromC(cel *C.libxl_ev_link) error { return nil } func (el *EvLink) toC() (cel C.libxl_ev_link, err error) { return } +// CpuidPolicyList represents a libxl_cpuid_policy_list. +// +// The value of CpuidPolicyList is honored when used as input to libxl. If +// a struct contains a field of type CpuidPolicyList, that field will be left +// empty when it is returned from libxl. +type CpuidPolicyList string + +func (cpl CpuidPolicyList) fromC(ccpl *C.libxl_cpuid_policy_list) error { return nil } + +func (cpl CpuidPolicyList) toC() (C.libxl_cpuid_policy_list, error) { + var ccpl C.libxl_cpuid_policy_list + + s := C.CString(string(cpl)) + defer C.free(unsafe.Pointer(s)) + + ret := C.libxl_cpuid_parse_config(&ccpl, s) + if ret != 0 { + C.libxl_cpuid_dispose(&ccpl) + + return ccpl, Error(-ret) + } + + return ccpl, nil +} + type Context struct { ctx *C.libxl_ctx logger *C.xentoollog_logger_stdiostream