diff mbox

qemu-kvm: Fix savevm under -no-kvm

Message ID 4AFB44C0.3080603@web.de (mailing list archive)
State New, archived
Headers show

Commit Message

Jan Kiszka Nov. 11, 2009, 11:12 p.m. UTC
None
diff mbox

Patch

diff --git a/hw/i8259.c b/hw/i8259.c
index 6f44ceb..7a484c0 100644
--- a/hw/i8259.c
+++ b/hw/i8259.c
@@ -464,18 +464,33 @@  static uint32_t elcr_ioport_read(void *opaque, uint32_t addr1)
     return s->elcr;
 }
 
-#ifdef KVM_CAP_IRQCHIP
-static void kvm_kernel_pic_save_to_user(void *opaque);
-static int kvm_kernel_pic_load_from_user(void *opaque, int version_id);
-#endif
+static void kvm_kernel_pic_save_to_user(PicState *s);
+static int kvm_kernel_pic_load_from_user(PicState *s);
+
+static void pic_pre_save(void *opaque)
+{
+    PicState *s = opaque;
+
+    if (kvm_enabled() && kvm_irqchip_in_kernel()) {
+        kvm_kernel_pic_save_to_user(s);
+    }
+}
+
+static int pic_post_load(void *opaque, int version_id)
+{
+    PicState *s = opaque;
+
+    if (kvm_enabled() && kvm_irqchip_in_kernel()) {
+        kvm_kernel_pic_load_from_user(s);
+    }
+    return 0;
+}
 
 static const VMStateDescription vmstate_pic = {
     .name = "i8259",
     .version_id = 1,
-#ifdef KVM_CAP_IRQCHIP
-    .pre_save = kvm_kernel_pic_save_to_user,
-    .post_load = kvm_kernel_pic_load_from_user,
-#endif
+    .pre_save = pic_pre_save,
+    .post_load = pic_post_load,
     .minimum_version_id = 1,
     .minimum_version_id_old = 1,
     .fields      = (VMStateField []) {
@@ -563,11 +578,9 @@  qemu_irq *i8259_init(qemu_irq parent_irq)
     return qemu_allocate_irqs(i8259_set_irq, s, 16);
 }
 
-#ifdef KVM_CAP_IRQCHIP
-static void kvm_kernel_pic_save_to_user(void *opaque)
+static void kvm_kernel_pic_save_to_user(PicState *s)
 {
-#if defined(TARGET_I386)
-    PicState *s = (void *)opaque;
+#ifdef KVM_CAP_IRQCHIP
     struct kvm_irqchip chip;
     struct kvm_pic_state *kpic;
 
@@ -596,10 +609,9 @@  static void kvm_kernel_pic_save_to_user(void *opaque)
 #endif
 }
 
-static int kvm_kernel_pic_load_from_user(void *opaque, int version)
+static int kvm_kernel_pic_load_from_user(PicState *s)
 {
-#if defined(TARGET_I386)
-    PicState *s = (void *)opaque;
+#ifdef KVM_CAP_IRQCHIP
     struct kvm_irqchip chip;
     struct kvm_pic_state *kpic;
 
@@ -630,6 +642,7 @@  static int kvm_kernel_pic_load_from_user(void *opaque, int version)
     return 0;
 }
 
+#ifdef KVM_CAP_IRQCHIP
 static void kvm_i8259_set_irq(void *opaque, int irq, int level)
 {
     int pic_ret;