Re: [PATCH] kvm: Set default accelerator to kvm if the host supports it

2012-10-03 Thread Jan Kiszka
On 2012-10-01 18:20, Anthony Liguori wrote:
 Jan Kiszka jan.kis...@siemens.com writes:
 
 If we built a target for a host that supports KVM in principle, set the
 default accelerator to KVM as well. This also means the start of QEMU
 will fail to start if KVM support turns out to be unavailable at
 runtime.

 Signed-off-by: Jan Kiszka jan.kis...@siemens.com
 ---
  kvm-all.c  |1 +
  kvm-stub.c |1 +
  kvm.h  |1 +
  vl.c   |4 ++--
  4 files changed, 5 insertions(+), 2 deletions(-)

 diff --git a/kvm-all.c b/kvm-all.c
 index 92a7137..4d5f86c 100644
 --- a/kvm-all.c
 +++ b/kvm-all.c
 @@ -103,6 +103,7 @@ struct KVMState
  #endif
  };
  
 +bool kvm_configured = true;
  KVMState *kvm_state;
  bool kvm_kernel_irqchip;
  bool kvm_async_interrupts_allowed;
 diff --git a/kvm-stub.c b/kvm-stub.c
 index 3c52eb5..86a6451 100644
 --- a/kvm-stub.c
 +++ b/kvm-stub.c
 @@ -17,6 +17,7 @@
  #include gdbstub.h
  #include kvm.h
  
 +bool kvm_configured;
  KVMState *kvm_state;
  bool kvm_kernel_irqchip;
  bool kvm_async_interrupts_allowed;
 diff --git a/kvm.h b/kvm.h
 index dea2998..9936e5f 100644
 --- a/kvm.h
 +++ b/kvm.h
 @@ -22,6 +22,7 @@
  #include linux/kvm.h
  #endif
  
 +extern bool kvm_configured;
  extern int kvm_allowed;
  extern bool kvm_kernel_irqchip;
  extern bool kvm_async_interrupts_allowed;
 diff --git a/vl.c b/vl.c
 index 8d305ca..f557bd1 100644
 --- a/vl.c
 +++ b/vl.c
 @@ -2215,8 +2215,8 @@ static int configure_accelerator(void)
  }
  
  if (p == NULL) {
 -/* Use the default accelerator, tcg */
 -p = tcg;
 +/* The default accelerator depends on the availability of KVM. */
 +p = kvm_configured ? kvm : tcg;
  }
 
 How about making this an arch_init() function call and then using a #if
 defined(KVM_CONFIG) in arch_init.c?
 
 I hate to introduce another global variable if we can avoid it...

Hacked too quickly. In fact, kvm_configured is simply kvm_available().
However, resistance appear to be too high here.

Jan

 
 Otherwise:
 
 Acked-by: Anthony Liguori aligu...@us.ibm.com
 
 Blue/Aurelien, any objections?
 
 Regards,
 
 Anthony Liguori
 
  
  while (!accel_initialised  *p != '\0') {
 -- 
 1.7.3.4
 --
 To unsubscribe from this list: send the line unsubscribe kvm in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
 




signature.asc
Description: OpenPGP digital signature


Re: [PATCH] kvm: Set default accelerator to kvm if the host supports it

2012-10-03 Thread Blue Swirl
On Mon, Oct 1, 2012 at 4:20 PM, Anthony Liguori anth...@codemonkey.ws wrote:
 Jan Kiszka jan.kis...@siemens.com writes:

 If we built a target for a host that supports KVM in principle, set the
 default accelerator to KVM as well. This also means the start of QEMU
 will fail to start if KVM support turns out to be unavailable at
 runtime.

 Signed-off-by: Jan Kiszka jan.kis...@siemens.com
 ---
  kvm-all.c  |1 +
  kvm-stub.c |1 +
  kvm.h  |1 +
  vl.c   |4 ++--
  4 files changed, 5 insertions(+), 2 deletions(-)

 diff --git a/kvm-all.c b/kvm-all.c
 index 92a7137..4d5f86c 100644
 --- a/kvm-all.c
 +++ b/kvm-all.c
 @@ -103,6 +103,7 @@ struct KVMState
  #endif
  };

 +bool kvm_configured = true;
  KVMState *kvm_state;
  bool kvm_kernel_irqchip;
  bool kvm_async_interrupts_allowed;
 diff --git a/kvm-stub.c b/kvm-stub.c
 index 3c52eb5..86a6451 100644
 --- a/kvm-stub.c
 +++ b/kvm-stub.c
 @@ -17,6 +17,7 @@
  #include gdbstub.h
  #include kvm.h

 +bool kvm_configured;
  KVMState *kvm_state;
  bool kvm_kernel_irqchip;
  bool kvm_async_interrupts_allowed;
 diff --git a/kvm.h b/kvm.h
 index dea2998..9936e5f 100644
 --- a/kvm.h
 +++ b/kvm.h
 @@ -22,6 +22,7 @@
  #include linux/kvm.h
  #endif

 +extern bool kvm_configured;
  extern int kvm_allowed;
  extern bool kvm_kernel_irqchip;
  extern bool kvm_async_interrupts_allowed;
 diff --git a/vl.c b/vl.c
 index 8d305ca..f557bd1 100644
 --- a/vl.c
 +++ b/vl.c
 @@ -2215,8 +2215,8 @@ static int configure_accelerator(void)
  }

  if (p == NULL) {
 -/* Use the default accelerator, tcg */
 -p = tcg;
 +/* The default accelerator depends on the availability of KVM. */
 +p = kvm_configured ? kvm : tcg;
  }

 How about making this an arch_init() function call and then using a #if
 defined(KVM_CONFIG) in arch_init.c?

 I hate to introduce another global variable if we can avoid it...

 Otherwise:

 Acked-by: Anthony Liguori aligu...@us.ibm.com

 Blue/Aurelien, any objections?

No, maybe a message could be printed that says that the default has
changed, for a few releases.


 Regards,

 Anthony Liguori


  while (!accel_initialised  *p != '\0') {
 --
 1.7.3.4
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] kvm: Set default accelerator to kvm if the host supports it

2012-10-01 Thread Anthony Liguori
Jan Kiszka jan.kis...@siemens.com writes:

 If we built a target for a host that supports KVM in principle, set the
 default accelerator to KVM as well. This also means the start of QEMU
 will fail to start if KVM support turns out to be unavailable at
 runtime.

 Signed-off-by: Jan Kiszka jan.kis...@siemens.com
 ---
  kvm-all.c  |1 +
  kvm-stub.c |1 +
  kvm.h  |1 +
  vl.c   |4 ++--
  4 files changed, 5 insertions(+), 2 deletions(-)

 diff --git a/kvm-all.c b/kvm-all.c
 index 92a7137..4d5f86c 100644
 --- a/kvm-all.c
 +++ b/kvm-all.c
 @@ -103,6 +103,7 @@ struct KVMState
  #endif
  };
  
 +bool kvm_configured = true;
  KVMState *kvm_state;
  bool kvm_kernel_irqchip;
  bool kvm_async_interrupts_allowed;
 diff --git a/kvm-stub.c b/kvm-stub.c
 index 3c52eb5..86a6451 100644
 --- a/kvm-stub.c
 +++ b/kvm-stub.c
 @@ -17,6 +17,7 @@
  #include gdbstub.h
  #include kvm.h
  
 +bool kvm_configured;
  KVMState *kvm_state;
  bool kvm_kernel_irqchip;
  bool kvm_async_interrupts_allowed;
 diff --git a/kvm.h b/kvm.h
 index dea2998..9936e5f 100644
 --- a/kvm.h
 +++ b/kvm.h
 @@ -22,6 +22,7 @@
  #include linux/kvm.h
  #endif
  
 +extern bool kvm_configured;
  extern int kvm_allowed;
  extern bool kvm_kernel_irqchip;
  extern bool kvm_async_interrupts_allowed;
 diff --git a/vl.c b/vl.c
 index 8d305ca..f557bd1 100644
 --- a/vl.c
 +++ b/vl.c
 @@ -2215,8 +2215,8 @@ static int configure_accelerator(void)
  }
  
  if (p == NULL) {
 -/* Use the default accelerator, tcg */
 -p = tcg;
 +/* The default accelerator depends on the availability of KVM. */
 +p = kvm_configured ? kvm : tcg;
  }

How about making this an arch_init() function call and then using a #if
defined(KVM_CONFIG) in arch_init.c?

I hate to introduce another global variable if we can avoid it...

Otherwise:

Acked-by: Anthony Liguori aligu...@us.ibm.com

Blue/Aurelien, any objections?

Regards,

Anthony Liguori

  
  while (!accel_initialised  *p != '\0') {
 -- 
 1.7.3.4
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] kvm: Set default accelerator to kvm if the host supports it

2012-10-01 Thread Aurelien Jarno
On Mon, Oct 01, 2012 at 11:20:41AM -0500, Anthony Liguori wrote:
 Jan Kiszka jan.kis...@siemens.com writes:
 
  If we built a target for a host that supports KVM in principle, set the
  default accelerator to KVM as well. This also means the start of QEMU
  will fail to start if KVM support turns out to be unavailable at
  runtime.
 
  Signed-off-by: Jan Kiszka jan.kis...@siemens.com
  ---
   kvm-all.c  |1 +
   kvm-stub.c |1 +
   kvm.h  |1 +
   vl.c   |4 ++--
   4 files changed, 5 insertions(+), 2 deletions(-)
 
  diff --git a/kvm-all.c b/kvm-all.c
  index 92a7137..4d5f86c 100644
  --- a/kvm-all.c
  +++ b/kvm-all.c
  @@ -103,6 +103,7 @@ struct KVMState
   #endif
   };
   
  +bool kvm_configured = true;
   KVMState *kvm_state;
   bool kvm_kernel_irqchip;
   bool kvm_async_interrupts_allowed;
  diff --git a/kvm-stub.c b/kvm-stub.c
  index 3c52eb5..86a6451 100644
  --- a/kvm-stub.c
  +++ b/kvm-stub.c
  @@ -17,6 +17,7 @@
   #include gdbstub.h
   #include kvm.h
   
  +bool kvm_configured;
   KVMState *kvm_state;
   bool kvm_kernel_irqchip;
   bool kvm_async_interrupts_allowed;
  diff --git a/kvm.h b/kvm.h
  index dea2998..9936e5f 100644
  --- a/kvm.h
  +++ b/kvm.h
  @@ -22,6 +22,7 @@
   #include linux/kvm.h
   #endif
   
  +extern bool kvm_configured;
   extern int kvm_allowed;
   extern bool kvm_kernel_irqchip;
   extern bool kvm_async_interrupts_allowed;
  diff --git a/vl.c b/vl.c
  index 8d305ca..f557bd1 100644
  --- a/vl.c
  +++ b/vl.c
  @@ -2215,8 +2215,8 @@ static int configure_accelerator(void)
   }
   
   if (p == NULL) {
  -/* Use the default accelerator, tcg */
  -p = tcg;
  +/* The default accelerator depends on the availability of KVM. */
  +p = kvm_configured ? kvm : tcg;
   }
 
 How about making this an arch_init() function call and then using a #if
 defined(KVM_CONFIG) in arch_init.c?
 
 I hate to introduce another global variable if we can avoid it...
 
 Otherwise:
 
 Acked-by: Anthony Liguori aligu...@us.ibm.com
 
 Blue/Aurelien, any objections?
 

I am not sure this way of doing is really distribution friendly, where
the QEMU package is built for a large variety of hosts, some of them
maybe without KVM support.

I am all for enabling KVM by default, but I think it should fall back to
TCG if it is not enabled (probably with a warning so that the user is
aware of that). On the other hand, if the user explicitly enables KVM
support with -enable-kvm or with accel=kvm, it should fail to start. In 
other words, a bit like the configure script options, by default we 
use auto-detection, but if an option is explicitly enabled, it fails if
it can't be enabled.

-- 
Aurelien Jarno  GPG: 1024D/F1BCDB73
aurel...@aurel32.net http://www.aurel32.net
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html