/* Create a router instance */ static vm_instance_t *cli_create_instance(char *name,char *platform_name, int instance_id) { vm_instance_t *vm; vm = vm_create_instance(name,instance_id,platform_name); if (vm == NULL) { fprintf(stderr,"C7200: unable to create instance!\n"); return NULL; } return vm; }
/* Create a VM instance */ static int cmd_create(hypervisor_conn_t *conn,int argc,char *argv[]) { vm_instance_t *vm; if (!(vm = vm_create_instance(argv[0],atoi(argv[1]),argv[2]))) { hypervisor_send_reply(conn,HSC_ERR_CREATE,1, "unable to create VM instance '%s'", argv[0]); return(-1); } vm->vtty_con_type = VTTY_TYPE_NONE; vm->vtty_aux_type = VTTY_TYPE_NONE; vm_release(vm); hypervisor_send_reply(conn,HSC_INFO_OK,1,"VM '%s' created",argv[0]); return(0); }
t_player *vm_read_player(t_app *app, char *filename) { int fd; t_player *rt; rt = malloc(sizeof(t_player)); ft_bzero(rt, sizeof(t_player)); if (!filename) vm_print_error("Error : Wrong player"); fd = open(filename, O_RDONLY); if (fd == -1) vm_print_error_str("Error : can't malloc or open player ", filename); if (read(fd, &rt->header, sizeof(t_header)) != sizeof(t_header)) vm_print_error_str("Error : can't read player ", filename); vm_swap_bytes_4(&rt->header.prog_size); vm_swap_bytes_4(&rt->header.magic); ft_bzero(rt->header.prog_name + PROG_NAME_LENGTH + 1, 3); ft_bzero(rt->header.comment + COMMENT_LENGTH + 1, 3); vm_read_prog(fd, rt, filename); vm_create_instance(app); return (rt); }