Example #1
0
void do_list_dba_task( Monitor* mon, const QDict* qdict ) {

    const dba_context* ctx;

    int i,
        tid = qdict_get_try_int( qdict, "tid", -1 );

    monitor_printf( mon, "%8s%8s%12s%12s%12s\t%s -> %s\n", "TaskID", "State", "Taint(Tag)", "Syscall", "Timer", "HostSample", "GuestSample" );
    monitor_printf( mon, "===================================================================================================\n" );

    // show targeted task
    if( tid != -1 ) {
        ctx = dba_get_task_context( tid );
        if( ctx == NULL )
            return;

        monitor_printf( mon, "%8d%8s%7s(%3d)%12s%12zu\t%s -> %s\n",
                        tid,
                        (ctx->state == DBA_TASK_BUSY)? "BUSY" : (ctx->state == DBA_TASK_DONE)? "DONE" : "IDLE",
                        (ctx->taint.is_enabled)? "TRUE" : "FALSE",
                        (ctx->taint.is_enabled)? ctx->taint.tag : 0 ,
                        (ctx->syscall.is_enabled)? "TRUE" : "FALSE",
                        ctx->sample_timer,
                        ctx->sample_hpath,
                        ctx->sample_gpath );
        return;
    }

    // enumerate
    for( i = 0; i < DBA_MAX_TASKS; ++i ) {
        
        ctx = dba_get_task_context( i );
        if( ctx == NULL )
            continue;

        monitor_printf( mon, "%8d%8s%7s(%3d)%12s%12zu\t%s -> %s\n",
                        i,
                        (ctx->state == DBA_TASK_BUSY)? "BUSY" : (ctx->state == DBA_TASK_DONE)? "DONE" : "IDLE",
                        (ctx->taint.is_enabled)? "TRUE" : "FALSE",
                        (ctx->taint.is_enabled)? ctx->taint.tag : 0 ,
                        (ctx->syscall.is_enabled)? "TRUE" : "FALSE",
                        ctx->sample_timer,
                        ctx->sample_hpath,
                        ctx->sample_gpath );
    }
}
Example #2
0
static PCIDevice *qemu_pci_hot_add_nic(Monitor *mon,
                                       const char *devaddr,
                                       const char *opts_str)
{
    Error *local_err = NULL;
    QemuOpts *opts;
    PCIBus *root = pci_find_primary_bus();
    PCIBus *bus;
    int ret, devfn;

    if (!root) {
        monitor_printf(mon, "no primary PCI bus (if there are multiple"
                       " PCI roots, you must use device_add instead)");
        return NULL;
    }

    bus = pci_get_bus_devfn(&devfn, root, devaddr);
    if (!bus) {
        monitor_printf(mon, "Invalid PCI device address %s\n", devaddr);
        return NULL;
    }
    if (!((BusState*)bus)->allow_hotplug) {
        monitor_printf(mon, "PCI bus doesn't support hotplug\n");
        return NULL;
    }

    opts = qemu_opts_parse(qemu_find_opts("net"), opts_str ? opts_str : "", 0);
    if (!opts) {
        return NULL;
    }

    qemu_opt_set(opts, "type", "nic");

    ret = net_client_init(opts, 0, &local_err);
    if (error_is_set(&local_err)) {
        qerror_report_err(local_err);
        error_free(local_err);
        return NULL;
    }
    if (nd_table[ret].devaddr) {
        monitor_printf(mon, "Parameter addr not supported\n");
        return NULL;
    }
    return pci_nic_init(&nd_table[ret], root, "rtl8139", devaddr);
}
Example #3
0
void hmp_info_status(Monitor *mon, const QDict *qdict)
{
    StatusInfo *info;

    info = qmp_query_status(NULL);

    monitor_printf(mon, "VM status: %s%s",
                   info->running ? "running" : "paused",
                   info->singlestep ? " (single step mode)" : "");

    if (!info->running && info->status != RUN_STATE_PAUSED) {
        monitor_printf(mon, " (%s)", RunState_lookup[info->status]);
    }

    monitor_printf(mon, "\n");

    qapi_free_StatusInfo(info);
}
Example #4
0
void migrate_fd_monitor_suspend(FdMigrationState *s)
{
    s->mon_resume = cur_mon;
    if (monitor_suspend(cur_mon) == 0)
        dprintf("suspending monitor\n");
    else
        monitor_printf(cur_mon, "terminal does not allow synchronous "
                       "migration, continuing detached\n");
}
Example #5
0
void lm32_do_pic_info(Monitor *mon)
{
    if (pic == NULL) {
        return;
    }

    monitor_printf(mon, "lm32-pic: im=%08x ip=%08x irq_state=%08x\n",
            pic->im, pic->ip, pic->irq_state);
}
Example #6
0
static void migrate_fd_monitor_suspend(MigrationState *s, Monitor *mon)
{
    if (monitor_suspend(mon) == 0) {
        DPRINTF("suspending monitor\n");
    } else {
        monitor_printf(mon, "terminal does not allow synchronous "
                       "migration, continuing detached\n");
    }
}
Example #7
0
static void wav_capture_info (void *opaque)
{
    WAVState *wav = opaque;
    char *path = wav->path;

    monitor_printf(cur_mon, "Capturing audio(%d,%d,%d) to %s: %d bytes\n",
                   wav->freq, wav->bits, wav->nchannels,
                   path ? path : "<not available>", wav->bytes);
}
Example #8
0
static void print_balloon_stat(const char *key, QObject *obj, void *opaque)
{
    Monitor *mon = opaque;

    if (strcmp(key, "actual")) {
        monitor_printf(mon, ",%s=%" PRId64, key,
                       qint_get_int(qobject_to_qint(obj)));
    }
}
Example #9
0
void sysbus_dev_print(Monitor *mon, DeviceState *dev, int indent)
{
    SysBusDevice *s = sysbus_from_qdev(dev);
    int i;

    for (i = 0; i < s->num_mmio; i++) {
        monitor_printf(mon, "%*smmio " TARGET_FMT_plx "/" TARGET_FMT_plx "\n",
                       indent, "", s->mmio[i].addr, s->mmio[i].size);
    }
}
Example #10
0
static int pci_read_devaddr(Monitor *mon, const char *addr,
                            int *busp, unsigned *slotp)
{
    int dom;

    /* strip legacy tag */
    if (!strncmp(addr, "pci_addr=", 9)) {
        addr += 9;
    }
    if (pci_parse_devaddr(addr, &dom, busp, slotp, NULL)) {
        monitor_printf(mon, "Invalid pci address\n");
        return -1;
    }
    if (dom != 0) {
        monitor_printf(mon, "Multiple PCI domains not supported, use device_add\n");
        return -1;
    }
    return 0;
}
Example #11
0
static void tracing_proc_start(procmod_Callback_Params * params)
{
  /* If tracingbyname, check if this is the process to trace. 
      If so, start the trace */
  if (procname_is_set()) {
    if (procname_match(params->lmm.name)) {
      uint32_t pid = params->lmm.pid;

      // Start tracing
      do_tracing_internal(pid, tracefile);
      monitor_printf(default_mon, "Tracing %s\n", procname_get());

      // No need to keep monitoring process name
      procname_clear();
    }
  }

  /* If tracing child and first child 
       then trace child instead of parent and enable logging */
  if (tracing_child && trackproc_found_child()) {
    uint32_t curr_pid = trackproc_get_current_pid();
    if ((trackproc_find_pid(curr_pid) != -1) &&
        (curr_pid != trackproc_get_root_pid()))
    {
      uint32_t child_cr3 = find_cr3(curr_pid);

      if (0 == child_cr3) {
        monitor_printf(default_mon, 
                        "CR3 for child process %d not found\n",curr_pid);
      }
      else {
        decaf_plugin->monitored_cr3 = child_cr3;
        tracepid = curr_pid;
        tracecr3 = child_cr3;
        monitor_printf(default_mon, 
                        "Now tracing child process. PID: %d CR3: 0x%08x\n",
                        curr_pid, child_cr3);
        skip_trace_write = 0;
        tracing_child = 0;
      }
    }
  }
}
Example #12
0
void hmp_info_mice(Monitor *mon, const QDict *qdict)
{
    MouseInfoList *mice_list, *mouse;

    mice_list = qmp_query_mice(NULL);
    if (!mice_list) {
        monitor_printf(mon, "No mouse devices connected\n");
        return;
    }

    for (mouse = mice_list; mouse; mouse = mouse->next) {
        monitor_printf(mon, "%c Mouse #%" PRId64 ": %s%s\n",
                       mouse->value->current ? '*' : ' ',
                       mouse->value->index, mouse->value->name,
                       mouse->value->absolute ? " (absolute)" : "");
    }

    qapi_free_MouseInfoList(mice_list);
}
Example #13
0
void hmp_info_name(Monitor *mon, const QDict *qdict)
{
    NameInfo *info;

    info = qmp_query_name(NULL);
    if (info->has_name) {
        monitor_printf(mon, "%s\n", info->name);
    }
    qapi_free_NameInfo(info);
}
Example #14
0
File: monitor.c Project: 8tab/qemu
void hmp_info_tlb(Monitor *mon, const QDict *qdict)
{
    CPUArchState *env1 = mon_get_cpu_env();

    if (!env1) {
        monitor_printf(mon, "No CPU available\n");
        return;
    }
    dump_mmu((FILE*)mon, (fprintf_function)monitor_printf, env1);
}
Example #15
0
void do_delete_dba_task( Monitor* mon, const QDict* qdict ) {
    
    int tid = qdict_get_int( qdict, "tid" );

    if( dba_delete_task(tid) == 0 )
        return;

    monitor_printf( mon, "Fail to delete the DBA task: " );
    switch( dba_errno ) {
        case DBA_ERR_INVALID_TID:
            monitor_printf( mon, "Invalid task ID\n" );
            break;
        case DBA_ERR_INVALID_TSTATE:
            monitor_printf( mon, "Invalid task state, only IDLE/DONE task can be deleted\n" );
            break;
        default:
            monitor_printf( mon, "General failure\n" );
            break;
    }
}
Example #16
0
void icp_pic_print_info(ICPState *icp, Monitor *mon)
{
    int cpu_index = icp->cs ? icp->cs->cpu_index : -1;

    if (!icp->output) {
        return;
    }
    monitor_printf(mon, "CPU %d XIRR=%08x (%p) PP=%02x MFRR=%02x\n",
                   cpu_index, icp->xirr, icp->xirr_owner,
                   icp->pending_priority, icp->mfrr);
}
Example #17
0
void hmp_dump_skeys(Monitor *mon, const QDict *qdict)
{
    const char *filename = qdict_get_str(qdict, "filename");
    Error *err = NULL;

    qmp_dump_skeys(filename, &err);
    if (err) {
        monitor_printf(mon, "%s\n", error_get_pretty(err));
        error_free(err);
    }
}
Example #18
0
void hmp_info_version(Monitor *mon, const QDict *qdict)
{
    VersionInfo *info;

    info = qmp_query_version(NULL);

    monitor_printf(mon, "%" PRId64 ".%" PRId64 ".%" PRId64 "%s\n",
                   info->qemu.major, info->qemu.minor, info->qemu.micro,
                   info->package);

    qapi_free_VersionInfo(info);
}
Example #19
0
// Monitor callback. This gets a string that you can then parse for
// commands. Could do something more complex here, e.g. getopt.
int monitor_callback(Monitor *mon, const char *cmd) {
#ifdef CONFIG_SOFTMMU
    char *cmd_work = g_strdup(cmd);
    char *word;
    word = strtok(cmd_work, " ");
    do {
        if (strncmp("help", word, 4) == 0) {
            monitor_printf(mon,
                "sample plugin help:\n"
                "  sample_foo: do the foo action\n"
            );
        }
        else if (strncmp("sample_foo", word, 10) == 0) {
            printf("Doing the foo action\n");
            monitor_printf(mon, "I did the foo action!\n");
        }
    } while((word = strtok(NULL, " ")) != NULL);
    g_free(cmd_work);
#endif
    return 1;
}
Example #20
0
void do_show_memory_taint_map(struct Monitor *mon, const struct QDict *qdict)
{
    uint64_t target_addr = qdict_get_int(qdict, "addr");
    uint64_t target_length = qdict_get_int(qdict, "len");
    int i;
    uint8_t* buf = (uint8_t*)malloc(target_length); 
    cpu_physical_memory_read(target_addr, buf, target_length);
    if(buf == NULL){
        monitor_printf(mon, "Cannot allocate memory for do_show_memory_taint_map()\n");
        return;
    }

    monitor_printf(mon, "Taint addr %"PRIx64" length %ld\n", target_addr, target_length);

    for(i = 0 ; i < target_length ; i++) {
        monitor_printf( mon, "%02x|%02x, ",
                buf[i], dift_get_memory_dirty(target_addr + i));
        if((i & 0xf) == 0xf)
            monitor_printf(mon, "\n");
    }
}
Example #21
0
void hmp_info_chardev(Monitor *mon, const QDict *qdict)
{
    ChardevInfoList *char_info, *info;

    char_info = qmp_query_chardev(NULL);
    for (info = char_info; info; info = info->next) {
        monitor_printf(mon, "%s: filename=%s\n", info->value->label,
                                                 info->value->filename);
    }

    qapi_free_ChardevInfoList(char_info);
}
Example #22
0
void do_get_physic_address(struct Monitor *mon, const struct QDict *qdict)
{
    uint64_t target_cr3		= qdict_get_int(qdict, "cr3");
    uint64_t target_addr    = qdict_get_int(qdict, "addr");
    X86CPU *cpu				= X86_CPU(ENV_GET_CPU((CPUArchState*)mba_mon_get_cpu()));
    hwaddr page             = target_addr & TARGET_PAGE_MASK;
	
    //XXX([email protected]):Only one phase copied. Should be fully copied to resist changes.
    X86CPU copied_cpu;
    memcpy(&copied_cpu, cpu, sizeof(copied_cpu));
    copied_cpu.env.cr[3] = target_cr3;
    
    hwaddr phys_page = cpu_get_phys_page_debug((CPUState*)&copied_cpu, page);
    if (phys_page == -1) {
        monitor_printf(mon, "Cannot find physic page\n");
		return;
    }

    hwaddr phys_addr = phys_page + (target_addr & ~TARGET_PAGE_MASK);
    monitor_printf(mon, "physic address = %p\n", (void*)phys_addr);
}
Example #23
0
static void sysbus_dev_print(Monitor *mon, DeviceState *dev, int indent)
{
    SysBusDevice *s = SYS_BUS_DEVICE(dev);
    hwaddr size;
    int i;

    for (i = 0; i < s->num_mmio; i++) {
        size = memory_region_size(s->mmio[i].memory);
        monitor_printf(mon, "%*smmio " TARGET_FMT_plx "/" TARGET_FMT_plx "\n",
                       indent, "", s->mmio[i].addr, size);
    }
}
Example #24
0
void ioapic_print_redtbl(Monitor *mon, IOAPICCommonState *s)
{
    static const char *delm_str[] = {
        "fixed", "lowest", "SMI", "...", "NMI", "INIT", "...", "extINT"};
    uint32_t remote_irr = 0;
    int i;

    monitor_printf(mon, "ioapic id=0x%02x sel=0x%02x", s->id, s->ioregsel);
    if (s->ioregsel) {
        monitor_printf(mon, " (redir[%u])\n",
                       (s->ioregsel - IOAPIC_REG_REDTBL_BASE) >> 1);
    } else {
Example #25
0
void hmp_migrationmode(Monitor *mon, const QDict *qdict)
{
    S390StAttribState *sas = s390_get_stattrib_device();
    S390StAttribClass *sac = S390_STATTRIB_GET_CLASS(sas);
    uint64_t what = qdict_get_int(qdict, "mode");
    int r;

    r = sac->set_migrationmode(sas, what);
    if (r < 0) {
        monitor_printf(mon, "Error: %s", strerror(-r));
    }
}
Example #26
0
void do_load_config(Monitor *mon, const QDict *qdict)
{
  int err = 0;
  const char *config_filepath = 
    qdict_get_str(qdict, "configuration_filepath");

  // Parse configuration file
  err = check_ini(config_filepath);
  if (err) {
    monitor_printf (mon, "Could not find INI file: %s\nTry again.\n", 
      config_filepath);
  }
}
Example #27
0
void monitor_print_balloon(Monitor *mon, const QObject *data)
{
    QDict *qdict;

    qdict = qobject_to_qdict(data);
    if (!qdict_haskey(qdict, "actual")) {
        return;
    }
    monitor_printf(mon, "balloon: actual=%" PRId64,
                   qdict_get_int(qdict, "actual") >> 20);
    qdict_iter(qdict, print_balloon_stat, mon);
    monitor_printf(mon, "\n");
}
Example #28
0
void hmp_info_skeys(Monitor *mon, const QDict *qdict)
{
    S390SKeysState *ss = s390_get_skeys_device();
    S390SKeysClass *skeyclass = S390_SKEYS_GET_CLASS(ss);
    uint64_t addr = qdict_get_int(qdict, "addr");
    uint8_t key;
    int r;

    /* Quick check to see if guest is using storage keys*/
    if (!skeyclass->skeys_enabled(ss)) {
        monitor_printf(mon, "Error: This guest is not using storage keys\n");
        return;
    }

    r = skeyclass->get_skeys(ss, addr / TARGET_PAGE_SIZE, 1, &key);
    if (r < 0) {
        monitor_printf(mon, "Error: %s\n", strerror(-r));
        return;
    }

    monitor_printf(mon, "  key: 0x%X\n", key);
}
Example #29
0
static void do_tracing_internal(uint32_t pid, const char *filename)
{
  /* if pid = 0, stop trace */
  if (0 == pid)
    tracing_stop();
  else {
    int retval = tracing_start(pid, filename);
    if (retval < 0)
      monitor_printf(default_mon, "Unable to open log file '%s'\n", filename);
  }

  /* Print configuration variables */
  //print_conf_vars(); 
}
Example #30
0
static void
sh3_load (struct serial *desc, char *file, int hashmark)
{
  if (parallel_in_use)
    {
      monitor_printf ("pl;s\r");
      load_srec (parallel, file, 0, 80, SREC_ALL, hashmark, NULL);
      monitor_expect_prompt (NULL, 0);
    }
  else
    {
      monitor_printf ("il;s:x\r");
      monitor_expect ("\005", NULL, 0);		/* Look for ENQ */
      serial_write (desc, "\006", 1);	/* Send ACK */
      monitor_expect ("LO x\r", NULL, 0);	/* Look for filename */

      load_srec (desc, file, 0, 80, SREC_ALL, hashmark, NULL);

      monitor_expect ("\005", NULL, 0);		/* Look for ENQ */
      serial_write (desc, "\006", 1);	/* Send ACK */
      monitor_expect_prompt (NULL, 0);
    }
}