arch_init.c 18 KB

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