From 1af4bc979495e9e51b67635d5a9890c559e31078 Mon Sep 17 00:00:00 2001
From: Sheng Yang <[EMAIL PROTECTED]>
Date: Fri, 7 Mar 2008 19:13:06 +0800
Subject: [PATCH] kvm: qemu: Add save/restore support for in kernel PIT
Signed-off-by: Sheng Yang <[EMAIL PROTECTED]>
---
qemu/hw/i8254.c | 73
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 73 insertions(+), 0 deletions(-)
diff --git a/qemu/hw/i8254.c b/qemu/hw/i8254.c
index 9e18ebc..e215f8b 100644
--- a/qemu/hw/i8254.c
+++ b/qemu/hw/i8254.c
@@ -414,12 +414,78 @@ static void pit_irq_timer(void *opaque)
pit_irq_timer_update(s, s->next_transition_time);
}
+#ifdef KVM_CAP_PIT
+
+static void kvm_kernel_pit_save_to_user(PITState *s)
+{
+ struct kvm_pit_state pit;
+ struct kvm_pit_channel_state *c;
+ struct PITChannelState *sc;
+ int i;
+
+ kvm_get_pit(kvm_context, &pit);
+
+ for (i = 0; i < 3; i++) {
+ c = &pit.channels[i];
+ sc = &s->channels[i];
+ sc->count = c->count;
+ sc->latched_count = c->latched_count;
+ sc->count_latched = c->count_latched;
+ sc->status_latched = c->status_latched;
+ sc->status = c->status;
+ sc->read_state = c->read_state;
+ sc->write_state = c->write_state;
+ sc->write_latch = c->write_latch;
+ sc->rw_mode = c->rw_mode;
+ sc->mode = c->mode;
+ sc->bcd = c->bcd;
+ sc->gate = c->gate;
+ sc->count_load_time = c->count_load_time;
+ }
+}
+
+static void kvm_kernel_pit_load_from_user(PITState *s)
+{
+ struct kvm_pit_state pit;
+ struct kvm_pit_channel_state *c;
+ struct PITChannelState *sc;
+ int i;
+
+ for (i = 0; i < 3; i++) {
+ c = &pit.channels[i];
+ sc = &s->channels[i];
+ c->count = sc->count;
+ c->latched_count = sc->latched_count;
+ c->count_latched = sc->count_latched;
+ c->status_latched = sc->status_latched;
+ c->status = sc->status;
+ c->read_state = sc->read_state;
+ c->write_state = sc->write_state;
+ c->write_latch = sc->write_latch;
+ c->rw_mode = sc->rw_mode;
+ c->mode = sc->mode;
+ c->bcd = sc->bcd;
+ c->gate = sc->gate;
+ c->count_load_time = sc->count_load_time;
+ }
+
+ kvm_set_pit(kvm_context, &pit);
+}
+
+#endif
+
static void pit_save(QEMUFile *f, void *opaque)
{
PITState *pit = opaque;
PITChannelState *s;
int i;
+#ifdef KVM_CAP_PIT
+ if (kvm_enabled() && qemu_kvm_pit_in_kernel()) {
+ kvm_kernel_pit_save_to_user(pit);
+ }
+#endif
+
for(i = 0; i < 3; i++) {
s = &pit->channels[i];
qemu_put_be32(f, s->count);
@@ -471,6 +537,13 @@ static int pit_load(QEMUFile *f, void *opaque, int
version_id)
qemu_get_timer(f, s->irq_timer);
}
}
+
+#ifdef KVM_CAP_PIT
+ if (kvm_enabled() && qemu_kvm_pit_in_kernel()) {
+ kvm_kernel_pit_load_from_user(pit);
+ }
+#endif
+
return 0;
}
--
debian.1.5.3.7.1-dirty
From 1af4bc979495e9e51b67635d5a9890c559e31078 Mon Sep 17 00:00:00 2001
From: Sheng Yang <[EMAIL PROTECTED]>
Date: Fri, 7 Mar 2008 19:13:06 +0800
Subject: [PATCH] kvm: qemu: Add save/restore support for in kernel PIT
Signed-off-by: Sheng Yang <[EMAIL PROTECTED]>
---
qemu/hw/i8254.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 73 insertions(+), 0 deletions(-)
diff --git a/qemu/hw/i8254.c b/qemu/hw/i8254.c
index 9e18ebc..e215f8b 100644
--- a/qemu/hw/i8254.c
+++ b/qemu/hw/i8254.c
@@ -414,12 +414,78 @@ static void pit_irq_timer(void *opaque)
pit_irq_timer_update(s, s->next_transition_time);
}
+#ifdef KVM_CAP_PIT
+
+static void kvm_kernel_pit_save_to_user(PITState *s)
+{
+ struct kvm_pit_state pit;
+ struct kvm_pit_channel_state *c;
+ struct PITChannelState *sc;
+ int i;
+
+ kvm_get_pit(kvm_context, &pit);
+
+ for (i = 0; i < 3; i++) {
+ c = &pit.channels[i];
+ sc = &s->channels[i];
+ sc->count = c->count;
+ sc->latched_count = c->latched_count;
+ sc->count_latched = c->count_latched;
+ sc->status_latched = c->status_latched;
+ sc->status = c->status;
+ sc->read_state = c->read_state;
+ sc->write_state = c->write_state;
+ sc->write_latch = c->write_latch;
+ sc->rw_mode = c->rw_mode;
+ sc->mode = c->mode;
+ sc->bcd = c->bcd;
+ sc->gate = c->gate;
+ sc->count_load_time = c->count_load_time;
+ }
+}
+
+static void kvm_kernel_pit_load_from_user(PITState *s)
+{
+ struct kvm_pit_state pit;
+ struct kvm_pit_channel_state *c;
+ struct PITChannelState *sc;
+ int i;
+
+ for (i = 0; i < 3; i++) {
+ c = &pit.channels[i];
+ sc = &s->channels[i];
+ c->count = sc->count;
+ c->latched_count = sc->latched_count;
+ c->count_latched = sc->count_latched;
+ c->status_latched = sc->status_latched;
+ c->status = sc->status;
+ c->read_state = sc->read_state;
+ c->write_state = sc->write_state;
+ c->write_latch = sc->write_latch;
+ c->rw_mode = sc->rw_mode;
+ c->mode = sc->mode;
+ c->bcd = sc->bcd;
+ c->gate = sc->gate;
+ c->count_load_time = sc->count_load_time;
+ }
+
+ kvm_set_pit(kvm_context, &pit);
+}
+
+#endif
+
static void pit_save(QEMUFile *f, void *opaque)
{
PITState *pit = opaque;
PITChannelState *s;
int i;
+#ifdef KVM_CAP_PIT
+ if (kvm_enabled() && qemu_kvm_pit_in_kernel()) {
+ kvm_kernel_pit_save_to_user(pit);
+ }
+#endif
+
for(i = 0; i < 3; i++) {
s = &pit->channels[i];
qemu_put_be32(f, s->count);
@@ -471,6 +537,13 @@ static int pit_load(QEMUFile *f, void *opaque, int version_id)
qemu_get_timer(f, s->irq_timer);
}
}
+
+#ifdef KVM_CAP_PIT
+ if (kvm_enabled() && qemu_kvm_pit_in_kernel()) {
+ kvm_kernel_pit_load_from_user(pit);
+ }
+#endif
+
return 0;
}
--
debian.1.5.3.7.1-dirty
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel