diff mbox

[1/2] vl: Factor object_create() out of main()

Message ID 1502367921-17730-2-git-send-email-armbru@redhat.com
State New
Headers show

Commit Message

Markus Armbruster Aug. 10, 2017, 12:25 p.m. UTC
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 vl.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

Comments

Eric Blake Aug. 10, 2017, 2:43 p.m. UTC | #1
On 08/10/2017 07:25 AM, Markus Armbruster wrote:
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  vl.c | 21 ++++++++++-----------
>  1 file changed, 10 insertions(+), 11 deletions(-)
> 

> +++ b/vl.c
> @@ -2845,7 +2845,6 @@ static bool object_create_initial(const char *type)
>      return true;
>  }
>  
> -
>  /*

Spurious whitespace change? I can live with it because it adds
consistency, but it's not on a function directly touched by this patch.

Reviewed-by: Eric Blake <eblake@redhat.com>
Markus Armbruster Aug. 10, 2017, 4:28 p.m. UTC | #2
Eric Blake <eblake@redhat.com> writes:

> On 08/10/2017 07:25 AM, Markus Armbruster wrote:
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> ---
>>  vl.c | 21 ++++++++++-----------
>>  1 file changed, 10 insertions(+), 11 deletions(-)
>> 
>
>> +++ b/vl.c
>> @@ -2845,7 +2845,6 @@ static bool object_create_initial(const char *type)
>>      return true;
>>  }
>>  
>> -
>>  /*
>
> Spurious whitespace change? I can live with it because it adds
> consistency, but it's not on a function directly touched by this patch.

Not intentional (alternatively: I've since forgotten).  I'll drop it.

> Reviewed-by: Eric Blake <eblake@redhat.com>

Thanks!
Philippe Mathieu-Daudé Aug. 11, 2017, 3:33 a.m. UTC | #3
On 08/10/2017 01:28 PM, Markus Armbruster wrote:
> Eric Blake <eblake@redhat.com> writes:
> 
>> On 08/10/2017 07:25 AM, Markus Armbruster wrote:
>>> Signed-off-by: Markus Armbruster <armbru@redhat.com>

for the refactor:
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

>>> ---
>>>   vl.c | 21 ++++++++++-----------
>>>   1 file changed, 10 insertions(+), 11 deletions(-)
>>>
>>
>>> +++ b/vl.c
>>> @@ -2845,7 +2845,6 @@ static bool object_create_initial(const char *type)
>>>       return true;
>>>   }
>>>   
>>> -
>>>   /*
>>
>> Spurious whitespace change? I can live with it because it adds
>> consistency, but it's not on a function directly touched by this patch.
> 
> Not intentional (alternatively: I've since forgotten).  I'll drop it.

If you ever send the whitespace change as another patch with at least 
some funny message:
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> 
>> Reviewed-by: Eric Blake <eblake@redhat.com>
> 
> Thanks!
>
diff mbox

Patch

diff --git a/vl.c b/vl.c
index 8e247cc..fd98ed1 100644
--- a/vl.c
+++ b/vl.c
@@ -2845,7 +2845,6 @@  static bool object_create_initial(const char *type)
     return true;
 }
 
-
 /*
  * The remainder of object creation happens after the
  * creation of chardev, fsdev, net clients and device data types.
@@ -2855,6 +2854,14 @@  static bool object_create_delayed(const char *type)
     return !object_create_initial(type);
 }
 
+static void object_create(bool (*type_predicate)(const char *))
+{
+    if (qemu_opts_foreach(qemu_find_opts("object"),
+                          user_creatable_add_opts_foreach,
+                          type_predicate, NULL)) {
+        exit(1);
+    }
+}
 
 static void set_memory_options(uint64_t *ram_slots, ram_addr_t *maxram_size,
                                MachineClass *mc)
@@ -4391,11 +4398,7 @@  int main(int argc, char **argv, char **envp)
     page_size_init();
     socket_init();
 
-    if (qemu_opts_foreach(qemu_find_opts("object"),
-                          user_creatable_add_opts_foreach,
-                          object_create_initial, NULL)) {
-        exit(1);
-    }
+    object_create(object_create_initial);
 
     if (qemu_opts_foreach(qemu_find_opts("chardev"),
                           chardev_init_func, NULL, NULL)) {
@@ -4520,11 +4523,7 @@  int main(int argc, char **argv, char **envp)
         exit(1);
     }
 
-    if (qemu_opts_foreach(qemu_find_opts("object"),
-                          user_creatable_add_opts_foreach,
-                          object_create_delayed, NULL)) {
-        exit(1);
-    }
+    object_create(object_create_delayed);
 
 #ifdef CONFIG_TPM
     if (tpm_init() < 0) {