From: Beth Kon <eak@us.ibm.com>
To: qemu-devel@nongnu.org
Cc: Beth Kon <eak@us.ibm.com>, alex.williamson@hp.com
Subject: [Qemu-devel] [PATCH][RESEND] Add/Fix command-line checks for smbios options v2
Date: Fri, 31 Jul 2009 13:49:14 -0400 [thread overview]
Message-ID: <1249062554-26912-1-git-send-email-eak@us.ibm.com> (raw)
- One type 4 table is required per cpu. Add a check for this.
- Fix check for smbios file.
Changes from v1:
- static designation of smbios_validate_table, and remove whitespace
Signed-off-by: Beth Kon <eak@us.ibm.com>
--
diff --git a/hw/smbios.c b/hw/smbios.c
index ced90ce..e28beba 100644
--- a/hw/smbios.c
+++ b/hw/smbios.c
@@ -40,9 +40,20 @@ struct smbios_table {
static uint8_t *smbios_entries;
static size_t smbios_entries_len;
+static int smbios_type4_count = 0;
+
+static void smbios_validate_table(void)
+{
+ if (smbios_type4_count && smbios_type4_count != smp_cpus) {
+ fprintf(stderr,
+ "Number of SMBIOS Type 4 tables must match cpu count.\n");
+ exit(1);
+ }
+}
uint8_t *smbios_get_table(size_t *length)
{
+ smbios_validate_table();
*length = smbios_entries_len;
return smbios_entries;
}
@@ -173,8 +184,8 @@ int smbios_entry_add(const char *t)
struct smbios_table *table;
int size = get_image_size(buf);
- if (size < sizeof(struct smbios_structure_header)) {
- fprintf(stderr, "Cannot read smbios file %s", buf);
+ if (size == -1 || size < sizeof(struct smbios_structure_header)) {
+ fprintf(stderr, "Cannot read smbios file %s\n", buf);
exit(1);
}
@@ -196,6 +207,9 @@ int smbios_entry_add(const char *t)
header = (struct smbios_structure_header *)(table->data);
smbios_check_collision(header->type, SMBIOS_TABLE_ENTRY);
+ if (header->type == 4) {
+ smbios_type4_count++;
+ }
smbios_entries_len += sizeof(*table) + size;
(*(uint16_t *)smbios_entries) =
reply other threads:[~2009-07-31 17:48 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1249062554-26912-1-git-send-email-eak@us.ibm.com \
--to=eak@us.ibm.com \
--cc=alex.williamson@hp.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).