qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] smbios: convert to use QemuOpts


From: Anthony Liguori
Subject: Re: [Qemu-devel] [PATCH] smbios: convert to use QemuOpts
Date: Fri, 07 Sep 2012 08:02:13 -0500
User-agent: Notmuch/0.13.2+93~ged93d79 (http://notmuchmail.org) Emacs/23.3.1 (x86_64-pc-linux-gnu)

Markus Armbruster <address@hidden> writes:

> Hello, this is your friendly remote compile service.

dirty tree + git-send-email == FAIL

Sorry for the noise.  At any rate, I've abandoned this patch and picked
up Paolo's tree.  I'll post the full series this afternoon.  I'm still
playing around with some additional cleanup.

https://github.com/aliguori/qemu/tree/qemuopts.2

Regards,

Anthony Liguori

>
> Anthony Liguori <address@hidden> writes:
>
>> Signed-off-by: Anthony Liguori <address@hidden>
>> ---
>>  arch_init.c   |   10 +++++-----
>>  arch_init.h   |    2 +-
>>  hw/smbios.c   |   53 +++++++++++++++++++++++++++++++----------------------
>>  hw/smbios.h   |    2 +-
>>  qemu-config.c |   50 ++++++++++++++++++++++++++++++++++++++++++++++++++
>>  vl.c          |    4 +++-
>>  6 files changed, 91 insertions(+), 30 deletions(-)
>>
>> diff --git a/arch_init.c b/arch_init.c
>> index 5a1173e..e43ace9 100644
>> --- a/arch_init.c
>> +++ b/arch_init.c
>> @@ -1033,13 +1033,13 @@ void do_acpitable_option(const char *optarg)
>>  #endif
>>  }
>>  
>> -void do_smbios_option(const char *optarg)
>> +int do_smbios_option(QemuOpts *opts, void *opaque)
>>  {
>>  #ifdef TARGET_I386
>> -    if (smbios_entry_add(optarg) < 0) {
>> -        fprintf(stderr, "Wrong smbios provided\n");
>> -        exit(1);
>> -    }
>> +    return smbios_entry_add(opts);
>> +#else
>> +    fprintf(stderr, "-smbios option not supported on this platform\n");
>> +    return -ENOSYS;
>>  #endif
>>  }
>>  
>> diff --git a/arch_init.h b/arch_init.h
>> index d9c572a..2dce578 100644
>> --- a/arch_init.h
>> +++ b/arch_init.h
>> @@ -26,7 +26,7 @@ extern const uint32_t arch_type;
>>  
>>  void select_soundhw(const char *optarg);
>>  void do_acpitable_option(const char *optarg);
>> -void do_smbios_option(const char *optarg);
>> +int do_smbios_option(QemuOpts *opts, void *opaque);
>>  void cpudef_init(void);
>>  int audio_available(void);
>>  void audio_init(ISABus *isa_bus, PCIBus *pci_bus);
>> diff --git a/hw/smbios.c b/hw/smbios.c
>> index c57237d..095bccc 100644
>> --- a/hw/smbios.c
>> +++ b/hw/smbios.c
>> @@ -124,21 +124,24 @@ void smbios_add_field(int type, int offset, int len, 
>> void *data)
>>              cpu_to_le16(le16_to_cpu(*(uint16_t *)smbios_entries) + 1);
>>  }
>>  
>> -static void smbios_build_type_0_fields(const char *t)
>> +static void smbios_build_type_0_fields(QemuOpts *opts)
>>  {
>>      char buf[1024];
>>  
>> -    if (get_param_value(buf, sizeof(buf), "vendor", t))
>> +    if ((buf = qemu_opt_get(opts, "vendor"))) {
>
>
> error: incompatible types when assigning to type ‘char[1024]’ from type 
> ‘const char *’
>
>>          smbios_add_field(0, offsetof(struct smbios_type_0, vendor_str),
>>                           strlen(buf) + 1, buf);
>> -    if (get_param_value(buf, sizeof(buf), "version", t))
>> +    }
>> +    if ((buf = qemu_opt_get(opts, "version"))) {
>>          smbios_add_field(0, offsetof(struct smbios_type_0, 
>> bios_version_str),
>>                           strlen(buf) + 1, buf);
>> -    if (get_param_value(buf, sizeof(buf), "date", t))
>> +    }
>> +    if ((buf = qemu_opt_get(opts, "date"))) {
>>          smbios_add_field(0, offsetof(struct smbios_type_0,
>>                                       bios_release_date_str),
>>                                       strlen(buf) + 1, buf);
>> -    if (get_param_value(buf, sizeof(buf), "release", t)) {
>> +    }
>> +    if ((buf = qemu_opt_get(opts, "release"))) {
>>          int major, minor;
>>          sscanf(buf, "%d.%d", &major, &minor);
>>          smbios_add_field(0, offsetof(struct smbios_type_0,
>> @@ -148,41 +151,47 @@ static void smbios_build_type_0_fields(const char *t)
>>      }
>>  }
>>  
>> -static void smbios_build_type_1_fields(const char *t)
>> +static void smbios_build_type_1_fields(QemuOpts *opts)
>>  {
>> -    char buf[1024];
>> +    const char *buf;
>>  
>> -    if (get_param_value(buf, sizeof(buf), "manufacturer", t))
>> +    if ((buf = qemu_opt_get(opts, "manufacturer"))) {
>
> warning: passing argument 4 of ‘smbios_add_field’ discards ‘const’ qualifier 
> from pointer target type [enabled by default]
>
>>          smbios_add_field(1, offsetof(struct smbios_type_1, 
>> manufacturer_str),
>>                           strlen(buf) + 1, buf);
>> -    if (get_param_value(buf, sizeof(buf), "product", t))
>> +    }
>> +    if ((buf = qemu_opt_get(opts, "product"))) {
>>          smbios_add_field(1, offsetof(struct smbios_type_1, 
>> product_name_str),
>>                           strlen(buf) + 1, buf);
>> -    if (get_param_value(buf, sizeof(buf), "version", t))
>> +    }
>> +    if ((buf = qemu_opt_get(opts, "version"))) {
>>          smbios_add_field(1, offsetof(struct smbios_type_1, version_str),
>>                           strlen(buf) + 1, buf);
>> -    if (get_param_value(buf, sizeof(buf), "serial", t))
>> +    }
>> +    if ((buf = qemu_opt_get(opts, "serial"))) {
>>          smbios_add_field(1, offsetof(struct smbios_type_1, 
>> serial_number_str),
>>                           strlen(buf) + 1, buf);
>> -    if (get_param_value(buf, sizeof(buf), "uuid", t)) {
>> +    }
>> +    if ((buf = qemu_opt_get(opts, "uuid"))) {
>>          if (qemu_uuid_parse(buf, qemu_uuid) != 0) {
>>              fprintf(stderr, "Invalid SMBIOS UUID string\n");
>>              exit(1);
>>          }
>>      }
>> -    if (get_param_value(buf, sizeof(buf), "sku", t))
>> +    if ((buf = qemu_opt_get(opts, "sku"))) {
>>          smbios_add_field(1, offsetof(struct smbios_type_1, sku_number_str),
>>                           strlen(buf) + 1, buf);
>> -    if (get_param_value(buf, sizeof(buf), "family", t))
>> +    }
>> +    if ((buf = qemu_opt_get(opts, "family"))) {
>>          smbios_add_field(1, offsetof(struct smbios_type_1, family_str),
>>                           strlen(buf) + 1, buf);
>> +    }
>>  }
>>  
>> -int smbios_entry_add(const char *t)
>> +int smbios_entry_add(QemuOpts *opts)
>>  {
>> -    char buf[1024];
>> +    const char *buf;
>>  
>> -    if (get_param_value(buf, sizeof(buf), "file", t)) {
>> +    if ((buf = qemu_opt_get(opts, "file"))) {
>>          struct smbios_structure_header *header;
>>          struct smbios_table *table;
>>          int size = get_image_size(buf);
>> @@ -203,7 +212,7 @@ int smbios_entry_add(const char *t)
>>          table->header.type = SMBIOS_TABLE_ENTRY;
>>          table->header.length = cpu_to_le16(sizeof(*table) + size);
>>  
>> -        if (load_image(buf, table->data) != size) {
>> +        if (load_image(filename, table->data) != size) {
>
> error: ‘filename’ undeclared (first use in this function)
>
>>              fprintf(stderr, "Failed to load smbios file %s", buf);
>>              exit(1);
>>          }
>> @@ -220,14 +229,14 @@ int smbios_entry_add(const char *t)
>>          return 0;
>>      }
>>  
>> -    if (get_param_value(buf, sizeof(buf), "type", t)) {
>> -        unsigned long type = strtoul(buf, NULL, 0);
>> +    if (qemu_opt_get(opts, "type")) {
>> +        unsigned long type = qemu_opt_get_number(opts, "type");
>
> error: too few arguments to function ‘qemu_opt_get_number’
>
>>          switch (type) {
>>          case 0:
>> -            smbios_build_type_0_fields(t);
>> +            smbios_build_type_0_fields(opts);
>>              return 0;
>>          case 1:
>> -            smbios_build_type_1_fields(t);
>> +            smbios_build_type_1_fields(opts);
>>              return 0;
>>          default:
>>              fprintf(stderr, "Don't know how to build fields for SMBIOS type 
>> "
> [...]




reply via email to

[Prev in Thread] Current Thread [Next in Thread]