Beispiel #1
0
void do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data)
{
    MigrationState *s = NULL;
    const char *p;
    int detach = qdict_get_int(qdict, "detach");
    const char *uri = qdict_get_str(qdict, "uri");

    if (strstart(uri, "tcp:", &p))
        s = tcp_start_outgoing_migration(p, max_throttle, detach);
#if !defined(WIN32)
    else if (strstart(uri, "exec:", &p))
        s = exec_start_outgoing_migration(p, max_throttle, detach);
    else if (strstart(uri, "unix:", &p))
        s = unix_start_outgoing_migration(p, max_throttle, detach);
    else if (strstart(uri, "fd:", &p))
        s = fd_start_outgoing_migration(mon, p, max_throttle, detach);
#endif
    else
        monitor_printf(mon, "unknown migration protocol: %s\n", uri);

    if (s == NULL)
        monitor_printf(mon, "migration failed\n");
    else {
        if (current_migration)
            current_migration->release(current_migration);

        current_migration = s;
    }
}
Beispiel #2
0
static int cdrom_probe_device(const char *filename)
{
    if (strstart(filename, "/dev/cd", NULL) ||
            strstart(filename, "/dev/acd", NULL))
        return 100;
    return 0;
}
Beispiel #3
0
static int floppy_probe_device(const char *filename)
{
    int fd, ret;
    int prio = 0;
    struct floppy_struct fdparam;
    struct stat st;

    if (strstart(filename, "/dev/fd", NULL) &&
        !strstart(filename, "/dev/fdset/", NULL)) {
        prio = 50;
    }

    fd = qemu_open(filename, O_RDONLY | O_NONBLOCK);
    if (fd < 0) {
        goto out;
    }
    ret = fstat(fd, &st);
    if (ret == -1 || !S_ISBLK(st.st_mode)) {
        goto outc;
    }

    /* Attempt to detect via a floppy specific ioctl */
    ret = ioctl(fd, FDGETPRM, &fdparam);
    if (ret >= 0)
        prio = 100;

outc:
    qemu_close(fd);
out:
    return prio;
}
Beispiel #4
0
static int check_for_evdev(void)
{
    SDL_SysWMinfo info;
    XkbDescPtr desc;
    int has_evdev = 0;
    const char *keycodes;

    SDL_VERSION(&info.version);
    if (!SDL_GetWMInfo(&info))
        return 0;

    desc = XkbGetKeyboard(info.info.x11.display,
                          XkbGBN_AllComponentsMask,
                          XkbUseCoreKbd);
    if (desc == NULL || desc->names == NULL)
        return 0;

    keycodes = XGetAtomName(info.info.x11.display, desc->names->keycodes);
    if (keycodes == NULL)
        fprintf(stderr, "could not lookup keycode name\n");
    else if (strstart(keycodes, "evdev", NULL))
        has_evdev = 1;
    else if (!strstart(keycodes, "xfree86", NULL))
        fprintf(stderr,
                "unknown keycodes `%s', please report to [email protected]\n",
                keycodes);

    XkbFreeClientMap(desc, XkbGBN_AllComponentsMask, True);

    return has_evdev;
}
Beispiel #5
0
MigrationState *migrate_get_current(void)
{
    static MigrationState current_migration = {
        .state = MIG_STATE_NONE,
        .bandwidth_limit = MAX_THROTTLE,
        .xbzrle_cache_size = DEFAULT_MIGRATE_CACHE_SIZE,
        .mbps = -1,
    };

    return &current_migration;
}

void qemu_start_incoming_migration(const char *uri, Error **errp)
{
    const char *p;

    if (strstart(uri, "tcp:", &p))
        tcp_start_incoming_migration(p, errp);
#ifdef CONFIG_RDMA
    else if (strstart(uri, "rdma:", &p))
        rdma_start_incoming_migration(p, errp);
#endif
#if !defined(WIN32)
    else if (strstart(uri, "exec:", &p))
        exec_start_incoming_migration(p, errp);
    else if (strstart(uri, "unix:", &p))
        unix_start_incoming_migration(p, errp);
    else if (strstart(uri, "fd:", &p))
        fd_start_incoming_migration(p, errp);
#endif
    else {
        error_setg(errp, "unknown migration protocol: %s", uri);
    }
}

static void process_incoming_migration_co(void *opaque)
{
    QEMUFile *f = opaque;
    int ret;

    ret = qemu_loadvm_state(f);
    qemu_fclose(f);
    free_xbzrle_decoded_buf();
    if (ret < 0) {
        fprintf(stderr, "load of migration failed\n");
        exit(EXIT_FAILURE);
    }
    qemu_announce_self();
    DPRINTF("successfully loaded vm state\n");

    bdrv_clear_incoming_migration_all();
    /* Make sure all file formats flush their mutable metadata */
    bdrv_invalidate_cache_all();

    if (autostart) {
        vm_start();
    } else {
        runstate_set(RUN_STATE_PAUSED);
    }
}
Beispiel #6
0
static int check_for_evdev(void)
{
    SDL_SysWMinfo info;
    XkbDescPtr desc = NULL;
    int has_evdev = 0;
    char *keycodes = NULL;

    SDL_VERSION(&info.version);
    if (!SDL_GetWMInfo(&info)) {
        return 0;
    }
    desc = XkbGetKeyboard(info.info.x11.display,
                          XkbGBN_AllComponentsMask,
                          XkbUseCoreKbd);
    if (desc && desc->names) {
        keycodes = XGetAtomName(info.info.x11.display, desc->names->keycodes);
        if (keycodes == NULL) {
            fprintf(stderr, "could not lookup keycode name\n");
        } else if (strstart(keycodes, "evdev", NULL)) {
            has_evdev = 1;
        } else if (!strstart(keycodes, "xfree86", NULL)) {
            fprintf(stderr, "unknown keycodes `%s', please report to "
                    "[email protected]\n", keycodes);
        }
    }

    if (desc) {
        XkbFreeKeyboard(desc, XkbGBN_AllComponentsMask, True);
    }
    if (keycodes) {
        XFree(keycodes);
    }
    return has_evdev;
}
Beispiel #7
0
int qemu_start_incoming_migration(const char *uri)
{
    const char *p;
    int ret;

    /* check ft_mode (Kemari protocol) */
    if (strstart(uri, "kemari:", &p)) {
        ft_mode = FT_INIT;
        uri = p;
    }

    if (strstart(uri, "tcp:", &p))
        ret = tcp_start_incoming_migration(p);
#if !defined(WIN32)
    else if (strstart(uri, "exec:", &p))
        ret =  exec_start_incoming_migration(p);
    else if (strstart(uri, "unix:", &p))
        ret = unix_start_incoming_migration(p);
    else if (strstart(uri, "fd:", &p))
        ret = fd_start_incoming_migration(p);
#endif
    else {
        fprintf(stderr, "unknown migration protocol: %s\n", uri);
        ret = -EPROTONOSUPPORT;
    }
    return ret;
}
Beispiel #8
0
void qmp_migrate(const char *uri, bool has_blk, bool blk,
                 bool has_inc, bool inc, bool has_detach, bool detach,
                 Error **errp)
{
    Error *local_err = NULL;
    MigrationState *s = migrate_get_current();
    MigrationParams params;
    const char *p;

    params.blk = has_blk && blk;
    params.shared = has_inc && inc;

    if (s->state == MIG_STATE_ACTIVE || s->state == MIG_STATE_SETUP ||
        s->state == MIG_STATE_CANCELLING) {
        error_set(errp, QERR_MIGRATION_ACTIVE);
        return;
    }

    if (runstate_check(RUN_STATE_INMIGRATE)) {
        error_setg(errp, "Guest is waiting for an incoming migration");
        return;
    }

    if (qemu_savevm_state_blocked(errp)) {
        return;
    }

    if (migration_blockers) {
        *errp = error_copy(migration_blockers->data);
        return;
    }

    s = migrate_init(&params);

    if (strstart(uri, "tcp:", &p)) {
        tcp_start_outgoing_migration(s, p, &local_err);
#ifdef CONFIG_RDMA
    } else if (strstart(uri, "rdma:", &p)) {
        rdma_start_outgoing_migration(s, p, &local_err);
#endif
#if !defined(WIN32)
    } else if (strstart(uri, "exec:", &p)) {
        exec_start_outgoing_migration(s, p, &local_err);
    } else if (strstart(uri, "unix:", &p)) {
        unix_start_outgoing_migration(s, p, &local_err);
    } else if (strstart(uri, "fd:", &p)) {
        fd_start_outgoing_migration(s, p, &local_err);
#endif
    } else {
        error_set(errp, QERR_INVALID_PARAMETER_VALUE, "uri", "a valid migration protocol");
        s->state = MIG_STATE_ERROR;
        return;
    }

    if (local_err) {
        migrate_fd_error(s);
        error_propagate(errp, local_err);
        return;
    }
}
Beispiel #9
0
int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data)
{
    MigrationState *s = NULL;
    const char *p;
    int detach = qdict_get_try_bool(qdict, "detach", 0);
    int blk = qdict_get_try_bool(qdict, "blk", 0);
    int inc = qdict_get_try_bool(qdict, "inc", 0);
    const char *uri = qdict_get_str(qdict, "uri");

    if (current_migration &&
        current_migration->get_status(current_migration) == MIG_STATE_ACTIVE) {
        monitor_printf(mon, "migration already in progress\n");
        return -1;
    }

    if (qemu_savevm_state_blocked(mon)) {
        return -1;
    }

    /* check ft_mode (Kemari protocol) */
    if (strstart(uri, "kemari:", &p)) {
        ft_mode = FT_INIT;
        uri = p;
    }

    if (strstart(uri, "tcp:", &p)) {
        s = tcp_start_outgoing_migration(mon, p, max_throttle, detach,
                                         blk, inc);
#if !defined(WIN32)
    } else if (strstart(uri, "exec:", &p)) {
        s = exec_start_outgoing_migration(mon, p, max_throttle, detach,
                                          blk, inc);
    } else if (strstart(uri, "unix:", &p)) {
        s = unix_start_outgoing_migration(mon, p, max_throttle, detach,
                                          blk, inc);
    } else if (strstart(uri, "fd:", &p)) {
        s = fd_start_outgoing_migration(mon, p, max_throttle, detach, 
                                        blk, inc);
#endif
    } else {
        monitor_printf(mon, "unknown migration protocol: %s\n", uri);
        return -1;
    }

    if (s == NULL) {
        monitor_printf(mon, "migration failed\n");
        return -1;
    }

    if (current_migration) {
        current_migration->release(current_migration);
    }

    current_migration = s;
    notifier_list_notify(&migration_state_notifiers);
    return 0;
}
static int nbd_open(BlockDriverState *bs, const char* filename, int flags)
{
    BDRVNBDState *s = bs->opaque;
    const char *host;
    const char *unixpath;
    int sock;
    off_t size;
    size_t blocksize;
    int ret;

    if ((flags & BDRV_O_CREAT))
        return -EINVAL;

    if (!strstart(filename, "nbd:", &host))
        return -EINVAL;

    if (strstart(host, "unix:", &unixpath)) {

        if (unixpath[0] != '/')
            return -EINVAL;

        sock = unix_socket_outgoing(unixpath);

    } else {
        uint16_t port;
        char *p, *r;
        char hostname[128];

        pstrcpy(hostname, 128, host);

        p = strchr(hostname, ':');
        if (p == NULL)
            return -EINVAL;

        *p = '\0';
        p++;

        port = strtol(p, &r, 0);
        if (r == p)
            return -EINVAL;
        sock = tcp_socket_outgoing(hostname, port);
    }

    if (sock == -1)
        return -errno;

    ret = nbd_receive_negotiate(sock, &size, &blocksize);
    if (ret == -1)
        return -errno;

    s->sock = sock;
    s->size = size;
    s->blocksize = blocksize;

    return 0;
}
Beispiel #11
0
static USBDevice *usb_serial_init(USBBus *bus, const char *filename)
{
    USBDevice *dev;
    CharDriverState *cdrv;
    uint32_t vendorid = 0, productid = 0;
    char label[32];
    static int index;

    while (*filename && *filename != ':') {
        const char *p;
        char *e;
        if (strstart(filename, "vendorid=", &p)) {
            vendorid = strtol(p, &e, 16);
            if (e == p || (*e && *e != ',' && *e != ':')) {
                error_report("bogus vendor ID %s", p);
                return NULL;
            }
            filename = e;
        } else if (strstart(filename, "productid=", &p)) {
            productid = strtol(p, &e, 16);
            if (e == p || (*e && *e != ',' && *e != ':')) {
                error_report("bogus product ID %s", p);
                return NULL;
            }
            filename = e;
        } else {
            error_report("unrecognized serial USB option %s", filename);
            return NULL;
        }
        while(*filename == ',')
            filename++;
    }
    if (!*filename) {
        error_report("character device specification needed");
        return NULL;
    }
    filename++;

    snprintf(label, sizeof(label), "usbserial%d", index++);
    cdrv = qemu_chr_new(label, filename, NULL);
    if (!cdrv)
        return NULL;

    dev = usb_create(bus, "usb-serial");
    if (!dev) {
        return NULL;
    }
    qdev_prop_set_chr(&dev->qdev, "chardev", cdrv);
    if (vendorid)
        qdev_prop_set_uint16(&dev->qdev, "vendorid", vendorid);
    if (productid)
        qdev_prop_set_uint16(&dev->qdev, "productid", productid);
    qdev_init_nofail(&dev->qdev);

    return dev;
}
Beispiel #12
0
bool
insn_is_prefetch(btmod *bt, insn_t const *insn)
{
    char const *opc = opctable_name(bt, insn->opc);
    if (strstart(opc, "prefe", NULL)
            || strstart(opc, "invlpg", NULL)) {
        return true;
    }
    return false;
}
Beispiel #13
0
static inline bool
insn_is_comparison(btmod *bt, insn_t const *insn)
{
    char const *opc = opctable_name(bt, insn->opc);
    if (strstart(opc, "test", NULL)
            || strstart(opc, "cmp", NULL)) {
        return true;
    }
    return false;
}
Beispiel #14
0
static inline bool
insn_is_indirect_branch(btmod *bt, insn_t const *insn)
{
    char const *opc = opctable_name(bt, insn->opc);
    if (strstart(opc, "jmp", NULL)
            || strstart(opc, "call", NULL)
            || strstart(opc, "ret", NULL)) {
        return true;
    }
    return false;
}
Beispiel #15
0
/* dummy redirector format (used directly in av_open_input_file now) */
static int redir_probe(AVProbeData *pd)
{
    const char *p;
    p = pd->buf;
    while (redir_isspace(*p))
        p++;
    if (strstart(p, "http://", NULL) ||
        strstart(p, "rtsp://", NULL))
        return AVPROBE_SCORE_MAX;
    return 0;
}
Beispiel #16
0
int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data)
{
    MigrationState *s = migrate_get_current();
    const char *p;
    int detach = qdict_get_try_bool(qdict, "detach", 0);
    int blk = qdict_get_try_bool(qdict, "blk", 0);
    int inc = qdict_get_try_bool(qdict, "inc", 0);
    const char *uri = qdict_get_str(qdict, "uri");
    int ret;

    if (s->state == MIG_STATE_ACTIVE) {
        monitor_printf(mon, "migration already in progress\n");
        return -1;
    }

    if (qemu_savevm_state_blocked(mon)) {
        return -1;
    }

    if (migration_blockers) {
        Error *err = migration_blockers->data;
        qerror_report_err(err);
        return -1;
    }

    s = migrate_init(mon, detach, blk, inc);

    if (strstart(uri, "tcp:", &p)) {
        ret = tcp_start_outgoing_migration(s, p);
#if !defined(WIN32)
    } else if (strstart(uri, "exec:", &p)) {
        ret = exec_start_outgoing_migration(s, p);
    } else if (strstart(uri, "unix:", &p)) {
        ret = unix_start_outgoing_migration(s, p);
    } else if (strstart(uri, "fd:", &p)) {
        ret = fd_start_outgoing_migration(s, p);
#endif
    } else {
        monitor_printf(mon, "unknown migration protocol: %s\n", uri);
        ret  = -EINVAL;
    }

    if (ret < 0) {
        monitor_printf(mon, "migration failed: %s\n", strerror(-ret));
        return ret;
    }

    if (detach) {
        s->mon = NULL;
    }

    notifier_list_notify(&migration_state_notifiers, s);
    return 0;
}
Beispiel #17
0
void MonitorFontChanges(const unsigned char *text)
{
    int n;

    diagnostics(6, "\nMonitorFont %10s\n", text);
    diagnostics(6, "MonitorFont before depth=%d, family=%d, size=%d, shape=%d, series=%d",
      FontInfoDepth, RtfFontInfo[FontInfoDepth].family,
      RtfFontInfo[FontInfoDepth].size, RtfFontInfo[FontInfoDepth].shape, RtfFontInfo[FontInfoDepth].series);

    if (strstart(text, "\\b0"))
        RtfFontInfo[FontInfoDepth].series = F_SERIES_MEDIUM;

    else if (strstart(text, "\\b ") || strstart(text, "\\b\\"))
        RtfFontInfo[FontInfoDepth].series = F_SERIES_BOLD;

    else if (strstart(text, "\\i0")) {
        int mode=getTexMode();
        if (mode==MODE_MATH || mode==MODE_DISPLAYMATH)
            RtfFontInfo[FontInfoDepth].shape = F_SHAPE_MATH_UPRIGHT;
        else
            RtfFontInfo[FontInfoDepth].shape = F_SHAPE_UPRIGHT;
    }
    else if (strstart(text, "\\i ") || strstart(text, "\\i\\"))
        RtfFontInfo[FontInfoDepth].shape = F_SHAPE_ITALIC;

    else if (strstart(text, "\\scaps0")){
        int mode=getTexMode();
        if (mode==MODE_MATH || mode==MODE_DISPLAYMATH)
            RtfFontInfo[FontInfoDepth].shape = F_SHAPE_MATH_UPRIGHT;
        else
            RtfFontInfo[FontInfoDepth].shape = F_SHAPE_UPRIGHT;
    }

    else if (strstart(text, "\\scaps ") || strstart(text, "\\scaps\\"))
        RtfFontInfo[FontInfoDepth].shape = F_SHAPE_CAPS;

    else if (strstartnum(text, "\\fs", &n))
        RtfFontInfo[FontInfoDepth].size = n;

    else if (strstartnum(text, "\\f", &n))
        RtfFontInfo[FontInfoDepth].family = n;

    else if (strstart(text, "\\plain")) {
        RtfFontInfo[FontInfoDepth].size = RtfFontInfo[0].size;
        RtfFontInfo[FontInfoDepth].family = RtfFontInfo[0].family;
        RtfFontInfo[FontInfoDepth].shape = RtfFontInfo[0].shape;
        RtfFontInfo[FontInfoDepth].series = RtfFontInfo[0].series;
    }

    diagnostics(6, "MonitorFont after depth=%d, family=%d, size=%d, shape=%d, series=%d",
      FontInfoDepth, RtfFontInfo[FontInfoDepth].family,
      RtfFontInfo[FontInfoDepth].size, RtfFontInfo[FontInfoDepth].shape, RtfFontInfo[FontInfoDepth].series);
}
Beispiel #18
0
void qemu_start_incoming_migration(const char *uri)
{
    const char *p;

    if (strstart(uri, "tcp:", &p))
        tcp_start_incoming_migration(p);
#if !defined(WIN32)
    else if (strstart(uri, "exec:", &p))
        exec_start_incoming_migration(p);
#endif
    else
        fprintf(stderr, "unknown migration protocol: %s\n", uri);
}
Beispiel #19
0
bool
insn_has_translation(btmod *bt, insn_t const *insn)
{
    const char *name;
    name = opctable_name(bt, insn->opc);
    if (strstart(name, "outs", NULL)) {
        return false;
    }
    if (strstart(name, "ins", NULL)) {
        return false;
    }
    return true;
}
Beispiel #20
0
void qmp_migrate(const char *uri, bool has_blk, bool blk,
                 bool has_inc, bool inc, bool has_detach, bool detach,
                 Error **errp)
{
    Error *local_err = NULL;
    MigrationState *s = migrate_get_current();
    MigrationParams params;
    const char *p;

    params.blk = blk;
    params.shared = inc;

    if (s->state == MIG_STATE_ACTIVE) {
        error_set(errp, QERR_MIGRATION_ACTIVE);
        return;
    }

    if (qemu_savevm_state_blocked(errp)) {
        return;
    }

    if (migration_blockers) {
        *errp = error_copy(migration_blockers->data);
        return;
    }

    s = migrate_init(&params);

    if (strstart(uri, "tcp:", &p)) {
        tcp_start_outgoing_migration(s, p, &local_err);
#if !defined(WIN32)
    } else if (strstart(uri, "exec:", &p)) {
        exec_start_outgoing_migration(s, p, &local_err);
    } else if (strstart(uri, "unix:", &p)) {
        unix_start_outgoing_migration(s, p, &local_err);
    } else if (strstart(uri, "fd:", &p)) {
        fd_start_outgoing_migration(s, p, &local_err);
#endif
    } else {
        error_set(errp, QERR_INVALID_PARAMETER_VALUE, "uri", "a valid migration protocol");
        return;
    }

    if (local_err) {
        migrate_fd_error(s);
        error_propagate(errp, local_err);
        return;
    }

    notifier_list_notify(&migration_state_notifiers, s);
}
Beispiel #21
0
/**
 * Handles a firm option.
 */
int firm_option(char const *const opt)
{
    char const* val;
    if ((val = strstart(opt, "dump-filter="))) {
        set_dump_filter(val);
        return 1;
    } else if ((val = strstart(opt, "clone-threshold="))) {
        sscanf(val, "%d", &firm_opt.clone_threshold);
        return 1;
    } else if ((val = strstart(opt, "inline-max-size="))) {
        sscanf(val, "%u", &firm_opt.inline_maxsize);
        return 1;
    } else if ((val = strstart(opt, "inline-threshold="))) {
        sscanf(val, "%u", &firm_opt.inline_threshold);
        return 1;
    } else if (streq(opt, "no-opt")) {
        disable_opts();
        return 1;
    }

    size_t const len = strlen(opt);
    for (size_t i = lengthof(firm_options); i != 0;) {
        struct params const* const o = &firm_options[--i];
        if (len == o->opt_len && strncmp(opt, o->option, len) == 0) {
            if (!o->flag) {
                /* help option */
                print_option_help(firm_options[0].option, firm_options[0].description);
                firm_opt_option_help();
                for (size_t k = 1; k != lengthof(firm_options); ++k) {
                    print_option_help(firm_options[k].option, firm_options[k].description);
                }
                return -1;
            }

            /* statistic options do accumulate */
            if (o->flag == &firm_dump.statistic)
                *o->flag = (bool) (*o->flag | o->set);
            else
                *o->flag = o->set;

            return 1;
        }
    }

    /* maybe this enables/disables optimisations */
    if (firm_opt_option(opt))
        return 1;

    return 0;
}
Beispiel #22
0
static int parse_h264_sdp_line(AVStream * stream, void *data,
                               const char *line)
{
    AVCodecContext *codec = stream->codec;
    h264_rtp_extra_data *h264_data = (h264_rtp_extra_data *) data;
    const char *p = line;

    assert(h264_data->cookie == MAGIC_COOKIE);

    if (strstart(p, "framesize:", &p)) {
        char buf1[50];
        char *dst = buf1;

        // remove the protocol identifier..
        while (*p && *p == ' ') p++; // strip spaces.
        while (*p && *p != ' ') p++; // eat protocol identifier
        while (*p && *p == ' ') p++; // strip trailing spaces.
        while (*p && *p != '-' && (buf1 - dst) < sizeof(buf1) - 1) {
            *dst++ = *p++;
        }
        *dst = '\0';

        // a='framesize:96 320-240'
        // set our parameters..
        codec->width = atoi(buf1);
        codec->height = atoi(p + 1); // skip the -
        codec->pix_fmt = PIX_FMT_YUV420P;
    } else if (strstart(p, "fmtp:", &p)) {
        char attr[256];
        char value[4096];

        // remove the protocol identifier..
        while (*p && *p == ' ') p++; // strip spaces.
        while (*p && *p != ' ') p++; // eat protocol identifier
        while (*p && *p == ' ') p++; // strip trailing spaces.

        /* loop on each attribute */
        while (rtsp_next_attr_and_value
               (&p, attr, sizeof(attr), value, sizeof(value))) {
            /* grab the codec extra_data from the config parameter of the fmtp line */
            sdp_parse_fmtp_config_h264(stream, h264_data, attr, value);
        }
    } else if (strstart(p, "cliprect:", &p)) {
        // could use this if we wanted.
    }

    av_set_pts_info(stream, 33, 1, 90000);      // 33 should be right, because the pts is 64 bit? (done elsewhere; this is a one time thing)

    return 0;                   // keep processing it the normal way...
}
Beispiel #23
0
bool
insn_has_direct_dependence(btmod *bt, insn_t const *insn)
{
    char const *opc;
    opc = opctable_name(bt, insn->opc);
    if (insn->op[0].type == op_imm) {
        if (strstart(opc, "call", NULL)) {
            return true;
        }
        if (strstart(opc, "jmp", NULL)) {
            return true;
        }
    }
    return false;
}
Beispiel #24
0
bool
insn_accesses_stack(btmod *bt, insn_t const *insn)
{
    char const *opc = opctable_name(bt, insn->opc);
    if (   strstart(opc, "push", NULL)
            || strstart(opc, "pop", NULL)
            || !strcmp(opc, "call")
            || !strcmp(opc, "ret")
            || !strcmp(opc, "lcall")
            || !strcmp(opc, "lret")
            || !strcmp(opc, "iret")) {
        return true;
    }
    return false;
}
Beispiel #25
0
int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data)
{
    MigrationState *s = NULL;
    const char *p;
    int detach = qdict_get_int(qdict, "detach");
    const char *uri = qdict_get_str(qdict, "uri");

    if (current_migration &&
        current_migration->get_status(current_migration) == MIG_STATE_ACTIVE) {
        monitor_printf(mon, "migration already in progress\n");
        return -1;
    }

    if (strstart(uri, "tcp:", &p)) {
        s = tcp_start_outgoing_migration(mon, p, max_throttle, detach,
                                         (int)qdict_get_int(qdict, "blk"), 
                                         (int)qdict_get_int(qdict, "inc"));
#if !defined(WIN32)
    } else if (strstart(uri, "exec:", &p)) {
        s = exec_start_outgoing_migration(mon, p, max_throttle, detach,
                                          (int)qdict_get_int(qdict, "blk"), 
                                          (int)qdict_get_int(qdict, "inc"));
    } else if (strstart(uri, "unix:", &p)) {
        s = unix_start_outgoing_migration(mon, p, max_throttle, detach,
					  (int)qdict_get_int(qdict, "blk"), 
                                          (int)qdict_get_int(qdict, "inc"));
    } else if (strstart(uri, "fd:", &p)) {
        s = fd_start_outgoing_migration(mon, p, max_throttle, detach, 
                                        (int)qdict_get_int(qdict, "blk"), 
                                        (int)qdict_get_int(qdict, "inc"));
#endif
    } else {
        monitor_printf(mon, "unknown migration protocol: %s\n", uri);
        return -1;
    }

    if (s == NULL) {
        monitor_printf(mon, "migration failed\n");
        return -1;
    }

    if (current_migration) {
        current_migration->release(current_migration);
    }

    current_migration = s;
    return 0;
}
Beispiel #26
0
static int wget_mode_probe(ModeDef *mode, ModeProbeData *p)
{
    if (strstart(p->real_filename, "http:", NULL)
    ||  strstart(p->real_filename, "https:", NULL)
    ||  strstart(p->real_filename, "ftp:", NULL)) {
        if (p->b && p->b->priv_data) {
            /* buffer loaded, re-selecting mode causes buffer reload */
            return 9;
        } else {
            /* buffer not yet loaded */
            return 90;
        }
    }

    return 0;
}
Beispiel #27
0
int
get_opcode_size(btmod *bt, insn_t const *insn)
{
    int i;
    int size = 4;
    const char *name;
    for (i = 0; i < MAX_NUM_OPERANDS; i++) {
        if (insn->op[i].size > 0 && size > insn->op[i].size) {
            size = insn->op[i].size;
        }
    }
    ASSERT(size == 1 || size == 2 || size == 4);
    if (size != 1) {
        int len;
        name = opctable_name(bt, insn->opc);
        len = strlen(name);
        if (name[len - 1] == 'b') {
            if (len < 8 && len > 3) {
                return 1;
            } else if (strstart(name, "orb", NULL)) {
                return 1;
            }
        }
    }
    return size;
}
Beispiel #28
0
/* This function should be better written, so that if we change the register
 * names, this function does not need to be changed. For now, let us go with
 * this simple implementation.
 */
static opertype_t
str_op_get_type(char const *ptr)
{
    opertype_t type = invalid;
    if (ptr[0] == '%') {
        if (ptr[2] == 's' && ptr[3] == '\0') {                         //cons seg
            type = op_seg;
        } else if ((ptr[1] == 'v' || ptr[1] == 't') && ptr[2] == 'r') {//var reg
            type = op_reg;
        } else if (ptr[1] == 'v' && ptr[2] == 's' && ptr[3] == 'e') {  //var seg
            type = op_seg;
        } else {                                                       //cons reg
            type = op_reg;
        }
    } else if (ptr[0] >= '0' && ptr[0] <= '9') {                     //cons imm
        type = op_imm;
    } else if ((ptr[0] == 'C')) {                                    //var imm
        type = op_imm;
    } else if (strstart(ptr, "prefix", NULL)) {
        type = op_prefix;
    } else {
        ERR("Type of string operand '%s' not supported.\n", ptr);
        ASSERT(0);
    }
    return type;
}
Beispiel #29
0
/* Valid blkverify filenames look like blkverify:path/to/raw_image:path/to/image */
static void blkverify_parse_filename(const char *filename, QDict *options,
                                     Error **errp)
{
    const char *c;
    QString *raw_path;


    /* Parse the blkverify: prefix */
    if (!strstart(filename, "blkverify:", &filename)) {
        /* There was no prefix; therefore, all options have to be already
           present in the QDict (except for the filename) */
        qdict_put(options, "x-image", qstring_from_str(filename));
        return;
    }

    /* Parse the raw image filename */
    c = strchr(filename, ':');
    if (c == NULL) {
        error_setg(errp, "blkverify requires raw copy and original image path");
        return;
    }

    /* TODO Implement option pass-through and set raw.filename here */
    raw_path = qstring_from_substr(filename, 0, c - filename - 1);
    qdict_put(options, "x-raw", raw_path);

    /* TODO Allow multi-level nesting and set file.filename here */
    filename = c + 1;
    qdict_put(options, "x-image", qstring_from_str(filename));
}
Beispiel #30
0
bool
writes_operand(btmod *bt, insn_t const *insn, const operand_t *op)
{
    int n;
    for (n = 0; n < 3; n++) {
        if ((unsigned)op == (unsigned)&insn->op[n]) {
            break;
        }
    }
    ASSERT(n < 3);
    if (n == 0) {
        if (insn_is_indirect_branch(bt, insn)) {
            return false;
        }
        if (insn_is_comparison(bt, insn)) {
            return false;
        }
        if (insn_is_nop(bt, insn)) {
            return false;
        }
        return true;
    }
    if (n == 1) {
        char const *opc = opctable_name(bt, insn->opc);
        if (is_xor_to_zero(bt, insn) || strstart(opc, "pop", NULL)) {
            return true;
        }
    }
    return false;
}