vl: exit if a bad property value is passed to -global
PATCH 1/1 vl: exit if a bad property value is passed to -global
When passing '-global driver=host-powerpc64-cpu,property=compat,value=foo' on the command line, without this patch, we get the following warning per device (which means many lines if the guests has many cpus):
qemu-system-ppc64: Warning: can't apply global host-powerpc64-cpu.compat=foo:
Invalid compatibility mode "foo"
... and QEMU continues execution, ignoring the property.
With this patch, we get a single line:
qemu-system-ppc64: can't apply global host-powerpc64-cpu.compat=foo:
Invalid compatibility mode "foo"
... and QEMU exits.
--- vl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
vl.c +2 -1
@@ -2922,6 +2922,7 @@ static int global_init_func(void *opaque, QemuOpts *opts, Error **errp) g->property =qemu_opt_get (opts,"property" ); g->value =qemu_opt_get (opts,"value" ); g->user_provided = true; + g->errp = errp;qdev_prop_register_global (g);return 0 ; }
@@ -4451,7 +4452,7 @@ int main(int argc, char **argv, char **envp)machine_register_compat_props (current_machine);qemu_opts_foreach (qemu_find_opts ("global" ), - global_init_func,NULL ,NULL ); + global_init_func,NULL , &error_fatal);/* This checkpoint is required by replay to separate prior clock reading from the other reads, because timer polling functions query
Quoted 9 lines · Greg Kurz
When passing '-global driver=host-powerpc64-cpu,property=compat,value=foo' on the command line, without this patch, we get the following warning per device (which means many lines if the guests has many cpus):
qemu-system-ppc64: Warning: can't apply global host-powerpc64-cpu.compat=foo:
Invalid compatibility mode "foo"... and QEMU continues execution, ignoring the property.
Quoted 8 lines
With this patch, we get a single line:
qemu-system-ppc64: can't apply global host-powerpc64-cpu.compat=foo:
Invalid compatibility mode "foo"... and QEMU exits.
Signed-off-by Greg Kurz <[email protected]>
Not really up to me to decide if this is the right approach for global option handling, but it seems like the way to go to me.
Quoted 26 lines
--- vl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)vl.c +2
-1@@ -2922,6 +2922,7 @@ static int global_init_func(void *opaque, QemuOpts *opts, Error **errp) g->property =qemu_opt_get (opts,"property" ); g->value =qemu_opt_get (opts,"value" ); g->user_provided = true; + g->errp = errp;qdev_prop_register_global (g);return 0 ; }@@ -4451,7 +4452,7 @@ int main(int argc, char **argv, char **envp)machine_register_compat_props (current_machine);qemu_opts_foreach (qemu_find_opts ("global" ), - global_init_func,NULL ,NULL ); + global_init_func,NULL , &error_fatal);/* This checkpoint is required by replay to separate prior clock reading from the other reads, because timer polling functions query
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Quoted 15 lines · On Thu, 14 Jul 2016 11:42:40 +1000 David Gibson <[email protected]>…
Quoted 14 lines · Greg Kurz
When passing '-global driver=host-powerpc64-cpu,property=compat,value=foo' on the command line, without this patch, we get the following warning per device (which means many lines if the guests has many cpus):
qemu-system-ppc64: Warning: can't apply global host-powerpc64-cpu.compat=foo:
Invalid compatibility mode "foo"... and QEMU continues execution, ignoring the property.
With this patch, we get a single line:
qemu-system-ppc64: can't apply global host-powerpc64-cpu.compat=foo:
Invalid compatibility mode "foo"
Quoted 8 lines
Quoted 3 lines
... and QEMU exits.
Signed-off-by Greg Kurz <[email protected]>Reviewed-by David Gibson <[email protected]>Not really up to me to decide if this is the right approach for global option handling, but it seems like the way to go to me.
CCing Eduardo
as he basically rewrote that path several times and might know why it's this way now.
Quoted 28 lines
Quoted 27 lines
--- vl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)vl.c +2
-1@@ -2922,6 +2922,7 @@ static int global_init_func(void *opaque, QemuOpts *opts, Error **errp) g->property =qemu_opt_get (opts,"property" ); g->value =qemu_opt_get (opts,"value" ); g->user_provided = true; + g->errp = errp;qdev_prop_register_global (g);return 0 ; }@@ -4451,7 +4452,7 @@ int main(int argc, char **argv, char **envp)machine_register_compat_props (current_machine);qemu_opts_foreach (qemu_find_opts ("global" ), - global_init_func,NULL ,NULL ); + global_init_func,NULL , &error_fatal);/* This checkpoint is required by replay to separate prior clock reading from the other reads, because timer polling functions query
Sorry for the long delay:
Quoted 34 lines · Igor Mammedov
Quoted 15 lines · On Thu, 14 Jul 2016 11:42:40 +1000 David Gibson <[email protected]>…
Quoted 14 lines · Greg Kurz
When passing '-global driver=host-powerpc64-cpu,property=compat,value=foo' on the command line, without this patch, we get the following warning per device (which means many lines if the guests has many cpus):
qemu-system-ppc64: Warning: can't apply global host-powerpc64-cpu.compat=foo:
Invalid compatibility mode "foo"... and QEMU continues execution, ignoring the property.
With this patch, we get a single line:
qemu-system-ppc64: can't apply global host-powerpc64-cpu.compat=foo:
Invalid compatibility mode "foo"Quoted 8 lines
Quoted 3 lines
... and QEMU exits.
Signed-off-by Greg Kurz <[email protected]>Reviewed-by David Gibson <[email protected]>Not really up to me to decide if this is the right approach for global option handling, but it seems like the way to go to me.
CCing Eduardo
as he basically rewrote that path several times and might know why it's this way now.Quoted 5 lines
Quoted 5 lines
--- vl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 9 lines
Quoted 9 lines
vl.c static int global_init_func(void *opaque, QemuOpts *opts, Error **errp) · line 2925
Quoted 9 lines
vl.c +1
-0@@ -2922,6 +2922,7 @@ static int global_init_func(void *opaque, QemuOpts *opts, Error **errp) g->property =qemu_opt_get (opts,"property" ); g->value =qemu_opt_get (opts,"value" ); g->user_provided = true; + g->errp = errp;
Exiting QEMU like you suggest is valid, but we can't set errp to error_fatal here, because it could make QEMU abort when using device_add.
Probably the simplest solution is to ignore GlobalProperty.errp in qdev_prop_set_globals_for_type() if dev->hotplugged is set. Then we can safely set errp here.
Signature · 1 line
Eduardo
Quoted 37 lines · On Wed, 20 Jul 2016 17:18:26 -0300 Eduardo Habkost <[email protected]> wrote:
Sorry for the long delay:
Quoted 34 lines · Igor Mammedov
Quoted 15 lines · On Thu, 14 Jul 2016 11:42:40 +1000 David Gibson <[email protected]>…
Quoted 14 lines · Greg Kurz
When passing '-global driver=host-powerpc64-cpu,property=compat,value=foo' on the command line, without this patch, we get the following warning per device (which means many lines if the guests has many cpus):
qemu-system-ppc64: Warning: can't apply global host-powerpc64-cpu.compat=foo:
Invalid compatibility mode "foo"... and QEMU continues execution, ignoring the property.
With this patch, we get a single line:
qemu-system-ppc64: can't apply global host-powerpc64-cpu.compat=foo:
Invalid compatibility mode "foo"Quoted 8 lines
Quoted 3 lines
... and QEMU exits.
Signed-off-by Greg Kurz <[email protected]>Reviewed-by David Gibson <[email protected]>Not really up to me to decide if this is the right approach for global option handling, but it seems like the way to go to me.
CCing Eduardo
as he basically rewrote that path several times and might know why it's this way now.Quoted 5 lines
Quoted 5 lines
--- vl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 14 lines
Quoted 9 lines
Quoted 9 lines
vl.c static int global_init_func(void *opaque, QemuOpts *opts, Error **errp) · line 2925
Quoted 9 lines
vl.c +1
-0@@ -2922,6 +2922,7 @@ static int global_init_func(void *opaque, QemuOpts *opts, Error **errp) g->property =qemu_opt_get (opts,"property" ); g->value =qemu_opt_get (opts,"value" ); g->user_provided = true; + g->errp = errp;Exiting QEMU like you suggest is valid, but we can't set errp to
error_fatalhere, because it could make QEMU abort when usingdevice_add.
Indeed QEMU exits :\
Quoted 4 lines
Probably the simplest solution is to ignore GlobalProperty.errp in
qdev_prop_set_globals_for_type()ifdev->hotpluggedis set. Then we can safely set errp here.
That should do the trick. I'll send a v2.
Thanks !
--
Greg