[Qemu-devel] [PATCH v2 07/12] vl: Create block backends before setting machine properties

Markus Armbruster posted 12 patches 6 years, 6 months ago
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, Kevin Wolf <kwolf@redhat.com>, "Andreas Färber" <afaerber@suse.de>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Richard Henderson <rth@twiddle.net>, Max Reitz <mreitz@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>, Eduardo Habkost <ehabkost@redhat.com>
There is a newer version of this series
[Qemu-devel] [PATCH v2 07/12] vl: Create block backends before setting machine properties
Posted by Markus Armbruster 6 years, 6 months ago
qemu-system-FOO's main() acts on command line arguments in its own
idiosyncratic order.  There's not much method to its madness.
Whenever we find a case where one kind of command line argument needs
to refer to something created for another kind later, we rejigger the
order.

Block devices get created long after machine properties get processed.
Therefore, block device machine properties can be created, but not
set.  No such properties exist.  But the next commit will create some.
Time to rejigger again: create block devices earlier.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 vl.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/vl.c b/vl.c
index 5a19d2a8ec..c250483fc1 100644
--- a/vl.c
+++ b/vl.c
@@ -4272,6 +4272,13 @@ int main(int argc, char **argv, char **envp)
         exit(0);
     }
 
+    /*
+     * Note: we need to create block backends before
+     * machine_set_property(), so machine properties can refer to
+     * them.
+     */
+    configure_blockdev(&bdo_queue, machine_class, snapshot);
+
     machine_opts = qemu_get_machine_opts();
     qemu_opt_foreach(machine_opts, machine_set_property, current_machine,
                      &error_fatal);
@@ -4398,8 +4405,6 @@ int main(int argc, char **argv, char **envp)
     ram_mig_init();
     dirty_bitmap_mig_init();
 
-    configure_blockdev(&bdo_queue, machine_class, snapshot);
-
     qemu_opts_foreach(qemu_find_opts("mon"),
                       mon_init_func, NULL, &error_fatal);
 
-- 
2.17.2


Re: [Qemu-devel] [PATCH v2 07/12] vl: Create block backends before setting machine properties
Posted by Philippe Mathieu-Daudé 6 years, 6 months ago
On 3/7/19 6:23 PM, Markus Armbruster wrote:
> qemu-system-FOO's main() acts on command line arguments in its own
> idiosyncratic order.  There's not much method to its madness.
> Whenever we find a case where one kind of command line argument needs
> to refer to something created for another kind later, we rejigger the
> order.
> 
> Block devices get created long after machine properties get processed.
> Therefore, block device machine properties can be created, but not
> set.  No such properties exist.  But the next commit will create some.
> Time to rejigger again: create block devices earlier.
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  vl.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/vl.c b/vl.c
> index 5a19d2a8ec..c250483fc1 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -4272,6 +4272,13 @@ int main(int argc, char **argv, char **envp)
>          exit(0);
>      }
>  
> +    /*
> +     * Note: we need to create block backends before
> +     * machine_set_property(), so machine properties can refer to
> +     * them.
> +     */

Thanks!

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> +    configure_blockdev(&bdo_queue, machine_class, snapshot);
> +
>      machine_opts = qemu_get_machine_opts();
>      qemu_opt_foreach(machine_opts, machine_set_property, current_machine,
>                       &error_fatal);
> @@ -4398,8 +4405,6 @@ int main(int argc, char **argv, char **envp)
>      ram_mig_init();
>      dirty_bitmap_mig_init();
>  
> -    configure_blockdev(&bdo_queue, machine_class, snapshot);
> -
>      qemu_opts_foreach(qemu_find_opts("mon"),
>                        mon_init_func, NULL, &error_fatal);
>  
>