1 | Index: ioemu/hw/cirrus_vga.c |
---|
2 | =================================================================== |
---|
3 | --- ioemu.orig/hw/cirrus_vga.c 2007-05-03 15:03:18.000000000 +0100 |
---|
4 | +++ ioemu/hw/cirrus_vga.c 2007-05-03 15:08:02.000000000 +0100 |
---|
5 | @@ -3011,11 +3011,42 @@ |
---|
6 | cirrus_mmio_writel, |
---|
7 | }; |
---|
8 | |
---|
9 | +void cirrus_stop_acc(CirrusVGAState *s) |
---|
10 | +{ |
---|
11 | + if (s->map_addr){ |
---|
12 | + int error; |
---|
13 | + s->map_addr = 0; |
---|
14 | + error = unset_vram_mapping(s->cirrus_lfb_addr, |
---|
15 | + s->cirrus_lfb_end, s->vram_ptr); |
---|
16 | + fprintf(stderr, "cirrus_stop_acc:unset_vram_mapping.\n"); |
---|
17 | + } |
---|
18 | +} |
---|
19 | + |
---|
20 | +void cirrus_restart_acc(CirrusVGAState *s) |
---|
21 | +{ |
---|
22 | + if (s->cirrus_lfb_addr && s->cirrus_lfb_end) { |
---|
23 | + void *vram_pointer, *old_vram; |
---|
24 | + fprintf(stderr, "cirrus_vga_load:re-enable vga acc.lfb_addr=0x%lx, lfb_end=0x%lx.\n", |
---|
25 | + s->cirrus_lfb_addr, s->cirrus_lfb_end); |
---|
26 | + vram_pointer = set_vram_mapping(s->cirrus_lfb_addr ,s->cirrus_lfb_end); |
---|
27 | + if (!vram_pointer){ |
---|
28 | + fprintf(stderr, "cirrus_vga_load:NULL vram_pointer\n"); |
---|
29 | + } else { |
---|
30 | + old_vram = vga_update_vram((VGAState *)s, vram_pointer, |
---|
31 | + VGA_RAM_SIZE); |
---|
32 | + qemu_free(old_vram); |
---|
33 | + s->map_addr = s->cirrus_lfb_addr; |
---|
34 | + s->map_end = s->cirrus_lfb_end; |
---|
35 | + } |
---|
36 | + } |
---|
37 | +} |
---|
38 | + |
---|
39 | /* load/save state */ |
---|
40 | |
---|
41 | static void cirrus_vga_save(QEMUFile *f, void *opaque) |
---|
42 | { |
---|
43 | CirrusVGAState *s = opaque; |
---|
44 | + uint8_t vga_acc; |
---|
45 | |
---|
46 | qemu_put_be32s(f, &s->latch); |
---|
47 | qemu_put_8s(f, &s->sr_index); |
---|
48 | @@ -3050,11 +3081,20 @@ |
---|
49 | qemu_put_be32s(f, &s->hw_cursor_y); |
---|
50 | /* XXX: we do not save the bitblt state - we assume we do not save |
---|
51 | the state when the blitter is active */ |
---|
52 | + |
---|
53 | + vga_acc = (!!s->map_addr); |
---|
54 | + qemu_put_8s(f, &vga_acc); |
---|
55 | + qemu_put_be64s(f, (uint64_t*)&s->cirrus_lfb_addr); |
---|
56 | + qemu_put_be64s(f, (uint64_t*)&s->cirrus_lfb_end); |
---|
57 | + qemu_put_buffer(f, s->vram_ptr, VGA_RAM_SIZE); |
---|
58 | + if (vga_acc) |
---|
59 | + cirrus_stop_acc(s); |
---|
60 | } |
---|
61 | |
---|
62 | static int cirrus_vga_load(QEMUFile *f, void *opaque, int version_id) |
---|
63 | { |
---|
64 | CirrusVGAState *s = opaque; |
---|
65 | + uint8_t vga_acc = 0; |
---|
66 | |
---|
67 | if (version_id != 1) |
---|
68 | return -EINVAL; |
---|
69 | @@ -3093,6 +3133,14 @@ |
---|
70 | qemu_get_be32s(f, &s->hw_cursor_x); |
---|
71 | qemu_get_be32s(f, &s->hw_cursor_y); |
---|
72 | |
---|
73 | + qemu_get_8s(f, &vga_acc); |
---|
74 | + qemu_get_be64s(f, (uint64_t*)&s->cirrus_lfb_addr); |
---|
75 | + qemu_get_be64s(f, (uint64_t*)&s->cirrus_lfb_end); |
---|
76 | + qemu_get_buffer(f, s->vram_ptr, VGA_RAM_SIZE); |
---|
77 | + if (vga_acc){ |
---|
78 | + cirrus_restart_acc(s); |
---|
79 | + } |
---|
80 | + |
---|
81 | /* force refresh */ |
---|
82 | s->graphic_mode = -1; |
---|
83 | cirrus_update_bank_ptr(s, 0); |
---|
84 | @@ -3298,6 +3346,8 @@ |
---|
85 | ds, vga_ram_base, vga_ram_offset, vga_ram_size); |
---|
86 | cirrus_init_common(s, device_id, 1); |
---|
87 | |
---|
88 | + register_savevm("cirrus_vga_pci", 0, 1, generic_pci_save, generic_pci_load, d); |
---|
89 | + |
---|
90 | /* setup memory space */ |
---|
91 | /* memory #0 LFB */ |
---|
92 | /* memory #1 memory-mapped I/O */ |
---|
93 | Index: ioemu/vl.c |
---|
94 | =================================================================== |
---|
95 | --- ioemu.orig/vl.c 2007-05-03 15:03:18.000000000 +0100 |
---|
96 | +++ ioemu/vl.c 2007-05-03 15:08:04.000000000 +0100 |
---|
97 | @@ -4470,6 +4470,11 @@ |
---|
98 | qemu_fseek(f, cur_pos + record_len, SEEK_SET); |
---|
99 | } |
---|
100 | fclose(f); |
---|
101 | + |
---|
102 | + /* del tmp file */ |
---|
103 | + if (unlink(filename) == -1) |
---|
104 | + fprintf(stderr, "delete tmp qemu state file failed.\n"); |
---|
105 | + |
---|
106 | ret = 0; |
---|
107 | the_end: |
---|
108 | if (saved_vm_running) |
---|
109 | @@ -5056,6 +5061,7 @@ |
---|
110 | static QEMUResetEntry *first_reset_entry; |
---|
111 | int reset_requested; |
---|
112 | int shutdown_requested; |
---|
113 | +int suspend_requested; |
---|
114 | static int powerdown_requested; |
---|
115 | |
---|
116 | void qemu_register_reset(QEMUResetHandler *func, void *opaque) |
---|
117 | @@ -5816,6 +5822,15 @@ |
---|
118 | return 0; |
---|
119 | } |
---|
120 | |
---|
121 | +void suspend(int sig) |
---|
122 | +{ |
---|
123 | + fprintf(logfile, "suspend sig handler called with requested=%d!\n", |
---|
124 | + suspend_requested); |
---|
125 | + if (sig != SIGUSR1) |
---|
126 | + fprintf(logfile, "suspend signal dismatch, get sig=%d!\n", sig); |
---|
127 | + suspend_requested = 1; |
---|
128 | +} |
---|
129 | + |
---|
130 | int main(int argc, char **argv) |
---|
131 | { |
---|
132 | #ifdef CONFIG_GDBSTUB |
---|
133 | @@ -6581,6 +6596,26 @@ |
---|
134 | vm_start(); |
---|
135 | } |
---|
136 | } |
---|
137 | + |
---|
138 | + /* register signal for the suspend request when save */ |
---|
139 | + { |
---|
140 | + struct sigaction act; |
---|
141 | + sigset_t set; |
---|
142 | + act.sa_handler = suspend; |
---|
143 | + act.sa_flags = SA_RESTART; |
---|
144 | + sigemptyset(&act.sa_mask); |
---|
145 | + |
---|
146 | + sigaction(SIGUSR1, &act, NULL); |
---|
147 | + |
---|
148 | + /* control panel mask some signals when spawn qemu, need unmask here*/ |
---|
149 | + sigemptyset(&set); |
---|
150 | + sigaddset(&set, SIGUSR1); |
---|
151 | + sigaddset(&set, SIGTERM); |
---|
152 | + if (sigprocmask(SIG_UNBLOCK, &set, NULL) == -1) |
---|
153 | + fprintf(stderr, "unblock signal fail, possible issue for HVM save!\n"); |
---|
154 | + |
---|
155 | + } |
---|
156 | + |
---|
157 | main_loop(); |
---|
158 | quit_timers(); |
---|
159 | return 0; |
---|
160 | Index: ioemu/hw/pci.c |
---|
161 | =================================================================== |
---|
162 | --- ioemu.orig/hw/pci.c 2007-05-03 15:03:12.000000000 +0100 |
---|
163 | +++ ioemu/hw/pci.c 2007-05-03 15:08:02.000000000 +0100 |
---|
164 | @@ -40,6 +40,8 @@ |
---|
165 | static int pci_irq_index; |
---|
166 | static PCIBus *first_bus; |
---|
167 | |
---|
168 | +static void pci_update_mappings(PCIDevice *d); |
---|
169 | + |
---|
170 | PCIBus *pci_register_bus(pci_set_irq_fn set_irq, void *pic, int devfn_min) |
---|
171 | { |
---|
172 | PCIBus *bus; |
---|
173 | @@ -71,6 +73,7 @@ |
---|
174 | return -EINVAL; |
---|
175 | |
---|
176 | qemu_get_buffer(f, s->config, 256); |
---|
177 | + pci_update_mappings(s); |
---|
178 | return 0; |
---|
179 | } |
---|
180 | |
---|
181 | Index: ioemu/hw/ide.c |
---|
182 | =================================================================== |
---|
183 | --- ioemu.orig/hw/ide.c 2007-05-03 15:03:12.000000000 +0100 |
---|
184 | +++ ioemu/hw/ide.c 2007-05-03 15:08:04.000000000 +0100 |
---|
185 | @@ -2405,6 +2405,8 @@ |
---|
186 | pic_set_irq_new, isa_pic, 15); |
---|
187 | ide_init_ioport(&d->ide_if[0], 0x1f0, 0x3f6); |
---|
188 | ide_init_ioport(&d->ide_if[2], 0x170, 0x376); |
---|
189 | + |
---|
190 | + register_savevm("ide_pci", 0, 1, generic_pci_save, generic_pci_load, d); |
---|
191 | } |
---|
192 | |
---|
193 | /***********************************************************/ |
---|
194 | Index: ioemu/target-i386-dm/helper2.c |
---|
195 | =================================================================== |
---|
196 | --- ioemu.orig/target-i386-dm/helper2.c 2007-05-03 15:03:18.000000000 +0100 |
---|
197 | +++ ioemu/target-i386-dm/helper2.c 2007-05-03 15:09:10.000000000 +0100 |
---|
198 | @@ -540,8 +540,10 @@ |
---|
199 | { |
---|
200 | extern int vm_running; |
---|
201 | extern int shutdown_requested; |
---|
202 | + extern int suspend_requested; |
---|
203 | CPUState *env = cpu_single_env; |
---|
204 | int evtchn_fd = xc_evtchn_fd(xce_handle); |
---|
205 | + char qemu_file[20]; |
---|
206 | |
---|
207 | qemu_set_fd_handler(evtchn_fd, cpu_handle_ioreq, NULL, env); |
---|
208 | |
---|
209 | @@ -549,7 +551,15 @@ |
---|
210 | /* Wait up to 10 msec. */ |
---|
211 | main_loop_wait(10); |
---|
212 | |
---|
213 | - destroy_hvm_domain(); |
---|
214 | + fprintf(logfile, "device model received suspend signal!\n"); |
---|
215 | + |
---|
216 | + /* Pull all outstanding ioreqs through the system */ |
---|
217 | + main_loop_wait(1); /* For the select() on events */ |
---|
218 | + |
---|
219 | + /* Save the device state */ |
---|
220 | + sprintf(qemu_file, "/tmp/xen.qemu-dm.%d", domid); |
---|
221 | + if (qemu_savevm(qemu_file) < 0) |
---|
222 | + fprintf(stderr, "qemu save fail.\n"); |
---|
223 | |
---|
224 | return 0; |
---|
225 | } |
---|