2
0

arch_init.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  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. #ifdef TARGET_SPARC
  45. int graphic_width = 1024;
  46. int graphic_height = 768;
  47. int graphic_depth = 8;
  48. #else
  49. int graphic_width = 800;
  50. int graphic_height = 600;
  51. int graphic_depth = 15;
  52. #endif
  53. const char arch_config_name[] = CONFIG_QEMU_CONFDIR "/target-" TARGET_ARCH ".conf";
  54. #if defined(TARGET_ALPHA)
  55. #define QEMU_ARCH QEMU_ARCH_ALPHA
  56. #elif defined(TARGET_ARM)
  57. #define QEMU_ARCH QEMU_ARCH_ARM
  58. #elif defined(TARGET_CRIS)
  59. #define QEMU_ARCH QEMU_ARCH_CRIS
  60. #elif defined(TARGET_I386)
  61. #define QEMU_ARCH QEMU_ARCH_I386
  62. #elif defined(TARGET_M68K)
  63. #define QEMU_ARCH QEMU_ARCH_M68K
  64. #elif defined(TARGET_LM32)
  65. #define QEMU_ARCH QEMU_ARCH_LM32
  66. #elif defined(TARGET_MICROBLAZE)
  67. #define QEMU_ARCH QEMU_ARCH_MICROBLAZE
  68. #elif defined(TARGET_MIPS)
  69. #define QEMU_ARCH QEMU_ARCH_MIPS
  70. #elif defined(TARGET_PPC)
  71. #define QEMU_ARCH QEMU_ARCH_PPC
  72. #elif defined(TARGET_S390X)
  73. #define QEMU_ARCH QEMU_ARCH_S390X
  74. #elif defined(TARGET_SH4)
  75. #define QEMU_ARCH QEMU_ARCH_SH4
  76. #elif defined(TARGET_SPARC)
  77. #define QEMU_ARCH QEMU_ARCH_SPARC
  78. #elif defined(TARGET_XTENSA)
  79. #define QEMU_ARCH QEMU_ARCH_XTENSA
  80. #endif
  81. const uint32_t arch_type = QEMU_ARCH;
  82. /***********************************************************/
  83. /* ram save/restore */
  84. #define RAM_SAVE_FLAG_FULL 0x01 /* Obsolete, not used anymore */
  85. #define RAM_SAVE_FLAG_COMPRESS 0x02
  86. #define RAM_SAVE_FLAG_MEM_SIZE 0x04
  87. #define RAM_SAVE_FLAG_PAGE 0x08
  88. #define RAM_SAVE_FLAG_EOS 0x10
  89. #define RAM_SAVE_FLAG_CONTINUE 0x20
  90. static int is_dup_page(uint8_t *page, uint8_t ch)
  91. {
  92. uint32_t val = ch << 24 | ch << 16 | ch << 8 | ch;
  93. uint32_t *array = (uint32_t *)page;
  94. int i;
  95. for (i = 0; i < (TARGET_PAGE_SIZE / 4); i++) {
  96. if (array[i] != val) {
  97. return 0;
  98. }
  99. }
  100. return 1;
  101. }
  102. static RAMBlock *last_block;
  103. static ram_addr_t last_offset;
  104. static int ram_save_block(QEMUFile *f)
  105. {
  106. RAMBlock *block = last_block;
  107. ram_addr_t offset = last_offset;
  108. ram_addr_t current_addr;
  109. int bytes_sent = 0;
  110. if (!block)
  111. block = QLIST_FIRST(&ram_list.blocks);
  112. current_addr = block->offset + offset;
  113. do {
  114. if (cpu_physical_memory_get_dirty(current_addr, MIGRATION_DIRTY_FLAG)) {
  115. uint8_t *p;
  116. int cont = (block == last_block) ? RAM_SAVE_FLAG_CONTINUE : 0;
  117. cpu_physical_memory_reset_dirty(current_addr,
  118. current_addr + TARGET_PAGE_SIZE,
  119. MIGRATION_DIRTY_FLAG);
  120. p = block->host + offset;
  121. if (is_dup_page(p, *p)) {
  122. qemu_put_be64(f, offset | cont | RAM_SAVE_FLAG_COMPRESS);
  123. if (!cont) {
  124. qemu_put_byte(f, strlen(block->idstr));
  125. qemu_put_buffer(f, (uint8_t *)block->idstr,
  126. strlen(block->idstr));
  127. }
  128. qemu_put_byte(f, *p);
  129. bytes_sent = 1;
  130. } else {
  131. qemu_put_be64(f, offset | cont | RAM_SAVE_FLAG_PAGE);
  132. if (!cont) {
  133. qemu_put_byte(f, strlen(block->idstr));
  134. qemu_put_buffer(f, (uint8_t *)block->idstr,
  135. strlen(block->idstr));
  136. }
  137. qemu_put_buffer(f, p, TARGET_PAGE_SIZE);
  138. bytes_sent = TARGET_PAGE_SIZE;
  139. }
  140. break;
  141. }
  142. offset += TARGET_PAGE_SIZE;
  143. if (offset >= block->length) {
  144. offset = 0;
  145. block = QLIST_NEXT(block, next);
  146. if (!block)
  147. block = QLIST_FIRST(&ram_list.blocks);
  148. }
  149. current_addr = block->offset + offset;
  150. } while (current_addr != last_block->offset + last_offset);
  151. last_block = block;
  152. last_offset = offset;
  153. return bytes_sent;
  154. }
  155. static uint64_t bytes_transferred;
  156. static ram_addr_t ram_save_remaining(void)
  157. {
  158. RAMBlock *block;
  159. ram_addr_t count = 0;
  160. QLIST_FOREACH(block, &ram_list.blocks, next) {
  161. ram_addr_t addr;
  162. for (addr = block->offset; addr < block->offset + block->length;
  163. addr += TARGET_PAGE_SIZE) {
  164. if (cpu_physical_memory_get_dirty(addr, MIGRATION_DIRTY_FLAG)) {
  165. count++;
  166. }
  167. }
  168. }
  169. return count;
  170. }
  171. uint64_t ram_bytes_remaining(void)
  172. {
  173. return ram_save_remaining() * TARGET_PAGE_SIZE;
  174. }
  175. uint64_t ram_bytes_transferred(void)
  176. {
  177. return bytes_transferred;
  178. }
  179. uint64_t ram_bytes_total(void)
  180. {
  181. RAMBlock *block;
  182. uint64_t total = 0;
  183. QLIST_FOREACH(block, &ram_list.blocks, next)
  184. total += block->length;
  185. return total;
  186. }
  187. static int block_compar(const void *a, const void *b)
  188. {
  189. RAMBlock * const *ablock = a;
  190. RAMBlock * const *bblock = b;
  191. if ((*ablock)->offset < (*bblock)->offset) {
  192. return -1;
  193. } else if ((*ablock)->offset > (*bblock)->offset) {
  194. return 1;
  195. }
  196. return 0;
  197. }
  198. static void sort_ram_list(void)
  199. {
  200. RAMBlock *block, *nblock, **blocks;
  201. int n;
  202. n = 0;
  203. QLIST_FOREACH(block, &ram_list.blocks, next) {
  204. ++n;
  205. }
  206. blocks = g_malloc(n * sizeof *blocks);
  207. n = 0;
  208. QLIST_FOREACH_SAFE(block, &ram_list.blocks, next, nblock) {
  209. blocks[n++] = block;
  210. QLIST_REMOVE(block, next);
  211. }
  212. qsort(blocks, n, sizeof *blocks, block_compar);
  213. while (--n >= 0) {
  214. QLIST_INSERT_HEAD(&ram_list.blocks, blocks[n], next);
  215. }
  216. g_free(blocks);
  217. }
  218. int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque)
  219. {
  220. ram_addr_t addr;
  221. uint64_t bytes_transferred_last;
  222. double bwidth = 0;
  223. uint64_t expected_time = 0;
  224. int ret;
  225. if (stage < 0) {
  226. cpu_physical_memory_set_dirty_tracking(0);
  227. return 0;
  228. }
  229. if (cpu_physical_sync_dirty_bitmap(0, TARGET_PHYS_ADDR_MAX) != 0) {
  230. qemu_file_set_error(f, -EINVAL);
  231. return -EINVAL;
  232. }
  233. if (stage == 1) {
  234. RAMBlock *block;
  235. bytes_transferred = 0;
  236. last_block = NULL;
  237. last_offset = 0;
  238. sort_ram_list();
  239. /* Make sure all dirty bits are set */
  240. QLIST_FOREACH(block, &ram_list.blocks, next) {
  241. for (addr = block->offset; addr < block->offset + block->length;
  242. addr += TARGET_PAGE_SIZE) {
  243. if (!cpu_physical_memory_get_dirty(addr,
  244. MIGRATION_DIRTY_FLAG)) {
  245. cpu_physical_memory_set_dirty(addr);
  246. }
  247. }
  248. }
  249. /* Enable dirty memory tracking */
  250. cpu_physical_memory_set_dirty_tracking(1);
  251. qemu_put_be64(f, ram_bytes_total() | RAM_SAVE_FLAG_MEM_SIZE);
  252. QLIST_FOREACH(block, &ram_list.blocks, next) {
  253. qemu_put_byte(f, strlen(block->idstr));
  254. qemu_put_buffer(f, (uint8_t *)block->idstr, strlen(block->idstr));
  255. qemu_put_be64(f, block->length);
  256. }
  257. }
  258. bytes_transferred_last = bytes_transferred;
  259. bwidth = qemu_get_clock_ns(rt_clock);
  260. while ((ret = qemu_file_rate_limit(f)) == 0) {
  261. int bytes_sent;
  262. bytes_sent = ram_save_block(f);
  263. bytes_transferred += bytes_sent;
  264. if (bytes_sent == 0) { /* no more blocks */
  265. break;
  266. }
  267. }
  268. if (ret < 0) {
  269. return ret;
  270. }
  271. bwidth = qemu_get_clock_ns(rt_clock) - bwidth;
  272. bwidth = (bytes_transferred - bytes_transferred_last) / bwidth;
  273. /* if we haven't transferred anything this round, force expected_time to a
  274. * a very high value, but without crashing */
  275. if (bwidth == 0) {
  276. bwidth = 0.000001;
  277. }
  278. /* try transferring iterative blocks of memory */
  279. if (stage == 3) {
  280. int bytes_sent;
  281. /* flush all remaining blocks regardless of rate limiting */
  282. while ((bytes_sent = ram_save_block(f)) != 0) {
  283. bytes_transferred += bytes_sent;
  284. }
  285. cpu_physical_memory_set_dirty_tracking(0);
  286. }
  287. qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
  288. expected_time = ram_save_remaining() * TARGET_PAGE_SIZE / bwidth;
  289. return (stage == 2) && (expected_time <= migrate_max_downtime());
  290. }
  291. static inline void *host_from_stream_offset(QEMUFile *f,
  292. ram_addr_t offset,
  293. int flags)
  294. {
  295. static RAMBlock *block = NULL;
  296. char id[256];
  297. uint8_t len;
  298. if (flags & RAM_SAVE_FLAG_CONTINUE) {
  299. if (!block) {
  300. fprintf(stderr, "Ack, bad migration stream!\n");
  301. return NULL;
  302. }
  303. return block->host + offset;
  304. }
  305. len = qemu_get_byte(f);
  306. qemu_get_buffer(f, (uint8_t *)id, len);
  307. id[len] = 0;
  308. QLIST_FOREACH(block, &ram_list.blocks, next) {
  309. if (!strncmp(id, block->idstr, sizeof(id)))
  310. return block->host + offset;
  311. }
  312. fprintf(stderr, "Can't find block %s!\n", id);
  313. return NULL;
  314. }
  315. int ram_load(QEMUFile *f, void *opaque, int version_id)
  316. {
  317. ram_addr_t addr;
  318. int flags;
  319. int error;
  320. if (version_id < 3 || version_id > 4) {
  321. return -EINVAL;
  322. }
  323. do {
  324. addr = qemu_get_be64(f);
  325. flags = addr & ~TARGET_PAGE_MASK;
  326. addr &= TARGET_PAGE_MASK;
  327. if (flags & RAM_SAVE_FLAG_MEM_SIZE) {
  328. if (version_id == 3) {
  329. if (addr != ram_bytes_total()) {
  330. return -EINVAL;
  331. }
  332. } else {
  333. /* Synchronize RAM block list */
  334. char id[256];
  335. ram_addr_t length;
  336. ram_addr_t total_ram_bytes = addr;
  337. while (total_ram_bytes) {
  338. RAMBlock *block;
  339. uint8_t len;
  340. len = qemu_get_byte(f);
  341. qemu_get_buffer(f, (uint8_t *)id, len);
  342. id[len] = 0;
  343. length = qemu_get_be64(f);
  344. QLIST_FOREACH(block, &ram_list.blocks, next) {
  345. if (!strncmp(id, block->idstr, sizeof(id))) {
  346. if (block->length != length)
  347. return -EINVAL;
  348. break;
  349. }
  350. }
  351. if (!block) {
  352. fprintf(stderr, "Unknown ramblock \"%s\", cannot "
  353. "accept migration\n", id);
  354. return -EINVAL;
  355. }
  356. total_ram_bytes -= length;
  357. }
  358. }
  359. }
  360. if (flags & RAM_SAVE_FLAG_COMPRESS) {
  361. void *host;
  362. uint8_t ch;
  363. if (version_id == 3)
  364. host = qemu_get_ram_ptr(addr);
  365. else
  366. host = host_from_stream_offset(f, addr, flags);
  367. if (!host) {
  368. return -EINVAL;
  369. }
  370. ch = qemu_get_byte(f);
  371. memset(host, ch, TARGET_PAGE_SIZE);
  372. #ifndef _WIN32
  373. if (ch == 0 &&
  374. (!kvm_enabled() || kvm_has_sync_mmu())) {
  375. qemu_madvise(host, TARGET_PAGE_SIZE, QEMU_MADV_DONTNEED);
  376. }
  377. #endif
  378. } else if (flags & RAM_SAVE_FLAG_PAGE) {
  379. void *host;
  380. if (version_id == 3)
  381. host = qemu_get_ram_ptr(addr);
  382. else
  383. host = host_from_stream_offset(f, addr, flags);
  384. qemu_get_buffer(f, host, TARGET_PAGE_SIZE);
  385. }
  386. error = qemu_file_get_error(f);
  387. if (error) {
  388. return error;
  389. }
  390. } while (!(flags & RAM_SAVE_FLAG_EOS));
  391. return 0;
  392. }
  393. #ifdef HAS_AUDIO
  394. struct soundhw {
  395. const char *name;
  396. const char *descr;
  397. int enabled;
  398. int isa;
  399. union {
  400. int (*init_isa) (qemu_irq *pic);
  401. int (*init_pci) (PCIBus *bus);
  402. } init;
  403. };
  404. static struct soundhw soundhw[] = {
  405. #ifdef HAS_AUDIO_CHOICE
  406. #if defined(TARGET_I386) || defined(TARGET_MIPS)
  407. {
  408. "pcspk",
  409. "PC speaker",
  410. 0,
  411. 1,
  412. { .init_isa = pcspk_audio_init }
  413. },
  414. #endif
  415. #ifdef CONFIG_SB16
  416. {
  417. "sb16",
  418. "Creative Sound Blaster 16",
  419. 0,
  420. 1,
  421. { .init_isa = SB16_init }
  422. },
  423. #endif
  424. #ifdef CONFIG_CS4231A
  425. {
  426. "cs4231a",
  427. "CS4231A",
  428. 0,
  429. 1,
  430. { .init_isa = cs4231a_init }
  431. },
  432. #endif
  433. #ifdef CONFIG_ADLIB
  434. {
  435. "adlib",
  436. #ifdef HAS_YMF262
  437. "Yamaha YMF262 (OPL3)",
  438. #else
  439. "Yamaha YM3812 (OPL2)",
  440. #endif
  441. 0,
  442. 1,
  443. { .init_isa = Adlib_init }
  444. },
  445. #endif
  446. #ifdef CONFIG_GUS
  447. {
  448. "gus",
  449. "Gravis Ultrasound GF1",
  450. 0,
  451. 1,
  452. { .init_isa = GUS_init }
  453. },
  454. #endif
  455. #ifdef CONFIG_AC97
  456. {
  457. "ac97",
  458. "Intel 82801AA AC97 Audio",
  459. 0,
  460. 0,
  461. { .init_pci = ac97_init }
  462. },
  463. #endif
  464. #ifdef CONFIG_ES1370
  465. {
  466. "es1370",
  467. "ENSONIQ AudioPCI ES1370",
  468. 0,
  469. 0,
  470. { .init_pci = es1370_init }
  471. },
  472. #endif
  473. #ifdef CONFIG_HDA
  474. {
  475. "hda",
  476. "Intel HD Audio",
  477. 0,
  478. 0,
  479. { .init_pci = intel_hda_and_codec_init }
  480. },
  481. #endif
  482. #endif /* HAS_AUDIO_CHOICE */
  483. { NULL, NULL, 0, 0, { NULL } }
  484. };
  485. void select_soundhw(const char *optarg)
  486. {
  487. struct soundhw *c;
  488. if (*optarg == '?') {
  489. show_valid_cards:
  490. printf("Valid sound card names (comma separated):\n");
  491. for (c = soundhw; c->name; ++c) {
  492. printf ("%-11s %s\n", c->name, c->descr);
  493. }
  494. printf("\n-soundhw all will enable all of the above\n");
  495. exit(*optarg != '?');
  496. }
  497. else {
  498. size_t l;
  499. const char *p;
  500. char *e;
  501. int bad_card = 0;
  502. if (!strcmp(optarg, "all")) {
  503. for (c = soundhw; c->name; ++c) {
  504. c->enabled = 1;
  505. }
  506. return;
  507. }
  508. p = optarg;
  509. while (*p) {
  510. e = strchr(p, ',');
  511. l = !e ? strlen(p) : (size_t) (e - p);
  512. for (c = soundhw; c->name; ++c) {
  513. if (!strncmp(c->name, p, l) && !c->name[l]) {
  514. c->enabled = 1;
  515. break;
  516. }
  517. }
  518. if (!c->name) {
  519. if (l > 80) {
  520. fprintf(stderr,
  521. "Unknown sound card name (too big to show)\n");
  522. }
  523. else {
  524. fprintf(stderr, "Unknown sound card name `%.*s'\n",
  525. (int) l, p);
  526. }
  527. bad_card = 1;
  528. }
  529. p += l + (e != NULL);
  530. }
  531. if (bad_card) {
  532. goto show_valid_cards;
  533. }
  534. }
  535. }
  536. void audio_init(qemu_irq *isa_pic, PCIBus *pci_bus)
  537. {
  538. struct soundhw *c;
  539. for (c = soundhw; c->name; ++c) {
  540. if (c->enabled) {
  541. if (c->isa) {
  542. if (isa_pic) {
  543. c->init.init_isa(isa_pic);
  544. }
  545. } else {
  546. if (pci_bus) {
  547. c->init.init_pci(pci_bus);
  548. }
  549. }
  550. }
  551. }
  552. }
  553. #else
  554. void select_soundhw(const char *optarg)
  555. {
  556. }
  557. void audio_init(qemu_irq *isa_pic, PCIBus *pci_bus)
  558. {
  559. }
  560. #endif
  561. int qemu_uuid_parse(const char *str, uint8_t *uuid)
  562. {
  563. int ret;
  564. if (strlen(str) != 36) {
  565. return -1;
  566. }
  567. ret = sscanf(str, UUID_FMT, &uuid[0], &uuid[1], &uuid[2], &uuid[3],
  568. &uuid[4], &uuid[5], &uuid[6], &uuid[7], &uuid[8], &uuid[9],
  569. &uuid[10], &uuid[11], &uuid[12], &uuid[13], &uuid[14],
  570. &uuid[15]);
  571. if (ret != 16) {
  572. return -1;
  573. }
  574. #ifdef TARGET_I386
  575. smbios_add_field(1, offsetof(struct smbios_type_1, uuid), 16, uuid);
  576. #endif
  577. return 0;
  578. }
  579. void do_acpitable_option(const char *optarg)
  580. {
  581. #ifdef TARGET_I386
  582. if (acpi_table_add(optarg) < 0) {
  583. fprintf(stderr, "Wrong acpi table provided\n");
  584. exit(1);
  585. }
  586. #endif
  587. }
  588. void do_smbios_option(const char *optarg)
  589. {
  590. #ifdef TARGET_I386
  591. if (smbios_entry_add(optarg) < 0) {
  592. fprintf(stderr, "Wrong smbios provided\n");
  593. exit(1);
  594. }
  595. #endif
  596. }
  597. void cpudef_init(void)
  598. {
  599. #if defined(cpudef_setup)
  600. cpudef_setup(); /* parse cpu definitions in target config file */
  601. #endif
  602. }
  603. int audio_available(void)
  604. {
  605. #ifdef HAS_AUDIO
  606. return 1;
  607. #else
  608. return 0;
  609. #endif
  610. }
  611. int tcg_available(void)
  612. {
  613. return 1;
  614. }
  615. int kvm_available(void)
  616. {
  617. #ifdef CONFIG_KVM
  618. return 1;
  619. #else
  620. return 0;
  621. #endif
  622. }
  623. int xen_available(void)
  624. {
  625. #ifdef CONFIG_XEN
  626. return 1;
  627. #else
  628. return 0;
  629. #endif
  630. }