From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M9jmF-00061K-PG for qemu-devel@nongnu.org; Thu, 28 May 2009 13:52:27 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M9jmB-00060d-B5 for qemu-devel@nongnu.org; Thu, 28 May 2009 13:52:27 -0400 Received: from [199.232.76.173] (port=52788 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M9jmB-00060a-8E for qemu-devel@nongnu.org; Thu, 28 May 2009 13:52:23 -0400 Received: from e39.co.us.ibm.com ([32.97.110.160]:56773) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1M9jmA-0008WM-Kb for qemu-devel@nongnu.org; Thu, 28 May 2009 13:52:22 -0400 Received: from d03relay03.boulder.ibm.com (d03relay03.boulder.ibm.com [9.17.195.228]) by e39.co.us.ibm.com (8.13.1/8.13.1) with ESMTP id n4SHmOKH012719 for ; Thu, 28 May 2009 11:48:24 -0600 Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d03relay03.boulder.ibm.com (8.13.8/8.13.8/NCO v9.2) with ESMTP id n4SHq1B7038972 for ; Thu, 28 May 2009 11:52:04 -0600 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n4SHpvsv009942 for ; Thu, 28 May 2009 11:51:57 -0600 From: Beth Kon Date: Thu, 28 May 2009 13:53:56 -0400 Message-Id: <1243533236-27813-1-git-send-email-eak@us.ibm.com> Subject: [Qemu-devel] [PATCH] Add/Fix command-line checks for smbios options List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Beth Kon , alex.williamson@hp.com - One type 4 table is required per cpu. Add a check for this. - Fix check for smbios file. Signed-off-by: Beth Kon -- diff --git a/hw/smbios.c b/hw/smbios.c index ced90ce..2bc5c67 100644 --- a/hw/smbios.c +++ b/hw/smbios.c @@ -40,9 +40,19 @@ struct smbios_table { static uint8_t *smbios_entries; static size_t smbios_entries_len; +static int smbios_type4_count = 0; + +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 +183,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 +206,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) =