/[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.7/hypervisor.c revision 10 by dpavlin, Sat Oct 6 16:29:14 2007 UTC upstream/dynamips-0.2.8-RC1/hypervisor.c revision 11 by dpavlin, Sat Oct 6 16:33:40 2007 UTC
# Line 41  Line 41 
41  #include "dev_c3725.h"  #include "dev_c3725.h"
42  #include "dev_c3745.h"  #include "dev_c3745.h"
43  #include "dev_c2600.h"  #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 136  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);  
    c2691_save_config_all(fd);  
    c3725_save_config_all(fd);  
    c3745_save_config_all(fd);  
    c2600_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 243  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 253  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 265  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 280  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 342  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 417  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 535  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 553  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();  
    hypervisor_c2691_init();  
    hypervisor_c3725_init();  
    hypervisor_c3745_init();  
    hypervisor_c2600_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");

Legend:
Removed from v.10  
changed lines
  Added in v.11

  ViewVC Help
Powered by ViewVC 1.1.26