MCPcopy Create free account
hub / github.com/ading2210/linuxpdf / init_vm

Function init_vm

tinyemu/jsemu.c:234–299  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

232}
233
234static void init_vm(void *arg)
235{
236 VMStartState *s = arg;
237 VirtMachine *m;
238 VirtMachineParams *p = s->p;
239 int i;
240
241 p->rtc_real_time = TRUE;
242 p->ram_size = s->ram_size << 20;
243 if (s->cmdline && s->cmdline[0] != '\0') {
244 vm_add_cmdline(s->p, s->cmdline);
245 }
246
247 if (global_width > 0 && global_height > 0) {
248 /* enable graphic output if needed */
249 if (!p->display_device)
250 p->display_device = strdup("simplefb");
251 p->width = global_width;
252 p->height = global_height;
253 } else {
254 p->console = console_init();
255 }
256
257 if (p->eth_count > 0 && !s->has_network) {
258 /* remove the interfaces */
259 for(i = 0; i < p->eth_count; i++) {
260 free(p->tab_eth[i].ifname);
261 free(p->tab_eth[i].driver);
262 }
263 p->eth_count = 0;
264 }
265
266 if (p->eth_count > 0) {
267 EthernetDevice *net;
268 int i;
269 assert(p->eth_count == 1);
270 net = mallocz(sizeof(EthernetDevice));
271 net->mac_addr[0] = 0x02;
272 for(i = 1; i < 6; i++)
273 net->mac_addr[i] = (int)(emscripten_random() * 256);
274 net->write_packet = net_recv_packet;
275 net->opaque = NULL;
276 p->tab_eth[0].net = net;
277 }
278
279 m = virt_machine_init(p);
280 global_vm = m;
281
282 virt_machine_free_config(s->p);
283
284 if (m->net) {
285 m->net->device_set_carrier(m->net, global_carrier_state);
286 }
287
288 free(s->p);
289 free(s->cmdline);
290 if (s->pwd) {
291 memset(s->pwd, 0, strlen(s->pwd));

Callers 1

init_vm_driveFunction · 0.85

Calls 6

vm_add_cmdlineFunction · 0.85
malloczFunction · 0.85
virt_machine_initFunction · 0.85
virt_machine_free_configFunction · 0.85
start_machine_intervalFunction · 0.85
console_initFunction · 0.70

Tested by

no test coverage detected