From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MWwDf-0006fM-17 for qemu-devel@nongnu.org; Fri, 31 Jul 2009 13:48:39 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MWwDZ-0006fA-H6 for qemu-devel@nongnu.org; Fri, 31 Jul 2009 13:48:37 -0400 Received: from [199.232.76.173] (port=37157 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MWwDZ-0006f7-AJ for qemu-devel@nongnu.org; Fri, 31 Jul 2009 13:48:33 -0400 Received: from e4.ny.us.ibm.com ([32.97.182.144]:43932) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MWwDY-0001BT-Ov for qemu-devel@nongnu.org; Fri, 31 Jul 2009 13:48:32 -0400 Received: from d01relay02.pok.ibm.com (d01relay02.pok.ibm.com [9.56.227.234]) by e4.ny.us.ibm.com (8.14.3/8.13.1) with ESMTP id n6VHgZ3F032089 for ; Fri, 31 Jul 2009 13:42:35 -0400 Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay02.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id n6VHmU2T257496 for ; Fri, 31 Jul 2009 13:48:30 -0400 Received: from d01av01.pok.ibm.com (loopback [127.0.0.1]) by d01av01.pok.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n6VHmTqN018772 for ; Fri, 31 Jul 2009 13:48:29 -0400 From: Beth Kon Date: Fri, 31 Jul 2009 13:49:14 -0400 Message-Id: <1249062554-26912-1-git-send-email-eak@us.ibm.com> Subject: [Qemu-devel] [PATCH][RESEND] Add/Fix command-line checks for smbios options v2 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. Changes from v1: - static designation of smbios_validate_table, and remove whitespace Signed-off-by: Beth Kon -- 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) =