1
0

two_instances.html 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <!doctype html>
  2. <title>Two emulators</title>
  3. <script src="../build/libv86.js"></script>
  4. <script>
  5. "use strict";
  6. window.onload = function()
  7. {
  8. var container1 = document.getElementById("screen_container1");
  9. var container2 = document.getElementById("screen_container2");
  10. var emulator1 = new V86({
  11. wasm_path: "../build/v86.wasm",
  12. screen_container: container1,
  13. bios: {
  14. url: "../bios/seabios.bin",
  15. },
  16. vga_bios: {
  17. url: "../bios/vgabios.bin",
  18. },
  19. cdrom: {
  20. url: "../images/linux4.iso",
  21. },
  22. autostart: true,
  23. });
  24. var emulator2 = new V86({
  25. wasm_path: "../build/v86.wasm",
  26. screen_container: container2,
  27. bios: {
  28. url: "../bios/seabios.bin",
  29. },
  30. vga_bios: {
  31. url: "../bios/vgabios.bin",
  32. },
  33. cdrom: {
  34. url: "../images/linux4.iso",
  35. },
  36. autostart: true,
  37. });
  38. emulator2.keyboard_set_status(false);
  39. container1.addEventListener("mousedown", function(e)
  40. {
  41. container1.style.borderColor = "yellow";
  42. container2.style.borderColor = "black";
  43. emulator1.keyboard_set_status(true);
  44. emulator2.keyboard_set_status(false);
  45. }, false);
  46. container2.addEventListener("mousedown", function(e)
  47. {
  48. container1.style.borderColor = "black";
  49. container2.style.borderColor = "yellow";
  50. emulator1.keyboard_set_status(false);
  51. emulator2.keyboard_set_status(true);
  52. }, false);
  53. emulator1.add_listener("serial0-output-byte", function(byte)
  54. {
  55. var char = String.fromCharCode(byte);
  56. emulator2.serial0_send(char);
  57. });
  58. emulator1.add_listener("net0-send", function(data)
  59. {
  60. emulator2.bus.send("net0-receive", data);
  61. });
  62. emulator2.add_listener("net0-send", function(data)
  63. {
  64. emulator1.bus.send("net0-receive", data);
  65. });
  66. };
  67. </script>
  68. To set up networking:
  69. <pre>
  70. # first VM
  71. ifconfig eth0 up arp 10.5.0.2
  72. # second VM
  73. ifconfig eth0 up arp 10.5.0.3
  74. ping 10.5.0.2
  75. </pre>
  76. Click on a screen to control it.
  77. <hr>
  78. <div id="screen_container1" style="float: left; margin: 10px; border: 3px solid yellow;">
  79. <div style="white-space: pre; font: 14px monospace; line-height: 14px"></div>
  80. <canvas style="display: none"></canvas>
  81. </div>
  82. <div id="screen_container2" style="float: left; margin: 10px; border: 3px solid black;">
  83. <div style="white-space: pre; font: 14px monospace; line-height: 14px"></div>
  84. <canvas style="display: none"></canvas>
  85. </div>