diff mbox

[RFC,v2,2/6] qtest: add support for target-i386 -M pc

Message ID 1322765012-3164-3-git-send-email-aliguori@us.ibm.com
State New
Headers show

Commit Message

Anthony Liguori Dec. 1, 2011, 6:43 p.m. UTC
This involves forcing the CPU into the halted state if qtest is enabled and
replacing the local APIC with the qtest interrupt controller.

It should be pretty straight forward to do the same for other machine types on
other architectures.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
 hw/pc.c      |    7 ++++++-
 hw/pc_piix.c |    9 ++++++---
 2 files changed, 12 insertions(+), 4 deletions(-)

Comments

Paolo Bonzini Dec. 2, 2011, 7:52 a.m. UTC | #1
On 12/01/2011 07:43 PM, Anthony Liguori wrote:
> This involves forcing the CPU into the halted state if qtest is enabled and
> replacing the local APIC with the qtest interrupt controller.
>
> It should be pretty straight forward to do the same for other machine types on
> other architectures.
>
> Signed-off-by: Anthony Liguori<aliguori@us.ibm.com>

Can you do this in some per-accelerator function?  Is it different from 
just not creating the CPU threads?  (Also, whatever you do here 
generally you could do for Xen, too).

Paolo
Peter Maydell Dec. 29, 2011, 5:40 p.m. UTC | #2
On 1 December 2011 18:43, Anthony Liguori <aliguori@us.ibm.com> wrote:
> This involves forcing the CPU into the halted state if qtest is enabled and
> replacing the local APIC with the qtest interrupt controller.
>
> It should be pretty straight forward to do the same for other machine types on
> other architectures.

Having to modify every machine type seems to me like a huge red flag that this
is the wrong approach for device level tests. Surely the right thing is to
(a) instantiate the device (b) manipulate it via its publicly exposed interfaces
(ie the memory regions, gpio signals, irqs, etc etc) ?

Alternatively if you're just testing features of the device as it
is wired up on the board then you want something that generates an
image that can just be run on the unmodified QEMU model; that then
lets you cross check by running your tests on real hardware.

-- PMM
Anthony Liguori Dec. 29, 2011, 6:47 p.m. UTC | #3
On 12/29/2011 11:40 AM, Peter Maydell wrote:
> On 1 December 2011 18:43, Anthony Liguori<aliguori@us.ibm.com>  wrote:
>> This involves forcing the CPU into the halted state if qtest is enabled and
>> replacing the local APIC with the qtest interrupt controller.
>>
>> It should be pretty straight forward to do the same for other machine types on
>> other architectures.
>
> Having to modify every machine type seems to me like a huge red flag that this
> is the wrong approach for device level tests. Surely the right thing is to
> (a) instantiate the device (b) manipulate it via its publicly exposed interfaces
> (ie the memory regions, gpio signals, irqs, etc etc) ?

The problem is the machine creation.  Once we convert everything to QOM 
including machine setup, yes, this is what we can do.

Regards,

Anthony Liguori

>
> Alternatively if you're just testing features of the device as it
> is wired up on the board then you want something that generates an
> image that can just be run on the unmodified QEMU model; that then
> lets you cross check by running your tests on real hardware.
>
> -- PMM
>
diff mbox

Patch

diff --git a/hw/pc.c b/hw/pc.c
index 33778fe..bba8adc 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -43,6 +43,7 @@ 
 #include "ui/qemu-spice.h"
 #include "memory.h"
 #include "exec-memory.h"
+#include "qtest.h"
 
 /* output Bochs bios info messages */
 //#define DEBUG_BIOS
@@ -926,7 +927,11 @@  static void pc_cpu_reset(void *opaque)
     CPUState *env = opaque;
 
     cpu_reset(env);
-    env->halted = !cpu_is_bsp(env);
+    if (qtest_enabled()) {
+        env->halted = 1;
+    } else {
+        env->halted = !cpu_is_bsp(env);
+    }
 }
 
 static CPUState *pc_new_cpu(const char *cpu_model)
diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index 970f43c..570d5fb 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -46,6 +46,7 @@ 
 #ifdef CONFIG_XEN
 #  include <xen/hvm/hvm_info_table.h>
 #endif
+#include "qtest.h"
 
 #define MAX_IDE_BUS 2
 
@@ -152,11 +153,13 @@  static void pc_init1(MemoryRegion *system_memory,
     }
     isa_bus_irqs(gsi);
 
-    if (!xen_enabled()) {
+    if (xen_enabled()) {
+        i8259 = xen_interrupt_controller_init();
+    } else if (qtest_enabled()) {
+        i8259 = qtest_interrupt_controller_init();
+    } else {
         cpu_irq = pc_allocate_cpu_irq();
         i8259 = i8259_init(cpu_irq[0]);
-    } else {
-        i8259 = xen_interrupt_controller_init();
     }
 
     for (i = 0; i < ISA_NUM_IRQS; i++) {