Skip to contentSkip to conversation

rebase xen patches

PATCH New Stefano Stabellini 2 participants 7 messages May 9, 2012 – May 14, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rebase xen patches

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

#1 lore raw

PATCH 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.

---
 hw/pc.c |   23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)
hw/pc.c +13 -10
index 4d34a33..c52caf6 100644
@@ -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]) {
Signature · 1 line
1.7.2.5
#2 lore raw

Re: [Qemu-devel] [PATCH 1.1 1/4] xen: do not initialize the interval timer and PCSPK emulator

Quoted 33 lines · 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.

---
  hw/pc.c |   23 +++++++++++++----------
  1 files changed, 13 insertions(+), 10 deletions(-)
hw/pc.c +2 -1
index 4d34a33..c52caf6 100644
@@ -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);

hw/pc.c void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi, · line 1130

Quoted 10 lines
hw/pc.c +1 -8
 
-    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

Quoted 15 lines
hw/pc.c +10 -1
+        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]) {
#3 lore raw

Re: [Qemu-devel] [PATCH 1.1 1/4] xen: do not initialize the interval timer and PCSPK emulator

Quoted 35 lines · Anthony Liguori
Quoted 34 lines · 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.

---
  hw/pc.c |   23 +++++++++++++----------
  1 files changed, 13 insertions(+), 10 deletions(-)
hw/pc.c +2 -1
index 4d34a33..c52caf6 100644
@@ -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);
 
Quoted 11 lines

hw/pc.c void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi, · line 1130

Quoted 9 lines
hw/pc.c +1 -8
-    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!

#4 lore raw

PATCH 2/4 xen: disable rtc_clock

In reply to 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.

---
 xen-all.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
xen-all.c +4 -0
index bdf9c0f..b88ad5d 100644
@@ -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 */
Signature · 1 line
1.7.2.5
#5 lore raw

PATCH 3/4 xen_disk: remove syncwrite option

In reply to 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.

---
 hw/xen_disk.c |    8 +-------
 1 files changed, 1 insertions(+), 7 deletions(-)
hw/xen_disk.c +1 -7
index 22dbd10..49e53b7 100644
@@ -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",
Signature · 1 line
1.7.2.5
#6 lore raw

PATCH 4/4 xen_disk: use bdrv_aio_flush instead of bdrv_flush

In reply to 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.

---
 hw/xen_disk.c |   22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 deletions(-)
hw/xen_disk.c +18 -4
index 49e53b7..cf06243 100644
@@ -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) {
Signature · 1 line
1.7.2.5