smbios cleanup & nicer defaults for type 1
v2 cover smbios cleanup & nicer defaults for type 1
From: Markus Armbruster <[email protected]>
This gets rid of one of the last get_param_value() users, makes multiple -smbios work sanely, cleans up the gross side effect in qemu_uuid_parse(), and more. Topped off with a little feature in the last patch.
v2: Rebase, only last patch had conflicts
Markus Armbruster (7):
smbios: Normalize smbios_entry_add()'s error handling to exit(1)
smbios: Convert to QemuOpts
smbios: Improve diagnostics for conflicting entries
smbios: Make multiple -smbios type= accumulate sanely
smbios: Factor out smbios_maybe_add_str()
vl: Set current_machine early
smbios: Set system manufacturer, product & version by default
arch_init.c | 9 +- hw/i386/pc.c | 6 +- hw/i386/pc_piix.c | 5 + hw/i386/pc_q35.c | 3 + hw/i386/smbios.c | 349 ++++++++++++++++++++++++++++++++------------- include/hw/i386/pc.h | 1 + include/hw/i386/smbios.h | 7 +- include/sysemu/arch_init.h | 2 +- include/sysemu/sysemu.h | 1 + vl.c | 8 +- 10 files changed, 276 insertions(+), 115 deletions(-)
Signature · 1 line
1.8.1.4
PATCH v2 1/7 smbios: Normalize smbios_entry_add()'s error handling to exit(1)
From: Markus Armbruster <[email protected]>
It exits on all error conditions but one, where it returns -1. Normalize, and return void.
--- arch_init.c | 4 +--- hw/i386/smbios.c | 10 +++++----- include/hw/i386/smbios.h | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-)
arch_init.c +1 -3
@@ -1136,9 +1136,7 @@ void do_acpitable_option(const QemuOpts *opts)void do_smbios_option (const char *optarg) {#ifdef TARGET_I386 -if (smbios_entry_add (optarg) <0 ) { -exit (1 ); - } +smbios_entry_add (optarg);#endif }
hw/i386/smbios.c +5 -5
@@ -183,7 +183,7 @@ static void smbios_build_type_1_fields(const char *t) buf, strlen(buf) + 1); } -int smbios_entry_add (const char *t) +void smbios_entry_add (const char *t) {char buf[1024 ];
@@ -222,7 +222,7 @@ int smbios_entry_add(const char *t) smbios_entries_len +=sizeof (*table) + size; (*(uint16_t *)smbios_entries) =cpu_to_le16 (le16_to_cpu (*(uint16_t *)smbios_entries) +1 ); -return 0 ; +return ; }if (get_param_value (buf,sizeof (buf),"type" , t)) {
@@ -230,10 +230,10 @@ int smbios_entry_add(const char *t)switch (type) {case 0 :smbios_build_type_0_fields (t); -return 0 ; +return ;case 1 :smbios_build_type_1_fields (t); -return 0 ; +return ;default :error_report ("Don't know how to build fields for SMBIOS type %ld" , type);
@@ -242,5 +242,5 @@ int smbios_entry_add(const char *t) }error_report ("Must specify type= or file=" ); -return -1 ; +exit (1 ); }
include/hw/i386/smbios.h +1 -1
@@ -13,7 +13,7 @@* */ -int smbios_entry_add (const char *t); +void smbios_entry_add (const char *t);void smbios_add_field (int type,int offset,const void *data,size_t len);uint8_t *smbios_get_table (size_t *length);
Signature · 1 line
1.8.1.4
PATCH v2 2/7 smbios: Convert to QemuOpts
In reply to [email protected]From: Markus Armbruster <[email protected]>
So that it can be set in config file for -readconfig.
This tightens parsing of -smbios, and makes it more consistent with other options: unknown parameters are rejected, numbers with trailing junk are rejected, when a parameter is given multiple times, last rather than first wins, ...
--- arch_init.c | 4 +- hw/i386/smbios.c | 211 ++++++++++++++++++++++++++++++++++++--------- include/hw/i386/smbios.h | 4 +- include/sysemu/arch_init.h | 2 +- vl.c | 3 +- 5 files changed, 180 insertions(+), 44 deletions(-)
arch_init.c +2 -2
@@ -1133,10 +1133,10 @@ void do_acpitable_option(const QemuOpts *opts)#endif } -void do_smbios_option (const char *optarg) +void do_smbios_option (QemuOpts *opts) {#ifdef TARGET_I386 -smbios_entry_add (optarg); +smbios_entry_add (opts);#endif }
hw/i386/smbios.c +172 -39
293 lines not on this page · raw message
include/hw/i386/smbios.h +3 -1
@@ -13,7 +13,9 @@* */ -void smbios_entry_add (const char *t); +#include "qemu/option.h" + +void smbios_entry_add (QemuOpts *opts);void smbios_add_field (int type,int offset,const void *data,size_t len);uint8_t *smbios_get_table (size_t *length);
include/sysemu/arch_init.h +1 -1
@@ -28,7 +28,7 @@ extern const uint32_t arch_type;void select_soundhw (const char *optarg);void do_acpitable_option (const QemuOpts *opts); -void do_smbios_option (const char *optarg); +void do_smbios_option (QemuOpts *opts);void cpudef_init (void );void audio_init (void );int tcg_available (void );
vl.c +2 -1
@@ -3565,7 +3565,8 @@ int main(int argc, char **argv, char **envp)do_acpitable_option (opts);break ;case QEMU_OPTION_smbios: -do_smbios_option (optarg); + opts =qemu_opts_parse (qemu_find_opts ("smbios" ), optarg,0 ); +do_smbios_option (opts);break ;case QEMU_OPTION_enable_kvm: olist =qemu_find_opts ("machine" );
Signature · 1 line
1.8.1.4
Re: [Qemu-devel] [PATCH v2 2/7] smbios: Convert to QemuOpts
Quoted 330 lines · On Fri, Aug 16, 2013 at 03:18:29PM +0200, [email protected] wrote:
From: Markus Armbruster <[email protected]>
So that it can be set in config file for -readconfig.
This tightens parsing of -smbios, and makes it more consistent with other options: unknown parameters are rejected, numbers with trailing junk are rejected, when a parameter is given multiple times, last rather than first wins, ...
Signed-off-by Markus Armbruster <[email protected]>Reviewed-by Eric Blake <[email protected]>--- arch_init.c | 4 +- hw/i386/smbios.c | 211 ++++++++++++++++++++++++++++++++++++--------- include/hw/i386/smbios.h | 4 +- include/sysemu/arch_init.h | 2 +- vl.c | 3 +- 5 files changed, 180 insertions(+), 44 deletions(-)arch_init.c +2
-2@@ -1133,10 +1133,10 @@ void do_acpitable_option(const QemuOpts *opts)#endif } -void do_smbios_option (const char *optarg) +void do_smbios_option (QemuOpts *opts) {#ifdef TARGET_I386 -smbios_entry_add (optarg); +smbios_entry_add (opts);#endif }hw/i386/smbios.c +168
-38@@ -2,9 +2,11 @@* SMBIOS Support * * Copyright (C) 2009 Hewlett-Packard Development Company, L.P. +* Copyright (C) 2013 Red Hat, Inc. * * Authors: * Alex Williamson <[email protected]> +* Markus Armbruster <[email protected]> * * This work is licensed under the terms of the GNU GPL, version 2. See * the COPYING file in the top-level directory. @@ -13,6 +15,7 @@* GNU GPL, version 2 or (at your option) any later version. */ +#include "qemu/config-file.h" #include "qemu/error-report.h" #include "sysemu/sysemu.h" #include "hw/i386/smbios.h" @@ -41,11 +44,100 @@ struct smbios_table {#define SMBIOS_FIELD_ENTRY 0#define SMBIOS_TABLE_ENTRY 1 -static uint8_t *smbios_entries;static size_t smbios_entries_len;static int smbios_type4_count =0 ; +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" , + }, + {/* 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 */ } +}; + +static void smbios_register_config (void ) +{ +qemu_add_opts (&qemu_smbios_opts); +} + +machine_init (smbios_register_config); +static void smbios_validate_table (void ) {if (smbios_type4_count && smbios_type4_count != smp_cpus) {@@ -124,23 +216,30 @@ void smbios_add_field(int type, int offset, const void *data, size_t len)cpu_to_le16 (le16_to_cpu (*(uint16_t *)smbios_entries) +1 ); } -static void smbios_build_type_0_fields (const char *t) +static void smbios_build_type_0_fields (QemuOpts *opts) { -char buf[1024 ]; +const char *val;unsigned char major, minor; -if (get_param_value (buf,sizeof (buf),"vendor" , t)) + val =qemu_opt_get (opts,"vendor" ); +if (val) {smbios_add_field (0 , offsetof(struct smbios_type_0 , vendor_str), - buf,strlen (buf) +1 ); -if (get_param_value (buf,sizeof (buf),"version" , t)) + val,strlen (val) +1 ); + } + val =qemu_opt_get (opts,"version" ); +if (val) {smbios_add_field (0 , offsetof(struct smbios_type_0 , bios_version_str), - buf,strlen (buf) +1 ); -if (get_param_value (buf,sizeof (buf),"date" , t)) + val,strlen (val) +1 ); + } + val =qemu_opt_get (opts,"date" ); +if (val) {smbios_add_field (0 , offsetof(struct smbios_type_0 , bios_release_date_str), - buf,strlen (buf) +1 ); -if (get_param_value (buf,sizeof (buf),"release" , t)) { -if (sscanf (buf,"%hhu.%hhu" , &major, &minor) !=2 ) { + val,strlen (val) +1 ); + } + val =qemu_opt_get (opts,"release" ); +if (val) { +if (sscanf (val,"%hhu.%hhu" , &major, &minor) !=2 ) {error_report ("Invalid release" );exit (1 ); }@@ -153,47 +252,69 @@ static void smbios_build_type_0_fields(const char *t) } } -static void smbios_build_type_1_fields (const char *t) +static void smbios_build_type_1_fields (QemuOpts *opts) { -char buf[1024 ]; +const char *val; -if (get_param_value (buf,sizeof (buf),"manufacturer" , t)) + val =qemu_opt_get (opts,"manufacturer" ); +if (val) {smbios_add_field (1 , offsetof(struct smbios_type_1 , manufacturer_str), - buf,strlen (buf) +1 ); -if (get_param_value (buf,sizeof (buf),"product" , t)) + val,strlen (val) +1 ); + } + val =qemu_opt_get (opts,"product" ); +if (val) {smbios_add_field (1 , offsetof(struct smbios_type_1 , product_name_str), - buf,strlen (buf) +1 ); -if (get_param_value (buf,sizeof (buf),"version" , t)) + val,strlen (val) +1 ); + } + val =qemu_opt_get (opts,"version" ); +if (val) {smbios_add_field (1 , offsetof(struct smbios_type_1 , version_str), - buf,strlen (buf) +1 ); -if (get_param_value (buf,sizeof (buf),"serial" , t)) + val,strlen (val) +1 ); + } + val =qemu_opt_get (opts,"serial" ); +if (val) {smbios_add_field (1 , offsetof(struct smbios_type_1 , serial_number_str), - buf,strlen (buf) +1 ); -if (get_param_value (buf,sizeof (buf),"uuid" , t)) { -if (qemu_uuid_parse (buf, qemu_uuid) !=0 ) { + val,strlen (val) +1 ); + } + val =qemu_opt_get (opts,"uuid" ); +if (val) { +if (qemu_uuid_parse (val, qemu_uuid) !=0 ) {error_report ("Invalid UUID" );exit (1 ); } } -if (get_param_value (buf,sizeof (buf),"sku" , t)) + val =qemu_opt_get (opts,"sku" ); +if (val) {smbios_add_field (1 , offsetof(struct smbios_type_1 , sku_number_str), - buf,strlen (buf) +1 ); -if (get_param_value (buf,sizeof (buf),"family" , t)) + val,strlen (val) +1 ); + } + val =qemu_opt_get (opts,"family" ); +if (val) {smbios_add_field (1 , offsetof(struct smbios_type_1 , family_str), - buf,strlen (buf) +1 ); + val,strlen (val) +1 ); + } } -void smbios_entry_add (const char *t) +void smbios_entry_add (QemuOpts *opts) { -char buf[1024 ]; +Error *local_err =NULL ; +const char *val; -if (get_param_value (buf,sizeof (buf),"file" , t)) { + val =qemu_opt_get (opts,"file" ); +if (val) {struct smbios_structure_header *header;struct smbios_table *table; -int size =get_image_size (buf); +int size; + +qemu_opts_validate (opts, qemu_smbios_file_opts, &local_err); +if (local_err) { +error_report ("%s" ,error_get_pretty (local_err)); +exit (1 ); + } + size =get_image_size (val);if (size ==-1 || size <sizeof (struct smbios_structure_header )) { -error_report ("Cannot read SMBIOS file %s" , buf); +error_report ("Cannot read SMBIOS file %s" , val);exit (1 ); }@@ -208,8 +329,8 @@ void smbios_entry_add(const char *t) table->header.type =SMBIOS_TABLE_ENTRY ; table->header.length =cpu_to_le16 (sizeof (*table) + size); -if (load_image (buf, table->data) != size) { -error_report ("Failed to load SMBIOS file %s" , buf); +if (load_image (val, table->data) != size) { +error_report ("Failed to load SMBIOS file %s" , val);exit (1 ); }@@ -225,17 +346,29 @@ void smbios_entry_add(const char *t)return ; } -if (get_param_value (buf,sizeof (buf),"type" , t)) { -unsigned long type =strtoul (buf,NULL ,0 ); + val =qemu_opt_get (opts,"type" ); +if (val) { +unsigned long type =strtoul (val,NULL ,0 ); +switch (type) {case 0 : -smbios_build_type_0_fields (t); +qemu_opts_validate (opts, qemu_smbios_type0_opts, &local_err); +if (local_err) { +error_report ("%s" ,error_get_pretty (local_err)); +exit (1 ); + } +smbios_build_type_0_fields (opts);return ;case 1 : -smbios_build_type_1_fields (t); +qemu_opts_validate (opts, qemu_smbios_type1_opts, &local_err); +if (local_err) { +error_report ("%s" ,error_get_pretty (local_err));
hw/i386/smbios.c void smbios_entry_add(const char *t) · line 374
Quoted 10 lines
hw/i386/smbios.c +4
-1+exit (1 ); + } +smbios_build_type_1_fields (opts);return ;default : -error_report ("Don't know how to build fields for SMBIOS type %ld" , +error_report ("Don't know how to build fields for SMBIOS type %" PRIu64, type);exit (1 ); }
This triggers a build failure:
/scm/qemu/hw/i386/smbios.c: In function ‘smbios_entry_add’:
/scm/qemu/hw/i386/smbios.c:382:26: error: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘long unsigned int’ [-Werror=format=]
type);
^It's a long value, why are you printing it with PRIu64? %ld seems right.
I reverted just this chunk.
Quoted 45 lines
include/hw/i386/smbios.h +3
-1@@ -13,7 +13,9 @@* */ -void smbios_entry_add (const char *t); +#include "qemu/option.h" + +void smbios_entry_add (QemuOpts *opts);void smbios_add_field (int type,int offset,const void *data,size_t len);uint8_t *smbios_get_table (size_t *length);include/sysemu/arch_init.h +1
-1@@ -28,7 +28,7 @@ extern const uint32_t arch_type;void select_soundhw (const char *optarg);void do_acpitable_option (const QemuOpts *opts); -void do_smbios_option (const char *optarg); +void do_smbios_option (QemuOpts *opts);void cpudef_init (void );void audio_init (void );int tcg_available (void );vl.c +2
-1@@ -3565,7 +3565,8 @@ int main(int argc, char **argv, char **envp)do_acpitable_option (opts);break ;case QEMU_OPTION_smbios: -do_smbios_option (optarg); + opts =qemu_opts_parse (qemu_find_opts ("smbios" ), optarg,0 ); +do_smbios_option (opts);break ;case QEMU_OPTION_enable_kvm: olist =qemu_find_opts ("machine" );Signature · 1 line
1.8.1.4
Re: [Qemu-devel] [PATCH v2 2/7] smbios: Convert to QemuOpts
Quoted 12 lines · Michael S. Tsirkin
Quoted 11 lines · On Fri, Aug 16, 2013 at 03:18:29PM +0200, [email protected] wrote:
From: Markus Armbruster <[email protected]>
So that it can be set in config file for -readconfig.
This tightens parsing of -smbios, and makes it more consistent with other options: unknown parameters are rejected, numbers with trailing junk are rejected, when a parameter is given multiple times, last rather than first wins, ...
Signed-off-by Markus Armbruster <[email protected]>Reviewed-by Eric Blake <[email protected]>
[...]
Quoted 4 lines
Quoted 4 lines
hw/i386/smbios.c +0
-0
[...]
Quoted 42 lines
Quoted 25 lines
hw/i386/smbios.c +13
-4@@ -225,17 +346,29 @@ void smbios_entry_add(const char *t)return ; } -if (get_param_value (buf,sizeof (buf),"type" , t)) { -unsigned long type =strtoul (buf,NULL ,0 ); + val =qemu_opt_get (opts,"type" ); +if (val) { +unsigned long type =strtoul (val,NULL ,0 ); +switch (type) {case 0 : -smbios_build_type_0_fields (t); +qemu_opts_validate (opts, qemu_smbios_type0_opts, &local_err); +if (local_err) { +error_report ("%s" ,error_get_pretty (local_err)); +exit (1 ); + } +smbios_build_type_0_fields (opts);return ;case 1 : -smbios_build_type_1_fields (t); +qemu_opts_validate (opts, qemu_smbios_type1_opts, &local_err); +if (local_err) { +error_report ("%s" ,error_get_pretty (local_err));hw/i386/smbios.c void smbios_entry_add(const char *t) · line 374
Quoted 10 lines
hw/i386/smbios.c +4
-1+exit (1 ); + } +smbios_build_type_1_fields (opts);return ;default : -error_report ("Don't know how to build fields for SMBIOS type %ld" , +error_report ("Don't know how to build fields for SMBIOS type %" PRIu64, type);exit (1 ); }This triggers a build failure:
/scm/qemu/hw/i386/smbios.c: In function ‘smbios_entry_add’:
/scm/qemu/hw/i386/smbios.c:382:26: error: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘long unsigned int’ [-Werror=format=]
Quoted 5 lines
type); ^It's a long value, why are you printing it with PRIu64? %ld seems right.
Yup.
Quoted 1 line
I reverted just this chunk.
Thanks for catching this. My compiler doesn't :(
[...]
PATCH v2 3/7 smbios: Improve diagnostics for conflicting entries
In reply to [email protected]From: Markus Armbruster <[email protected]>
We allow either tables or fields for the same type. Makes sense, because SeaBIOS uses fields only when no tables are present.
We do this by searching the SMBIOS blob for a previously added table or field. Error messages look like this:
qemu-system-x86_64: -smbios type=1,serial=42: SMBIOS type 1 table already defined, cannot add field
User needs to know that "table" is defined by -smbios file=..., and "field" by -smbios type=...
Instead of searching the blob, record additions of interest, and check that. Simpler, and makes better error messages possible:
qemu-system-x86_64: -smbios file=smbios_type_1.bin: Can't mix file= and type= for same type
qemu-system-x86_64: -smbios type=1,serial=42,serial=99: This is the conflicting setting
--- hw/i386/smbios.c | 43 +++++++++++++++++-------------------------- 1 file changed, 17 insertions(+), 26 deletions(-)
hw/i386/smbios.c +17 -26
@@ -48,6 +48,12 @@ static uint8_t *smbios_entries;static size_t smbios_entries_len;static int smbios_type4_count =0 ; +static struct { +bool seen; +int headertype; +Location loc; +} first_opt[2 ]; +static QemuOptsList qemu_smbios_opts = { .name ="smbios" , .head =QTAILQ_HEAD_INITIALIZER (qemu_smbios_opts.head),
@@ -159,35 +165,20 @@ uint8_t *smbios_get_table(size_t *length)*/ static void smbios_check_collision (int type,int entry) { -uint16_t *num_entries = (uint16_t *)smbios_entries; -struct smbios_header *header; -char *p; -int i; - -if (!num_entries) -return ; - - p = (char *)(num_entries +1 ); - -for (i =0 ; i < *num_entries; i++) { - header = (struct smbios_header *)p; -if (entry ==SMBIOS_TABLE_ENTRY && header->type ==SMBIOS_FIELD_ENTRY ) { -struct smbios_field *field = (void *)header; -if (type == field->type) { -error_report ("SMBIOS type %d field already defined, " -"cannot add table" , type); -exit (1 ); - } - }else if (entry ==SMBIOS_FIELD_ENTRY && - header->type ==SMBIOS_TABLE_ENTRY ) { -struct smbios_structure_header *table = (void *)(header +1 ); -if (type == table->type) { -error_report ("SMBIOS type %d table already defined, " -"cannot add field" , type); +if (type <ARRAY_SIZE (first_opt)) { +if (first_opt[type].seen) { +if (first_opt[type].headertype != entry) { +error_report ("Can't mix file= and type= for same type" ); +loc_push_restore (&first_opt[type].loc); +error_report ("This is the conflicting setting" ); +loc_pop (&first_opt[type].loc);exit (1 ); } + }else { + first_opt[type].seen = true; + first_opt[type].headertype = entry; +loc_save (&first_opt[type].loc); } - p +=le16_to_cpu (header->length); } }
Signature · 1 line
1.8.1.4
PATCH v2 4/7 smbios: Make multiple -smbios type= accumulate sanely
In reply to [email protected]From: Markus Armbruster <[email protected]>
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.
--- arch_init.c | 3 - hw/i386/smbios.c | 152 ++++++++++++++++++++++++++++------------------- include/hw/i386/smbios.h | 1 - include/sysemu/sysemu.h | 1 + vl.c | 2 + 5 files changed, 94 insertions(+), 65 deletions(-)
arch_init.c +0 -3
@@ -1112,9 +1112,6 @@ int qemu_uuid_parse(const char *str, uint8_t *uuid)if (ret !=16 ) {return -1 ; } -#ifdef TARGET_I386 -smbios_add_field (1 , offsetof(struct smbios_type_1 , uuid), uuid,16 ); -#endif return 0 ; }
hw/i386/smbios.c +91 -61
236 lines not on this page · raw message
include/hw/i386/smbios.h +0 -1
@@ -16,7 +16,6 @@#include "qemu/option.h" void smbios_entry_add (QemuOpts *opts); -void smbios_add_field (int type,int offset,const void *data,size_t len);uint8_t *smbios_get_table (size_t *length);/*
include/sysemu/sysemu.h +1 -0
@@ -16,6 +16,7 @@ extern const char *bios_name;extern const char *qemu_name;extern uint8_t qemu_uuid[]; +extern bool qemu_uuid_set;int qemu_uuid_parse (const char *str,uint8_t *uuid);#define UUID_FMT "%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx"
vl.c +2 -0
@@ -254,6 +254,7 @@ uint64_t node_mem[MAX_NODES];unsigned long *node_cpumask[MAX_NODES ];uint8_t qemu_uuid[16 ]; +bool qemu_uuid_set;static QEMUBootSetHandler *boot_set_handler;static void *boot_set_opaque;
@@ -3662,6 +3663,7 @@ int main(int argc, char **argv, char **envp) " Wrong format.\n");exit (1 ); } + qemu_uuid_set = true;break ;case QEMU_OPTION_option_rom:if (nb_option_roms >=MAX_OPTION_ROMS ) {
Signature · 1 line
1.8.1.4
Re: [Qemu-devel] [PATCH v2 4/7] smbios: Make multiple -smbios type= accumulate sanely
hw/i386/smbios.c void smbios_entry_add(QemuOpts *opts) · line 363
Quoted 13 lines · On 08/16/2013 07:18 AM, [email protected] wrote:
From: Markus Armbruster <[email protected]>
Currently, -smbios type=T,NAME=VAL,... adds one field (T,NAME) with value VAL to
fw_cfgfor each unique NAME. If NAME occurs multiple times, the last one's VAL is used (before the QemuOpts conversion, the first one was used).hw/i386/smbios.c +5
-0+ + val =qemu_opt_get (opts,"release" ); +if (val) { +if (sscanf (val,"%hhu.%hhu" , &type0.major, &type0.minor) !=2 ) { +error_report ("Invalid release" );
As in v1, I'm not a fan of using sscanf for integer parsing (it has undefined behavior if the user provides a value that overflows the destination type); but as this is code motion, it does not invalidate my review.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH v2 5/7 smbios: Factor out smbios_maybe_add_str()
In reply to [email protected]From: Markus Armbruster <[email protected]>
--- hw/i386/smbios.c | 61 +++++++++++++++++++++++--------------------------------- 1 file changed, 25 insertions(+), 36 deletions(-)
hw/i386/smbios.c +25 -36
@@ -210,21 +210,22 @@ static void smbios_add_field(int type, int offset, const void *data, size_t len)cpu_to_le16 (le16_to_cpu (*(uint16_t *)smbios_entries) +1 ); } -static void smbios_build_type_0_fields (void ) +static void smbios_maybe_add_str (int type,int offset,const char *data) { -if (type0.vendor) { -smbios_add_field (0 , offsetof(struct smbios_type_0 , vendor_str), - type0.vendor,strlen (type0.vendor) +1 ); - } -if (type0.version) { -smbios_add_field (0 , offsetof(struct smbios_type_0 , bios_version_str), - type0.version,strlen (type0.version) +1 ); +if (data) { +smbios_add_field (type, offset, data,strlen (data) +1 ); } -if (type0.date) { -smbios_add_field (0 , offsetof(struct smbios_type_0 , +} + +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 , bios_release_date_str), - type0.date,strlen (type0.date) +1 ); - } + type0.date);if (type0.have_major_minor) { smbios_add_field(0, offsetof(struct smbios_type_0, system_bios_major_release),
@@ -237,30 +238,18 @@ static void smbios_build_type_0_fields(void)static void smbios_build_type_1_fields (void ) { -if (type1.manufacturer) { -smbios_add_field (1 , offsetof(struct smbios_type_1 , manufacturer_str), - type1.manufacturer,strlen (type1.manufacturer) +1 ); - } -if (type1.product) { -smbios_add_field (1 , offsetof(struct smbios_type_1 , product_name_str), - type1.product,strlen (type1.product) +1 ); - } -if (type1.version) { -smbios_add_field (1 , offsetof(struct smbios_type_1 , version_str), - type1.version,strlen (type1.version) +1 ); - } -if (type1.serial) { -smbios_add_field (1 , offsetof(struct smbios_type_1 , serial_number_str), - type1.serial,strlen (type1.serial) +1 ); - } -if (type1.sku) { -smbios_add_field (1 , offsetof(struct smbios_type_1 , sku_number_str), - type1.sku,strlen (type1.sku) +1 ); - } -if (type1.family) { -smbios_add_field (1 , offsetof(struct smbios_type_1 , family_str), - type1.family,strlen (type1.family) +1 ); - } +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);if (qemu_uuid_set) {smbios_add_field (1 , offsetof(struct smbios_type_1 , uuid), qemu_uuid,16 );
Signature · 1 line
1.8.1.4
PATCH v2 6/7 vl: Set current_machine early
In reply to [email protected]From: Markus Armbruster <[email protected]>
I'd like to access QEMUMachine from a QEMUMachine init() method, which is currently not possible. Instead of passing it as an argument, I simply set current_machine earlier.
--- vl.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
vl.c +1 -2
@@ -3897,6 +3897,7 @@ int main(int argc, char **argv, char **envp)fprintf (stderr,"No machine found.\n" );exit (1 ); } + current_machine = machine;if (machine->hw_version) {qemu_set_version (machine->hw_version);
@@ -4325,8 +4326,6 @@ int main(int argc, char **argv, char **envp)set_numa_modes (); - current_machine = machine; -/* init USB devices */ if (usb_enabled (false)) {if (foreach_device_config (DEV_USB , usb_parse) <0 )
Signature · 1 line
1.8.1.4
Re: [Qemu-devel] [PATCH v2 6/7] vl: Set current_machine early
Am 16.08.2013 15:18, schrieb [email protected]:
Quoted 5 lines
From: Markus Armbruster <[email protected]>
I'd like to access QEMUMachine from a QEMUMachine
init()method, which is currently not possible. Instead of passing it as an argument, I simply setcurrent_machineearlier.
We had such a patch for CPU hot-add and decided against doing this. Currently current_machine != signals that it has been initialized. And generally we have been trying to get away from accessing globals from random parts of code.
Can't you pass either QEMUMachine or the specific fields needed from PC code to those SMBIOS functions? You did add a bool argument.
Andreas
Quoted 29 lines
Signed-off-by Markus Armbruster <[email protected]>Reviewed-by Eric Blake <[email protected]>--- vl.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)vl.c +1
-2@@ -3897,6 +3897,7 @@ int main(int argc, char **argv, char **envp)fprintf (stderr,"No machine found.\n" );exit (1 ); } + current_machine = machine;if (machine->hw_version) {qemu_set_version (machine->hw_version);@@ -4325,8 +4326,6 @@ int main(int argc, char **argv, char **envp)set_numa_modes (); - current_machine = machine; -/* init USB devices */ if (usb_enabled (false)) {if (foreach_device_config (DEV_USB , usb_parse) <0 )
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH v2 6/7] vl: Set current_machine early
Quoted 9 lines · Andreas Färber
Am 16.08.2013 15:18, schrieb [email protected]:
Quoted 5 lines
From: Markus Armbruster <[email protected]>
I'd like to access QEMUMachine from a QEMUMachine
init()method, which is currently not possible. Instead of passing it as an argument, I simply setcurrent_machineearlier.We had such a patch for CPU hot-add and decided against doing this. Currently
current_machine!= signals that it has been initialized. And
Does any code actually depend on this undocumented condition? I found none.
Quoted 2 lines
generally we have been trying to get away from accessing globals from random parts of code.
Global state need to be managed with care. Global variables have their place in that.
In my experience, the most common kind of carelessness involving global variables is indisciplined *updating* of global state via global variables.
Unchanging global state is relatively harmless, and referring to it via global variables is often the easiest and most obvious way to manage such state.
Quoted 2 lines
Can't you pass either QEMUMachine or the specific fields needed from PC code to those SMBIOS functions? You did add a bool argument.
Can't see how to do that without passing the machine to QEMUMachine method init(), which involves touching all boards. I doubt that's a good idea, but if you insist, I can do it.
Re: [Qemu-devel] [PATCH v2 6/7] vl: Set current_machine early
Am 19.08.2013 11:35, schrieb Markus Armbruster:
Quoted 9 lines
Quoted 7 lines · Andreas Färber
Am 16.08.2013 15:18, schrieb [email protected]:
Quoted 5 lines
From: Markus Armbruster <[email protected]>
I'd like to access QEMUMachine from a QEMUMachine
init()method, which is currently not possible. Instead of passing it as an argument, I simply setcurrent_machineearlier.
Quoted 5 lines
Quoted 2 lines
We had such a patch for CPU hot-add and decided against doing this. Currently
current_machine!= signals that it has been initialized. AndDoes any code actually depend on this undocumented condition? I found none.
I didn't audit. Currently the users are limited to vl.c itself, device-hotplug.c for block_default_type and qmp.c for hot_add_cpu. pc.c feels odd in that mix.
[...]
Quoted 6 lines
Quoted 2 lines
Can't you pass either QEMUMachine or the specific fields needed from PC code to those SMBIOS functions? You did add a bool argument.
Can't see how to do that without passing the machine to QEMUMachine method
init(), which involves touching all boards. I doubt that's a good idea, but if you insist, I can do it.
Isn't that exactly what QEMUMachineArgs was meant to address? :) Had a look at your don't-explode patches and they looked good.
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH v2 6/7] vl: Set current_machine early
Quoted 24 lines · Andreas Färber
Am 19.08.2013 11:35, schrieb Markus Armbruster:
Quoted 9 lines
Quoted 7 lines · Andreas Färber
Am 16.08.2013 15:18, schrieb [email protected]:
Quoted 5 lines
From: Markus Armbruster <[email protected]>
I'd like to access QEMUMachine from a QEMUMachine
init()method, which is currently not possible. Instead of passing it as an argument, I simply setcurrent_machineearlier.Quoted 5 lines
Quoted 2 lines
We had such a patch for CPU hot-add and decided against doing this. Currently
current_machine!= signals that it has been initialized. AndDoes any code actually depend on this undocumented condition? I found none.
I didn't audit. Currently the users are limited to
vl.citself,device-hotplug.cforblock_default_typeandqmp.cforhot_add_cpu.pc.cfeels odd in that mix.[...]
Quoted 3 lines
Quoted 2 lines
Can't you pass either QEMUMachine or the specific fields needed from PC code to those SMBIOS functions? You did add a bool argument.
Quoted 6 lines
Quoted 3 lines
Can't see how to do that without passing the machine to QEMUMachine method
init(), which involves touching all boards. I doubt that's a good idea, but if you insist, I can do it.Isn't that exactly what QEMUMachineArgs was meant to address? :) Had a look at your don't-explode patches and they looked good.
I could give it a try, but to be honest, I'm reluctant to base new work on a series that has been ignored by all committers for more than two months.
PATCH v2 7/7 smbios: Set system manufacturer, product & version by default
In reply to [email protected]From: Markus Armbruster <[email protected]>
Currently, we get SeaBIOS defaults: manufacturer Bochs, product Bochs, no version. Best SeaBIOS can do, but we can provide better defaults:
manufacturer QEMU, product & version taken from QEMUMachine desc and name.
Take care to do this only for new machine types, of course.
--- hw/i386/pc.c | 6 +++--- hw/i386/pc_piix.c | 5 +++++ hw/i386/pc_q35.c | 3 +++ hw/i386/smbios.c | 12 +++++++++++- include/hw/i386/pc.h | 1 + include/hw/i386/smbios.h | 2 +- 6 files changed, 24 insertions(+), 5 deletions(-)
hw/i386/pc.c +3 -3
@@ -604,7 +604,7 @@ static unsigned int pc_apic_id_limit(unsigned int max_cpus)return x86_cpu_apic_id_from_index (max_cpus -1 ) +1 ; } -static FWCfgState *bochs_bios_init (void ) +static FWCfgState *bochs_bios_init (bool smbios_type1_defaults) {FWCfgState *fw_cfg;uint8_t *smbios_table;
@@ -635,7 +635,7 @@ static FWCfgState *bochs_bios_init(void) acpi_tables, acpi_tables_len);fw_cfg_add_i32 (fw_cfg,FW_CFG_IRQ0_OVERRIDE ,kvm_allows_irq0_override ()); - smbios_table =smbios_get_table (&smbios_len); + smbios_table =smbios_get_table (&smbios_len, smbios_type1_defaults);if (smbios_table)fw_cfg_add_bytes (fw_cfg,FW_CFG_SMBIOS_ENTRIES , smbios_table, smbios_len);
@@ -1155,7 +1155,7 @@ FWCfgState *pc_memory_init(MemoryRegion *system_memory, option_rom_mr, 1); - fw_cfg =bochs_bios_init (); + fw_cfg =bochs_bios_init (guest_info->smbios_type1_defaults);rom_set_fw (fw_cfg);if (linux_boot) {
hw/i386/pc_piix.c +5 -0
@@ -58,6 +58,7 @@ static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };static bool has_pvpanic;static bool has_pci_info = true; +static bool smbios_type1_defaults = true;/* PC hardware initialisation */ static void pc_init1(MemoryRegion *system_memory,
@@ -128,6 +129,7 @@ static void pc_init1(MemoryRegion *system_memory, guest_info =pc_guest_info_init (below_4g_mem_size, above_4g_mem_size); guest_info->has_pci_info = has_pci_info; guest_info->isapc_ram_fw = !pci_enabled; + guest_info->smbios_type1_defaults = smbios_type1_defaults;/* allocate ram and load rom/bios */ if (!xen_enabled ()) {
@@ -258,6 +260,7 @@ static void pc_init_pci_1_6(QEMUMachineInitArgs *args)static void pc_init_pci_1_5 (QEMUMachineInitArgs *args) { has_pvpanic = true; + smbios_type1_defaults = false;pc_init_pci_1_6 (args); }
@@ -298,6 +301,7 @@ static void pc_init_pci_no_kvmclock(QEMUMachineInitArgs *args)const char *initrd_filename = args->initrd_filename;const char *boot_device = args->boot_device; has_pci_info = false; + smbios_type1_defaults = false;disable_kvm_pv_eoi ();enable_compat_apic_id_mode (); pc_init1(get_system_memory(),
@@ -316,6 +320,7 @@ static void pc_init_isa(QEMUMachineInitArgs *args)const char *initrd_filename = args->initrd_filename;const char *boot_device = args->boot_device; has_pci_info = false; + smbios_type1_defaults = false;if (cpu_model ==NULL ) cpu_model ="486" ;disable_kvm_pv_eoi ();
hw/i386/pc_q35.c +3 -0
@@ -48,6 +48,7 @@static bool has_pvpanic;static bool has_pci_info = true; +static bool smbios_type1_defaults = true;/* PC hardware initialisation */ static void pc_q35_init (QEMUMachineInitArgs *args)
@@ -111,6 +112,7 @@ static void pc_q35_init(QEMUMachineInitArgs *args) guest_info =pc_guest_info_init (below_4g_mem_size, above_4g_mem_size); guest_info->has_pci_info = has_pci_info; guest_info->isapc_ram_fw = false; + guest_info->smbios_type1_defaults = smbios_type1_defaults;/* allocate ram and load rom/bios */ if (!xen_enabled ()) {
@@ -227,6 +229,7 @@ static void pc_q35_init_1_6(QEMUMachineInitArgs *args)static void pc_q35_init_1_5 (QEMUMachineInitArgs *args) { has_pvpanic = true; + smbios_type1_defaults = false;pc_q35_init_1_6 (args); }
hw/i386/smbios.c +11 -1
@@ -18,6 +18,7 @@#include "qemu/config-file.h" #include "qemu/error-report.h" #include "sysemu/sysemu.h" +#include "hw/boards.h" #include "hw/i386/smbios.h" #include "hw/loader.h"
@@ -256,9 +257,18 @@ static void smbios_build_type_1_fields(void) } } -uint8_t *smbios_get_table (size_t *length) +uint8_t *smbios_get_table (size_t *length,bool type1_defaults) {if (!smbios_immutable) { +if (type1_defaults && !type1.manufacturer) { + type1.manufacturer ="QEMU" ; + } +if (type1_defaults && !type1.product) { + type1.product = current_machine->desc; + } +if (type1_defaults && !type1.version) { + type1.version = current_machine->name; + }smbios_build_type_0_fields ();smbios_build_type_1_fields ();smbios_validate_table ();
include/hw/i386/pc.h +1 -0
@@ -20,6 +20,7 @@ typedef struct PcPciInfo {struct PcGuestInfo {bool has_pci_info;bool isapc_ram_fw; +bool smbios_type1_defaults;FWCfgState *fw_cfg; };
include/hw/i386/smbios.h +1 -1
@@ -16,7 +16,7 @@#include "qemu/option.h" void smbios_entry_add (QemuOpts *opts); -uint8_t *smbios_get_table (size_t *length); +uint8_t *smbios_get_table (size_t *length,bool type1_defaults);/* * SMBIOS spec defined tables
Signature · 1 line
1.8.1.4
Re: [Qemu-devel] [PATCH v2 7/7] smbios: Set system manufacturer, product & version by default
Quoted 11 lines · On Fri, Aug 16, 2013 at 03:18:34PM +0200, [email protected] wrote:
From: Markus Armbruster <[email protected]>
Currently, we get SeaBIOS defaults: manufacturer Bochs, product Bochs, no version. Best SeaBIOS can do, but we can provide better defaults:
manufacturer QEMU, product & version taken from QEMUMachine desc and name.Take care to do this only for new machine types, of course.
Signed-off-by Markus Armbruster <[email protected]>Reviewed-by Eric Blake <[email protected]>
We can do this of course, but why is this better? It seems to expose new information to the guest for no reason, we just might come to regret it later if guests start implementing hacks keying off the version number.
Quoted 172 lines
--- hw/i386/pc.c | 6 +++--- hw/i386/pc_piix.c | 5 +++++ hw/i386/pc_q35.c | 3 +++ hw/i386/smbios.c | 12 +++++++++++- include/hw/i386/pc.h | 1 + include/hw/i386/smbios.h | 2 +- 6 files changed, 24 insertions(+), 5 deletions(-)hw/i386/pc.c +3
-3@@ -604,7 +604,7 @@ static unsigned int pc_apic_id_limit(unsigned int max_cpus)return x86_cpu_apic_id_from_index (max_cpus -1 ) +1 ; } -static FWCfgState *bochs_bios_init (void ) +static FWCfgState *bochs_bios_init (bool smbios_type1_defaults) {FWCfgState *fw_cfg;uint8_t *smbios_table;@@ -635,7 +635,7 @@ static FWCfgState *bochs_bios_init(void) acpi_tables, acpi_tables_len);fw_cfg_add_i32 (fw_cfg,FW_CFG_IRQ0_OVERRIDE ,kvm_allows_irq0_override ()); - smbios_table =smbios_get_table (&smbios_len); + smbios_table =smbios_get_table (&smbios_len, smbios_type1_defaults);if (smbios_table)fw_cfg_add_bytes (fw_cfg,FW_CFG_SMBIOS_ENTRIES , smbios_table, smbios_len);@@ -1155,7 +1155,7 @@ FWCfgState *pc_memory_init(MemoryRegion *system_memory, option_rom_mr, 1); - fw_cfg =bochs_bios_init (); + fw_cfg =bochs_bios_init (guest_info->smbios_type1_defaults);rom_set_fw (fw_cfg);if (linux_boot) {hw/i386/pc_piix.c +5
-0@@ -58,6 +58,7 @@ static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };static bool has_pvpanic;static bool has_pci_info = true; +static bool smbios_type1_defaults = true;/* PC hardware initialisation */ static void pc_init1(MemoryRegion *system_memory,@@ -128,6 +129,7 @@ static void pc_init1(MemoryRegion *system_memory, guest_info =pc_guest_info_init (below_4g_mem_size, above_4g_mem_size); guest_info->has_pci_info = has_pci_info; guest_info->isapc_ram_fw = !pci_enabled; + guest_info->smbios_type1_defaults = smbios_type1_defaults;/* allocate ram and load rom/bios */ if (!xen_enabled ()) {@@ -258,6 +260,7 @@ static void pc_init_pci_1_6(QEMUMachineInitArgs *args)static void pc_init_pci_1_5 (QEMUMachineInitArgs *args) { has_pvpanic = true; + smbios_type1_defaults = false;pc_init_pci_1_6 (args); }@@ -298,6 +301,7 @@ static void pc_init_pci_no_kvmclock(QEMUMachineInitArgs *args)const char *initrd_filename = args->initrd_filename;const char *boot_device = args->boot_device; has_pci_info = false; + smbios_type1_defaults = false;disable_kvm_pv_eoi ();enable_compat_apic_id_mode (); pc_init1(get_system_memory(),@@ -316,6 +320,7 @@ static void pc_init_isa(QEMUMachineInitArgs *args)const char *initrd_filename = args->initrd_filename;const char *boot_device = args->boot_device; has_pci_info = false; + smbios_type1_defaults = false;if (cpu_model ==NULL ) cpu_model ="486" ;disable_kvm_pv_eoi ();hw/i386/pc_q35.c +3
-0@@ -48,6 +48,7 @@static bool has_pvpanic;static bool has_pci_info = true; +static bool smbios_type1_defaults = true;/* PC hardware initialisation */ static void pc_q35_init (QEMUMachineInitArgs *args)@@ -111,6 +112,7 @@ static void pc_q35_init(QEMUMachineInitArgs *args) guest_info =pc_guest_info_init (below_4g_mem_size, above_4g_mem_size); guest_info->has_pci_info = has_pci_info; guest_info->isapc_ram_fw = false; + guest_info->smbios_type1_defaults = smbios_type1_defaults;/* allocate ram and load rom/bios */ if (!xen_enabled ()) {@@ -227,6 +229,7 @@ static void pc_q35_init_1_6(QEMUMachineInitArgs *args)static void pc_q35_init_1_5 (QEMUMachineInitArgs *args) { has_pvpanic = true; + smbios_type1_defaults = false;pc_q35_init_1_6 (args); }hw/i386/smbios.c +11
-1@@ -18,6 +18,7 @@#include "qemu/config-file.h" #include "qemu/error-report.h" #include "sysemu/sysemu.h" +#include "hw/boards.h" #include "hw/i386/smbios.h" #include "hw/loader.h" @@ -256,9 +257,18 @@ static void smbios_build_type_1_fields(void) } } -uint8_t *smbios_get_table (size_t *length) +uint8_t *smbios_get_table (size_t *length,bool type1_defaults) {if (!smbios_immutable) { +if (type1_defaults && !type1.manufacturer) { + type1.manufacturer ="QEMU" ; + } +if (type1_defaults && !type1.product) { + type1.product = current_machine->desc; + } +if (type1_defaults && !type1.version) { + type1.version = current_machine->name; + }smbios_build_type_0_fields ();smbios_build_type_1_fields ();smbios_validate_table ();include/hw/i386/pc.h +1
-0@@ -20,6 +20,7 @@ typedef struct PcPciInfo {struct PcGuestInfo {bool has_pci_info;bool isapc_ram_fw; +bool smbios_type1_defaults;FWCfgState *fw_cfg; };include/hw/i386/smbios.h +1
-1@@ -16,7 +16,7 @@#include "qemu/option.h" void smbios_entry_add (QemuOpts *opts); -uint8_t *smbios_get_table (size_t *length); +uint8_t *smbios_get_table (size_t *length,bool type1_defaults);/* * SMBIOS spec defined tables Signature · 1 line
1.8.1.4
Re: [Qemu-devel] [PATCH v2 7/7] smbios: Set system manufacturer, product & version by default
Quoted 10 lines · Michael S. Tsirkin
Quoted 9 lines · On Fri, Aug 16, 2013 at 03:18:34PM +0200, [email protected] wrote:
From: Markus Armbruster <[email protected]>
Currently, we get SeaBIOS defaults: manufacturer Bochs, product Bochs, no version. Best SeaBIOS can do, but we can provide better defaults:
manufacturer QEMU, product & version taken from QEMUMachine desc and name.Take care to do this only for new machine types, of course.
Quoted 8 lines
Quoted 2 lines
Signed-off-by Markus Armbruster <[email protected]>Reviewed-by Eric Blake <[email protected]>We can do this of course, but why is this better? It seems to expose new information to the guest for no reason, we just might come to regret it later if guests start implementing hacks keying off the version number.
Some guests (cough: some OEM builds of windows) already DO key off of SMBIOS information to determine if they are running in a valid environment. Furthermore, making this change to qemu makes it easier to decouple the strings being presented to guests by default; it's always better to have a situation where changing just qemu works, instead of having to patch both qemu and BIOS in tandem.
The choice of whether to present the different information MUST be tied to machine types (we cannot change SMBIOS data without an explicit change to a newer machine type, precisely _because_ there are guests that base their licensing decisions on constancy of BIOS information). But for a new machine type, presenting qemu as the machine type rather than being stuck to a particular SeaBIOS build seems nicer.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH v2 7/7] smbios: Set system manufacturer, product & version by default
Quoted 20 lines · Eric Blake
Quoted 10 lines · Michael S. Tsirkin
Quoted 9 lines · On Fri, Aug 16, 2013 at 03:18:34PM +0200, [email protected] wrote:
From: Markus Armbruster <[email protected]>
Currently, we get SeaBIOS defaults: manufacturer Bochs, product Bochs, no version. Best SeaBIOS can do, but we can provide better defaults:
manufacturer QEMU, product & version taken from QEMUMachine desc and name.Take care to do this only for new machine types, of course.
Quoted 8 lines
Quoted 2 lines
Signed-off-by Markus Armbruster <[email protected]>Reviewed-by Eric Blake <[email protected]>We can do this of course, but why is this better? It seems to expose new information to the guest for no reason, we just might come to regret it later if guests start implementing hacks keying off the version number.
Quoted 3 lines
Some guests (cough: some OEM builds of windows) already DO key off of SMBIOS information to determine if they are running in a valid environment.
Well they are unlikely to like either QEMU or Bochs.
Quoted 11 lines
Furthermore, making this change to qemu makes it easier to decouple the strings being presented to guests by default; it's always better to have a situation where changing just qemu works, instead of having to patch both qemu and BIOS in tandem.
The choice of whether to present the different information MUST be tied to machine types (we cannot change SMBIOS data without an explicit change to a newer machine type, precisely _because_ there are guests that base their licensing decisions on constancy of BIOS information). But for a new machine type, presenting qemu as the machine type rather than being stuck to a particular SeaBIOS build seems nicer.
Yes but why change anything at all?
We have command line flags to set these fields for whatever you want to boot OEM windows - which is highly unlikely to match any QEMU version. Why isn't this enough?
Quoted 4 lines
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Eric,
Quoted 8 lines · On 08/16/13 15:18, [email protected] wrote:
From: Markus Armbruster <[email protected]>
This gets rid of one of the last
get_param_value()users, makes multiple -smbios work sanely, cleans up the gross side effect inqemu_uuid_parse(), and more. Topped off with a little feature in the last patch.v2: Rebase, only last patch had conflicts
can you please re-ack this? You acked v2:
http://thread.gmane.org/gmane.comp.emulators.qemu/222747
(And I don't have the slightest clue why it hasn't been merged after your Reviewed-by; it was posted, and reviewed, and pinged, before the hard freeze for 1.6)
If you don't have the time, I can review it from scratch.
Sometime.
Hopefully.
Thanks,
Laszlo
Quoted 10 lines · Laszlo Ersek
Eric,
Quoted 7 lines · On 08/16/13 15:18, [email protected] wrote:
From: Markus Armbruster <[email protected]>
This gets rid of one of the last
get_param_value()users, makes multiple -smbios work sanely, cleans up the gross side effect inqemu_uuid_parse(), and more. Topped off with a little feature in the last patch.
Quoted 5 lines
Quoted 1 line
v2: Rebase, only last patch had conflicts
can you please re-ack this? You acked v2:
My prior review still stands. The series looks good to me.
Quoted 4 lines
(And I don't have the slightest clue why it hasn't been merged after your Reviewed-by; it was posted, and reviewed, and pinged, before the hard freeze for 1.6)
I have no idea what happened either.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 8 lines · On Fri, Aug 16, 2013 at 03:18:27PM +0200, [email protected] wrote:
From: Markus Armbruster <[email protected]>
This gets rid of one of the last
get_param_value()users, makes multiple -smbios work sanely, cleans up the gross side effect inqemu_uuid_parse(), and more. Topped off with a little feature in the last patch.v2: Rebase, only last patch had conflicts
OK my thinking at this point is:
patches 1-6 are ready
Any objections?
patch 7 - I would prefer some way to explicitly set default smbios manufacturer/version in machine type and set these from machine type, instead of the smbios_type1_defaults boolean.
Would you like
- me to apply 1-6 and keep working on 7?
- wait for you to repost v3?
- look for another maintainer to take patchset as is (if someone cares to, I won't object)?
Quoted 24 lines
Markus Armbruster (7):
smbios: Normalize smbios_entry_add()'s error handling to exit(1)
smbios: Convert to QemuOpts
smbios: Improve diagnostics for conflicting entries
smbios: Make multiple -smbios type= accumulate sanely
smbios: Factor outsmbios_maybe_add_str()
vl: Setcurrent_machineearly
smbios: Set system manufacturer, product & version by defaultarch_init.c | 9 +- hw/i386/pc.c | 6 +- hw/i386/pc_piix.c | 5 + hw/i386/pc_q35.c | 3 + hw/i386/smbios.c | 349 ++++++++++++++++++++++++++++++++------------- include/hw/i386/pc.h | 1 + include/hw/i386/smbios.h | 7 +- include/sysemu/arch_init.h | 2 +- include/sysemu/sysemu.h | 1 + vl.c | 8 +- 10 files changed, 276 insertions(+), 115 deletions(-)Signature · 1 line
1.8.1.4
[Note cc: Andreas]
Quoted 10 lines · Michael S. Tsirkin
Quoted 8 lines · On Fri, Aug 16, 2013 at 03:18:27PM +0200, [email protected] wrote:
From: Markus Armbruster <[email protected]>
This gets rid of one of the last
get_param_value()users, makes multiple -smbios work sanely, cleans up the gross side effect inqemu_uuid_parse(), and more. Topped off with a little feature in the last patch.v2: Rebase, only last patch had conflicts
Quoted 7 lines
OK my thinking at this point is:
patches 1-6 are ready
Any objections?
patch 7 - I would prefer some way to explicitly set default smbios manufacturer/version in machine type and set these from machine type, instead of thesmbios_type1_defaultsboolean.
Are you asking for a new QEMUMachine member holding manufacturer (either "Bochs", "QEMU" or null), and new members holding product and version (either null or same value as existing members desc and version, at least now)? Or just for moving smbios_type1_defaults from init function into QEMUMachine?
Quoted 5 lines
Would you like
- me to apply 1-6 and keep working on 7?
- wait for you to repost v3?
- look for another maintainer to take patchset as is (if someone cares to, I won't object)?
Waiting for another maintainer after waiting >2 months for *any* maintainer doesn't strike me as a good idea %-}
I'm totally fine with you taking just PATCH 1-5. PATCH 6, however, should not be applied without PATCH 7. Andreas doesn't like PATCH 6, and overruling his dislike without an actual use for it (which comes only in PATCH 7) isn't nice.
Quoted 22 lines · Markus Armbruster
[Note cc: Andreas]
Quoted 10 lines · Michael S. Tsirkin
Quoted 8 lines · On Fri, Aug 16, 2013 at 03:18:27PM +0200, [email protected] wrote:
From: Markus Armbruster <[email protected]>
This gets rid of one of the last
get_param_value()users, makes multiple -smbios work sanely, cleans up the gross side effect inqemu_uuid_parse(), and more. Topped off with a little feature in the last patch.v2: Rebase, only last patch had conflicts
Quoted 7 lines
OK my thinking at this point is:
patches 1-6 are ready
Any objections?
patch 7 - I would prefer some way to explicitly set default smbios manufacturer/version in machine type and set these from machine type, instead of thesmbios_type1_defaultsboolean.
Quoted 4 lines
Are you asking for a new QEMUMachine member holding manufacturer (either "Bochs", "QEMU" or null), and new members holding product and version (either null or same value as existing members desc and version, at least now)?
Yes, I think we can live with this one.
Though I would really prefer a property of some device.
Quoted 9 lines
Or just for moving
smbios_type1_defaultsfrom init function into QEMUMachine?Quoted 5 lines
Would you like
- me to apply 1-6 and keep working on 7?
- wait for you to repost v3?
- look for another maintainer to take patchset as is (if someone cares to, I won't object)?
Quoted 7 lines
Waiting for another maintainer after waiting >2 months for *any* maintainer doesn't strike me as a good idea %-}
I'm totally fine with you taking just PATCH 1-5. PATCH 6, however, should not be applied without PATCH 7. Andreas doesn't like PATCH 6, and overruling his dislike without an actual use for it (which comes only in PATCH 7) isn't nice.
I missed this fact, thanks for pointing it out. So please arrive at consensus with Andreas re PATCH 6.
Michael S. Tsirkin
AppliedQuoted 8 lines · On Fri, Aug 16, 2013 at 03:18:27PM +0200, [email protected] wrote:
From: Markus Armbruster <[email protected]>
This gets rid of one of the last
get_param_value()users, makes multiple -smbios work sanely, cleans up the gross side effect inqemu_uuid_parse(), and more. Topped off with a little feature in the last patch.v2: Rebase, only last patch had conflicts
I applied patch 1-5 on my tree, thanks everyone.
Quoted 24 lines
Markus Armbruster (7):
smbios: Normalize smbios_entry_add()'s error handling to exit(1)
smbios: Convert to QemuOpts
smbios: Improve diagnostics for conflicting entries
smbios: Make multiple -smbios type= accumulate sanely
smbios: Factor outsmbios_maybe_add_str()
vl: Setcurrent_machineearly
smbios: Set system manufacturer, product & version by defaultarch_init.c | 9 +- hw/i386/pc.c | 6 +- hw/i386/pc_piix.c | 5 + hw/i386/pc_q35.c | 3 + hw/i386/smbios.c | 349 ++++++++++++++++++++++++++++++++------------- include/hw/i386/pc.h | 1 + include/hw/i386/smbios.h | 7 +- include/sysemu/arch_init.h | 2 +- include/sysemu/sysemu.h | 1 + vl.c | 8 +- 10 files changed, 276 insertions(+), 115 deletions(-)Signature · 1 line
1.8.1.4