aboutsummaryrefslogtreecommitdiff
path: root/hw/smbios/smbios_build.h
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2017-10-28 21:51:36 +0100
committerMichael S. Tsirkin <mst@redhat.com>2017-12-05 19:13:45 +0200
commit2d6dcbf93fb01b4a7f45a93d276d4d74b16392dd (patch)
treeb4875db763ef63618bb6a8aeb84e43b6cc38ce14 /hw/smbios/smbios_build.h
parent2babfe0c9241c239272a03fec785165a50e8288c (diff)
downloadqemu-2d6dcbf93fb01b4a7f45a93d276d4d74b16392dd.zip
qemu-2d6dcbf93fb01b4a7f45a93d276d4d74b16392dd.tar.gz
qemu-2d6dcbf93fb01b4a7f45a93d276d4d74b16392dd.tar.bz2
smbios: support setting OEM strings table
The cloud-init program currently allows fetching of its data by repurposing of the 'system' type 'serial' field. This is a clear abuse of the serial field that would clash with other valid usage a virt management app might have for that field. Fortunately the SMBIOS defines an "OEM Strings" table whose puporse is to allow exposing of arbitrary vendor specific strings to the operating system. This is perfect for use with cloud-init, or as a way to pass arguments to OS installers such as anaconda. This patch makes it easier to support this with QEMU. e.g. $QEMU -smbios type=11,value=Hello,value=World,value=Tricky,,value=test Which results in the guest seeing dmidecode data Handle 0x0E00, DMI type 11, 5 bytes OEM Strings String 1: Hello String 2: World String 3: Tricky,value=test It is suggested that any app wanting to make use of this OEM strings capability for accepting data from the host mgmt layer should use its name as a string prefix. e.g. to expose OEM strings targetting both cloud init and anaconda in parallel the mgmt app could set $QEMU -smbios type=11,value=cloud-init:ds=nocloud-net;s=http://10.10.0.1:8000/,\ value=anaconda:method=http://dl.fedoraproject.org/pub/fedora/linux/releases/25/x86_64/os which would appear as Handle 0x0E00, DMI type 11, 5 bytes OEM Strings String 1: cloud-init:ds=nocloud-net;s=http://10.10.0.1:8000/ String 2: anaconda:method=http://dl.fedoraproject.org/pub/fedora/linux/releases/25/x86_64/os Use of such string prefixes means the app won't have to care which string slot its data appears in. Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/smbios/smbios_build.h')
-rw-r--r--hw/smbios/smbios_build.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/hw/smbios/smbios_build.h b/hw/smbios/smbios_build.h
index 68b8b72..93b360d 100644
--- a/hw/smbios/smbios_build.h
+++ b/hw/smbios/smbios_build.h
@@ -63,6 +63,18 @@ extern unsigned smbios_table_cnt;
} \
} while (0)
+#define SMBIOS_TABLE_SET_STR_LIST(tbl_type, value) \
+ do { \
+ int len = (value != NULL) ? strlen(value) + 1 : 0; \
+ if (len > 1) { \
+ smbios_tables = g_realloc(smbios_tables, \
+ smbios_tables_len + len); \
+ memcpy(smbios_tables + smbios_tables_len, value, len); \
+ smbios_tables_len += len; \
+ ++str_index; \
+ } \
+ } while (0)
+
#define SMBIOS_BUILD_TABLE_POST \
do { \
size_t term_cnt, t_size; \