From patchwork Tue Dec 10 15:47:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Rosbrook X-Patchwork-Id: 11282881 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 BFE7014E3 for ; Tue, 10 Dec 2019 15:49:31 +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 9BE32214D8 for ; Tue, 10 Dec 2019 15:49:31 +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="EygbGrdk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9BE32214D8 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 1iehkg-0003GR-Db; Tue, 10 Dec 2019 15:48:42 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehke-0003FW-SL for xen-devel@lists.xenproject.org; Tue, 10 Dec 2019 15:48:40 +0000 X-Inumbo-ID: 72e21ea8-1b64-11ea-88e7-bc764e2007e4 Received: from mail-qk1-x743.google.com (unknown [2607:f8b0:4864:20::743]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 72e21ea8-1b64-11ea-88e7-bc764e2007e4; Tue, 10 Dec 2019 15:48:02 +0000 (UTC) Received: by mail-qk1-x743.google.com with SMTP id d71so8822149qkc.0 for ; Tue, 10 Dec 2019 07:48:02 -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=Zeqavew/vY6f4t63gmA+rSSNtPJ2y+B2UxfgLhzHhUY=; b=EygbGrdkLsTEk84mPqLcTv0ZRFwnCJfn950cmfQS7JbKzUn/9cHW+fppSCNGF7xek0 Bb9gDYey8ithsZAYGYV55EeJQcipgmee+ugZGBP9jZvd3+6wv98oa7FPdS25EKHhi02e Uyeq0Jvt216T8Lsd3RM2XWf/QnI+14Ehu0lDfTndkG1obPM0SBtHQCGtVEIF8NPT/ary AqSVSQMjp5sl7t2fghySRJV++bgtJxyBYA/m6uBWDVt3Uth7+qQVZrw4RdWQG9AHrFrN 5SRlKp2028GvIrso/6mOqCY8CcTMNfkC16t/ZxE3DMxFv76rS51djEY2aFhN2wNw2VUN mHQw== 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=Zeqavew/vY6f4t63gmA+rSSNtPJ2y+B2UxfgLhzHhUY=; b=SjRndx2HH8hHOSJHoAP/LE+b+fBaLthYVfw6ykFYjJMdgGBOpWhrg5CmA2Pm8ZLD9o SOkf+NjQqCH5qd1tSOqIQEgXD0aLuMki5RmU7m92Cgr7yEclpL42UN0hH9YN/nb+Moyq D0KyR8TwMvCHXzHhg1IWX1jUei7y9Dwh0Q5e+hV93P/xXJy47OwCk0GDcKF3vZU1hrHz VwVqV5HGLGp2+dSEBGCkT6gz7GQgzKDMLZjQgjZwxstc8nZLaypBwrb46EU9Z1LFpUw/ 8XPeRodlkbkc6Rb3xAvluOpTtWzCOLSq3++LueBHu0qjPnuBMayYJ2mtDOQ1+lW6KQtj RBgw== X-Gm-Message-State: APjAAAU/wE2M0xg3NtpkYVnFHtrs/Sce6h2WSCFn6CerHu1ndUau7mje hmKVvO1fFqAqfVnvRlbnXjlnH9d8 X-Google-Smtp-Source: APXvYqwh9aTRRUDRv9wyWdtg/YUET9v/Hyw7FI8XTve/UavWp824/kDuEMYqZ+I6Uj7wSJRabYz+TA== X-Received: by 2002:a05:620a:12ab:: with SMTP id x11mr33769828qki.149.1575992881771; Tue, 10 Dec 2019 07:48:01 -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 m29sm1247848qtf.1.2019.12.10.07.48.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2019 07:48:00 -0800 (PST) From: Nick Rosbrook To: xen-devel@lists.xenproject.org Date: Tue, 10 Dec 2019 10:47:25 -0500 Message-Id: <7e9e0c548291406c980e9496a7f09d081682d3c7.1575990937.git.rosbrookn@ainfosec.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 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 c1d9fe85fd..6b87bf857d 100644 --- a/tools/golang/xenlight/xenlight.go +++ b/tools/golang/xenlight/xenlight.go @@ -245,6 +245,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