public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: "Yang, Sheng" <sheng.yang@intel.com>
To: kvm-devel@lists.sourceforge.net
Subject: [PATCH 6/6] kvm: qemu: Add save/restore support for in kernel PIT
Date: Fri, 7 Mar 2008 20:52:27 +0800	[thread overview]
Message-ID: <200803072052.28094.sheng.yang@intel.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2915 bytes --]

From 1af4bc979495e9e51b67635d5a9890c559e31078 Mon Sep 17 00:00:00 2001
From: Sheng Yang <sheng.yang@intel.com>
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 <sheng.yang@intel.com>
---
 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


[-- Attachment #2: 0004-kvm-qemu-Add-save-restore-support-for-in-kernel-PI.patch --]
[-- Type: text/x-diff, Size: 2915 bytes --]

From 1af4bc979495e9e51b67635d5a9890c559e31078 Mon Sep 17 00:00:00 2001
From: Sheng Yang <sheng.yang@intel.com>
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 <sheng.yang@intel.com>
---
 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


[-- Attachment #3: Type: text/plain, Size: 228 bytes --]

-------------------------------------------------------------------------
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/

[-- Attachment #4: Type: text/plain, Size: 158 bytes --]

_______________________________________________
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel

             reply	other threads:[~2008-03-07 12:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-07 12:52 Yang, Sheng [this message]
  -- strict thread matches above, loose matches on Subject: below --
2008-03-04 10:23 [PATCH 6/6] kvm: qemu: Add save/restore support for in kernel PIT Yang, Sheng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200803072052.28094.sheng.yang@intel.com \
    --to=sheng.yang@intel.com \
    --cc=kvm-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox