]> git.proxmox.com Git - qemu.git/blob - arch_init.c
ram: iterate phase
[qemu.git] / arch_init.c
1 /*
2 * QEMU System Emulator
3 *
4 * Copyright (c) 2003-2008 Fabrice Bellard
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24 #include <stdint.h>
25 #include <stdarg.h>
26 #include <stdlib.h>
27 #ifndef _WIN32
28 #include <sys/types.h>
29 #include <sys/mman.h>
30 #endif
31 #include "config.h"
32 #include "monitor.h"
33 #include "sysemu.h"
34 #include "arch_init.h"
35 #include "audio/audio.h"
36 #include "hw/pc.h"
37 #include "hw/pci.h"
38 #include "hw/audiodev.h"
39 #include "kvm.h"
40 #include "migration.h"
41 #include "net.h"
42 #include "gdbstub.h"
43 #include "hw/smbios.h"
44 #include "exec-memory.h"
45 #include "hw/pcspk.h"
46
47 #ifdef DEBUG_ARCH_INIT
48 #define DPRINTF(fmt, ...) \
49 do { fprintf(stdout, "arch_init: " fmt, ## __VA_ARGS__); } while (0)
50 #else
51 #define DPRINTF(fmt, ...) \
52 do { } while (0)
53 #endif
54
55 #ifdef TARGET_SPARC
56 int graphic_width = 1024;
57 int graphic_height = 768;
58 int graphic_depth = 8;
59 #else
60 int graphic_width = 800;
61 int graphic_height = 600;
62 int graphic_depth = 15;
63 #endif
64
65
66 #if defined(TARGET_ALPHA)
67 #define QEMU_ARCH QEMU_ARCH_ALPHA
68 #elif defined(TARGET_ARM)
69 #define QEMU_ARCH QEMU_ARCH_ARM
70 #elif defined(TARGET_CRIS)
71 #define QEMU_ARCH QEMU_ARCH_CRIS
72 #elif defined(TARGET_I386)
73 #define QEMU_ARCH QEMU_ARCH_I386
74 #elif defined(TARGET_M68K)
75 #define QEMU_ARCH QEMU_ARCH_M68K
76 #elif defined(TARGET_LM32)
77 #define QEMU_ARCH QEMU_ARCH_LM32
78 #elif defined(TARGET_MICROBLAZE)
79 #define QEMU_ARCH QEMU_ARCH_MICROBLAZE
80 #elif defined(TARGET_MIPS)
81 #define QEMU_ARCH QEMU_ARCH_MIPS
82 #elif defined(TARGET_PPC)
83 #define QEMU_ARCH QEMU_ARCH_PPC
84 #elif defined(TARGET_S390X)
85 #define QEMU_ARCH QEMU_ARCH_S390X
86 #elif defined(TARGET_SH4)
87 #define QEMU_ARCH QEMU_ARCH_SH4
88 #elif defined(TARGET_SPARC)
89 #define QEMU_ARCH QEMU_ARCH_SPARC
90 #elif defined(TARGET_XTENSA)
91 #define QEMU_ARCH QEMU_ARCH_XTENSA
92 #endif
93
94 const uint32_t arch_type = QEMU_ARCH;
95
96 /***********************************************************/
97 /* ram save/restore */
98
99 #define RAM_SAVE_FLAG_FULL 0x01 /* Obsolete, not used anymore */
100 #define RAM_SAVE_FLAG_COMPRESS 0x02
101 #define RAM_SAVE_FLAG_MEM_SIZE 0x04
102 #define RAM_SAVE_FLAG_PAGE 0x08
103 #define RAM_SAVE_FLAG_EOS 0x10
104 #define RAM_SAVE_FLAG_CONTINUE 0x20
105
106 #ifdef __ALTIVEC__
107 #include <altivec.h>
108 #define VECTYPE vector unsigned char
109 #define SPLAT(p) vec_splat(vec_ld(0, p), 0)
110 #define ALL_EQ(v1, v2) vec_all_eq(v1, v2)
111 /* altivec.h may redefine the bool macro as vector type.
112 * Reset it to POSIX semantics. */
113 #undef bool
114 #define bool _Bool
115 #elif defined __SSE2__
116 #include <emmintrin.h>
117 #define VECTYPE __m128i
118 #define SPLAT(p) _mm_set1_epi8(*(p))
119 #define ALL_EQ(v1, v2) (_mm_movemask_epi8(_mm_cmpeq_epi8(v1, v2)) == 0xFFFF)
120 #else
121 #define VECTYPE unsigned long
122 #define SPLAT(p) (*(p) * (~0UL / 255))
123 #define ALL_EQ(v1, v2) ((v1) == (v2))
124 #endif
125
126
127 static struct defconfig_file {
128 const char *filename;
129 /* Indicates it is an user config file (disabled by -no-user-config) */
130 bool userconfig;
131 } default_config_files[] = {
132 { CONFIG_QEMU_DATADIR "/cpus-" TARGET_ARCH ".conf", false },
133 { CONFIG_QEMU_CONFDIR "/qemu.conf", true },
134 { CONFIG_QEMU_CONFDIR "/target-" TARGET_ARCH ".conf", true },
135 { NULL }, /* end of list */
136 };
137
138
139 int qemu_read_default_config_files(bool userconfig)
140 {
141 int ret;
142 struct defconfig_file *f;
143
144 for (f = default_config_files; f->filename; f++) {
145 if (!userconfig && f->userconfig) {
146 continue;
147 }
148 ret = qemu_read_config_file(f->filename);
149 if (ret < 0 && ret != -ENOENT) {
150 return ret;
151 }
152 }
153
154 return 0;
155 }
156
157 static int is_dup_page(uint8_t *page)
158 {
159 VECTYPE *p = (VECTYPE *)page;
160 VECTYPE val = SPLAT(page);
161 int i;
162
163 for (i = 0; i < TARGET_PAGE_SIZE / sizeof(VECTYPE); i++) {
164 if (!ALL_EQ(val, p[i])) {
165 return 0;
166 }
167 }
168
169 return 1;
170 }
171
172 static void save_block_hdr(QEMUFile *f, RAMBlock *block, ram_addr_t offset,
173 int cont, int flag)
174 {
175 qemu_put_be64(f, offset | cont | flag);
176 if (!cont) {
177 qemu_put_byte(f, strlen(block->idstr));
178 qemu_put_buffer(f, (uint8_t *)block->idstr,
179 strlen(block->idstr));
180 }
181
182 }
183
184 static RAMBlock *last_block;
185 static ram_addr_t last_offset;
186
187 static int ram_save_block(QEMUFile *f)
188 {
189 RAMBlock *block = last_block;
190 ram_addr_t offset = last_offset;
191 int bytes_sent = 0;
192 MemoryRegion *mr;
193
194 if (!block)
195 block = QLIST_FIRST(&ram_list.blocks);
196
197 do {
198 mr = block->mr;
199 if (memory_region_get_dirty(mr, offset, TARGET_PAGE_SIZE,
200 DIRTY_MEMORY_MIGRATION)) {
201 uint8_t *p;
202 int cont = (block == last_block) ? RAM_SAVE_FLAG_CONTINUE : 0;
203
204 memory_region_reset_dirty(mr, offset, TARGET_PAGE_SIZE,
205 DIRTY_MEMORY_MIGRATION);
206
207 p = memory_region_get_ram_ptr(mr) + offset;
208
209 if (is_dup_page(p)) {
210 save_block_hdr(f, block, offset, cont, RAM_SAVE_FLAG_COMPRESS);
211 qemu_put_byte(f, *p);
212 bytes_sent = 1;
213 } else {
214 save_block_hdr(f, block, offset, cont, RAM_SAVE_FLAG_PAGE);
215 qemu_put_buffer(f, p, TARGET_PAGE_SIZE);
216 bytes_sent = TARGET_PAGE_SIZE;
217 }
218
219 break;
220 }
221
222 offset += TARGET_PAGE_SIZE;
223 if (offset >= block->length) {
224 offset = 0;
225 block = QLIST_NEXT(block, next);
226 if (!block)
227 block = QLIST_FIRST(&ram_list.blocks);
228 }
229 } while (block != last_block || offset != last_offset);
230
231 last_block = block;
232 last_offset = offset;
233
234 return bytes_sent;
235 }
236
237 static uint64_t bytes_transferred;
238
239 static ram_addr_t ram_save_remaining(void)
240 {
241 return ram_list.dirty_pages;
242 }
243
244 uint64_t ram_bytes_remaining(void)
245 {
246 return ram_save_remaining() * TARGET_PAGE_SIZE;
247 }
248
249 uint64_t ram_bytes_transferred(void)
250 {
251 return bytes_transferred;
252 }
253
254 uint64_t ram_bytes_total(void)
255 {
256 RAMBlock *block;
257 uint64_t total = 0;
258
259 QLIST_FOREACH(block, &ram_list.blocks, next)
260 total += block->length;
261
262 return total;
263 }
264
265 static int block_compar(const void *a, const void *b)
266 {
267 RAMBlock * const *ablock = a;
268 RAMBlock * const *bblock = b;
269
270 return strcmp((*ablock)->idstr, (*bblock)->idstr);
271 }
272
273 static void sort_ram_list(void)
274 {
275 RAMBlock *block, *nblock, **blocks;
276 int n;
277 n = 0;
278 QLIST_FOREACH(block, &ram_list.blocks, next) {
279 ++n;
280 }
281 blocks = g_malloc(n * sizeof *blocks);
282 n = 0;
283 QLIST_FOREACH_SAFE(block, &ram_list.blocks, next, nblock) {
284 blocks[n++] = block;
285 QLIST_REMOVE(block, next);
286 }
287 qsort(blocks, n, sizeof *blocks, block_compar);
288 while (--n >= 0) {
289 QLIST_INSERT_HEAD(&ram_list.blocks, blocks[n], next);
290 }
291 g_free(blocks);
292 }
293
294 static void migration_end(void)
295 {
296 memory_global_dirty_log_stop();
297 }
298
299 static void ram_migration_cancel(void *opaque)
300 {
301 migration_end();
302 }
303
304 #define MAX_WAIT 50 /* ms, half buffered_file limit */
305
306 static int ram_save_setup(QEMUFile *f, void *opaque)
307 {
308 ram_addr_t addr;
309 RAMBlock *block;
310
311 memory_global_sync_dirty_bitmap(get_system_memory());
312
313 bytes_transferred = 0;
314 last_block = NULL;
315 last_offset = 0;
316 sort_ram_list();
317
318 /* Make sure all dirty bits are set */
319 QLIST_FOREACH(block, &ram_list.blocks, next) {
320 for (addr = 0; addr < block->length; addr += TARGET_PAGE_SIZE) {
321 if (!memory_region_get_dirty(block->mr, addr, TARGET_PAGE_SIZE,
322 DIRTY_MEMORY_MIGRATION)) {
323 memory_region_set_dirty(block->mr, addr, TARGET_PAGE_SIZE);
324 }
325 }
326 }
327
328 memory_global_dirty_log_start();
329
330 qemu_put_be64(f, ram_bytes_total() | RAM_SAVE_FLAG_MEM_SIZE);
331
332 QLIST_FOREACH(block, &ram_list.blocks, next) {
333 qemu_put_byte(f, strlen(block->idstr));
334 qemu_put_buffer(f, (uint8_t *)block->idstr, strlen(block->idstr));
335 qemu_put_be64(f, block->length);
336 }
337
338 qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
339
340 return 0;
341 }
342
343 static int ram_save_iterate(QEMUFile *f, void *opaque)
344 {
345 uint64_t bytes_transferred_last;
346 double bwidth = 0;
347 int ret;
348 int i;
349 uint64_t expected_time;
350
351 bytes_transferred_last = bytes_transferred;
352 bwidth = qemu_get_clock_ns(rt_clock);
353
354 i = 0;
355 while ((ret = qemu_file_rate_limit(f)) == 0) {
356 int bytes_sent;
357
358 bytes_sent = ram_save_block(f);
359 bytes_transferred += bytes_sent;
360 if (bytes_sent == 0) { /* no more blocks */
361 break;
362 }
363 /* we want to check in the 1st loop, just in case it was the 1st time
364 and we had to sync the dirty bitmap.
365 qemu_get_clock_ns() is a bit expensive, so we only check each some
366 iterations
367 */
368 if ((i & 63) == 0) {
369 uint64_t t1 = (qemu_get_clock_ns(rt_clock) - bwidth) / 1000000;
370 if (t1 > MAX_WAIT) {
371 DPRINTF("big wait: " PRIu64 " milliseconds, %d iterations\n",
372 t1, i);
373 break;
374 }
375 }
376 i++;
377 }
378
379 if (ret < 0) {
380 return ret;
381 }
382
383 bwidth = qemu_get_clock_ns(rt_clock) - bwidth;
384 bwidth = (bytes_transferred - bytes_transferred_last) / bwidth;
385
386 /* if we haven't transferred anything this round, force expected_time to a
387 * a very high value, but without crashing */
388 if (bwidth == 0) {
389 bwidth = 0.000001;
390 }
391
392 qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
393
394 expected_time = ram_save_remaining() * TARGET_PAGE_SIZE / bwidth;
395
396 DPRINTF("ram_save_live: expected(" PRIu64 ") <= max(" PRIu64 ")?\n",
397 expected_time, migrate_max_downtime());
398
399 if (expected_time <= migrate_max_downtime()) {
400 memory_global_sync_dirty_bitmap(get_system_memory());
401 expected_time = ram_save_remaining() * TARGET_PAGE_SIZE / bwidth;
402
403 return expected_time <= migrate_max_downtime();
404 }
405 return 0;
406 }
407
408 static int ram_save_complete(QEMUFile *f, void *opaque)
409 {
410 int bytes_sent;
411
412 memory_global_sync_dirty_bitmap(get_system_memory());
413
414 /* try transferring iterative blocks of memory */
415
416 /* flush all remaining blocks regardless of rate limiting */
417 while ((bytes_sent = ram_save_block(f)) != 0) {
418 bytes_transferred += bytes_sent;
419 }
420 memory_global_dirty_log_stop();
421
422 qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
423
424 return 0;
425 }
426
427 static inline void *host_from_stream_offset(QEMUFile *f,
428 ram_addr_t offset,
429 int flags)
430 {
431 static RAMBlock *block = NULL;
432 char id[256];
433 uint8_t len;
434
435 if (flags & RAM_SAVE_FLAG_CONTINUE) {
436 if (!block) {
437 fprintf(stderr, "Ack, bad migration stream!\n");
438 return NULL;
439 }
440
441 return memory_region_get_ram_ptr(block->mr) + offset;
442 }
443
444 len = qemu_get_byte(f);
445 qemu_get_buffer(f, (uint8_t *)id, len);
446 id[len] = 0;
447
448 QLIST_FOREACH(block, &ram_list.blocks, next) {
449 if (!strncmp(id, block->idstr, sizeof(id)))
450 return memory_region_get_ram_ptr(block->mr) + offset;
451 }
452
453 fprintf(stderr, "Can't find block %s!\n", id);
454 return NULL;
455 }
456
457 static int ram_load(QEMUFile *f, void *opaque, int version_id)
458 {
459 ram_addr_t addr;
460 int flags, ret = 0;
461 int error;
462 static uint64_t seq_iter;
463
464 seq_iter++;
465
466 if (version_id < 4 || version_id > 4) {
467 return -EINVAL;
468 }
469
470 do {
471 addr = qemu_get_be64(f);
472
473 flags = addr & ~TARGET_PAGE_MASK;
474 addr &= TARGET_PAGE_MASK;
475
476 if (flags & RAM_SAVE_FLAG_MEM_SIZE) {
477 if (version_id == 4) {
478 /* Synchronize RAM block list */
479 char id[256];
480 ram_addr_t length;
481 ram_addr_t total_ram_bytes = addr;
482
483 while (total_ram_bytes) {
484 RAMBlock *block;
485 uint8_t len;
486
487 len = qemu_get_byte(f);
488 qemu_get_buffer(f, (uint8_t *)id, len);
489 id[len] = 0;
490 length = qemu_get_be64(f);
491
492 QLIST_FOREACH(block, &ram_list.blocks, next) {
493 if (!strncmp(id, block->idstr, sizeof(id))) {
494 if (block->length != length) {
495 ret = -EINVAL;
496 goto done;
497 }
498 break;
499 }
500 }
501
502 if (!block) {
503 fprintf(stderr, "Unknown ramblock \"%s\", cannot "
504 "accept migration\n", id);
505 ret = -EINVAL;
506 goto done;
507 }
508
509 total_ram_bytes -= length;
510 }
511 }
512 }
513
514 if (flags & RAM_SAVE_FLAG_COMPRESS) {
515 void *host;
516 uint8_t ch;
517
518 host = host_from_stream_offset(f, addr, flags);
519 if (!host) {
520 return -EINVAL;
521 }
522
523 ch = qemu_get_byte(f);
524 memset(host, ch, TARGET_PAGE_SIZE);
525 #ifndef _WIN32
526 if (ch == 0 &&
527 (!kvm_enabled() || kvm_has_sync_mmu())) {
528 qemu_madvise(host, TARGET_PAGE_SIZE, QEMU_MADV_DONTNEED);
529 }
530 #endif
531 } else if (flags & RAM_SAVE_FLAG_PAGE) {
532 void *host;
533
534 host = host_from_stream_offset(f, addr, flags);
535 if (!host) {
536 return -EINVAL;
537 }
538
539 qemu_get_buffer(f, host, TARGET_PAGE_SIZE);
540 }
541 error = qemu_file_get_error(f);
542 if (error) {
543 ret = error;
544 goto done;
545 }
546 } while (!(flags & RAM_SAVE_FLAG_EOS));
547
548 done:
549 DPRINTF("Completed load of VM with exit code %d seq iteration " PRIu64 "\n",
550 ret, seq_iter);
551 return ret;
552 }
553
554 SaveVMHandlers savevm_ram_handlers = {
555 .save_live_setup = ram_save_setup,
556 .save_live_iterate = ram_save_iterate,
557 .save_live_complete = ram_save_complete,
558 .load_state = ram_load,
559 .cancel = ram_migration_cancel,
560 };
561
562 #ifdef HAS_AUDIO
563 struct soundhw {
564 const char *name;
565 const char *descr;
566 int enabled;
567 int isa;
568 union {
569 int (*init_isa) (ISABus *bus);
570 int (*init_pci) (PCIBus *bus);
571 } init;
572 };
573
574 static struct soundhw soundhw[] = {
575 #ifdef HAS_AUDIO_CHOICE
576 #ifdef CONFIG_PCSPK
577 {
578 "pcspk",
579 "PC speaker",
580 0,
581 1,
582 { .init_isa = pcspk_audio_init }
583 },
584 #endif
585
586 #ifdef CONFIG_SB16
587 {
588 "sb16",
589 "Creative Sound Blaster 16",
590 0,
591 1,
592 { .init_isa = SB16_init }
593 },
594 #endif
595
596 #ifdef CONFIG_CS4231A
597 {
598 "cs4231a",
599 "CS4231A",
600 0,
601 1,
602 { .init_isa = cs4231a_init }
603 },
604 #endif
605
606 #ifdef CONFIG_ADLIB
607 {
608 "adlib",
609 #ifdef HAS_YMF262
610 "Yamaha YMF262 (OPL3)",
611 #else
612 "Yamaha YM3812 (OPL2)",
613 #endif
614 0,
615 1,
616 { .init_isa = Adlib_init }
617 },
618 #endif
619
620 #ifdef CONFIG_GUS
621 {
622 "gus",
623 "Gravis Ultrasound GF1",
624 0,
625 1,
626 { .init_isa = GUS_init }
627 },
628 #endif
629
630 #ifdef CONFIG_AC97
631 {
632 "ac97",
633 "Intel 82801AA AC97 Audio",
634 0,
635 0,
636 { .init_pci = ac97_init }
637 },
638 #endif
639
640 #ifdef CONFIG_ES1370
641 {
642 "es1370",
643 "ENSONIQ AudioPCI ES1370",
644 0,
645 0,
646 { .init_pci = es1370_init }
647 },
648 #endif
649
650 #ifdef CONFIG_HDA
651 {
652 "hda",
653 "Intel HD Audio",
654 0,
655 0,
656 { .init_pci = intel_hda_and_codec_init }
657 },
658 #endif
659
660 #endif /* HAS_AUDIO_CHOICE */
661
662 { NULL, NULL, 0, 0, { NULL } }
663 };
664
665 void select_soundhw(const char *optarg)
666 {
667 struct soundhw *c;
668
669 if (*optarg == '?') {
670 show_valid_cards:
671
672 printf("Valid sound card names (comma separated):\n");
673 for (c = soundhw; c->name; ++c) {
674 printf ("%-11s %s\n", c->name, c->descr);
675 }
676 printf("\n-soundhw all will enable all of the above\n");
677 exit(*optarg != '?');
678 }
679 else {
680 size_t l;
681 const char *p;
682 char *e;
683 int bad_card = 0;
684
685 if (!strcmp(optarg, "all")) {
686 for (c = soundhw; c->name; ++c) {
687 c->enabled = 1;
688 }
689 return;
690 }
691
692 p = optarg;
693 while (*p) {
694 e = strchr(p, ',');
695 l = !e ? strlen(p) : (size_t) (e - p);
696
697 for (c = soundhw; c->name; ++c) {
698 if (!strncmp(c->name, p, l) && !c->name[l]) {
699 c->enabled = 1;
700 break;
701 }
702 }
703
704 if (!c->name) {
705 if (l > 80) {
706 fprintf(stderr,
707 "Unknown sound card name (too big to show)\n");
708 }
709 else {
710 fprintf(stderr, "Unknown sound card name `%.*s'\n",
711 (int) l, p);
712 }
713 bad_card = 1;
714 }
715 p += l + (e != NULL);
716 }
717
718 if (bad_card) {
719 goto show_valid_cards;
720 }
721 }
722 }
723
724 void audio_init(ISABus *isa_bus, PCIBus *pci_bus)
725 {
726 struct soundhw *c;
727
728 for (c = soundhw; c->name; ++c) {
729 if (c->enabled) {
730 if (c->isa) {
731 if (isa_bus) {
732 c->init.init_isa(isa_bus);
733 }
734 } else {
735 if (pci_bus) {
736 c->init.init_pci(pci_bus);
737 }
738 }
739 }
740 }
741 }
742 #else
743 void select_soundhw(const char *optarg)
744 {
745 }
746 void audio_init(ISABus *isa_bus, PCIBus *pci_bus)
747 {
748 }
749 #endif
750
751 int qemu_uuid_parse(const char *str, uint8_t *uuid)
752 {
753 int ret;
754
755 if (strlen(str) != 36) {
756 return -1;
757 }
758
759 ret = sscanf(str, UUID_FMT, &uuid[0], &uuid[1], &uuid[2], &uuid[3],
760 &uuid[4], &uuid[5], &uuid[6], &uuid[7], &uuid[8], &uuid[9],
761 &uuid[10], &uuid[11], &uuid[12], &uuid[13], &uuid[14],
762 &uuid[15]);
763
764 if (ret != 16) {
765 return -1;
766 }
767 #ifdef TARGET_I386
768 smbios_add_field(1, offsetof(struct smbios_type_1, uuid), 16, uuid);
769 #endif
770 return 0;
771 }
772
773 void do_acpitable_option(const char *optarg)
774 {
775 #ifdef TARGET_I386
776 if (acpi_table_add(optarg) < 0) {
777 fprintf(stderr, "Wrong acpi table provided\n");
778 exit(1);
779 }
780 #endif
781 }
782
783 void do_smbios_option(const char *optarg)
784 {
785 #ifdef TARGET_I386
786 if (smbios_entry_add(optarg) < 0) {
787 fprintf(stderr, "Wrong smbios provided\n");
788 exit(1);
789 }
790 #endif
791 }
792
793 void cpudef_init(void)
794 {
795 #if defined(cpudef_setup)
796 cpudef_setup(); /* parse cpu definitions in target config file */
797 #endif
798 }
799
800 int audio_available(void)
801 {
802 #ifdef HAS_AUDIO
803 return 1;
804 #else
805 return 0;
806 #endif
807 }
808
809 int tcg_available(void)
810 {
811 return 1;
812 }
813
814 int kvm_available(void)
815 {
816 #ifdef CONFIG_KVM
817 return 1;
818 #else
819 return 0;
820 #endif
821 }
822
823 int xen_available(void)
824 {
825 #ifdef CONFIG_XEN
826 return 1;
827 #else
828 return 0;
829 #endif
830 }