/[dynamips]/trunk/hypervisor.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/hypervisor.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

upstream/dynamips-0.2.6-RC1/hypervisor.c revision 2 by dpavlin, Sat Oct 6 16:03:58 2007 UTC trunk/hypervisor.c revision 12 by dpavlin, Sat Oct 6 16:45:40 2007 UTC
# Line 1  Line 1 
1  /*  /*
2   * Cisco 7200 (Predator) simulation platform.   * Cisco router simulation platform.
3   * Copyright (c) 2006 Christophe Fillot (cf@utc.fr)   * Copyright (c) 2006 Christophe Fillot (cf@utc.fr)
4   *   *
5   * Hypervisor routines.   * Hypervisor routines.
# Line 32  Line 32 
32  #include "parser.h"  #include "parser.h"
33  #include "net.h"  #include "net.h"
34  #include "registry.h"  #include "registry.h"
35  #include "mips64.h"  #include "cpu.h"
36    #include "vm.h"
37  #include "dynamips.h"  #include "dynamips.h"
38  #include "dev_c7200.h"  #include "dev_c7200.h"
39  #include "dev_c3600.h"  #include "dev_c3600.h"
40    #include "dev_c2691.h"
41    #include "dev_c3725.h"
42    #include "dev_c3745.h"
43    #include "dev_c2600.h"
44    #include "dev_c1700.h"
45  #include "hypervisor.h"  #include "hypervisor.h"
46  #include "net_io.h"  #include "net_io.h"
47  #include "net_io_bridge.h"  #include "net_io_bridge.h"
# Line 131  static int cmd_save_config(hypervisor_co Line 137  static int cmd_save_config(hypervisor_co
137     frsw_save_config_all(fd);     frsw_save_config_all(fd);
138     atmsw_save_config_all(fd);     atmsw_save_config_all(fd);
139     netio_bridge_save_config_all(fd);     netio_bridge_save_config_all(fd);
140     c7200_save_config_all(fd);     vm_save_config_all(fd);
    c3600_save_config_all(fd);  
141    
142     hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");     hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
143     return(0);     return(0);
# Line 234  void *hypervisor_find_object(hypervisor_ Line 239  void *hypervisor_find_object(hypervisor_
239  }  }
240    
241  /* Find a VM in the registry */  /* Find a VM in the registry */
242  void *hypervisor_find_vm(hypervisor_conn_t *conn,char *name,int vm_type)  void *hypervisor_find_vm(hypervisor_conn_t *conn,char *name)
243  {  {
244       vm_platform_t *platform = conn->cur_module->opt;
245     vm_instance_t *vm;     vm_instance_t *vm;
246    
247     if (!(vm = vm_acquire(name))) {     if (!(vm = vm_acquire(name))) {
# Line 244  void *hypervisor_find_vm(hypervisor_conn Line 250  void *hypervisor_find_vm(hypervisor_conn
250        return NULL;        return NULL;
251     }     }
252    
253     if (vm->type != vm_type) {     if (vm->platform != platform) {
254        vm_release(vm);        vm_release(vm);
255        hypervisor_send_reply(conn,HSC_ERR_BAD_OBJ,1,        hypervisor_send_reply(conn,HSC_ERR_BAD_OBJ,1,
256                              "VM '%s' is not a VM type %d",                              "VM '%s' is not a VM type %s",
257                              name,vm_type);                              name,platform->name);
258        return NULL;        return NULL;
259     }     }
260    
# Line 256  void *hypervisor_find_vm(hypervisor_conn Line 262  void *hypervisor_find_vm(hypervisor_conn
262  }  }
263    
264  /* Register a module */  /* Register a module */
265  hypervisor_module_t *hypervisor_register_module(char *name)  hypervisor_module_t *hypervisor_register_module(char *name,void *opt)
266  {  {
267     hypervisor_module_t *m;     hypervisor_module_t *m;
268    
# Line 271  hypervisor_module_t *hypervisor_register Line 277  hypervisor_module_t *hypervisor_register
277     }     }
278    
279     m->name = name;     m->name = name;
280       m->opt  = opt;
281     m->cmd_list = NULL;     m->cmd_list = NULL;
282    
283     m->next = module_list;     m->next = module_list;
# Line 333  static int hypervisor_exec_cmd(hyperviso Line 340  static int hypervisor_exec_cmd(hyperviso
340        return(-1);        return(-1);
341     }     }
342    
343       conn->cur_module = module;
344    
345     return(cmd->handler(conn,argc,argv));     return(cmd->handler(conn,argc,argv));
346  }  }
347    
# Line 408  int hypervisor_init(void) Line 417  int hypervisor_init(void)
417  {  {
418     hypervisor_module_t *module;     hypervisor_module_t *module;
419    
420     module = hypervisor_register_module("hypervisor");     module = hypervisor_register_module("hypervisor",NULL);
421     assert(module != NULL);     assert(module != NULL);
422    
423     hypervisor_register_cmd_array(module,hypervisor_cmd_array);     hypervisor_register_cmd_array(module,hypervisor_cmd_array);
# Line 526  int hypervisor_stopsig(void) Line 535  int hypervisor_stopsig(void)
535  }  }
536    
537  /* Hypervisor TCP server */  /* Hypervisor TCP server */
538  int hypervisor_tcp_server(int tcp_port)  int hypervisor_tcp_server(char *ip_addr,int tcp_port)
539  {  {
540     int fd_array[HYPERVISOR_MAX_FD];     int fd_array[HYPERVISOR_MAX_FD];
541     struct sockaddr_storage remote_addr;     struct sockaddr_storage remote_addr;
# Line 544  int hypervisor_tcp_server(int tcp_port) Line 553  int hypervisor_tcp_server(int tcp_port)
553     hypervisor_ethsw_init();     hypervisor_ethsw_init();
554     hypervisor_vm_init();     hypervisor_vm_init();
555     hypervisor_vm_debug_init();     hypervisor_vm_debug_init();
    hypervisor_c7200_init();  
    hypervisor_c3600_init();  
556    
557     signal(SIGPIPE,sigpipe_handler);     signal(SIGPIPE,sigpipe_handler);
558    
559     if (!tcp_port)     if (!tcp_port)
560        tcp_port = HYPERVISOR_TCP_PORT;        tcp_port = HYPERVISOR_TCP_PORT;
561    
562     fd_count = ip_listen(tcp_port,SOCK_STREAM,HYPERVISOR_MAX_FD,fd_array);     fd_count = ip_listen(ip_addr,tcp_port,SOCK_STREAM,
563                            HYPERVISOR_MAX_FD,fd_array);
564    
565     if (fd_count <= 0) {     if (fd_count <= 0) {
566        fprintf(stderr,"Hypervisor: unable to create TCP sockets.\n");        fprintf(stderr,"Hypervisor: unable to create TCP sockets.\n");
# Line 560  int hypervisor_tcp_server(int tcp_port) Line 568  int hypervisor_tcp_server(int tcp_port)
568     }     }
569    
570     /* Start accepting connections */     /* Start accepting connections */
571     printf("Hypervisor TCP control server started.\n");     printf("Hypervisor TCP control server started (port %d).\n",tcp_port);
572     hypervisor_running = TRUE;     hypervisor_running = TRUE;
573    
574     while(hypervisor_running) {     while(hypervisor_running) {

Legend:
Removed from v.2  
changed lines
  Added in v.12

  ViewVC Help
Powered by ViewVC 1.1.26