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