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
Stefano Stabellini
2012-May-09 12:44 UTC
[PATCH 1.1 1/4] xen: do not initialize the interval timer and PCSPK emulator
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
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
Stefano Stabellini
2012-May-09 12:44 UTC
[PATCH 1.1 3/4] xen_disk: remove syncwrite option
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
Stefano Stabellini
2012-May-09 12:44 UTC
[PATCH 1.1 4/4] xen_disk: use bdrv_aio_flush instead of bdrv_flush
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
Anthony Liguori
2012-May-14 16:38 UTC
Re: [PATCH 1.1 1/4] xen: do not initialize the interval timer and PCSPK emulator
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]) {
Stefano Stabellini
2012-May-14 17:00 UTC
Re: [PATCH 1.1 1/4] xen: do not initialize the interval timer and PCSPK emulator
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!