43 |
#include "registry.h" |
#include "registry.h" |
44 |
#include "hypervisor.h" |
#include "hypervisor.h" |
45 |
|
|
46 |
|
/* Find the specified CPU */ |
47 |
|
static cpu_mips_t *find_cpu(hypervisor_conn_t *conn,vm_instance_t *vm, |
48 |
|
u_int cpu_id) |
49 |
|
{ |
50 |
|
cpu_mips_t *cpu; |
51 |
|
|
52 |
|
cpu = cpu_group_find_id(vm->cpu_group,cpu_id); |
53 |
|
|
54 |
|
if (!cpu) { |
55 |
|
vm_release(vm); |
56 |
|
hypervisor_send_reply(conn,HSC_ERR_BAD_OBJ,1,"Bad CPU specified"); |
57 |
|
return NULL; |
58 |
|
} |
59 |
|
|
60 |
|
return cpu; |
61 |
|
} |
62 |
|
|
63 |
/* Set debugging level */ |
/* Set debugging level */ |
64 |
static int cmd_set_debug_level(hypervisor_conn_t *conn,int argc,char *argv[]) |
static int cmd_set_debug_level(hypervisor_conn_t *conn,int argc,char *argv[]) |
65 |
{ |
{ |
195 |
return(0); |
return(0); |
196 |
} |
} |
197 |
|
|
198 |
|
/* Set the idle PC value when the CPU is online */ |
199 |
|
static int cmd_set_idle_pc_online(hypervisor_conn_t *conn, |
200 |
|
int argc,char *argv[]) |
201 |
|
{ |
202 |
|
vm_instance_t *vm; |
203 |
|
cpu_mips_t *cpu; |
204 |
|
|
205 |
|
if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM))) |
206 |
|
return(-1); |
207 |
|
|
208 |
|
if (!(cpu = find_cpu(conn,vm,atoi(argv[1])))) |
209 |
|
return(-1); |
210 |
|
|
211 |
|
cpu->idle_pc = strtoull(argv[2],NULL,0); |
212 |
|
|
213 |
|
vm_release(vm); |
214 |
|
hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK"); |
215 |
|
return(0); |
216 |
|
} |
217 |
|
|
218 |
|
/* Get the idle PC proposals */ |
219 |
|
static int cmd_get_idle_pc_prop(hypervisor_conn_t *conn,int argc,char *argv[]) |
220 |
|
{ |
221 |
|
vm_instance_t *vm; |
222 |
|
cpu_mips_t *cpu; |
223 |
|
int i; |
224 |
|
|
225 |
|
if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM))) |
226 |
|
return(-1); |
227 |
|
|
228 |
|
if (!(cpu = find_cpu(conn,vm,atoi(argv[1])))) |
229 |
|
return(-1); |
230 |
|
|
231 |
|
mips64_get_idling_pc(cpu); |
232 |
|
|
233 |
|
for(i=0;i<cpu->idle_pc_prop_count;i++) { |
234 |
|
hypervisor_send_reply(conn,HSC_INFO_MSG,0,"0x%llx [%d]", |
235 |
|
cpu->idle_pc_prop[i].pc, |
236 |
|
cpu->idle_pc_prop[i].count); |
237 |
|
} |
238 |
|
|
239 |
|
vm_release(vm); |
240 |
|
hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK"); |
241 |
|
return(0); |
242 |
|
} |
243 |
|
|
244 |
|
/* Dump the idle PC proposals */ |
245 |
|
static int cmd_show_idle_pc_prop(hypervisor_conn_t *conn,int argc,char *argv[]) |
246 |
|
{ |
247 |
|
vm_instance_t *vm; |
248 |
|
cpu_mips_t *cpu; |
249 |
|
int i; |
250 |
|
|
251 |
|
if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM))) |
252 |
|
return(-1); |
253 |
|
|
254 |
|
if (!(cpu = find_cpu(conn,vm,atoi(argv[1])))) |
255 |
|
return(-1); |
256 |
|
|
257 |
|
for(i=0;i<cpu->idle_pc_prop_count;i++) { |
258 |
|
hypervisor_send_reply(conn,HSC_INFO_MSG,0,"0x%llx [%d]", |
259 |
|
cpu->idle_pc_prop[i].pc, |
260 |
|
cpu->idle_pc_prop[i].count); |
261 |
|
} |
262 |
|
|
263 |
|
vm_release(vm); |
264 |
|
hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK"); |
265 |
|
return(0); |
266 |
|
} |
267 |
|
|
268 |
|
/* Set CPU idle max value */ |
269 |
|
static int cmd_set_idle_max(hypervisor_conn_t *conn,int argc,char *argv[]) |
270 |
|
{ |
271 |
|
vm_instance_t *vm; |
272 |
|
cpu_mips_t *cpu; |
273 |
|
|
274 |
|
if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM))) |
275 |
|
return(-1); |
276 |
|
|
277 |
|
if (!(cpu = find_cpu(conn,vm,atoi(argv[1])))) |
278 |
|
return(-1); |
279 |
|
|
280 |
|
cpu->idle_max = atoi(argv[2]); |
281 |
|
|
282 |
|
vm_release(vm); |
283 |
|
hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK"); |
284 |
|
return(0); |
285 |
|
} |
286 |
|
|
287 |
|
/* Set CPU idle sleep time value */ |
288 |
|
static int cmd_set_idle_sleep_time(hypervisor_conn_t *conn, |
289 |
|
int argc,char *argv[]) |
290 |
|
{ |
291 |
|
vm_instance_t *vm; |
292 |
|
cpu_mips_t *cpu; |
293 |
|
|
294 |
|
if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM))) |
295 |
|
return(-1); |
296 |
|
|
297 |
|
if (!(cpu = find_cpu(conn,vm,atoi(argv[1])))) |
298 |
|
return(-1); |
299 |
|
|
300 |
|
cpu->idle_sleep_time = atoi(argv[2]); |
301 |
|
|
302 |
|
vm_release(vm); |
303 |
|
hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK"); |
304 |
|
return(0); |
305 |
|
} |
306 |
|
|
307 |
|
/* Show info about potential timer drift */ |
308 |
|
static int cmd_show_timer_drift(hypervisor_conn_t *conn, |
309 |
|
int argc,char *argv[]) |
310 |
|
{ |
311 |
|
vm_instance_t *vm; |
312 |
|
cpu_mips_t *cpu; |
313 |
|
|
314 |
|
if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM))) |
315 |
|
return(-1); |
316 |
|
|
317 |
|
if (!(cpu = find_cpu(conn,vm,atoi(argv[1])))) |
318 |
|
return(-1); |
319 |
|
|
320 |
|
hypervisor_send_reply(conn,HSC_INFO_MSG,0,"Timer Drift: %u", |
321 |
|
cpu->timer_drift); |
322 |
|
|
323 |
|
hypervisor_send_reply(conn,HSC_INFO_MSG,0,"Pending Timer IRQ: %u", |
324 |
|
cpu->timer_irq_pending); |
325 |
|
|
326 |
|
vm_release(vm); |
327 |
|
hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK"); |
328 |
|
return(0); |
329 |
|
} |
330 |
|
|
331 |
/* Set the exec area size */ |
/* Set the exec area size */ |
332 |
static int cmd_set_exec_area(hypervisor_conn_t *conn,int argc,char *argv[]) |
static int cmd_set_exec_area(hypervisor_conn_t *conn,int argc,char *argv[]) |
333 |
{ |
{ |
343 |
return(0); |
return(0); |
344 |
} |
} |
345 |
|
|
346 |
|
/* Set ghost RAM file */ |
347 |
|
static int cmd_set_ghost_file(hypervisor_conn_t *conn,int argc,char *argv[]) |
348 |
|
{ |
349 |
|
vm_instance_t *vm; |
350 |
|
|
351 |
|
if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM))) |
352 |
|
return(-1); |
353 |
|
|
354 |
|
vm->ghost_ram_filename = strdup(argv[1]); |
355 |
|
|
356 |
|
vm_release(vm); |
357 |
|
hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK"); |
358 |
|
return(0); |
359 |
|
} |
360 |
|
|
361 |
|
/* Set ghost RAM status */ |
362 |
|
static int cmd_set_ghost_status(hypervisor_conn_t *conn,int argc,char *argv[]) |
363 |
|
{ |
364 |
|
vm_instance_t *vm; |
365 |
|
|
366 |
|
if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM))) |
367 |
|
return(-1); |
368 |
|
|
369 |
|
vm->ghost_status = atoi(argv[1]); |
370 |
|
|
371 |
|
vm_release(vm); |
372 |
|
hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK"); |
373 |
|
return(0); |
374 |
|
} |
375 |
|
|
376 |
|
|
377 |
/* Set PCMCIA ATA disk0 size */ |
/* Set PCMCIA ATA disk0 size */ |
378 |
static int cmd_set_disk0(hypervisor_conn_t *conn,int argc,char *argv[]) |
static int cmd_set_disk0(hypervisor_conn_t *conn,int argc,char *argv[]) |
379 |
{ |
{ |
586 |
return(0); |
return(0); |
587 |
} |
} |
588 |
|
|
589 |
|
/* Send a message on the console */ |
590 |
|
static int cmd_send_con_msg(hypervisor_conn_t *conn,int argc,char *argv[]) |
591 |
|
{ |
592 |
|
vm_instance_t *vm; |
593 |
|
|
594 |
|
if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM))) |
595 |
|
return(-1); |
596 |
|
|
597 |
|
vtty_store_str(vm->vtty_con,argv[1]); |
598 |
|
|
599 |
|
vm_release(vm); |
600 |
|
hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK"); |
601 |
|
return(0); |
602 |
|
} |
603 |
|
|
604 |
|
/* Send a message on the AUX port */ |
605 |
|
static int cmd_send_aux_msg(hypervisor_conn_t *conn,int argc,char *argv[]) |
606 |
|
{ |
607 |
|
vm_instance_t *vm; |
608 |
|
|
609 |
|
if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM))) |
610 |
|
return(-1); |
611 |
|
|
612 |
|
vtty_store_str(vm->vtty_aux,argv[1]); |
613 |
|
|
614 |
|
vm_release(vm); |
615 |
|
hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK"); |
616 |
|
return(0); |
617 |
|
} |
618 |
|
|
619 |
/* Show info about VM object */ |
/* Show info about VM object */ |
620 |
static void cmd_show_vm_list(registry_entry_t *entry,void *opt,int *err) |
static void cmd_show_vm_list(registry_entry_t *entry,void *opt,int *err) |
621 |
{ |
{ |
649 |
{ "set_disk1", 2, 2, cmd_set_disk1, NULL }, |
{ "set_disk1", 2, 2, cmd_set_disk1, NULL }, |
650 |
{ "set_conf_reg", 2, 2, cmd_set_conf_reg, NULL }, |
{ "set_conf_reg", 2, 2, cmd_set_conf_reg, NULL }, |
651 |
{ "set_idle_pc", 2, 2, cmd_set_idle_pc, NULL }, |
{ "set_idle_pc", 2, 2, cmd_set_idle_pc, NULL }, |
652 |
|
{ "set_idle_pc_online", 3, 3, cmd_set_idle_pc_online, NULL }, |
653 |
|
{ "get_idle_pc_prop", 2, 2, cmd_get_idle_pc_prop, NULL }, |
654 |
|
{ "show_idle_pc_prop", 2, 2, cmd_show_idle_pc_prop, NULL }, |
655 |
|
{ "set_idle_max", 3, 3, cmd_set_idle_max, NULL }, |
656 |
|
{ "set_idle_sleep_time", 3, 3, cmd_set_idle_sleep_time, NULL }, |
657 |
|
{ "show_timer_drift", 2, 2, cmd_show_timer_drift, NULL }, |
658 |
|
{ "set_ghost_file", 3, 3, cmd_set_ghost_file, NULL }, |
659 |
|
{ "set_ghost_status", 3, 3, cmd_set_ghost_status, NULL }, |
660 |
{ "set_con_tcp_port", 2, 2, cmd_set_con_tcp_port, NULL }, |
{ "set_con_tcp_port", 2, 2, cmd_set_con_tcp_port, NULL }, |
661 |
{ "set_aux_tcp_port", 2, 2, cmd_set_aux_tcp_port, NULL }, |
{ "set_aux_tcp_port", 2, 2, cmd_set_aux_tcp_port, NULL }, |
662 |
{ "extract_config", 1, 1, cmd_extract_config, NULL }, |
{ "extract_config", 1, 1, cmd_extract_config, NULL }, |
664 |
{ "cpu_info", 2, 2, cmd_show_cpu_info, NULL }, |
{ "cpu_info", 2, 2, cmd_show_cpu_info, NULL }, |
665 |
{ "suspend", 1, 1, cmd_suspend, NULL }, |
{ "suspend", 1, 1, cmd_suspend, NULL }, |
666 |
{ "resume", 1, 1, cmd_resume, NULL }, |
{ "resume", 1, 1, cmd_resume, NULL }, |
667 |
|
{ "send_con_msg", 2, 2, cmd_send_con_msg, NULL }, |
668 |
|
{ "send_aux_msg", 2, 2, cmd_send_aux_msg, NULL }, |
669 |
{ "list", 0, 0, cmd_vm_list, NULL }, |
{ "list", 0, 0, cmd_vm_list, NULL }, |
670 |
{ NULL, -1, -1, NULL, NULL }, |
{ NULL, -1, -1, NULL, NULL }, |
671 |
}; |
}; |