diff mbox

[v2,02/15] vl: add tcg_enabled() for tcg related code

Message ID 1499076743-15477-3-git-send-email-yang.zhong@intel.com
State New
Headers show

Commit Message

Yang Zhong July 3, 2017, 10:12 a.m. UTC
Need to disable the tcg related code in the vl.c if the
disable-tcg option is added into ./configure command.

Signed-off-by: Yang Zhong <yang.zhong@intel.com>
---
 accel/tcg/tcg-all.c    |  2 +-
 include/sysemu/accel.h |  2 +-
 vl.c                   | 15 +++++++++++----
 3 files changed, 13 insertions(+), 6 deletions(-)

Comments

Thomas Huth July 3, 2017, 12:30 p.m. UTC | #1
On 03.07.2017 12:12, Yang Zhong wrote:
> Need to disable the tcg related code in the vl.c if the
> disable-tcg option is added into ./configure command.
> 
> Signed-off-by: Yang Zhong <yang.zhong@intel.com>
> ---
>  accel/tcg/tcg-all.c    |  2 +-
>  include/sysemu/accel.h |  2 +-
>  vl.c                   | 15 +++++++++++----
>  3 files changed, 13 insertions(+), 6 deletions(-)
> 
> diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c
> index dba9931..b86c896 100644
> --- a/accel/tcg/tcg-all.c
> +++ b/accel/tcg/tcg-all.c
> @@ -28,7 +28,7 @@
>  #include "sysemu/sysemu.h"
>  #include "qom/object.h"
>  
> -int tcg_tb_size;
> +long tcg_tb_size;

This looks like a non-related change. I think you should either put it
into a separate patch, or drop it.

>  static bool tcg_allowed = true;
>  
>  static int tcg_init(MachineState *ms)
> diff --git a/include/sysemu/accel.h b/include/sysemu/accel.h
> index ecc5c84..7b905b7 100644
> --- a/include/sysemu/accel.h
> +++ b/include/sysemu/accel.h
> @@ -63,7 +63,7 @@ typedef struct AccelClass {
>  #define ACCEL_GET_CLASS(obj) \
>      OBJECT_GET_CLASS(AccelClass, (obj), TYPE_ACCEL)
>  
> -extern int tcg_tb_size;
> +extern long tcg_tb_size;
>  
>  void configure_accelerator(MachineState *ms);
>  /* Register accelerator specific global properties */
> diff --git a/vl.c b/vl.c
> index 36ff3f4..f28c1ac 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -3933,9 +3933,14 @@ int main(int argc, char **argv, char **envp)
>                  configure_rtc(opts);
>                  break;
>              case QEMU_OPTION_tb_size:
> -                tcg_tb_size = strtol(optarg, NULL, 0);
> -                if (tcg_tb_size < 0) {
> -                    tcg_tb_size = 0;
> +                if (tcg_enabled()) {
> +                    qemu_strtol(optarg, NULL, 0, &tcg_tb_size);
> +                    if (tcg_tb_size < 0) {
> +                        tcg_tb_size = 0;
> +                    }
> +                } else {
> +                    error_report("TCG is disabled");
> +                    exit(1);
>                  }


You could do this without an else-part, leaving the tcg_tb_size code
unmodified:

+                  if (!tcg_enabled()) {
+                      error_report("TCG is disabled");
+                      exit(1);
+                  }
                   tcg_tb_size = strtol(optarg, NULL, 0);
                   if (tcg_tb_size < 0) {
                       tcg_tb_size = 0;

>                  break;
>              case QEMU_OPTION_icount:
> @@ -4481,7 +4486,9 @@ int main(int argc, char **argv, char **envp)
>          qemu_opts_del(icount_opts);
>      }
>  
> -    qemu_tcg_configure(accel_opts, &error_fatal);
> +    if (tcg_enabled()) {
> +        qemu_tcg_configure(accel_opts, &error_fatal);
> +    }
>  
>      if (default_net) {
>          QemuOptsList *net = qemu_find_opts("net");
> 

 Thomas
diff mbox

Patch

diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c
index dba9931..b86c896 100644
--- a/accel/tcg/tcg-all.c
+++ b/accel/tcg/tcg-all.c
@@ -28,7 +28,7 @@ 
 #include "sysemu/sysemu.h"
 #include "qom/object.h"
 
-int tcg_tb_size;
+long tcg_tb_size;
 static bool tcg_allowed = true;
 
 static int tcg_init(MachineState *ms)
diff --git a/include/sysemu/accel.h b/include/sysemu/accel.h
index ecc5c84..7b905b7 100644
--- a/include/sysemu/accel.h
+++ b/include/sysemu/accel.h
@@ -63,7 +63,7 @@  typedef struct AccelClass {
 #define ACCEL_GET_CLASS(obj) \
     OBJECT_GET_CLASS(AccelClass, (obj), TYPE_ACCEL)
 
-extern int tcg_tb_size;
+extern long tcg_tb_size;
 
 void configure_accelerator(MachineState *ms);
 /* Register accelerator specific global properties */
diff --git a/vl.c b/vl.c
index 36ff3f4..f28c1ac 100644
--- a/vl.c
+++ b/vl.c
@@ -3933,9 +3933,14 @@  int main(int argc, char **argv, char **envp)
                 configure_rtc(opts);
                 break;
             case QEMU_OPTION_tb_size:
-                tcg_tb_size = strtol(optarg, NULL, 0);
-                if (tcg_tb_size < 0) {
-                    tcg_tb_size = 0;
+                if (tcg_enabled()) {
+                    qemu_strtol(optarg, NULL, 0, &tcg_tb_size);
+                    if (tcg_tb_size < 0) {
+                        tcg_tb_size = 0;
+                    }
+                } else {
+                    error_report("TCG is disabled");
+                    exit(1);
                 }
                 break;
             case QEMU_OPTION_icount:
@@ -4481,7 +4486,9 @@  int main(int argc, char **argv, char **envp)
         qemu_opts_del(icount_opts);
     }
 
-    qemu_tcg_configure(accel_opts, &error_fatal);
+    if (tcg_enabled()) {
+        qemu_tcg_configure(accel_opts, &error_fatal);
+    }
 
     if (default_net) {
         QemuOptsList *net = qemu_find_opts("net");