diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index d50d3675d7afb41e75fadab9655bec3484079b01..674f49386d3dae5b5bcfd327fa256a9a6c766145 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -4012,6 +4012,7 @@ static void qemuMigrationIOFunc(void *arg) if (virStreamFinish(data->st) < 0) goto error; + VIR_FORCE_CLOSE(data->sock); VIR_FREE(buffer); return; @@ -4029,7 +4030,11 @@ static void qemuMigrationIOFunc(void *arg) } error: - virCopyLastError(&data->err); + /* Let the source qemu know that the transfer cant continue anymore. + * Don't copy the error for EPIPE as destination has the actual error. */ + VIR_FORCE_CLOSE(data->sock); + if (!virLastErrorIsSystemErrno(EPIPE)) + virCopyLastError(&data->err); virResetLastError(); VIR_FREE(buffer); } @@ -4352,9 +4357,14 @@ qemuMigrationRun(virQEMUDriverPtr driver, } } - if (spec->fwdType != MIGRATION_FWD_DIRECT && - !(iothread = qemuMigrationStartTunnel(spec->fwd.stream, fd))) - goto cancel; + if (spec->fwdType != MIGRATION_FWD_DIRECT) { + if (!(iothread = qemuMigrationStartTunnel(spec->fwd.stream, fd))) + goto cancel; + /* If we've created a tunnel, then the 'fd' will be closed in the + * qemuMigrationIOFunc as data->sock. + */ + fd = -1; + } rc = qemuMigrationWaitForCompletion(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT,