* [Qemu-devel] [PATCH 1/3] only add qemu_tpmdev_opts when CONFIG_TPM is defined
2014-03-27 2:38 [Qemu-devel] [PATCH 0/3] ABI change: change group name of option table to match with option name Amos Kong
@ 2014-03-27 2:38 ` Amos Kong
2014-03-27 2:38 ` [Qemu-devel] [PATCH 2/3] abort QEMU if group name in option table doesn't match with defined option name Amos Kong
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Amos Kong @ 2014-03-27 2:38 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, libvirt-list, anthony, pbonzini, afaerber
Signed-off-by: Amos Kong <akong@redhat.com>
---
vl.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/vl.c b/vl.c
index 2355227..596ecfa 100644
--- a/vl.c
+++ b/vl.c
@@ -449,6 +449,7 @@ static QemuOptsList qemu_object_opts = {
},
};
+#ifdef CONFIG_TPM
static QemuOptsList qemu_tpmdev_opts = {
.name = "tpmdev",
.implied_opt_name = "type",
@@ -458,6 +459,7 @@ static QemuOptsList qemu_tpmdev_opts = {
{ /* end of list */ }
},
};
+#endif
static QemuOptsList qemu_realtime_opts = {
.name = "realtime",
@@ -2992,7 +2994,9 @@ int main(int argc, char **argv, char **envp)
qemu_add_opts(&qemu_sandbox_opts);
qemu_add_opts(&qemu_add_fd_opts);
qemu_add_opts(&qemu_object_opts);
+#ifdef CONFIG_TPM
qemu_add_opts(&qemu_tpmdev_opts);
+#endif
qemu_add_opts(&qemu_realtime_opts);
qemu_add_opts(&qemu_msg_opts);
qemu_add_opts(&qemu_name_opts);
--
1.8.5.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH 2/3] abort QEMU if group name in option table doesn't match with defined option name
2014-03-27 2:38 [Qemu-devel] [PATCH 0/3] ABI change: change group name of option table to match with option name Amos Kong
2014-03-27 2:38 ` [Qemu-devel] [PATCH 1/3] only add qemu_tpmdev_opts when CONFIG_TPM is defined Amos Kong
@ 2014-03-27 2:38 ` Amos Kong
2014-03-27 2:38 ` [Qemu-devel] [PATCH 3/3] update names in option tables to match with actual command-line spelling Amos Kong
2014-03-27 12:28 ` [Qemu-devel] [PATCH 0/3] ABI change: change group name of option table to match with option name Paolo Bonzini
3 siblings, 0 replies; 6+ messages in thread
From: Amos Kong @ 2014-03-27 2:38 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, libvirt-list, anthony, pbonzini, afaerber
All the options are defined in qemu-options.hx. If we can't find a
matched option definition by group name of option table, then the
group name doesn't match with defined option name, it's not allowed
from 2.0
Signed-off-by: Amos Kong <akong@redhat.com>
---
qemu-options.h | 12 ++++++++++++
util/qemu-config.c | 28 ++++++++++++++++++++++++++++
vl.c | 19 ++-----------------
3 files changed, 42 insertions(+), 17 deletions(-)
diff --git a/qemu-options.h b/qemu-options.h
index 89a009e..4024487 100644
--- a/qemu-options.h
+++ b/qemu-options.h
@@ -28,9 +28,21 @@
#ifndef _QEMU_OPTIONS_H_
#define _QEMU_OPTIONS_H_
+#include "sysemu/arch_init.h"
+
enum {
#define QEMU_OPTIONS_GENERATE_ENUM
#include "qemu-options-wrapper.h"
};
+#define HAS_ARG 0x0001
+
+typedef struct QEMUOption {
+ const char *name;
+ int flags;
+ int index;
+ uint32_t arch_mask;
+} QEMUOption;
+
+extern const QEMUOption qemu_options[];
#endif
diff --git a/util/qemu-config.c b/util/qemu-config.c
index f610101..eba5428 100644
--- a/util/qemu-config.c
+++ b/util/qemu-config.c
@@ -6,6 +6,14 @@
#include "hw/qdev.h"
#include "qapi/error.h"
#include "qmp-commands.h"
+#include "qemu-options.h"
+
+const QEMUOption qemu_options[] = {
+ { "h", 0, QEMU_OPTION_h, QEMU_ARCH_ALL },
+#define QEMU_OPTIONS_GENERATE_OPTIONS
+#include "qemu-options-wrapper.h"
+ { NULL },
+};
static QemuOptsList *vm_config_groups[32];
static QemuOptsList *drive_config_groups[4];
@@ -184,6 +192,20 @@ void qemu_add_drive_opts(QemuOptsList *list)
abort();
}
+/* check if the option is defined in qemu-options.hx */
+static bool opt_is_defined(const char *name)
+{
+ int i;
+
+ for (i = 0; qemu_options[i].name; i++) {
+ if (!strcmp(qemu_options[i].name, name)) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
void qemu_add_opts(QemuOptsList *list)
{
int entries, i;
@@ -193,6 +215,12 @@ void qemu_add_opts(QemuOptsList *list)
for (i = 0; i < entries; i++) {
if (vm_config_groups[i] == NULL) {
vm_config_groups[i] = list;
+ if (!opt_is_defined(list->name)) {
+ error_report("Didn't find a matched option definition, "
+ "group name (%s) of option table must match with "
+ "defined option name (Since 2.0)", list->name);
+ abort();
+ }
return;
}
}
diff --git a/vl.c b/vl.c
index 596ecfa..580bd22 100644
--- a/vl.c
+++ b/vl.c
@@ -111,7 +111,6 @@ int main(int argc, char **argv)
#include "trace/control.h"
#include "qemu/queue.h"
#include "sysemu/cpus.h"
-#include "sysemu/arch_init.h"
#include "qemu/osdep.h"
#include "ui/qemu-spice.h"
@@ -2082,22 +2081,6 @@ static void help(int exitcode)
exit(exitcode);
}
-#define HAS_ARG 0x0001
-
-typedef struct QEMUOption {
- const char *name;
- int flags;
- int index;
- uint32_t arch_mask;
-} QEMUOption;
-
-static const QEMUOption qemu_options[] = {
- { "h", 0, QEMU_OPTION_h, QEMU_ARCH_ALL },
-#define QEMU_OPTIONS_GENERATE_OPTIONS
-#include "qemu-options-wrapper.h"
- { NULL },
-};
-
static bool vga_available(void)
{
return object_class_by_name("VGA") || object_class_by_name("isa-vga");
@@ -2842,6 +2825,8 @@ static const QEMUOption *lookup_opt(int argc, char **argv,
return popt;
}
+#undef HAS_ARG
+
static gpointer malloc_and_trace(gsize n_bytes)
{
void *ptr = malloc(n_bytes);
--
1.8.5.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH 3/3] update names in option tables to match with actual command-line spelling
2014-03-27 2:38 [Qemu-devel] [PATCH 0/3] ABI change: change group name of option table to match with option name Amos Kong
2014-03-27 2:38 ` [Qemu-devel] [PATCH 1/3] only add qemu_tpmdev_opts when CONFIG_TPM is defined Amos Kong
2014-03-27 2:38 ` [Qemu-devel] [PATCH 2/3] abort QEMU if group name in option table doesn't match with defined option name Amos Kong
@ 2014-03-27 2:38 ` Amos Kong
2014-03-27 12:28 ` [Qemu-devel] [PATCH 0/3] ABI change: change group name of option table to match with option name Paolo Bonzini
3 siblings, 0 replies; 6+ messages in thread
From: Amos Kong @ 2014-03-27 2:38 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, libvirt-list, anthony, pbonzini, afaerber
We want to establish a mapping between option name and option table,
then we can search related option table by option name.
This patch makes all the member name of QemuOptsList to match with
actual command-line spelling(option name).
[ Important Note ]
The QemuOptsList member name values are ABI, changing them can break
existing -readconfig configuration files.
This patch changes:
from to introduced in
acpi acpitable 0c764a9 v1.5.0
boot-opts boot 3d3b830 v1.0
smp-opts smp 12b7f57 v1.6.0
All three have calcified into ABI already.
I have updated the release note of 2.0
http://wiki.qemu.org/ChangeLog/2.0#ABI_breaking
Signed-off-by: Amos Kong <akong@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
hw/acpi/core.c | 8 ++++----
hw/nvram/fw_cfg.c | 4 ++--
include/qemu/option.h | 2 +-
vl.c | 14 +++++++-------
4 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/hw/acpi/core.c b/hw/acpi/core.c
index 79414b4..12e9ae8 100644
--- a/hw/acpi/core.c
+++ b/hw/acpi/core.c
@@ -54,16 +54,16 @@ static const char unsigned dfl_hdr[ACPI_TABLE_HDR_SIZE - ACPI_TABLE_PFX_SIZE] =
char unsigned *acpi_tables;
size_t acpi_tables_len;
-static QemuOptsList qemu_acpi_opts = {
- .name = "acpi",
+static QemuOptsList qemu_acpitable_opts = {
+ .name = "acpitable",
.implied_opt_name = "data",
- .head = QTAILQ_HEAD_INITIALIZER(qemu_acpi_opts.head),
+ .head = QTAILQ_HEAD_INITIALIZER(qemu_acpitable_opts.head),
.desc = { { 0 } } /* validated with OptsVisitor */
};
static void acpi_register_config(void)
{
- qemu_add_opts(&qemu_acpi_opts);
+ qemu_add_opts(&qemu_acpitable_opts);
}
machine_init(acpi_register_config);
diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
index 282341a..3e6b048 100644
--- a/hw/nvram/fw_cfg.c
+++ b/hw/nvram/fw_cfg.c
@@ -125,7 +125,7 @@ static void fw_cfg_bootsplash(FWCfgState *s)
const char *temp;
/* get user configuration */
- QemuOptsList *plist = qemu_find_opts("boot-opts");
+ QemuOptsList *plist = qemu_find_opts("boot");
QemuOpts *opts = QTAILQ_FIRST(&plist->head);
if (opts != NULL) {
temp = qemu_opt_get(opts, "splash");
@@ -191,7 +191,7 @@ static void fw_cfg_reboot(FWCfgState *s)
const char *temp;
/* get user configuration */
- QemuOptsList *plist = qemu_find_opts("boot-opts");
+ QemuOptsList *plist = qemu_find_opts("boot");
QemuOpts *opts = QTAILQ_FIRST(&plist->head);
if (opts != NULL) {
temp = qemu_opt_get(opts, "reboot-timeout");
diff --git a/include/qemu/option.h b/include/qemu/option.h
index 8c0ac34..96b7c29 100644
--- a/include/qemu/option.h
+++ b/include/qemu/option.h
@@ -102,7 +102,7 @@ typedef struct QemuOptDesc {
} QemuOptDesc;
struct QemuOptsList {
- const char *name;
+ const char *name; /* option name */
const char *implied_opt_name;
bool merge_lists; /* Merge multiple uses of option into a single list? */
QTAILQ_HEAD(, QemuOpts) head;
diff --git a/vl.c b/vl.c
index 580bd22..bd44c52 100644
--- a/vl.c
+++ b/vl.c
@@ -387,7 +387,7 @@ static QemuOptsList qemu_machine_opts = {
};
static QemuOptsList qemu_boot_opts = {
- .name = "boot-opts",
+ .name = "boot",
.implied_opt_name = "order",
.merge_lists = true,
.head = QTAILQ_HEAD_INITIALIZER(qemu_boot_opts.head),
@@ -1358,7 +1358,7 @@ static void numa_add(const char *optarg)
}
static QemuOptsList qemu_smp_opts = {
- .name = "smp-opts",
+ .name = "smp",
.implied_opt_name = "cpus",
.merge_lists = true,
.head = QTAILQ_HEAD_INITIALIZER(qemu_smp_opts.head),
@@ -3226,7 +3226,7 @@ int main(int argc, char **argv, char **envp)
drive_add(IF_DEFAULT, 2, optarg, CDROM_OPTS);
break;
case QEMU_OPTION_boot:
- opts = qemu_opts_parse(qemu_find_opts("boot-opts"), optarg, 1);
+ opts = qemu_opts_parse(qemu_find_opts("boot"), optarg, 1);
if (!opts) {
exit(1);
}
@@ -3595,7 +3595,7 @@ int main(int argc, char **argv, char **envp)
break;
}
case QEMU_OPTION_acpitable:
- opts = qemu_opts_parse(qemu_find_opts("acpi"), optarg, 1);
+ opts = qemu_opts_parse(qemu_find_opts("acpitable"), optarg, 1);
if (!opts) {
exit(1);
}
@@ -3662,7 +3662,7 @@ int main(int argc, char **argv, char **envp)
}
break;
case QEMU_OPTION_smp:
- if (!qemu_opts_parse(qemu_find_opts("smp-opts"), optarg, 1)) {
+ if (!qemu_opts_parse(qemu_find_opts("smp"), optarg, 1)) {
exit(1);
}
break;
@@ -3987,7 +3987,7 @@ int main(int argc, char **argv, char **envp)
data_dir[data_dir_idx++] = CONFIG_QEMU_DATADIR;
}
- smp_parse(qemu_opts_find(qemu_find_opts("smp-opts"), NULL));
+ smp_parse(qemu_opts_find(qemu_find_opts("smp"), NULL));
machine->max_cpus = machine->max_cpus ?: 1; /* Default to UP */
if (smp_cpus > machine->max_cpus) {
@@ -4171,7 +4171,7 @@ int main(int argc, char **argv, char **envp)
bios_name = qemu_opt_get(machine_opts, "firmware");
boot_order = machine->default_boot_order;
- opts = qemu_opts_find(qemu_find_opts("boot-opts"), NULL);
+ opts = qemu_opts_find(qemu_find_opts("boot"), NULL);
if (opts) {
char *normal_boot_order;
const char *order, *once;
--
1.8.5.3
^ permalink raw reply related [flat|nested] 6+ messages in thread