From: Jan Kiszka <jan.kiszka@web.de>
To: Avi Kivity <avi@redhat.com>, Marcelo Tosatti <mtosatti@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Anthony Liguori <aliguori@us.ibm.com>,
qemu-devel <qemu-devel@nongnu.org>,
kvm@vger.kernel.org
Subject: [Qemu-devel] [PATCH 2/4 v3] i8254: Open-code timer restore
Date: Sun, 05 Feb 2012 13:03:53 +0100 [thread overview]
Message-ID: <4F2E7029.5000802@web.de> (raw)
In-Reply-To: <77a9fa5aa9aae73889803315c291418a4d99505a.1328438750.git.jan.kiszka@web.de>
From: Jan Kiszka <jan.kiszka@siemens.com>
Same as for the APIC: To enable migration between accelerated and
non-accelerated models, we need to arm the channel 0 timer only inside
the emulated PIT model. The common code just saves/restores that timer
to the the next_transition_time field.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
Changes in v3:
- invoke post_load callback from load_old (as noted by Paolo)
hw/i8254.c | 12 ++++++++++++
hw/i8254_common.c | 10 +++++++---
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/hw/i8254.c b/hw/i8254.c
index f9f58e0..d41ee05 100644
--- a/hw/i8254.c
+++ b/hw/i8254.c
@@ -300,6 +300,17 @@ static const MemoryRegionOps pit_ioport_ops = {
.old_portio = pit_portio
};
+static void pit_post_load(PITCommonState *s)
+{
+ PITChannelState *sc = &s->channels[0];
+
+ if (sc->next_transition_time != -1) {
+ qemu_mod_timer(sc->irq_timer, sc->next_transition_time);
+ } else {
+ qemu_del_timer(sc->irq_timer);
+ }
+}
+
static int pit_initfn(PITCommonState *pit)
{
PITChannelState *s;
@@ -329,6 +340,7 @@ static void pit_class_initfn(ObjectClass *klass, void *data)
k->init = pit_initfn;
k->set_channel_gate = pit_set_channel_gate;
k->get_channel_info = pit_get_channel_info_common;
+ k->post_load = pit_post_load;
dc->reset = pit_reset;
dc->props = pit_properties;
}
diff --git a/hw/i8254_common.c b/hw/i8254_common.c
index 0601d88..2517db6 100644
--- a/hw/i8254_common.c
+++ b/hw/i8254_common.c
@@ -211,6 +211,7 @@ static const VMStateDescription vmstate_pit_channel = {
static int pit_load_old(QEMUFile *f, void *opaque, int version_id)
{
PITCommonState *pit = opaque;
+ PITCommonClass *c = PIT_COMMON_GET_CLASS(pit);
PITChannelState *s;
int i;
@@ -234,11 +235,13 @@ static int pit_load_old(QEMUFile *f, void *opaque, int version_id)
qemu_get_8s(f, &s->gate);
s->count_load_time = qemu_get_be64(f);
s->irq_disabled = 0;
- if (s->irq_timer) {
+ if (i == 0) {
s->next_transition_time = qemu_get_be64(f);
- qemu_get_timer(f, s->irq_timer);
}
}
+ if (c->post_load) {
+ c->post_load(pit);
+ }
return 0;
}
@@ -275,7 +278,8 @@ static const VMStateDescription vmstate_pit_common = {
VMSTATE_UINT32_V(channels[0].irq_disabled, PITCommonState, 3),
VMSTATE_STRUCT_ARRAY(channels, PITCommonState, 3, 2,
vmstate_pit_channel, PITChannelState),
- VMSTATE_TIMER(channels[0].irq_timer, PITCommonState),
+ VMSTATE_INT64(channels[0].next_transition_time,
+ PITCommonState), /* formerly irq_timer */
VMSTATE_END_OF_LIST()
}
};
next prev parent reply other threads:[~2012-02-05 12:04 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-05 10:46 [Qemu-devel] [PATCH 0/4] uq/master: Introduce KVM PIT support Jan Kiszka
2012-02-05 10:46 ` [Qemu-devel] [PATCH 1/4] i8254: Factor out base class for KVM reuse Jan Kiszka
2012-02-05 10:46 ` [Qemu-devel] [PATCH 2/4] i8254: Open-code timer restore Jan Kiszka
2012-02-05 11:23 ` Paolo Bonzini
2012-02-05 11:33 ` Jan Kiszka
2012-02-05 12:03 ` Jan Kiszka [this message]
2012-02-05 10:46 ` [Qemu-devel] [PATCH 3/4] kvm: Add kvm_has_pit_state2 helper Jan Kiszka
2012-02-05 20:03 ` Juan Quintela
2012-02-05 20:36 ` Jan Kiszka
2012-02-05 10:46 ` [Qemu-devel] [PATCH 4/4] kvm: x86: Add user space part for in-kernel i8254 Jan Kiszka
2012-02-08 18:24 ` [Qemu-devel] [PATCH 0/4] uq/master: Introduce KVM PIT support Marcelo Tosatti
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=4F2E7029.5000802@web.de \
--to=jan.kiszka@web.de \
--cc=aliguori@us.ibm.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/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;
as well as URLs for NNTP newsgroup(s).