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