From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:56662) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T9yDJ-0006aO-K6 for qemu-devel@nongnu.org; Fri, 07 Sep 2012 09:03:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T9yDA-0004Yq-R2 for qemu-devel@nongnu.org; Fri, 07 Sep 2012 09:03:13 -0400 Received: from e5.ny.us.ibm.com ([32.97.182.145]:59955) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T9yDA-0004XZ-MP for qemu-devel@nongnu.org; Fri, 07 Sep 2012 09:03:04 -0400 Received: from /spool/local by e5.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 7 Sep 2012 09:02:48 -0400 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id B29636E8044 for ; Fri, 7 Sep 2012 09:02:26 -0400 (EDT) Received: from d03av04.boulder.ibm.com (d03av04.boulder.ibm.com [9.17.195.170]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q87D2Pv3156324 for ; Fri, 7 Sep 2012 09:02:26 -0400 Received: from d03av04.boulder.ibm.com (loopback [127.0.0.1]) by d03av04.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q87D2MGF029119 for ; Fri, 7 Sep 2012 07:02:23 -0600 From: Anthony Liguori In-Reply-To: <87zk52nxhy.fsf@blackfin.pond.sub.org> References: <1346874721-15536-1-git-send-email-aliguori@us.ibm.com> <87zk52nxhy.fsf@blackfin.pond.sub.org> Date: Fri, 07 Sep 2012 08:02:13 -0500 Message-ID: <87ligmhtpm.fsf@codemonkey.ws> 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: Markus Armbruster Cc: qemu-devel@nongnu.org Markus Armbruster writes: > Hello, this is your friendly remote compile service. dirty tree + git-send-email =3D=3D 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 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 le= n, 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 discard= s =E2=80=98const=E2=80=99 qualifier from pointer target type [enabled by de= fault] > >> 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_numbe= r_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_s= tr), >> 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 = type " > [...]