[v2,04/18] vl: extract accelerator option processing to a separate function
diff mbox series

Message ID 1575903705-12925-5-git-send-email-pbonzini@redhat.com
State New
Headers show
Series
  • Complete the implementation of -accel
Related show

Commit Message

Paolo Bonzini Dec. 9, 2019, 3:01 p.m. UTC
As a first step towards supporting multiple "-accel" options, push the
late processing of -icount and -accel into a new function, and use
qemu_opts_foreach to retrieve -accel options instead of stashing
them into globals.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 vl.c | 28 ++++++++++++++++++++--------
 1 file changed, 20 insertions(+), 8 deletions(-)

Comments

Philippe Mathieu-Daudé Dec. 10, 2019, 11:56 a.m. UTC | #1
On 12/9/19 4:01 PM, Paolo Bonzini wrote:
> As a first step towards supporting multiple "-accel" options, push the
> late processing of -icount and -accel into a new function, and use
> qemu_opts_foreach to retrieve -accel options instead of stashing
> them into globals.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

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

> ---
>   vl.c | 28 ++++++++++++++++++++--------
>   1 file changed, 20 insertions(+), 8 deletions(-)
> 
> diff --git a/vl.c b/vl.c
> index f69fea1..1ad6dfb 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2831,6 +2831,25 @@ static int do_configure_icount(void *opaque, QemuOpts *opts, Error **errp)
>       return 0;
>   }
>   
> +static int do_configure_accelerator(void *opaque, QemuOpts *opts, Error **errp)
> +{
> +    if (tcg_enabled()) {
> +        qemu_tcg_configure(opts, &error_fatal);
> +    }
> +    return 0;
> +}
> +
> +static void configure_accelerators(void)
> +{
> +    qemu_opts_foreach(qemu_find_opts("accel"),
> +                      do_configure_accelerator, NULL, &error_fatal);
> +
> +    if (!tcg_enabled() && use_icount) {
> +        error_report("-icount is not allowed with hardware virtualization");
> +        exit(1);
> +    }
> +}
> +
>   int main(int argc, char **argv, char **envp)
>   {
>       int i;
> @@ -4258,14 +4277,7 @@ int main(int argc, char **argv, char **envp)
>       qemu_spice_init();
>   
>       cpu_ticks_init();
> -    if (!tcg_enabled() && use_icount) {
> -        error_report("-icount is not allowed with hardware virtualization");
> -        exit(1);
> -    }
> -
> -    if (tcg_enabled()) {
> -        qemu_tcg_configure(accel_opts, &error_fatal);
> -    }
> +    configure_accelerators();
>   
>       if (default_net) {
>           QemuOptsList *net = qemu_find_opts("net");
>

Patch
diff mbox series

diff --git a/vl.c b/vl.c
index f69fea1..1ad6dfb 100644
--- a/vl.c
+++ b/vl.c
@@ -2831,6 +2831,25 @@  static int do_configure_icount(void *opaque, QemuOpts *opts, Error **errp)
     return 0;
 }
 
+static int do_configure_accelerator(void *opaque, QemuOpts *opts, Error **errp)
+{
+    if (tcg_enabled()) {
+        qemu_tcg_configure(opts, &error_fatal);
+    }
+    return 0;
+}
+
+static void configure_accelerators(void)
+{
+    qemu_opts_foreach(qemu_find_opts("accel"),
+                      do_configure_accelerator, NULL, &error_fatal);
+
+    if (!tcg_enabled() && use_icount) {
+        error_report("-icount is not allowed with hardware virtualization");
+        exit(1);
+    }
+}
+
 int main(int argc, char **argv, char **envp)
 {
     int i;
@@ -4258,14 +4277,7 @@  int main(int argc, char **argv, char **envp)
     qemu_spice_init();
 
     cpu_ticks_init();
-    if (!tcg_enabled() && use_icount) {
-        error_report("-icount is not allowed with hardware virtualization");
-        exit(1);
-    }
-
-    if (tcg_enabled()) {
-        qemu_tcg_configure(accel_opts, &error_fatal);
-    }
+    configure_accelerators();
 
     if (default_net) {
         QemuOptsList *net = qemu_find_opts("net");