qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 1.1] rebase xen patches
@ 2012-05-09 12:43 Stefano Stabellini
  2012-05-09 12:44 ` [Qemu-devel] [PATCH 1.1 1/4] xen: do not initialize the interval timer and PCSPK emulator Stefano Stabellini
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Stefano Stabellini @ 2012-05-09 12:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: xen-devel, Stefano Stabellini

Hi all,
this patch series is a collection of the outstanding Xen patches for
QEMU 1.1: all of them have been sent to qemu-devel at least once
already, some of them as many as 6 times.

Patch 1 and 2 remove unneeded devices and timers when Xen is enabled,
patch 3 and 4 are improvements for xen_disk.c.

Stefano Stabellini (4):
      xen: do not initialize the interval timer and PCSPK emulator
      xen: disable rtc_clock
      xen_disk: remove syncwrite option
      xen_disk: use bdrv_aio_flush instead of bdrv_flush

 hw/pc.c       |   23 +++++++++++++----------
 hw/xen_disk.c |   30 +++++++++++++++++++-----------
 xen-all.c     |    4 ++++
 3 files changed, 36 insertions(+), 21 deletions(-)

git://xenbits.xen.org/people/sstabellini/qemu-dm.git for_1.1

Cheers,

Stefano

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

* [Qemu-devel] [PATCH 1.1 1/4] xen: do not initialize the interval timer and PCSPK emulator
  2012-05-09 12:43 [Qemu-devel] [PATCH 1.1] rebase xen patches Stefano Stabellini
@ 2012-05-09 12:44 ` Stefano Stabellini
  2012-05-14 16:38   ` Anthony Liguori
  2012-05-09 12:44 ` [Qemu-devel] [PATCH 1.1 2/4] xen: disable rtc_clock Stefano Stabellini
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Stefano Stabellini @ 2012-05-09 12:44 UTC (permalink / raw)
  To: qemu-devel; +Cc: xen-devel, Stefano Stabellini

PIT and PCSPK are emulated by the hypervisor so we don't need to emulate
them in Qemu: this patch prevents Qemu from waking up needlessly at
PIT_FREQ on Xen.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
 hw/pc.c |   23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/hw/pc.c b/hw/pc.c
index 4d34a33..c52caf6 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -47,6 +47,7 @@
 #include "ui/qemu-spice.h"
 #include "memory.h"
 #include "exec-memory.h"
+#include "arch_init.h"
 
 /* output Bochs bios info messages */
 //#define DEBUG_BIOS
@@ -1097,7 +1098,7 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
     qemu_irq pit_alt_irq = NULL;
     qemu_irq rtc_irq = NULL;
     qemu_irq *a20_line;
-    ISADevice *i8042, *port92, *vmmouse, *pit;
+    ISADevice *i8042, *port92, *vmmouse, *pit = NULL;
     qemu_irq *cpu_exit_irq;
 
     register_ioport_write(0x80, 1, 1, ioport80_write, NULL);
@@ -1126,16 +1127,18 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
 
     qemu_register_boot_set(pc_boot_set, *rtc_state);
 
-    if (kvm_irqchip_in_kernel()) {
-        pit = kvm_pit_init(isa_bus, 0x40);
-    } else {
-        pit = pit_init(isa_bus, 0x40, pit_isa_irq, pit_alt_irq);
-    }
-    if (hpet) {
-        /* connect PIT to output control line of the HPET */
-        qdev_connect_gpio_out(hpet, 0, qdev_get_gpio_in(&pit->qdev, 0));
+    if (!xen_available()) {
+        if (kvm_irqchip_in_kernel()) {
+            pit = kvm_pit_init(isa_bus, 0x40);
+        } else {
+            pit = pit_init(isa_bus, 0x40, pit_isa_irq, pit_alt_irq);
+        }
+        if (hpet) {
+            /* connect PIT to output control line of the HPET */
+            qdev_connect_gpio_out(hpet, 0, qdev_get_gpio_in(&pit->qdev, 0));
+        }
+        pcspk_init(isa_bus, pit);
     }
-    pcspk_init(isa_bus, pit);
 
     for(i = 0; i < MAX_SERIAL_PORTS; i++) {
         if (serial_hds[i]) {
-- 
1.7.2.5

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

* [Qemu-devel] [PATCH 1.1 2/4] xen: disable rtc_clock
  2012-05-09 12:43 [Qemu-devel] [PATCH 1.1] rebase xen patches Stefano Stabellini
  2012-05-09 12:44 ` [Qemu-devel] [PATCH 1.1 1/4] xen: do not initialize the interval timer and PCSPK emulator Stefano Stabellini
@ 2012-05-09 12:44 ` Stefano Stabellini
  2012-05-09 12:44 ` [Qemu-devel] [PATCH 1.1 3/4] xen_disk: remove syncwrite option Stefano Stabellini
  2012-05-09 12:44 ` [Qemu-devel] [PATCH 1.1 4/4] xen_disk: use bdrv_aio_flush instead of bdrv_flush Stefano Stabellini
  3 siblings, 0 replies; 7+ messages in thread
From: Stefano Stabellini @ 2012-05-09 12:44 UTC (permalink / raw)
  To: qemu-devel; +Cc: xen-devel, Stefano Stabellini

rtc_clock is only used by the RTC emulator (mc146818rtc.c), however Xen
has its own RTC emulator in the hypervisor so we can disable it.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
 xen-all.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/xen-all.c b/xen-all.c
index bdf9c0f..b88ad5d 100644
--- a/xen-all.c
+++ b/xen-all.c
@@ -603,6 +603,10 @@ void xen_vcpu_init(void)
         qemu_register_reset(xen_reset_vcpu, first_cpu);
         xen_reset_vcpu(first_cpu);
     }
+    /* if rtc_clock is left to default (host_clock), disable it */
+    if (rtc_clock == host_clock) {
+        qemu_clock_enable(rtc_clock, false);
+    }
 }
 
 /* get the ioreq packets from share mem */
-- 
1.7.2.5

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

* [Qemu-devel] [PATCH 1.1 3/4] xen_disk: remove syncwrite option
  2012-05-09 12:43 [Qemu-devel] [PATCH 1.1] rebase xen patches Stefano Stabellini
  2012-05-09 12:44 ` [Qemu-devel] [PATCH 1.1 1/4] xen: do not initialize the interval timer and PCSPK emulator Stefano Stabellini
  2012-05-09 12:44 ` [Qemu-devel] [PATCH 1.1 2/4] xen: disable rtc_clock Stefano Stabellini
@ 2012-05-09 12:44 ` Stefano Stabellini
  2012-05-09 12:44 ` [Qemu-devel] [PATCH 1.1 4/4] xen_disk: use bdrv_aio_flush instead of bdrv_flush Stefano Stabellini
  3 siblings, 0 replies; 7+ messages in thread
From: Stefano Stabellini @ 2012-05-09 12:44 UTC (permalink / raw)
  To: qemu-devel; +Cc: xen-devel, Stefano Stabellini

This patch removes a dead option.

The same can be achieved removing BDRV_O_NOCACHE and BDRV_O_CACHE_WB
from the flags passed to bdrv_open.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
 hw/xen_disk.c |    8 +-------
 1 files changed, 1 insertions(+), 7 deletions(-)

diff --git a/hw/xen_disk.c b/hw/xen_disk.c
index 22dbd10..49e53b7 100644
--- a/hw/xen_disk.c
+++ b/hw/xen_disk.c
@@ -48,7 +48,6 @@
 
 /* ------------------------------------------------------------- */
 
-static int syncwrite    = 0;
 static int batch_maps   = 0;
 
 static int max_requests = 32;
@@ -189,15 +188,10 @@ static int ioreq_parse(struct ioreq *ioreq)
             ioreq->presync = 1;
             return 0;
         }
-        if (!syncwrite) {
-            ioreq->presync = ioreq->postsync = 1;
-        }
+        ioreq->presync = ioreq->postsync = 1;
         /* fall through */
     case BLKIF_OP_WRITE:
         ioreq->prot = PROT_READ; /* from memory */
-        if (syncwrite) {
-            ioreq->postsync = 1;
-        }
         break;
     default:
         xen_be_printf(&blkdev->xendev, 0, "error: unknown operation (%d)\n",
-- 
1.7.2.5

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

* [Qemu-devel] [PATCH 1.1 4/4] xen_disk: use bdrv_aio_flush instead of bdrv_flush
  2012-05-09 12:43 [Qemu-devel] [PATCH 1.1] rebase xen patches Stefano Stabellini
                   ` (2 preceding siblings ...)
  2012-05-09 12:44 ` [Qemu-devel] [PATCH 1.1 3/4] xen_disk: remove syncwrite option Stefano Stabellini
@ 2012-05-09 12:44 ` Stefano Stabellini
  3 siblings, 0 replies; 7+ messages in thread
From: Stefano Stabellini @ 2012-05-09 12:44 UTC (permalink / raw)
  To: qemu-devel; +Cc: xen-devel, Stefano Stabellini

Use bdrv_aio_flush instead of bdrv_flush.

Make sure to call bdrv_aio_writev/readv after the presync bdrv_aio_flush is fully
completed and make sure to call the postsync bdrv_aio_flush after
bdrv_aio_writev/readv is fully completed.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
 hw/xen_disk.c |   22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/hw/xen_disk.c b/hw/xen_disk.c
index 49e53b7..cf06243 100644
--- a/hw/xen_disk.c
+++ b/hw/xen_disk.c
@@ -66,6 +66,7 @@ struct ioreq {
     QEMUIOVector        v;
     int                 presync;
     int                 postsync;
+    uint8_t             mapped;
 
     /* grant mapping */
     uint32_t            domids[BLKIF_MAX_SEGMENTS_PER_REQUEST];
@@ -242,7 +243,7 @@ static void ioreq_unmap(struct ioreq *ioreq)
     XenGnttab gnt = ioreq->blkdev->xendev.gnttabdev;
     int i;
 
-    if (ioreq->v.niov == 0) {
+    if (ioreq->v.niov == 0 || ioreq->mapped == 0) {
         return;
     }
     if (batch_maps) {
@@ -268,6 +269,7 @@ static void ioreq_unmap(struct ioreq *ioreq)
             ioreq->page[i] = NULL;
         }
     }
+    ioreq->mapped = 0;
 }
 
 static int ioreq_map(struct ioreq *ioreq)
@@ -275,7 +277,7 @@ static int ioreq_map(struct ioreq *ioreq)
     XenGnttab gnt = ioreq->blkdev->xendev.gnttabdev;
     int i;
 
-    if (ioreq->v.niov == 0) {
+    if (ioreq->v.niov == 0 || ioreq->mapped == 1) {
         return 0;
     }
     if (batch_maps) {
@@ -307,9 +309,12 @@ static int ioreq_map(struct ioreq *ioreq)
             ioreq->blkdev->cnt_map++;
         }
     }
+    ioreq->mapped = 1;
     return 0;
 }
 
+static int ioreq_runio_qemu_aio(struct ioreq *ioreq);
+
 static void qemu_aio_complete(void *opaque, int ret)
 {
     struct ioreq *ioreq = opaque;
@@ -321,11 +326,19 @@ static void qemu_aio_complete(void *opaque, int ret)
     }
 
     ioreq->aio_inflight--;
+    if (ioreq->presync) {
+        ioreq->presync = 0;
+        ioreq_runio_qemu_aio(ioreq);
+        return;
+    }
     if (ioreq->aio_inflight > 0) {
         return;
     }
     if (ioreq->postsync) {
-        bdrv_flush(ioreq->blkdev->bs);
+        ioreq->postsync = 0;
+        ioreq->aio_inflight++;
+        bdrv_aio_flush(ioreq->blkdev->bs, qemu_aio_complete, ioreq);
+        return;
     }
 
     ioreq->status = ioreq->aio_errors ? BLKIF_RSP_ERROR : BLKIF_RSP_OKAY;
@@ -345,7 +358,8 @@ static int ioreq_runio_qemu_aio(struct ioreq *ioreq)
 
     ioreq->aio_inflight++;
     if (ioreq->presync) {
-        bdrv_flush(blkdev->bs); /* FIXME: aio_flush() ??? */
+        bdrv_aio_flush(ioreq->blkdev->bs, qemu_aio_complete, ioreq);
+        return 0;
     }
 
     switch (ioreq->req.operation) {
-- 
1.7.2.5

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

* Re: [Qemu-devel] [PATCH 1.1 1/4] xen: do not initialize the interval timer and PCSPK emulator
  2012-05-09 12:44 ` [Qemu-devel] [PATCH 1.1 1/4] xen: do not initialize the interval timer and PCSPK emulator Stefano Stabellini
@ 2012-05-14 16:38   ` Anthony Liguori
  2012-05-14 17:00     ` Stefano Stabellini
  0 siblings, 1 reply; 7+ messages in thread
From: Anthony Liguori @ 2012-05-14 16:38 UTC (permalink / raw)
  To: Stefano Stabellini; +Cc: xen-devel, qemu-devel

On 05/09/2012 07:44 AM, Stefano Stabellini wrote:
> PIT and PCSPK are emulated by the hypervisor so we don't need to emulate
> them in Qemu: this patch prevents Qemu from waking up needlessly at
> PIT_FREQ on Xen.
>
> Signed-off-by: Stefano Stabellini<stefano.stabellini@eu.citrix.com>
> ---
>   hw/pc.c |   23 +++++++++++++----------
>   1 files changed, 13 insertions(+), 10 deletions(-)
>
> diff --git a/hw/pc.c b/hw/pc.c
> index 4d34a33..c52caf6 100644
> --- a/hw/pc.c
> +++ b/hw/pc.c
> @@ -47,6 +47,7 @@
>   #include "ui/qemu-spice.h"
>   #include "memory.h"
>   #include "exec-memory.h"
> +#include "arch_init.h"
>
>   /* output Bochs bios info messages */
>   //#define DEBUG_BIOS
> @@ -1097,7 +1098,7 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
>       qemu_irq pit_alt_irq = NULL;
>       qemu_irq rtc_irq = NULL;
>       qemu_irq *a20_line;
> -    ISADevice *i8042, *port92, *vmmouse, *pit;
> +    ISADevice *i8042, *port92, *vmmouse, *pit = NULL;
>       qemu_irq *cpu_exit_irq;
>
>       register_ioport_write(0x80, 1, 1, ioport80_write, NULL);
> @@ -1126,16 +1127,18 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
>
>       qemu_register_boot_set(pc_boot_set, *rtc_state);
>
> -    if (kvm_irqchip_in_kernel()) {
> -        pit = kvm_pit_init(isa_bus, 0x40);
> -    } else {
> -        pit = pit_init(isa_bus, 0x40, pit_isa_irq, pit_alt_irq);
> -    }
> -    if (hpet) {
> -        /* connect PIT to output control line of the HPET */
> -        qdev_connect_gpio_out(hpet, 0, qdev_get_gpio_in(&pit->qdev, 0));
> +    if (!xen_available()) {

Shouldn't this be xen_enabled()?

Regards,

Anthony Liguori

> +        if (kvm_irqchip_in_kernel()) {
> +            pit = kvm_pit_init(isa_bus, 0x40);
> +        } else {
> +            pit = pit_init(isa_bus, 0x40, pit_isa_irq, pit_alt_irq);
> +        }
> +        if (hpet) {
> +            /* connect PIT to output control line of the HPET */
> +            qdev_connect_gpio_out(hpet, 0, qdev_get_gpio_in(&pit->qdev, 0));
> +        }
> +        pcspk_init(isa_bus, pit);
>       }
> -    pcspk_init(isa_bus, pit);
>
>       for(i = 0; i<  MAX_SERIAL_PORTS; i++) {
>           if (serial_hds[i]) {

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

* Re: [Qemu-devel] [PATCH 1.1 1/4] xen: do not initialize the interval timer and PCSPK emulator
  2012-05-14 16:38   ` Anthony Liguori
@ 2012-05-14 17:00     ` Stefano Stabellini
  0 siblings, 0 replies; 7+ messages in thread
From: Stefano Stabellini @ 2012-05-14 17:00 UTC (permalink / raw)
  To: Anthony Liguori
  Cc: xen-devel@lists.xensource.com, qemu-devel@nongnu.org,
	Stefano Stabellini

On Mon, 14 May 2012, Anthony Liguori wrote:
> On 05/09/2012 07:44 AM, Stefano Stabellini wrote:
> > PIT and PCSPK are emulated by the hypervisor so we don't need to emulate
> > them in Qemu: this patch prevents Qemu from waking up needlessly at
> > PIT_FREQ on Xen.
> >
> > Signed-off-by: Stefano Stabellini<stefano.stabellini@eu.citrix.com>
> > ---
> >   hw/pc.c |   23 +++++++++++++----------
> >   1 files changed, 13 insertions(+), 10 deletions(-)
> >
> > diff --git a/hw/pc.c b/hw/pc.c
> > index 4d34a33..c52caf6 100644
> > --- a/hw/pc.c
> > +++ b/hw/pc.c
> > @@ -47,6 +47,7 @@
> >   #include "ui/qemu-spice.h"
> >   #include "memory.h"
> >   #include "exec-memory.h"
> > +#include "arch_init.h"
> >
> >   /* output Bochs bios info messages */
> >   //#define DEBUG_BIOS
> > @@ -1097,7 +1098,7 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
> >       qemu_irq pit_alt_irq = NULL;
> >       qemu_irq rtc_irq = NULL;
> >       qemu_irq *a20_line;
> > -    ISADevice *i8042, *port92, *vmmouse, *pit;
> > +    ISADevice *i8042, *port92, *vmmouse, *pit = NULL;
> >       qemu_irq *cpu_exit_irq;
> >
> >       register_ioport_write(0x80, 1, 1, ioport80_write, NULL);
> > @@ -1126,16 +1127,18 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
> >
> >       qemu_register_boot_set(pc_boot_set, *rtc_state);
> >
> > -    if (kvm_irqchip_in_kernel()) {
> > -        pit = kvm_pit_init(isa_bus, 0x40);
> > -    } else {
> > -        pit = pit_init(isa_bus, 0x40, pit_isa_irq, pit_alt_irq);
> > -    }
> > -    if (hpet) {
> > -        /* connect PIT to output control line of the HPET */
> > -        qdev_connect_gpio_out(hpet, 0, qdev_get_gpio_in(&pit->qdev, 0));
> > +    if (!xen_available()) {
> 
> Shouldn't this be xen_enabled()?

Yes, it should!

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

end of thread, other threads:[~2012-05-14 17:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-09 12:43 [Qemu-devel] [PATCH 1.1] rebase xen patches Stefano Stabellini
2012-05-09 12:44 ` [Qemu-devel] [PATCH 1.1 1/4] xen: do not initialize the interval timer and PCSPK emulator Stefano Stabellini
2012-05-14 16:38   ` Anthony Liguori
2012-05-14 17:00     ` Stefano Stabellini
2012-05-09 12:44 ` [Qemu-devel] [PATCH 1.1 2/4] xen: disable rtc_clock Stefano Stabellini
2012-05-09 12:44 ` [Qemu-devel] [PATCH 1.1 3/4] xen_disk: remove syncwrite option Stefano Stabellini
2012-05-09 12:44 ` [Qemu-devel] [PATCH 1.1 4/4] xen_disk: use bdrv_aio_flush instead of bdrv_flush Stefano Stabellini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).