* [Qemu-devel] [PATCH] Add/Fix command-line checks for smbios options
@ 2009-05-28 17:53 Beth Kon
2009-05-28 18:02 ` [Qemu-devel] " Alex Williamson
0 siblings, 1 reply; 2+ messages in thread
From: Beth Kon @ 2009-05-28 17:53 UTC (permalink / raw)
To: qemu-devel; +Cc: Beth Kon, alex.williamson
- One type 4 table is required per cpu. Add a check for this.
- Fix check for smbios file.
Signed-off-by: Beth Kon <eak@us.ibm.com>
--
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) =
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [Qemu-devel] Re: [PATCH] Add/Fix command-line checks for smbios options
2009-05-28 17:53 [Qemu-devel] [PATCH] Add/Fix command-line checks for smbios options Beth Kon
@ 2009-05-28 18:02 ` Alex Williamson
0 siblings, 0 replies; 2+ messages in thread
From: Alex Williamson @ 2009-05-28 18:02 UTC (permalink / raw)
To: Beth Kon; +Cc: qemu-devel
On Thu, 2009-05-28 at 13:53 -0400, Beth Kon wrote:
> - One type 4 table is required per cpu. Add a check for this.
> - Fix check for smbios file.
>
> Signed-off-by: Beth Kon <eak@us.ibm.com>
> --
>
> 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) {
static?
> + if (smbios_type4_count && smbios_type4_count != smp_cpus) {
> + fprintf(stderr,
> + "Number of SMBIOS Type 4 tables must match cpu count.\n");
extra space.
Looks ok otherwise. Thanks,
Alex
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-05-28 18:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-28 17:53 [Qemu-devel] [PATCH] Add/Fix command-line checks for smbios options Beth Kon
2009-05-28 18:02 ` [Qemu-devel] " Alex Williamson
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).