: rename machine options to use dashes
cover : rename machine options to use dashes
Today, machine options use underscores to separate words (eg. kernel_irqchip), however upcoming QOM conversion wants to use dashes instead.
This series converts all machine type options to use dashes. Command-line backwards compatibility is maintained by adding an alias for each changed option.
device_tree.c | 2 +- hw/ppce500_mpc8544ds.c | 2 +- kvm-all.c | 2 +- qemu-config.c | 12 ++++++++---- qemu-option.c | 9 ++++++++- qemu-option.h | 1 + qemu-options.hx | 8 ++++---- target-i386/kvm.c | 2 +- 8 files changed, 25 insertions(+), 13 deletions(-)
PATCH 1/5 qemu-option: add alias support
It allows for specifying an alias for each option name, see next commits examples.
--- qemu-option.c | 9 ++++++++- qemu-option.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-)
qemu-option.c +8 -1
@@ -616,6 +616,7 @@ static void opt_set(QemuOpts *opts, const char *name, const char *value, bool prepend, Error **errp) { QemuOpt *opt; +const char *optname;const QemuOptDesc *desc = opts->list->desc;Error *local_err =NULL ;int i;
@@ -624,18 +625,24 @@ static void opt_set(QemuOpts *opts, const char *name, const char *value,if (strcmp (desc[i].name, name) ==0 ) {break ; } +if (desc[i].alias &&strcmp (desc[i].alias, name) ==0 ) { +break ; + } }if (desc[i].name ==NULL ) {if (i ==0 ) {/* empty list -> allow any */ ; + optname = name; }else {error_set (errp,QERR_INVALID_PARAMETER , name);return ; } + }else { + optname = desc[i].name; } opt =g_malloc0 (sizeof (*opt)); - opt->name =g_strdup (name); + opt->name =g_strdup (optname); opt->opts = opts;if (prepend) {QTAILQ_INSERT_HEAD (&opts->head, opt, next);
qemu-option.h +1 -0
@@ -94,6 +94,7 @@ enum QemuOptType {typedef struct QemuOptDesc {const char *name; +const char *alias;enum QemuOptType type;const char *help; }QemuOptDesc ;
Signature · 1 line
1.7.11.1.116.g8228a23
Re: [Qemu-devel] [PATCH 1/5] qemu-option: add alias support
Quoted 37 lines · Luiz Capitulino
It allows for specifying an alias for each option name, see next commits examples.
Signed-off-by Luiz Capitulino <[email protected]>--- qemu-option.c | 9 ++++++++- qemu-option.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-)qemu-option.c +5
-0@@ -616,6 +616,7 @@ static void opt_set(QemuOpts *opts, const char *name, const char *value, bool prepend, Error **errp) { QemuOpt *opt; +const char *optname;const QemuOptDesc *desc = opts->list->desc;Error *local_err =NULL ;int i;@@ -624,18 +625,24 @@ static void opt_set(QemuOpts *opts, const char *name, const char *value,if (strcmp (desc[i].name, name) ==0 ) {break ; } +if (desc[i].alias &&strcmp (desc[i].alias, name) ==0 ) { +break ; + } }if (desc[i].name ==NULL ) {if (i ==0 ) {/* empty list -> allow any */ ; + optname = name; }else {error_set (errp,QERR_INVALID_PARAMETER , name);return ; }
qemu-option.c static void opt_set(QemuOpts *opts, const char *name, const char *value, · line 648
Quoted 10 lines
qemu-option.c +3
-1+ }else { + optname = desc[i].name; } opt =g_malloc0 (sizeof (*opt)); - opt->name =g_strdup (name); + opt->name =g_strdup (optname); opt->opts = opts;if (prepend) {QTAILQ_INSERT_HEAD (&opts->head, opt, next);
What about qemu_opt_set_bool() and qemu_opts_validate()? Don't they need alias support as well?
By the way, I really dislike qemu_opt_set_bool() duplicating qemu_opt_set(). Shame on commit f02b77c9.
Quoted 12 lines
qemu-option.h +1
-0@@ -94,6 +94,7 @@ enum QemuOptType {typedef struct QemuOptDesc {const char *name; +const char *alias;enum QemuOptType type;const char *help; }QemuOptDesc ;
Re: [Qemu-devel] [PATCH 1/5] qemu-option: add alias support
Quoted 43 lines · On Wed, 11 Jul 2012 09:00:59 +0200 Markus Armbruster <[email protected]> wrote:
Quoted 41 lines · Luiz Capitulino
It allows for specifying an alias for each option name, see next commits examples.
Signed-off-by Luiz Capitulino <[email protected]>--- qemu-option.c | 9 ++++++++- qemu-option.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-)qemu-option.c +7
-0@@ -616,6 +616,7 @@ static void opt_set(QemuOpts *opts, const char *name, const char *value, bool prepend, Error **errp) { QemuOpt *opt; +const char *optname;const QemuOptDesc *desc = opts->list->desc;Error *local_err =NULL ;int i;@@ -624,18 +625,24 @@ static void opt_set(QemuOpts *opts, const char *name, const char *value,if (strcmp (desc[i].name, name) ==0 ) {break ; } +if (desc[i].alias &&strcmp (desc[i].alias, name) ==0 ) { +break ; + } }if (desc[i].name ==NULL ) {if (i ==0 ) {/* empty list -> allow any */ ; + optname = name; }else {error_set (errp,QERR_INVALID_PARAMETER , name);return ; } + }else { + optname = desc[i].name; }
Quoted 9 lines
qemu-option.c static void opt_set(QemuOpts *opts, const char *name, const char *value, · line 648
Quoted 6 lines
qemu-option.c +1
-1opt =g_malloc0 (sizeof (*opt)); - opt->name =g_strdup (name); + opt->name =g_strdup (optname); opt->opts = opts;if (prepend) {QTAILQ_INSERT_HEAD (&opts->head, opt, next);What about
qemu_opt_set_bool()andqemu_opts_validate()? Don't they need alias support as well?
Oh, you're right, thanks for catching this.
Quoted 2 lines
By the way, I really dislike
qemu_opt_set_bool()duplicatingqemu_opt_set(). Shame on commitf02b77c9.
Yeah, I'll fix the duplication.
Quoted 14 lines
Quoted 13 lines
qemu-option.h +1
-0@@ -94,6 +94,7 @@ enum QemuOptType {typedef struct QemuOptDesc {const char *name; +const char *alias;enum QemuOptType type;const char *help; }QemuOptDesc ;
PATCH 2/5 machine: rename kernel_irqchip to kernel-irqchip
In reply to Luiz CapitulinoQOM conversion wants option names with dashes (instead of underscores), this commit does the change for the kernel_irqchip machine option.
The underscore is still supported through an option alias for backwards compatibility.
--- kvm-all.c | 2 +- qemu-config.c | 3 ++- qemu-options.hx | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-)
kvm-all.c +1 -1
@@ -1168,7 +1168,7 @@ static int kvm_irqchip_create(KVMState *s)if (QTAILQ_EMPTY (&list->head) || !qemu_opt_get_bool (QTAILQ_FIRST (&list->head), -"kernel_irqchip" , true) || +"kernel-irqchip" , true) || !kvm_check_extension (s,KVM_CAP_IRQCHIP )) {return 0 ; }
qemu-config.c +2 -1
@@ -560,7 +560,8 @@ static QemuOptsList qemu_machine_opts = { .type = QEMU_OPT_STRING, .help = "accelerator list", }, { - .name = "kernel_irqchip", + .name = "kernel-irqchip", + .alias= "kernel_irqchip", .type = QEMU_OPT_BOOL, .help = "use KVM in-kernel irqchip", }, {
qemu-options.hx +2 -2
@@ -32,7 +32,7 @@ DEF("machine", HAS_ARG, QEMU_OPTION_machine, \ " selects emulated machine (-machine ? for list)\n" " property accel=accel1[:accel2[:...]] selects accelerator\n" " supported accelerators are kvm, xen, tcg (default: tcg)\n" - " kernel_irqchip=on|off controls accelerated irqchip support\n" + " kernel-irqchip=on|off controls accelerated irqchip support\n" " kvm_shadow_mem=size of KVM shadow MMU\n", QEMU_ARCH_ALL) STEXI
@@ -46,7 +46,7 @@ This is used to enable an accelerator. Depending on the target architecture, kvm, xen, or tcg can be available. By default, tcg is used. If there is more than one accelerator specified, the next one is used if the previous one fails to initialize. -@item kernel_irqchip=on|off +@item kernel-irqchip=on|off Enables in-kernel irqchip support for the chosen accelerator when available. @item kvm_shadow_mem=size Defines the size of the KVM shadow MMU.
Signature · 1 line
1.7.11.1.116.g8228a23
PATCH 3/5 machine: rename kvm_shadow_mem to kvm-shadow-mem
In reply to Luiz CapitulinoQOM conversion wants option names with dashes (instead of underscores), this commit does the change for the kvm_shadow_mem machine option.
The underscore is still supported through an option alias for backwards compatibility.
--- qemu-config.c | 3 ++- qemu-options.hx | 4 ++-- target-i386/kvm.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-)
qemu-config.c +2 -1
@@ -565,7 +565,8 @@ static QemuOptsList qemu_machine_opts = { .type = QEMU_OPT_BOOL, .help = "use KVM in-kernel irqchip", }, { - .name = "kvm_shadow_mem", + .name = "kvm-shadow-mem", + .alias= "kvm_shadow_mem", .type = QEMU_OPT_SIZE, .help = "KVM shadow MMU size", }, {
qemu-options.hx +2 -2
@@ -33,7 +33,7 @@ DEF("machine", HAS_ARG, QEMU_OPTION_machine, \ " property accel=accel1[:accel2[:...]] selects accelerator\n" " supported accelerators are kvm, xen, tcg (default: tcg)\n" " kernel-irqchip=on|off controls accelerated irqchip support\n" - " kvm_shadow_mem=size of KVM shadow MMU\n", + " kvm-shadow-mem=size of KVM shadow MMU\n", QEMU_ARCH_ALL) STEXI @item -machine [type=]@var{name}[,prop=@var{value}[,...]]
@@ -48,7 +48,7 @@ than one accelerator specified, the next one is used if the previous one fails to initialize. @item kernel-irqchip=on|off Enables in-kernel irqchip support for the chosen accelerator when available. -@item kvm_shadow_mem=size +@item kvm-shadow-mem=size Defines the size of the KVM shadow MMU. @end table ETEXI
target-i386/kvm.c +1 -1
@@ -698,7 +698,7 @@ int kvm_arch_init(KVMState *s)if (!QTAILQ_EMPTY (&list->head)) { shadow_mem =qemu_opt_get_size (QTAILQ_FIRST (&list->head), -"kvm_shadow_mem" ,-1 ); +"kvm-shadow-mem" ,-1 );if (shadow_mem !=-1 ) { shadow_mem /=4096 ; ret =kvm_vm_ioctl (s,KVM_SET_NR_MMU_PAGES , shadow_mem);
Signature · 1 line
1.7.11.1.116.g8228a23
PATCH 4/5 machine: rename phandle_start to phandle-start
In reply to Luiz CapitulinoQOM conversion wants option names with dashes (instead of underscores), this commit does the change for the phandle_start machine option.
The underscore is still supported through an option alias for backwards compatibility.
--- device_tree.c | 2 +- qemu-config.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-)
device_tree.c +1 -1
@@ -213,7 +213,7 @@ uint32_t qemu_devtree_alloc_phandle(void *fdt) machine_opts =qemu_opts_find (qemu_find_opts ("machine" ),0 );if (machine_opts) {const char *phandle_start; - phandle_start =qemu_opt_get (machine_opts,"phandle_start" ); + phandle_start =qemu_opt_get (machine_opts,"phandle-start" );if (phandle_start) { phandle =strtoul (phandle_start,NULL ,0 ); }
qemu-config.c +2 -1
@@ -590,7 +590,8 @@ static QemuOptsList qemu_machine_opts = { .type = QEMU_OPT_STRING, .help = "Dump current dtb to a file and quit", }, { - .name = "phandle_start", + .name = "phandle-start", + .alias= "phandle_start", .type = QEMU_OPT_STRING, .help = "The first phandle ID we may generate dynamically", }, {
Signature · 1 line
1.7.11.1.116.g8228a23
PATCH 5/5 machine: rename dt_compatible to dt-compatible
In reply to Luiz CapitulinoQOM conversion wants option names with dashes (instead of underscores), this commit does the change for the dt_compatible machine option.
The underscore is still supported through an option alias for backwards compatibility.
--- hw/ppce500_mpc8544ds.c | 2 +- qemu-config.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-)
hw/ppce500_mpc8544ds.c +1 -1
@@ -148,7 +148,7 @@ static int mpc8544_load_device_tree(CPUPPCState *env,const char *tmp; dumpdtb =qemu_opt_get (machine_opts,"dumpdtb" ); dtb_file =qemu_opt_get (machine_opts,"dtb" ); - tmp =qemu_opt_get (machine_opts,"dt_compatible" ); + tmp =qemu_opt_get (machine_opts,"dt-compatible" );if (tmp) { compatible = tmp; compatible_len =strlen (compatible) +1 ;
qemu-config.c +2 -1
@@ -595,7 +595,8 @@ static QemuOptsList qemu_machine_opts = { .type = QEMU_OPT_STRING, .help = "The first phandle ID we may generate dynamically", }, { - .name = "dt_compatible", + .name = "dt-compatible", + .alias= "dt_compatible", .type = QEMU_OPT_STRING, .help = "Overrides the \"compatible\" property of the dt root node", },
Signature · 1 line
1.7.11.1.116.g8228a23
Quoted 2 lines · Luiz Capitulino
Today, machine options use underscores to separate words (eg.
kernel_irqchip), however upcoming QOM conversion wants to use dashes instead.
Command line users will appreciate consistent use of '-', too.
Quoted 3 lines
This series converts all machine type options to use dashes. Command-line backwards compatibility is maintained by adding an alias for each changed option.
Looks good except for PATCH 1/5.
Many -machine options are not documented in -help. Not your fault.
A quick git-grep for more instances of '_' in option parameter names finds only vcard_emul_options(). Yet another ad hoc option argument parser. I'm not asking you to do anything about it.