All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] [RFC] Make kvm-unit-tests more friendly to upstream QEMU
@ 2011-08-30 23:51 Lucas Meneghel Rodrigues
  2011-08-30 23:51 ` [PATCH 1/2] kvm-unit-tests: add x86 port io accessors Lucas Meneghel Rodrigues
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Lucas Meneghel Rodrigues @ 2011-08-30 23:51 UTC (permalink / raw)
  To: kvm; +Cc: avi, Lucas Meneghel Rodrigues

aliguori - This series makes an attempt to make kvm-unit-tests more friendly
to upstream QEMU.  I've been writing unit tests for all of the QMP commands
and many of them, like ballooning, require guest cooperation to be tested in
a meaningful way.

I'm leaning towards building simple guests using libcflat in order to do this
using some very simple PCI device drivers.  To get started, I made a few changes
to kvm-unit-tests to make them more friendly to QEMU upstream basically by
using platform devices instead of relying on special test devices.

lmr - This is an attempt to revive Anthony's patch series to kvm-unit-tests,
I tried to figure out what an updated version of the patchset would look like,
that is, dropping patch "do not set level sensitive irq when initializing the PIC"
and putting the old behavior of the test dev writes on an ifdef block. Let
me know if I got this right. Original patches for reference:

http://lists.gnu.org/archive/html/qemu-devel/2011-02/msg03025.html
http://lists.gnu.org/archive/html/qemu-devel/2011-02/msg03022.html
http://lists.gnu.org/archive/html/qemu-devel/2011-02/msg03023.html
http://lists.gnu.org/archive/html/qemu-devel/2011-02/msg03024.html

Anthony Liguori (2):
  kvm-unit-tests: add x86 port io accessors
  kvm-unit-tests: make I/O more friendly to existing QEMU hardware

 lib/x86/io.c |   58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 lib/x86/io.h |   40 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 97 insertions(+), 1 deletions(-)
 create mode 100644 lib/x86/io.h

-- 
1.7.6


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] kvm-unit-tests: add x86 port io accessors
  2011-08-30 23:51 [PATCH 0/2] [RFC] Make kvm-unit-tests more friendly to upstream QEMU Lucas Meneghel Rodrigues
@ 2011-08-30 23:51 ` Lucas Meneghel Rodrigues
  2011-08-30 23:51 ` [PATCH 2/2] kvm-unit-tests: make I/O more friendly to existing QEMU hardware Lucas Meneghel Rodrigues
  2011-08-31  9:43 ` [PATCH 0/2] [RFC] Make kvm-unit-tests more friendly to upstream QEMU Avi Kivity
  2 siblings, 0 replies; 4+ messages in thread
From: Lucas Meneghel Rodrigues @ 2011-08-30 23:51 UTC (permalink / raw)
  To: kvm; +Cc: avi, Lucas Meneghel Rodrigues, Anthony Liguori

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
 lib/x86/io.h |   40 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 40 insertions(+), 0 deletions(-)
 create mode 100644 lib/x86/io.h

diff --git a/lib/x86/io.h b/lib/x86/io.h
new file mode 100644
index 0000000..bd6341c
--- /dev/null
+++ b/lib/x86/io.h
@@ -0,0 +1,40 @@
+#ifndef IO_H
+#define IO_H
+
+static inline unsigned char inb(unsigned short port)
+{
+    unsigned char value;
+    asm volatile("inb %w1, %0" : "=a" (value) : "Nd" (port));
+    return value;
+}
+
+static inline unsigned short inw(unsigned short port)
+{
+    unsigned short value;
+    asm volatile("inw %w1, %0" : "=a" (value) : "Nd" (port));
+    return value;
+}
+
+static inline unsigned int inl(unsigned short port)
+{
+    unsigned int value;
+    asm volatile("inl %w1, %0" : "=a" (value) : "Nd" (port));
+    return value;
+}
+
+static inline void outb(unsigned char value, unsigned short port)
+{
+    asm volatile("outb %b0, %w1" : : "a"(value), "Nd"(port));
+}
+
+static inline void outw(unsigned short value, unsigned short port)
+{
+    asm volatile("outw %w0, %w1" : : "a"(value), "Nd"(port));
+}
+
+static inline void outl(unsigned int value, unsigned short port)
+{
+    asm volatile("outl %0, %w1" : : "a"(value), "Nd"(port));
+}
+
+#endif
-- 
1.7.6


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] kvm-unit-tests: make I/O more friendly to existing QEMU hardware
  2011-08-30 23:51 [PATCH 0/2] [RFC] Make kvm-unit-tests more friendly to upstream QEMU Lucas Meneghel Rodrigues
  2011-08-30 23:51 ` [PATCH 1/2] kvm-unit-tests: add x86 port io accessors Lucas Meneghel Rodrigues
@ 2011-08-30 23:51 ` Lucas Meneghel Rodrigues
  2011-08-31  9:43 ` [PATCH 0/2] [RFC] Make kvm-unit-tests more friendly to upstream QEMU Avi Kivity
  2 siblings, 0 replies; 4+ messages in thread
From: Lucas Meneghel Rodrigues @ 2011-08-30 23:51 UTC (permalink / raw)
  To: kvm; +Cc: avi, Lucas Meneghel Rodrigues, Anthony Liguori

Use the serial port for printf() and use the Bochs bios exit
port if the testdev port isn't available.

This unconditionally switches to use the serial port but tries
to use the testdev exit port since that lets you pass an exit
status.

This version puts the old behavior on an IFDEF block, as Avi
asked on the first review of the patch.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
---
 lib/x86/io.c |   60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 59 insertions(+), 1 deletions(-)

diff --git a/lib/x86/io.c b/lib/x86/io.c
index 894f398..1f550b5 100644
--- a/lib/x86/io.c
+++ b/lib/x86/io.c
@@ -1,13 +1,58 @@
 #include "libcflat.h"
 #include "smp.h"
+#include "io.h"
+#ifndef USE_SERIAL
+#define USE_SERIAL
 
 static struct spinlock lock;
+static int serial_iobase = 0x3f8;
+static int serial_inited = 0;
+
+static void serial_outb(char ch)
+{
+        u8 lsr;
+
+        do {
+                lsr = inb(serial_iobase + 0x05);
+        } while (!(lsr & 0x20));
+
+        outb(ch, serial_iobase + 0x00);
+}
+
+static void serial_init(void)
+{
+        u8 lcr;
+
+        /* set DLAB */
+        lcr = inb(serial_iobase + 0x03);
+        lcr |= 0x80;
+        outb(lcr, serial_iobase + 0x03);
+
+        /* set baud rate to 115200 */
+        outb(0x01, serial_iobase + 0x00);
+        outb(0x00, serial_iobase + 0x01);
+
+        /* clear DLAB */
+        lcr = inb(serial_iobase + 0x03);
+        lcr &= ~0x80;
+        outb(lcr, serial_iobase + 0x03);
+}
 
 static void print_serial(const char *buf)
 {
 	unsigned long len = strlen(buf);
+#ifdef USE_SERIAL
+        unsigned long i;
+        if (!serial_inited) {
+            serial_init();
+        }
 
-	asm volatile ("rep/outsb" : "+S"(buf), "+c"(len) : "d"(0xf1));
+        for (i = 0; i < len; i++) {
+            serial_outb(buf[i]);
+        }
+#else
+        asm volatile ("rep/outsb" : "+S"(buf), "+c"(len) : "d"(0xf1));
+#endif
 }
 
 void puts(const char *s)
@@ -19,5 +64,18 @@ void puts(const char *s)
 
 void exit(int code)
 {
+#ifdef USE_SERIAL
+        static const char shutdown_str[8] = "Shutdown";
+        int i;
+
+        /* test device exit (with status) */
+        outl(code, 0xf4);
+
+        /* if that failed, try the Bochs poweroff port */
+        for (i = 0; i < 8; i++) {
+                outb(shutdown_str[i], 0x8900);
+        }
+#else
         asm volatile("out %0, %1" : : "a"(code), "d"((short)0xf4));
+#endif
 }
-- 
1.7.6


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] [RFC] Make kvm-unit-tests more friendly to upstream QEMU
  2011-08-30 23:51 [PATCH 0/2] [RFC] Make kvm-unit-tests more friendly to upstream QEMU Lucas Meneghel Rodrigues
  2011-08-30 23:51 ` [PATCH 1/2] kvm-unit-tests: add x86 port io accessors Lucas Meneghel Rodrigues
  2011-08-30 23:51 ` [PATCH 2/2] kvm-unit-tests: make I/O more friendly to existing QEMU hardware Lucas Meneghel Rodrigues
@ 2011-08-31  9:43 ` Avi Kivity
  2 siblings, 0 replies; 4+ messages in thread
From: Avi Kivity @ 2011-08-31  9:43 UTC (permalink / raw)
  To: Lucas Meneghel Rodrigues; +Cc: kvm

On 08/31/2011 02:51 AM, Lucas Meneghel Rodrigues wrote:
> aliguori - This series makes an attempt to make kvm-unit-tests more friendly
> to upstream QEMU.  I've been writing unit tests for all of the QMP commands
> and many of them, like ballooning, require guest cooperation to be tested in
> a meaningful way.
>
> I'm leaning towards building simple guests using libcflat in order to do this
> using some very simple PCI device drivers.  To get started, I made a few changes
> to kvm-unit-tests to make them more friendly to QEMU upstream basically by
> using platform devices instead of relying on special test devices.
>
> lmr - This is an attempt to revive Anthony's patch series to kvm-unit-tests,
> I tried to figure out what an updated version of the patchset would look like,
> that is, dropping patch "do not set level sensitive irq when initializing the PIC"
> and putting the old behavior of the test dev writes on an ifdef block. Let
> me know if I got this right. Original patches for reference:
>
> http://lists.gnu.org/archive/html/qemu-devel/2011-02/msg03025.html
> http://lists.gnu.org/archive/html/qemu-devel/2011-02/msg03022.html
> http://lists.gnu.org/archive/html/qemu-devel/2011-02/msg03023.html
> http://lists.gnu.org/archive/html/qemu-devel/2011-02/msg03024.html
>

Thanks, applied.

-- 
error compiling committee.c: too many arguments to function


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-08-31  9:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-30 23:51 [PATCH 0/2] [RFC] Make kvm-unit-tests more friendly to upstream QEMU Lucas Meneghel Rodrigues
2011-08-30 23:51 ` [PATCH 1/2] kvm-unit-tests: add x86 port io accessors Lucas Meneghel Rodrigues
2011-08-30 23:51 ` [PATCH 2/2] kvm-unit-tests: make I/O more friendly to existing QEMU hardware Lucas Meneghel Rodrigues
2011-08-31  9:43 ` [PATCH 0/2] [RFC] Make kvm-unit-tests more friendly to upstream QEMU Avi Kivity

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.