int exec_start_outgoing_migration(MigrationState *s, const char *command) { FILE *f; f = popen(command, "w"); if (f == NULL) { DPRINTF("Unable to popen exec target\n"); goto err_after_popen; } s->fd = fileno(f); if (s->fd == -1) { DPRINTF("Unable to retrieve file descriptor for popen'd handle\n"); goto err_after_open; } socket_set_nonblock(s->fd); s->opaque = qemu_popen(f, "w"); s->close = exec_close; s->get_error = file_errno; s->write = file_write; migrate_fd_connect(s); return 0; err_after_open: pclose(f); err_after_popen: return -1; }
MigrationState *exec_start_outgoing_migration(const char *command, int64_t bandwidth_limit, int async) { FdMigrationState *s; FILE *f; s = qemu_mallocz(sizeof(*s)); if (s == NULL) { dprintf("Unable to allocate FdMigrationState\n"); goto err; } f = popen(command, "w"); if (f == NULL) { dprintf("Unable to popen exec target\n"); goto err_after_alloc; } s->fd = fileno(f); if (s->fd == -1) { dprintf("Unable to retrieve file descriptor for popen'd handle\n"); goto err_after_open; } if (fcntl(s->fd, F_SETFD, O_NONBLOCK) == -1) { dprintf("Unable to set nonblocking mode on file descriptor\n"); goto err_after_open; } s->opaque = qemu_popen(f, "w"); s->close = exec_close; s->get_error = file_errno; s->write = file_write; s->mig_state.cancel = migrate_fd_cancel; s->mig_state.get_status = migrate_fd_get_status; s->mig_state.release = migrate_fd_release; s->state = MIG_STATE_ACTIVE; s->detach = !async; s->bandwidth_limit = bandwidth_limit; if (s->detach == 1) { dprintf("detaching from monitor\n"); monitor_suspend(); s->detach = 2; } migrate_fd_connect(s); return &s->mig_state; err_after_open: pclose(f); err_after_alloc: qemu_free(s); err: return NULL; }
int tlc_exec_start_outgoing_migration(MigrationState *s, const char *command) { FILE *f; //int64_t test_timer_start, // test_timer_stop3, // test_timer_stop2, // test_timer_stop1; //test_timer_start = qemu_get_clock_ms(rt_clock); f = popen(command, "w"); if (f == NULL) { DPRINTF("Unable to popen exec target\n"); goto err_after_popen; } //test_timer_stop1 = qemu_get_clock_ms(rt_clock); //DREG{printf("exec: test_timer1: elasp = %" PRId64 " ms\n", test_timer_stop1 - test_timer_start); //fflush(stdout);} s->fd = fileno(f); if (s->fd == -1) { DPRINTF("Unable to retrieve file descriptor for popen'd handle\n"); goto err_after_open; } if(unlikely(mthread)){ //printf("exec_outgoing: set blocking\n"); fflush(stdout); socket_set_block(s->fd); } else{ printf("exec_outgoing: set NON blocking\n"); fflush(stdout); socket_set_nonblock(s->fd); } s->opaque = qemu_popen(f, "w"); //test_timer_stop2 = qemu_get_clock_ms(rt_clock); //DREG{printf("exec: test_timer2: elasp = %" PRId64 " ms\n", test_timer_stop2 - test_timer_stop1); //fflush(stdout);} s->close = exec_close; s->get_error = file_errno; s->write = file_write; migrate_fd_connect(s); //test_timer_stop3 = qemu_get_clock_ms(rt_clock); //DREG{printf("exec: test_timer3: elasp = %" PRId64 " ms\n", test_timer_stop3 - test_timer_stop2); //fflush(stdout);} return 0; err_after_open: pclose(f); err_after_popen: return -1; }
MigrationState *exec_start_outgoing_migration(Monitor *mon, const char *command, int64_t bandwidth_limit, int detach, int blk, int inc) { FdMigrationState *s; FILE *f; s = qemu_mallocz(sizeof(*s)); f = popen(command, "w"); if (f == NULL) { dprintf("Unable to popen exec target\n"); goto err_after_alloc; } s->fd = fileno(f); if (s->fd == -1) { dprintf("Unable to retrieve file descriptor for popen'd handle\n"); goto err_after_open; } socket_set_nonblock(s->fd); s->opaque = qemu_popen(f, "w"); s->close = exec_close; s->get_error = file_errno; s->write = file_write; s->mig_state.cancel = migrate_fd_cancel; s->mig_state.get_status = migrate_fd_get_status; s->mig_state.release = migrate_fd_release; s->mig_state.blk = blk; s->mig_state.shared = inc; s->state = MIG_STATE_ACTIVE; s->mon = NULL; s->bandwidth_limit = bandwidth_limit; if (!detach) { migrate_fd_monitor_suspend(s, mon); } migrate_fd_connect(s); return &s->mig_state; err_after_open: pclose(f); err_after_alloc: qemu_free(s); return NULL; }
QEMUFile *qemu_popen_cmd(const char *command, const char *mode) { FILE *popen_file; popen_file = popen(command, mode); if(popen_file == NULL) { return NULL; } return qemu_popen(popen_file, mode); }
QEMUFile *qemu_popen_cmd(const char *command, const char *mode) { FILE *popen_file; #ifdef CONFIG_STUBDOM errno = ENOSYS; return NULL; #else popen_file = popen(command, mode); if(popen_file == NULL) { return NULL; } return qemu_popen(popen_file, mode); #endif /*!CONFIG_STUBDOM*/ }