diff mbox

[RFC,1/2] ahci: Refactor ports as a fixed-size array for VMState

Message ID 1324652151-4299-2-git-send-email-afaerber@suse.de
State New
Headers show

Commit Message

Andreas Färber Dec. 23, 2011, 2:55 p.m. UTC
It seems, VMState cannot handle a dynamically allocated array of
structs at this time.

Change AHCIState to use an AHCIDevice array of size AHCI_MAX_PORTS.
Of those 32, only 6 are being used for ich9.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Cc: Juan Quintela <quintela@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Alexander Graf <agraf@suse.de>
---
 hw/ide/ahci.c |    3 +--
 hw/ide/ahci.h |    2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
index 0af201d..51cb48b 100644
--- a/hw/ide/ahci.c
+++ b/hw/ide/ahci.c
@@ -1168,7 +1168,7 @@  void ahci_init(AHCIState *s, DeviceState *qdev, int ports)
     int i;
 
     s->ports = ports;
-    s->dev = g_malloc0(sizeof(AHCIDevice) * ports);
+    memset(s->dev, 0, sizeof(AHCIDevice) * ports);
     ahci_reg_init(s);
     /* XXX BAR size should be 1k, but that breaks, so bump it to 4k for now */
     memory_region_init_io(&s->mem, &ahci_mem_ops, s, "ahci", AHCI_MEM_BAR_SIZE);
@@ -1194,7 +1194,6 @@  void ahci_uninit(AHCIState *s)
 {
     memory_region_destroy(&s->mem);
     memory_region_destroy(&s->idp);
-    g_free(s->dev);
 }
 
 void ahci_reset(void *opaque)
diff --git a/hw/ide/ahci.h b/hw/ide/ahci.h
index b223d2c..4df7c2b 100644
--- a/hw/ide/ahci.h
+++ b/hw/ide/ahci.h
@@ -291,7 +291,7 @@  struct AHCIDevice {
 };
 
 typedef struct AHCIState {
-    AHCIDevice *dev;
+    AHCIDevice dev[AHCI_MAX_PORTS];
     AHCIControlRegs control_regs;
     MemoryRegion mem;
     MemoryRegion idp;       /* Index-Data Pair I/O port space */