From: Zhuang Yanying <ann.zhuangyanying(a)huawei.com>
This wires up the previously added Chassis strings XML schema to be able to
generate comamnd line args for QEMU. This requires QEMU >= 2.1 release
containing this patch:
SMBIOS: Build aggregate smbios tables and entry point
https://git.qemu.org/?p=qemu.git;a=commit;h=c97294ec1b9e36887e119589d4565...
Signed-off-by: Zhuang Yanying <ann.zhuangyanying(a)huawei.com>
---
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(virSysinfoOEMStringsDefPtr def)
}
+static char *
+qemuBuildSmbiosChassisStr(virSysinfoChassisDefPtr def)
+{
+ virBuffer buf = VIR_BUFFER_INITIALIZER;
+
+ if (!def)
+ return NULL;
+
+ virBufferAddLit(&buf, "type=3");
+
+ /* 3:Manufacturer */
+ virBufferAddLit(&buf, ",manufacturer=");
+ virQEMUBuildBufferEscapeComma(&buf, def->manufacturer);
+ /* 3:Version */
+ if (def->version) {
+ virBufferAddLit(&buf, ",version=");
+ virQEMUBuildBufferEscapeComma(&buf, def->version);
+ }
+ /* 3:Serial Number */
+ if (def->serial) {
+ virBufferAddLit(&buf, ",serial=");
+ virQEMUBuildBufferEscapeComma(&buf, def->serial);
+ }
+ /* 3:Asset Tag */
+ if (def->asset) {
+ virBufferAddLit(&buf, ",asset=");
+ virQEMUBuildBufferEscapeComma(&buf, def->asset);
+ }
+ /* 3:Sku */
+ if (def->sku) {
+ virBufferAddLit(&buf, ",sku=");
+ 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);
}
+ smbioscmd = qemuBuildSmbiosChassisStr(source->chassis);
+ if (smbioscmd != NULL) {
+ virCommandAddArgList(cmd, "-smbios", smbioscmd, NULL);
+ VIR_FREE(smbioscmd);
+ }
+
if (source->oemStrings) {
if (!(smbioscmd = qemuBuildSmbiosOEMStringsStr(source->oemStrings)))
return -1;
diff --git a/tests/qemuxml2argvdata/smbios.args b/tests/qemuxml2argvdata/smbios.args
index d27d436..2f0a89f 100644
--- a/tests/qemuxml2argvdata/smbios.args
+++ b/tests/qemuxml2argvdata/smbios.args
@@ -17,6 +17,8 @@ serial=32dfcb37-5af1-552b-357c-be8c3aa38310,\
uuid=c7a5fdbd-edaf-9455-926a-d65c16db1809,sku=1234567890,family=Red Hat' \
-smbios 'type=2,manufacturer=Hewlett-Packard,product=0B4Ch,version=D,\
serial=CZC1065993,asset=CZC1065993,location=Upside down' \
+-smbios 'type=3,manufacturer=Huawei,version=To be filled by O.E.M.,\
+serial=To be filled by O.E.M.,asset=To be filled by O.E.M.,sku=Type3Sku1' \
-smbios 'type=11,value=Hello,value=World,value=This is,,\
more tricky value=escaped' \
-nographic \
diff --git a/tests/qemuxml2argvdata/smbios.xml b/tests/qemuxml2argvdata/smbios.xml
index 319bdf6..474b7d8 100644
--- a/tests/qemuxml2argvdata/smbios.xml
+++ b/tests/qemuxml2argvdata/smbios.xml
@@ -26,6 +26,13 @@
<entry name='asset'>CZC1065993</entry>
<entry name='location'>Upside down</entry>
</baseBoard>
+ <chassis>
+ <entry name='manufacturer'>Huawei</entry>
+ <entry name='version'>To be filled by O.E.M.</entry>
+ <entry name='serial'>To be filled by O.E.M.</entry>
+ <entry name='asset'>To be filled by O.E.M.</entry>
+ <entry name='sku'>Type3Sku1</entry>
+ </chassis>
<oemStrings>
<entry>Hello</entry>
<entry>World</entry>
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 @@
<entry name='asset'>CZC1065993</entry>
<entry name='location'>Upside down</entry>
</baseBoard>
+ <chassis>
+ <entry name='manufacturer'>Huawei</entry>
+ <entry name='version'>To be filled by O.E.M.</entry>
+ <entry name='serial'>To be filled by O.E.M.</entry>
+ <entry name='asset'>To be filled by O.E.M.</entry>
+ <entry name='sku'>Type3Sku1</entry>
+ </chassis>
<oemStrings>
<entry>Hello</entry>
<entry>World</entry>
--
1.8.3.1