示例#1
0
文件: vmexit.c 项目: borisnorm/akaros
/* Is this a vmm specific thing?  or generic?
 *
 * what do we do when we want to kill the vm?  what are our other options? */
bool handle_vmexit(struct guest_thread *gth)
{
	struct vm_trapframe *vm_tf = gth_to_vmtf(gth);

	switch (vm_tf->tf_exit_reason) {
	case EXIT_REASON_EPT_VIOLATION:
		return handle_ept_fault(gth);
	case EXIT_REASON_VMCALL:
		return handle_vmcall(gth);
	case EXIT_REASON_IO_INSTRUCTION:
		return handle_io(gth);
	case EXIT_REASON_MSR_WRITE:
	case EXIT_REASON_MSR_READ:
		return handle_msr(gth);
	case EXIT_REASON_APIC_ACCESS:
		return handle_apic_access(gth);
	case EXIT_REASON_HLT:
		return handle_halt(gth);
	case EXIT_REASON_MWAIT_INSTRUCTION:
		return handle_mwait(gth);
	case EXIT_REASON_EXTERNAL_INTERRUPT:
	case EXIT_REASON_APIC_WRITE:
		/* TODO: just ignore these? */
		return TRUE;
	default:
		fprintf(stderr, "Don't know how to handle exit %d\n",
		        vm_tf->tf_exit_reason);
		fprintf(stderr, "RIP %p, shutdown 0x%x\n", vm_tf->tf_rip,
		        vm_tf->tf_exit_reason);
		return FALSE;
	}
}
示例#2
0
文件: nbnet.c 项目: fdslight/netbus
void handle_events(int num)
{
    struct nb_net_ev *net_ev = net_ev_head;
    int r, w, fileno;

    while (NULL != net_ev){
        if (net_ev->is_invalid){
            net_ev = net_ev->next;
            continue;
        }

        r = 0;
        w = 0;
        fileno = net_ev->fileno;

        if (FD_ISSET(fileno, &readfds)) r = 1;
        if (FD_ISSET(fileno, &writefds)) w = 1;

        net_ev->readable = r;
        net_ev->writable = w;

        if (r || w){
            handle_io(net_ev);
        }

        net_ev = net_ev->next;
    }
}
示例#3
0
bool ContextClosest::parseCmdArgs(int argc, char **argv, int skipFirstArgs){
	_argc = argc;
	_argv = argv;
	_skipFirstArgs = skipFirstArgs;
	if (_argc < 2) {
		setShowHelp(true);
		return false;
	}

	setProgram(_programNames[argv[0]]);

	_argsProcessed.resize(_argc - _skipFirstArgs, false);

	for (_i=_skipFirstArgs; _i < argc; _i++) {
		if (isUsed(_i - _skipFirstArgs)) {
			continue;
		}
		if (strcmp(_argv[_i], "-c") == 0) {
			//bypass intersect's use of the -c option, because -c
			//means writeCount for intersect, but means columns for map.
			if (!ContextBase::handle_c()) return false;
		}
        else if (strcmp(_argv[_i], "-d") == 0) {
           if (!handle_d()) return false;
        }
        else if (strcmp(_argv[_i], "-D") == 0) {
        	if (!handle_D()) return false;
        }
        else if (strcmp(_argv[_i], "-io") == 0) {
        	if (!handle_io()) return false;
        }
        else if (strcmp(_argv[_i], "-iu") == 0) {
        	if (!handle_iu()) return false;
        }
        else if (strcmp(_argv[_i], "-id") == 0) {
        	if (!handle_id()) return false;
        }
        else if (strcmp(_argv[_i], "-N") == 0) {
        	if (!handle_N()) return false;
        }
        else if (strcmp(_argv[_i], "-t") == 0) {
        	if (!handle_t()) return false;
        }
        else if (strcmp(_argv[_i], "-mdb") == 0) {
        	if (!handle_mdb()) return false;
        }

	}
	return ContextIntersect::parseCmdArgs(argc, argv, _skipFirstArgs);
}
示例#4
0
/*
 * Moves and existsing cursor - calls canvas_cursor_move in tcl
 *
 * Returns whether we've scrolled the canvas.
 */
int canvas_cursor_move(Tcl_Interp *interp,
		       GapIO *io,
		       int cnum,
		       cursor_t *cursor,
		       CanvasPtr *canvas,
		       win **win_list,
		       int num_wins,
		       int reg_id,
		       int offset,
		       WorldPtr *world,
		       int cursor_show)
{
    int i, apos, ret;
    double cx, cy;
    char cmd[1024];

#ifdef DEBUG
    printf("canvas_cursor_move %d\n", cursor->abspos);
#endif
    ret = 0;
    apos = cursor->abspos;
    if (apos < 1)
	apos = 1;
    if (apos > io_clength(io, cnum) + 1)
	apos = io_clength(io, cnum) + 1;
    for (i = 0; i < num_wins; i++) {
	/* only move cursors in the x direction */
	if (win_list[i]->scroll == 'x' || win_list[i]->scroll == 'b') {

	    WorldToCanvas(canvas, (double)(apos + offset), 0,
			  &cx, &cy);
	    sprintf(cmd, "canvas_cursor_move %d %d %s %d %d %f",
		    *handle_io(io), cnum, win_list[i]->window,
		    cursor->id, reg_id, cx);

	    if (TCL_ERROR == Tcl_Eval(interp, cmd)) {
		printf("canvas_cursor_move: %s\n", interp->result);
	    }
	}
    }

    /* Make sure the cursor is still visible */
    if (cursor_show)
	return canvas_cursor_show(interp, io, canvas, win_list, num_wins,
				  world, apos+offset, cursor->sent_by,
				  reg_id);

    return 0;
}
/*
 * plot vertical contigs and deal with diagonal line in dot plot
 */
void
update_contig_comparator(Tcl_Interp *interp,
			 GapIO *io,
			 obj_cs *cs)
{
    int win_wd;
    char cmd[1024];

    Tcl_VarEval(interp, "winfo width ", cs->vert, NULL);
    win_wd = atoi(Tcl_GetStringResult(interp));

    display_contigs(interp, io, cs->vert, cs->line_colour, cs->line_width,
		    cs->tick->line_width, cs->tick->ht, win_wd/2, "vertical");

    scaleSingleCanvas(interp, cs->world, cs->canvas, cs->vert, 'y', "all");

    sprintf(cmd, "DisplayDiagonal %s %s %d", cs->frame, cs->window,
	    *handle_io(io));
    if (TCL_ERROR == Tcl_Eval(interp, cmd))
	printf("update_contig_comparator: %s\n", Tcl_GetStringResult(interp));

}
/*
 * plot horizontal contigs
 */
void
update_contig_selector(Tcl_Interp *interp,
		       GapIO *io,
		       obj_cs *cs)
{
    int win_ht;
    char cmd[1024];

    Tcl_VarEval(interp, "winfo height ", cs->hori, NULL);
    win_ht = atoi(Tcl_GetStringResult(interp));

    display_contigs(interp, io, cs->hori, cs->line_colour, cs->line_width,
		    cs->tick->line_width, cs->tick->ht, win_ht/2, "horizontal");

    cs->world->total->x1 = 1;
    cs->world->total->x2 = CalcTotalContigLen(io);
    cs->world->total->y1 = 1;
    cs->world->total->y2 = CalcTotalContigLen(io);

    if (lengthZoom(cs->zoom) <= 1) {

	memcpy(cs->world->visible, cs->world->total, sizeof(d_box));
	SetCanvasCoords(interp, cs->world->visible->x1, cs->world->visible->y1,
			cs->world->visible->x2,cs->world->visible->y2, cs->canvas);
	/* remove all current zooming info */
	freeZoom(&cs->zoom);

	/* add first zoom */
	pushZoom(&cs->zoom, cs->world->visible);
    }

    display_cs_tags(interp, io, cs);

    scaleSingleCanvas(interp, cs->world, cs->canvas, cs->hori, 'x', "all");

    /* rehighlight selected contigs */
    sprintf(cmd, "ReHighlightContigSelection %d %s", *handle_io(io), cs->hori);
    Tcl_Eval(interp, cmd);
}
示例#7
0
/*
 * Deletes an existing cursor - calls canvas_cursor_delete in tcl
 */
void canvas_cursor_delete(Tcl_Interp *interp, GapIO *io, cursor_t *cursor,
			  CanvasPtr *canvas, win **win_list, int num_wins)
{
    int i;
    char cmd[1024];

#ifdef DEBUG
    printf("canvas_cursor_delete\n");
#endif
    for (i = 0; i < num_wins; i++) {
	/* existing cursors will only be in the x direction */
	if (win_list[i]->scroll == 'x' || win_list[i]->scroll == 'b') {

	    sprintf(cmd, "canvas_cursor_delete %d %s %d",
		    *handle_io(io), win_list[i]->window, cursor->id);

	    if (TCL_ERROR == Tcl_Eval(interp, cmd)) {
		printf("canvas_cursor_delete: %s\n", interp->result);
	    }

	}
    }
}
void
cs_callback(GapIO *io, int contig, void *fdata, reg_data *jdata) {
    char cmd[1024];
    obj_cs *cs = (obj_cs *)fdata;

    switch(jdata->job) {
    case REG_BUFFER_START:
	{
#ifdef DEBUG
	    printf("REG_BUFFER_START count %d \n", cs->buffer_count);
#endif
	    cs->buffer_count++;
	    cs->do_update = REG_BUFFER_START;
	    return;
	}
    case REG_BUFFER_END:
	{
#ifdef DEBUG
	    printf("REG_BUFFER_END count %d \n", cs->buffer_count);
#endif
	    cs->buffer_count--;
	    if (cs->buffer_count <= 0) {
		cs->buffer_count = 0;
		if (cs->do_update & REG_LENGTH) {

		} else if (cs->do_update & REG_ANNO) {
		    Tcl_VarEval(GetInterp(), cs->hori, " delete tag", NULL);
		    display_cs_tags(GetInterp(), io, cs);
		    scaleSingleCanvas(GetInterp(), cs->world, cs->canvas,
				      cs->hori, 'x', "tag");
		} else if (cs->do_update & REG_ORDER) {
		    update_contig_selector(GetInterp(), io, cs);
		    if (cs->vert[0] != '\0') {
			update_contig_comparator(GetInterp(), io, cs);
		    }
		}
		cs->do_update = 0;
	    }
	    return;
	}
    case REG_QUERY_NAME:
	{
	    sprintf(jdata->name.line, "Contig selector");
	    return;
	}

    case REG_GET_OPS:
	{
	    /* jdata->get_ops.ops = "Information\0Configure\0"; */
	    return;
	}
    case REG_ANNO:
	{
#ifdef DEBUG
	    printf("contig selector REG_ANNO\n");
#endif
	    if (!cs->do_update) {
		Tcl_VarEval(GetInterp(), cs->hori, " delete tag", NULL);
		display_cs_tags(GetInterp(), io, cs);
		scaleSingleCanvas(GetInterp(), cs->world, cs->canvas,
				  cs->hori, 'x', "tag");
	    } else {
		cs->do_update |= REG_ANNO;
	    }
	    return;
	}
    case REG_ORDER:
	{

#ifdef DEBUG
	    printf("contig selector REG_ORDER %d\n", cs->buffer_count);
#endif
	    if (!cs->do_update) {

		update_contig_selector(GetInterp(), io, cs);
		if (cs->vert[0] != '\0') {
		    update_contig_comparator(GetInterp(), io, cs);
		}
	    } else {
		cs->do_update |= REG_ORDER;
	    }
	    break;
	}
    case REG_QUIT:
	{
	    cs_shutdown(io, cs);
	    return;
	}

    case REG_GENERIC:
	switch(jdata->generic.task) {

	case TASK_WINDOW_ADD:
	    {
		win *winfo = (win *)jdata->generic.data;

		addWindow(cs->win_list, &cs->num_wins, winfo->window,
			  winfo->scroll, winfo->id);
		break;
	    }
	case TASK_WINDOW_DELETE:
	    {
		char *window = (char *)jdata->generic.data;

		deleteWindow(cs->win_list, &cs->num_wins, window);
		break;
	    }
	case TASK_CANVAS_SCROLLX:
	    {
		char *scroll = (char *)jdata->generic.data;

		canvasScrollX(GetInterp(), cs->window, cs->win_list,
			      cs->num_wins, cs->world->visible, cs->canvas,
			      scroll);
		break;
	    }
	case TASK_CANVAS_SCROLLY:
	    {
		char *scroll = (char *)jdata->generic.data;

		canvasScrollY(GetInterp(), cs->window, cs->win_list,
			      cs->num_wins, cs->world->visible, cs->canvas,
			      scroll);

		break;
	    }
	case TASK_CANVAS_RESIZE:
	    {
		char scroll_args[20];
		/* resize template display window */
		resizeCanvas(GetInterp(), cs->window, cs->win_list,
			     cs->num_wins, cs->world->visible,
			     cs->world->total, cs->canvas);
		sprintf(scroll_args, "scroll 0 units");
		canvasScrollX(GetInterp(), cs->window, cs->win_list,
			      cs->num_wins, cs->world->visible, cs->canvas,
			      scroll_args);

		break;
	    }
	case TASK_CANVAS_ZOOMBACK:
	    {

		if (lengthZoom(cs->zoom) <= 2) {
		    freeZoom(&cs->zoom);
		    pushZoom(&cs->zoom, cs->world->total);
		}

		canvasZoomback(GetInterp(), cs->canvas, cs->window, cs->world,
			       cs->win_list, cs->num_wins, &cs->zoom);

		break;
		}
	case TASK_CANVAS_ZOOM:
	    {
		s_zoom *szoom = (s_zoom *)jdata->generic.data;
		canvasZoom(GetInterp(), cs->canvas, cs->window, cs->world,
			   cs->win_list, cs->num_wins, &cs->zoom, szoom->zoom,
			   szoom->scroll);

		break;
	    }
	case TASK_CANVAS_CURSOR_X:
	    {
		char *label;
		int *cx = (int *)jdata->generic.data;
		double local_pos;
		double wx, wy;

		CanvasToWorld(cs->canvas, *cx, 0, &wx, &wy);

		label = get_default_string(GetInterp(), gap_defs,
					   "CONTIG_SEL.CURSOR1_X");

		canvasCursorX(GetInterp(), cs->canvas, cs->frame, label,
			      cs->cursor.colour, cs->cursor.width, *cx, wx,
			      cs->win_list, cs->num_wins);

		/* fill in local position of cursor in label box */
		local_pos = CSLocalCursor(io, wx);

		label = get_default_string(GetInterp(), gap_defs,
					   "CONTIG_SEL.CURSOR2_X");

		sprintf(cmd, "%s%s configure -text %d\n", cs->frame, label,
			(int)local_pos);
		Tcl_Eval(GetInterp(), cmd);

		break;
	    }
	case TASK_CANVAS_CURSOR_Y:
	    {
		char *label;
		int *cy = (int *)jdata->generic.data;
		double local_pos;
		double wx, wy;
		char cmd[1024];
		double cx1, cy1;

		CanvasToWorld(cs->canvas, 0, *cy, &wx, &wy);
		WorldToCanvas(cs->canvas, wy, 0, &cx1, &cy1);

		label = get_default_string(GetInterp(), gap_defs,
					   "CONTIG_SEL.CURSOR1_Y");

		canvasCursorY(GetInterp(), cs->canvas, cs->frame, label,
			      cs->cursor.colour, cs->cursor.width, *cy, wy,
			      cs->win_list, cs->num_wins);

		sprintf(cmd, "DrawCanvasCursorX1 %s %s %.20f %s %d\n",
			cs->frame, cs->hori, cx1, cs->cursor.colour,
			cs->cursor.width);
		if (TCL_ERROR == Tcl_Eval(GetInterp(), cmd))
		    printf("%s\n", GetInterpResult());

		/* fill in local position of cursor in label box */
		local_pos = CSLocalCursor(io, wy);

		label = get_default_string(GetInterp(), gap_defs,
					   "CONTIG_SEL.CURSOR2_Y");

		sprintf(cmd, "%s%s configure -text %d\n", cs->frame, label,
			(int)local_pos);
		Tcl_Eval(GetInterp(), cmd);

		break;
	    }
	case TASK_CANVAS_CURSOR_DELETE:
	    {
		int i;
		for (i = 0; i < cs->num_wins; i++) {
		    Tcl_VarEval(GetInterp(), cs->win_list[i]->window,
				" delete cursor_x cursor_x1 cursor_y", NULL);
		}
		break;
	    }
	case TASK_CS_REDRAW:
	    {
		/* HACK - never used */
		int i, id = register_id();

		for (i = 1; i <= NumContigs(io); i++) {
		    contig_deregister(io, i, cs_callback, fdata);
		    contig_register(io, i, cs_callback, fdata, id,
				    REG_REQUIRED |
				    REG_DATA_CHANGE |
				    REG_OPS |
				    REG_NUMBER_CHANGE |
				    REG_ANNO |
				    REG_GENERIC |
				    REG_FLAG_INVIS |
				    REG_BUFFER,
				    REG_TYPE_CONTIGSEL);
		}
		break;
	    }
	    break;
	}
	break;
    case REG_JOIN_TO:
    case REG_LENGTH:
    case REG_DELETE:
    case REG_COMPLEMENT:
    case REG_NUMBER_CHANGE:
#ifdef DEBUG
	printf("contig selector REG_REDRAW %d\n", cs->buffer_count);
#endif
	update_contig_selector(GetInterp(), io, cs);
	if (cs->vert[0] != '\0') {
	    update_contig_comparator(GetInterp(), io, cs);
	}
	/* update tcl globals, CurContig, LREG and RREG */
	sprintf(cmd, "ContigParams %d", *handle_io(io));
	Tcl_Eval(GetInterp(), cmd);


#ifdef HACK
	printf("COM %s \n", cs->com);
	if (cs->buffer_count) {
	    cs->do_update = 1;
	} else {
	    Tcl_Eval(cs->interp, cs->com);
	}
#endif
	break;
    }
}
示例#9
0
文件: odexm.c 项目: andreiw/ode4linux
void
run_command(void)
{
  int in_pipe[2];
  int out_pipe[2];
  int pid;
  int child;
  int status;
  char * src;
  char * dst;
  int src_f;
  int dst_f;

    if (debug)
        diag("command started %s ", cmdbuf );
    (void) strcpy(userbuf+sizeof("USER="******"odexm_cp") == 0 ) {
        src = strdup ( *(arglist+1) );
        dst = strdup ( *(arglist+2) );
        unlink ( dst );
        makepath ( dst, NULL, 0, 0 );
        src_f = open ( src, O_RDONLY, 0 );
        dst_f = open ( dst, O_CREAT | O_WRONLY, S_IWUSR );
        status = filecopy ( src_f, dst_f ); 
        close ( src_f );
        close ( dst_f );
        chmod ( dst, S_IRUSR | S_IRGRP | S_IROTH );
        transmit_status2 ();
      } else {
        pipe (in_pipe);
        pipe (out_pipe);
        pid = fork ();
        if ( pid == 0 ) {
          setenv ( "PATH", exec_path, 1 );
          dup2 ( out_pipe[0], 0 );
          close ( out_pipe[0] );
          close ( out_pipe[1] );
          dup2 ( in_pipe[1], 1 );
          close ( in_pipe[0] );
          close ( in_pipe[1] );
          exit_status = runvp(cmdbuf, arglist);
          exit ( exit_status );
        } /* if */
        close ( in_pipe[1] );
        close ( out_pipe[0] );

        handle_io ( in_pipe[0], out_pipe[1] );

        do {
          child = wait ( &status );
        } while ( child != pid && child != -1 );
        if (child == -1) {
          (void) fprintf(stderr, "wait: %s\n", strerror ( errno ) );
          exit_status = -1;
        } else {
          if (WIFSIGNALED(status) || WEXITSTATUS(status) == 0377)
            exit_status = -1;
          else
            exit_status = WEXITSTATUS(status);
          /* if */
        } /* if */
        transmit_status2 ();
        close ( in_pipe[0] );
        close ( out_pipe[1] );
      } /* if */
    } else {
      setenv ( "PATH", exec_path, 1 );
      exit_status = runvp(cmdbuf, arglist);
      (void) close(0);
      (void) close(1);
    } /* if */
    if (debug)
        diag("command finished status %d", exit_status);
}
示例#10
0
int kvm_run(kvm_context_t kvm, int vcpu)
{
	int r;
	int fd = kvm->vcpu_fd[vcpu];
	struct kvm_run *run = kvm->run[vcpu];

	/*if (kvm_abi == 10)
		return kvm_run_abi10(kvm, vcpu);*/

again:
//	if (!kvm->irqchip_in_kernel)
//		run->request_interrupt_window = try_push_interrupts(kvm);
	//r = pre_kvm_run(kvm, vcpu);
	//if (r)
	//    return r;
	r = ioctl(fd, KVM_RUN, 0);
  printf("here\n");
	//post_kvm_run(kvm, vcpu);

	if (r == -1 && errno != EINTR && errno != EAGAIN) {
		r = -errno;
		printf("kvm_run: %m\n");
		return r;
	}
	if (r == -1) {
		r = handle_io_window(kvm);
		goto more;
	}
	if (1) {
		switch (run->exit_reason) {
		case KVM_EXIT_UNKNOWN:
			fprintf(stderr, "unhandled vm exit:  0x%x\n", 
				(unsigned)run->hw.hardware_exit_reason);
			kvm_show_regs(kvm, vcpu);
			abort();
			break;
		case KVM_EXIT_FAIL_ENTRY:
			fprintf(stderr, "kvm_run: failed entry, reason %u\n", 
				(unsigned)run->fail_entry.hardware_entry_failure_reason & 0xffff);
			return -ENOEXEC;
			break;
		case KVM_EXIT_EXCEPTION:
			fprintf(stderr, "exception %d (%x)\n", 
			       run->ex.exception,
			       run->ex.error_code);
			kvm_show_regs(kvm, vcpu);
			kvm_show_code(kvm, vcpu);
			abort();
			break;
		case KVM_EXIT_IO:
			r = handle_io(kvm, run, vcpu);
			break;
		case KVM_EXIT_DEBUG:
			r = handle_debug(kvm, vcpu);
			break;
		case KVM_EXIT_MMIO:
			r = handle_mmio(kvm, run);
			break;
		case KVM_EXIT_HLT:
			r = handle_halt(kvm, vcpu);
			break;
		case KVM_EXIT_IRQ_WINDOW_OPEN:
			break;
		case KVM_EXIT_SHUTDOWN:
			r = handle_shutdown(kvm, vcpu);
			break;
		case KVM_EXIT_SET_TPR:
			break;
		default:
			fprintf(stderr, "unhandled vm exit: 0x%x\n", run->exit_reason);
			kvm_show_regs(kvm, vcpu);
			abort();
			break;
		}
	}
more:
	if (!r)
		goto again;
	return r;
}
示例#11
0
文件: kvmctl.c 项目: AmesianX/winkvm
int __cdecl kvm_run(kvm_context_t kvm, int vcpu)
{
	int r = 0;
	int fd = kvm->vcpu_fd[vcpu];
	struct kvm_run kvm_run;
	int retlen;
	BOOL ret = FALSE;

	kvm_run.emulated = 0;
	kvm_run.mmio_completed = 0;
	kvm_run.vcpu_fd = fd;

again:
	kvm_run.request_interrupt_window = try_push_interrupts(kvm);
	pre_kvm_run(kvm, &kvm_run);

/*	r = ioctl(fd, KVM_RUN, &kvm_run); */
	ret = DeviceIoControl(
		    kvm->hnd,
			KVM_RUN,
			&kvm_run,
			sizeof(kvm_run),
			&kvm_run,
			sizeof(kvm_run),
			&retlen,
			NULL);

	if (retlen != sizeof(kvm_run)) {
		fprintf(stderr, "kvm_run: invalid return value\n");
		return r;
	}

	post_kvm_run(kvm, &kvm_run);
	kvm_run.emulated = 0;
	kvm_run.mmio_completed = 0;

	if (!ret) {
		fprintf(stderr, "kvm_run: failed\n");
		return -1;
	}
	if (kvm_run.ioctl_r == -1 && kvm_run._errno != EINTR) {
		r = -(kvm_run._errno);
		fprintf(stderr, "kvm_run: %d\n", kvm_run._errno);
		return r;
	}
	if (kvm_run.ioctl_r == -1) {
		r = handle_io_window(kvm, &kvm_run);
		goto more;
	}
	/*
	if (kvm_run.ioctl_r == -EINTR) {
		r = handle_io_window(kvm, &kvm_run);
		r = 1;
		goto more;
	}
	*/
	switch (kvm_run.exit_type) {
	case KVM_EXIT_TYPE_FAIL_ENTRY:
		fprintf(stderr, "kvm_run: failed entry, reason %u\n", 
			kvm_run.exit_reason & 0xffff);
		return -ENOEXEC;
		break;
	case KVM_EXIT_TYPE_VM_EXIT:
		switch (kvm_run.exit_reason) {
		case KVM_EXIT_UNKNOWN:
			fprintf(stderr, "unhandled vm exit:  0x%x\n", 
			       kvm_run.hw.hardware_exit_reason);
			kvm_show_regs(kvm, vcpu);
			abort();
			break;
		case KVM_EXIT_EXCEPTION:
			fprintf(stderr, "exception %d (%x)\n", 
			       kvm_run.ex.exception,
			       kvm_run.ex.error_code);
			kvm_show_regs(kvm, vcpu);
			abort();
			break;
		case KVM_EXIT_IO:
			r = handle_io(kvm, &kvm_run, vcpu);
			break;
		case KVM_EXIT_CPUID:
			r = handle_cpuid(kvm, &kvm_run, vcpu);
			break;
		case KVM_EXIT_DEBUG:
			r = handle_debug(kvm, &kvm_run, vcpu);
			break;
		case KVM_EXIT_MMIO:
			r = handle_mmio(kvm, &kvm_run);
			break;
		case KVM_EXIT_HLT:
			r = handle_halt(kvm, &kvm_run, vcpu);
			break;
		case KVM_EXIT_IRQ_WINDOW_OPEN:
			break;
		case KVM_EXIT_SHUTDOWN:
			r = handle_shutdown(kvm, &kvm_run, vcpu);
			break;
		default:
			fprintf(stderr, "unhandled vm exit: 0x%x\n", kvm_run.exit_reason);
			kvm_show_regs(kvm, vcpu);
			abort();
			break;
		}
	}
more:
	if (!r)
		goto again;
	return r;
}
示例#12
0
文件: tagU2.c 项目: svn2github/staden
int write_tag(GapIO *io, tag_id n, tagRecord t)
{
    writtg_(handle_io(io), &n, &t.position, &t.length, &t.comment,
	    &t.type. i, &t.next, &t.sense);
    return 0;
}
示例#13
0
文件: tagU2.c 项目: svn2github/staden
int read_tag(GapIO *io, tag_id n, tagRecord *t)
{
    readtg_(handle_io(io), &n, &t->position, &t->length, &t->comment,
	    &t->type.i, &t->next, &t->sense);
    return 0;
}
示例#14
0
文件: main.c 项目: CrazyXen/XEN_CODE
int main(int argc, char **argv)
{
	const char *sopts = "hVvit:o:";
	struct option lopts[] = {
		{ "help", 0, 0, 'h' },
		{ "version", 0, 0, 'V' },
		{ "verbose", 0, 0, 'v' },
		{ "interactive", 0, 0, 'i' },
		{ "log", 1, 0, 'l' },
		{ "log-dir", 1, 0, 'r' },
		{ "pid-file", 1, 0, 'p' },
		{ "timestamp", 1, 0, 't' },
		{ "overflow-data", 1, 0, 'o'},
		{ 0 },
	};
	bool is_interactive = false;
	int ch;
	int syslog_option = LOG_CONS;
	int syslog_mask = LOG_MASK(LOG_WARNING)|LOG_MASK(LOG_ERR)|LOG_MASK(LOG_CRIT)|\
		          LOG_MASK(LOG_ALERT)|LOG_MASK(LOG_EMERG);
	int opt_ind = 0;
	char *pidfile = NULL;

	while ((ch = getopt_long(argc, argv, sopts, lopts, &opt_ind)) != -1) {
		switch (ch) {
		case 'h':
			usage(argv[0]);
			exit(0);
		case 'V':
			version(argv[0]);
			exit(0);
		case 'v':
#ifndef __sun__
			syslog_option |= LOG_PERROR;
#endif
			syslog_mask |= LOG_MASK(LOG_NOTICE)|LOG_MASK(LOG_INFO)| \
				      LOG_MASK(LOG_DEBUG);
			break;
		case 'i':
			is_interactive = true;
			break;
		case 'l':
		        if (!strcmp(optarg, "all")) {
			      log_hv = 1;
			      log_guest = 1;
			} else if (!strcmp(optarg, "hv")) {
			      log_hv = 1;
			} else if (!strcmp(optarg, "guest")) {
			      log_guest = 1;
			}
			break;
		case 'r':
		        log_dir = strdup(optarg);
			break;
		case 'p':
		        pidfile = strdup(optarg);
			break;
		case 't':
			if (!strcmp(optarg, "all")) {
				log_time_hv = 1;
				log_time_guest = 1;
			} else if (!strcmp(optarg, "hv")) {
				log_time_hv = 1;
			} else if (!strcmp(optarg, "guest")) {
				log_time_guest = 1;
			} else if (!strcmp(optarg, "none")) {
				log_time_guest = 0;
				log_time_hv = 0;
			}
			break;
		case 'o':
			if (!strcmp(optarg, "keep")) {
				discard_overflowed_data = 0;
			} else if (!strcmp(optarg, "discard")) {
				discard_overflowed_data = 1;
			}
			break;
		case '?':
			fprintf(stderr,
				"Try `%s --help' for more information\n",
				argv[0]);
			exit(EINVAL);
		}
	}

	if (!log_dir) {
		log_dir = strdup("/var/log/xen/console");
	}

	if (geteuid() != 0) {
		fprintf(stderr, "%s requires root to run.\n", argv[0]);
		exit(EPERM);
	}

	signal(SIGHUP, handle_hup);

	openlog("xenconsoled", syslog_option, LOG_DAEMON);
	setlogmask(syslog_mask);

	if (!is_interactive) {
		daemonize(pidfile ? pidfile : "/var/run/xenconsoled.pid");
	}

	if (!xen_setup())
		exit(1);

	handle_io();

	closelog();
	free(log_dir);
	free(pidfile);

	return 0;
}