Signed-off-by: Marcelo Tosatti <[EMAIL PROTECTED]>
Index: kvm-userspace.realtip/qemu/hw/acpi.c
===================================================================
--- kvm-userspace.realtip.orig/qemu/hw/acpi.c
+++ kvm-userspace.realtip/qemu/hw/acpi.c
@@ -86,8 +86,16 @@ static uint32_t get_pmtmr(PIIX4PMState *
{
uint32_t d;
if (!s->direct_access) {
- d = muldiv64(qemu_get_clock(vm_clock), PM_FREQ, ticks_per_sec);
- d += s->pmtimer_offset;
+ if (qemu_kvm_acpi_timer_in_kernel()) {
+#ifdef KVM_CAP_ACPI_TIMER
+ struct kvm_acpi_timer_state acpi_state;
+ kvm_get_acpi_timer(kvm_context, &acpi_state);
+ return acpi_state.timer_val;
+#endif
+ } else {
+ d = muldiv64(qemu_get_clock(vm_clock), PM_FREQ, ticks_per_sec);
+ d += s->pmtimer_offset;
+ }
} else
qemu_kvm_get_pmtimer(&d);
@@ -482,6 +490,22 @@ static void pm_write_config(PCIDevice *d
pm_io_space_update((PIIX4PMState *)d, 0);
}
+#ifdef KVM_CAP_ACPI_TIMER
+static int kvm_restore_acpi_timer(uint32_t pmtmr_val, uint32_t pmtimer_base)
+{
+ struct kvm_acpi_timer_state acpi_state;
+ acpi_state.timer_val = pmtmr_val;
+ acpi_state.base_address = pmtimer_base;
+
+ return kvm_set_acpi_timer(kvm_context, &acpi_state);
+}
+#else
+static int kvm_restore_acpi_timer(uint32_t pmtmr_val, uint32_t pmtimer_base)
+{
+ return -EINVAL;
+}
+#endif
+
static void pm_save(QEMUFile* f,void *opaque)
{
PIIX4PMState *s = opaque;
@@ -544,6 +568,12 @@ static int pm_load(QEMUFile* f,void* opa
host_pmtimer_base = 0;
}
#endif
+ if (qemu_kvm_acpi_timer_in_kernel()) {
+ ret = kvm_restore_acpi_timer(pmtmr_val, s->pmtimer_base);
+ if (ret)
+ return ret;
+ }
+
s->pmtimer_offset = pmtmr_val - get_pmtmr(s);
}
--
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html