当前位置: 首页>>代码示例>>C++>>正文


C++ qemu_fopen_ops函数代码示例

本文整理汇总了C++中qemu_fopen_ops函数的典型用法代码示例。如果您正苦于以下问题:C++ qemu_fopen_ops函数的具体用法?C++ qemu_fopen_ops怎么用?C++ qemu_fopen_ops使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了qemu_fopen_ops函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: qemu_mallocz

QEMUFile *qemu_fopen(const char *filename, const char *mode)
{
    QEMUFileStdio *s;

    s = qemu_mallocz(sizeof(QEMUFileStdio));

    s->outfile = fopen(filename, mode);
    if (!s->outfile)
        goto fail;

#ifdef CONFIG_STUBDOM
    setvbuf(s->outfile, NULL, _IONBF, 0);
#endif

    if (!strcmp(mode, "wb"))
        return qemu_fopen_ops(s, file_put_buffer, NULL, file_close, NULL);
    else if (!strcmp(mode, "rb"))
        return qemu_fopen_ops(s, NULL, file_get_buffer, file_close, NULL);

fail:
    if (s->outfile)
        fclose(s->outfile);
    qemu_free(s);
    return NULL;
}
开发者ID:OpenXT-Extras,项目名称:ioemu,代码行数:25,代码来源:savevm.c

示例2: qemu_fopen_ops

static QEMUFile *qemu_fopen_bdrv(BlockDriverState *bs, int is_writable)
{
    if (is_writable) {
        return qemu_fopen_ops(bs, &bdrv_write_ops);
    }
    return qemu_fopen_ops(bs, &bdrv_read_ops);
}
开发者ID:bowlofstew,项目名称:qemu,代码行数:7,代码来源:savevm.c

示例3: error_report

QEMUFile *qemu_bufopen(const char *mode, QEMUSizedBuffer *input)
{
    QEMUBuffer *s;

    if (mode == NULL || (mode[0] != 'r' && mode[0] != 'w') ||
        mode[1] != '\0') {
        error_report("qemu_bufopen: Argument validity check failed");
        return NULL;
    }

    s = g_malloc0(sizeof(QEMUBuffer));
    s->qsb = input;

    if (s->qsb == NULL) {
        s->qsb = qsb_create(NULL, 0);
        s->qsb_allocated = true;
    }
    if (!s->qsb) {
        g_free(s);
        error_report("qemu_bufopen: qsb_create failed");
        return NULL;
    }


    if (mode[0] == 'r') {
        s->file = qemu_fopen_ops(s, &buf_read_ops);
    } else {
        s->file = qemu_fopen_ops(s, &buf_write_ops);
    }
    return s->file;
}
开发者ID:AdrianHuang,项目名称:qemu,代码行数:31,代码来源:qemu-file-buf.c

示例4: fprintf

QEMUFile *qemu_popen(FILE *popen_file, const char *mode)
{
    QEMUFilePopen *s;

#ifdef CONFIG_STUBDOM
    errno = ENOSYS;
    return NULL;
#else

    if (popen_file == NULL || mode == NULL || (mode[0] != 'r' && mode[0] != 'w') || mode[1] != 0) {
        fprintf(stderr, "qemu_popen: Argument validity check failed\n");
        return NULL;
    }

    s = qemu_mallocz(sizeof(QEMUFilePopen));

    s->popen_file = popen_file;

    if(mode[0] == 'r') {
        s->file = qemu_fopen_ops(s, NULL, popen_get_buffer, popen_close, NULL);
    } else {
        s->file = qemu_fopen_ops(s, popen_put_buffer, NULL, popen_close, NULL);
    }
    fprintf(stderr, "qemu_popen: returning result of qemu_fopen_ops\n");
    return s->file;

#endif /*!CONFIG_STUBDOM*/
}
开发者ID:OpenXT-Extras,项目名称:ioemu,代码行数:28,代码来源:savevm.c

示例5: fprintf

QEMUFile *qemu_fopen(const char *filename, const char *mode)
{
    QEMUFileStdio *s;

    if (mode == NULL ||
	(mode[0] != 'r' && mode[0] != 'w') ||
	mode[1] != 'b' || mode[2] != 0) {
        fprintf(stderr, "qemu_fopen: Argument validity check failed\n");
        return NULL;
    }

    s = qemu_mallocz(sizeof(QEMUFileStdio));

    s->stdio_file = fopen(filename, mode);
    if (!s->stdio_file)
        goto fail;
    
    if(mode[0] == 'w') {
        s->file = qemu_fopen_ops(s, file_put_buffer, NULL, stdio_fclose, 
				 NULL, NULL, NULL);
    } else {
        s->file = qemu_fopen_ops(s, NULL, file_get_buffer, stdio_fclose, 
			       NULL, NULL, NULL);
    }
    return s->file;
fail:
    qemu_free(s);
    return NULL;
}
开发者ID:yujinyu,项目名称:QEMU_PACER,代码行数:29,代码来源:savevm.c

示例6: g_malloc0

QEMUFile *qemu_fopen(const char *filename, const char *mode)
{
    QEMUFileStdio *s;

    if (qemu_file_mode_is_not_valid(mode)) {
        return NULL;
    }

    s = g_malloc0(sizeof(QEMUFileStdio));

    s->stdio_file = fopen(filename, mode);
    if (!s->stdio_file) {
        goto fail;
    }

    if (mode[0] == 'w') {
        s->file = qemu_fopen_ops(s, &stdio_file_write_ops);
    } else {
        s->file = qemu_fopen_ops(s, &stdio_file_read_ops);
    }
    return s->file;
fail:
    g_free(s);
    return NULL;
}
开发者ID:Acidburn0zzz,项目名称:qemu,代码行数:25,代码来源:qemu-file.c

示例7: fprintf

QEMUFile *qemu_popen_cmd(const char *command, const char *mode)
{
    FILE *stdio_file;
    QEMUFileStdio *s;

    if (mode == NULL || (mode[0] != 'r' && mode[0] != 'w') || mode[1] != 0) {
        fprintf(stderr, "qemu_popen: Argument validity check failed\n");
        return NULL;
    }

    stdio_file = popen(command, mode);
    if (stdio_file == NULL) {
        return NULL;
    }

    s = g_malloc0(sizeof(QEMUFileStdio));

    s->stdio_file = stdio_file;

    if (mode[0] == 'r') {
        s->file = qemu_fopen_ops(s, &stdio_pipe_read_ops);
    } else {
        s->file = qemu_fopen_ops(s, &stdio_pipe_write_ops);
    }
    return s->file;
}
开发者ID:Acidburn0zzz,项目名称:qemu,代码行数:26,代码来源:qemu-file.c

示例8: qemu_fopen_ops

static QEMUFile *qemu_fopen_bdrv(BlockDriverState *bs, int is_writable)
{
    if (is_writable)
        return qemu_fopen_ops(bs, block_put_buffer, NULL, bdrv_fclose, 
			      NULL, NULL, NULL);
    return qemu_fopen_ops(bs, NULL, block_get_buffer, bdrv_fclose, NULL, NULL, NULL);
}
开发者ID:yujinyu,项目名称:QEMU_PACER,代码行数:7,代码来源:savevm.c

示例9: qemu_mallocz

static QEMUFile *qemu_fopen_bdrv(BlockDriverState *bs, int64_t offset, int is_writable)
{
    QEMUFileBdrv *s;

    s = qemu_mallocz(sizeof(QEMUFileBdrv));

    s->bs = bs;
    s->base_offset = offset;

    if (is_writable)
        return qemu_fopen_ops(s, block_put_buffer, NULL, bdrv_fclose, NULL, NULL);

    return qemu_fopen_ops(s, NULL, block_get_buffer, bdrv_fclose, NULL, NULL);
}
开发者ID:hongjiujing,项目名称:Opensource,代码行数:14,代码来源:savevm.c

示例10: qemu_mallocz

QEMUFile *qemu_fopen_ops_buffered(void *opaque,
                                  size_t bytes_per_sec,
                                  BufferedPutFunc *put_buffer,
                                  BufferedPutReadyFunc *put_ready,
                                  BufferedWaitForUnfreezeFunc *wait_for_unfreeze,
                                  BufferedCloseFunc *close)
{
    QEMUFileBuffered *s;

    s = qemu_mallocz(sizeof(*s));

    s->opaque = opaque;
    s->xfer_limit = bytes_per_sec / 10;
    s->put_buffer = put_buffer;
    s->put_ready = put_ready;
    s->wait_for_unfreeze = wait_for_unfreeze;
    s->close = close;

    s->file = qemu_fopen_ops(s, buffered_put_buffer, NULL,
                             buffered_close, buffered_rate_limit,
                             buffered_set_rate_limit,
			     buffered_get_rate_limit);

    s->timer = qemu_new_timer_ms(rt_clock, buffered_rate_tick, s);

    qemu_mod_timer(s->timer, qemu_get_clock_ms(rt_clock) + 100);

    return s->file;
}
开发者ID:16aug,项目名称:nvmeqemu,代码行数:29,代码来源:buffered_file.c

示例11: fprintf

QEMUFile *qemu_popen(FILE *popen_file, const char *mode)
{
    QEMUFilePopen *s;

    if (popen_file == NULL || mode == NULL || (mode[0] != 'r' && mode[0] != 'w') || mode[1] != 0) {
        fprintf(stderr, "qemu_popen: Argument validity check failed\n");
        return NULL;
    }

    s = qemu_mallocz(sizeof(QEMUFilePopen));

    s->popen_file = popen_file;

    if(mode[0] == 'r') {
        s->file = qemu_fopen_ops(s, NULL, popen_get_buffer, popen_close, NULL, NULL);
    } else {
        s->file = qemu_fopen_ops(s, popen_put_buffer, NULL, popen_close, NULL, NULL);
    }
    return s->file;
}
开发者ID:hongjiujing,项目名称:Opensource,代码行数:20,代码来源:savevm.c

示例12: g_malloc0

/*
 * Give a QEMUFile* off the same socket but data in the opposite
 * direction.
 */
static QEMUFile *socket_get_return_path(void *opaque)
{
    QEMUFileSocket *forward = opaque;
    QEMUFileSocket *reverse;

    if (qemu_file_get_error(forward->file)) {
        /* If the forward file is in error, don't try and open a return */
        return NULL;
    }

    reverse = g_malloc0(sizeof(QEMUFileSocket));
    reverse->fd = forward->fd;
    /* I don't think there's a better way to tell which direction 'this' is */
    if (forward->file->ops->get_buffer != NULL) {
        /* being called from the read side, so we need to be able to write */
        return qemu_fopen_ops(reverse, &socket_return_write_ops);
    } else {
        return qemu_fopen_ops(reverse, &socket_return_read_ops);
    }
}
开发者ID:32bitmicro,项目名称:riscv-qemu,代码行数:24,代码来源:qemu-file-unix.c

示例13: fprintf

QEMUFile *qemu_popen(FILE *stdio_file, const char *mode)
{
    QEMUFileStdio *s;

    if (stdio_file == NULL || mode == NULL || (mode[0] != 'r' && mode[0] != 'w') || mode[1] != 0) {
        fprintf(stderr, "qemu_popen: Argument validity check failed\n");
        return NULL;
    }

    s = g_malloc0(sizeof(QEMUFileStdio));

    s->stdio_file = stdio_file;

    if(mode[0] == 'r') {
        s->file = qemu_fopen_ops(s, NULL, stdio_get_buffer, stdio_pclose,
				 NULL, NULL, NULL);
    } else {
        s->file = qemu_fopen_ops(s, stdio_put_buffer, NULL, stdio_pclose,
				 NULL, NULL, NULL);
    }
    return s->file;
}
开发者ID:ecit241,项目名称:qemu-android,代码行数:22,代码来源:savevm.c

示例14: g_malloc0

QEMUFile *qemu_fopen_ops_buffered(MigrationState *migration_state)
{
    QEMUFileBuffered *s;

    s = g_malloc0(sizeof(*s));

    s->migration_state = migration_state;
    s->xfer_limit = migration_state->bandwidth_limit / 10;

    s->file = qemu_fopen_ops(s, &buffered_file_ops);

    s->timer = qemu_new_timer_ms(rt_clock, buffered_rate_tick, s);

    qemu_mod_timer(s->timer, qemu_get_clock_ms(rt_clock) + 100);

    return s->file;
}
开发者ID:npe9,项目名称:qemu-acid,代码行数:17,代码来源:buffered_file.c

示例15: migrate_fd_connect

void migrate_fd_connect(MigrationState *s)
{
    s->state = MIG_STATE_ACTIVE;
    s->bytes_xfer = 0;
    s->buffer = NULL;
    s->buffer_size = 0;
    s->buffer_capacity = 0;

    s->xfer_limit = s->bandwidth_limit / XFER_LIMIT_RATIO;
    s->complete = false;

    s->file = qemu_fopen_ops(s, &buffered_file_ops);

    qemu_thread_create(&s->thread, buffered_file_thread, s,
                       QEMU_THREAD_DETACHED);
    notifier_list_notify(&migration_state_notifiers, s);
}
开发者ID:JehandadKhan,项目名称:dpdk-ovs,代码行数:17,代码来源:migration.c


注:本文中的qemu_fopen_ops函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。