[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC 1/2] ahci: Refactor ports as a fixed-size array for VM
From: |
Andreas Färber |
Subject: |
[Qemu-devel] [RFC 1/2] ahci: Refactor ports as a fixed-size array for VMState |
Date: |
Fri, 23 Dec 2011 15:55:50 +0100 |
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 <address@hidden>
Cc: Juan Quintela <address@hidden>
Cc: Kevin Wolf <address@hidden>
Cc: Alexander Graf <address@hidden>
---
hw/ide/ahci.c | 3 +--
hw/ide/ahci.h | 2 +-
2 files changed, 2 insertions(+), 3 deletions(-)
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 */
--
1.7.7