41 |
#include "registry.h" |
#include "registry.h" |
42 |
#include "hypervisor.h" |
#include "hypervisor.h" |
43 |
|
|
|
/* Create a C7200 instance */ |
|
|
static int cmd_create(hypervisor_conn_t *conn,int argc,char *argv[]) |
|
|
{ |
|
|
c7200_t *router; |
|
|
|
|
|
if (!(router = c7200_create_instance(argv[0],atoi(argv[1])))) { |
|
|
hypervisor_send_reply(conn,HSC_ERR_CREATE,1, |
|
|
"unable to create C7200 instance '%s'", |
|
|
argv[0]); |
|
|
return(-1); |
|
|
} |
|
|
|
|
|
router->vm->vtty_con_type = VTTY_TYPE_NONE; |
|
|
router->vm->vtty_aux_type = VTTY_TYPE_NONE; |
|
|
|
|
|
vm_release(router->vm); |
|
|
hypervisor_send_reply(conn,HSC_INFO_OK,1,"C7200 '%s' created",argv[0]); |
|
|
return(0); |
|
|
} |
|
|
|
|
|
/* Delete a C7200 instance */ |
|
|
static int cmd_delete(hypervisor_conn_t *conn,int argc,char *argv[]) |
|
|
{ |
|
|
int res; |
|
|
|
|
|
res = c7200_delete_instance(argv[0]); |
|
|
|
|
|
if (res == 1) { |
|
|
hypervisor_send_reply(conn,HSC_INFO_OK,1,"C7200 '%s' deleted",argv[0]); |
|
|
} else { |
|
|
hypervisor_send_reply(conn,HSC_ERR_DELETE,1, |
|
|
"unable to delete C7200 '%s'",argv[0]); |
|
|
} |
|
|
|
|
|
return(res); |
|
|
} |
|
|
|
|
44 |
/* Set the NPE type */ |
/* Set the NPE type */ |
45 |
static int cmd_set_npe(hypervisor_conn_t *conn,int argc,char *argv[]) |
static int cmd_set_npe(hypervisor_conn_t *conn,int argc,char *argv[]) |
46 |
{ |
{ |
47 |
vm_instance_t *vm; |
vm_instance_t *vm; |
48 |
|
|
49 |
if (!(vm = hypervisor_find_vm(conn,argv[0],VM_TYPE_C7200))) |
if (!(vm = hypervisor_find_vm(conn,argv[0]))) |
50 |
return(-1); |
return(-1); |
51 |
|
|
52 |
if ((c7200_npe_set_type(VM_C7200(vm),argv[1])) == -1) { |
if ((c7200_npe_set_type(VM_C7200(vm),argv[1])) == -1) { |
67 |
{ |
{ |
68 |
vm_instance_t *vm; |
vm_instance_t *vm; |
69 |
|
|
70 |
if (!(vm = hypervisor_find_vm(conn,argv[0],VM_TYPE_C7200))) |
if (!(vm = hypervisor_find_vm(conn,argv[0]))) |
71 |
return(-1); |
return(-1); |
72 |
|
|
73 |
if ((c7200_midplane_set_type(VM_C7200(vm),argv[1])) == -1) { |
if ((c7200_midplane_set_type(VM_C7200(vm),argv[1])) == -1) { |
88 |
{ |
{ |
89 |
vm_instance_t *vm; |
vm_instance_t *vm; |
90 |
|
|
91 |
if (!(vm = hypervisor_find_vm(conn,argv[0],VM_TYPE_C7200))) |
if (!(vm = hypervisor_find_vm(conn,argv[0]))) |
92 |
return(-1); |
return(-1); |
93 |
|
|
94 |
if ((c7200_midplane_set_mac_addr(VM_C7200(vm),argv[1])) == -1) { |
if ((c7200_midplane_set_mac_addr(VM_C7200(vm),argv[1])) == -1) { |
104 |
return(0); |
return(0); |
105 |
} |
} |
106 |
|
|
|
/* Start a C7200 instance */ |
|
|
static int cmd_start(hypervisor_conn_t *conn,int argc,char *argv[]) |
|
|
{ |
|
|
vm_instance_t *vm; |
|
|
c7200_t *router; |
|
|
|
|
|
if (!(vm = hypervisor_find_vm(conn,argv[0],VM_TYPE_C7200))) |
|
|
return(-1); |
|
|
|
|
|
router = VM_C7200(vm); |
|
|
|
|
|
if (router->vm->vtty_con_type == VTTY_TYPE_NONE) { |
|
|
hypervisor_send_reply(conn,HSC_INFO_MSG,0, |
|
|
"Warning: no console port defined for " |
|
|
"C7200 '%s'",argv[0]); |
|
|
} |
|
|
|
|
|
if (c7200_init_instance(router) == -1) { |
|
|
vm_release(vm); |
|
|
hypervisor_send_reply(conn,HSC_ERR_START,1, |
|
|
"unable to start instance '%s'", |
|
|
argv[0]); |
|
|
return(-1); |
|
|
} |
|
|
|
|
|
vm_release(vm); |
|
|
hypervisor_send_reply(conn,HSC_INFO_OK,1,"C7200 '%s' started",argv[0]); |
|
|
return(0); |
|
|
} |
|
|
|
|
|
/* Stop a C7200 instance */ |
|
|
static int cmd_stop(hypervisor_conn_t *conn,int argc,char *argv[]) |
|
|
{ |
|
|
vm_instance_t *vm; |
|
|
c7200_t *router; |
|
|
|
|
|
if (!(vm = hypervisor_find_vm(conn,argv[0],VM_TYPE_C7200))) |
|
|
return(-1); |
|
|
|
|
|
router = VM_C7200(vm); |
|
|
|
|
|
if (c7200_stop_instance(router) == -1) { |
|
|
vm_release(vm); |
|
|
hypervisor_send_reply(conn,HSC_ERR_STOP,1, |
|
|
"unable to stop instance '%s'", |
|
|
argv[0]); |
|
|
return(-1); |
|
|
} |
|
|
|
|
|
vm_release(vm); |
|
|
hypervisor_send_reply(conn,HSC_INFO_OK,1,"C7200 '%s' stopped",argv[0]); |
|
|
return(0); |
|
|
} |
|
|
|
|
|
/* Show PA bindings */ |
|
|
static int cmd_pa_bindings(hypervisor_conn_t *conn,int argc,char *argv[]) |
|
|
{ |
|
|
vm_instance_t *vm; |
|
|
c7200_t *router; |
|
|
char *pa_type; |
|
|
int i; |
|
|
|
|
|
if (!(vm = hypervisor_find_vm(conn,argv[0],VM_TYPE_C7200))) |
|
|
return(-1); |
|
|
|
|
|
router = VM_C7200(vm); |
|
|
|
|
|
for(i=0;i<C7200_MAX_PA_BAYS;i++) { |
|
|
pa_type = c7200_pa_get_type(router,i); |
|
|
if (pa_type) |
|
|
hypervisor_send_reply(conn,HSC_INFO_MSG,0,"%u: %s",i,pa_type); |
|
|
} |
|
|
|
|
|
vm_release(vm); |
|
|
hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK"); |
|
|
return(0); |
|
|
} |
|
|
|
|
|
/* Show PA NIO bindings */ |
|
|
static int cmd_pa_nio_bindings(hypervisor_conn_t *conn,int argc,char *argv[]) |
|
|
{ |
|
|
struct c7200_nio_binding *nb; |
|
|
struct c7200_pa_bay *bay; |
|
|
vm_instance_t *vm; |
|
|
c7200_t *router; |
|
|
u_int pa_bay; |
|
|
|
|
|
if (!(vm = hypervisor_find_vm(conn,argv[0],VM_TYPE_C7200))) |
|
|
return(-1); |
|
|
|
|
|
router = VM_C7200(vm); |
|
|
pa_bay = atoi(argv[1]); |
|
|
|
|
|
if (!(bay = c7200_pa_get_info(router,pa_bay))) { |
|
|
vm_release(vm); |
|
|
hypervisor_send_reply(conn,HSC_ERR_UNK_OBJ,1,"Invalid slot %u",pa_bay); |
|
|
return(-1); |
|
|
} |
|
|
|
|
|
for(nb=bay->nio_list;nb;nb=nb->next) |
|
|
hypervisor_send_reply(conn,HSC_INFO_MSG,0,"%u: %s", |
|
|
nb->port_id,nb->nio->name); |
|
|
|
|
|
vm_release(vm); |
|
|
hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK"); |
|
|
return(0); |
|
|
} |
|
|
|
|
|
/* Add a PA binding for the specified slot */ |
|
|
static int cmd_add_pa_binding(hypervisor_conn_t *conn,int argc,char *argv[]) |
|
|
{ |
|
|
vm_instance_t *vm; |
|
|
c7200_t *router; |
|
|
u_int pa_bay; |
|
|
|
|
|
if (!(vm = hypervisor_find_vm(conn,argv[0],VM_TYPE_C7200))) |
|
|
return(-1); |
|
|
|
|
|
router = VM_C7200(vm); |
|
|
pa_bay = atoi(argv[1]); |
|
|
|
|
|
if (c7200_pa_add_binding(router,argv[2],pa_bay) == -1) { |
|
|
vm_release(vm); |
|
|
hypervisor_send_reply(conn,HSC_ERR_BINDING,1, |
|
|
"C7200 %s: unable to add PA binding for slot %u", |
|
|
argv[0],pa_bay); |
|
|
return(-1); |
|
|
} |
|
|
|
|
|
vm_release(vm); |
|
|
hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK"); |
|
|
return(0); |
|
|
} |
|
|
|
|
|
/* Remove a PA binding for the specified slot */ |
|
|
static int cmd_remove_pa_binding(hypervisor_conn_t *conn,int argc,char *argv[]) |
|
|
{ |
|
|
vm_instance_t *vm; |
|
|
c7200_t *router; |
|
|
u_int pa_bay; |
|
|
|
|
|
if (!(vm = hypervisor_find_vm(conn,argv[0],VM_TYPE_C7200))) |
|
|
return(-1); |
|
|
|
|
|
router = VM_C7200(vm); |
|
|
pa_bay = atoi(argv[1]); |
|
|
|
|
|
if (c7200_pa_remove_binding(router,pa_bay) == -1) { |
|
|
vm_release(vm); |
|
|
hypervisor_send_reply(conn,HSC_ERR_BINDING,1, |
|
|
"C7200 %s: unable to remove PA binding for " |
|
|
"slot %u",argv[0],pa_bay); |
|
|
return(-1); |
|
|
} |
|
|
|
|
|
vm_release(vm); |
|
|
hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK"); |
|
|
return(0); |
|
|
} |
|
|
|
|
|
/* Add a NIO binding to the specified slot/port */ |
|
|
static int cmd_add_nio_binding(hypervisor_conn_t *conn,int argc,char *argv[]) |
|
|
{ |
|
|
u_int pa_bay,port_id; |
|
|
vm_instance_t *vm; |
|
|
c7200_t *router; |
|
|
|
|
|
if (!(vm = hypervisor_find_vm(conn,argv[0],VM_TYPE_C7200))) |
|
|
return(-1); |
|
|
|
|
|
router = VM_C7200(vm); |
|
|
|
|
|
pa_bay = atoi(argv[1]); |
|
|
port_id = atoi(argv[2]); |
|
|
|
|
|
if (c7200_pa_add_nio_binding(router,pa_bay,port_id,argv[3]) == -1) { |
|
|
vm_release(vm); |
|
|
hypervisor_send_reply(conn,HSC_ERR_BINDING,1, |
|
|
"C7200 %s: unable to add NIO binding for " |
|
|
"interface %u/%u",argv[0],pa_bay,port_id); |
|
|
return(-1); |
|
|
} |
|
|
|
|
|
vm_release(vm); |
|
|
hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK"); |
|
|
return(0); |
|
|
} |
|
|
|
|
|
/* Remove a NIO binding from the specified slot/port */ |
|
|
static int cmd_remove_nio_binding(hypervisor_conn_t *conn, |
|
|
int argc,char *argv[]) |
|
|
{ |
|
|
u_int pa_bay,port_id; |
|
|
vm_instance_t *vm; |
|
|
c7200_t *router; |
|
|
|
|
|
if (!(vm = hypervisor_find_vm(conn,argv[0],VM_TYPE_C7200))) |
|
|
return(-1); |
|
|
|
|
|
router = VM_C7200(vm); |
|
|
|
|
|
pa_bay = atoi(argv[1]); |
|
|
port_id = atoi(argv[2]); |
|
|
|
|
|
if (c7200_pa_remove_nio_binding(router,pa_bay,port_id) == -1) { |
|
|
vm_release(vm); |
|
|
hypervisor_send_reply(conn,HSC_ERR_BINDING,1, |
|
|
"C7200 %s: unable to remove NIO binding for " |
|
|
"interface %u/%u",argv[0],pa_bay,port_id); |
|
|
return(-1); |
|
|
} |
|
|
|
|
|
vm_release(vm); |
|
|
hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK"); |
|
|
return(0); |
|
|
} |
|
|
|
|
|
/* Enable NIO of the specified slot/port */ |
|
|
static int cmd_pa_enable_nio(hypervisor_conn_t *conn,int argc,char *argv[]) |
|
|
{ |
|
|
u_int pa_bay,port_id; |
|
|
vm_instance_t *vm; |
|
|
c7200_t *router; |
|
|
|
|
|
if (!(vm = hypervisor_find_vm(conn,argv[0],VM_TYPE_C7200))) |
|
|
return(-1); |
|
|
|
|
|
router = VM_C7200(vm); |
|
|
|
|
|
pa_bay = atoi(argv[1]); |
|
|
port_id = atoi(argv[2]); |
|
|
|
|
|
if (c7200_pa_enable_nio(router,pa_bay,port_id) == -1) { |
|
|
vm_release(vm); |
|
|
hypervisor_send_reply(conn,HSC_ERR_BINDING,1, |
|
|
"C7200 %s: unable to enable NIO for " |
|
|
"interface %u/%u",argv[0],pa_bay,port_id); |
|
|
return(-1); |
|
|
} |
|
|
|
|
|
vm_release(vm); |
|
|
hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK"); |
|
|
return(0); |
|
|
} |
|
|
|
|
|
/* Disable NIO of the specified slot/port */ |
|
|
static int cmd_pa_disable_nio(hypervisor_conn_t *conn,int argc,char *argv[]) |
|
|
{ |
|
|
u_int pa_bay,port_id; |
|
|
vm_instance_t *vm; |
|
|
c7200_t *router; |
|
|
|
|
|
if (!(vm = hypervisor_find_vm(conn,argv[0],VM_TYPE_C7200))) |
|
|
return(-1); |
|
|
|
|
|
router = VM_C7200(vm); |
|
|
|
|
|
pa_bay = atoi(argv[1]); |
|
|
port_id = atoi(argv[2]); |
|
|
|
|
|
if (c7200_pa_disable_nio(router,pa_bay,port_id) == -1) { |
|
|
vm_release(vm); |
|
|
hypervisor_send_reply(conn,HSC_ERR_BINDING,1, |
|
|
"C7200 %s: unable to unset NIO for " |
|
|
"interface %u/%u", |
|
|
argv[0],pa_bay,port_id); |
|
|
return(-1); |
|
|
} |
|
|
|
|
|
vm_release(vm); |
|
|
hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK"); |
|
|
return(0); |
|
|
} |
|
|
|
|
107 |
/* Initialize a PA while the router is running */ |
/* Initialize a PA while the router is running */ |
108 |
static int cmd_pa_init_online(hypervisor_conn_t *conn,int argc,char *argv[]) |
static int cmd_pa_init_online(hypervisor_conn_t *conn,int argc,char *argv[]) |
109 |
{ |
{ |
111 |
c7200_t *router; |
c7200_t *router; |
112 |
u_int pa_bay; |
u_int pa_bay; |
113 |
|
|
114 |
if (!(vm = hypervisor_find_vm(conn,argv[0],VM_TYPE_C7200))) |
if (!(vm = hypervisor_find_vm(conn,argv[0]))) |
115 |
return(-1); |
return(-1); |
116 |
|
|
117 |
router = VM_C7200(vm); |
router = VM_C7200(vm); |
131 |
c7200_t *router; |
c7200_t *router; |
132 |
u_int pa_bay; |
u_int pa_bay; |
133 |
|
|
134 |
if (!(vm = hypervisor_find_vm(conn,argv[0],VM_TYPE_C7200))) |
if (!(vm = hypervisor_find_vm(conn,argv[0]))) |
135 |
return(-1); |
return(-1); |
136 |
|
|
137 |
router = VM_C7200(vm); |
router = VM_C7200(vm); |
150 |
vm_instance_t *vm; |
vm_instance_t *vm; |
151 |
c7200_t *router; |
c7200_t *router; |
152 |
|
|
153 |
if (!(vm = hypervisor_find_vm(conn,argv[0],VM_TYPE_C7200))) |
if (!(vm = hypervisor_find_vm(conn,argv[0]))) |
154 |
return(-1); |
return(-1); |
155 |
|
|
156 |
router = VM_C7200(vm); |
router = VM_C7200(vm); |
167 |
hypervisor_conn_t *conn = opt; |
hypervisor_conn_t *conn = opt; |
168 |
vm_instance_t *vm = entry->data; |
vm_instance_t *vm = entry->data; |
169 |
|
|
170 |
if (vm->type == VM_TYPE_C7200) |
if (vm->platform == conn->cur_module->opt) |
171 |
hypervisor_send_reply(conn,HSC_INFO_MSG,0,"%s",entry->name); |
hypervisor_send_reply(conn,HSC_INFO_MSG,0,"%s",entry->name); |
172 |
} |
} |
173 |
|
|
182 |
|
|
183 |
/* C7200 commands */ |
/* C7200 commands */ |
184 |
static hypervisor_cmd_t c7200_cmd_array[] = { |
static hypervisor_cmd_t c7200_cmd_array[] = { |
|
{ "create", 2, 2, cmd_create, NULL }, |
|
|
{ "delete", 1, 1, cmd_delete, NULL }, |
|
185 |
{ "set_npe", 2, 2, cmd_set_npe, NULL }, |
{ "set_npe", 2, 2, cmd_set_npe, NULL }, |
186 |
{ "set_midplane", 2, 2, cmd_set_midplane, NULL }, |
{ "set_midplane", 2, 2, cmd_set_midplane, NULL }, |
187 |
{ "set_mac_addr", 2, 2, cmd_set_mac_addr, NULL }, |
{ "set_mac_addr", 2, 2, cmd_set_mac_addr, NULL }, |
|
{ "start", 1, 1, cmd_start, NULL }, |
|
|
{ "stop", 1, 1, cmd_stop, NULL }, |
|
|
{ "pa_bindings", 1, 1, cmd_pa_bindings, NULL }, |
|
|
{ "pa_nio_bindings", 2, 2, cmd_pa_nio_bindings, NULL }, |
|
|
{ "add_pa_binding", 3, 3, cmd_add_pa_binding, NULL }, |
|
|
{ "remove_pa_binding", 2, 2, cmd_remove_pa_binding, NULL }, |
|
|
{ "add_nio_binding", 4, 4, cmd_add_nio_binding, NULL }, |
|
|
{ "remove_nio_binding", 3, 3, cmd_remove_nio_binding, NULL }, |
|
|
{ "pa_enable_nio", 3, 3, cmd_pa_enable_nio, NULL }, |
|
|
{ "pa_disable_nio", 3, 3, cmd_pa_disable_nio, NULL }, |
|
188 |
{ "pa_init_online", 2, 2, cmd_pa_init_online, NULL }, |
{ "pa_init_online", 2, 2, cmd_pa_init_online, NULL }, |
189 |
{ "pa_stop_online", 2, 2, cmd_pa_stop_online, NULL }, |
{ "pa_stop_online", 2, 2, cmd_pa_stop_online, NULL }, |
190 |
{ "show_hardware", 1, 1, cmd_show_hardware, NULL }, |
{ "show_hardware", 1, 1, cmd_show_hardware, NULL }, |
193 |
}; |
}; |
194 |
|
|
195 |
/* Hypervisor C7200 initialization */ |
/* Hypervisor C7200 initialization */ |
196 |
int hypervisor_c7200_init(void) |
int hypervisor_c7200_init(vm_platform_t *platform) |
197 |
{ |
{ |
198 |
hypervisor_module_t *module; |
hypervisor_module_t *module; |
199 |
|
|
200 |
module = hypervisor_register_module("c7200"); |
module = hypervisor_register_module(platform->name,platform); |
201 |
assert(module != NULL); |
assert(module != NULL); |
202 |
|
|
203 |
hypervisor_register_cmd_array(module,c7200_cmd_array); |
hypervisor_register_cmd_array(module,c7200_cmd_array); |