Skip to contentSkip to conversation

qemu-kvm: Switch to upstream in-kernel KVM PIT

PATCH Applied Jan Kiszka 2 participants 2 messages Apr 23, 2012 – Apr 24, 2012

Subsystems (2)
lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH 1/1 qemu-kvm: Switch to upstream in-kernel KVM PIT

The upstream version provides the same feature plus proper support for the PC speaker port while the in-kernel PIT is enabled.

---

A cleanup patch will follow once the _kvm_arch_init_vcpu thing is resolved.

 Makefile.objs     |    3 +-
 Makefile.target   |    2 -
 configure         |   11 -----
 hw/hpet.c         |    1 -
 hw/i8254-kvm.c    |  114 -----------------------------------------------------
 hw/i8254.c        |   19 ---------
 hw/i8254.h        |    6 ---
 hw/i8254_common.c |    2 +-
 hw/pc.c           |    4 +-
 vl.c              |   13 ++++++-
 10 files changed, 16 insertions(+), 159 deletions(-)
 delete mode 100644 hw/i8254-kvm.c
Makefile.objs +1 -2
index e1509f1..a166112 100644
@@ -227,8 +227,7 @@ hw-obj-$(CONFIG_EMPTY_SLOT) += empty_slot.o
 
 hw-obj-$(CONFIG_SERIAL) += serial.o
 hw-obj-$(CONFIG_PARALLEL) += parallel.o
-# Moved back to Makefile.target due to #include qemu-kvm.h:
-#hw-obj-$(CONFIG_I8254) += i8254_common.o i8254.o
+hw-obj-$(CONFIG_I8254) += i8254_common.o i8254.o
 hw-obj-$(CONFIG_PCSPK) += pcspk.o
 hw-obj-$(CONFIG_PCKBD) += pckbd.o
 hw-obj-$(CONFIG_USB_UHCI) += usb/hcd-uhci.o
Makefile.target +0 -2
index 5c74f88..7ed7535 100644
@@ -253,7 +253,6 @@ obj-i386-$(CONFIG_SPICE) += qxl.o qxl-logger.o qxl-render.o
 obj-i386-y += testdev.o
 obj-i386-y += acpi.o acpi_piix4.o
 
-obj-i386-y += i8254_common.o i8254.o
 obj-i386-$(CONFIG_KVM_DEVICE_ASSIGNMENT) += device-assignment.o
 
 # shared objects
@@ -310,7 +309,6 @@ obj-lm32-y += milkymist-vgafb.o
 obj-lm32-y += framebuffer.o
 
 obj-mips-y = mips_r4k.o mips_jazz.o mips_malta.o mips_mipssim.o
-obj-mips-y += i8254_common.o i8254.o
 obj-mips-y += acpi.o acpi_piix4.o
 obj-mips-y += mips_addr.o mips_timer.o mips_int.o
 obj-mips-y += gt64xxx.o mc146818rtc.o
configure +0 -11
index b1640f0..f69e08fd 100755
@@ -188,7 +188,6 @@ bsd_user="no"
 guest_base=""
 uname_release=""
 mixemu="no"
-kvm_cap_pit="yes"
 kvm_cap_device_assignment="yes"
 aix="no"
 blobs="yes"
@@ -710,10 +709,6 @@ for opt do
   ;;
   --enable-tcg-interpreter) tcg_interpreter="yes"
   ;;
-  --disable-kvm-pit) kvm_cap_pit="no"
-  ;;
-  --enable-kvm-pit) kvm_cap_pit="yes"
-  ;;
   --disable-kvm-device-assignment) kvm_cap_device_assignment="no"
   ;;
   --enable-kvm-device-assignment) kvm_cap_device_assignment="yes"
@@ -1078,8 +1073,6 @@ echo "  --disable-slirp          disable SLIRP userspace network connectivity"
 echo "  --disable-kvm            disable KVM acceleration support"
 echo "  --enable-kvm             enable KVM acceleration support"
 echo "  --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)"
-echo "  --disable-kvm-pit        disable KVM pit support"
-echo "  --enable-kvm-pit         enable KVM pit support"
 echo "  --disable-kvm-device-assignment  disable KVM device assignment support"
 echo "  --enable-kvm-device-assignment   enable KVM device assignment support"
 echo "  --disable-nptl           disable usermode NPTL support"
@@ -2959,7 +2952,6 @@ echo "ATTR/XATTR support $attr"
 echo "Install blobs     $blobs"
 echo "KVM support       $kvm"
 echo "TCG interpreter   $tcg_interpreter"
-echo "KVM PIT support   $kvm_cap_pit"
 echo "KVM device assig. $kvm_cap_device_assignment"
 echo "fdt support       $fdt"
 echo "preadv support    $preadv"
@@ -3677,9 +3669,6 @@ case "$target_arch2" in
       if test "$vhost_net" = "yes" ; then
         echo "CONFIG_VHOST_NET=y" >> $config_target_mak
       fi
-      if test $kvm_cap_pit = "yes" ; then
-        echo "CONFIG_KVM_PIT=y" >> $config_target_mak
-      fi
       if test $kvm_cap_device_assignment = "yes" ; then
         echo "CONFIG_KVM_DEVICE_ASSIGNMENT=y" >> $config_target_mak
       fi
hw/hpet.c +0 -1
index 51074b7..fd3ddca 100644
@@ -239,7 +239,6 @@ static int hpet_post_load(void *opaque, int version_id)
     if (s->timer[0].config & HPET_TN_FSB_CAP) {
         s->flags |= 1 << HPET_MSI_SUPPORT;
     }
-
     return 0;
 }
 
hw/i8254-kvm.c deleted +0 -114

114 lines not on this page · raw message

hw/i8254.c +0 -19
index 9604547..77bd5e8 100644
@@ -25,7 +25,6 @@
 #include "pc.h"
 #include "isa.h"
 #include "qemu-timer.h"
-#include "kvm.h"
 #include "i8254.h"
 #include "i8254_internal.h"
 
@@ -38,10 +37,6 @@
 
 static void pit_irq_timer_update(PITChannelState *s, int64_t current_time);
 
-#ifdef CONFIG_KVM_PIT
-static void qemu_kvm_pit_init(PITCommonState *pit);
-#endif
-
 static int pit_get_count(PITChannelState *s)
 {
     uint64_t d;
@@ -266,8 +261,6 @@ static void pit_irq_timer(void *opaque)
     pit_irq_timer_update(s, s->next_transition_time);
 }
 
-extern VMStateDescription vmstate_pit_common;
-
 static void pit_reset(DeviceState *dev)
 {
     PITCommonState *pit = DO_UPCAST(PITCommonState, dev.qdev, dev);
@@ -279,9 +272,6 @@ static void pit_reset(DeviceState *dev)
     if (!s->irq_disabled) {
         qemu_mod_timer(s->irq_timer, s->next_transition_time);
     }
-    if (vmstate_pit_common.post_load) {
-        vmstate_pit_common.post_load(pit, 2);
-    }
 }
 
 /* When HPET is operating in legacy mode, suppress the ignored timer IRQ,
@@ -325,13 +315,6 @@ static int pit_initfn(PITCommonState *pit)
 {
     PITChannelState *s;
 
-#ifdef CONFIG_KVM_PIT
-    if (kvm_enabled() && kvm_irqchip_in_kernel()) {
-        qemu_kvm_pit_init(pit);
-        return 0;
-    }
-#endif
-
     s = &pit->channels[0];
     /* the timer 0 is connected to an IRQ */
     s->irq_timer = qemu_new_timer_ns(vm_clock, pit_irq_timer, s);
@@ -375,5 +358,3 @@ static void pit_register_types(void)
 }
 
 type_init(pit_register_types)
-
-#include "i8254-kvm.c"
hw/i8254.h +0 -6
index 933866d..ba6b598 100644
@@ -27,7 +27,6 @@
 
 #include "hw.h"
 #include "isa.h"
-#include "kvm.h"
 
 #define PIT_FREQ 1193182
 
@@ -46,11 +45,6 @@ static inline ISADevice *pit_init(ISABus *bus, int base, int isa_irq,
     dev = isa_create(bus, "isa-pit");
     qdev_prop_set_uint32(&dev->qdev, "iobase", base);
     qdev_init_nofail(&dev->qdev);
-
-    if (kvm_enabled() && kvm_irqchip_in_kernel()) {
-        return dev;
-    }
-
     qdev_connect_gpio_out(&dev->qdev, 0,
                           isa_irq >= 0 ? isa_get_irq(dev, isa_irq) : alt_irq);
 
hw/i8254_common.c +1 -1
index e2e11b5..b01ad70 100644
@@ -266,7 +266,7 @@ static int pit_dispatch_post_load(void *opaque, int version_id)
     return 0;
 }
 
-VMStateDescription vmstate_pit_common = {
+static const VMStateDescription vmstate_pit_common = {
     .name = "i8254",
     .version_id = 3,
     .minimum_version_id = 2,
hw/pc.c +2 -2
index feb6ef3..edfeed1 100644
@@ -907,7 +907,7 @@ static DeviceState *apic_init(void *env, uint8_t apic_id)
         apic_mapped = 1;
     }
 
-#ifdef UNUSED_UPSTREAM_KVM
+#ifdef UPSTREAM_KVM
     /* KVM does not support MSI yet. */
     if (!kvm_irqchip_in_kernel()) {
         msi_supported = true;
@@ -1127,7 +1127,7 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
     } else {
         pit = pit_init(isa_bus, 0x40, pit_isa_irq, pit_alt_irq);
     }
-    if (hpet && !(kvm_enabled() && kvm_irqchip_in_kernel())) {
+    if (hpet) {
         /* connect PIT to output control line of the HPET */
         qdev_connect_gpio_out(hpet, 0, qdev_get_gpio_in(&pit->qdev, 0));
     }
vl.c +12 -1
index fccf647..e857b68 100644
@@ -2986,7 +2986,18 @@ int main(int argc, char **argv, char **envp)
 		break;
 	    }
             case QEMU_OPTION_no_kvm_pit_reinjection: {
-                kvm_pit_reinject = 0;
+                static GlobalProperty kvm_pit_lost_tick_policy[] = {
+                    {
+                        .driver   = "kvm-pit",
+                        .property = "lost_tick_policy",
+                        .value    = "discard",
+                    },
+                    { /* end of list */ }
+                };
+
+                fprintf(stderr, "Warning: option deprecated, use "
+                        "lost_tick_policy property of kvm-pit instead.\n");
+                qdev_prop_register_global_list(kvm_pit_lost_tick_policy);
                 break;
             }
 #endif
Signature · 1 line
1.7.3.4
Applied
#1 lore raw
Quoted 4 lines · Jan Kiszka

The upstream version provides the same feature plus proper support for the PC speaker port while the in-kernel PIT is enabled.

Thanks, applied.

Signature · 1 line
error compiling committee.c: too many arguments to function