clean: remove buildinfo/changes
[pve-qemu-kvm.git] / debian / patches / old / ahci-add_migration-support.patch
bloba5791f70931ce6f886eab011736987403264cc50
1 From: Jason Baron
2 Subject: [Qemu-devel] [PATCH] ahci: add migration support
3 Date: Thu, 30 Aug 2012 14:00:04 -0400
5 Add support for ahci migration. This patch builds upon the patches posted
6 previously by Andreas Faerber:
8 http://lists.gnu.org/archive/html/qemu-devel/2012-08/msg01538.html
10 (I hope I am giving Andreas proper credit for his work.)
12 I've tested these patches by migrating Windows 7 and Fedora 16 guests on
13 both piix with ahci attached and on q35 (which has a built-in ahci controller).
15 Signed-off-by: Jason Baron <address@hidden>
16 ---
17 hw/ide/ahci.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
18 hw/ide/ahci.h | 10 +++++++++
19 hw/ide/ich.c | 11 +++++++--
20 3 files changed, 81 insertions(+), 4 deletions(-)
22 Index: new/hw/ide/ahci.c
23 ===================================================================
24 --- new.orig/hw/ide/ahci.c 2012-09-24 07:15:00.000000000 +0200
25 +++ new/hw/ide/ahci.c 2012-09-24 07:15:28.000000000 +0200
26 @@ -1203,6 +1203,65 @@
30 +static const VMStateDescription vmstate_ahci_device = {
31 + .name = "ahci port",
32 + .version_id = 1,
33 + .fields = (VMStateField []) {
34 + VMSTATE_IDE_BUS(port, AHCIDevice),
35 + VMSTATE_UINT32(port_state, AHCIDevice),
36 + VMSTATE_UINT32(finished, AHCIDevice),
37 + VMSTATE_UINT32(port_regs.lst_addr, AHCIDevice),
38 + VMSTATE_UINT32(port_regs.lst_addr_hi, AHCIDevice),
39 + VMSTATE_UINT32(port_regs.fis_addr, AHCIDevice),
40 + VMSTATE_UINT32(port_regs.fis_addr_hi, AHCIDevice),
41 + VMSTATE_UINT32(port_regs.irq_stat, AHCIDevice),
42 + VMSTATE_UINT32(port_regs.irq_mask, AHCIDevice),
43 + VMSTATE_UINT32(port_regs.cmd, AHCIDevice),
44 + VMSTATE_UINT32(port_regs.tfdata, AHCIDevice),
45 + VMSTATE_UINT32(port_regs.sig, AHCIDevice),
46 + VMSTATE_UINT32(port_regs.scr_stat, AHCIDevice),
47 + VMSTATE_UINT32(port_regs.scr_ctl, AHCIDevice),
48 + VMSTATE_UINT32(port_regs.scr_err, AHCIDevice),
49 + VMSTATE_UINT32(port_regs.scr_act, AHCIDevice),
50 + VMSTATE_UINT32(port_regs.cmd_issue, AHCIDevice),
51 + VMSTATE_END_OF_LIST()
52 + },
53 +};
55 +static int ahci_state_post_load(void *opaque, int version_id)
57 + int i;
58 + AHCIState *s = opaque;
60 + for (i = 0; i < s->ports; i++) {
61 + AHCIPortRegs *pr = &s->dev[i].port_regs;
63 + map_page(&s->dev[i].lst,
64 + ((uint64_t)pr->lst_addr_hi << 32) | pr->lst_addr, 1024);
65 + map_page(&s->dev[i].res_fis,
66 + ((uint64_t)pr->fis_addr_hi << 32) | pr->fis_addr, 256);
67 + }
69 + return 0;
72 +const VMStateDescription vmstate_ahci = {
73 + .name = "ahci",
74 + .version_id = 1,
75 + .post_load = ahci_state_post_load,
76 + .fields = (VMStateField []) {
77 + VMSTATE_STRUCT_VARRAY_POINTER_INT32(dev, AHCIState, ports,
78 + vmstate_ahci_device, AHCIDevice),
79 + VMSTATE_UINT32(control_regs.cap, AHCIState),
80 + VMSTATE_UINT32(control_regs.ghc, AHCIState),
81 + VMSTATE_UINT32(control_regs.irqstatus, AHCIState),
82 + VMSTATE_UINT32(control_regs.impl, AHCIState),
83 + VMSTATE_UINT32(control_regs.version, AHCIState),
84 + VMSTATE_UINT32(idp_index, AHCIState),
85 + VMSTATE_END_OF_LIST()
86 + },
87 +};
89 typedef struct SysbusAHCIState {
90 SysBusDevice busdev;
91 AHCIState ahci;
92 @@ -1211,7 +1270,10 @@
94 static const VMStateDescription vmstate_sysbus_ahci = {
95 .name = "sysbus-ahci",
96 - .unmigratable = 1,
97 + .fields = (VMStateField []) {
98 + VMSTATE_AHCI(ahci, AHCIPCIState),
99 + VMSTATE_END_OF_LIST()
100 + },
103 static void sysbus_ahci_reset(DeviceState *dev)
104 Index: new/hw/ide/ahci.h
105 ===================================================================
106 --- new.orig/hw/ide/ahci.h 2012-09-24 07:15:00.000000000 +0200
107 +++ new/hw/ide/ahci.h 2012-09-24 07:15:28.000000000 +0200
108 @@ -307,6 +307,16 @@
109 AHCIState ahci;
110 } AHCIPCIState;
112 +extern const VMStateDescription vmstate_ahci;
114 +#define VMSTATE_AHCI(_field, _state) { \
115 + .name = (stringify(_field)), \
116 + .size = sizeof(AHCIState), \
117 + .vmsd = &vmstate_ahci, \
118 + .flags = VMS_STRUCT, \
119 + .offset = vmstate_offset_value(_state, _field, AHCIState), \
122 typedef struct NCQFrame {
123 uint8_t fis_type;
124 uint8_t c;
125 Index: new/hw/ide/ich.c
126 ===================================================================
127 --- new.orig/hw/ide/ich.c 2012-09-24 07:15:00.000000000 +0200
128 +++ new/hw/ide/ich.c 2012-09-24 07:15:28.000000000 +0200
129 @@ -79,9 +79,14 @@
130 #define ICH9_IDP_INDEX 0x10
131 #define ICH9_IDP_INDEX_LOG2 0x04
133 -static const VMStateDescription vmstate_ahci = {
134 +static const VMStateDescription vmstate_ich9_ahci = {
135 .name = "ahci",
136 - .unmigratable = 1,
137 + .version_id = 1,
138 + .fields = (VMStateField []) {
139 + VMSTATE_PCI_DEVICE(card, AHCIPCIState),
140 + VMSTATE_AHCI(ahci, AHCIPCIState),
141 + VMSTATE_END_OF_LIST()
142 + },
145 static void pci_ich9_reset(DeviceState *dev)
146 @@ -152,7 +157,7 @@
147 k->device_id = PCI_DEVICE_ID_INTEL_82801IR;
148 k->revision = 0x02;
149 k->class_id = PCI_CLASS_STORAGE_SATA;
150 - dc->vmsd = &vmstate_ahci;
151 + dc->vmsd = &vmstate_ich9_ahci;
152 dc->reset = pci_ich9_reset;