Revision 817b9ed5

b/include/migration/qemu-file.h
77 77
QEMUFile *qemu_fopen(const char *filename, const char *mode);
78 78
QEMUFile *qemu_fdopen(int fd, const char *mode);
79 79
QEMUFile *qemu_fopen_socket(int fd);
80
QEMUFile *qemu_popen(FILE *popen_file, const char *mode);
81 80
QEMUFile *qemu_popen_cmd(const char *command, const char *mode);
82 81
int qemu_get_fd(QEMUFile *f);
83 82
int qemu_fclose(QEMUFile *f);
b/migration-exec.c
59 59

  
60 60
void exec_start_outgoing_migration(MigrationState *s, const char *command, Error **errp)
61 61
{
62
    FILE *f;
63

  
64
    f = popen(command, "w");
62
    QEMUFile *f;
63
    f = qemu_popen_cmd(command, "w");
65 64
    if (f == NULL) {
66 65
        error_setg_errno(errp, errno, "failed to popen the migration target");
67 66
        return;
68 67
    }
69 68

  
70
    s->fd = fileno(f);
69
    s->opaque = f;
70
    s->fd = qemu_get_fd(f);
71 71
    assert(s->fd != -1);
72 72

  
73
    s->opaque = qemu_popen(f, "w");
74

  
75 73
    s->close = exec_close;
76 74
    s->get_error = file_errno;
77 75
    s->write = file_write;
b/savevm.c
275 275
    .close =      stdio_pclose
276 276
};
277 277

  
278
QEMUFile *qemu_popen(FILE *stdio_file, const char *mode)
278
QEMUFile *qemu_popen_cmd(const char *command, const char *mode)
279 279
{
280
    FILE *stdio_file;
280 281
    QEMUFileStdio *s;
281 282

  
282
    if (stdio_file == NULL || mode == NULL || (mode[0] != 'r' && mode[0] != 'w') || mode[1] != 0) {
283
    stdio_file = popen(command, mode);
284
    if (stdio_file == NULL) {
285
        return NULL;
286
    }
287

  
288
    if (mode == NULL || (mode[0] != 'r' && mode[0] != 'w') || mode[1] != 0) {
283 289
        fprintf(stderr, "qemu_popen: Argument validity check failed\n");
284 290
        return NULL;
285 291
    }
......
296 302
    return s->file;
297 303
}
298 304

  
299
QEMUFile *qemu_popen_cmd(const char *command, const char *mode)
300
{
301
    FILE *popen_file;
302

  
303
    popen_file = popen(command, mode);
304
    if(popen_file == NULL) {
305
        return NULL;
306
    }
307

  
308
    return qemu_popen(popen_file, mode);
309
}
310

  
311 305
static const QEMUFileOps stdio_file_read_ops = {
312 306
    .get_fd =     stdio_get_fd,
313 307
    .get_buffer = stdio_get_buffer,

Also available in: Unified diff