本文整理汇总了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;
}
示例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);
}
示例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;
}
示例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*/
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}