* [Qemu-devel] [PATCH] smbios: convert to use QemuOpts
@ 2012-09-05 19:52 Anthony Liguori
2012-09-06 13:18 ` Paolo Bonzini
2012-09-07 6:43 ` Markus Armbruster
0 siblings, 2 replies; 4+ messages in thread
From: Anthony Liguori @ 2012-09-05 19:52 UTC (permalink / raw)
To: qemu-devel; +Cc: Anthony Liguori
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
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"))) {
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"))) {
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) {
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");
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 "
diff --git a/hw/smbios.h b/hw/smbios.h
index 94e3641..6392fbe 100644
--- a/hw/smbios.h
+++ b/hw/smbios.h
@@ -13,7 +13,7 @@
*
*/
-int smbios_entry_add(const char *t);
+int smbios_entry_add(QemuOpts *opts);
void smbios_add_field(int type, int offset, int len, void *data);
uint8_t *smbios_get_table(size_t *length);
diff --git a/qemu-config.c b/qemu-config.c
index c05ffbc..3031012 100644
--- a/qemu-config.c
+++ b/qemu-config.c
@@ -643,6 +643,55 @@ QemuOptsList qemu_boot_opts = {
},
};
+QemuOptsList qemu_smbios_opts = {
+ .name = "smbios",
+ .head = QTAILQ_HEAD_INITIALIZER(qemu_smbios_opts.head),
+ .desc = {
+ {
+ .name = "file",
+ .type = QEMU_OPT_STRING,
+ }, {
+ .name = "type",
+ .type = QEMU_OPT_NUMBER,
+ }, {
+ .name = "manufacturer",
+ .type = QEMU_OPT_STRING,
+ }, {
+ .name = "product",
+ .type = QEMU_OPT_STRING,
+ }, {
+ .name = "version",
+ .type = QEMU_OPT_STRING,
+ }, {
+ .name = "serial",
+ .type = QEMU_OPT_STRING,
+ }, {
+ .name = "uuid",
+ .type = QEMU_OPT_STRING,
+ }, {
+ .name = "sku",
+ .type = QEMU_OPT_STRING,
+ }, {
+ .name = "family",
+ .type = QEMU_OPT_STRING,
+ }, {
+ .name = "vendor",
+ .type = QEMU_OPT_STRING,
+ }, {
+ .name = "version",
+ .type = QEMU_OPT_STRING,
+ }, {
+ .name = "date",
+ .type = QEMU_OPT_STRING,
+ }, {
+ .name = "release",
+ .type = QEMU_OPT_STRING,
+ }, {
+ /* End of list */
+ }
+ },
+};
+
static QemuOptsList *vm_config_groups[32] = {
&qemu_drive_opts,
&qemu_chardev_opts,
@@ -659,6 +708,7 @@ static QemuOptsList *vm_config_groups[32] = {
&qemu_boot_opts,
&qemu_iscsi_opts,
&qemu_sandbox_opts,
+ &qemu_smbios_opts,
NULL,
};
diff --git a/vl.c b/vl.c
index 47c5974..ba56cee 100644
--- a/vl.c
+++ b/vl.c
@@ -3050,7 +3050,7 @@ int main(int argc, char **argv, char **envp)
do_acpitable_option(optarg);
break;
case QEMU_OPTION_smbios:
- do_smbios_option(optarg);
+ opts = qemu_opts_parse(qemu_find_opts("smbios"), optarg, 1);
break;
case QEMU_OPTION_enable_kvm:
olist = qemu_find_opts("machine");
@@ -3368,6 +3368,8 @@ int main(int argc, char **argv, char **envp)
exit(1);
}
+ qemu_opts_foreach(qemu_find_opts("smbios"), do_smbios_option, NULL, 0);
+
/*
* Get the default machine options from the machine if it is not already
* specified either by the configuration file or by the command line.
--
1.7.5.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] smbios: convert to use QemuOpts
2012-09-05 19:52 [Qemu-devel] [PATCH] smbios: convert to use QemuOpts Anthony Liguori
@ 2012-09-06 13:18 ` Paolo Bonzini
2012-09-07 6:43 ` Markus Armbruster
1 sibling, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2012-09-06 13:18 UTC (permalink / raw)
To: Anthony Liguori; +Cc: qemu-devel
Il 05/09/2012 21:52, Anthony Liguori ha scritto:
> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
> ---
> 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"))) {
> 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"))) {
> 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) {
> 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");
> 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 "
> diff --git a/hw/smbios.h b/hw/smbios.h
> index 94e3641..6392fbe 100644
> --- a/hw/smbios.h
> +++ b/hw/smbios.h
> @@ -13,7 +13,7 @@
> *
> */
>
> -int smbios_entry_add(const char *t);
> +int smbios_entry_add(QemuOpts *opts);
> void smbios_add_field(int type, int offset, int len, void *data);
> uint8_t *smbios_get_table(size_t *length);
>
> diff --git a/qemu-config.c b/qemu-config.c
> index c05ffbc..3031012 100644
> --- a/qemu-config.c
> +++ b/qemu-config.c
> @@ -643,6 +643,55 @@ QemuOptsList qemu_boot_opts = {
> },
> };
>
> +QemuOptsList qemu_smbios_opts = {
> + .name = "smbios",
> + .head = QTAILQ_HEAD_INITIALIZER(qemu_smbios_opts.head),
> + .desc = {
> + {
> + .name = "file",
> + .type = QEMU_OPT_STRING,
> + }, {
> + .name = "type",
> + .type = QEMU_OPT_NUMBER,
> + }, {
> + .name = "manufacturer",
> + .type = QEMU_OPT_STRING,
> + }, {
> + .name = "product",
> + .type = QEMU_OPT_STRING,
> + }, {
> + .name = "version",
> + .type = QEMU_OPT_STRING,
> + }, {
> + .name = "serial",
> + .type = QEMU_OPT_STRING,
> + }, {
> + .name = "uuid",
> + .type = QEMU_OPT_STRING,
> + }, {
> + .name = "sku",
> + .type = QEMU_OPT_STRING,
> + }, {
> + .name = "family",
> + .type = QEMU_OPT_STRING,
> + }, {
> + .name = "vendor",
> + .type = QEMU_OPT_STRING,
> + }, {
> + .name = "version",
> + .type = QEMU_OPT_STRING,
> + }, {
> + .name = "date",
> + .type = QEMU_OPT_STRING,
> + }, {
> + .name = "release",
> + .type = QEMU_OPT_STRING,
> + }, {
> + /* End of list */
> + }
> + },
> +};
> +
> static QemuOptsList *vm_config_groups[32] = {
> &qemu_drive_opts,
> &qemu_chardev_opts,
> @@ -659,6 +708,7 @@ static QemuOptsList *vm_config_groups[32] = {
> &qemu_boot_opts,
> &qemu_iscsi_opts,
> &qemu_sandbox_opts,
> + &qemu_smbios_opts,
> NULL,
> };
>
> diff --git a/vl.c b/vl.c
> index 47c5974..ba56cee 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -3050,7 +3050,7 @@ int main(int argc, char **argv, char **envp)
> do_acpitable_option(optarg);
> break;
> case QEMU_OPTION_smbios:
> - do_smbios_option(optarg);
> + opts = qemu_opts_parse(qemu_find_opts("smbios"), optarg, 1);
> break;
> case QEMU_OPTION_enable_kvm:
> olist = qemu_find_opts("machine");
> @@ -3368,6 +3368,8 @@ int main(int argc, char **argv, char **envp)
> exit(1);
> }
>
> + qemu_opts_foreach(qemu_find_opts("smbios"), do_smbios_option, NULL, 0);
> +
> /*
> * Get the default machine options from the machine if it is not already
> * specified either by the configuration file or by the command line.
>
Looks good.
Paolo
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] smbios: convert to use QemuOpts
2012-09-05 19:52 [Qemu-devel] [PATCH] smbios: convert to use QemuOpts Anthony Liguori
2012-09-06 13:18 ` Paolo Bonzini
@ 2012-09-07 6:43 ` Markus Armbruster
2012-09-07 13:02 ` Anthony Liguori
1 sibling, 1 reply; 4+ messages in thread
From: Markus Armbruster @ 2012-09-07 6:43 UTC (permalink / raw)
To: Anthony Liguori; +Cc: qemu-devel
Hello, this is your friendly remote compile service.
Anthony Liguori <aliguori@us.ibm.com> writes:
> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
> ---
> 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 "
[...]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] smbios: convert to use QemuOpts
2012-09-07 6:43 ` Markus Armbruster
@ 2012-09-07 13:02 ` Anthony Liguori
0 siblings, 0 replies; 4+ messages in thread
From: Anthony Liguori @ 2012-09-07 13:02 UTC (permalink / raw)
To: Markus Armbruster; +Cc: qemu-devel
Markus Armbruster <armbru@redhat.com> 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 <aliguori@us.ibm.com> writes:
>
>> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
>> ---
>> 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 "
> [...]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-09-07 13:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-05 19:52 [Qemu-devel] [PATCH] smbios: convert to use QemuOpts Anthony Liguori
2012-09-06 13:18 ` Paolo Bonzini
2012-09-07 6:43 ` Markus Armbruster
2012-09-07 13:02 ` Anthony Liguori
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).