qemu: Add support for SMBIOS command line otions (Alex Williamson)
Create a new -smbios option (x86-only) to allow binary SMBIOS entries
to be passed through to the BIOS or modify the default values of
individual fields of type 0 and 1 entries on the command line.
Binary SMBIOS entries can be generated as follows:
dmidecode -t 1 -u | grep $'^\t\t[^"]' | xargs -n1 | \
perl -lne 'printf "%c", hex($_)' > smbios_type_1.bin
These can then be passed to the BIOS using this switch:
-smbios file=smbios_type_1.bin
Command line generation supports the following syntax:
-smbios type=0[,vendor=str][,version=str][,date=str][,release=%d.%d]
-smbios type=1[,manufacturer=str][,product=str][,version=str][,serial=str]
[,uuid=$(uuidgen)][,sku=str][,family=str]
For instance, to add a serial number to the type 1 table:
-smbios type=1,serial=0123456789
Interface is extensible to support more fields/tables as needed.
aliguori: remove texi formatting from help output
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7163 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17 20:59:56 +02:00
|
|
|
/*
|
|
|
|
* SMBIOS Support
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Hewlett-Packard Development Company, L.P.
|
2013-08-16 15:18:29 +02:00
|
|
|
* Copyright (C) 2013 Red Hat, Inc.
|
qemu: Add support for SMBIOS command line otions (Alex Williamson)
Create a new -smbios option (x86-only) to allow binary SMBIOS entries
to be passed through to the BIOS or modify the default values of
individual fields of type 0 and 1 entries on the command line.
Binary SMBIOS entries can be generated as follows:
dmidecode -t 1 -u | grep $'^\t\t[^"]' | xargs -n1 | \
perl -lne 'printf "%c", hex($_)' > smbios_type_1.bin
These can then be passed to the BIOS using this switch:
-smbios file=smbios_type_1.bin
Command line generation supports the following syntax:
-smbios type=0[,vendor=str][,version=str][,date=str][,release=%d.%d]
-smbios type=1[,manufacturer=str][,product=str][,version=str][,serial=str]
[,uuid=$(uuidgen)][,sku=str][,family=str]
For instance, to add a serial number to the type 1 table:
-smbios type=1,serial=0123456789
Interface is extensible to support more fields/tables as needed.
aliguori: remove texi formatting from help output
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7163 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17 20:59:56 +02:00
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Alex Williamson <alex.williamson@hp.com>
|
2013-08-16 15:18:29 +02:00
|
|
|
* Markus Armbruster <armbru@redhat.com>
|
qemu: Add support for SMBIOS command line otions (Alex Williamson)
Create a new -smbios option (x86-only) to allow binary SMBIOS entries
to be passed through to the BIOS or modify the default values of
individual fields of type 0 and 1 entries on the command line.
Binary SMBIOS entries can be generated as follows:
dmidecode -t 1 -u | grep $'^\t\t[^"]' | xargs -n1 | \
perl -lne 'printf "%c", hex($_)' > smbios_type_1.bin
These can then be passed to the BIOS using this switch:
-smbios file=smbios_type_1.bin
Command line generation supports the following syntax:
-smbios type=0[,vendor=str][,version=str][,date=str][,release=%d.%d]
-smbios type=1[,manufacturer=str][,product=str][,version=str][,serial=str]
[,uuid=$(uuidgen)][,sku=str][,family=str]
For instance, to add a serial number to the type 1 table:
-smbios type=1,serial=0123456789
Interface is extensible to support more fields/tables as needed.
aliguori: remove texi formatting from help output
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7163 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17 20:59:56 +02:00
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2. See
|
|
|
|
* the COPYING file in the top-level directory.
|
|
|
|
*
|
2012-01-13 17:44:23 +01:00
|
|
|
* Contributions after 2012-01-13 are licensed under the terms of the
|
|
|
|
* GNU GPL, version 2 or (at your option) any later version.
|
qemu: Add support for SMBIOS command line otions (Alex Williamson)
Create a new -smbios option (x86-only) to allow binary SMBIOS entries
to be passed through to the BIOS or modify the default values of
individual fields of type 0 and 1 entries on the command line.
Binary SMBIOS entries can be generated as follows:
dmidecode -t 1 -u | grep $'^\t\t[^"]' | xargs -n1 | \
perl -lne 'printf "%c", hex($_)' > smbios_type_1.bin
These can then be passed to the BIOS using this switch:
-smbios file=smbios_type_1.bin
Command line generation supports the following syntax:
-smbios type=0[,vendor=str][,version=str][,date=str][,release=%d.%d]
-smbios type=1[,manufacturer=str][,product=str][,version=str][,serial=str]
[,uuid=$(uuidgen)][,sku=str][,family=str]
For instance, to add a serial number to the type 1 table:
-smbios type=1,serial=0123456789
Interface is extensible to support more fields/tables as needed.
aliguori: remove texi formatting from help output
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7163 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17 20:59:56 +02:00
|
|
|
*/
|
|
|
|
|
2016-01-26 19:17:30 +01:00
|
|
|
#include "qemu/osdep.h"
|
include/qemu/osdep.h: Don't include qapi/error.h
Commit 57cb38b included qapi/error.h into qemu/osdep.h to get the
Error typedef. Since then, we've moved to include qemu/osdep.h
everywhere. Its file comment explains: "To avoid getting into
possible circular include dependencies, this file should not include
any other QEMU headers, with the exceptions of config-host.h,
compiler.h, os-posix.h and os-win32.h, all of which are doing a
similar job to this file and are under similar constraints."
qapi/error.h doesn't do a similar job, and it doesn't adhere to
similar constraints: it includes qapi-types.h. That's in excess of
100KiB of crap most .c files don't actually need.
Add the typedef to qemu/typedefs.h, and include that instead of
qapi/error.h. Include qapi/error.h in .c files that need it and don't
get it now. Include qapi-types.h in qom/object.h for uint16List.
Update scripts/clean-includes accordingly. Update it further to match
reality: replace config.h by config-target.h, add sysemu/os-posix.h,
sysemu/os-win32.h. Update the list of includes in the qemu/osdep.h
comment quoted above similarly.
This reduces the number of objects depending on qapi/error.h from "all
of them" to less than a third. Unfortunately, the number depending on
qapi-types.h shrinks only a little. More work is needed for that one.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
[Fix compilation without the spice devel packages. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-03-14 09:01:28 +01:00
|
|
|
#include "qapi/error.h"
|
2013-08-16 15:18:29 +02:00
|
|
|
#include "qemu/config-file.h"
|
2013-06-07 15:00:33 +02:00
|
|
|
#include "qemu/error-report.h"
|
2018-02-01 12:18:46 +01:00
|
|
|
#include "qemu/option.h"
|
2012-12-17 18:20:04 +01:00
|
|
|
#include "sysemu/sysemu.h"
|
2016-09-21 06:27:14 +02:00
|
|
|
#include "qemu/uuid.h"
|
2014-04-23 15:42:42 +02:00
|
|
|
#include "sysemu/cpus.h"
|
2015-08-12 04:08:20 +02:00
|
|
|
#include "hw/smbios/smbios.h"
|
2013-02-04 15:40:22 +01:00
|
|
|
#include "hw/loader.h"
|
2015-08-12 04:08:20 +02:00
|
|
|
#include "exec/cpu-common.h"
|
2016-06-10 11:15:40 +02:00
|
|
|
#include "smbios_build.h"
|
2016-06-10 11:15:41 +02:00
|
|
|
#include "hw/smbios/ipmi.h"
|
2014-04-23 15:42:38 +02:00
|
|
|
|
|
|
|
/* legacy structures and constants for <= 2.0 machines */
|
qemu: Add support for SMBIOS command line otions (Alex Williamson)
Create a new -smbios option (x86-only) to allow binary SMBIOS entries
to be passed through to the BIOS or modify the default values of
individual fields of type 0 and 1 entries on the command line.
Binary SMBIOS entries can be generated as follows:
dmidecode -t 1 -u | grep $'^\t\t[^"]' | xargs -n1 | \
perl -lne 'printf "%c", hex($_)' > smbios_type_1.bin
These can then be passed to the BIOS using this switch:
-smbios file=smbios_type_1.bin
Command line generation supports the following syntax:
-smbios type=0[,vendor=str][,version=str][,date=str][,release=%d.%d]
-smbios type=1[,manufacturer=str][,product=str][,version=str][,serial=str]
[,uuid=$(uuidgen)][,sku=str][,family=str]
For instance, to add a serial number to the type 1 table:
-smbios type=1,serial=0123456789
Interface is extensible to support more fields/tables as needed.
aliguori: remove texi formatting from help output
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7163 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17 20:59:56 +02:00
|
|
|
struct smbios_header {
|
|
|
|
uint16_t length;
|
|
|
|
uint8_t type;
|
2011-08-31 12:38:01 +02:00
|
|
|
} QEMU_PACKED;
|
qemu: Add support for SMBIOS command line otions (Alex Williamson)
Create a new -smbios option (x86-only) to allow binary SMBIOS entries
to be passed through to the BIOS or modify the default values of
individual fields of type 0 and 1 entries on the command line.
Binary SMBIOS entries can be generated as follows:
dmidecode -t 1 -u | grep $'^\t\t[^"]' | xargs -n1 | \
perl -lne 'printf "%c", hex($_)' > smbios_type_1.bin
These can then be passed to the BIOS using this switch:
-smbios file=smbios_type_1.bin
Command line generation supports the following syntax:
-smbios type=0[,vendor=str][,version=str][,date=str][,release=%d.%d]
-smbios type=1[,manufacturer=str][,product=str][,version=str][,serial=str]
[,uuid=$(uuidgen)][,sku=str][,family=str]
For instance, to add a serial number to the type 1 table:
-smbios type=1,serial=0123456789
Interface is extensible to support more fields/tables as needed.
aliguori: remove texi formatting from help output
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7163 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17 20:59:56 +02:00
|
|
|
|
|
|
|
struct smbios_field {
|
|
|
|
struct smbios_header header;
|
|
|
|
uint8_t type;
|
|
|
|
uint16_t offset;
|
|
|
|
uint8_t data[];
|
2011-08-31 12:38:01 +02:00
|
|
|
} QEMU_PACKED;
|
qemu: Add support for SMBIOS command line otions (Alex Williamson)
Create a new -smbios option (x86-only) to allow binary SMBIOS entries
to be passed through to the BIOS or modify the default values of
individual fields of type 0 and 1 entries on the command line.
Binary SMBIOS entries can be generated as follows:
dmidecode -t 1 -u | grep $'^\t\t[^"]' | xargs -n1 | \
perl -lne 'printf "%c", hex($_)' > smbios_type_1.bin
These can then be passed to the BIOS using this switch:
-smbios file=smbios_type_1.bin
Command line generation supports the following syntax:
-smbios type=0[,vendor=str][,version=str][,date=str][,release=%d.%d]
-smbios type=1[,manufacturer=str][,product=str][,version=str][,serial=str]
[,uuid=$(uuidgen)][,sku=str][,family=str]
For instance, to add a serial number to the type 1 table:
-smbios type=1,serial=0123456789
Interface is extensible to support more fields/tables as needed.
aliguori: remove texi formatting from help output
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7163 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17 20:59:56 +02:00
|
|
|
|
|
|
|
struct smbios_table {
|
|
|
|
struct smbios_header header;
|
|
|
|
uint8_t data[];
|
2011-08-31 12:38:01 +02:00
|
|
|
} QEMU_PACKED;
|
qemu: Add support for SMBIOS command line otions (Alex Williamson)
Create a new -smbios option (x86-only) to allow binary SMBIOS entries
to be passed through to the BIOS or modify the default values of
individual fields of type 0 and 1 entries on the command line.
Binary SMBIOS entries can be generated as follows:
dmidecode -t 1 -u | grep $'^\t\t[^"]' | xargs -n1 | \
perl -lne 'printf "%c", hex($_)' > smbios_type_1.bin
These can then be passed to the BIOS using this switch:
-smbios file=smbios_type_1.bin
Command line generation supports the following syntax:
-smbios type=0[,vendor=str][,version=str][,date=str][,release=%d.%d]
-smbios type=1[,manufacturer=str][,product=str][,version=str][,serial=str]
[,uuid=$(uuidgen)][,sku=str][,family=str]
For instance, to add a serial number to the type 1 table:
-smbios type=1,serial=0123456789
Interface is extensible to support more fields/tables as needed.
aliguori: remove texi formatting from help output
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7163 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17 20:59:56 +02:00
|
|
|
|
|
|
|
#define SMBIOS_FIELD_ENTRY 0
|
|
|
|
#define SMBIOS_TABLE_ENTRY 1
|
|
|
|
|
|
|
|
static uint8_t *smbios_entries;
|
|
|
|
static size_t smbios_entries_len;
|
2014-04-23 15:42:42 +02:00
|
|
|
static bool smbios_legacy = true;
|
smbios: Encode UUID according to SMBIOS specification
Differently from older versions, SMBIOS version 2.6 is explicit about
the encoding of UUID fields:
> Although RFC 4122 recommends network byte order for all fields, the PC
> industry (including the ACPI, UEFI, and Microsoft specifications) has
> consistently used little-endian byte encoding for the first three fields:
> time_low, time_mid, time_hi_and_version. The same encoding, also known as
> wire format, should also be used for the SMBIOS representation of the UUID.
>
> The UUID {00112233-4455-6677-8899-AABBCCDDEEFF} would thus be represented
> as 33 22 11 00 55 44 77 66 88 99 AA BB CC DD EE FF.
The dmidecode tool implements this and decodes the above "wire format"
when SMBIOS version >= 2.6. We moved from SMBIOS version 2.4 to 2.8 when
we started building the SMBIOS entry point inside QEMU, on commit
c97294ec1b9e36887e119589d456557d72ab37b5.
Change smbios_build_type_1_table() to encode the UUID as specified.
To make sure we won't change the guest-visible UUID when upgrading to a
newer QEMU version, keep the old behavior on pc-*-2.1 and older.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2014-10-29 14:26:08 +01:00
|
|
|
static bool smbios_uuid_encoded = true;
|
2014-04-23 15:42:38 +02:00
|
|
|
/* end: legacy structures & constants for <= 2.0 machines */
|
|
|
|
|
|
|
|
|
2016-06-10 11:15:40 +02:00
|
|
|
uint8_t *smbios_tables;
|
|
|
|
size_t smbios_tables_len;
|
|
|
|
unsigned smbios_table_max;
|
|
|
|
unsigned smbios_table_cnt;
|
2015-09-07 11:39:28 +02:00
|
|
|
static SmbiosEntryPointType smbios_ep_type = SMBIOS_ENTRY_POINT_21;
|
|
|
|
|
|
|
|
static SmbiosEntryPoint ep;
|
2014-04-23 15:42:42 +02:00
|
|
|
|
2009-07-31 19:49:14 +02:00
|
|
|
static int smbios_type4_count = 0;
|
smbios: Make multiple -smbios type= accumulate sanely
Currently, -smbios type=T,NAME=VAL,... adds one field (T,NAME) with
value VAL to fw_cfg for each unique NAME. If NAME occurs multiple
times, the last one's VAL is used (before the QemuOpts conversion, the
first one was used).
Multiple -smbios can add multiple fields with the same (T, NAME).
SeaBIOS reads all of them from fw_cfg, but uses only the first field
(T, NAME). The others are ignored.
"First one wins, subsequent ones get ignored silently" isn't nice. We
commonly let the last option win. Useful, because it lets you
-readconfig first, then selectively override with command line
options.
Clean up -smbios to work the common way. Accumulate the settings,
with later ones overwriting earlier ones. Put the result into fw_cfg
(no more useless duplicates).
Bonus cleanup: qemu_uuid_parse() no longer sets SMBIOS system uuid by
side effect.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2013-08-16 15:18:31 +02:00
|
|
|
static bool smbios_immutable;
|
2014-04-23 15:42:42 +02:00
|
|
|
static bool smbios_have_defaults;
|
|
|
|
static uint32_t smbios_cpuid_version, smbios_cpuid_features, smbios_smp_sockets;
|
2009-07-31 19:49:14 +02:00
|
|
|
|
2014-04-23 15:42:41 +02:00
|
|
|
static DECLARE_BITMAP(have_binfile_bitmap, SMBIOS_MAX_TYPE+1);
|
|
|
|
static DECLARE_BITMAP(have_fields_bitmap, SMBIOS_MAX_TYPE+1);
|
2013-08-16 15:18:30 +02:00
|
|
|
|
smbios: Make multiple -smbios type= accumulate sanely
Currently, -smbios type=T,NAME=VAL,... adds one field (T,NAME) with
value VAL to fw_cfg for each unique NAME. If NAME occurs multiple
times, the last one's VAL is used (before the QemuOpts conversion, the
first one was used).
Multiple -smbios can add multiple fields with the same (T, NAME).
SeaBIOS reads all of them from fw_cfg, but uses only the first field
(T, NAME). The others are ignored.
"First one wins, subsequent ones get ignored silently" isn't nice. We
commonly let the last option win. Useful, because it lets you
-readconfig first, then selectively override with command line
options.
Clean up -smbios to work the common way. Accumulate the settings,
with later ones overwriting earlier ones. Put the result into fw_cfg
(no more useless duplicates).
Bonus cleanup: qemu_uuid_parse() no longer sets SMBIOS system uuid by
side effect.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2013-08-16 15:18:31 +02:00
|
|
|
static struct {
|
|
|
|
const char *vendor, *version, *date;
|
2014-05-19 16:09:54 +02:00
|
|
|
bool have_major_minor, uefi;
|
smbios: Make multiple -smbios type= accumulate sanely
Currently, -smbios type=T,NAME=VAL,... adds one field (T,NAME) with
value VAL to fw_cfg for each unique NAME. If NAME occurs multiple
times, the last one's VAL is used (before the QemuOpts conversion, the
first one was used).
Multiple -smbios can add multiple fields with the same (T, NAME).
SeaBIOS reads all of them from fw_cfg, but uses only the first field
(T, NAME). The others are ignored.
"First one wins, subsequent ones get ignored silently" isn't nice. We
commonly let the last option win. Useful, because it lets you
-readconfig first, then selectively override with command line
options.
Clean up -smbios to work the common way. Accumulate the settings,
with later ones overwriting earlier ones. Put the result into fw_cfg
(no more useless duplicates).
Bonus cleanup: qemu_uuid_parse() no longer sets SMBIOS system uuid by
side effect.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2013-08-16 15:18:31 +02:00
|
|
|
uint8_t major, minor;
|
|
|
|
} type0;
|
|
|
|
|
|
|
|
static struct {
|
|
|
|
const char *manufacturer, *product, *version, *serial, *sku, *family;
|
2016-09-21 06:27:22 +02:00
|
|
|
/* uuid is in qemu_uuid */
|
smbios: Make multiple -smbios type= accumulate sanely
Currently, -smbios type=T,NAME=VAL,... adds one field (T,NAME) with
value VAL to fw_cfg for each unique NAME. If NAME occurs multiple
times, the last one's VAL is used (before the QemuOpts conversion, the
first one was used).
Multiple -smbios can add multiple fields with the same (T, NAME).
SeaBIOS reads all of them from fw_cfg, but uses only the first field
(T, NAME). The others are ignored.
"First one wins, subsequent ones get ignored silently" isn't nice. We
commonly let the last option win. Useful, because it lets you
-readconfig first, then selectively override with command line
options.
Clean up -smbios to work the common way. Accumulate the settings,
with later ones overwriting earlier ones. Put the result into fw_cfg
(no more useless duplicates).
Bonus cleanup: qemu_uuid_parse() no longer sets SMBIOS system uuid by
side effect.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2013-08-16 15:18:31 +02:00
|
|
|
} type1;
|
|
|
|
|
2014-04-23 15:42:42 +02:00
|
|
|
static struct {
|
|
|
|
const char *manufacturer, *product, *version, *serial, *asset, *location;
|
|
|
|
} type2;
|
|
|
|
|
|
|
|
static struct {
|
|
|
|
const char *manufacturer, *version, *serial, *asset, *sku;
|
|
|
|
} type3;
|
|
|
|
|
|
|
|
static struct {
|
|
|
|
const char *sock_pfx, *manufacturer, *version, *serial, *asset, *part;
|
|
|
|
} type4;
|
|
|
|
|
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>
2017-10-28 22:51:36 +02:00
|
|
|
static struct {
|
|
|
|
size_t nvalues;
|
|
|
|
const char **values;
|
|
|
|
} type11;
|
|
|
|
|
2014-04-23 15:42:42 +02:00
|
|
|
static struct {
|
|
|
|
const char *loc_pfx, *bank, *manufacturer, *serial, *asset, *part;
|
2015-03-11 18:58:01 +01:00
|
|
|
uint16_t speed;
|
2014-04-23 15:42:42 +02:00
|
|
|
} type17;
|
|
|
|
|
2013-08-16 15:18:29 +02:00
|
|
|
static QemuOptsList qemu_smbios_opts = {
|
|
|
|
.name = "smbios",
|
|
|
|
.head = QTAILQ_HEAD_INITIALIZER(qemu_smbios_opts.head),
|
|
|
|
.desc = {
|
|
|
|
/*
|
|
|
|
* no elements => accept any params
|
|
|
|
* validation will happen later
|
|
|
|
*/
|
|
|
|
{ /* end of list */ }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static const QemuOptDesc qemu_smbios_file_opts[] = {
|
|
|
|
{
|
|
|
|
.name = "file",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "binary file containing an SMBIOS element",
|
|
|
|
},
|
|
|
|
{ /* end of list */ }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const QemuOptDesc qemu_smbios_type0_opts[] = {
|
|
|
|
{
|
|
|
|
.name = "type",
|
|
|
|
.type = QEMU_OPT_NUMBER,
|
|
|
|
.help = "SMBIOS element type",
|
|
|
|
},{
|
|
|
|
.name = "vendor",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "vendor name",
|
|
|
|
},{
|
|
|
|
.name = "version",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "version number",
|
|
|
|
},{
|
|
|
|
.name = "date",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "release date",
|
|
|
|
},{
|
|
|
|
.name = "release",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "revision number",
|
2014-05-19 16:09:54 +02:00
|
|
|
},{
|
|
|
|
.name = "uefi",
|
|
|
|
.type = QEMU_OPT_BOOL,
|
|
|
|
.help = "uefi support",
|
2013-08-16 15:18:29 +02:00
|
|
|
},
|
|
|
|
{ /* end of list */ }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const QemuOptDesc qemu_smbios_type1_opts[] = {
|
|
|
|
{
|
|
|
|
.name = "type",
|
|
|
|
.type = QEMU_OPT_NUMBER,
|
|
|
|
.help = "SMBIOS element type",
|
|
|
|
},{
|
|
|
|
.name = "manufacturer",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "manufacturer name",
|
|
|
|
},{
|
|
|
|
.name = "product",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "product name",
|
|
|
|
},{
|
|
|
|
.name = "version",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "version number",
|
|
|
|
},{
|
|
|
|
.name = "serial",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "serial number",
|
|
|
|
},{
|
|
|
|
.name = "uuid",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "UUID",
|
|
|
|
},{
|
|
|
|
.name = "sku",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "SKU number",
|
|
|
|
},{
|
|
|
|
.name = "family",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "family name",
|
|
|
|
},
|
|
|
|
{ /* end of list */ }
|
|
|
|
};
|
|
|
|
|
2014-04-23 15:42:42 +02:00
|
|
|
static const QemuOptDesc qemu_smbios_type2_opts[] = {
|
|
|
|
{
|
|
|
|
.name = "type",
|
|
|
|
.type = QEMU_OPT_NUMBER,
|
|
|
|
.help = "SMBIOS element type",
|
|
|
|
},{
|
|
|
|
.name = "manufacturer",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "manufacturer name",
|
|
|
|
},{
|
|
|
|
.name = "product",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "product name",
|
|
|
|
},{
|
|
|
|
.name = "version",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "version number",
|
|
|
|
},{
|
|
|
|
.name = "serial",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "serial number",
|
|
|
|
},{
|
|
|
|
.name = "asset",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "asset tag number",
|
|
|
|
},{
|
|
|
|
.name = "location",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "location in chassis",
|
|
|
|
},
|
|
|
|
{ /* end of list */ }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const QemuOptDesc qemu_smbios_type3_opts[] = {
|
|
|
|
{
|
|
|
|
.name = "type",
|
|
|
|
.type = QEMU_OPT_NUMBER,
|
|
|
|
.help = "SMBIOS element type",
|
|
|
|
},{
|
|
|
|
.name = "manufacturer",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "manufacturer name",
|
|
|
|
},{
|
|
|
|
.name = "version",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "version number",
|
|
|
|
},{
|
|
|
|
.name = "serial",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "serial number",
|
|
|
|
},{
|
|
|
|
.name = "asset",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "asset tag number",
|
|
|
|
},{
|
|
|
|
.name = "sku",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "SKU number",
|
|
|
|
},
|
|
|
|
{ /* end of list */ }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const QemuOptDesc qemu_smbios_type4_opts[] = {
|
|
|
|
{
|
|
|
|
.name = "type",
|
|
|
|
.type = QEMU_OPT_NUMBER,
|
|
|
|
.help = "SMBIOS element type",
|
|
|
|
},{
|
|
|
|
.name = "sock_pfx",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "socket designation string prefix",
|
|
|
|
},{
|
|
|
|
.name = "manufacturer",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "manufacturer name",
|
|
|
|
},{
|
|
|
|
.name = "version",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "version number",
|
|
|
|
},{
|
|
|
|
.name = "serial",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "serial number",
|
|
|
|
},{
|
|
|
|
.name = "asset",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "asset tag number",
|
|
|
|
},{
|
|
|
|
.name = "part",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "part number",
|
|
|
|
},
|
|
|
|
{ /* end of list */ }
|
|
|
|
};
|
|
|
|
|
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>
2017-10-28 22:51:36 +02:00
|
|
|
static const QemuOptDesc qemu_smbios_type11_opts[] = {
|
|
|
|
{
|
|
|
|
.name = "value",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "OEM string data",
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2014-04-23 15:42:42 +02:00
|
|
|
static const QemuOptDesc qemu_smbios_type17_opts[] = {
|
|
|
|
{
|
|
|
|
.name = "type",
|
|
|
|
.type = QEMU_OPT_NUMBER,
|
|
|
|
.help = "SMBIOS element type",
|
|
|
|
},{
|
|
|
|
.name = "loc_pfx",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "device locator string prefix",
|
|
|
|
},{
|
|
|
|
.name = "bank",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "bank locator string",
|
|
|
|
},{
|
|
|
|
.name = "manufacturer",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "manufacturer name",
|
|
|
|
},{
|
|
|
|
.name = "serial",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "serial number",
|
|
|
|
},{
|
|
|
|
.name = "asset",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "asset tag number",
|
|
|
|
},{
|
|
|
|
.name = "part",
|
|
|
|
.type = QEMU_OPT_STRING,
|
|
|
|
.help = "part number",
|
2015-03-11 18:58:01 +01:00
|
|
|
},{
|
|
|
|
.name = "speed",
|
|
|
|
.type = QEMU_OPT_NUMBER,
|
|
|
|
.help = "maximum capable speed",
|
2014-04-23 15:42:42 +02:00
|
|
|
},
|
|
|
|
{ /* end of list */ }
|
|
|
|
};
|
|
|
|
|
2013-08-16 15:18:29 +02:00
|
|
|
static void smbios_register_config(void)
|
|
|
|
{
|
|
|
|
qemu_add_opts(&qemu_smbios_opts);
|
|
|
|
}
|
|
|
|
|
2016-02-16 21:59:07 +01:00
|
|
|
opts_init(smbios_register_config);
|
2013-08-16 15:18:29 +02:00
|
|
|
|
2009-07-31 19:49:14 +02:00
|
|
|
static void smbios_validate_table(void)
|
|
|
|
{
|
2014-04-23 15:42:42 +02:00
|
|
|
uint32_t expect_t4_count = smbios_legacy ? smp_cpus : smbios_smp_sockets;
|
|
|
|
|
|
|
|
if (smbios_type4_count && smbios_type4_count != expect_t4_count) {
|
|
|
|
error_report("Expected %d SMBIOS Type 4 tables, got %d instead",
|
|
|
|
expect_t4_count, smbios_type4_count);
|
2009-07-31 19:49:14 +02:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
qemu: Add support for SMBIOS command line otions (Alex Williamson)
Create a new -smbios option (x86-only) to allow binary SMBIOS entries
to be passed through to the BIOS or modify the default values of
individual fields of type 0 and 1 entries on the command line.
Binary SMBIOS entries can be generated as follows:
dmidecode -t 1 -u | grep $'^\t\t[^"]' | xargs -n1 | \
perl -lne 'printf "%c", hex($_)' > smbios_type_1.bin
These can then be passed to the BIOS using this switch:
-smbios file=smbios_type_1.bin
Command line generation supports the following syntax:
-smbios type=0[,vendor=str][,version=str][,date=str][,release=%d.%d]
-smbios type=1[,manufacturer=str][,product=str][,version=str][,serial=str]
[,uuid=$(uuidgen)][,sku=str][,family=str]
For instance, to add a serial number to the type 1 table:
-smbios type=1,serial=0123456789
Interface is extensible to support more fields/tables as needed.
aliguori: remove texi formatting from help output
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7163 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17 20:59:56 +02:00
|
|
|
|
2014-04-23 15:42:38 +02:00
|
|
|
|
|
|
|
/* legacy setup functions for <= 2.0 machines */
|
smbios: Make multiple -smbios type= accumulate sanely
Currently, -smbios type=T,NAME=VAL,... adds one field (T,NAME) with
value VAL to fw_cfg for each unique NAME. If NAME occurs multiple
times, the last one's VAL is used (before the QemuOpts conversion, the
first one was used).
Multiple -smbios can add multiple fields with the same (T, NAME).
SeaBIOS reads all of them from fw_cfg, but uses only the first field
(T, NAME). The others are ignored.
"First one wins, subsequent ones get ignored silently" isn't nice. We
commonly let the last option win. Useful, because it lets you
-readconfig first, then selectively override with command line
options.
Clean up -smbios to work the common way. Accumulate the settings,
with later ones overwriting earlier ones. Put the result into fw_cfg
(no more useless duplicates).
Bonus cleanup: qemu_uuid_parse() no longer sets SMBIOS system uuid by
side effect.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2013-08-16 15:18:31 +02:00
|
|
|
static void smbios_add_field(int type, int offset, const void *data, size_t len)
|
qemu: Add support for SMBIOS command line otions (Alex Williamson)
Create a new -smbios option (x86-only) to allow binary SMBIOS entries
to be passed through to the BIOS or modify the default values of
individual fields of type 0 and 1 entries on the command line.
Binary SMBIOS entries can be generated as follows:
dmidecode -t 1 -u | grep $'^\t\t[^"]' | xargs -n1 | \
perl -lne 'printf "%c", hex($_)' > smbios_type_1.bin
These can then be passed to the BIOS using this switch:
-smbios file=smbios_type_1.bin
Command line generation supports the following syntax:
-smbios type=0[,vendor=str][,version=str][,date=str][,release=%d.%d]
-smbios type=1[,manufacturer=str][,product=str][,version=str][,serial=str]
[,uuid=$(uuidgen)][,sku=str][,family=str]
For instance, to add a serial number to the type 1 table:
-smbios type=1,serial=0123456789
Interface is extensible to support more fields/tables as needed.
aliguori: remove texi formatting from help output
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7163 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17 20:59:56 +02:00
|
|
|
{
|
|
|
|
struct smbios_field *field;
|
|
|
|
|
|
|
|
if (!smbios_entries) {
|
|
|
|
smbios_entries_len = sizeof(uint16_t);
|
2011-08-21 05:09:37 +02:00
|
|
|
smbios_entries = g_malloc0(smbios_entries_len);
|
qemu: Add support for SMBIOS command line otions (Alex Williamson)
Create a new -smbios option (x86-only) to allow binary SMBIOS entries
to be passed through to the BIOS or modify the default values of
individual fields of type 0 and 1 entries on the command line.
Binary SMBIOS entries can be generated as follows:
dmidecode -t 1 -u | grep $'^\t\t[^"]' | xargs -n1 | \
perl -lne 'printf "%c", hex($_)' > smbios_type_1.bin
These can then be passed to the BIOS using this switch:
-smbios file=smbios_type_1.bin
Command line generation supports the following syntax:
-smbios type=0[,vendor=str][,version=str][,date=str][,release=%d.%d]
-smbios type=1[,manufacturer=str][,product=str][,version=str][,serial=str]
[,uuid=$(uuidgen)][,sku=str][,family=str]
For instance, to add a serial number to the type 1 table:
-smbios type=1,serial=0123456789
Interface is extensible to support more fields/tables as needed.
aliguori: remove texi formatting from help output
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7163 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17 20:59:56 +02:00
|
|
|
}
|
2011-08-21 05:09:37 +02:00
|
|
|
smbios_entries = g_realloc(smbios_entries, smbios_entries_len +
|
qemu: Add support for SMBIOS command line otions (Alex Williamson)
Create a new -smbios option (x86-only) to allow binary SMBIOS entries
to be passed through to the BIOS or modify the default values of
individual fields of type 0 and 1 entries on the command line.
Binary SMBIOS entries can be generated as follows:
dmidecode -t 1 -u | grep $'^\t\t[^"]' | xargs -n1 | \
perl -lne 'printf "%c", hex($_)' > smbios_type_1.bin
These can then be passed to the BIOS using this switch:
-smbios file=smbios_type_1.bin
Command line generation supports the following syntax:
-smbios type=0[,vendor=str][,version=str][,date=str][,release=%d.%d]
-smbios type=1[,manufacturer=str][,product=str][,version=str][,serial=str]
[,uuid=$(uuidgen)][,sku=str][,family=str]
For instance, to add a serial number to the type 1 table:
-smbios type=1,serial=0123456789
Interface is extensible to support more fields/tables as needed.
aliguori: remove texi formatting from help output
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7163 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17 20:59:56 +02:00
|
|
|
sizeof(*field) + len);
|
|
|
|
field = (struct smbios_field *)(smbios_entries + smbios_entries_len);
|
|
|
|
field->header.type = SMBIOS_FIELD_ENTRY;
|
|
|
|
field->header.length = cpu_to_le16(sizeof(*field) + len);
|
|
|
|
|
|
|
|
field->type = type;
|
|
|
|
field->offset = cpu_to_le16(offset);
|
|
|
|
memcpy(field->data, data, len);
|
|
|
|
|
|
|
|
smbios_entries_len += sizeof(*field) + len;
|
|
|
|
(*(uint16_t *)smbios_entries) =
|
|
|
|
cpu_to_le16(le16_to_cpu(*(uint16_t *)smbios_entries) + 1);
|
|
|
|
}
|
|
|
|
|
2013-08-16 15:18:32 +02:00
|
|
|
static void smbios_maybe_add_str(int type, int offset, const char *data)
|
qemu: Add support for SMBIOS command line otions (Alex Williamson)
Create a new -smbios option (x86-only) to allow binary SMBIOS entries
to be passed through to the BIOS or modify the default values of
individual fields of type 0 and 1 entries on the command line.
Binary SMBIOS entries can be generated as follows:
dmidecode -t 1 -u | grep $'^\t\t[^"]' | xargs -n1 | \
perl -lne 'printf "%c", hex($_)' > smbios_type_1.bin
These can then be passed to the BIOS using this switch:
-smbios file=smbios_type_1.bin
Command line generation supports the following syntax:
-smbios type=0[,vendor=str][,version=str][,date=str][,release=%d.%d]
-smbios type=1[,manufacturer=str][,product=str][,version=str][,serial=str]
[,uuid=$(uuidgen)][,sku=str][,family=str]
For instance, to add a serial number to the type 1 table:
-smbios type=1,serial=0123456789
Interface is extensible to support more fields/tables as needed.
aliguori: remove texi formatting from help output
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7163 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17 20:59:56 +02:00
|
|
|
{
|
2013-08-16 15:18:32 +02:00
|
|
|
if (data) {
|
|
|
|
smbios_add_field(type, offset, data, strlen(data) + 1);
|
2013-08-16 15:18:29 +02:00
|
|
|
}
|
2013-08-16 15:18:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void smbios_build_type_0_fields(void)
|
|
|
|
{
|
|
|
|
smbios_maybe_add_str(0, offsetof(struct smbios_type_0, vendor_str),
|
|
|
|
type0.vendor);
|
|
|
|
smbios_maybe_add_str(0, offsetof(struct smbios_type_0, bios_version_str),
|
|
|
|
type0.version);
|
|
|
|
smbios_maybe_add_str(0, offsetof(struct smbios_type_0,
|
qemu: Add support for SMBIOS command line otions (Alex Williamson)
Create a new -smbios option (x86-only) to allow binary SMBIOS entries
to be passed through to the BIOS or modify the default values of
individual fields of type 0 and 1 entries on the command line.
Binary SMBIOS entries can be generated as follows:
dmidecode -t 1 -u | grep $'^\t\t[^"]' | xargs -n1 | \
perl -lne 'printf "%c", hex($_)' > smbios_type_1.bin
These can then be passed to the BIOS using this switch:
-smbios file=smbios_type_1.bin
Command line generation supports the following syntax:
-smbios type=0[,vendor=str][,version=str][,date=str][,release=%d.%d]
-smbios type=1[,manufacturer=str][,product=str][,version=str][,serial=str]
[,uuid=$(uuidgen)][,sku=str][,family=str]
For instance, to add a serial number to the type 1 table:
-smbios type=1,serial=0123456789
Interface is extensible to support more fields/tables as needed.
aliguori: remove texi formatting from help output
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7163 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17 20:59:56 +02:00
|
|
|
bios_release_date_str),
|
2013-08-16 15:18:32 +02:00
|
|
|
type0.date);
|
smbios: Make multiple -smbios type= accumulate sanely
Currently, -smbios type=T,NAME=VAL,... adds one field (T,NAME) with
value VAL to fw_cfg for each unique NAME. If NAME occurs multiple
times, the last one's VAL is used (before the QemuOpts conversion, the
first one was used).
Multiple -smbios can add multiple fields with the same (T, NAME).
SeaBIOS reads all of them from fw_cfg, but uses only the first field
(T, NAME). The others are ignored.
"First one wins, subsequent ones get ignored silently" isn't nice. We
commonly let the last option win. Useful, because it lets you
-readconfig first, then selectively override with command line
options.
Clean up -smbios to work the common way. Accumulate the settings,
with later ones overwriting earlier ones. Put the result into fw_cfg
(no more useless duplicates).
Bonus cleanup: qemu_uuid_parse() no longer sets SMBIOS system uuid by
side effect.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2013-08-16 15:18:31 +02:00
|
|
|
if (type0.have_major_minor) {
|
qemu: Add support for SMBIOS command line otions (Alex Williamson)
Create a new -smbios option (x86-only) to allow binary SMBIOS entries
to be passed through to the BIOS or modify the default values of
individual fields of type 0 and 1 entries on the command line.
Binary SMBIOS entries can be generated as follows:
dmidecode -t 1 -u | grep $'^\t\t[^"]' | xargs -n1 | \
perl -lne 'printf "%c", hex($_)' > smbios_type_1.bin
These can then be passed to the BIOS using this switch:
-smbios file=smbios_type_1.bin
Command line generation supports the following syntax:
-smbios type=0[,vendor=str][,version=str][,date=str][,release=%d.%d]
-smbios type=1[,manufacturer=str][,product=str][,version=str][,serial=str]
[,uuid=$(uuidgen)][,sku=str][,family=str]
For instance, to add a serial number to the type 1 table:
-smbios type=1,serial=0123456789
Interface is extensible to support more fields/tables as needed.
aliguori: remove texi formatting from help output
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7163 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17 20:59:56 +02:00
|
|
|
smbios_add_field(0, offsetof(struct smbios_type_0,
|
2013-06-07 15:00:34 +02:00
|
|
|
system_bios_major_release),
|
smbios: Make multiple -smbios type= accumulate sanely
Currently, -smbios type=T,NAME=VAL,... adds one field (T,NAME) with
value VAL to fw_cfg for each unique NAME. If NAME occurs multiple
times, the last one's VAL is used (before the QemuOpts conversion, the
first one was used).
Multiple -smbios can add multiple fields with the same (T, NAME).
SeaBIOS reads all of them from fw_cfg, but uses only the first field
(T, NAME). The others are ignored.
"First one wins, subsequent ones get ignored silently" isn't nice. We
commonly let the last option win. Useful, because it lets you
-readconfig first, then selectively override with command line
options.
Clean up -smbios to work the common way. Accumulate the settings,
with later ones overwriting earlier ones. Put the result into fw_cfg
(no more useless duplicates).
Bonus cleanup: qemu_uuid_parse() no longer sets SMBIOS system uuid by
side effect.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2013-08-16 15:18:31 +02:00
|
|
|
&type0.major, 1);
|
qemu: Add support for SMBIOS command line otions (Alex Williamson)
Create a new -smbios option (x86-only) to allow binary SMBIOS entries
to be passed through to the BIOS or modify the default values of
individual fields of type 0 and 1 entries on the command line.
Binary SMBIOS entries can be generated as follows:
dmidecode -t 1 -u | grep $'^\t\t[^"]' | xargs -n1 | \
perl -lne 'printf "%c", hex($_)' > smbios_type_1.bin
These can then be passed to the BIOS using this switch:
-smbios file=smbios_type_1.bin
Command line generation supports the following syntax:
-smbios type=0[,vendor=str][,version=str][,date=str][,release=%d.%d]
-smbios type=1[,manufacturer=str][,product=str][,version=str][,serial=str]
[,uuid=$(uuidgen)][,sku=str][,family=str]
For instance, to add a serial number to the type 1 table:
-smbios type=1,serial=0123456789
Interface is extensible to support more fields/tables as needed.
aliguori: remove texi formatting from help output
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7163 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17 20:59:56 +02:00
|
|
|
smbios_add_field(0, offsetof(struct smbios_type_0,
|
2013-06-07 15:00:34 +02:00
|
|
|
system_bios_minor_release),
|
smbios: Make multiple -smbios type= accumulate sanely
Currently, -smbios type=T,NAME=VAL,... adds one field (T,NAME) with
value VAL to fw_cfg for each unique NAME. If NAME occurs multiple
times, the last one's VAL is used (before the QemuOpts conversion, the
first one was used).
Multiple -smbios can add multiple fields with the same (T, NAME).
SeaBIOS reads all of them from fw_cfg, but uses only the first field
(T, NAME). The others are ignored.
"First one wins, subsequent ones get ignored silently" isn't nice. We
commonly let the last option win. Useful, because it lets you
-readconfig first, then selectively override with command line
options.
Clean up -smbios to work the common way. Accumulate the settings,
with later ones overwriting earlier ones. Put the result into fw_cfg
(no more useless duplicates).
Bonus cleanup: qemu_uuid_parse() no longer sets SMBIOS system uuid by
side effect.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2013-08-16 15:18:31 +02:00
|
|
|
&type0.minor, 1);
|
qemu: Add support for SMBIOS command line otions (Alex Williamson)
Create a new -smbios option (x86-only) to allow binary SMBIOS entries
to be passed through to the BIOS or modify the default values of
individual fields of type 0 and 1 entries on the command line.
Binary SMBIOS entries can be generated as follows:
dmidecode -t 1 -u | grep $'^\t\t[^"]' | xargs -n1 | \
perl -lne 'printf "%c", hex($_)' > smbios_type_1.bin
These can then be passed to the BIOS using this switch:
-smbios file=smbios_type_1.bin
Command line generation supports the following syntax:
-smbios type=0[,vendor=str][,version=str][,date=str][,release=%d.%d]
-smbios type=1[,manufacturer=str][,product=str][,version=str][,serial=str]
[,uuid=$(uuidgen)][,sku=str][,family=str]
For instance, to add a serial number to the type 1 table:
-smbios type=1,serial=0123456789
Interface is extensible to support more fields/tables as needed.
aliguori: remove texi formatting from help output
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7163 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17 20:59:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
smbios: Make multiple -smbios type= accumulate sanely
Currently, -smbios type=T,NAME=VAL,... adds one field (T,NAME) with
value VAL to fw_cfg for each unique NAME. If NAME occurs multiple
times, the last one's VAL is used (before the QemuOpts conversion, the
first one was used).
Multiple -smbios can add multiple fields with the same (T, NAME).
SeaBIOS reads all of them from fw_cfg, but uses only the first field
(T, NAME). The others are ignored.
"First one wins, subsequent ones get ignored silently" isn't nice. We
commonly let the last option win. Useful, because it lets you
-readconfig first, then selectively override with command line
options.
Clean up -smbios to work the common way. Accumulate the settings,
with later ones overwriting earlier ones. Put the result into fw_cfg
(no more useless duplicates).
Bonus cleanup: qemu_uuid_parse() no longer sets SMBIOS system uuid by
side effect.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2013-08-16 15:18:31 +02:00
|
|
|
static void smbios_build_type_1_fields(void)
|
qemu: Add support for SMBIOS command line otions (Alex Williamson)
Create a new -smbios option (x86-only) to allow binary SMBIOS entries
to be passed through to the BIOS or modify the default values of
individual fields of type 0 and 1 entries on the command line.
Binary SMBIOS entries can be generated as follows:
dmidecode -t 1 -u | grep $'^\t\t[^"]' | xargs -n1 | \
perl -lne 'printf "%c", hex($_)' > smbios_type_1.bin
These can then be passed to the BIOS using this switch:
-smbios file=smbios_type_1.bin
Command line generation supports the following syntax:
-smbios type=0[,vendor=str][,version=str][,date=str][,release=%d.%d]
-smbios type=1[,manufacturer=str][,product=str][,version=str][,serial=str]
[,uuid=$(uuidgen)][,sku=str][,family=str]
For instance, to add a serial number to the type 1 table:
-smbios type=1,serial=0123456789
Interface is extensible to support more fields/tables as needed.
aliguori: remove texi formatting from help output
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7163 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17 20:59:56 +02:00
|
|
|
{
|
2013-08-16 15:18:32 +02:00
|
|
|
smbios_maybe_add_str(1, offsetof(struct smbios_type_1, manufacturer_str),
|
|
|
|
type1.manufacturer);
|
|
|
|
smbios_maybe_add_str(1, offsetof(struct smbios_type_1, product_name_str),
|
|
|
|
type1.product);
|
|
|
|
smbios_maybe_add_str(1, offsetof(struct smbios_type_1, version_str),
|
|
|
|
type1.version);
|
|
|
|
smbios_maybe_add_str(1, offsetof(struct smbios_type_1, serial_number_str),
|
|
|
|
type1.serial);
|
|
|
|
smbios_maybe_add_str(1, offsetof(struct smbios_type_1, sku_number_str),
|
|
|
|
type1.sku);
|
|
|
|
smbios_maybe_add_str(1, offsetof(struct smbios_type_1, family_str),
|
|
|
|
type1.family);
|
smbios: Make multiple -smbios type= accumulate sanely
Currently, -smbios type=T,NAME=VAL,... adds one field (T,NAME) with
value VAL to fw_cfg for each unique NAME. If NAME occurs multiple
times, the last one's VAL is used (before the QemuOpts conversion, the
first one was used).
Multiple -smbios can add multiple fields with the same (T, NAME).
SeaBIOS reads all of them from fw_cfg, but uses only the first field
(T, NAME). The others are ignored.
"First one wins, subsequent ones get ignored silently" isn't nice. We
commonly let the last option win. Useful, because it lets you
-readconfig first, then selectively override with command line
options.
Clean up -smbios to work the common way. Accumulate the settings,
with later ones overwriting earlier ones. Put the result into fw_cfg
(no more useless duplicates).
Bonus cleanup: qemu_uuid_parse() no longer sets SMBIOS system uuid by
side effect.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2013-08-16 15:18:31 +02:00
|
|
|
if (qemu_uuid_set) {
|
smbios: Encode UUID according to SMBIOS specification
Differently from older versions, SMBIOS version 2.6 is explicit about
the encoding of UUID fields:
> Although RFC 4122 recommends network byte order for all fields, the PC
> industry (including the ACPI, UEFI, and Microsoft specifications) has
> consistently used little-endian byte encoding for the first three fields:
> time_low, time_mid, time_hi_and_version. The same encoding, also known as
> wire format, should also be used for the SMBIOS representation of the UUID.
>
> The UUID {00112233-4455-6677-8899-AABBCCDDEEFF} would thus be represented
> as 33 22 11 00 55 44 77 66 88 99 AA BB CC DD EE FF.
The dmidecode tool implements this and decodes the above "wire format"
when SMBIOS version >= 2.6. We moved from SMBIOS version 2.4 to 2.8 when
we started building the SMBIOS entry point inside QEMU, on commit
c97294ec1b9e36887e119589d456557d72ab37b5.
Change smbios_build_type_1_table() to encode the UUID as specified.
To make sure we won't change the guest-visible UUID when upgrading to a
newer QEMU version, keep the old behavior on pc-*-2.1 and older.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2014-10-29 14:26:08 +01:00
|
|
|
/* We don't encode the UUID in the "wire format" here because this
|
|
|
|
* function is for legacy mode and needs to keep the guest ABI, and
|
|
|
|
* because we don't know what's the SMBIOS version advertised by the
|
|
|
|
* BIOS.
|
|
|
|
*/
|
smbios: Make multiple -smbios type= accumulate sanely
Currently, -smbios type=T,NAME=VAL,... adds one field (T,NAME) with
value VAL to fw_cfg for each unique NAME. If NAME occurs multiple
times, the last one's VAL is used (before the QemuOpts conversion, the
first one was used).
Multiple -smbios can add multiple fields with the same (T, NAME).
SeaBIOS reads all of them from fw_cfg, but uses only the first field
(T, NAME). The others are ignored.
"First one wins, subsequent ones get ignored silently" isn't nice. We
commonly let the last option win. Useful, because it lets you
-readconfig first, then selectively override with command line
options.
Clean up -smbios to work the common way. Accumulate the settings,
with later ones overwriting earlier ones. Put the result into fw_cfg
(no more useless duplicates).
Bonus cleanup: qemu_uuid_parse() no longer sets SMBIOS system uuid by
side effect.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2013-08-16 15:18:31 +02:00
|
|
|
smbios_add_field(1, offsetof(struct smbios_type_1, uuid),
|
2016-09-21 06:27:22 +02:00
|
|
|
&qemu_uuid, 16);
|
smbios: Make multiple -smbios type= accumulate sanely
Currently, -smbios type=T,NAME=VAL,... adds one field (T,NAME) with
value VAL to fw_cfg for each unique NAME. If NAME occurs multiple
times, the last one's VAL is used (before the QemuOpts conversion, the
first one was used).
Multiple -smbios can add multiple fields with the same (T, NAME).
SeaBIOS reads all of them from fw_cfg, but uses only the first field
(T, NAME). The others are ignored.
"First one wins, subsequent ones get ignored silently" isn't nice. We
commonly let the last option win. Useful, because it lets you
-readconfig first, then selectively override with command line
options.
Clean up -smbios to work the common way. Accumulate the settings,
with later ones overwriting earlier ones. Put the result into fw_cfg
(no more useless duplicates).
Bonus cleanup: qemu_uuid_parse() no longer sets SMBIOS system uuid by
side effect.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2013-08-16 15:18:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-23 15:42:38 +02:00
|
|
|
uint8_t *smbios_get_table_legacy(size_t *length)
|
smbios: Make multiple -smbios type= accumulate sanely
Currently, -smbios type=T,NAME=VAL,... adds one field (T,NAME) with
value VAL to fw_cfg for each unique NAME. If NAME occurs multiple
times, the last one's VAL is used (before the QemuOpts conversion, the
first one was used).
Multiple -smbios can add multiple fields with the same (T, NAME).
SeaBIOS reads all of them from fw_cfg, but uses only the first field
(T, NAME). The others are ignored.
"First one wins, subsequent ones get ignored silently" isn't nice. We
commonly let the last option win. Useful, because it lets you
-readconfig first, then selectively override with command line
options.
Clean up -smbios to work the common way. Accumulate the settings,
with later ones overwriting earlier ones. Put the result into fw_cfg
(no more useless duplicates).
Bonus cleanup: qemu_uuid_parse() no longer sets SMBIOS system uuid by
side effect.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2013-08-16 15:18:31 +02:00
|
|
|
{
|
2014-04-23 15:42:42 +02:00
|
|
|
if (!smbios_legacy) {
|
|
|
|
*length = 0;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
smbios: Make multiple -smbios type= accumulate sanely
Currently, -smbios type=T,NAME=VAL,... adds one field (T,NAME) with
value VAL to fw_cfg for each unique NAME. If NAME occurs multiple
times, the last one's VAL is used (before the QemuOpts conversion, the
first one was used).
Multiple -smbios can add multiple fields with the same (T, NAME).
SeaBIOS reads all of them from fw_cfg, but uses only the first field
(T, NAME). The others are ignored.
"First one wins, subsequent ones get ignored silently" isn't nice. We
commonly let the last option win. Useful, because it lets you
-readconfig first, then selectively override with command line
options.
Clean up -smbios to work the common way. Accumulate the settings,
with later ones overwriting earlier ones. Put the result into fw_cfg
(no more useless duplicates).
Bonus cleanup: qemu_uuid_parse() no longer sets SMBIOS system uuid by
side effect.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2013-08-16 15:18:31 +02:00
|
|
|
if (!smbios_immutable) {
|
|
|
|
smbios_build_type_0_fields();
|
|
|
|
smbios_build_type_1_fields();
|
|
|
|
smbios_validate_table();
|
|
|
|
smbios_immutable = true;
|
|
|
|
}
|
|
|
|
*length = smbios_entries_len;
|
|
|
|
return smbios_entries;
|
|
|
|
}
|
2014-04-23 15:42:38 +02:00
|
|
|
/* end: legacy setup functions for <= 2.0 machines */
|
|
|
|
|
smbios: Make multiple -smbios type= accumulate sanely
Currently, -smbios type=T,NAME=VAL,... adds one field (T,NAME) with
value VAL to fw_cfg for each unique NAME. If NAME occurs multiple
times, the last one's VAL is used (before the QemuOpts conversion, the
first one was used).
Multiple -smbios can add multiple fields with the same (T, NAME).
SeaBIOS reads all of them from fw_cfg, but uses only the first field
(T, NAME). The others are ignored.
"First one wins, subsequent ones get ignored silently" isn't nice. We
commonly let the last option win. Useful, because it lets you
-readconfig first, then selectively override with command line
options.
Clean up -smbios to work the common way. Accumulate the settings,
with later ones overwriting earlier ones. Put the result into fw_cfg
(no more useless duplicates).
Bonus cleanup: qemu_uuid_parse() no longer sets SMBIOS system uuid by
side effect.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2013-08-16 15:18:31 +02:00
|
|
|
|
2016-06-10 11:15:40 +02:00
|
|
|
bool smbios_skip_table(uint8_t type, bool required_table)
|
2014-04-23 15:42:42 +02:00
|
|
|
{
|
|
|
|
if (test_bit(type, have_binfile_bitmap)) {
|
|
|
|
return true; /* user provided their own binary blob(s) */
|
|
|
|
}
|
|
|
|
if (test_bit(type, have_fields_bitmap)) {
|
|
|
|
return false; /* user provided fields via command line */
|
|
|
|
}
|
|
|
|
if (smbios_have_defaults && required_table) {
|
|
|
|
return false; /* we're building tables, and this one's required */
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void smbios_build_type_0_table(void)
|
|
|
|
{
|
|
|
|
SMBIOS_BUILD_TABLE_PRE(0, 0x000, false); /* optional, leave up to BIOS */
|
|
|
|
|
|
|
|
SMBIOS_TABLE_SET_STR(0, vendor_str, type0.vendor);
|
|
|
|
SMBIOS_TABLE_SET_STR(0, bios_version_str, type0.version);
|
|
|
|
|
2014-05-19 16:09:53 +02:00
|
|
|
t->bios_starting_address_segment = cpu_to_le16(0xE800); /* from SeaBIOS */
|
2014-04-23 15:42:42 +02:00
|
|
|
|
|
|
|
SMBIOS_TABLE_SET_STR(0, bios_release_date_str, type0.date);
|
|
|
|
|
|
|
|
t->bios_rom_size = 0; /* hardcoded in SeaBIOS with FIXME comment */
|
|
|
|
|
2014-05-19 16:09:54 +02:00
|
|
|
t->bios_characteristics = cpu_to_le64(0x08); /* Not supported */
|
2014-04-23 15:42:42 +02:00
|
|
|
t->bios_characteristics_extension_bytes[0] = 0;
|
2014-05-19 16:09:54 +02:00
|
|
|
t->bios_characteristics_extension_bytes[1] = 0x14; /* TCD/SVVP | VM */
|
|
|
|
if (type0.uefi) {
|
|
|
|
t->bios_characteristics_extension_bytes[1] |= 0x08; /* |= UEFI */
|
|
|
|
}
|
2014-04-23 15:42:42 +02:00
|
|
|
|
|
|
|
if (type0.have_major_minor) {
|
|
|
|
t->system_bios_major_release = type0.major;
|
|
|
|
t->system_bios_minor_release = type0.minor;
|
|
|
|
} else {
|
|
|
|
t->system_bios_major_release = 0;
|
|
|
|
t->system_bios_minor_release = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* hardcoded in SeaBIOS */
|
|
|
|
t->embedded_controller_major_release = 0xFF;
|
|
|
|
t->embedded_controller_minor_release = 0xFF;
|
|
|
|
|
|
|
|
SMBIOS_BUILD_TABLE_POST;
|
|
|
|
}
|
|
|
|
|
smbios: Encode UUID according to SMBIOS specification
Differently from older versions, SMBIOS version 2.6 is explicit about
the encoding of UUID fields:
> Although RFC 4122 recommends network byte order for all fields, the PC
> industry (including the ACPI, UEFI, and Microsoft specifications) has
> consistently used little-endian byte encoding for the first three fields:
> time_low, time_mid, time_hi_and_version. The same encoding, also known as
> wire format, should also be used for the SMBIOS representation of the UUID.
>
> The UUID {00112233-4455-6677-8899-AABBCCDDEEFF} would thus be represented
> as 33 22 11 00 55 44 77 66 88 99 AA BB CC DD EE FF.
The dmidecode tool implements this and decodes the above "wire format"
when SMBIOS version >= 2.6. We moved from SMBIOS version 2.4 to 2.8 when
we started building the SMBIOS entry point inside QEMU, on commit
c97294ec1b9e36887e119589d456557d72ab37b5.
Change smbios_build_type_1_table() to encode the UUID as specified.
To make sure we won't change the guest-visible UUID when upgrading to a
newer QEMU version, keep the old behavior on pc-*-2.1 and older.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2014-10-29 14:26:08 +01:00
|
|
|
/* Encode UUID from the big endian encoding described on RFC4122 to the wire
|
|
|
|
* format specified by SMBIOS version 2.6.
|
|
|
|
*/
|
2016-09-21 06:27:22 +02:00
|
|
|
static void smbios_encode_uuid(struct smbios_uuid *uuid, QemuUUID *in)
|
smbios: Encode UUID according to SMBIOS specification
Differently from older versions, SMBIOS version 2.6 is explicit about
the encoding of UUID fields:
> Although RFC 4122 recommends network byte order for all fields, the PC
> industry (including the ACPI, UEFI, and Microsoft specifications) has
> consistently used little-endian byte encoding for the first three fields:
> time_low, time_mid, time_hi_and_version. The same encoding, also known as
> wire format, should also be used for the SMBIOS representation of the UUID.
>
> The UUID {00112233-4455-6677-8899-AABBCCDDEEFF} would thus be represented
> as 33 22 11 00 55 44 77 66 88 99 AA BB CC DD EE FF.
The dmidecode tool implements this and decodes the above "wire format"
when SMBIOS version >= 2.6. We moved from SMBIOS version 2.4 to 2.8 when
we started building the SMBIOS entry point inside QEMU, on commit
c97294ec1b9e36887e119589d456557d72ab37b5.
Change smbios_build_type_1_table() to encode the UUID as specified.
To make sure we won't change the guest-visible UUID when upgrading to a
newer QEMU version, keep the old behavior on pc-*-2.1 and older.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2014-10-29 14:26:08 +01:00
|
|
|
{
|
2016-09-28 16:38:10 +02:00
|
|
|
memcpy(uuid, in, 16);
|
smbios: Encode UUID according to SMBIOS specification
Differently from older versions, SMBIOS version 2.6 is explicit about
the encoding of UUID fields:
> Although RFC 4122 recommends network byte order for all fields, the PC
> industry (including the ACPI, UEFI, and Microsoft specifications) has
> consistently used little-endian byte encoding for the first three fields:
> time_low, time_mid, time_hi_and_version. The same encoding, also known as
> wire format, should also be used for the SMBIOS representation of the UUID.
>
> The UUID {00112233-4455-6677-8899-AABBCCDDEEFF} would thus be represented
> as 33 22 11 00 55 44 77 66 88 99 AA BB CC DD EE FF.
The dmidecode tool implements this and decodes the above "wire format"
when SMBIOS version >= 2.6. We moved from SMBIOS version 2.4 to 2.8 when
we started building the SMBIOS entry point inside QEMU, on commit
c97294ec1b9e36887e119589d456557d72ab37b5.
Change smbios_build_type_1_table() to encode the UUID as specified.
To make sure we won't change the guest-visible UUID when upgrading to a
newer QEMU version, keep the old behavior on pc-*-2.1 and older.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2014-10-29 14:26:08 +01:00
|
|
|
if (smbios_uuid_encoded) {
|
|
|
|
uuid->time_low = bswap32(uuid->time_low);
|
|
|
|
uuid->time_mid = bswap16(uuid->time_mid);
|
|
|
|
uuid->time_hi_and_version = bswap16(uuid->time_hi_and_version);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-23 15:42:42 +02:00
|
|
|
static void smbios_build_type_1_table(void)
|
|
|
|
{
|
|
|
|
SMBIOS_BUILD_TABLE_PRE(1, 0x100, true); /* required */
|
|
|
|
|
|
|
|
SMBIOS_TABLE_SET_STR(1, manufacturer_str, type1.manufacturer);
|
|
|
|
SMBIOS_TABLE_SET_STR(1, product_name_str, type1.product);
|
|
|
|
SMBIOS_TABLE_SET_STR(1, version_str, type1.version);
|
|
|
|
SMBIOS_TABLE_SET_STR(1, serial_number_str, type1.serial);
|
|
|
|
if (qemu_uuid_set) {
|
2016-09-21 06:27:22 +02:00
|
|
|
smbios_encode_uuid(&t->uuid, &qemu_uuid);
|
2014-04-23 15:42:42 +02:00
|
|
|
} else {
|
smbios: Encode UUID according to SMBIOS specification
Differently from older versions, SMBIOS version 2.6 is explicit about
the encoding of UUID fields:
> Although RFC 4122 recommends network byte order for all fields, the PC
> industry (including the ACPI, UEFI, and Microsoft specifications) has
> consistently used little-endian byte encoding for the first three fields:
> time_low, time_mid, time_hi_and_version. The same encoding, also known as
> wire format, should also be used for the SMBIOS representation of the UUID.
>
> The UUID {00112233-4455-6677-8899-AABBCCDDEEFF} would thus be represented
> as 33 22 11 00 55 44 77 66 88 99 AA BB CC DD EE FF.
The dmidecode tool implements this and decodes the above "wire format"
when SMBIOS version >= 2.6. We moved from SMBIOS version 2.4 to 2.8 when
we started building the SMBIOS entry point inside QEMU, on commit
c97294ec1b9e36887e119589d456557d72ab37b5.
Change smbios_build_type_1_table() to encode the UUID as specified.
To make sure we won't change the guest-visible UUID when upgrading to a
newer QEMU version, keep the old behavior on pc-*-2.1 and older.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2014-10-29 14:26:08 +01:00
|
|
|
memset(&t->uuid, 0, 16);
|
2014-04-23 15:42:42 +02:00
|
|
|
}
|
|
|
|
t->wake_up_type = 0x06; /* power switch */
|
|
|
|
SMBIOS_TABLE_SET_STR(1, sku_number_str, type1.sku);
|
|
|
|
SMBIOS_TABLE_SET_STR(1, family_str, type1.family);
|
|
|
|
|
|
|
|
SMBIOS_BUILD_TABLE_POST;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void smbios_build_type_2_table(void)
|
|
|
|
{
|
|
|
|
SMBIOS_BUILD_TABLE_PRE(2, 0x200, false); /* optional */
|
|
|
|
|
|
|
|
SMBIOS_TABLE_SET_STR(2, manufacturer_str, type2.manufacturer);
|
|
|
|
SMBIOS_TABLE_SET_STR(2, product_str, type2.product);
|
|
|
|
SMBIOS_TABLE_SET_STR(2, version_str, type2.version);
|
|
|
|
SMBIOS_TABLE_SET_STR(2, serial_number_str, type2.serial);
|
|
|
|
SMBIOS_TABLE_SET_STR(2, asset_tag_number_str, type2.asset);
|
|
|
|
t->feature_flags = 0x01; /* Motherboard */
|
|
|
|
SMBIOS_TABLE_SET_STR(2, location_str, type2.location);
|
2014-05-19 16:09:53 +02:00
|
|
|
t->chassis_handle = cpu_to_le16(0x300); /* Type 3 (System enclosure) */
|
2014-04-23 15:42:42 +02:00
|
|
|
t->board_type = 0x0A; /* Motherboard */
|
|
|
|
t->contained_element_count = 0;
|
|
|
|
|
|
|
|
SMBIOS_BUILD_TABLE_POST;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void smbios_build_type_3_table(void)
|
|
|
|
{
|
|
|
|
SMBIOS_BUILD_TABLE_PRE(3, 0x300, true); /* required */
|
|
|
|
|
|
|
|
SMBIOS_TABLE_SET_STR(3, manufacturer_str, type3.manufacturer);
|
|
|
|
t->type = 0x01; /* Other */
|
|
|
|
SMBIOS_TABLE_SET_STR(3, version_str, type3.version);
|
|
|
|
SMBIOS_TABLE_SET_STR(3, serial_number_str, type3.serial);
|
|
|
|
SMBIOS_TABLE_SET_STR(3, asset_tag_number_str, type3.asset);
|
|
|
|
t->boot_up_state = 0x03; /* Safe */
|
|
|
|
t->power_supply_state = 0x03; /* Safe */
|
|
|
|
t->thermal_state = 0x03; /* Safe */
|
|
|
|
t->security_status = 0x02; /* Unknown */
|
2014-05-19 16:09:53 +02:00
|
|
|
t->oem_defined = cpu_to_le32(0);
|
2014-04-23 15:42:42 +02:00
|
|
|
t->height = 0;
|
|
|
|
t->number_of_power_cords = 0;
|
|
|
|
t->contained_element_count = 0;
|
|
|
|
SMBIOS_TABLE_SET_STR(3, sku_number_str, type3.sku);
|
|
|
|
|
|
|
|
SMBIOS_BUILD_TABLE_POST;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void smbios_build_type_4_table(unsigned instance)
|
|
|
|
{
|
|
|
|
char sock_str[128];
|
|
|
|
|
|
|
|
SMBIOS_BUILD_TABLE_PRE(4, 0x400 + instance, true); /* required */
|
|
|
|
|
|
|
|
snprintf(sock_str, sizeof(sock_str), "%s%2x", type4.sock_pfx, instance);
|
|
|
|
SMBIOS_TABLE_SET_STR(4, socket_designation_str, sock_str);
|
|
|
|
t->processor_type = 0x03; /* CPU */
|
2014-05-19 16:09:53 +02:00
|
|
|
t->processor_family = 0x01; /* Other */
|
2014-04-23 15:42:42 +02:00
|
|
|
SMBIOS_TABLE_SET_STR(4, processor_manufacturer_str, type4.manufacturer);
|
2014-05-19 16:09:53 +02:00
|
|
|
t->processor_id[0] = cpu_to_le32(smbios_cpuid_version);
|
|
|
|
t->processor_id[1] = cpu_to_le32(smbios_cpuid_features);
|
2014-04-23 15:42:42 +02:00
|
|
|
SMBIOS_TABLE_SET_STR(4, processor_version_str, type4.version);
|
|
|
|
t->voltage = 0;
|
2014-05-19 16:09:53 +02:00
|
|
|
t->external_clock = cpu_to_le16(0); /* Unknown */
|
2015-01-07 18:36:34 +01:00
|
|
|
/* SVVP requires max_speed and current_speed to not be unknown. */
|
|
|
|
t->max_speed = cpu_to_le16(2000); /* 2000 MHz */
|
|
|
|
t->current_speed = cpu_to_le16(2000); /* 2000 MHz */
|
2014-04-23 15:42:42 +02:00
|
|
|
t->status = 0x41; /* Socket populated, CPU enabled */
|
|
|
|
t->processor_upgrade = 0x01; /* Other */
|
2014-05-19 16:09:53 +02:00
|
|
|
t->l1_cache_handle = cpu_to_le16(0xFFFF); /* N/A */
|
|
|
|
t->l2_cache_handle = cpu_to_le16(0xFFFF); /* N/A */
|
|
|
|
t->l3_cache_handle = cpu_to_le16(0xFFFF); /* N/A */
|
2014-04-23 15:42:42 +02:00
|
|
|
SMBIOS_TABLE_SET_STR(4, serial_number_str, type4.serial);
|
|
|
|
SMBIOS_TABLE_SET_STR(4, asset_tag_number_str, type4.asset);
|
|
|
|
SMBIOS_TABLE_SET_STR(4, part_number_str, type4.part);
|
|
|
|
t->core_count = t->core_enabled = smp_cores;
|
|
|
|
t->thread_count = smp_threads;
|
2014-05-19 16:09:53 +02:00
|
|
|
t->processor_characteristics = cpu_to_le16(0x02); /* Unknown */
|
|
|
|
t->processor_family2 = cpu_to_le16(0x01); /* Other */
|
2014-04-23 15:42:42 +02:00
|
|
|
|
|
|
|
SMBIOS_BUILD_TABLE_POST;
|
|
|
|
smbios_type4_count++;
|
|
|
|
}
|
|
|
|
|
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>
2017-10-28 22:51:36 +02:00
|
|
|
static void smbios_build_type_11_table(void)
|
|
|
|
{
|
|
|
|
char count_str[128];
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
if (type11.nvalues == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
SMBIOS_BUILD_TABLE_PRE(11, 0xe00, true); /* required */
|
|
|
|
|
|
|
|
snprintf(count_str, sizeof(count_str), "%zu", type11.nvalues);
|
|
|
|
t->count = type11.nvalues;
|
|
|
|
|
|
|
|
for (i = 0; i < type11.nvalues; i++) {
|
|
|
|
SMBIOS_TABLE_SET_STR_LIST(11, type11.values[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
SMBIOS_BUILD_TABLE_POST;
|
|
|
|
}
|
|
|
|
|
2014-04-23 15:42:42 +02:00
|
|
|
#define ONE_KB ((ram_addr_t)1 << 10)
|
|
|
|
#define ONE_MB ((ram_addr_t)1 << 20)
|
|
|
|
#define ONE_GB ((ram_addr_t)1 << 30)
|
|
|
|
|
|
|
|
#define MAX_T16_STD_SZ 0x80000000 /* 2T in Kilobytes */
|
|
|
|
|
|
|
|
static void smbios_build_type_16_table(unsigned dimm_cnt)
|
|
|
|
{
|
2014-11-05 07:19:54 +01:00
|
|
|
uint64_t size_kb;
|
2014-04-23 15:42:42 +02:00
|
|
|
|
|
|
|
SMBIOS_BUILD_TABLE_PRE(16, 0x1000, true); /* required */
|
|
|
|
|
|
|
|
t->location = 0x01; /* Other */
|
|
|
|
t->use = 0x03; /* System memory */
|
|
|
|
t->error_correction = 0x06; /* Multi-bit ECC (for Microsoft, per SeaBIOS) */
|
|
|
|
size_kb = QEMU_ALIGN_UP(ram_size, ONE_KB) / ONE_KB;
|
|
|
|
if (size_kb < MAX_T16_STD_SZ) {
|
2014-05-19 16:09:53 +02:00
|
|
|
t->maximum_capacity = cpu_to_le32(size_kb);
|
|
|
|
t->extended_maximum_capacity = cpu_to_le64(0);
|
2014-04-23 15:42:42 +02:00
|
|
|
} else {
|
2014-05-19 16:09:53 +02:00
|
|
|
t->maximum_capacity = cpu_to_le32(MAX_T16_STD_SZ);
|
|
|
|
t->extended_maximum_capacity = cpu_to_le64(ram_size);
|
2014-04-23 15:42:42 +02:00
|
|
|
}
|
2014-05-19 16:09:53 +02:00
|
|
|
t->memory_error_information_handle = cpu_to_le16(0xFFFE); /* Not provided */
|
|
|
|
t->number_of_memory_devices = cpu_to_le16(dimm_cnt);
|
2014-04-23 15:42:42 +02:00
|
|
|
|
|
|
|
SMBIOS_BUILD_TABLE_POST;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define MAX_T17_STD_SZ 0x7FFF /* (32G - 1M), in Megabytes */
|
|
|
|
#define MAX_T17_EXT_SZ 0x80000000 /* 2P, in Megabytes */
|
|
|
|
|
2014-11-05 07:19:54 +01:00
|
|
|
static void smbios_build_type_17_table(unsigned instance, uint64_t size)
|
2014-04-23 15:42:42 +02:00
|
|
|
{
|
|
|
|
char loc_str[128];
|
2014-11-05 07:19:54 +01:00
|
|
|
uint64_t size_mb;
|
2014-04-23 15:42:42 +02:00
|
|
|
|
|
|
|
SMBIOS_BUILD_TABLE_PRE(17, 0x1100 + instance, true); /* required */
|
|
|
|
|
2014-05-19 16:09:53 +02:00
|
|
|
t->physical_memory_array_handle = cpu_to_le16(0x1000); /* Type 16 above */
|
|
|
|
t->memory_error_information_handle = cpu_to_le16(0xFFFE); /* Not provided */
|
|
|
|
t->total_width = cpu_to_le16(0xFFFF); /* Unknown */
|
|
|
|
t->data_width = cpu_to_le16(0xFFFF); /* Unknown */
|
2014-04-23 15:42:42 +02:00
|
|
|
size_mb = QEMU_ALIGN_UP(size, ONE_MB) / ONE_MB;
|
|
|
|
if (size_mb < MAX_T17_STD_SZ) {
|
2014-05-19 16:09:53 +02:00
|
|
|
t->size = cpu_to_le16(size_mb);
|
|
|
|
t->extended_size = cpu_to_le32(0);
|
2014-04-23 15:42:42 +02:00
|
|
|
} else {
|
|
|
|
assert(size_mb < MAX_T17_EXT_SZ);
|
2014-05-19 16:09:53 +02:00
|
|
|
t->size = cpu_to_le16(MAX_T17_STD_SZ);
|
|
|
|
t->extended_size = cpu_to_le32(size_mb);
|
2014-04-23 15:42:42 +02:00
|
|
|
}
|
|
|
|
t->form_factor = 0x09; /* DIMM */
|
|
|
|
t->device_set = 0; /* Not in a set */
|
|
|
|
snprintf(loc_str, sizeof(loc_str), "%s %d", type17.loc_pfx, instance);
|
|
|
|
SMBIOS_TABLE_SET_STR(17, device_locator_str, loc_str);
|
|
|
|
SMBIOS_TABLE_SET_STR(17, bank_locator_str, type17.bank);
|
|
|
|
t->memory_type = 0x07; /* RAM */
|
2014-05-19 16:09:53 +02:00
|
|
|
t->type_detail = cpu_to_le16(0x02); /* Other */
|
2015-03-11 18:58:01 +01:00
|
|
|
t->speed = cpu_to_le16(type17.speed);
|
2014-04-23 15:42:42 +02:00
|
|
|
SMBIOS_TABLE_SET_STR(17, manufacturer_str, type17.manufacturer);
|
|
|
|
SMBIOS_TABLE_SET_STR(17, serial_number_str, type17.serial);
|
|
|
|
SMBIOS_TABLE_SET_STR(17, asset_tag_number_str, type17.asset);
|
|
|
|
SMBIOS_TABLE_SET_STR(17, part_number_str, type17.part);
|
|
|
|
t->attributes = 0; /* Unknown */
|
2015-03-11 18:58:01 +01:00
|
|
|
t->configured_clock_speed = t->speed; /* reuse value for max speed */
|
2014-05-19 16:09:55 +02:00
|
|
|
t->minimum_voltage = cpu_to_le16(0); /* Unknown */
|
|
|
|
t->maximum_voltage = cpu_to_le16(0); /* Unknown */
|
|
|
|
t->configured_voltage = cpu_to_le16(0); /* Unknown */
|
2014-04-23 15:42:42 +02:00
|
|
|
|
|
|
|
SMBIOS_BUILD_TABLE_POST;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void smbios_build_type_19_table(unsigned instance,
|
2014-11-05 07:19:54 +01:00
|
|
|
uint64_t start, uint64_t size)
|
2014-04-23 15:42:42 +02:00
|
|
|
{
|
2014-11-05 07:19:54 +01:00
|
|
|
uint64_t end, start_kb, end_kb;
|
2014-04-23 15:42:42 +02:00
|
|
|
|
|
|
|
SMBIOS_BUILD_TABLE_PRE(19, 0x1300 + instance, true); /* required */
|
|
|
|
|
|
|
|
end = start + size - 1;
|
|
|
|
assert(end > start);
|
|
|
|
start_kb = start / ONE_KB;
|
|
|
|
end_kb = end / ONE_KB;
|
|
|
|
if (start_kb < UINT32_MAX && end_kb < UINT32_MAX) {
|
2014-05-19 16:09:53 +02:00
|
|
|
t->starting_address = cpu_to_le32(start_kb);
|
|
|
|
t->ending_address = cpu_to_le32(end_kb);
|
|
|
|
t->extended_starting_address =
|
|
|
|
t->extended_ending_address = cpu_to_le64(0);
|
2014-04-23 15:42:42 +02:00
|
|
|
} else {
|
2014-05-19 16:09:53 +02:00
|
|
|
t->starting_address = t->ending_address = cpu_to_le32(UINT32_MAX);
|
|
|
|
t->extended_starting_address = cpu_to_le64(start);
|
|
|
|
t->extended_ending_address = cpu_to_le64(end);
|
2014-04-23 15:42:42 +02:00
|
|
|
}
|
2014-05-19 16:09:53 +02:00
|
|
|
t->memory_array_handle = cpu_to_le16(0x1000); /* Type 16 above */
|
2014-04-23 15:42:42 +02:00
|
|
|
t->partition_width = 1; /* One device per row */
|
|
|
|
|
|
|
|
SMBIOS_BUILD_TABLE_POST;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void smbios_build_type_32_table(void)
|
|
|
|
{
|
|
|
|
SMBIOS_BUILD_TABLE_PRE(32, 0x2000, true); /* required */
|
|
|
|
|
|
|
|
memset(t->reserved, 0, 6);
|
|
|
|
t->boot_status = 0; /* No errors detected */
|
|
|
|
|
|
|
|
SMBIOS_BUILD_TABLE_POST;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void smbios_build_type_127_table(void)
|
|
|
|
{
|
|
|
|
SMBIOS_BUILD_TABLE_PRE(127, 0x7F00, true); /* required */
|
|
|
|
SMBIOS_BUILD_TABLE_POST;
|
|
|
|
}
|
|
|
|
|
|
|
|
void smbios_set_cpuid(uint32_t version, uint32_t features)
|
|
|
|
{
|
|
|
|
smbios_cpuid_version = version;
|
|
|
|
smbios_cpuid_features = features;
|
|
|
|
}
|
|
|
|
|
2014-04-23 15:42:40 +02:00
|
|
|
#define SMBIOS_SET_DEFAULT(field, value) \
|
|
|
|
if (!field) { \
|
|
|
|
field = value; \
|
|
|
|
}
|
|
|
|
|
|
|
|
void smbios_set_defaults(const char *manufacturer, const char *product,
|
smbios: Encode UUID according to SMBIOS specification
Differently from older versions, SMBIOS version 2.6 is explicit about
the encoding of UUID fields:
> Although RFC 4122 recommends network byte order for all fields, the PC
> industry (including the ACPI, UEFI, and Microsoft specifications) has
> consistently used little-endian byte encoding for the first three fields:
> time_low, time_mid, time_hi_and_version. The same encoding, also known as
> wire format, should also be used for the SMBIOS representation of the UUID.
>
> The UUID {00112233-4455-6677-8899-AABBCCDDEEFF} would thus be represented
> as 33 22 11 00 55 44 77 66 88 99 AA BB CC DD EE FF.
The dmidecode tool implements this and decodes the above "wire format"
when SMBIOS version >= 2.6. We moved from SMBIOS version 2.4 to 2.8 when
we started building the SMBIOS entry point inside QEMU, on commit
c97294ec1b9e36887e119589d456557d72ab37b5.
Change smbios_build_type_1_table() to encode the UUID as specified.
To make sure we won't change the guest-visible UUID when upgrading to a
newer QEMU version, keep the old behavior on pc-*-2.1 and older.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2014-10-29 14:26:08 +01:00
|
|
|
const char *version, bool legacy_mode,
|
2015-09-07 11:39:28 +02:00
|
|
|
bool uuid_encoded, SmbiosEntryPointType ep_type)
|
2014-04-23 15:42:40 +02:00
|
|
|
{
|
2014-04-23 15:42:42 +02:00
|
|
|
smbios_have_defaults = true;
|
|
|
|
smbios_legacy = legacy_mode;
|
smbios: Encode UUID according to SMBIOS specification
Differently from older versions, SMBIOS version 2.6 is explicit about
the encoding of UUID fields:
> Although RFC 4122 recommends network byte order for all fields, the PC
> industry (including the ACPI, UEFI, and Microsoft specifications) has
> consistently used little-endian byte encoding for the first three fields:
> time_low, time_mid, time_hi_and_version. The same encoding, also known as
> wire format, should also be used for the SMBIOS representation of the UUID.
>
> The UUID {00112233-4455-6677-8899-AABBCCDDEEFF} would thus be represented
> as 33 22 11 00 55 44 77 66 88 99 AA BB CC DD EE FF.
The dmidecode tool implements this and decodes the above "wire format"
when SMBIOS version >= 2.6. We moved from SMBIOS version 2.4 to 2.8 when
we started building the SMBIOS entry point inside QEMU, on commit
c97294ec1b9e36887e119589d456557d72ab37b5.
Change smbios_build_type_1_table() to encode the UUID as specified.
To make sure we won't change the guest-visible UUID when upgrading to a
newer QEMU version, keep the old behavior on pc-*-2.1 and older.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2014-10-29 14:26:08 +01:00
|
|
|
smbios_uuid_encoded = uuid_encoded;
|
2015-09-07 11:39:28 +02:00
|
|
|
smbios_ep_type = ep_type;
|
2014-04-23 15:42:42 +02:00
|
|
|
|
|
|
|
/* drop unwanted version of command-line file blob(s) */
|
|
|
|
if (smbios_legacy) {
|
2014-06-04 18:00:28 +02:00
|
|
|
g_free(smbios_tables);
|
2014-04-23 15:42:42 +02:00
|
|
|
/* in legacy mode, also complain if fields were given for types > 1 */
|
|
|
|
if (find_next_bit(have_fields_bitmap,
|
|
|
|
SMBIOS_MAX_TYPE+1, 2) < SMBIOS_MAX_TYPE+1) {
|
|
|
|
error_report("can't process fields for smbios "
|
|
|
|
"types > 1 on machine versions < 2.1!");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
} else {
|
2014-06-04 18:00:28 +02:00
|
|
|
g_free(smbios_entries);
|
2014-04-23 15:42:42 +02:00
|
|
|
}
|
|
|
|
|
2014-04-23 15:42:40 +02:00
|
|
|
SMBIOS_SET_DEFAULT(type1.manufacturer, manufacturer);
|
|
|
|
SMBIOS_SET_DEFAULT(type1.product, product);
|
|
|
|
SMBIOS_SET_DEFAULT(type1.version, version);
|
2014-04-23 15:42:42 +02:00
|
|
|
SMBIOS_SET_DEFAULT(type2.manufacturer, manufacturer);
|
|
|
|
SMBIOS_SET_DEFAULT(type2.product, product);
|
|
|
|
SMBIOS_SET_DEFAULT(type2.version, version);
|
|
|
|
SMBIOS_SET_DEFAULT(type3.manufacturer, manufacturer);
|
|
|
|
SMBIOS_SET_DEFAULT(type3.version, version);
|
|
|
|
SMBIOS_SET_DEFAULT(type4.sock_pfx, "CPU");
|
|
|
|
SMBIOS_SET_DEFAULT(type4.manufacturer, manufacturer);
|
|
|
|
SMBIOS_SET_DEFAULT(type4.version, version);
|
|
|
|
SMBIOS_SET_DEFAULT(type17.loc_pfx, "DIMM");
|
|
|
|
SMBIOS_SET_DEFAULT(type17.manufacturer, manufacturer);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void smbios_entry_point_setup(void)
|
|
|
|
{
|
2015-09-07 11:39:28 +02:00
|
|
|
switch (smbios_ep_type) {
|
|
|
|
case SMBIOS_ENTRY_POINT_21:
|
|
|
|
memcpy(ep.ep21.anchor_string, "_SM_", 4);
|
|
|
|
memcpy(ep.ep21.intermediate_anchor_string, "_DMI_", 5);
|
|
|
|
ep.ep21.length = sizeof(struct smbios_21_entry_point);
|
|
|
|
ep.ep21.entry_point_revision = 0; /* formatted_area reserved */
|
|
|
|
memset(ep.ep21.formatted_area, 0, 5);
|
|
|
|
|
|
|
|
/* compliant with smbios spec v2.8 */
|
|
|
|
ep.ep21.smbios_major_version = 2;
|
|
|
|
ep.ep21.smbios_minor_version = 8;
|
|
|
|
ep.ep21.smbios_bcd_revision = 0x28;
|
|
|
|
|
|
|
|
/* set during table construction, but BIOS may override: */
|
|
|
|
ep.ep21.structure_table_length = cpu_to_le16(smbios_tables_len);
|
|
|
|
ep.ep21.max_structure_size = cpu_to_le16(smbios_table_max);
|
|
|
|
ep.ep21.number_of_structures = cpu_to_le16(smbios_table_cnt);
|
|
|
|
|
|
|
|
/* BIOS must recalculate */
|
|
|
|
ep.ep21.checksum = 0;
|
|
|
|
ep.ep21.intermediate_checksum = 0;
|
|
|
|
ep.ep21.structure_table_address = cpu_to_le32(0);
|
|
|
|
|
|
|
|
break;
|
|
|
|
case SMBIOS_ENTRY_POINT_30:
|
|
|
|
memcpy(ep.ep30.anchor_string, "_SM3_", 5);
|
|
|
|
ep.ep30.length = sizeof(struct smbios_30_entry_point);
|
|
|
|
ep.ep30.entry_point_revision = 1;
|
|
|
|
ep.ep30.reserved = 0;
|
|
|
|
|
|
|
|
/* compliant with smbios spec 3.0 */
|
|
|
|
ep.ep30.smbios_major_version = 3;
|
|
|
|
ep.ep30.smbios_minor_version = 0;
|
|
|
|
ep.ep30.smbios_doc_rev = 0;
|
|
|
|
|
|
|
|
/* set during table construct, but BIOS might override */
|
|
|
|
ep.ep30.structure_table_max_size = cpu_to_le32(smbios_tables_len);
|
|
|
|
|
|
|
|
/* BIOS must recalculate */
|
|
|
|
ep.ep30.checksum = 0;
|
|
|
|
ep.ep30.structure_table_address = cpu_to_le64(0);
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
break;
|
|
|
|
}
|
2014-04-23 15:42:42 +02:00
|
|
|
}
|
|
|
|
|
2015-08-12 04:08:19 +02:00
|
|
|
void smbios_get_tables(const struct smbios_phys_mem_area *mem_array,
|
|
|
|
const unsigned int mem_array_size,
|
|
|
|
uint8_t **tables, size_t *tables_len,
|
2014-04-23 15:42:42 +02:00
|
|
|
uint8_t **anchor, size_t *anchor_len)
|
|
|
|
{
|
2015-08-12 04:08:19 +02:00
|
|
|
unsigned i, dimm_cnt;
|
2014-04-23 15:42:42 +02:00
|
|
|
|
|
|
|
if (smbios_legacy) {
|
|
|
|
*tables = *anchor = NULL;
|
|
|
|
*tables_len = *anchor_len = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!smbios_immutable) {
|
|
|
|
smbios_build_type_0_table();
|
|
|
|
smbios_build_type_1_table();
|
|
|
|
smbios_build_type_2_table();
|
|
|
|
smbios_build_type_3_table();
|
|
|
|
|
2014-09-30 03:21:45 +02:00
|
|
|
smbios_smp_sockets = DIV_ROUND_UP(smp_cpus, smp_cores * smp_threads);
|
2014-04-23 15:42:42 +02:00
|
|
|
assert(smbios_smp_sockets >= 1);
|
|
|
|
|
|
|
|
for (i = 0; i < smbios_smp_sockets; i++) {
|
|
|
|
smbios_build_type_4_table(i);
|
|
|
|
}
|
|
|
|
|
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>
2017-10-28 22:51:36 +02:00
|
|
|
smbios_build_type_11_table();
|
|
|
|
|
2014-04-23 15:42:42 +02:00
|
|
|
#define MAX_DIMM_SZ (16ll * ONE_GB)
|
2015-01-07 18:36:33 +01:00
|
|
|
#define GET_DIMM_SZ ((i < dimm_cnt - 1) ? MAX_DIMM_SZ \
|
|
|
|
: ((ram_size - 1) % MAX_DIMM_SZ) + 1)
|
2014-04-23 15:42:42 +02:00
|
|
|
|
|
|
|
dimm_cnt = QEMU_ALIGN_UP(ram_size, MAX_DIMM_SZ) / MAX_DIMM_SZ;
|
|
|
|
|
|
|
|
smbios_build_type_16_table(dimm_cnt);
|
|
|
|
|
|
|
|
for (i = 0; i < dimm_cnt; i++) {
|
|
|
|
smbios_build_type_17_table(i, GET_DIMM_SZ);
|
|
|
|
}
|
|
|
|
|
2015-08-12 04:08:19 +02:00
|
|
|
for (i = 0; i < mem_array_size; i++) {
|
|
|
|
smbios_build_type_19_table(i, mem_array[i].address,
|
|
|
|
mem_array[i].length);
|
2014-04-23 15:42:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
smbios_build_type_32_table();
|
2016-06-10 11:15:41 +02:00
|
|
|
smbios_build_type_38_table();
|
2014-04-23 15:42:42 +02:00
|
|
|
smbios_build_type_127_table();
|
|
|
|
|
|
|
|
smbios_validate_table();
|
|
|
|
smbios_entry_point_setup();
|
|
|
|
smbios_immutable = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* return tables blob and entry point (anchor), and their sizes */
|
|
|
|
*tables = smbios_tables;
|
|
|
|
*tables_len = smbios_tables_len;
|
|
|
|
*anchor = (uint8_t *)&ep;
|
2015-09-07 11:39:28 +02:00
|
|
|
|
|
|
|
/* calculate length based on anchor string */
|
|
|
|
if (!strncmp((char *)&ep, "_SM_", 4)) {
|
|
|
|
*anchor_len = sizeof(struct smbios_21_entry_point);
|
|
|
|
} else if (!strncmp((char *)&ep, "_SM3_", 5)) {
|
|
|
|
*anchor_len = sizeof(struct smbios_30_entry_point);
|
|
|
|
} else {
|
|
|
|
abort();
|
|
|
|
}
|
2014-04-23 15:42:40 +02:00
|
|
|
}
|
|
|
|
|
smbios: Make multiple -smbios type= accumulate sanely
Currently, -smbios type=T,NAME=VAL,... adds one field (T,NAME) with
value VAL to fw_cfg for each unique NAME. If NAME occurs multiple
times, the last one's VAL is used (before the QemuOpts conversion, the
first one was used).
Multiple -smbios can add multiple fields with the same (T, NAME).
SeaBIOS reads all of them from fw_cfg, but uses only the first field
(T, NAME). The others are ignored.
"First one wins, subsequent ones get ignored silently" isn't nice. We
commonly let the last option win. Useful, because it lets you
-readconfig first, then selectively override with command line
options.
Clean up -smbios to work the common way. Accumulate the settings,
with later ones overwriting earlier ones. Put the result into fw_cfg
(no more useless duplicates).
Bonus cleanup: qemu_uuid_parse() no longer sets SMBIOS system uuid by
side effect.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2013-08-16 15:18:31 +02:00
|
|
|
static void save_opt(const char **dest, QemuOpts *opts, const char *name)
|
|
|
|
{
|
|
|
|
const char *val = qemu_opt_get(opts, name);
|
|
|
|
|
|
|
|
if (val) {
|
|
|
|
*dest = val;
|
2013-08-16 15:18:29 +02:00
|
|
|
}
|
qemu: Add support for SMBIOS command line otions (Alex Williamson)
Create a new -smbios option (x86-only) to allow binary SMBIOS entries
to be passed through to the BIOS or modify the default values of
individual fields of type 0 and 1 entries on the command line.
Binary SMBIOS entries can be generated as follows:
dmidecode -t 1 -u | grep $'^\t\t[^"]' | xargs -n1 | \
perl -lne 'printf "%c", hex($_)' > smbios_type_1.bin
These can then be passed to the BIOS using this switch:
-smbios file=smbios_type_1.bin
Command line generation supports the following syntax:
-smbios type=0[,vendor=str][,version=str][,date=str][,release=%d.%d]
-smbios type=1[,manufacturer=str][,product=str][,version=str][,serial=str]
[,uuid=$(uuidgen)][,sku=str][,family=str]
For instance, to add a serial number to the type 1 table:
-smbios type=1,serial=0123456789
Interface is extensible to support more fields/tables as needed.
aliguori: remove texi formatting from help output
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7163 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17 20:59:56 +02:00
|
|
|
}
|
|
|
|
|
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>
2017-10-28 22:51:36 +02:00
|
|
|
|
|
|
|
struct opt_list {
|
|
|
|
const char *name;
|
|
|
|
size_t *ndest;
|
|
|
|
const char ***dest;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int save_opt_one(void *opaque,
|
|
|
|
const char *name, const char *value,
|
|
|
|
Error **errp)
|
|
|
|
{
|
|
|
|
struct opt_list *opt = opaque;
|
|
|
|
|
|
|
|
if (!g_str_equal(name, opt->name)) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
*opt->dest = g_renew(const char *, *opt->dest, (*opt->ndest) + 1);
|
|
|
|
(*opt->dest)[*opt->ndest] = value;
|
|
|
|
(*opt->ndest)++;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void save_opt_list(size_t *ndest, const char ***dest,
|
|
|
|
QemuOpts *opts, const char *name)
|
|
|
|
{
|
|
|
|
struct opt_list opt = {
|
|
|
|
name, ndest, dest,
|
|
|
|
};
|
|
|
|
qemu_opt_foreach(opts, save_opt_one, &opt, NULL);
|
|
|
|
}
|
|
|
|
|
2016-12-22 16:18:28 +01:00
|
|
|
void smbios_entry_add(QemuOpts *opts, Error **errp)
|
qemu: Add support for SMBIOS command line otions (Alex Williamson)
Create a new -smbios option (x86-only) to allow binary SMBIOS entries
to be passed through to the BIOS or modify the default values of
individual fields of type 0 and 1 entries on the command line.
Binary SMBIOS entries can be generated as follows:
dmidecode -t 1 -u | grep $'^\t\t[^"]' | xargs -n1 | \
perl -lne 'printf "%c", hex($_)' > smbios_type_1.bin
These can then be passed to the BIOS using this switch:
-smbios file=smbios_type_1.bin
Command line generation supports the following syntax:
-smbios type=0[,vendor=str][,version=str][,date=str][,release=%d.%d]
-smbios type=1[,manufacturer=str][,product=str][,version=str][,serial=str]
[,uuid=$(uuidgen)][,sku=str][,family=str]
For instance, to add a serial number to the type 1 table:
-smbios type=1,serial=0123456789
Interface is extensible to support more fields/tables as needed.
aliguori: remove texi formatting from help output
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7163 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17 20:59:56 +02:00
|
|
|
{
|
2013-08-16 15:18:29 +02:00
|
|
|
const char *val;
|
qemu: Add support for SMBIOS command line otions (Alex Williamson)
Create a new -smbios option (x86-only) to allow binary SMBIOS entries
to be passed through to the BIOS or modify the default values of
individual fields of type 0 and 1 entries on the command line.
Binary SMBIOS entries can be generated as follows:
dmidecode -t 1 -u | grep $'^\t\t[^"]' | xargs -n1 | \
perl -lne 'printf "%c", hex($_)' > smbios_type_1.bin
These can then be passed to the BIOS using this switch:
-smbios file=smbios_type_1.bin
Command line generation supports the following syntax:
-smbios type=0[,vendor=str][,version=str][,date=str][,release=%d.%d]
-smbios type=1[,manufacturer=str][,product=str][,version=str][,serial=str]
[,uuid=$(uuidgen)][,sku=str][,family=str]
For instance, to add a serial number to the type 1 table:
-smbios type=1,serial=0123456789
Interface is extensible to support more fields/tables as needed.
aliguori: remove texi formatting from help output
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7163 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17 20:59:56 +02:00
|
|
|
|
smbios: Make multiple -smbios type= accumulate sanely
Currently, -smbios type=T,NAME=VAL,... adds one field (T,NAME) with
value VAL to fw_cfg for each unique NAME. If NAME occurs multiple
times, the last one's VAL is used (before the QemuOpts conversion, the
first one was used).
Multiple -smbios can add multiple fields with the same (T, NAME).
SeaBIOS reads all of them from fw_cfg, but uses only the first field
(T, NAME). The others are ignored.
"First one wins, subsequent ones get ignored silently" isn't nice. We
commonly let the last option win. Useful, because it lets you
-readconfig first, then selectively override with command line
options.
Clean up -smbios to work the common way. Accumulate the settings,
with later ones overwriting earlier ones. Put the result into fw_cfg
(no more useless duplicates).
Bonus cleanup: qemu_uuid_parse() no longer sets SMBIOS system uuid by
side effect.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2013-08-16 15:18:31 +02:00
|
|
|
assert(!smbios_immutable);
|
2014-04-23 15:42:42 +02:00
|
|
|
|
2013-08-16 15:18:29 +02:00
|
|
|
val = qemu_opt_get(opts, "file");
|
|
|
|
if (val) {
|
qemu: Add support for SMBIOS command line otions (Alex Williamson)
Create a new -smbios option (x86-only) to allow binary SMBIOS entries
to be passed through to the BIOS or modify the default values of
individual fields of type 0 and 1 entries on the command line.
Binary SMBIOS entries can be generated as follows:
dmidecode -t 1 -u | grep $'^\t\t[^"]' | xargs -n1 | \
perl -lne 'printf "%c", hex($_)' > smbios_type_1.bin
These can then be passed to the BIOS using this switch:
-smbios file=smbios_type_1.bin
Command line generation supports the following syntax:
-smbios type=0[,vendor=str][,version=str][,date=str][,release=%d.%d]
-smbios type=1[,manufacturer=str][,product=str][,version=str][,serial=str]
[,uuid=$(uuidgen)][,sku=str][,family=str]
For instance, to add a serial number to the type 1 table:
-smbios type=1,serial=0123456789
Interface is extensible to support more fields/tables as needed.
aliguori: remove texi formatting from help output
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7163 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17 20:59:56 +02:00
|
|
|
struct smbios_structure_header *header;
|
2013-08-16 15:18:29 +02:00
|
|
|
int size;
|
2014-04-23 15:42:42 +02:00
|
|
|
struct smbios_table *table; /* legacy mode only */
|
2013-08-16 15:18:29 +02:00
|
|
|
|
2015-09-11 15:04:45 +02:00
|
|
|
qemu_opts_validate(opts, qemu_smbios_file_opts, &error_fatal);
|
qemu: Add support for SMBIOS command line otions (Alex Williamson)
Create a new -smbios option (x86-only) to allow binary SMBIOS entries
to be passed through to the BIOS or modify the default values of
individual fields of type 0 and 1 entries on the command line.
Binary SMBIOS entries can be generated as follows:
dmidecode -t 1 -u | grep $'^\t\t[^"]' | xargs -n1 | \
perl -lne 'printf "%c", hex($_)' > smbios_type_1.bin
These can then be passed to the BIOS using this switch:
-smbios file=smbios_type_1.bin
Command line generation supports the following syntax:
-smbios type=0[,vendor=str][,version=str][,date=str][,release=%d.%d]
-smbios type=1[,manufacturer=str][,product=str][,version=str][,serial=str]
[,uuid=$(uuidgen)][,sku=str][,family=str]
For instance, to add a serial number to the type 1 table:
-smbios type=1,serial=0123456789
Interface is extensible to support more fields/tables as needed.
aliguori: remove texi formatting from help output
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7163 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17 20:59:56 +02:00
|
|
|
|
2013-08-16 15:18:29 +02:00
|
|
|
size = get_image_size(val);
|
2009-07-31 19:49:14 +02:00
|
|
|
if (size == -1 || size < sizeof(struct smbios_structure_header)) {
|
2013-08-16 15:18:29 +02:00
|
|
|
error_report("Cannot read SMBIOS file %s", val);
|
qemu: Add support for SMBIOS command line otions (Alex Williamson)
Create a new -smbios option (x86-only) to allow binary SMBIOS entries
to be passed through to the BIOS or modify the default values of
individual fields of type 0 and 1 entries on the command line.
Binary SMBIOS entries can be generated as follows:
dmidecode -t 1 -u | grep $'^\t\t[^"]' | xargs -n1 | \
perl -lne 'printf "%c", hex($_)' > smbios_type_1.bin
These can then be passed to the BIOS using this switch:
-smbios file=smbios_type_1.bin
Command line generation supports the following syntax:
-smbios type=0[,vendor=str][,version=str][,date=str][,release=%d.%d]
-smbios type=1[,manufacturer=str][,product=str][,version=str][,serial=str]
[,uuid=$(uuidgen)][,sku=str][,family=str]
For instance, to add a serial number to the type 1 table:
-smbios type=1,serial=0123456789
Interface is extensible to support more fields/tables as needed.
aliguori: remove texi formatting from help output
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7163 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17 20:59:56 +02:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2014-04-23 15:42:42 +02:00
|
|
|
/*
|
|
|
|
* NOTE: standard double '\0' terminator expected, per smbios spec.
|
|
|
|
* (except in legacy mode, where the second '\0' is implicit and
|
|
|
|
* will be inserted by the BIOS).
|
|
|
|
*/
|
|
|
|
smbios_tables = g_realloc(smbios_tables, smbios_tables_len + size);
|
|
|
|
header = (struct smbios_structure_header *)(smbios_tables +
|
|
|
|
smbios_tables_len);
|
qemu: Add support for SMBIOS command line otions (Alex Williamson)
Create a new -smbios option (x86-only) to allow binary SMBIOS entries
to be passed through to the BIOS or modify the default values of
individual fields of type 0 and 1 entries on the command line.
Binary SMBIOS entries can be generated as follows:
dmidecode -t 1 -u | grep $'^\t\t[^"]' | xargs -n1 | \
perl -lne 'printf "%c", hex($_)' > smbios_type_1.bin
These can then be passed to the BIOS using this switch:
-smbios file=smbios_type_1.bin
Command line generation supports the following syntax:
-smbios type=0[,vendor=str][,version=str][,date=str][,release=%d.%d]
-smbios type=1[,manufacturer=str][,product=str][,version=str][,serial=str]
[,uuid=$(uuidgen)][,sku=str][,family=str]
For instance, to add a serial number to the type 1 table:
-smbios type=1,serial=0123456789
Interface is extensible to support more fields/tables as needed.
aliguori: remove texi formatting from help output
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7163 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17 20:59:56 +02:00
|
|
|
|
2014-04-23 15:42:42 +02:00
|
|
|
if (load_image(val, (uint8_t *)header) != size) {
|
2013-08-16 15:18:29 +02:00
|
|
|
error_report("Failed to load SMBIOS file %s", val);
|
qemu: Add support for SMBIOS command line otions (Alex Williamson)
Create a new -smbios option (x86-only) to allow binary SMBIOS entries
to be passed through to the BIOS or modify the default values of
individual fields of type 0 and 1 entries on the command line.
Binary SMBIOS entries can be generated as follows:
dmidecode -t 1 -u | grep $'^\t\t[^"]' | xargs -n1 | \
perl -lne 'printf "%c", hex($_)' > smbios_type_1.bin
These can then be passed to the BIOS using this switch:
-smbios file=smbios_type_1.bin
Command line generation supports the following syntax:
-smbios type=0[,vendor=str][,version=str][,date=str][,release=%d.%d]
-smbios type=1[,manufacturer=str][,product=str][,version=str][,serial=str]
[,uuid=$(uuidgen)][,sku=str][,family=str]
For instance, to add a serial number to the type 1 table:
-smbios type=1,serial=0123456789
Interface is extensible to support more fields/tables as needed.
aliguori: remove texi formatting from help output
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7163 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17 20:59:56 +02:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2014-04-23 15:42:41 +02:00
|
|
|
if (test_bit(header->type, have_fields_bitmap)) {
|
|
|
|
error_report("can't load type %d struct, fields already specified!",
|
|
|
|
header->type);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
set_bit(header->type, have_binfile_bitmap);
|
|
|
|
|
2009-07-31 19:49:14 +02:00
|
|
|
if (header->type == 4) {
|
|
|
|
smbios_type4_count++;
|
|
|
|
}
|
qemu: Add support for SMBIOS command line otions (Alex Williamson)
Create a new -smbios option (x86-only) to allow binary SMBIOS entries
to be passed through to the BIOS or modify the default values of
individual fields of type 0 and 1 entries on the command line.
Binary SMBIOS entries can be generated as follows:
dmidecode -t 1 -u | grep $'^\t\t[^"]' | xargs -n1 | \
perl -lne 'printf "%c", hex($_)' > smbios_type_1.bin
These can then be passed to the BIOS using this switch:
-smbios file=smbios_type_1.bin
Command line generation supports the following syntax:
-smbios type=0[,vendor=str][,version=str][,date=str][,release=%d.%d]
-smbios type=1[,manufacturer=str][,product=str][,version=str][,serial=str]
[,uuid=$(uuidgen)][,sku=str][,family=str]
For instance, to add a serial number to the type 1 table:
-smbios type=1,serial=0123456789
Interface is extensible to support more fields/tables as needed.
aliguori: remove texi formatting from help output
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7163 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17 20:59:56 +02:00
|
|
|
|
2014-04-23 15:42:42 +02:00
|
|
|
smbios_tables_len += size;
|
|
|
|
if (size > smbios_table_max) {
|
|
|
|
smbios_table_max = size;
|
|
|
|
}
|
|
|
|
smbios_table_cnt++;
|
|
|
|
|
|
|
|
/* add a copy of the newly loaded blob to legacy smbios_entries */
|
|
|
|
/* NOTE: This code runs before smbios_set_defaults(), so we don't
|
|
|
|
* yet know which mode (legacy vs. aggregate-table) will be
|
|
|
|
* required. We therefore add the binary blob to both legacy
|
|
|
|
* (smbios_entries) and aggregate (smbios_tables) tables, and
|
|
|
|
* delete the one we don't need from smbios_set_defaults(),
|
|
|
|
* once we know which machine version has been requested.
|
|
|
|
*/
|
|
|
|
if (!smbios_entries) {
|
|
|
|
smbios_entries_len = sizeof(uint16_t);
|
|
|
|
smbios_entries = g_malloc0(smbios_entries_len);
|
|
|
|
}
|
|
|
|
smbios_entries = g_realloc(smbios_entries, smbios_entries_len +
|
|
|
|
size + sizeof(*table));
|
|
|
|
table = (struct smbios_table *)(smbios_entries + smbios_entries_len);
|
|
|
|
table->header.type = SMBIOS_TABLE_ENTRY;
|
|
|
|
table->header.length = cpu_to_le16(sizeof(*table) + size);
|
|
|
|
memcpy(table->data, header, size);
|
qemu: Add support for SMBIOS command line otions (Alex Williamson)
Create a new -smbios option (x86-only) to allow binary SMBIOS entries
to be passed through to the BIOS or modify the default values of
individual fields of type 0 and 1 entries on the command line.
Binary SMBIOS entries can be generated as follows:
dmidecode -t 1 -u | grep $'^\t\t[^"]' | xargs -n1 | \
perl -lne 'printf "%c", hex($_)' > smbios_type_1.bin
These can then be passed to the BIOS using this switch:
-smbios file=smbios_type_1.bin
Command line generation supports the following syntax:
-smbios type=0[,vendor=str][,version=str][,date=str][,release=%d.%d]
-smbios type=1[,manufacturer=str][,product=str][,version=str][,serial=str]
[,uuid=$(uuidgen)][,sku=str][,family=str]
For instance, to add a serial number to the type 1 table:
-smbios type=1,serial=0123456789
Interface is extensible to support more fields/tables as needed.
aliguori: remove texi formatting from help output
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7163 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17 20:59:56 +02:00
|
|
|
smbios_entries_len += sizeof(*table) + size;
|
|
|
|
(*(uint16_t *)smbios_entries) =
|
|
|
|
cpu_to_le16(le16_to_cpu(*(uint16_t *)smbios_entries) + 1);
|
2014-04-23 15:42:42 +02:00
|
|
|
/* end: add a copy of the newly loaded blob to legacy smbios_entries */
|
|
|
|
|
2013-08-16 15:18:28 +02:00
|
|
|
return;
|
qemu: Add support for SMBIOS command line otions (Alex Williamson)
Create a new -smbios option (x86-only) to allow binary SMBIOS entries
to be passed through to the BIOS or modify the default values of
individual fields of type 0 and 1 entries on the command line.
Binary SMBIOS entries can be generated as follows:
dmidecode -t 1 -u | grep $'^\t\t[^"]' | xargs -n1 | \
perl -lne 'printf "%c", hex($_)' > smbios_type_1.bin
These can then be passed to the BIOS using this switch:
-smbios file=smbios_type_1.bin
Command line generation supports the following syntax:
-smbios type=0[,vendor=str][,version=str][,date=str][,release=%d.%d]
-smbios type=1[,manufacturer=str][,product=str][,version=str][,serial=str]
[,uuid=$(uuidgen)][,sku=str][,family=str]
For instance, to add a serial number to the type 1 table:
-smbios type=1,serial=0123456789
Interface is extensible to support more fields/tables as needed.
aliguori: remove texi formatting from help output
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7163 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17 20:59:56 +02:00
|
|
|
}
|
|
|
|
|
2013-08-16 15:18:29 +02:00
|
|
|
val = qemu_opt_get(opts, "type");
|
|
|
|
if (val) {
|
|
|
|
unsigned long type = strtoul(val, NULL, 0);
|
|
|
|
|
2014-04-23 15:42:41 +02:00
|
|
|
if (type > SMBIOS_MAX_TYPE) {
|
|
|
|
error_report("out of range!");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (test_bit(type, have_binfile_bitmap)) {
|
|
|
|
error_report("can't add fields, binary file already loaded!");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
set_bit(type, have_fields_bitmap);
|
smbios: Make multiple -smbios type= accumulate sanely
Currently, -smbios type=T,NAME=VAL,... adds one field (T,NAME) with
value VAL to fw_cfg for each unique NAME. If NAME occurs multiple
times, the last one's VAL is used (before the QemuOpts conversion, the
first one was used).
Multiple -smbios can add multiple fields with the same (T, NAME).
SeaBIOS reads all of them from fw_cfg, but uses only the first field
(T, NAME). The others are ignored.
"First one wins, subsequent ones get ignored silently" isn't nice. We
commonly let the last option win. Useful, because it lets you
-readconfig first, then selectively override with command line
options.
Clean up -smbios to work the common way. Accumulate the settings,
with later ones overwriting earlier ones. Put the result into fw_cfg
(no more useless duplicates).
Bonus cleanup: qemu_uuid_parse() no longer sets SMBIOS system uuid by
side effect.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2013-08-16 15:18:31 +02:00
|
|
|
|
qemu: Add support for SMBIOS command line otions (Alex Williamson)
Create a new -smbios option (x86-only) to allow binary SMBIOS entries
to be passed through to the BIOS or modify the default values of
individual fields of type 0 and 1 entries on the command line.
Binary SMBIOS entries can be generated as follows:
dmidecode -t 1 -u | grep $'^\t\t[^"]' | xargs -n1 | \
perl -lne 'printf "%c", hex($_)' > smbios_type_1.bin
These can then be passed to the BIOS using this switch:
-smbios file=smbios_type_1.bin
Command line generation supports the following syntax:
-smbios type=0[,vendor=str][,version=str][,date=str][,release=%d.%d]
-smbios type=1[,manufacturer=str][,product=str][,version=str][,serial=str]
[,uuid=$(uuidgen)][,sku=str][,family=str]
For instance, to add a serial number to the type 1 table:
-smbios type=1,serial=0123456789
Interface is extensible to support more fields/tables as needed.
aliguori: remove texi formatting from help output
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7163 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17 20:59:56 +02:00
|
|
|
switch (type) {
|
|
|
|
case 0:
|
2015-09-11 15:04:45 +02:00
|
|
|
qemu_opts_validate(opts, qemu_smbios_type0_opts, &error_fatal);
|
smbios: Make multiple -smbios type= accumulate sanely
Currently, -smbios type=T,NAME=VAL,... adds one field (T,NAME) with
value VAL to fw_cfg for each unique NAME. If NAME occurs multiple
times, the last one's VAL is used (before the QemuOpts conversion, the
first one was used).
Multiple -smbios can add multiple fields with the same (T, NAME).
SeaBIOS reads all of them from fw_cfg, but uses only the first field
(T, NAME). The others are ignored.
"First one wins, subsequent ones get ignored silently" isn't nice. We
commonly let the last option win. Useful, because it lets you
-readconfig first, then selectively override with command line
options.
Clean up -smbios to work the common way. Accumulate the settings,
with later ones overwriting earlier ones. Put the result into fw_cfg
(no more useless duplicates).
Bonus cleanup: qemu_uuid_parse() no longer sets SMBIOS system uuid by
side effect.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2013-08-16 15:18:31 +02:00
|
|
|
save_opt(&type0.vendor, opts, "vendor");
|
|
|
|
save_opt(&type0.version, opts, "version");
|
|
|
|
save_opt(&type0.date, opts, "date");
|
2014-05-19 16:09:54 +02:00
|
|
|
type0.uefi = qemu_opt_get_bool(opts, "uefi", false);
|
smbios: Make multiple -smbios type= accumulate sanely
Currently, -smbios type=T,NAME=VAL,... adds one field (T,NAME) with
value VAL to fw_cfg for each unique NAME. If NAME occurs multiple
times, the last one's VAL is used (before the QemuOpts conversion, the
first one was used).
Multiple -smbios can add multiple fields with the same (T, NAME).
SeaBIOS reads all of them from fw_cfg, but uses only the first field
(T, NAME). The others are ignored.
"First one wins, subsequent ones get ignored silently" isn't nice. We
commonly let the last option win. Useful, because it lets you
-readconfig first, then selectively override with command line
options.
Clean up -smbios to work the common way. Accumulate the settings,
with later ones overwriting earlier ones. Put the result into fw_cfg
(no more useless duplicates).
Bonus cleanup: qemu_uuid_parse() no longer sets SMBIOS system uuid by
side effect.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2013-08-16 15:18:31 +02:00
|
|
|
|
|
|
|
val = qemu_opt_get(opts, "release");
|
|
|
|
if (val) {
|
|
|
|
if (sscanf(val, "%hhu.%hhu", &type0.major, &type0.minor) != 2) {
|
|
|
|
error_report("Invalid release");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
type0.have_major_minor = true;
|
|
|
|
}
|
2013-08-16 15:18:28 +02:00
|
|
|
return;
|
qemu: Add support for SMBIOS command line otions (Alex Williamson)
Create a new -smbios option (x86-only) to allow binary SMBIOS entries
to be passed through to the BIOS or modify the default values of
individual fields of type 0 and 1 entries on the command line.
Binary SMBIOS entries can be generated as follows:
dmidecode -t 1 -u | grep $'^\t\t[^"]' | xargs -n1 | \
perl -lne 'printf "%c", hex($_)' > smbios_type_1.bin
These can then be passed to the BIOS using this switch:
-smbios file=smbios_type_1.bin
Command line generation supports the following syntax:
-smbios type=0[,vendor=str][,version=str][,date=str][,release=%d.%d]
-smbios type=1[,manufacturer=str][,product=str][,version=str][,serial=str]
[,uuid=$(uuidgen)][,sku=str][,family=str]
For instance, to add a serial number to the type 1 table:
-smbios type=1,serial=0123456789
Interface is extensible to support more fields/tables as needed.
aliguori: remove texi formatting from help output
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7163 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17 20:59:56 +02:00
|
|
|
case 1:
|
2015-09-11 15:04:45 +02:00
|
|
|
qemu_opts_validate(opts, qemu_smbios_type1_opts, &error_fatal);
|
smbios: Make multiple -smbios type= accumulate sanely
Currently, -smbios type=T,NAME=VAL,... adds one field (T,NAME) with
value VAL to fw_cfg for each unique NAME. If NAME occurs multiple
times, the last one's VAL is used (before the QemuOpts conversion, the
first one was used).
Multiple -smbios can add multiple fields with the same (T, NAME).
SeaBIOS reads all of them from fw_cfg, but uses only the first field
(T, NAME). The others are ignored.
"First one wins, subsequent ones get ignored silently" isn't nice. We
commonly let the last option win. Useful, because it lets you
-readconfig first, then selectively override with command line
options.
Clean up -smbios to work the common way. Accumulate the settings,
with later ones overwriting earlier ones. Put the result into fw_cfg
(no more useless duplicates).
Bonus cleanup: qemu_uuid_parse() no longer sets SMBIOS system uuid by
side effect.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2013-08-16 15:18:31 +02:00
|
|
|
save_opt(&type1.manufacturer, opts, "manufacturer");
|
|
|
|
save_opt(&type1.product, opts, "product");
|
|
|
|
save_opt(&type1.version, opts, "version");
|
|
|
|
save_opt(&type1.serial, opts, "serial");
|
|
|
|
save_opt(&type1.sku, opts, "sku");
|
|
|
|
save_opt(&type1.family, opts, "family");
|
|
|
|
|
|
|
|
val = qemu_opt_get(opts, "uuid");
|
|
|
|
if (val) {
|
2016-09-21 06:27:22 +02:00
|
|
|
if (qemu_uuid_parse(val, &qemu_uuid) != 0) {
|
smbios: Make multiple -smbios type= accumulate sanely
Currently, -smbios type=T,NAME=VAL,... adds one field (T,NAME) with
value VAL to fw_cfg for each unique NAME. If NAME occurs multiple
times, the last one's VAL is used (before the QemuOpts conversion, the
first one was used).
Multiple -smbios can add multiple fields with the same (T, NAME).
SeaBIOS reads all of them from fw_cfg, but uses only the first field
(T, NAME). The others are ignored.
"First one wins, subsequent ones get ignored silently" isn't nice. We
commonly let the last option win. Useful, because it lets you
-readconfig first, then selectively override with command line
options.
Clean up -smbios to work the common way. Accumulate the settings,
with later ones overwriting earlier ones. Put the result into fw_cfg
(no more useless duplicates).
Bonus cleanup: qemu_uuid_parse() no longer sets SMBIOS system uuid by
side effect.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2013-08-16 15:18:31 +02:00
|
|
|
error_report("Invalid UUID");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
qemu_uuid_set = true;
|
|
|
|
}
|
2013-08-16 15:18:28 +02:00
|
|
|
return;
|
2014-04-23 15:42:42 +02:00
|
|
|
case 2:
|
2015-09-11 15:04:45 +02:00
|
|
|
qemu_opts_validate(opts, qemu_smbios_type2_opts, &error_fatal);
|
2014-04-23 15:42:42 +02:00
|
|
|
save_opt(&type2.manufacturer, opts, "manufacturer");
|
|
|
|
save_opt(&type2.product, opts, "product");
|
|
|
|
save_opt(&type2.version, opts, "version");
|
|
|
|
save_opt(&type2.serial, opts, "serial");
|
|
|
|
save_opt(&type2.asset, opts, "asset");
|
|
|
|
save_opt(&type2.location, opts, "location");
|
|
|
|
return;
|
|
|
|
case 3:
|
2015-09-11 15:04:45 +02:00
|
|
|
qemu_opts_validate(opts, qemu_smbios_type3_opts, &error_fatal);
|
2014-04-23 15:42:42 +02:00
|
|
|
save_opt(&type3.manufacturer, opts, "manufacturer");
|
|
|
|
save_opt(&type3.version, opts, "version");
|
|
|
|
save_opt(&type3.serial, opts, "serial");
|
|
|
|
save_opt(&type3.asset, opts, "asset");
|
|
|
|
save_opt(&type3.sku, opts, "sku");
|
|
|
|
return;
|
|
|
|
case 4:
|
2015-09-11 15:04:45 +02:00
|
|
|
qemu_opts_validate(opts, qemu_smbios_type4_opts, &error_fatal);
|
2014-04-23 15:42:42 +02:00
|
|
|
save_opt(&type4.sock_pfx, opts, "sock_pfx");
|
|
|
|
save_opt(&type4.manufacturer, opts, "manufacturer");
|
|
|
|
save_opt(&type4.version, opts, "version");
|
|
|
|
save_opt(&type4.serial, opts, "serial");
|
|
|
|
save_opt(&type4.asset, opts, "asset");
|
|
|
|
save_opt(&type4.part, opts, "part");
|
|
|
|
return;
|
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>
2017-10-28 22:51:36 +02:00
|
|
|
case 11:
|
|
|
|
qemu_opts_validate(opts, qemu_smbios_type11_opts, &error_fatal);
|
|
|
|
save_opt_list(&type11.nvalues, &type11.values, opts, "value");
|
|
|
|
return;
|
2014-04-23 15:42:42 +02:00
|
|
|
case 17:
|
2015-09-11 15:04:45 +02:00
|
|
|
qemu_opts_validate(opts, qemu_smbios_type17_opts, &error_fatal);
|
2014-04-23 15:42:42 +02:00
|
|
|
save_opt(&type17.loc_pfx, opts, "loc_pfx");
|
|
|
|
save_opt(&type17.bank, opts, "bank");
|
|
|
|
save_opt(&type17.manufacturer, opts, "manufacturer");
|
|
|
|
save_opt(&type17.serial, opts, "serial");
|
|
|
|
save_opt(&type17.asset, opts, "asset");
|
|
|
|
save_opt(&type17.part, opts, "part");
|
2015-03-11 18:58:01 +01:00
|
|
|
type17.speed = qemu_opt_get_number(opts, "speed", 0);
|
2014-04-23 15:42:42 +02:00
|
|
|
return;
|
qemu: Add support for SMBIOS command line otions (Alex Williamson)
Create a new -smbios option (x86-only) to allow binary SMBIOS entries
to be passed through to the BIOS or modify the default values of
individual fields of type 0 and 1 entries on the command line.
Binary SMBIOS entries can be generated as follows:
dmidecode -t 1 -u | grep $'^\t\t[^"]' | xargs -n1 | \
perl -lne 'printf "%c", hex($_)' > smbios_type_1.bin
These can then be passed to the BIOS using this switch:
-smbios file=smbios_type_1.bin
Command line generation supports the following syntax:
-smbios type=0[,vendor=str][,version=str][,date=str][,release=%d.%d]
-smbios type=1[,manufacturer=str][,product=str][,version=str][,serial=str]
[,uuid=$(uuidgen)][,sku=str][,family=str]
For instance, to add a serial number to the type 1 table:
-smbios type=1,serial=0123456789
Interface is extensible to support more fields/tables as needed.
aliguori: remove texi formatting from help output
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7163 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17 20:59:56 +02:00
|
|
|
default:
|
2013-06-07 15:00:33 +02:00
|
|
|
error_report("Don't know how to build fields for SMBIOS type %ld",
|
|
|
|
type);
|
qemu: Add support for SMBIOS command line otions (Alex Williamson)
Create a new -smbios option (x86-only) to allow binary SMBIOS entries
to be passed through to the BIOS or modify the default values of
individual fields of type 0 and 1 entries on the command line.
Binary SMBIOS entries can be generated as follows:
dmidecode -t 1 -u | grep $'^\t\t[^"]' | xargs -n1 | \
perl -lne 'printf "%c", hex($_)' > smbios_type_1.bin
These can then be passed to the BIOS using this switch:
-smbios file=smbios_type_1.bin
Command line generation supports the following syntax:
-smbios type=0[,vendor=str][,version=str][,date=str][,release=%d.%d]
-smbios type=1[,manufacturer=str][,product=str][,version=str][,serial=str]
[,uuid=$(uuidgen)][,sku=str][,family=str]
For instance, to add a serial number to the type 1 table:
-smbios type=1,serial=0123456789
Interface is extensible to support more fields/tables as needed.
aliguori: remove texi formatting from help output
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7163 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17 20:59:56 +02:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-07 15:00:33 +02:00
|
|
|
error_report("Must specify type= or file=");
|
2013-08-16 15:18:28 +02:00
|
|
|
exit(1);
|
qemu: Add support for SMBIOS command line otions (Alex Williamson)
Create a new -smbios option (x86-only) to allow binary SMBIOS entries
to be passed through to the BIOS or modify the default values of
individual fields of type 0 and 1 entries on the command line.
Binary SMBIOS entries can be generated as follows:
dmidecode -t 1 -u | grep $'^\t\t[^"]' | xargs -n1 | \
perl -lne 'printf "%c", hex($_)' > smbios_type_1.bin
These can then be passed to the BIOS using this switch:
-smbios file=smbios_type_1.bin
Command line generation supports the following syntax:
-smbios type=0[,vendor=str][,version=str][,date=str][,release=%d.%d]
-smbios type=1[,manufacturer=str][,product=str][,version=str][,serial=str]
[,uuid=$(uuidgen)][,sku=str][,family=str]
For instance, to add a serial number to the type 1 table:
-smbios type=1,serial=0123456789
Interface is extensible to support more fields/tables as needed.
aliguori: remove texi formatting from help output
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7163 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17 20:59:56 +02:00
|
|
|
}
|