From nobody Thu Nov 28 04:51:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1678135271; cv=none; d=zohomail.com; s=zohoarc; b=K9a5b7rHyLQ6UiDeAFnxFfvZ+3VDndkq3tyAjsme8DvKGws9oTlV/AXgtBWvnSoGnSsGHUf+DBykrkAuvJOWzW76Tpq2I1G3QHuqvFDaqNsAxtPX5CWnbvfFET3ZV5xANmjOcnhcLWLLQ3Xpa+q5TXKd98MRGc+8pGswjERmrwU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678135271; h=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; bh=y28wWCfzzCCf0En/MTSEqU7UtSyyDPmGt1fjWU1k+QE=; b=UpLCDKxNif90FFaUbAlLfGZ1XKl4Ri+v5lvntNv2vN6eavR8oNz3kcoeuKiI1PMLpOzWo1Fpg15FWpZpwgKoPJaP33TXpDfeb6oc+1osSYaivDuGv7exse2Mt56Zqc0rxmCbOpXmyb6cjxuz8jCqPAnfHzRlrd6b8E/M2qeTeFM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1678135271189878.1641987368376; Mon, 6 Mar 2023 12:41:11 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.507109.780327 (Exim 4.92) (envelope-from ) id 1pZHdR-00011F-95; Mon, 06 Mar 2023 20:40:41 +0000 Received: by outflank-mailman (output) from mailman id 507109.780327; Mon, 06 Mar 2023 20:40:41 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pZHdR-000118-5p; Mon, 06 Mar 2023 20:40:41 +0000 Received: by outflank-mailman (input) for mailman id 507109; Mon, 06 Mar 2023 20:40:40 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pZHdQ-0000m6-7n for xen-devel@lists.xenproject.org; Mon, 06 Mar 2023 20:40:40 +0000 Received: from mail-qt1-x82b.google.com (mail-qt1-x82b.google.com [2607:f8b0:4864:20::82b]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 2783c7fd-bc5f-11ed-96b5-2f268f93b82a; Mon, 06 Mar 2023 21:40:39 +0100 (CET) Received: by mail-qt1-x82b.google.com with SMTP id c3so12081786qtc.8 for ; Mon, 06 Mar 2023 12:40:39 -0800 (PST) Received: from pm2-ws13.praxislan02.com ([2001:470:8:67e:2825:cedc:1289:7391]) by smtp.gmail.com with ESMTPSA id j10-20020ac8440a000000b003b82a07c4d6sm8086316qtn.84.2023.03.06.12.40.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 12:40:37 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 2783c7fd-bc5f-11ed-96b5-2f268f93b82a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678135238; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=y28wWCfzzCCf0En/MTSEqU7UtSyyDPmGt1fjWU1k+QE=; b=pOS7MOKa3aKm/6gJKPiLUcYhTlP3C4ufRg/Wbl6qeTAFw+ISxiqBfqrE/LxRqBmWPN AyC3PRQAQugtmJbbKnzic9Ct6mHPIu5iwG4jJh3Q4Hhu11x+XsHmcUP0+lNflE7jWZKy Y+oQmYsVSl+7etoAzBMB4hg4lCPuGSnwEOTMo0Fz3yF6g3AkV/mYkZlr894Nd2UZ8Krl 673NrSHdTYtS99eYlduJVrqMS/Bt7VU2Solk8D6Dj2In0TkVq48hje0nTfThb4GHQmSm 7/VO3+UdUUu+oidohm9jcrmnWaRnSbbfXmpUWkryUeAk+AKbFyZjTFwBbLi18VN3gYaL Mong== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678135238; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=y28wWCfzzCCf0En/MTSEqU7UtSyyDPmGt1fjWU1k+QE=; b=FYu83frzJM9Rt1+A5+/WFAWIWagundxBmZo+J18ue3wk1vwp2QPsass4Ia6U+o4zOn fTKR2JnOpkcFTQigiGc4re9iQTAoquFcdp1Kse3sliaGOveBA8Ckw+GdVrtcj1HpAYso rg+q7vqRD0TS79FPkABrgk9iMFfIpz0xs2c2i66/7kWmXpy0ensDVT2EMkjx6A+cPWYY bkRnWlxu2d57k7D3010ONJmiP8Vs9Aj+a6RZGBRZ8YFAqBnsg7JfpQtDYNbnO0IhQbBW qkMzECDakW64edbiTJOq17RMuI/6pGy9ZLB1p249LZmK//SkFUFwzzR9q2oDg8u3q7XQ 3pBg== X-Gm-Message-State: AO0yUKUcEc/0IAFLUh7BU9ebD3Vap7XhKVAGtp2Nqh2bQbpl2JKfR4UQ qyK4glbUCM6BSyD6U1cHEMCajh3ZY9g= X-Google-Smtp-Source: AK7set+8EY1clqDGMHutI3NT4TBwSF9qFqitsupVTFFzFDB9+Gyfw1lnf9qnLSfekCSsWCq8ny8RXA== X-Received: by 2002:ac8:4e8f:0:b0:3bf:cea5:9866 with SMTP id 15-20020ac84e8f000000b003bfcea59866mr21102985qtp.24.1678135237738; Mon, 06 Mar 2023 12:40:37 -0800 (PST) From: Jason Andryuk To: xen-devel@lists.xenproject.org Cc: Jason Andryuk , George Dunlap , Nick Rosbrook , Wei Liu , Anthony PERARD Subject: [PATCH v4 1/3] golang/xenlight: Extend KeyedUnion to support Arrays Date: Mon, 6 Mar 2023 15:40:22 -0500 Message-Id: <20230306204024.124882-2-jandryuk@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306204024.124882-1-jandryuk@gmail.com> References: <20230306204024.124882-1-jandryuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1678135271715100001 Content-Type: text/plain; charset="utf-8" Generation for KeyedUnion types doesn't support Arrays. The smbios support will place an smbios array inside the hvm KeyedUnion, and gentotypes doesn't generate buildable Go code. Have KeyedUnion add an idl.Array check and issue the approriate xenlight_golang_array_to_C and xenlight_golang_array_from_C calls when needed. This matches how it is done in xenlight_golang_define_to_C & xenlight_golang_define_from_C xenlight_golang_array_to_C and xenlight_golang_array_from_C need to be extended to set the cvarname and govarname as approriate for the KeyedUnion cases to match the surrounding code. Signed-off-by: Jason Andryuk Acked-by: George Dunlap --- tools/golang/xenlight/gengotypes.py | 41 ++++++++++++++++++----------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/tools/golang/xenlight/gengotypes.py b/tools/golang/xenlight/ge= ngotypes.py index 9fec60602d..e4eb7ca1c1 100644 --- a/tools/golang/xenlight/gengotypes.py +++ b/tools/golang/xenlight/gengotypes.py @@ -376,6 +376,10 @@ def xenlight_golang_union_from_C(ty =3D None, union_na= me =3D '', struct_name =3D ''): s +=3D 'tmp :=3D (*C.{0})(unsafe.Pointer(&xc.{1}[0]))\n'.format(ty= pename,union_name) =20 for nf in f.type.fields: + if isinstance(nf.type, idl.Array): + s +=3D xenlight_golang_array_from_C(nf,cvarname=3D'tmp') + continue + s +=3D xenlight_golang_convert_from_C(nf,cvarname=3D'tmp') =20 s +=3D 'return nil\n' @@ -416,7 +420,7 @@ def xenlight_golang_union_from_C(ty =3D None, union_nam= e =3D '', struct_name =3D ''): =20 return (s,extras) =20 -def xenlight_golang_array_from_C(ty =3D None): +def xenlight_golang_array_from_C(ty =3D None, cvarname =3D 'xc'): """ Convert C array to Go slice using the method described here: @@ -433,9 +437,9 @@ def xenlight_golang_array_from_C(ty =3D None): clenvar =3D ty.type.lenvar.name =20 s +=3D 'x.{0} =3D nil\n'.format(goname) - s +=3D 'if n :=3D int(xc.{0}); n > 0 {{\n'.format(clenvar) + s +=3D 'if n :=3D int({0}.{1}); n > 0 {{\n'.format(cvarname,clenvar) s +=3D '{0} :=3D '.format(cslice) - s +=3D'(*[1<<28]C.{0})(unsafe.Pointer(xc.{1}))[:n:n]\n'.format(ctypena= me, cname) + s +=3D'(*[1<<28]C.{0})(unsafe.Pointer({1}.{2}))[:n:n]\n'.format(ctypen= ame, cvarname, cname) s +=3D 'x.{0} =3D make([]{1}, n)\n'.format(goname, gotypename) s +=3D 'for i, v :=3D range {0} {{\n'.format(cslice) =20 @@ -579,6 +583,11 @@ def xenlight_golang_union_to_C(ty =3D None, union_name= =3D '', =20 s +=3D 'var {0} C.{1}\n'.format(f.name,cgotype) for uf in f.type.fields: + if isinstance(uf.type, idl.Array): + s +=3D xenlight_golang_array_to_C(uf, cvarname=3Df.name, + govarname=3D"tmp") + continue + s +=3D xenlight_golang_convert_to_C(uf,cvarname=3Df.name, govarname=3D'tmp') =20 @@ -596,7 +605,7 @@ def xenlight_golang_union_to_C(ty =3D None, union_name = =3D '', =20 return s =20 -def xenlight_golang_array_to_C(ty =3D None): +def xenlight_golang_array_to_C(ty =3D None, cvarname=3D"xc", govarname=3D"= x"): s =3D '' =20 gotypename =3D xenlight_golang_fmt_name(ty.type.elem_type.typename) @@ -608,27 +617,27 @@ def xenlight_golang_array_to_C(ty =3D None): =20 is_enum =3D isinstance(ty.type.elem_type,idl.Enumeration) if gotypename in go_builtin_types or is_enum: - s +=3D 'if {0} :=3D len(x.{1}); {2} > 0 {{\n'.format(golenvar,gona= me,golenvar) - s +=3D 'xc.{0} =3D (*C.{1})(C.malloc(C.size_t({2}*{3})))\n'.format= (cname,ctypename, + s +=3D 'if {0} :=3D len({1}.{2}); {3} > 0 {{\n'.format(golenvar,go= varname,goname,golenvar) + s +=3D '{0}.{1} =3D (*C.{2})(C.malloc(C.size_t({3}*{4})))\n'.forma= t(cvarname,cname,ctypename, golenva= r,golenvar) - s +=3D 'xc.{0} =3D C.int({1})\n'.format(clenvar,golenvar) - s +=3D 'c{0} :=3D (*[1<<28]C.{1})(unsafe.Pointer(xc.{2}))[:{3}:{4}= ]\n'.format(goname, - ctyp= ename,cname, + s +=3D '{0}.{1} =3D C.int({2})\n'.format(cvarname,clenvar,golenvar) + s +=3D 'c{0} :=3D (*[1<<28]C.{1})(unsafe.Pointer({2}.{3}))[:{4}:{5= }]\n'.format(goname, + ctyp= ename,cvarname,cname, gole= nvar,golenvar) - s +=3D 'for i,v :=3D range x.{0} {{\n'.format(goname) + s +=3D 'for i,v :=3D range {0}.{1} {{\n'.format(govarname,goname) s +=3D 'c{0}[i] =3D C.{1}(v)\n'.format(goname,ctypename) s +=3D '}\n}\n' =20 return s =20 - s +=3D 'if {0} :=3D len(x.{1}); {2} > 0 {{\n'.format(golenvar,goname,g= olenvar) - s +=3D 'xc.{0} =3D (*C.{1})(C.malloc(C.ulong({2})*C.sizeof_{3}))\n'.fo= rmat(cname,ctypename, + s +=3D 'if {0} :=3D len({1}.{2}); {3} > 0 {{\n'.format(golenvar,govarn= ame,goname,golenvar) + s +=3D '{0}.{1} =3D (*C.{2})(C.malloc(C.ulong({3})*C.sizeof_{4}))\n'.f= ormat(cvarname,cname,ctypename, golenva= r,ctypename) - s +=3D 'xc.{0} =3D C.int({1})\n'.format(clenvar,golenvar) - s +=3D 'c{0} :=3D (*[1<<28]C.{1})(unsafe.Pointer(xc.{2}))[:{3}:{4}]\n'= .format(goname, - c= typename,cname, + s +=3D '{0}.{1} =3D C.int({2})\n'.format(cvarname,clenvar,golenvar) + s +=3D 'c{0} :=3D (*[1<<28]C.{1})(unsafe.Pointer({2}.{3}))[:{4}:{5}]\n= '.format(goname, + c= typename,cvarname,cname, g= olenvar,golenvar) - s +=3D 'for i,v :=3D range x.{0} {{\n'.format(goname) + s +=3D 'for i,v :=3D range {0}.{1} {{\n'.format(govarname,goname) s +=3D 'if err :=3D v.toC(&c{0}[i]); err !=3D nil {{\n'.format(goname) s +=3D 'return fmt.Errorf("converting field {0}: %v", err)\n'.format(g= oname) s +=3D '}\n}\n}\n' --=20 2.39.2 From nobody Thu Nov 28 04:51:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1678135274; cv=none; d=zohomail.com; s=zohoarc; b=GjOHAClepFkpUfaj67AIVSIxj7WZOB7U8tZjJl4Qgw+cNwP7XnqRpftMVQ8t2T4X0tB3E/bU0lfLRdNMb9T1RoHki60kbjzAbH1KO4OAdeCOSrhd/vsnrZTx7WcHFzWWTneF5Cp2EkWba8k9iQfV/FZRzBkITeAxdukSsqt0O0o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678135274; h=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; bh=XhXDy5ti8KLorVIT2G2UDKzu/rOmP963s9KoYPQtJPg=; b=UW/G+gNgMeKYuhRrcnx/skp55ZySTe+47dQlbrGBeEhM2Wh6ntLLwV3OMmbS5mkBjJUJnEoJ7ACCrc57caa3SS79B+wPts9DHBHS4E+T/K3/nzyWJ/CqxyhkPqKStEFh1sGGMKMOul+TwU37n1sKWOvcRV1XdIP1J/hS9mwjXOk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 16781352748636.959289874297724; Mon, 6 Mar 2023 12:41:14 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.507110.780337 (Exim 4.92) (envelope-from ) id 1pZHdU-0001HX-IE; Mon, 06 Mar 2023 20:40:44 +0000 Received: by outflank-mailman (output) from mailman id 507110.780337; Mon, 06 Mar 2023 20:40:44 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pZHdU-0001HJ-ET; Mon, 06 Mar 2023 20:40:44 +0000 Received: by outflank-mailman (input) for mailman id 507110; Mon, 06 Mar 2023 20:40:43 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pZHdT-0000m6-AA for xen-devel@lists.xenproject.org; Mon, 06 Mar 2023 20:40:43 +0000 Received: from mail-qt1-x82c.google.com (mail-qt1-x82c.google.com [2607:f8b0:4864:20::82c]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 2900348b-bc5f-11ed-96b5-2f268f93b82a; Mon, 06 Mar 2023 21:40:42 +0100 (CET) Received: by mail-qt1-x82c.google.com with SMTP id h19so12077425qtk.7 for ; Mon, 06 Mar 2023 12:40:42 -0800 (PST) Received: from pm2-ws13.praxislan02.com ([2001:470:8:67e:2825:cedc:1289:7391]) by smtp.gmail.com with ESMTPSA id j10-20020ac8440a000000b003b82a07c4d6sm8086316qtn.84.2023.03.06.12.40.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 12:40:39 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 2900348b-bc5f-11ed-96b5-2f268f93b82a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678135240; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XhXDy5ti8KLorVIT2G2UDKzu/rOmP963s9KoYPQtJPg=; b=eyCh7wyIPm1KFpLgKs+7TCdsYLsW2uO2qFPO9zBCmdPOrV9jKzUJv2K3evBH4O3ERZ l/bUtrLd+KaJYiaI3bMjYYpYS0tDbmLYXZzAp6UtXm7/pbLtv62/p5NhjYMr+19GU4sI eg4AWjeCZMfEBbs3ujY6Yv5C9FkzrFAlOuImjM158CJhlRiEP7B3a+orny2YudrFAJ6v mLiwJ+5xGeWecRiZFvIJx6yfEoqw2IEnS1WRKwJQ/sI/FCM8H93rcgJE2pvPBanpMQtf k3ZYYG+gHodFX2M5XsMIl998k+gxARyf3KoFi92u24hVf/DDpsDYlA23Y62AgoW1Pyo9 9VZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678135240; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XhXDy5ti8KLorVIT2G2UDKzu/rOmP963s9KoYPQtJPg=; b=r/bkSljilu0N2mIfleI1KUjBfdFU8rzx3sDQlG90EeZVfYkcprO11ODgeIhYs+nGUC TgKEc7E41XhdqmQb1oPbOiHOD5eAF39vwt2OIyxj0dpqM+LYQKQlnwk8nHoAtkLeMkOd PcWumXcTQ8MbvCovpDbrjp2fIFDHsgCIITddAXVxM4fZ4KrVTsbmvFf6iyhgXrDZcR9K 7SKhpWpQwX3YBih7f24dNM+7szp3TtnI6QIw4lZtKgXkhAfD2aPJQlF1OOl1harmLi3n EQlJ01XB2/aY3ydFwzdb1UqZxvh2ACS9ADDffo1IOWMQCwGXFVQRHggH+9v1dWBMcP5A pUzw== X-Gm-Message-State: AO0yUKVNFIIHbYZODZWD8dZil2SZAXH036RqlYpMp3oF/W50mmNyOCee iWIYEBwmlxRCJJcKZ1wukXbfRWfxViU= X-Google-Smtp-Source: AK7set++jiCpAfR58iuZ5SwbyicSozBn5xU3pSr39+n4WlUA1blXwaM1msSoRur+65ZbsLDCkedh9Q== X-Received: by 2002:a05:622a:48:b0:3ba:1d8d:f6d0 with SMTP id y8-20020a05622a004800b003ba1d8df6d0mr22135529qtw.23.1678135240326; Mon, 06 Mar 2023 12:40:40 -0800 (PST) From: Jason Andryuk To: xen-devel@lists.xenproject.org Cc: Jason Andryuk , Wei Liu , Anthony PERARD , George Dunlap , Nick Rosbrook , Juergen Gross Subject: [PATCH v4 2/3] xl/libxl: Add ability to specify SMBIOS strings Date: Mon, 6 Mar 2023 15:40:23 -0500 Message-Id: <20230306204024.124882-3-jandryuk@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306204024.124882-1-jandryuk@gmail.com> References: <20230306204024.124882-1-jandryuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1678135275427100007 Content-Type: text/plain; charset="utf-8" hvm_xs_strings.h specifies xenstore entries which can be used to set or override smbios strings. hvmloader has support for reading them, but xl/libxl support is not wired up. Allow specifying the strings with the new xl.cfg option: smbios=3D["bios_vendor=3DXen Project","system_version=3D1.0"] In terms of strings, the SMBIOS specification 3.5 says: https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.5.0.= pdf """ Strings must be encoded as UTF-8 with no byte order mark (BOM). For compatibility with older SMBIOS parsers, US-ASCII characters should be used. NOTE There is no limit on the length of each individual text string. However, the length of the entire structure table (including all strings) must be reported in the Structure Table Length field of the 32-bit Structure Table Entry Point (see 5.2.1) and/or the Structure Table Maximum Size field of the 64-bit Structure Table Entry Point (see 5.2.2). """ The strings aren't checked for utf-8 or length. hvmloader has a sanity check on the overall length. The libxl_smbios_type enum starts at 1 since otherwise the 0th key is not printed in the json output. Signed-off-by: Jason Andryuk Acked-by: George Dunlap Reviewed-by: Anthony PERARD --- v3 Disallow empty value strings xstrdup listitem before modifying Handle option=3Dfoo=3Dbar -> option foo=3Dbar Fix compilation - remove stray } Remove log message newline Add multiline comment star Rename variable v to key v2: Update s/_/-/ comment Update debug print to xs_path =3D "value" Error on xlu_cfg_get_listitem failure Use EXIT_FAILURE consistently free parsed strings Move break to new line The rendered man page and html don't have a newline at the end of the new section. """ battery_device_name=3DSTRING ms_vm_genid=3D"OPTION" """ however the txt format is correct: """ battery_device_name=3DSTRING ms_vm_genid=3D"OPTION" """ I'm at a loss as to why this is happening. --- docs/man/xl.cfg.5.pod.in | 45 +++++++++++++++++++++ tools/golang/xenlight/helpers.gen.go | 51 ++++++++++++++++++++++++ tools/golang/xenlight/types.gen.go | 27 +++++++++++++ tools/include/libxl.h | 5 +++ tools/libs/light/libxl_dom.c | 21 ++++++++++ tools/libs/light/libxl_types.idl | 26 +++++++++++++ tools/xl/xl_parse.c | 58 +++++++++++++++++++++++++++- 7 files changed, 232 insertions(+), 1 deletion(-) diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in index 024bceeb61..bc4386ee96 100644 --- a/docs/man/xl.cfg.5.pod.in +++ b/docs/man/xl.cfg.5.pod.in @@ -2079,6 +2079,51 @@ number of vendor defined SMBIOS structures (type 128= - 255). Since SMBIOS structures do not present their overall size, each entry in the file must = be preceded by a 32b integer indicating the size of the following structure. =20 +=3Ditem B + +Specifies the SMBIOS values to be provided to the guest. These set or +override specific entries in the tables provided to the guest. + +Each B is a C string from the following l= ist: + +=3Dover 4 + +=3Ditem B + +=3Ditem B + +=3Ditem B + +=3Ditem B + +=3Ditem B + +=3Ditem B + +=3Ditem B + +=3Ditem B + +=3Ditem B + +=3Ditem B + +=3Ditem B + +=3Ditem B + +=3Ditem B + +=3Ditem B + +=3Ditem B + +=3Ditem B + +=3Ditem B + +=3Dback + =3Ditem B =20 Provide a VM generation ID to the guest. diff --git a/tools/golang/xenlight/helpers.gen.go b/tools/golang/xenlight/h= elpers.gen.go index 3ac4938858..0a203d2232 100644 --- a/tools/golang/xenlight/helpers.gen.go +++ b/tools/golang/xenlight/helpers.gen.go @@ -589,6 +589,38 @@ xc.build_id =3D C.CString(x.BuildId)} return nil } =20 +// NewSmbios returns an instance of Smbios initialized with defaults. +func NewSmbios() (*Smbios, error) { +var ( +x Smbios +xc C.libxl_smbios) + +C.libxl_smbios_init(&xc) +defer C.libxl_smbios_dispose(&xc) + +if err :=3D x.fromC(&xc); err !=3D nil { +return nil, err } + +return &x, nil} + +func (x *Smbios) fromC(xc *C.libxl_smbios) error { + x.Key =3D SmbiosType(xc.key) +x.Value =3D C.GoString(xc.value) + + return nil} + +func (x *Smbios) toC(xc *C.libxl_smbios) (err error){defer func(){ +if err !=3D nil{ +C.libxl_smbios_dispose(xc)} +}() + +xc.key =3D C.libxl_smbios_type(x.Key) +if x.Value !=3D "" { +xc.value =3D C.CString(x.Value)} + + return nil + } + // NewDomainCreateInfo returns an instance of DomainCreateInfo initialized= with defaults. func NewDomainCreateInfo() (*DomainCreateInfo, error) { var ( @@ -1183,6 +1215,15 @@ return fmt.Errorf("converting field Altp2M: %v", err) } x.SystemFirmware =3D C.GoString(tmp.system_firmware) x.SmbiosFirmware =3D C.GoString(tmp.smbios_firmware) +x.Smbios =3D nil +if n :=3D int(tmp.num_smbios); n > 0 { +cSmbios :=3D (*[1<<28]C.libxl_smbios)(unsafe.Pointer(tmp.smbios))[:n:n] +x.Smbios =3D make([]Smbios, n) +for i, v :=3D range cSmbios { +if err :=3D x.Smbios[i].fromC(&v); err !=3D nil { +return fmt.Errorf("converting field Smbios: %v", err) } +} +} x.AcpiFirmware =3D C.GoString(tmp.acpi_firmware) x.Hdtype =3D Hdtype(tmp.hdtype) if err :=3D x.Nographic.fromC(&tmp.nographic);err !=3D nil { @@ -1495,6 +1536,16 @@ if tmp.SystemFirmware !=3D "" { hvm.system_firmware =3D C.CString(tmp.SystemFirmware)} if tmp.SmbiosFirmware !=3D "" { hvm.smbios_firmware =3D C.CString(tmp.SmbiosFirmware)} +if numSmbios :=3D len(tmp.Smbios); numSmbios > 0 { +hvm.smbios =3D (*C.libxl_smbios)(C.malloc(C.ulong(numSmbios)*C.sizeof_libx= l_smbios)) +hvm.num_smbios =3D C.int(numSmbios) +cSmbios :=3D (*[1<<28]C.libxl_smbios)(unsafe.Pointer(hvm.smbios))[:numSmbi= os:numSmbios] +for i,v :=3D range tmp.Smbios { +if err :=3D v.toC(&cSmbios[i]); err !=3D nil { +return fmt.Errorf("converting field Smbios: %v", err) +} +} +} if tmp.AcpiFirmware !=3D "" { hvm.acpi_firmware =3D C.CString(tmp.AcpiFirmware)} hvm.hdtype =3D C.libxl_hdtype(tmp.Hdtype) diff --git a/tools/golang/xenlight/types.gen.go b/tools/golang/xenlight/typ= es.gen.go index 16ce879e3f..2d8bc7654a 100644 --- a/tools/golang/xenlight/types.gen.go +++ b/tools/golang/xenlight/types.gen.go @@ -392,6 +392,32 @@ Commandline string BuildId string } =20 +type SmbiosType int +const( +SmbiosTypeBiosVendor SmbiosType =3D 1 +SmbiosTypeBiosVersion SmbiosType =3D 2 +SmbiosTypeSystemManufacturer SmbiosType =3D 3 +SmbiosTypeSystemProductName SmbiosType =3D 4 +SmbiosTypeSystemVersion SmbiosType =3D 5 +SmbiosTypeSystemSerialNumber SmbiosType =3D 6 +SmbiosTypeBaseboardManufacturer SmbiosType =3D 7 +SmbiosTypeBaseboardProductName SmbiosType =3D 8 +SmbiosTypeBaseboardVersion SmbiosType =3D 9 +SmbiosTypeBaseboardSerialNumber SmbiosType =3D 10 +SmbiosTypeBaseboardAssetTag SmbiosType =3D 11 +SmbiosTypeBaseboardLocationInChassis SmbiosType =3D 12 +SmbiosTypeEnclosureManufacturer SmbiosType =3D 13 +SmbiosTypeEnclosureSerialNumber SmbiosType =3D 14 +SmbiosTypeEnclosureAssetTag SmbiosType =3D 15 +SmbiosTypeBatteryManufacturer SmbiosType =3D 16 +SmbiosTypeBatteryDeviceName SmbiosType =3D 17 +) + +type Smbios struct { +Key SmbiosType +Value string +} + type DomainCreateInfo struct { Type DomainType Hap Defbool @@ -572,6 +598,7 @@ NestedHvm Defbool Altp2M Defbool SystemFirmware string SmbiosFirmware string +Smbios []Smbios AcpiFirmware string Hdtype Hdtype Nographic Defbool diff --git a/tools/include/libxl.h b/tools/include/libxl.h index d652895075..5c65222f1e 100644 --- a/tools/include/libxl.h +++ b/tools/include/libxl.h @@ -174,6 +174,11 @@ */ #define LIBXL_HAVE_BUILDINFO_HVM_MS_VM_GENID 1 =20 +/* + * libxl_domain_build_info has the u.hvm.smbios field. + */ +#define LIBXL_HAVE_BUILDINFO_HVM_SMBIOS 1 + /* * LIBXL_HAVE_VCPUINFO_SOFT_AFFINITY indicates that a 'cpumap_soft' * field (of libxl_bitmap type) is present in libxl_vcpuinfo, diff --git a/tools/libs/light/libxl_dom.c b/tools/libs/light/libxl_dom.c index f6311eea6e..5433301f70 100644 --- a/tools/libs/light/libxl_dom.c +++ b/tools/libs/light/libxl_dom.c @@ -773,6 +773,27 @@ static int hvm_build_set_xs_values(libxl__gc *gc, goto err; } =20 + for (int i =3D 0; i < info->u.hvm.num_smbios; i++) { + char *p; + path =3D GCSPRINTF("/local/domain/%d/"HVM_XS_BIOS_STRINGS"/%s", do= mid, + libxl_smbios_type_to_string(info->u.hvm.smbios[i].key)); + + /* Convert libxl_smbios_type string to xenstore path that hvmloader + * will use, as defined by HVM_XS_*. That is convert the '_' to '-= '. */ + p =3D strrchr(path, '/'); + for ( ; *p; p++) { + if (*p =3D=3D '_') + *p =3D '-'; + } + + LOGD(DEBUG, domid, "Writing %s =3D \"%s\"", path, + info->u.hvm.smbios[i].value); + ret =3D libxl__xs_printf(gc, XBT_NULL, path, "%s", + info->u.hvm.smbios[i].value); + if (ret) + goto err; + } + /* Only one module can be passed. PVHv2 guests do not support this. */ if (dom->acpi_modules[0].guest_addr_out &&=20 info->type =3D=3D LIBXL_DOMAIN_TYPE_HVM) { diff --git a/tools/libs/light/libxl_types.idl b/tools/libs/light/libxl_type= s.idl index 0cfad8508d..df4dd36697 100644 --- a/tools/libs/light/libxl_types.idl +++ b/tools/libs/light/libxl_types.idl @@ -423,6 +423,31 @@ libxl_version_info =3D Struct("version_info", [ ("build_id", string), ], dir=3DDIR_OUT) =20 +libxl_smbios_type =3D Enumeration("smbios_type", [ + (1, "bios_vendor"), + (2, "bios_version"), + (3, "system_manufacturer"), + (4, "system_product_name"), + (5, "system_version"), + (6, "system_serial_number"), + (7, "baseboard_manufacturer"), + (8, "baseboard_product_name"), + (9, "baseboard_version"), + (10, "baseboard_serial_number"), + (11, "baseboard_asset_tag"), + (12, "baseboard_location_in_chassis"), + (13, "enclosure_manufacturer"), + (14, "enclosure_serial_number"), + (15, "enclosure_asset_tag"), + (16, "battery_manufacturer"), + (17, "battery_device_name"), + ]) + +libxl_smbios =3D Struct("smbios", [ + ("key", libxl_smbios_type), + ("value", string), + ], dir=3DDIR_IN) + libxl_domain_create_info =3D Struct("domain_create_info",[ ("type", libxl_domain_type), ("hap", libxl_defbool), @@ -609,6 +634,7 @@ libxl_domain_build_info =3D Struct("domain_build_info",[ ("altp2m", libxl_defbool), ("system_firmware", string), ("smbios_firmware", string), + ("smbios", Array(libxl_sm= bios, "num_smbios")), ("acpi_firmware", string), ("hdtype", libxl_hdtype), ("nographic", libxl_defbool), diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c index 853e9f357a..ba219024b6 100644 --- a/tools/xl/xl_parse.c +++ b/tools/xl/xl_parse.c @@ -1297,8 +1297,9 @@ void parse_config_data(const char *config_source, XLU_ConfigList *cpus, *vbds, *nics, *pcis, *cvfbs, *cpuids, *vtpms, *usbctrls, *usbdevs, *p9devs, *vdispls, *pvcallsifs_dev= s; XLU_ConfigList *channels, *ioports, *irqs, *iomem, *viridian, *dtdevs, - *mca_caps; + *mca_caps, *smbios; int num_ioports, num_irqs, num_iomem, num_cpus, num_viridian, num_mca_= caps; + int num_smbios; int pci_power_mgmt =3D 0; int pci_msitranslate =3D 0; int pci_permissive =3D 0; @@ -1860,6 +1861,61 @@ void parse_config_data(const char *config_source, xlu_cfg_replace_string(config, "acpi_firmware", &b_info->u.hvm.acpi_firmware, 0); =20 + switch (xlu_cfg_get_list(config, "smbios", &smbios, &num_smbios, 0= )) + { + case 0: /* Success */ + b_info->u.hvm.num_smbios =3D num_smbios; + b_info->u.hvm.smbios =3D xcalloc(num_smbios, sizeof(libxl_smbi= os)); + for (i =3D 0; i < num_smbios; i++) { + libxl_smbios_type type; + char *option; + char *value; + + buf =3D xlu_cfg_get_listitem(smbios, i); + if (!buf) { + fprintf(stderr, + "xl: Unable to get element #%d in smbios list\= n", + i); + exit(EXIT_FAILURE); + } + + option =3D xstrdup(buf); + value =3D strchr(option, '=3D'); + if (value =3D=3D NULL) { + fprintf(stderr, "xl: failed to split \"%s\" at '=3D'\n= ", + option); + exit(EXIT_FAILURE); + } + + *value =3D '\0'; + value++; + + if (*value =3D=3D '\0') { + fprintf(stderr, + "xl: empty value not allowed for smbios \"%s= =3D\"\n", + option); + exit(EXIT_FAILURE); + } + + e =3D libxl_smbios_type_from_string(option, &type); + if (e) { + fprintf(stderr, "xl: unknown smbios type '%s'\n", opti= on); + exit(EXIT_FAILURE); + } + + b_info->u.hvm.smbios[i].key =3D type; + b_info->u.hvm.smbios[i].value =3D xstrdup(value); + + free(option); + } + break; + case ESRCH: /* Option not present */ + break; + default: + fprintf(stderr,"xl: Unable to parse smbios options.\n"); + exit(EXIT_FAILURE); + } + if (!xlu_cfg_get_string(config, "ms_vm_genid", &buf, 0)) { if (!strcmp(buf, "generate")) { e =3D libxl_ms_vm_genid_generate(ctx, &b_info->u.hvm.ms_vm= _genid); --=20 2.39.2 From nobody Thu Nov 28 04:51:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1678135271; cv=none; d=zohomail.com; s=zohoarc; b=YnYsTQlL7DpX2g+XD5xQvxp7P9OX2aLS0PMFBhiTK7Eu+XxuYdzSYaxPKp51TVk3es7ERsyFX69O5aPkhkDJuBAn493f5XCpr3+heRIG8cD/v5BeJ+gmPy1TstC1hnG5W4toQXK4riD7G9JzqeOGeJoMrOVmh2hYC44OtQK9dhA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678135271; h=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; bh=Vfk/rPawOAJLlZCQLkL2VKm1IzggPUh3nbzo39BZfvE=; b=LuNCKWFgisogqrbp71XwG3p/OX4OzyfwhMuCGHFWzaam+09YqdaVjZlBv7tXzDEcUq0323cV5mmnBGwcyl3v+KrndI1No3M28MeboewAFpTgxtyO8T3NcKgRDVqkAbcrfiE9ibdLF8VjwK8piOKEqJNAe0zQnGFDXgShIQJJEVU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1678135271302684.4702247888197; Mon, 6 Mar 2023 12:41:11 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.507111.780346 (Exim 4.92) (envelope-from ) id 1pZHdZ-0001b0-0D; Mon, 06 Mar 2023 20:40:49 +0000 Received: by outflank-mailman (output) from mailman id 507111.780346; Mon, 06 Mar 2023 20:40:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pZHdY-0001ar-T8; Mon, 06 Mar 2023 20:40:48 +0000 Received: by outflank-mailman (input) for mailman id 507111; Mon, 06 Mar 2023 20:40:48 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pZHdY-0001Yf-1N for xen-devel@lists.xenproject.org; Mon, 06 Mar 2023 20:40:48 +0000 Received: from mail-qt1-x82a.google.com (mail-qt1-x82a.google.com [2607:f8b0:4864:20::82a]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 2a586ee2-bc5f-11ed-a550-8520e6686977; Mon, 06 Mar 2023 21:40:44 +0100 (CET) Received: by mail-qt1-x82a.google.com with SMTP id l18so12121307qtp.1 for ; Mon, 06 Mar 2023 12:40:44 -0800 (PST) Received: from pm2-ws13.praxislan02.com ([2001:470:8:67e:2825:cedc:1289:7391]) by smtp.gmail.com with ESMTPSA id j10-20020ac8440a000000b003b82a07c4d6sm8086316qtn.84.2023.03.06.12.40.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 12:40:42 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 2a586ee2-bc5f-11ed-a550-8520e6686977 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678135242; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Vfk/rPawOAJLlZCQLkL2VKm1IzggPUh3nbzo39BZfvE=; b=pwib/E7fZpMEgZj6q46rp1M996L8fifkdOsW0gnX3Af6a4vYp+P1tlK7GbElvhYOjS 6QGFp0mUGfCQEjOe/8yWcFyPkc/3Q20aIkRTjDCyGMndNA9iwth9GPSS3Po3XCSwaL6x qAXze8FXhkMtayNkHrnps9TCNG3wDUjHPpe5ADetj6gx29Ln651lFrf/E/D6g9SxX+po BSucj+v8OIi+wqHfty6d3H3vpTk6HoLptbkDdFORu4jerCf+eDf96gIK5xG7hn5inpmk iEapkUIXmfSoOILJwPJF5+LfuDB9Aqs1qHEp5jTKKx0h8x6oGJKQY9JopKTDFf/VdlVU +DPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678135242; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Vfk/rPawOAJLlZCQLkL2VKm1IzggPUh3nbzo39BZfvE=; b=klTR/O4MxAQTpGO2lTihz0ONsv8CJIg9fAYaImTutCSnJ/pUYpxfi0etZxCUR0X0Aq 0WI7VYlSsVdgGdEE2Wrnu3bQ9pqZxyEgPJGyLL4mjPwgUOGfEYYtHbE08UgMz/D1vT1s gnNVEtt4JCVNSREX3eaiEpv9Lzf3OHUjDu4GPtwIZYfitb5nBh+IKGxA/YZ3q03GL248 5duQGlIUQBKye+CeDCsE2eeA6xSV9lkS94ODuUhWWOeEen5TbY/9m+SXOFiWjGwDnnIC 7mWpdvj/VeHyh7pve/W8yam8DA6yNT2gUYx9HdQGJv3jjE0UuTfXT8z1yCBEVRTJNNQk 5wig== X-Gm-Message-State: AO0yUKXfGnxTH67onf7Ql5EvdKwvX3RIXk2iUIhjTUwGWPxJUyRl8yuP L5cTNOArzHKANzzVl1YBewHij+bYJz0= X-Google-Smtp-Source: AK7set9QDBiBf+sZ/r6SIHghP2w3mQO/LyXVMA0sMDoSswzRUsoDvnNEF54FensgRkQH04z/GIaIsA== X-Received: by 2002:a05:622a:5c9:b0:3bf:d9a9:25e5 with SMTP id d9-20020a05622a05c900b003bfd9a925e5mr18486750qtb.30.1678135242687; Mon, 06 Mar 2023 12:40:42 -0800 (PST) From: Jason Andryuk To: xen-devel@lists.xenproject.org Cc: Jason Andryuk , Wei Liu , Anthony PERARD , George Dunlap , Nick Rosbrook , Juergen Gross Subject: [PATCH v4 3/3] xl/libxl: Add OEM string support to smbios Date: Mon, 6 Mar 2023 15:40:24 -0500 Message-Id: <20230306204024.124882-4-jandryuk@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306204024.124882-1-jandryuk@gmail.com> References: <20230306204024.124882-1-jandryuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1678135273630100005 Content-Type: text/plain; charset="utf-8" Add support for OEM strings in the SMBIOS type 11. hvmloader checks them sequentially, so hide the implementation detail. Allow multiple plain oem=3D items and assign the numeric values internally. Signed-off-by: Jason Andryuk Acked-by: George Dunlap Reviewed-by: Anthony PERARD --- v3: Add } from patch 2 to parse_config_data Use EXIT_FAILURE Print error message in libxl for > 99 OEM strings v2: Move oem=3D description to be indented in docs Re-work oem=3D description Re-word oem string limit xl error message Replace OEM_{1,99) with just OEM and handle in libxl This change re-introduces the newline before ms_vm_genid. --- docs/man/xl.cfg.5.pod.in | 4 ++++ tools/golang/xenlight/types.gen.go | 1 + tools/libs/light/libxl_dom.c | 16 ++++++++++++++-- tools/libs/light/libxl_types.idl | 1 + tools/xl/xl_parse.c | 13 +++++++++++++ 5 files changed, 33 insertions(+), 2 deletions(-) diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in index bc4386ee96..10f37990be 100644 --- a/docs/man/xl.cfg.5.pod.in +++ b/docs/man/xl.cfg.5.pod.in @@ -2122,6 +2122,10 @@ Each B is a C strin= g from the following list: =20 =3Ditem B =20 +=3Ditem B + +oem=3D can be specified up to 99 times. + =3Dback =20 =3Ditem B diff --git a/tools/golang/xenlight/types.gen.go b/tools/golang/xenlight/typ= es.gen.go index 2d8bc7654a..a7c17699f8 100644 --- a/tools/golang/xenlight/types.gen.go +++ b/tools/golang/xenlight/types.gen.go @@ -411,6 +411,7 @@ SmbiosTypeEnclosureSerialNumber SmbiosType =3D 14 SmbiosTypeEnclosureAssetTag SmbiosType =3D 15 SmbiosTypeBatteryManufacturer SmbiosType =3D 16 SmbiosTypeBatteryDeviceName SmbiosType =3D 17 +SmbiosTypeOem SmbiosType =3D 18 ) =20 type Smbios struct { diff --git a/tools/libs/light/libxl_dom.c b/tools/libs/light/libxl_dom.c index 5433301f70..25fb716084 100644 --- a/tools/libs/light/libxl_dom.c +++ b/tools/libs/light/libxl_dom.c @@ -755,6 +755,7 @@ static int hvm_build_set_xs_values(libxl__gc *gc, const libxl_domain_build_info *info) { char *path =3D NULL; + int num_oem =3D 1; int ret =3D 0; =20 if (dom->smbios_module.guest_addr_out) { @@ -775,8 +776,19 @@ static int hvm_build_set_xs_values(libxl__gc *gc, =20 for (int i =3D 0; i < info->u.hvm.num_smbios; i++) { char *p; - path =3D GCSPRINTF("/local/domain/%d/"HVM_XS_BIOS_STRINGS"/%s", do= mid, - libxl_smbios_type_to_string(info->u.hvm.smbios[i].key)); + if (info->u.hvm.smbios[i].key =3D=3D LIBXL_SMBIOS_TYPE_OEM) { + if (num_oem > 99) { + LOGD(ERROR, domid, "More than 99 SMBIOS OEM strings specif= ied"); + ret =3D ERROR_INVAL; + goto err; + } + path =3D GCSPRINTF("/local/domain/%d/"HVM_XS_OEM_STRINGS, domi= d, + num_oem); + num_oem++; + } else { + path =3D GCSPRINTF("/local/domain/%d/"HVM_XS_BIOS_STRINGS"/%s"= , domid, + libxl_smbios_type_to_string(info->u.hvm.smbios[i].k= ey)); + } =20 /* Convert libxl_smbios_type string to xenstore path that hvmloader * will use, as defined by HVM_XS_*. That is convert the '_' to '-= '. */ diff --git a/tools/libs/light/libxl_types.idl b/tools/libs/light/libxl_type= s.idl index df4dd36697..c10292e0d7 100644 --- a/tools/libs/light/libxl_types.idl +++ b/tools/libs/light/libxl_types.idl @@ -441,6 +441,7 @@ libxl_smbios_type =3D Enumeration("smbios_type", [ (15, "enclosure_asset_tag"), (16, "battery_manufacturer"), (17, "battery_device_name"), + (18, "oem"), ]) =20 libxl_smbios =3D Struct("smbios", [ diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c index ba219024b6..e344d4fda3 100644 --- a/tools/xl/xl_parse.c +++ b/tools/xl/xl_parse.c @@ -1864,6 +1864,9 @@ void parse_config_data(const char *config_source, switch (xlu_cfg_get_list(config, "smbios", &smbios, &num_smbios, 0= )) { case 0: /* Success */ + { + unsigned int num_oem =3D 1; + b_info->u.hvm.num_smbios =3D num_smbios; b_info->u.hvm.smbios =3D xcalloc(num_smbios, sizeof(libxl_smbi= os)); for (i =3D 0; i < num_smbios; i++) { @@ -1903,12 +1906,22 @@ void parse_config_data(const char *config_source, exit(EXIT_FAILURE); } =20 + if (type =3D=3D LIBXL_SMBIOS_TYPE_OEM) { + if (num_oem > 99) { + fprintf(stderr, + "xl: smbios limited to 99 oem strings\n"); + exit(EXIT_FAILURE); + } + num_oem++; + } + b_info->u.hvm.smbios[i].key =3D type; b_info->u.hvm.smbios[i].value =3D xstrdup(value); =20 free(option); } break; + } case ESRCH: /* Option not present */ break; default: --=20 2.39.2