Debian Codegraph @

unstable/hv_vm.c

raw
1 /*
2 * Cisco router simulation platform.
3 * Copyright (c) 2006 Christophe Fillot ([email protected])
4 *
5 * Hypervisor generic VM routines.
6 */
7
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <unistd.h>
11 #include <string.h>
12 #include <sys/types.h>
13 #include <sys/stat.h>
14 #include <signal.h>
15 #include <fcntl.h>
16 #include <errno.h>
17 #include <assert.h>
18 #include <stdarg.h>
19 #include <sys/ioctl.h>
20 #include <sys/types.h>
21 #include <sys/socket.h>
22 #include <arpa/inet.h>
23 #include <pthread.h>
24 #include <glob.h>
25
26 #include "cpu.h"
27 #include "vm.h"
28 #include "dynamips.h"
29 #include "device.h"
30 #include "dev_c7200.h"
31 #include "dev_vtty.h"
32 #include "utils.h"
33 #include "base64.h"
34 #include "net.h"
35 #include "atm.h"
36 #include "frame_relay.h"
37 #include "crc.h"
38 #include "net_io.h"
39 #include "net_io_bridge.h"
40 #ifdef GEN_ETH
41 #include "gen_eth.h"
42 #endif
43 #include "registry.h"
44 #include "hypervisor.h"
45 #include "get_cpu_time.h"
46
47 /* Find the specified CPU */
48 static cpu_gen_t *find_cpu(hypervisor_conn_t *conn,vm_instance_t *vm,
49 u_int cpu_id)
50 {
51 cpu_gen_t *cpu;
52
53
54 cpu = cpu_group_find_id(vm->cpu_group,cpu_id);
55
56 if (!cpu) {
57 vm_release(vm);
58 hypervisor_send_reply(conn,HSC_ERR_BAD_OBJ,1,"Bad CPU specified");
59 return NULL;
60 }
61
62 return cpu;
63 }
64
65 /* Create a VM instance */
66 static int cmd_create(hypervisor_conn_t *conn,int argc,char *argv[])
67 {
68 vm_instance_t *vm;
69
70 if (!(vm = vm_create_instance(argv[0],atoi(argv[1]),argv[2]))) {
71 hypervisor_send_reply(conn,HSC_ERR_CREATE,1,
72 "unable to create VM instance '%s'",
73 argv[0]);
74 return(-1);
75 }
76
77 vm->vtty_con_type = VTTY_TYPE_NONE;
78 vm->vtty_aux_type = VTTY_TYPE_NONE;
79
80 vm_release(vm);
81 hypervisor_send_reply(conn,HSC_INFO_OK,1,"VM '%s' created",argv[0]);
82 return(0);
83 }
84
85 /* Rename a VM instance */
86 static int cmd_rename(hypervisor_conn_t *conn,int argc,char *argv[])
87 {
88 vm_instance_t *vm;
89
90 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
91 return(-1);
92
93 if (registry_exists(argv[1],OBJ_TYPE_VM)) {
94 vm_release(vm);
95 hypervisor_send_reply(conn,HSC_ERR_RENAME,1,
96 "unable to rename VM instance '%s', '%s' already exists",
97 argv[0],argv[1]);
98 return(-1);
99 }
100
101 if (vm_rename_instance(vm,argv[1])) {
102 hypervisor_send_reply(conn,HSC_ERR_RENAME,1,
103 "unable to rename VM instance '%s'",
104 argv[0]);
105 return(-1);
106 }
107
108 vm_release(vm);
109 hypervisor_send_reply(conn,HSC_INFO_OK,1,"VM '%s' renamed to '%s'",argv[0],argv[1]);
110 return(0);
111 }
112
113 /* Delete a VM instance */
114 static int cmd_delete(hypervisor_conn_t *conn,int argc,char *argv[])
115 {
116 int res;
117
118 res = vm_delete_instance(argv[0]);
119
120 if (res == 1) {
121 hypervisor_send_reply(conn,HSC_INFO_OK,1,"VM '%s' deleted",argv[0]);
122 } else {
123 hypervisor_send_reply(conn,HSC_ERR_DELETE,1,
124 "unable to delete VM '%s'",argv[0]);
125 }
126
127 return(res);
128 }
129
130 /* Delete a VM instance and related files */
131 static int cmd_clean_delete(hypervisor_conn_t *conn,int argc,char *argv[])
132 {
133 int res, i;
134 glob_t globbuf;
135 char *pattern;
136 vm_instance_t *vm;
137
138 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
139 return(-1);
140
141 pattern = vm_build_filename(vm, "*");
142 vm_release(vm);
143 res = vm_delete_instance(argv[0]);
144
145 if (res == 1) {
146 /* delete related files (best effort) */
147 if (pattern != NULL && glob(pattern, GLOB_NOSORT, NULL, &globbuf) == 0) {
148 for (i = 0; i < globbuf.gl_pathc; i++) {
149 remove(globbuf.gl_pathv[i]);
150 }
151
152 globfree(&globbuf);
153 }
154
155 hypervisor_send_reply(conn,HSC_INFO_OK,1,"VM '%s' and related files deleted",argv[0]);
156 } else {
157 hypervisor_send_reply(conn,HSC_ERR_DELETE,1,
158 "unable to delete VM '%s'",argv[0]);
159 }
160
161 free(pattern);
162 return(res);
163 }
164
165 /* Start a VM instance */
166 static int cmd_start(hypervisor_conn_t *conn,int argc,char *argv[])
167 {
168 vm_instance_t *vm;
169
170 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
171 return(-1);
172
173 if (vm->vtty_con_type == VTTY_TYPE_NONE) {
174 hypervisor_send_reply(conn,HSC_INFO_MSG,0,
175 "Warning: no console port defined for "
176 "VM '%s'",argv[0]);
177 }
178
179 if (vm_init_instance(vm) == -1) {
180 vm_release(vm);
181 hypervisor_send_reply(conn,HSC_ERR_START,1,
182 "unable to start VM instance '%s'",
183 argv[0]);
184 return(-1);
185 }
186
187 vm_release(vm);
188 hypervisor_send_reply(conn,HSC_INFO_OK,1,"VM '%s' started",argv[0]);
189 return(0);
190 }
191
192 /* Stop a VM instance */
193 static int cmd_stop(hypervisor_conn_t *conn,int argc,char *argv[])
194 {
195 vm_instance_t *vm;
196
197 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
198 return(-1);
199
200 if (vm_stop_instance(vm) == -1) {
201 vm_release(vm);
202 hypervisor_send_reply(conn,HSC_ERR_STOP,1,
203 "unable to stop VM instance '%s'",
204 argv[0]);
205 return(-1);
206 }
207
208 vm_release(vm);
209 hypervisor_send_reply(conn,HSC_INFO_OK,1,"VM '%s' stopped",argv[0]);
210 return(0);
211 }
212
213 /* Get the status of a VM instance */
214 static int cmd_get_status(hypervisor_conn_t *conn,int argc,char *argv[])
215 {
216 vm_instance_t *vm;
217 int status;
218
219 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
220 return(-1);
221
222 status = vm->status;
223
224 vm_release(vm);
225 hypervisor_send_reply(conn,HSC_INFO_OK,1,"%d",status);
226 return(0);
227 }
228
229 /* Set translation sharing group */
230 static int cmd_set_tsg(hypervisor_conn_t *conn,int argc,char *argv[])
231 {
232 vm_instance_t *vm;
233 int res;
234
235 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
236 return(-1);
237
238 res = vm_set_tsg(vm,atoi(argv[1]));
239
240 vm_release(vm);
241
242 if (res < 0)
243 hypervisor_send_reply(conn,HSC_ERR_BAD_PARAM,1,"unable to set group");
244 else
245 hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
246 return(0);
247 }
248
249 /* Set debugging level */
250 static int cmd_set_debug_level(hypervisor_conn_t *conn,int argc,char *argv[])
251 {
252 vm_instance_t *vm;
253
254 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
255 return(-1);
256
257 vm->debug_level = atoi(argv[1]);
258
259 vm_release(vm);
260 hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
261 return(0);
262 }
263
264 /* Set IOS image filename */
265 static int cmd_set_ios(hypervisor_conn_t *conn,int argc,char *argv[])
266 {
267 vm_instance_t *vm;
268
269 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
270 return(-1);
271
272 if (vm_ios_set_image(vm,argv[1]) == -1) {
273 vm_release(vm);
274 hypervisor_send_reply(conn,HSC_ERR_CREATE,1,
275 "unable to store IOS image name for router '%s'",
276 argv[0]);
277 return(-1);
278 }
279
280 vm_release(vm);
281 hypervisor_send_reply(conn,HSC_INFO_OK,1,"IOS image set for '%s'",argv[0]);
282 return(0);
283 }
284
285 /* Set IOS configuration filename to load at startup */
286 static int cmd_set_config(hypervisor_conn_t *conn,int argc,char *argv[])
287 {
288 vm_instance_t *vm;
289 const char *startup_filename = argv[1];
290 const char *private_filename = ((argc > 2) ? argv[2] : "");
291
292 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
293 return(-1);
294
295 if (0 == strlen(startup_filename))
296 startup_filename = NULL; // keep existing data
297
298 if (0 == strlen(private_filename))
299 private_filename = NULL; // keep existing data
300
301 if (vm_ios_set_config(vm,startup_filename,private_filename) == -1) {
302 vm_release(vm);
303 hypervisor_send_reply(conn,HSC_ERR_CREATE,1,
304 "unable to store IOS config for router '%s'",
305 argv[0]);
306 return(-1);
307 }
308
309 vm_release(vm);
310 hypervisor_send_reply(conn,HSC_INFO_OK,1,"IOS config file set for '%s'",
311 argv[0]);
312 return(0);
313 }
314
315 /* Set RAM size */
316 static int cmd_set_ram(hypervisor_conn_t *conn,int argc,char *argv[])
317 {
318 vm_instance_t *vm;
319
320 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
321 return(-1);
322
323 vm->ram_size = atoi(argv[1]);
324
325 /* XXX npe-400 can split excess ram into iomem, adjusting ram_size */
326 if (vm->elf_machine_id == C7200_ELF_MACHINE_ID)
327 VM_C7200(vm)->npe400_ram_size = vm->ram_size;
328
329 vm_release(vm);
330 hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
331 return(0);
332 }
333
334 /* Set NVRAM size */
335 static int cmd_set_nvram(hypervisor_conn_t *conn,int argc,char *argv[])
336 {
337 vm_instance_t *vm;
338
339 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
340 return(-1);
341
342 vm->nvram_size = atoi(argv[1]);
343
344 vm_release(vm);
345 hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
346 return(0);
347 }
348
349 /* Enable/disable use of a memory-mapped file to simulate RAM */
350 static int cmd_set_ram_mmap(hypervisor_conn_t *conn,int argc,char *argv[])
351 {
352 vm_instance_t *vm;
353
354 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
355 return(-1);
356
357 vm->ram_mmap = atoi(argv[1]);
358
359 vm_release(vm);
360 hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
361 return(0);
362 }
363
364 /* Enable/disable use of sparse memory */
365 static int cmd_set_sparse_mem(hypervisor_conn_t *conn,int argc,char *argv[])
366 {
367 vm_instance_t *vm;
368
369 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
370 return(-1);
371
372 vm->sparse_mem = atoi(argv[1]);
373
374 vm_release(vm);
375 hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
376 return(0);
377 }
378
379 /* Set the clock divisor */
380 static int cmd_set_clock_divisor(hypervisor_conn_t *conn,int argc,char *argv[])
381 {
382 vm_instance_t *vm;
383 u_int clock_div;
384
385 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
386 return(-1);
387
388 if ((clock_div = atoi(argv[1])) != 0)
389 vm->clock_divisor = clock_div;
390
391 vm_release(vm);
392 hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
393 return(0);
394 }
395
396 /* Enable/disable use of block direct jump (compatibility option) */
397 static int cmd_set_blk_direct_jump(hypervisor_conn_t *conn,
398 int argc,char *argv[])
399 {
400 vm_instance_t *vm;
401
402 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
403 return(-1);
404
405 vm->exec_blk_direct_jump = atoi(argv[1]);
406
407 vm_release(vm);
408 hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
409 return(0);
410 }
411
412 /* Set the idle PC */
413 static int cmd_set_idle_pc(hypervisor_conn_t *conn,int argc,char *argv[])
414 {
415 vm_instance_t *vm;
416
417 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
418 return(-1);
419
420 vm->idle_pc = strtoull(argv[1],NULL,0);
421
422 vm_release(vm);
423 hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
424 return(0);
425 }
426
427 /* Set the idle PC value when the CPU is online */
428 static int cmd_set_idle_pc_online(hypervisor_conn_t *conn,
429 int argc,char *argv[])
430 {
431 vm_instance_t *vm;
432 cpu_gen_t *cpu;
433
434 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
435 return(-1);
436
437 if (!(cpu = find_cpu(conn,vm,atoi(argv[1]))))
438 return(-1);
439
440 cpu->set_idle_pc(cpu,strtoull(argv[2],NULL,0));
441
442 vm_release(vm);
443 hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
444 return(0);
445 }
446
447 /* Get the idle PC proposals */
448 static int cmd_get_idle_pc_prop(hypervisor_conn_t *conn,int argc,char *argv[])
449 {
450 vm_instance_t *vm;
451 cpu_gen_t *cpu;
452 int i;
453
454 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
455 return(-1);
456
457 if (!(cpu = find_cpu(conn,vm,atoi(argv[1]))))
458 return(-1);
459
460 cpu->get_idling_pc(cpu);
461
462 for(i=0;i<cpu->idle_pc_prop_count;i++) {
463 hypervisor_send_reply(conn,HSC_INFO_MSG,0,"0x%llx [%d]",
464 cpu->idle_pc_prop[i].pc,
465 cpu->idle_pc_prop[i].count);
466 }
467
468 vm_release(vm);
469 hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
470 return(0);
471 }
472
473 /* Dump the idle PC proposals */
474 static int cmd_show_idle_pc_prop(hypervisor_conn_t *conn,int argc,char *argv[])
475 {
476 vm_instance_t *vm;
477 cpu_gen_t *cpu;
478 int i;
479
480 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
481 return(-1);
482
483 if (!(cpu = find_cpu(conn,vm,atoi(argv[1]))))
484 return(-1);
485
486 for(i=0;i<cpu->idle_pc_prop_count;i++) {
487 hypervisor_send_reply(conn,HSC_INFO_MSG,0,"0x%llx [%d]",
488 cpu->idle_pc_prop[i].pc,
489 cpu->idle_pc_prop[i].count);
490 }
491
492 vm_release(vm);
493 hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
494 return(0);
495 }
496
497 /* Set CPU idle max value */
498 static int cmd_set_idle_max(hypervisor_conn_t *conn,int argc,char *argv[])
499 {
500 vm_instance_t *vm;
501 cpu_gen_t *cpu;
502
503 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
504 return(-1);
505
506 if (!(cpu = find_cpu(conn,vm,atoi(argv[1]))))
507 return(-1);
508
509 cpu->idle_max = atoi(argv[2]);
510
511 vm_release(vm);
512 hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
513 return(0);
514 }
515
516 /* Set CPU idle sleep time value */
517 static int cmd_set_idle_sleep_time(hypervisor_conn_t *conn,
518 int argc,char *argv[])
519 {
520 vm_instance_t *vm;
521 cpu_gen_t *cpu;
522
523 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
524 return(-1);
525
526 if (!(cpu = find_cpu(conn,vm,atoi(argv[1]))))
527 return(-1);
528
529 cpu->idle_sleep_time = atoi(argv[2]);
530
531 vm_release(vm);
532 hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
533 return(0);
534 }
535
536 /* Show info about potential timer drift */
537 static int cmd_show_timer_drift(hypervisor_conn_t *conn,
538 int argc,char *argv[])
539 {
540 vm_instance_t *vm;
541 cpu_gen_t *cpu;
542
543 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
544 return(-1);
545
546 if (!(cpu = find_cpu(conn,vm,atoi(argv[1]))))
547 return(-1);
548
549 switch(cpu->type) {
550 case CPU_TYPE_MIPS64:
551 hypervisor_send_reply(conn,HSC_INFO_MSG,0,"Timer Drift: %u",
552 CPU_MIPS64(cpu)->timer_drift);
553
554 hypervisor_send_reply(conn,HSC_INFO_MSG,0,"Pending Timer IRQ: %u",
555 CPU_MIPS64(cpu)->timer_irq_pending);
556 break;
557
558 case CPU_TYPE_PPC32:
559 hypervisor_send_reply(conn,HSC_INFO_MSG,0,"Timer Drift: %u",
560 CPU_PPC32(cpu)->timer_drift);
561
562 hypervisor_send_reply(conn,HSC_INFO_MSG,0,"Pending Timer IRQ: %u",
563 CPU_PPC32(cpu)->timer_irq_pending);
564 break;
565 }
566
567 vm_release(vm);
568 hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
569 return(0);
570 }
571
572 /* Set the exec area size */
573 static int cmd_set_exec_area(hypervisor_conn_t *conn,int argc,char *argv[])
574 {
575 vm_instance_t *vm;
576
577 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
578 return(-1);
579
580 vm->exec_area_size = atoi(argv[1]);
581
582 vm_release(vm);
583 hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
584 return(0);
585 }
586
587 /* Set ghost RAM file */
588 static int cmd_set_ghost_file(hypervisor_conn_t *conn,int argc,char *argv[])
589 {
590 vm_instance_t *vm;
591
592 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
593 return(-1);
594
595 free(vm->ghost_ram_filename);
596 vm->ghost_ram_filename = strdup(argv[1]);
597
598 vm_release(vm);
599 hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
600 return(0);
601 }
602
603 /* Set ghost RAM status */
604 static int cmd_set_ghost_status(hypervisor_conn_t *conn,int argc,char *argv[])
605 {
606 vm_instance_t *vm;
607
608 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
609 return(-1);
610
611 vm->ghost_status = atoi(argv[1]);
612
613 vm_release(vm);
614 hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
615 return(0);
616 }
617
618
619 /* Set PCMCIA ATA disk0 size */
620 static int cmd_set_disk0(hypervisor_conn_t *conn,int argc,char *argv[])
621 {
622 vm_instance_t *vm;
623
624 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
625 return(-1);
626
627 vm->pcmcia_disk_size[0] = atoi(argv[1]);
628 vm_release(vm);
629 hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
630 return(0);
631 }
632
633 /* Set PCMCIA ATA disk1 size */
634 static int cmd_set_disk1(hypervisor_conn_t *conn,int argc,char *argv[])
635 {
636 vm_instance_t *vm;
637
638 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
639 return(-1);
640
641 vm->pcmcia_disk_size[1] = atoi(argv[1]);
642 vm_release(vm);
643 hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
644 return(0);
645 }
646
647 /* Set the config register used at startup */
648 static int cmd_set_conf_reg(hypervisor_conn_t *conn,int argc,char *argv[])
649 {
650 vm_instance_t *vm;
651
652 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
653 return(-1);
654
655 vm->conf_reg_setup = strtol(argv[1],NULL,0);
656 vm_release(vm);
657 hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
658 return(0);
659 }
660
661 /* Set TCP port for console */
662 static int cmd_set_con_tcp_port(hypervisor_conn_t *conn,int argc,char *argv[])
663 {
664 vm_instance_t *vm;
665
666 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
667 return(-1);
668
669 vm->vtty_con_type = VTTY_TYPE_TCP;
670 vm->vtty_con_tcp_port = atoi(argv[1]);
671
672 vm_release(vm);
673 hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
674 return(0);
675 }
676
677 /* Set TCP port for AUX port */
678 static int cmd_set_aux_tcp_port(hypervisor_conn_t *conn,int argc,char *argv[])
679 {
680 vm_instance_t *vm;
681
682 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
683 return(-1);
684
685 vm->vtty_aux_type = VTTY_TYPE_TCP;
686 vm->vtty_aux_tcp_port = atoi(argv[1]);
687
688 vm_release(vm);
689 hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
690 return(0);
691 }
692
693 /* Read IOS configuration files from a given router */
694 static int cmd_extract_config(hypervisor_conn_t *conn,int argc,char *argv[])
695 {
696 vm_instance_t *vm;
697 u_char *startup_config = NULL;
698 u_char *private_config = NULL;
699 size_t startup_len;
700 size_t private_len;
701 u_char *startup_base64 = NULL;
702 u_char *private_base64 = NULL;
703
704 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
705 return(-1);
706
707 if (!vm->platform->nvram_extract_config)
708 goto err_no_extract_method;
709
710 /* Extract the IOS configuration */
711 if ((vm->platform->nvram_extract_config(vm,&startup_config,&startup_len,&private_config,&private_len)))
712 goto err_nvram_extract;
713
714 /*
715 * Convert config to base64. base64 generates 4 bytes for each group of 3 bytes.
716 */
717 if (!(startup_base64 = malloc(1 + (startup_len + 2) / 3 * 4)) ||
718 !(private_base64 = malloc(1 + (private_len + 2) / 3 * 4)))
719 goto err_alloc_base64;
720
721 base64_encode(startup_base64,startup_config,startup_len);
722 base64_encode(private_base64,private_config,private_len);
723
724 vm_release(vm);
725 hypervisor_send_reply(conn,HSC_INFO_OK,1,"conf '%s' '%s' '%s'",argv[0],startup_base64,private_base64);
726
727 free(private_base64);
728 free(startup_base64);
729 free(private_config);
730 free(startup_config);
731 return(0);
732
733 err_alloc_base64:
734 free(private_base64);
735 free(startup_base64);
736 free(private_config);
737 free(startup_config);
738 err_nvram_extract:
739 err_no_extract_method:
740 vm_release(vm);
741 hypervisor_send_reply(conn,HSC_ERR_CREATE,1,
742 "unable to extract config of VM '%s'",argv[0]);
743 return(-1);
744 }
745
746 /* Push IOS configuration to a given router */
747 static int cmd_push_config(hypervisor_conn_t *conn,int argc,char *argv[])
748 {
749 vm_instance_t *vm;
750 u_char *startup_config = NULL;
751 u_char *private_config = NULL;
752 int startup_len = 0;
753 int private_len = 0;
754
755 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
756 return(-1);
757
758 if (!vm->platform->nvram_push_config)
759 goto err_no_push_method;
760
761 /*
762 * Convert base64 input to standard text. base64 uses 4 bytes for each group of 3 bytes.
763 */
764 if (strcmp(argv[1],"(keep)") != 0) {
765 startup_len = (strlen(argv[1]) + 3) / 4 * 3;
766 if (!(startup_config = malloc(1 + startup_len)))
767 goto err_alloc_base64;
768
769 if ((startup_len = base64_decode(startup_config,(u_char *)argv[1],startup_len)) < 0)
770 goto err_decode_base64;
771
772 startup_config[startup_len] = '\0';
773 }
774
775 if (argc > 2 && strcmp(argv[2],"(keep)") != 0) {
776 private_len = (strlen(argv[2]) + 3) / 4 * 3;
777 if (!(private_config = malloc(1 + private_len)))
778 goto err_alloc_base64;
779
780 if ((private_len = base64_decode(private_config,(u_char *)argv[2],private_len)) < 0)
781 goto err_decode_base64;
782
783 private_config[private_len] = '\0';
784 }
785
786 /* Push configuration */
787 if (vm->platform->nvram_push_config(vm,startup_config,(size_t)startup_len,private_config,(size_t)private_len) < 0)
788 goto err_nvram_push;
789
790 free(private_config);
791 free(startup_config);
792 vm_release(vm);
793 hypervisor_send_reply(conn,HSC_INFO_OK,1,
794 "IOS config file pushed tm VM '%s'",
795 argv[0]);
796 return(0);
797
798 err_nvram_push:
799 err_decode_base64:
800 err_alloc_base64:
801 free(private_config);
802 free(startup_config);
803 err_no_push_method:
804 vm_release(vm);
805 hypervisor_send_reply(conn,HSC_ERR_CREATE,1,
806 "unable to push IOS config for VM '%s'",
807 argv[0]);
808 return(-1);
809 }
810
811 /* Show info about the specified CPU */
812 static int cmd_show_cpu_info(hypervisor_conn_t *conn,int argc,char *argv[])
813 {
814 vm_instance_t *vm;
815 cpu_gen_t *cpu;
816
817 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
818 return(-1);
819
820 cpu = cpu_group_find_id(vm->cpu_group,atoi(argv[1]));
821
822 if (cpu) {
823 cpu->reg_dump(cpu);
824 cpu->mmu_dump(cpu);
825 }
826
827 vm_release(vm);
828 hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
829 return(0);
830 }
831
832 /* Show CPU usage - experimental */
833 static int cmd_show_cpu_usage(hypervisor_conn_t *conn,int argc,char *argv[])
834 {
835 vm_instance_t *vm;
836 double usage;
837
838 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
839 return(-1);
840
841 usage = get_cpu_time();
842 if (usage == -1)
843 return(-1);
844 hypervisor_send_reply(conn,HSC_INFO_MSG,0,"%lu", (unsigned long)usage);
845
846 vm_release(vm);
847 hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
848 return(0);
849 }
850
851 /* Suspend a VM instance */
852 static int cmd_suspend(hypervisor_conn_t *conn,int argc,char *argv[])
853 {
854 vm_instance_t *vm;
855
856 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
857 return(-1);
858
859 vm_suspend(vm);
860
861 vm_release(vm);
862 hypervisor_send_reply(conn,HSC_INFO_OK,1,"VM '%s' suspended",argv[0]);
863 return(0);
864 }
865
866 /* Resume a VM instance */
867 static int cmd_resume(hypervisor_conn_t *conn,int argc,char *argv[])
868 {
869 vm_instance_t *vm;
870
871 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
872 return(-1);
873
874 vm_resume(vm);
875
876 vm_release(vm);
877 hypervisor_send_reply(conn,HSC_INFO_OK,1,"VM '%s' resumed",argv[0]);
878 return(0);
879 }
880
881 /* Send a message on the console */
882 static int cmd_send_con_msg(hypervisor_conn_t *conn,int argc,char *argv[])
883 {
884 vm_instance_t *vm = NULL;
885 const char *format = NULL;
886 char *data = NULL;
887 int len,written;
888
889 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
890 return(-1);
891
892 format = (argc > 2)? argv[2]: "plain";
893 len = (int)strlen(argv[1]);
894 written = -1;
895
896 if (strcmp(format,"plain") == 0 && len >= 0) {
897 written = vtty_store_data(vm->vtty_con,argv[1],len);
898 }
899 else if (strcmp(format,"base64") == 0 && len >= 0) {
900 data = malloc(len+1);
901 len = base64_decode((unsigned char*)data,(const unsigned char *)argv[1],len);
902 written = vtty_store_data(vm->vtty_con,data,len);
903 free(data);
904 data = NULL;
905 }
906
907 vm_release(vm);
908 if (written < 0) {
909 hypervisor_send_reply(conn,HSC_ERR_INV_PARAM,1,"Invalid parameter");
910 return(-1);
911 }
912 else {
913 hypervisor_send_reply(conn,HSC_INFO_OK,1,"%d byte(s) written",written);
914 return(0);
915 }
916 }
917
918 /* Send a message on the AUX port */
919 static int cmd_send_aux_msg(hypervisor_conn_t *conn,int argc,char *argv[])
920 {
921 vm_instance_t *vm = NULL;
922 const char *format = NULL;
923 char *data = NULL;
924 int len,written;
925
926 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
927 return(-1);
928
929 format = (argc > 2)? argv[2]: "plain";
930 len = (int)strlen(argv[1]);
931 written = -1;
932
933 if (strcmp(format,"plain") == 0 && len >= 0) {
934 written = vtty_store_data(vm->vtty_aux,argv[1],len);
935 }
936 else if (strcmp(format,"base64") == 0 && len >= 0) {
937 data = malloc(len+1);
938 len = base64_decode((unsigned char*)data,(const unsigned char *)argv[1],len);
939 written = vtty_store_data(vm->vtty_aux,data,len);
940 free(data);
941 data = NULL;
942 }
943
944 vm_release(vm);
945 if (written < 0) {
946 hypervisor_send_reply(conn,HSC_ERR_INV_PARAM,1,"Invalid parameter");
947 return(-1);
948 }
949 else {
950 hypervisor_send_reply(conn,HSC_INFO_OK,1,"%d byte(s) written",written);
951 return(0);
952 }
953 }
954
955
956 /* Show slot bindings */
957 static int cmd_slot_bindings(hypervisor_conn_t *conn,int argc,char *argv[])
958 {
959 struct cisco_card *card,*sc;
960 vm_instance_t *vm;
961 int i,j;
962
963 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
964 return(-1);
965
966 for(i=0;i<vm->nr_slots;i++) {
967 if (!(card = vm_slot_get_card_ptr(vm,i)))
968 continue;
969
970 /* main module */
971 hypervisor_send_reply(conn,HSC_INFO_MSG,0,"%u/%u: %s",
972 card->slot_id,card->subslot_id,card->dev_type);
973
974 /* sub-slots */
975 for(j=0;j<CISCO_CARD_MAX_SUBSLOTS;j++) {
976 if (!(sc = card->sub_slots[j]))
977 continue;
978
979 hypervisor_send_reply(conn,HSC_INFO_MSG,0,"%u/%u: %s",
980 card->slot_id,card->subslot_id,card->dev_type);
981 }
982 }
983
984 vm_release(vm);
985 hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
986 return(0);
987 }
988
989 /* Show NIO bindings for the specified slot */
990 static int cmd_slot_nio_bindings(hypervisor_conn_t *conn,int argc,char *argv[])
991 {
992 struct cisco_nio_binding *nb;
993 struct cisco_card *card,*sc;
994 vm_instance_t *vm;
995 u_int i,slot;
996
997 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
998 return(-1);
999
1000 slot = atoi(argv[1]);
1001
1002 if ((card = vm_slot_get_card_ptr(vm,slot)))
1003 {
1004 /* main module */
1005 for(nb=card->nio_list;nb;nb=nb->next) {
1006 hypervisor_send_reply(conn,HSC_INFO_MSG,0,"%u: %s",
1007 nb->port_id,nb->nio->name);
1008 }
1009
1010 /* sub-slots */
1011 for(i=0;i<CISCO_CARD_MAX_SUBSLOTS;i++) {
1012 if (!(sc = card->sub_slots[i]))
1013 continue;
1014
1015 for(nb=sc->nio_list;nb;nb=nb->next) {
1016 hypervisor_send_reply(conn,HSC_INFO_MSG,0,"%u: %s",
1017 nb->port_id,nb->nio->name);
1018 }
1019 }
1020 }
1021
1022 vm_release(vm);
1023 hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
1024 return(0);
1025 }
1026
1027 /* Add a slot binding */
1028 static int cmd_slot_add_binding(hypervisor_conn_t *conn,int argc,char *argv[])
1029 {
1030 vm_instance_t *vm;
1031 u_int slot,port;
1032
1033 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
1034 return(-1);
1035
1036 slot = atoi(argv[1]);
1037 port = atoi(argv[2]);
1038
1039 if (vm_slot_add_binding(vm,argv[3],slot,port) == -1) {
1040 vm_release(vm);
1041 hypervisor_send_reply(conn,HSC_ERR_BINDING,1,
1042 "VM %s: unable to add binding for slot %u/%u",
1043 argv[0],slot,port);
1044 return(-1);
1045 }
1046
1047 vm_release(vm);
1048 hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
1049 return(0);
1050 }
1051
1052 /* Remove a slot binding */
1053 static int cmd_slot_remove_binding(hypervisor_conn_t *conn,
1054 int argc,char *argv[])
1055 {
1056 vm_instance_t *vm;
1057 u_int slot,port;
1058
1059 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
1060 return(-1);
1061
1062 slot = atoi(argv[1]);
1063 port = atoi(argv[2]);
1064
1065 if (vm_slot_remove_binding(vm,slot,port) == -1) {
1066 vm_release(vm);
1067 hypervisor_send_reply(conn,HSC_ERR_BINDING,1,
1068 "VM %s: unable to remove binding for slot %u/%u",
1069 argv[0],slot,port);
1070 return(-1);
1071 }
1072
1073 vm_release(vm);
1074 hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
1075 return(0);
1076 }
1077
1078 /* Add a NIO binding for a slot/port */
1079 static int cmd_slot_add_nio_binding(hypervisor_conn_t *conn,
1080 int argc,char *argv[])
1081 {
1082 vm_instance_t *vm;
1083 u_int slot,port;
1084
1085 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
1086 return(-1);
1087
1088 slot = atoi(argv[1]);
1089 port = atoi(argv[2]);
1090
1091 if (vm_slot_add_nio_binding(vm,slot,port,argv[3]) == -1) {
1092 vm_release(vm);
1093 hypervisor_send_reply(conn,HSC_ERR_BINDING,1,
1094 "VM %s: unable to add binding "
1095 "for slot %u/%u",argv[0],slot,port);
1096 return(-1);
1097 }
1098
1099 vm_release(vm);
1100 hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
1101 return(0);
1102 }
1103
1104 /* Remove a NIO binding for a slot/port */
1105 static int cmd_slot_remove_nio_binding(hypervisor_conn_t *conn,
1106 int argc,char *argv[])
1107 {
1108 vm_instance_t *vm;
1109 u_int slot,port;
1110
1111 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
1112 return(-1);
1113
1114 slot = atoi(argv[1]);
1115 port = atoi(argv[2]);
1116
1117 if (vm_slot_remove_nio_binding(vm,slot,port) == -1) {
1118 vm_release(vm);
1119 hypervisor_send_reply(conn,HSC_ERR_BINDING,1,
1120 "VM %s: unable to remove NIO binding "
1121 "for slot %u/%u",argv[0],slot,port);
1122 return(-1);
1123 }
1124
1125 vm_release(vm);
1126 hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
1127 return(0);
1128 }
1129
1130 /* Enable NIO of the specified slot/port */
1131 static int cmd_slot_enable_nio(hypervisor_conn_t *conn,int argc,char *argv[])
1132 {
1133 vm_instance_t *vm;
1134 u_int slot,port;
1135
1136 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
1137 return(-1);
1138
1139 slot = atoi(argv[1]);
1140 port = atoi(argv[2]);
1141
1142 if (vm_slot_enable_nio(vm,slot,port) == -1) {
1143 vm_release(vm);
1144 hypervisor_send_reply(conn,HSC_ERR_BINDING,1,
1145 "VM %s: unable to enable NIO for slot %u/%u",
1146 argv[0],slot,port);
1147 return(-1);
1148 }
1149
1150 vm_release(vm);
1151 hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
1152 return(0);
1153 }
1154
1155 /* Disable NIO of the specified slot/port */
1156 static int cmd_slot_disable_nio(hypervisor_conn_t *conn,int argc,char *argv[])
1157 {
1158 vm_instance_t *vm;
1159 u_int slot,port;
1160
1161 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
1162 return(-1);
1163
1164 slot = atoi(argv[1]);
1165 port = atoi(argv[2]);
1166
1167 if (vm_slot_disable_nio(vm,slot,port) == -1) {
1168 vm_release(vm);
1169 hypervisor_send_reply(conn,HSC_ERR_BINDING,1,
1170 "VM %s: unable to disable NIO for slot %u/%u",
1171 argv[0],slot,port);
1172 return(-1);
1173 }
1174
1175 vm_release(vm);
1176 hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
1177 return(0);
1178 }
1179
1180 /* OIR to start a slot/subslot */
1181 static int cmd_slot_oir_start(hypervisor_conn_t *conn,int argc,char *argv[])
1182 {
1183 vm_instance_t *vm;
1184 u_int slot,subslot;
1185
1186 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
1187 return(-1);
1188
1189 slot = atoi(argv[1]);
1190 subslot = atoi(argv[2]);
1191
1192 if (vm_oir_start(vm,slot,subslot) == -1) {
1193 vm_release(vm);
1194 hypervisor_send_reply(conn,HSC_ERR_START,1,
1195 "VM %s: unable to engage OIR for slot %u/%u",
1196 argv[0],slot,subslot);
1197 return(-1);
1198 }
1199
1200 vm_release(vm);
1201 hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
1202 return(0);
1203 }
1204
1205 /* OIR to stop a slot/subslot */
1206 static int cmd_slot_oir_stop(hypervisor_conn_t *conn,int argc,char *argv[])
1207 {
1208 vm_instance_t *vm;
1209 u_int slot,subslot;
1210
1211 if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
1212 return(-1);
1213
1214 slot = atoi(argv[1]);
1215 subslot = atoi(argv[2]);
1216
1217 if (vm_oir_stop(vm,slot,subslot) == -1) {
1218 vm_release(vm);
1219 hypervisor_send_reply(conn,HSC_ERR_STOP,1,
1220 "VM %s: unable to engage OIR for slot %u/%u",
1221 argv[0],slot,subslot);
1222 return(-1);
1223 }
1224
1225 vm_release(vm);
1226 hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
1227 return(0);
1228 }
1229
1230 /* Show info about VM object */
1231 static void cmd_show_vm_list(registry_entry_t *entry,void *opt,int *err)
1232 {
1233 hypervisor_conn_t *conn = opt;
1234 vm_instance_t *vm = entry->data;
1235
1236 hypervisor_send_reply(conn,HSC_INFO_MSG,0,"%s (%s)",
1237 entry->name,vm_get_type(vm));
1238 }
1239
1240 /* VM List */
1241 static int cmd_vm_list(hypervisor_conn_t *conn,int argc,char *argv[])
1242 {
1243 int err = 0;
1244 registry_foreach_type(OBJ_TYPE_VM,cmd_show_vm_list,conn,&err);
1245 hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
1246 return(0);
1247 }
1248
1249 /* Show console TCP port info about VM object */
1250 static void cmd_show_vm_list_con_ports(registry_entry_t *entry,void *opt,
1251 int *err)
1252 {
1253 hypervisor_conn_t *conn = opt;
1254 vm_instance_t *vm = entry->data;
1255
1256 if (vm->vtty_con_type == VTTY_TYPE_TCP)
1257 hypervisor_send_reply(conn,HSC_INFO_MSG,0,"%s (%d)",
1258 vm->name,vm->vtty_con_tcp_port);
1259 }
1260
1261 /* VM console TCP port list */
1262 static int cmd_vm_list_con_ports(hypervisor_conn_t *conn,int argc,char *argv[])
1263 {
1264 int err = 0;
1265 registry_foreach_type(OBJ_TYPE_VM,cmd_show_vm_list_con_ports,conn,&err);
1266 hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
1267 return(0);
1268 }
1269
1270 /* VM commands */
1271 static hypervisor_cmd_t vm_cmd_array[] = {
1272 { "create", 3, 3, cmd_create, NULL },
1273 { "rename", 2, 2, cmd_rename, NULL },
1274 { "delete", 1, 1, cmd_delete, NULL },
1275 { "clean_delete", 1, 1, cmd_clean_delete, NULL, },
1276 { "start", 1, 1, cmd_start, NULL },
1277 { "stop", 1, 1, cmd_stop, NULL },
1278 { "get_status", 1, 1, cmd_get_status, NULL },
1279 { "set_tsg", 2, 2, cmd_set_tsg, NULL },
1280 { "set_debug_level", 2, 2, cmd_set_debug_level, NULL },
1281 { "set_ios", 2, 2, cmd_set_ios, NULL },
1282 { "set_config", 2, 3, cmd_set_config, NULL },
1283 { "set_ram", 2, 2, cmd_set_ram, NULL },
1284 { "set_nvram", 2, 2, cmd_set_nvram, NULL },
1285 { "set_ram_mmap", 2, 2, cmd_set_ram_mmap, NULL },
1286 { "set_sparse_mem", 2, 2, cmd_set_sparse_mem, NULL },
1287 { "set_clock_divisor", 2, 2, cmd_set_clock_divisor, NULL },
1288 { "set_blk_direct_jump", 2, 2, cmd_set_blk_direct_jump, NULL },
1289 { "set_exec_area", 2, 2, cmd_set_exec_area, NULL },
1290 { "set_disk0", 2, 2, cmd_set_disk0, NULL },
1291 { "set_disk1", 2, 2, cmd_set_disk1, NULL },
1292 { "set_conf_reg", 2, 2, cmd_set_conf_reg, NULL },
1293 { "set_idle_pc", 2, 2, cmd_set_idle_pc, NULL },
1294 { "set_idle_pc_online", 3, 3, cmd_set_idle_pc_online, NULL },
1295 { "get_idle_pc_prop", 2, 2, cmd_get_idle_pc_prop, NULL },
1296 { "show_idle_pc_prop", 2, 2, cmd_show_idle_pc_prop, NULL },
1297 { "set_idle_max", 3, 3, cmd_set_idle_max, NULL },
1298 { "set_idle_sleep_time", 3, 3, cmd_set_idle_sleep_time, NULL },
1299 { "show_timer_drift", 2, 2, cmd_show_timer_drift, NULL },
1300 { "set_ghost_file", 2, 2, cmd_set_ghost_file, NULL },
1301 { "set_ghost_status", 2, 2, cmd_set_ghost_status, NULL },
1302 { "set_con_tcp_port", 2, 2, cmd_set_con_tcp_port, NULL },
1303 { "set_aux_tcp_port", 2, 2, cmd_set_aux_tcp_port, NULL },
1304 { "extract_config", 1, 1, cmd_extract_config, NULL },
1305 { "push_config", 2, 3, cmd_push_config, NULL },
1306 { "cpu_info", 2, 2, cmd_show_cpu_info, NULL },
1307 { "cpu_usage", 2, 2, cmd_show_cpu_usage, NULL },
1308 { "suspend", 1, 1, cmd_suspend, NULL },
1309 { "resume", 1, 1, cmd_resume, NULL },
1310 { "send_con_msg", 2, 3, cmd_send_con_msg, NULL },
1311 { "send_aux_msg", 2, 3, cmd_send_aux_msg, NULL },
1312 { "slot_bindings", 1, 1, cmd_slot_bindings, NULL },
1313 { "slot_nio_bindings", 2, 2, cmd_slot_nio_bindings, NULL },
1314 { "slot_add_binding", 4, 4, cmd_slot_add_binding, NULL },
1315 { "slot_remove_binding", 3, 3, cmd_slot_remove_binding, NULL },
1316 { "slot_add_nio_binding", 4, 4, cmd_slot_add_nio_binding, NULL },
1317 { "slot_remove_nio_binding", 3, 3, cmd_slot_remove_nio_binding, NULL },
1318 { "slot_enable_nio", 3, 3, cmd_slot_enable_nio, NULL },
1319 { "slot_disable_nio", 3, 3, cmd_slot_disable_nio, NULL },
1320 { "slot_oir_start", 3, 3, cmd_slot_oir_start, NULL },
1321 { "slot_oir_stop", 3, 3, cmd_slot_oir_stop, NULL },
1322 { "list", 0, 0, cmd_vm_list, NULL },
1323 { "list_con_ports", 0, 0, cmd_vm_list_con_ports, NULL },
1324 { NULL, -1, -1, NULL, NULL },
1325 };
1326
1327 /* Hypervisor VM initialization */
1328 int hypervisor_vm_init(void)
1329 {
1330 hypervisor_module_t *module;
1331
1332 module = hypervisor_register_module("vm",NULL);
1333 assert(module != NULL);
1334
1335 hypervisor_register_cmd_array(module,vm_cmd_array);
1336 return(0);
1337 }