Received: from eggs.gnu.org ([208.118.235.92]:57249) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T9sII-0006Pz-QO for qemu-devel@nongnu.org; Fri, 07 Sep 2012 02:44:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T9sIH-00081m-F2 for qemu-devel@nongnu.org; Fri, 07 Sep 2012 02:43:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37764) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T9sIH-00081i-6Z for qemu-devel@nongnu.org; Fri, 07 Sep 2012 02:43:57 -0400 From: Markus Armbruster References: <1346874721-15536-1-git-send-email-aliguori@us.ibm.com> Date: Fri, 07 Sep 2012 08:43:53 +0200 In-Reply-To: <1346874721-15536-1-git-send-email-aliguori@us.ibm.com> (Anthony Liguori's message of "Wed, 5 Sep 2012 14:52:01 -0500") Message-ID: <87zk52nxhy.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] smbios: convert to use QemuOpts List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: qemu-devel@nongnu.org Hello, this is your friendly remote compile service. Anthony Liguori writes: > Signed-off-by: Anthony Liguori > --- > 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 > } >=20=20 > -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 > } >=20=20 > 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; >=20=20 > 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); > } >=20=20 > -static void smbios_build_type_0_fields(const char *t) > +static void smbios_build_type_0_fields(QemuOpts *opts) > { > char buf[1024]; >=20=20 > - if (get_param_value(buf, sizeof(buf), "vendor", t)) > + if ((buf =3D qemu_opt_get(opts, "vendor"))) { error: incompatible types when assigning to type =E2=80=98char[1024]=E2=80= =99 from type =E2=80=98const char *=E2=80=99 > 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 =3D 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 =3D 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 =3D 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) > } > } >=20=20 > -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; >=20=20 > - if (get_param_value(buf, sizeof(buf), "manufacturer", t)) > + if ((buf =3D qemu_opt_get(opts, "manufacturer"))) { warning: passing argument 4 of =E2=80=98smbios_add_field=E2=80=99 discards = =E2=80=98const=E2=80=99 qualifier from pointer target type [enabled by defa= ult] > 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 =3D 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 =3D 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 =3D 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 =3D qemu_opt_get(opts, "uuid"))) { > if (qemu_uuid_parse(buf, qemu_uuid) !=3D 0) { > fprintf(stderr, "Invalid SMBIOS UUID string\n"); > exit(1); > } > } > - if (get_param_value(buf, sizeof(buf), "sku", t)) > + if ((buf =3D qemu_opt_get(opts, "sku"))) { > smbios_add_field(1, offsetof(struct smbios_type_1, sku_number_st= r), > strlen(buf) + 1, buf); > - if (get_param_value(buf, sizeof(buf), "family", t)) > + } > + if ((buf =3D qemu_opt_get(opts, "family"))) { > smbios_add_field(1, offsetof(struct smbios_type_1, family_str), > strlen(buf) + 1, buf); > + } > } >=20=20 > -int smbios_entry_add(const char *t) > +int smbios_entry_add(QemuOpts *opts) > { > - char buf[1024]; > + const char *buf; >=20=20 > - if (get_param_value(buf, sizeof(buf), "file", t)) { > + if ((buf =3D qemu_opt_get(opts, "file"))) { > struct smbios_structure_header *header; > struct smbios_table *table; > int size =3D get_image_size(buf); > @@ -203,7 +212,7 @@ int smbios_entry_add(const char *t) > table->header.type =3D SMBIOS_TABLE_ENTRY; > table->header.length =3D cpu_to_le16(sizeof(*table) + size); >=20=20 > - if (load_image(buf, table->data) !=3D size) { > + if (load_image(filename, table->data) !=3D size) { error: =E2=80=98filename=E2=80=99 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; > } >=20=20 > - if (get_param_value(buf, sizeof(buf), "type", t)) { > - unsigned long type =3D strtoul(buf, NULL, 0); > + if (qemu_opt_get(opts, "type")) { > + unsigned long type =3D qemu_opt_get_number(opts, "type"); error: too few arguments to function =E2=80=98qemu_opt_get_number=E2=80=99 > 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 t= ype " [...]