qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: Pavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru>
Subject: [Qemu-devel] [PULL 09/13] apic_common: migrate missing fields
Date: Thu, 13 Nov 2014 16:40:24 +0100	[thread overview]
Message-ID: <1415893228-25823-10-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1415893228-25823-1-git-send-email-pbonzini@redhat.com>

From: Pavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru>

This patch adds missed sipi_vector and wait_for_sipi fields to a new
subsection of the vmstate of the apic_common module. Saving and loading
of these fields makes migration of the apic state deterministic.

Signed-off-by: Pavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru>
[Initialize the field in pre_load and kvm_apic_realize. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/i386/kvm/apic.c    |  3 +++
 hw/intc/apic_common.c | 38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+)

diff --git a/hw/i386/kvm/apic.c b/hw/i386/kvm/apic.c
index e873b50..271e97f 100644
--- a/hw/i386/kvm/apic.c
+++ b/hw/i386/kvm/apic.c
@@ -175,6 +175,9 @@ static void kvm_apic_realize(DeviceState *dev, Error **errp)
 {
     APICCommonState *s = APIC_COMMON(dev);
 
+    /* Not used by KVM, which uses the CPU mp_state instead.  */
+    s->wait_for_sipi = 0;
+
     memory_region_init_io(&s->io_memory, NULL, &kvm_apic_io_ops, s, "kvm-apic-msi",
                           APIC_SPACE_SIZE);
 
diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c
index ce3d903..4e62f25 100644
--- a/hw/intc/apic_common.c
+++ b/hw/intc/apic_common.c
@@ -324,6 +324,19 @@ static void apic_common_realize(DeviceState *dev, Error **errp)
 
 }
 
+static int apic_pre_load(void *opaque)
+{
+    APICCommonState *s = APIC_COMMON(opaque);
+
+    /* The default is !cpu_is_bsp(s->cpu), but the common value is 0
+     * so that's what apic_common_sipi_needed checks for.  Reset to
+     * the value that is assumed when the apic_sipi subsection is
+     * absent.
+     */
+    s->wait_for_sipi = 0;
+    return 0;
+}
+
 static void apic_dispatch_pre_save(void *opaque)
 {
     APICCommonState *s = APIC_COMMON(opaque);
@@ -345,12 +358,30 @@ static int apic_dispatch_post_load(void *opaque, int version_id)
     return 0;
 }
 
+static bool apic_common_sipi_needed(void *opaque)
+{
+    APICCommonState *s = APIC_COMMON(opaque);
+    return s->wait_for_sipi != 0;
+}
+
+static const VMStateDescription vmstate_apic_common_sipi = {
+    .name = "apic_sipi",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_INT32(sipi_vector, APICCommonState),
+        VMSTATE_INT32(wait_for_sipi, APICCommonState),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 static const VMStateDescription vmstate_apic_common = {
     .name = "apic",
     .version_id = 3,
     .minimum_version_id = 3,
     .minimum_version_id_old = 1,
     .load_state_old = apic_load_old,
+    .pre_load = apic_pre_load,
     .pre_save = apic_dispatch_pre_save,
     .post_load = apic_dispatch_post_load,
     .fields = (VMStateField[]) {
@@ -375,6 +406,13 @@ static const VMStateDescription vmstate_apic_common = {
         VMSTATE_INT64(timer_expiry,
                       APICCommonState), /* open-coded timer state */
         VMSTATE_END_OF_LIST()
+    },
+    .subsections = (VMStateSubsection[]) {
+        {
+            .vmsd = &vmstate_apic_common_sipi,
+            .needed = apic_common_sipi_needed,
+        },
+        VMSTATE_END_OF_LIST()
     }
 };
 
-- 
1.8.3.1

  parent reply	other threads:[~2014-11-13 15:41 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-13 15:40 [Qemu-devel] [PULL 00/13] x86 and SCSI patches for QEMU 2.2.0-rc2 Paolo Bonzini
2014-11-13 15:40 ` [Qemu-devel] [PULL 01/13] esp-pci: fixup deadlock with linux Paolo Bonzini
2014-11-13 15:40 ` [Qemu-devel] [PULL 02/13] virtio-scsi: work around bug in old BIOSes Paolo Bonzini
2014-11-13 15:40 ` [Qemu-devel] [PULL 03/13] esp: fix coding standards Paolo Bonzini
2014-11-13 15:40 ` [Qemu-devel] [PULL 04/13] virtio-scsi: dataplane: fix allocation for 'cmd_vrings' Paolo Bonzini
2014-11-13 15:40 ` [Qemu-devel] [PULL 05/13] esp: Do not overwrite ESP_TCHI after reset Paolo Bonzini
2014-11-13 15:40 ` [Qemu-devel] [PULL 06/13] virtio-scsi: dataplane: suppress guest notification Paolo Bonzini
2014-11-13 15:40 ` [Qemu-devel] [PULL 07/13] virtio-scsi: Fix comment for VirtIOSCSIReq Paolo Bonzini
2014-11-13 15:40 ` [Qemu-devel] [PULL 08/13] target-i386: eliminate dead code and hoist common code out of "if" Paolo Bonzini
2014-11-13 15:40 ` Paolo Bonzini [this message]
2014-11-13 15:40 ` [Qemu-devel] [PULL 10/13] target-i386: fix Coverity complaints about overflows Paolo Bonzini
2014-11-13 15:40 ` [Qemu-devel] [PULL 11/13] kvmclock: Add comment explaining why we need cpu_clean_all_dirty() Paolo Bonzini
2014-11-13 15:40 ` [Qemu-devel] [PULL 12/13] smbios: change 'ram_addr_t' variables to 'uint64_t' Paolo Bonzini
2014-11-13 15:40 ` [Qemu-devel] [PULL 13/13] acpi: accurate overflow check Paolo Bonzini
2014-11-13 16:43 ` [Qemu-devel] [PULL 00/13] x86 and SCSI patches for QEMU 2.2.0-rc2 Peter Maydell

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=1415893228-25823-10-git-send-email-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=Pavel.Dovgaluk@ispras.ru \
    --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).