From nobody Thu May 15 18:07:58 2025 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