From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M9zbV-0002Kg-9g for qemu-devel@nongnu.org; Fri, 29 May 2009 06:46:25 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M9zbP-0002Du-Mp for qemu-devel@nongnu.org; Fri, 29 May 2009 06:46:23 -0400 Received: from [199.232.76.173] (port=49066 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M9zbP-0002Db-Fr for qemu-devel@nongnu.org; Fri, 29 May 2009 06:46:19 -0400 Received: from e2.ny.us.ibm.com ([32.97.182.142]:35450) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1M9zbO-0007MP-Us for qemu-devel@nongnu.org; Fri, 29 May 2009 06:46:19 -0400 Received: from d01relay02.pok.ibm.com (d01relay02.pok.ibm.com [9.56.227.234]) by e2.ny.us.ibm.com (8.13.1/8.13.1) with ESMTP id n4TAg0lf025241 for ; Fri, 29 May 2009 06:42:00 -0400 Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay02.pok.ibm.com (8.13.8/8.13.8/NCO v9.2) with ESMTP id n4TAkFEF222814 for ; Fri, 29 May 2009 06:46:15 -0400 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n4TAkFmQ003628 for ; Fri, 29 May 2009 06:46:15 -0400 From: Beth Kon Date: Fri, 29 May 2009 06:48:18 -0400 Message-Id: <1243594098-6772-1-git-send-email-eak@us.ibm.com> Subject: [Qemu-devel] [PATCH] 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 (Resending with "v2" in subject line) - 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..57d2c2d 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; + +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 +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) =