diff mbox

[PULL,v2,07/12] vl: Create (most) objects before creating chardev backends

Message ID 5583E8E1.7090604@suse.de
State New
Headers show

Commit Message

Andreas Färber June 19, 2015, 10:03 a.m. UTC
Am 27.05.2015 um 20:20 schrieb Andreas Färber:
> From: "Daniel P. Berrange" <berrange@redhat.com>
> 
> Some types of object must be created before chardevs, other types of
> object must be created after chardevs. As such there is no option but
> to create objects in two phases.
> 
> This takes the decision to create as many object types as possible
> right away before anyother backends are created, and only delay
> creation of those few which have an explicit dependency on the
> chardevs. Hopefully the set which need delaying will remain small
> over time.
> 
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Andreas Färber <afaerber@suse.de>
> ---
>  vl.c | 40 +++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 39 insertions(+), 1 deletion(-)

Rebasing my queue, I needed the attached changes to make it apply and
build. Second pairs of eyes welcome.

Regards,
Andreas

Comments

Paolo Bonzini June 19, 2015, 10:04 a.m. UTC | #1
On 19/06/2015 12:03, Andreas Färber wrote:
> Am 27.05.2015 um 20:20 schrieb Andreas Färber:
>> From: "Daniel P. Berrange" <berrange@redhat.com>
>>
>> Some types of object must be created before chardevs, other types of
>> object must be created after chardevs. As such there is no option but
>> to create objects in two phases.
>>
>> This takes the decision to create as many object types as possible
>> right away before anyother backends are created, and only delay
>> creation of those few which have an explicit dependency on the
>> chardevs. Hopefully the set which need delaying will remain small
>> over time.
>>
>> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
>> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
>> Signed-off-by: Andreas Färber <afaerber@suse.de>
>> ---
>>  vl.c | 40 +++++++++++++++++++++++++++++++++++++++-
>>  1 file changed, 39 insertions(+), 1 deletion(-)
> 
> Rebasing my queue, I needed the attached changes to make it apply and
> build. Second pairs of eyes welcome.

Looks good.

Paolo
Daniel P. Berrangé June 19, 2015, 10:49 a.m. UTC | #2
On Fri, Jun 19, 2015 at 12:03:13PM +0200, Andreas Färber wrote:
> Am 27.05.2015 um 20:20 schrieb Andreas Färber:
> > From: "Daniel P. Berrange" <berrange@redhat.com>
> > 
> > Some types of object must be created before chardevs, other types of
> > object must be created after chardevs. As such there is no option but
> > to create objects in two phases.
> > 
> > This takes the decision to create as many object types as possible
> > right away before anyother backends are created, and only delay
> > creation of those few which have an explicit dependency on the
> > chardevs. Hopefully the set which need delaying will remain small
> > over time.
> > 
> > Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> > Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
> > Signed-off-by: Andreas Färber <afaerber@suse.de>
> > ---
> >  vl.c | 40 +++++++++++++++++++++++++++++++++++++++-
> >  1 file changed, 39 insertions(+), 1 deletion(-)
> 
> Rebasing my queue, I needed the attached changes to make it apply and
> build. Second pairs of eyes welcome.


> @@@ -4114,14 -4062,16 +4145,20 @@@ int main(int argc, char **argv, char **
>   
>       socket_init();
>   
> +     if (qemu_opts_foreach(qemu_find_opts("object"),
> +                           object_create,
>  -                          object_create_initial, 0) != 0) {
> ++                          object_create_initial, NULL)) {
> +         exit(1);
> +     }
> + 
>  -    if (qemu_opts_foreach(qemu_find_opts("chardev"), chardev_init_func, NULL, 1) != 0)
>  +    if (qemu_opts_foreach(qemu_find_opts("chardev"),
>  +                          chardev_init_func, NULL, NULL)) {
>           exit(1);
>  +    }
>  +
>   #ifdef CONFIG_VIRTFS
>  -    if (qemu_opts_foreach(qemu_find_opts("fsdev"), fsdev_init_func, NULL, 1) != 0) {
>  +    if (qemu_opts_foreach(qemu_find_opts("fsdev"),
>  +                          fsdev_init_func, NULL, NULL)) {
>           exit(1);
>       }
>   #endif
> @@@ -4137,7 -4087,8 +4174,8 @@@
>       }
>   
>       if (qemu_opts_foreach(qemu_find_opts("object"),
> -                           object_create, NULL, NULL)) {
> +                           object_create,
>  -                          object_create_delayed, 0) != 0) {
> ++                          object_create_delayed, NULL)) {
>           exit(1);
>       }

Yep, this looks correct wrt the change of Markus' that recently
merged in vl.c

Regards,
Daniel
diff mbox

Patch

diff --cc vl.c
index 2201e27,b7c7511..0000000
--- a/vl.c
+++ b/vl.c
@@@ -2671,7 -2601,34 +2671,34 @@@ static int machine_set_property(void *o
      return 0;
  }
  
+ 
+ /*
+  * Initial object creation happens before all other
+  * QEMU data types are created. The majority of objects
+  * can be created at this point. The rng-egd object
+  * cannot be created here, as it depends on the chardev
+  * already existing.
+  */
+ static bool object_create_initial(const char *type)
+ {
+     if (g_str_equal(type, "rng-egd")) {
+         return false;
+     }
+     return true;
+ }
+ 
+ 
+ /*
+  * The remainder of object creation happens after the
+  * creation of chardev, fsdev and device data types.
+  */
+ static bool object_create_delayed(const char *type)
+ {
+     return !object_create_initial(type);
+ }
+ 
+ 
 -static int object_create(QemuOpts *opts, void *opaque)
 +static int object_create(void *opaque, QemuOpts *opts, Error **errp)
  {
      Error *err = NULL;
      char *type = NULL;
@@@ -4114,14 -4062,16 +4145,20 @@@ int main(int argc, char **argv, char **
  
      socket_init();
  
+     if (qemu_opts_foreach(qemu_find_opts("object"),
+                           object_create,
 -                          object_create_initial, 0) != 0) {
++                          object_create_initial, NULL)) {
+         exit(1);
+     }
+ 
 -    if (qemu_opts_foreach(qemu_find_opts("chardev"), chardev_init_func, NULL, 1) != 0)
 +    if (qemu_opts_foreach(qemu_find_opts("chardev"),
 +                          chardev_init_func, NULL, NULL)) {
          exit(1);
 +    }
 +
  #ifdef CONFIG_VIRTFS
 -    if (qemu_opts_foreach(qemu_find_opts("fsdev"), fsdev_init_func, NULL, 1) != 0) {
 +    if (qemu_opts_foreach(qemu_find_opts("fsdev"),
 +                          fsdev_init_func, NULL, NULL)) {
          exit(1);
      }
  #endif
@@@ -4137,7 -4087,8 +4174,8 @@@
      }
  
      if (qemu_opts_foreach(qemu_find_opts("object"),
-                           object_create, NULL, NULL)) {
+                           object_create,
 -                          object_create_delayed, 0) != 0) {
++                          object_create_delayed, NULL)) {
          exit(1);
      }