ide: introduce ide_register_restart_cb
authorPaolo Bonzini <pbonzini@redhat.com>
Mon, 23 Feb 2015 16:17:52 +0000 (11:17 -0500)
committerKevin Wolf <kwolf@redhat.com>
Tue, 10 Mar 2015 13:02:22 +0000 (14:02 +0100)
A helper is added that registers the IDEDMAOp .restart_cb()
via qemu_add_vm_change_state_handler instead of requiring
each HBA to register the callback themselves.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 1424708286-16483-4-git-send-email-jsnow@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
hw/ide/cmd646.c
hw/ide/core.c
hw/ide/internal.h
hw/ide/piix.c
hw/ide/via.c

index c8b0322155108bd9c0347eee4ba83b3c3347fccf..0374653471a1efd68f53c5e8b1761b1dd0e177dd 100644 (file)
@@ -368,8 +368,7 @@ static int pci_cmd646_ide_initfn(PCIDevice *dev)
 
         bmdma_init(&d->bus[i], &d->bmdma[i], d);
         d->bmdma[i].bus = &d->bus[i];
-        qemu_add_vm_change_state_handler(d->bus[i].dma->ops->restart_cb,
-                                         &d->bmdma[i].dma);
+        ide_register_restart_cb(&d->bus[i]);
     }
 
     vmstate_register(DEVICE(dev), 0, &vmstate_ide_pci, d);
index ac3f015a8dae3600ee20746face0fa87a4be5560..5a42771420e36dadf0086d86d3b0da38311eb2a6 100644 (file)
@@ -2330,6 +2330,11 @@ static const IDEDMAOps ide_dma_nop_ops = {
     .restart_cb     = ide_nop_restart,
 };
 
+void ide_register_restart_cb(IDEBus *bus)
+{
+    qemu_add_vm_change_state_handler(bus->dma->ops->restart_cb, bus->dma);
+}
+
 static IDEDMA ide_dma_nop = {
     .ops = &ide_dma_nop_ops,
     .aiocb = NULL,
index 2566503e5cb2f5d6f5f9deab5e2c644669749ed5..57ef5ca4a43ec373b50df35d820f47e0f7290b33 100644 (file)
@@ -551,6 +551,7 @@ int ide_init_drive(IDEState *s, BlockBackend *blk, IDEDriveKind kind,
                    int chs_trans);
 void ide_init2(IDEBus *bus, qemu_irq irq);
 void ide_init_ioport(IDEBus *bus, ISADevice *isa, int iobase, int iobase2);
+void ide_register_restart_cb(IDEBus *bus);
 
 void ide_exec_cmd(IDEBus *bus, uint32_t val);
 void ide_dma_cb(void *opaque, int ret);
index b0172fbf59917bf5fc72b272638b1947f75a0949..247dd4f8b0c3b4a44de26fa75da9b0fa9b586c30 100644 (file)
@@ -143,8 +143,7 @@ static void pci_piix_init_ports(PCIIDEState *d) {
 
         bmdma_init(&d->bus[i], &d->bmdma[i], d);
         d->bmdma[i].bus = &d->bus[i];
-        qemu_add_vm_change_state_handler(d->bus[i].dma->ops->restart_cb,
-                                         &d->bmdma[i].dma);
+        ide_register_restart_cb(&d->bus[i]);
     }
 }
 
index 4d8089de7509eb7741f150c3e37f99cf92d3e141..fb3d8a0861673a3f54e45cf2834b9481c1e056c7 100644 (file)
@@ -166,8 +166,7 @@ static void vt82c686b_init_ports(PCIIDEState *d) {
 
         bmdma_init(&d->bus[i], &d->bmdma[i], d);
         d->bmdma[i].bus = &d->bus[i];
-        qemu_add_vm_change_state_handler(d->bus[i].dma->ops->restart_cb,
-                                         &d->bmdma[i].dma);
+        ide_register_restart_cb(&d->bus[i]);
     }
 }