From: Eric Blake <eblake@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: aliguori@us.ibm.com, lersek@redhat.com, qemu-devel@nongnu.org,
ehabkost@redhat.com
Subject: Re: [Qemu-devel] [PATCH 4/7] smbios: Make multiple -smbios type= accumulate sanely
Date: Wed, 17 Jul 2013 13:21:22 -0600 [thread overview]
Message-ID: <51E6EEB2.4060603@redhat.com> (raw)
In-Reply-To: <1374081369-1511-5-git-send-email-armbru@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2652 bytes --]
On 07/17/2013 11:16 AM, Markus Armbruster wrote:
> 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>
> ---
> }
> - val = qemu_opt_get(opts, "release");
> - if (val) {
> - if (sscanf(val, "%hhu.%hhu", &major, &minor) != 2) {
> - error_report("Invalid release");
> - exit(1);
> @@ -348,7 +353,18 @@ void smbios_entry_add(QemuOpts *opts)
> error_report("%s", error_get_pretty(local_err));
> exit(1);
> }
> - smbios_build_type_0_fields(opts);
> + save_opt(&type0.vendor, opts, "vendor");
> + save_opt(&type0.version, opts, "version");
> + save_opt(&type0.date, opts, "date");
> +
> + val = qemu_opt_get(opts, "release");
> + if (val) {
> + if (sscanf(val, "%hhu.%hhu", &type0.major, &type0.minor) != 2) {
sscanf() is lousy at detecting overflow. Since this is just code
motion, you can get away without changing it now, but it would be nice
if you at least considered switching this to use [a sane wrapper around]
strtol() for proper overflow detection of user input at some point in
your refactoring.
> + val = qemu_opt_get(opts, "uuid");
> + if (val) {
> + if (qemu_uuid_parse(val, qemu_uuid) != 0) {
> + error_report("Invalid UUID");
> + exit(1);
My comments from earlier in the series about preferring
exit(EXIT_FAILURE) apply here as well.
Neither issue is a show-stopper, so
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 621 bytes --]
next prev parent reply other threads:[~2013-07-17 19:21 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-17 17:16 [Qemu-devel] [PATCH 0/7] smbios cleanup & nicer defaults for type 1 Markus Armbruster
2013-07-17 17:16 ` [Qemu-devel] [PATCH 1/7] smbios: Normalize smbios_entry_add()'s error handling to exit(1) Markus Armbruster
2013-07-17 17:53 ` Eric Blake
2013-07-17 17:16 ` [Qemu-devel] [PATCH 2/7] smbios: Convert to QemuOpts Markus Armbruster
2013-07-17 19:04 ` Eric Blake
2013-07-17 17:16 ` [Qemu-devel] [PATCH 3/7] smbios: Improve diagnostics for conflicting entries Markus Armbruster
2013-07-17 19:09 ` Eric Blake
2013-07-17 17:16 ` [Qemu-devel] [PATCH 4/7] smbios: Make multiple -smbios type= accumulate sanely Markus Armbruster
2013-07-17 19:21 ` Eric Blake [this message]
2013-07-17 20:31 ` Markus Armbruster
2013-07-17 17:16 ` [Qemu-devel] [PATCH 5/7] smbios: Factor out smbios_maybe_add_str() Markus Armbruster
2013-07-17 19:22 ` Eric Blake
2013-07-17 17:16 ` [Qemu-devel] [PATCH 6/7] vl: Set current_machine early Markus Armbruster
2013-07-17 19:23 ` Eric Blake
2013-07-17 17:16 ` [Qemu-devel] [PATCH 7/7] smbios: Set system manufacturer, product & version by default Markus Armbruster
2013-07-17 19:24 ` Eric Blake
2013-07-30 6:01 ` [Qemu-devel] [PATCH 0/7] smbios cleanup & nicer defaults for type 1 Markus Armbruster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=51E6EEB2.4060603@redhat.com \
--to=eblake@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=armbru@redhat.com \
--cc=ehabkost@redhat.com \
--cc=lersek@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).