From nobody Sun May 5 13:37:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 151860020054943.444046327325054; Wed, 14 Feb 2018 01:23:20 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7E527780EC; Wed, 14 Feb 2018 09:23:18 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 20D83608F2; Wed, 14 Feb 2018 09:23:18 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 3E334180BAE3; Wed, 14 Feb 2018 09:23:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1E9NFjt004686 for ; Wed, 14 Feb 2018 04:23:15 -0500 Received: by smtp.corp.redhat.com (Postfix) id 89CAA5C1AB; Wed, 14 Feb 2018 09:23:15 +0000 (UTC) Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 75A485C57D; Wed, 14 Feb 2018 09:23:13 +0000 (UTC) Received: from huawei.com (szxga04-in.huawei.com [45.249.212.190]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 91F4581E01; Wed, 14 Feb 2018 09:23:11 +0000 (UTC) Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 8EB56B8138FCD; Wed, 14 Feb 2018 17:22:58 +0800 (CST) Received: from localhost (10.177.21.2) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.361.1; Wed, 14 Feb 2018 17:22:52 +0800 From: Zhuangyanying To: , , Date: Wed, 14 Feb 2018 17:22:38 +0800 Message-ID: <1518600160-15600-2-git-send-email-ann.zhuangyanying@huawei.com> In-Reply-To: <1518600160-15600-1-git-send-email-ann.zhuangyanying@huawei.com> References: <1518600160-15600-1-git-send-email-ann.zhuangyanying@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.21.2] X-CFilter-Loop: Reflected X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 14 Feb 2018 09:23:12 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 14 Feb 2018 09:23:12 +0000 (UTC) for IP:'45.249.212.190' DOMAIN:'szxga04-in.huawei.com' HELO:'huawei.com' FROM:'ann.zhuangyanying@huawei.com' RCPT:'' X-RedHat-Spam-Score: -0.022 (RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD) 45.249.212.190 szxga04-in.huawei.com 45.249.212.190 szxga04-in.huawei.com X-Scanned-By: MIMEDefang 2.83 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: oscar.zhangbo@huawei.com, arei.gonglei@huawei.com, jiangyifei@huawei.com Subject: [libvirt] [PATCH 1/3] conf: add support for setting Chassis SMBIOS data fields X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 14 Feb 2018 09:23:19 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Zhuang Yanying This type of information defines attributes of a system chassis, such as SMBIOS Chassis Asset Tag. access inside VM (for example) Linux: /sys/class/dmi/id/chassis_asset_tag. Windows: (Get-WmiObject Win32_SystemEnclosure).SMBIOSAssetTag wirhin Windows PowerShell. As an example, you could use something like Huawei To be filled by O.E.M. To be filled by O.E.M. To be filled by O.E.M. Type3Sku1 Signed-off-by: Zhuang Yanying --- docs/formatdomain.html.in | 23 ++++++++ docs/schemas/domaincommon.rng | 22 +++++++ src/conf/domain_conf.c | 55 +++++++++++++++++ src/libvirt_private.syms | 1 + src/util/virsysinfo.c | 133 ++++++++++++++++++++++++++++++++++++++= +++- src/util/virsysinfo.h | 13 +++++ 6 files changed, 246 insertions(+), 1 deletion(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 3ec1173..bcbf6fd 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -411,6 +411,13 @@ <entry name=3D'version'>0B98401 Pro</entry> <entry name=3D'serial'>W1KS427111E</entry> </baseBoard> + <chassis> + <entry name=3D'manufacturer'>Huawei</entry> + <entry name=3D'version'>To be filled by O.E.M.</entry> + <entry name=3D'serial'>To be filled by O.E.M.</entry> + <entry name=3D'asset'>To be filled by O.E.M.</entry> + <entry name=3D'sku'>Type3Sku1</entry> + </chassis> <oemStrings> <entry>myappname:some arbitrary data</entry> <entry>otherappname:more arbitrary data</entry> @@ -502,6 +509,22 @@ validation and date format checking, all values a= re passed as strings to the hypervisor driver. +
chassis
+
+ This is block 3 of SMBIOS, with entry names drawn from: +
+
manufacturer
+
Manufacturer of Chassis
+
version
+
Version of the Chassis
+
serial
+
Serial number
+
asset
+
Asset tag
+
sku
+
SKU number
+
+
oemStrings
This is block 11 of SMBIOS. This element should appear once and diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index ee6f83c..8165e69 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -4896,6 +4896,18 @@ + + + + + + + + + + + + @@ -4940,6 +4952,16 @@ =20 + + + manufacturer + version + serial + asset + sku + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index fb732a0..e369235 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -14542,6 +14542,50 @@ virSysinfoOEMStringsParseXML(xmlXPathContextPtr ct= xt, return ret; } =20 + +static int +virSysinfoChassisParseXML(xmlNodePtr node, + xmlXPathContextPtr ctxt, + virSysinfoChassisDefPtr *chassisdef) +{ + int ret =3D -1; + virSysinfoChassisDefPtr def; + + if (!xmlStrEqual(node->name, BAD_CAST "chassis")) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("XML does not contain expected 'chassis' element"= )); + return ret; + } + + if (VIR_ALLOC(def) < 0) + goto cleanup; + + def->manufacturer =3D + virXPathString("string(entry[@name=3D'manufacturer'])", ctxt); + def->version =3D + virXPathString("string(entry[@name=3D'version'])", ctxt); + def->serial =3D + virXPathString("string(entry[@name=3D'serial'])", ctxt); + def->asset =3D + virXPathString("string(entry[@name=3D'asset'])", ctxt); + def->sku =3D + virXPathString("string(entry[@name=3D'sku'])", ctxt); + + if (!def->manufacturer && !def->version && + !def->serial && !def->asset && !def->sku) { + virSysinfoChassisDefFree(def); + def =3D NULL; + } + + *chassisdef =3D def; + def =3D NULL; + ret =3D 0; + cleanup: + virSysinfoChassisDefFree(def); + return ret; +} + + static virSysinfoDefPtr virSysinfoParseXML(xmlNodePtr node, xmlXPathContextPtr ctxt, @@ -14600,6 +14644,17 @@ virSysinfoParseXML(xmlNodePtr node, if (virSysinfoBaseBoardParseXML(ctxt, &def->baseBoard, &def->nbaseBoar= d) < 0) goto error; =20 + /* Extract chassis related metadata */ + if ((tmpnode =3D virXPathNode("./chassis[1]", ctxt)) !=3D NULL) { + oldnode =3D ctxt->node; + ctxt->node =3D tmpnode; + if (virSysinfoChassisParseXML(tmpnode, ctxt, &def->chassis) < 0) { + ctxt->node =3D oldnode; + goto error; + } + ctxt->node =3D oldnode; + } + /* Extract system related metadata */ if ((tmpnode =3D virXPathNode("./oemStrings[1]", ctxt)) !=3D NULL) { oldnode =3D ctxt->node; diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 3b14d7d..97e4c00 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2860,6 +2860,7 @@ virVasprintfInternal; # util/virsysinfo.h virSysinfoBaseBoardDefClear; virSysinfoBIOSDefFree; +virSysinfoChassisDefFree; virSysinfoDefFree; virSysinfoFormat; virSysinfoRead; diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c index e8d3371..856215c 100644 --- a/src/util/virsysinfo.c +++ b/src/util/virsysinfo.c @@ -108,6 +108,19 @@ void virSysinfoBaseBoardDefClear(virSysinfoBaseBoardDe= fPtr def) VIR_FREE(def->location); } =20 +void virSysinfoChassisDefFree(virSysinfoChassisDefPtr def) +{ + if (def =3D=3D NULL) + return; + + VIR_FREE(def->manufacturer); + VIR_FREE(def->version); + VIR_FREE(def->serial); + VIR_FREE(def->asset); + VIR_FREE(def->sku); + VIR_FREE(def); +} + void virSysinfoOEMStringsDefFree(virSysinfoOEMStringsDefPtr def) { size_t i; @@ -143,6 +156,8 @@ void virSysinfoDefFree(virSysinfoDefPtr def) virSysinfoBaseBoardDefClear(def->baseBoard + i); VIR_FREE(def->baseBoard); =20 + virSysinfoChassisDefFree(def->chassis); + for (i =3D 0; i < def->nprocessor; i++) { VIR_FREE(def->processor[i].processor_socket_destination); VIR_FREE(def->processor[i].processor_type); @@ -826,6 +841,66 @@ virSysinfoParseX86BaseBoard(const char *base, } =20 static int +virSysinfoParseX86Chassis(const char *base, + virSysinfoChassisDefPtr *chassisdef) +{ + int ret =3D -1; + const char *cur, *eol =3D NULL; + virSysinfoChassisDefPtr def; + + if ((cur =3D strstr(base, "Chassis Information")) =3D=3D NULL) + return 0; + + if (VIR_ALLOC(def) < 0) + return ret; + + base =3D cur; + if ((cur =3D strstr(base, "Manufacturer: ")) !=3D NULL) { + cur +=3D 14; + eol =3D strchr(cur, '\n'); + if (eol && VIR_STRNDUP(def->manufacturer, cur, eol - cur) < 0) + goto cleanup; + } + if ((cur =3D strstr(base, "Version: ")) !=3D NULL) { + cur +=3D 9; + eol =3D strchr(cur, '\n'); + if (eol && VIR_STRNDUP(def->version, cur, eol - cur) < 0) + goto cleanup; + } + if ((cur =3D strstr(base, "Serial Number: ")) !=3D NULL) { + cur +=3D 15; + eol =3D strchr(cur, '\n'); + if (eol && VIR_STRNDUP(def->serial, cur, eol - cur) < 0) + goto cleanup; + } + if ((cur =3D strstr(base, "Asset Tag: ")) !=3D NULL) { + cur +=3D 11; + eol =3D strchr(cur, '\n'); + if (eol && VIR_STRNDUP(def->sku, cur, eol - cur) < 0) + goto cleanup; + } + if ((cur =3D strstr(base, "SKU Number: ")) !=3D NULL) { + cur +=3D 12; + eol =3D strchr(cur, '\n'); + if (eol && VIR_STRNDUP(def->sku, cur, eol - cur) < 0) + goto cleanup; + } + + if (!def->manufacturer && !def->version && + !def->serial && !def->asset && !def->sku) { + virSysinfoChassisDefFree(def); + def =3D NULL; + } + + *chassisdef =3D def; + def =3D NULL; + ret =3D 0; + cleanup: + virSysinfoChassisDefFree(def); + return ret; +} + +static int virSysinfoParseX86Processor(const char *base, virSysinfoDefPtr ret) { const char *cur, *tmp_base; @@ -1047,7 +1122,7 @@ virSysinfoReadX86(void) return NULL; } =20 - cmd =3D virCommandNewArgList(path, "-q", "-t", "0,1,2,4,17", NULL); + cmd =3D virCommandNewArgList(path, "-q", "-t", "0,1,2,3,4,17", NULL); VIR_FREE(path); virCommandSetOutputBuffer(cmd, &outbuf); if (virCommandRun(cmd, NULL) < 0) @@ -1067,6 +1142,9 @@ virSysinfoReadX86(void) if (virSysinfoParseX86BaseBoard(outbuf, &ret->baseBoard, &ret->nbaseBo= ard) < 0) goto error; =20 + if (virSysinfoParseX86Chassis(outbuf, &ret->chassis) < 0) + goto error; + ret->nprocessor =3D 0; ret->processor =3D NULL; if (virSysinfoParseX86Processor(outbuf, ret) < 0) @@ -1203,6 +1281,29 @@ virSysinfoBaseBoardFormat(virBufferPtr buf, } =20 static void +virSysinfoChassisFormat(virBufferPtr buf, + virSysinfoChassisDefPtr def) +{ + if (!def) + return; + + virBufferAddLit(buf, "\n"); + virBufferAdjustIndent(buf, 2); + virBufferEscapeString(buf, "%s\n", + def->manufacturer); + virBufferEscapeString(buf, "%s\n", + def->version); + virBufferEscapeString(buf, "%s\n", + def->serial); + virBufferEscapeString(buf, "%s\n", + def->asset); + virBufferEscapeString(buf, "%s\n", + def->sku); + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); +} + +static void virSysinfoProcessorFormat(virBufferPtr buf, virSysinfoDefPtr def) { size_t i; @@ -1354,6 +1455,7 @@ virSysinfoFormat(virBufferPtr buf, virSysinfoDefPtr d= ef) virSysinfoBIOSFormat(&childrenBuf, def->bios); virSysinfoSystemFormat(&childrenBuf, def->system); virSysinfoBaseBoardFormat(&childrenBuf, def->baseBoard, def->nbaseBoar= d); + virSysinfoChassisFormat(&childrenBuf, def->chassis); virSysinfoProcessorFormat(&childrenBuf, def); virSysinfoMemoryFormat(&childrenBuf, def); virSysinfoOEMStringsFormat(&childrenBuf, def->oemStrings); @@ -1466,6 +1568,32 @@ virSysinfoBaseBoardIsEqual(virSysinfoBaseBoardDefPtr= src, return identical; } =20 +static bool +virSysinfoChassisIsEqual(virSysinfoChassisDefPtr src, + virSysinfoChassisDefPtr dst) +{ + bool identical =3D false; + + if (!src && !dst) + return true; + + if ((src && !dst) || (!src && dst)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Target chassis does not match source")); + goto cleanup; + } + + CHECK_FIELD(manufacturer, "chassis vendor"); + CHECK_FIELD(version, "chassis version"); + CHECK_FIELD(serial, "chassis serial"); + CHECK_FIELD(asset, "chassis asset"); + CHECK_FIELD(sku, "chassis sku"); + + identical =3D true; + cleanup: + return identical; +} + #undef CHECK_FIELD =20 bool virSysinfoIsEqual(virSysinfoDefPtr src, @@ -1509,6 +1637,9 @@ bool virSysinfoIsEqual(virSysinfoDefPtr src, dst->baseBoard + i)) goto cleanup; =20 + if (!virSysinfoChassisIsEqual(src->chassis, dst->chassis)) + goto cleanup; + identical =3D true; =20 cleanup: diff --git a/src/util/virsysinfo.h b/src/util/virsysinfo.h index ecb3a36..00a15db 100644 --- a/src/util/virsysinfo.h +++ b/src/util/virsysinfo.h @@ -98,6 +98,16 @@ struct _virSysinfoBaseBoardDef { /* XXX board type */ }; =20 +typedef struct _virSysinfoChassisDef virSysinfoChassisDef; +typedef virSysinfoChassisDef *virSysinfoChassisDefPtr; +struct _virSysinfoChassisDef { + char *manufacturer; + char *version; + char *serial; + char *asset; + char *sku; +}; + typedef struct _virSysinfoOEMStringsDef virSysinfoOEMStringsDef; typedef virSysinfoOEMStringsDef *virSysinfoOEMStringsDefPtr; struct _virSysinfoOEMStringsDef { @@ -116,6 +126,8 @@ struct _virSysinfoDef { size_t nbaseBoard; virSysinfoBaseBoardDefPtr baseBoard; =20 + virSysinfoChassisDefPtr chassis; + size_t nprocessor; virSysinfoProcessorDefPtr processor; =20 @@ -130,6 +142,7 @@ virSysinfoDefPtr virSysinfoRead(void); void virSysinfoBIOSDefFree(virSysinfoBIOSDefPtr def); void virSysinfoSystemDefFree(virSysinfoSystemDefPtr def); void virSysinfoBaseBoardDefClear(virSysinfoBaseBoardDefPtr def); +void virSysinfoChassisDefFree(virSysinfoChassisDefPtr def); void virSysinfoOEMStringsDefFree(virSysinfoOEMStringsDefPtr def); void virSysinfoDefFree(virSysinfoDefPtr def); =20 --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 13:37:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1518614111659171.77585558244823; Wed, 14 Feb 2018 05:15:11 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B137CC057F85; Wed, 14 Feb 2018 13:15:09 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AA9E15C8A1; Wed, 14 Feb 2018 13:15:08 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 8D8B218033E9; Wed, 14 Feb 2018 13:15:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1EDC6Cs024264 for ; Wed, 14 Feb 2018 08:12:06 -0500 Received: by smtp.corp.redhat.com (Postfix) id 79F625D978; Wed, 14 Feb 2018 13:12:06 +0000 (UTC) Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4E9B45D971; Wed, 14 Feb 2018 13:12:03 +0000 (UTC) Received: from huawei.com (unknown [45.249.212.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D8E4A356CB; Wed, 14 Feb 2018 13:12:00 +0000 (UTC) Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 17075793C7569; Wed, 14 Feb 2018 17:23:03 +0800 (CST) Received: from localhost (10.177.21.2) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.361.1; Wed, 14 Feb 2018 17:22:54 +0800 From: Zhuangyanying To: , , Date: Wed, 14 Feb 2018 17:22:39 +0800 Message-ID: <1518600160-15600-3-git-send-email-ann.zhuangyanying@huawei.com> In-Reply-To: <1518600160-15600-1-git-send-email-ann.zhuangyanying@huawei.com> References: <1518600160-15600-1-git-send-email-ann.zhuangyanying@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.21.2] X-CFilter-Loop: Reflected X-Greylist: Delayed for 03:48:55 by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 14 Feb 2018 13:12:01 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 14 Feb 2018 13:12:01 +0000 (UTC) for IP:'45.249.212.35' DOMAIN:'[45.249.212.35]' HELO:'huawei.com' FROM:'ann.zhuangyanying@huawei.com' RCPT:'' X-RedHat-Spam-Score: 1.272 * (RDNS_NONE, SPF_HELO_PASS, SPF_PASS) 45.249.212.35 [45.249.212.35] 45.249.212.35 [45.249.212.35] X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: oscar.zhangbo@huawei.com, arei.gonglei@huawei.com, jiangyifei@huawei.com Subject: [libvirt] [PATCH 2/3] qemu: add support for generating SMBIOS Chassis strings command line X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 14 Feb 2018 13:15:10 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Zhuang Yanying This wires up the previously added Chassis strings XML schema to be able to generate comamnd line args for QEMU. This requires QEMU >=3D 2.1 release containing this patch: SMBIOS: Build aggregate smbios tables and entry point https://git.qemu.org/?p=3Dqemu.git;a=3Dcommit;h=3Dc97294ec1b9e36887e119589d= 456557d72ab37b5 Signed-off-by: Zhuang Yanying --- src/qemu/qemu_command.c | 51 +++++++++++++++++++++++++++++++++= ++++ tests/qemuxml2argvdata/smbios.args | 2 ++ tests/qemuxml2argvdata/smbios.xml | 7 +++++ tests/qemuxml2xmloutdata/smbios.xml | 7 +++++ 4 files changed, 67 insertions(+) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 6c73cd7..266b354 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5817,6 +5817,51 @@ qemuBuildSmbiosOEMStringsStr(virSysinfoOEMStringsDef= Ptr def) } =20 =20 +static char * +qemuBuildSmbiosChassisStr(virSysinfoChassisDefPtr def) +{ + virBuffer buf =3D VIR_BUFFER_INITIALIZER; + + if (!def) + return NULL; + + virBufferAddLit(&buf, "type=3D3"); + + /* 3:Manufacturer */ + virBufferAddLit(&buf, ",manufacturer=3D"); + virQEMUBuildBufferEscapeComma(&buf, def->manufacturer); + /* 3:Version */ + if (def->version) { + virBufferAddLit(&buf, ",version=3D"); + virQEMUBuildBufferEscapeComma(&buf, def->version); + } + /* 3:Serial Number */ + if (def->serial) { + virBufferAddLit(&buf, ",serial=3D"); + virQEMUBuildBufferEscapeComma(&buf, def->serial); + } + /* 3:Asset Tag */ + if (def->asset) { + virBufferAddLit(&buf, ",asset=3D"); + virQEMUBuildBufferEscapeComma(&buf, def->asset); + } + /* 3:Sku */ + if (def->sku) { + virBufferAddLit(&buf, ",sku=3D"); + virQEMUBuildBufferEscapeComma(&buf, def->sku); + } + + if (virBufferCheckError(&buf) < 0) + goto error; + + return virBufferContentAndReset(&buf); + + error: + virBufferFreeAndReset(&buf); + return NULL; +} + + static int qemuBuildSmbiosCommandLine(virCommandPtr cmd, virQEMUDriverPtr driver, @@ -5888,6 +5933,12 @@ qemuBuildSmbiosCommandLine(virCommandPtr cmd, VIR_FREE(smbioscmd); } =20 + smbioscmd =3D qemuBuildSmbiosChassisStr(source->chassis); + if (smbioscmd !=3D NULL) { + virCommandAddArgList(cmd, "-smbios", smbioscmd, NULL); + VIR_FREE(smbioscmd); + } + if (source->oemStrings) { if (!(smbioscmd =3D qemuBuildSmbiosOEMStringsStr(source->oemSt= rings))) return -1; diff --git a/tests/qemuxml2argvdata/smbios.args b/tests/qemuxml2argvdata/sm= bios.args index d27d436..2f0a89f 100644 --- a/tests/qemuxml2argvdata/smbios.args +++ b/tests/qemuxml2argvdata/smbios.args @@ -17,6 +17,8 @@ serial=3D32dfcb37-5af1-552b-357c-be8c3aa38310,\ uuid=3Dc7a5fdbd-edaf-9455-926a-d65c16db1809,sku=3D1234567890,family=3DRed = Hat' \ -smbios 'type=3D2,manufacturer=3DHewlett-Packard,product=3D0B4Ch,version= =3DD,\ serial=3DCZC1065993,asset=3DCZC1065993,location=3DUpside down' \ +-smbios 'type=3D3,manufacturer=3DHuawei,version=3DTo be filled by O.E.M.,\ +serial=3DTo be filled by O.E.M.,asset=3DTo be filled by O.E.M.,sku=3DType3= Sku1' \ -smbios 'type=3D11,value=3DHello,value=3DWorld,value=3DThis is,,\ more tricky value=3Descaped' \ -nographic \ diff --git a/tests/qemuxml2argvdata/smbios.xml b/tests/qemuxml2argvdata/smb= ios.xml index 319bdf6..474b7d8 100644 --- a/tests/qemuxml2argvdata/smbios.xml +++ b/tests/qemuxml2argvdata/smbios.xml @@ -26,6 +26,13 @@ CZC1065993 Upside down + + Huawei + To be filled by O.E.M. + To be filled by O.E.M. + To be filled by O.E.M. + Type3Sku1 + Hello World diff --git a/tests/qemuxml2xmloutdata/smbios.xml b/tests/qemuxml2xmloutdata= /smbios.xml index cbe616c..5ef9402 100644 --- a/tests/qemuxml2xmloutdata/smbios.xml +++ b/tests/qemuxml2xmloutdata/smbios.xml @@ -26,6 +26,13 @@ CZC1065993 Upside down + + Huawei + To be filled by O.E.M. + To be filled by O.E.M. + To be filled by O.E.M. + Type3Sku1 + Hello World --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 13:37:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1518600205739950.129501424869; Wed, 14 Feb 2018 01:23:25 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7F81881DE1; Wed, 14 Feb 2018 09:23:24 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 55A8B60BE7; Wed, 14 Feb 2018 09:23:24 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 16494180610F; Wed, 14 Feb 2018 09:23:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1E9NMvC004701 for ; Wed, 14 Feb 2018 04:23:22 -0500 Received: by smtp.corp.redhat.com (Postfix) id 73ECE5D6B7; Wed, 14 Feb 2018 09:23:22 +0000 (UTC) Received: from mx1.redhat.com (ext-mx10.extmail.prod.ext.phx2.redhat.com [10.5.110.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3B4985D6A8; Wed, 14 Feb 2018 09:23:19 +0000 (UTC) Received: from huawei.com (szxga05-in.huawei.com [45.249.212.191]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2CA9662E96; Wed, 14 Feb 2018 09:23:18 +0000 (UTC) Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 19B2CBFF18E08; Wed, 14 Feb 2018 17:23:04 +0800 (CST) Received: from localhost (10.177.21.2) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.361.1; Wed, 14 Feb 2018 17:22:55 +0800 From: Zhuangyanying To: , , Date: Wed, 14 Feb 2018 17:22:40 +0800 Message-ID: <1518600160-15600-4-git-send-email-ann.zhuangyanying@huawei.com> In-Reply-To: <1518600160-15600-1-git-send-email-ann.zhuangyanying@huawei.com> References: <1518600160-15600-1-git-send-email-ann.zhuangyanying@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.21.2] X-CFilter-Loop: Reflected X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 14 Feb 2018 09:23:18 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 14 Feb 2018 09:23:18 +0000 (UTC) for IP:'45.249.212.191' DOMAIN:'szxga05-in.huawei.com' HELO:'huawei.com' FROM:'ann.zhuangyanying@huawei.com' RCPT:'' X-RedHat-Spam-Score: -0.022 (RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD) 45.249.212.191 szxga05-in.huawei.com 45.249.212.191 szxga05-in.huawei.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.39 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: oscar.zhangbo@huawei.com, arei.gonglei@huawei.com, jiangyifei@huawei.com Subject: [libvirt] [PATCH 3/3] news: add support for setting Chassis SMBIOS data fields X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 14 Feb 2018 09:23:24 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Zhuang Yanying Signed-off-by: Zhuang Yanying --- docs/news.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/news.xml b/docs/news.xml index 5a2943a..b60cb2d 100644 --- a/docs/news.xml +++ b/docs/news.xml @@ -72,6 +72,11 @@ completion data. + + + conf: add support for setting Chassis SMBIOS data fields + +
--=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list