mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 23:37:42 +00:00
qemu: use lighter-weight fd:n on incoming tunneled migration
Outgoing migration still uses a Unix socket and or exec netcat until the next patch. * src/qemu/qemu_migration.c (qemuMigrationPrepareTunnel): Replace Unix socket with simpler pipe. Suggested by Paolo Bonzini.
This commit is contained in:
parent
e004a8d98e
commit
c7af07ace4
@ -239,11 +239,10 @@ qemuMigrationPrepareTunnel(struct qemud_driver *driver,
|
|||||||
{
|
{
|
||||||
virDomainDefPtr def = NULL;
|
virDomainDefPtr def = NULL;
|
||||||
virDomainObjPtr vm = NULL;
|
virDomainObjPtr vm = NULL;
|
||||||
char *migrateFrom;
|
|
||||||
virDomainEventPtr event = NULL;
|
virDomainEventPtr event = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
int internalret;
|
int internalret;
|
||||||
char *unixfile = NULL;
|
int dataFD[2] = { -1, -1 };
|
||||||
virBitmapPtr qemuCaps = NULL;
|
virBitmapPtr qemuCaps = NULL;
|
||||||
qemuDomainObjPrivatePtr priv = NULL;
|
qemuDomainObjPrivatePtr priv = NULL;
|
||||||
struct timeval now;
|
struct timeval now;
|
||||||
@ -289,12 +288,12 @@ qemuMigrationPrepareTunnel(struct qemud_driver *driver,
|
|||||||
/* Domain starts inactive, even if the domain XML had an id field. */
|
/* Domain starts inactive, even if the domain XML had an id field. */
|
||||||
vm->def->id = -1;
|
vm->def->id = -1;
|
||||||
|
|
||||||
if (virAsprintf(&unixfile, "%s/qemu.tunnelmigrate.dest.%s",
|
if (pipe(dataFD) < 0 ||
|
||||||
driver->libDir, vm->def->name) < 0) {
|
virSetCloseExec(dataFD[0]) < 0) {
|
||||||
virReportOOMError();
|
virReportSystemError(errno, "%s",
|
||||||
|
_("cannot create pipe for tunnelled migration"));
|
||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
}
|
||||||
unlink(unixfile);
|
|
||||||
|
|
||||||
/* check that this qemu version supports the interactive exec */
|
/* check that this qemu version supports the interactive exec */
|
||||||
if (qemuCapsExtractVersionInfo(vm->def->emulator, vm->def->os.arch,
|
if (qemuCapsExtractVersionInfo(vm->def->emulator, vm->def->os.arch,
|
||||||
@ -304,25 +303,11 @@ qemuMigrationPrepareTunnel(struct qemud_driver *driver,
|
|||||||
vm->def->emulator);
|
vm->def->emulator);
|
||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
}
|
||||||
if (qemuCapsGet(qemuCaps, QEMU_CAPS_MIGRATE_QEMU_UNIX))
|
|
||||||
internalret = virAsprintf(&migrateFrom, "unix:%s", unixfile);
|
|
||||||
else if (qemuCapsGet(qemuCaps, QEMU_CAPS_MIGRATE_QEMU_EXEC))
|
|
||||||
internalret = virAsprintf(&migrateFrom, "exec:nc -U -l %s", unixfile);
|
|
||||||
else {
|
|
||||||
qemuReportError(VIR_ERR_OPERATION_FAILED,
|
|
||||||
"%s", _("Destination qemu is too old to support tunnelled migration"));
|
|
||||||
goto endjob;
|
|
||||||
}
|
|
||||||
if (internalret < 0) {
|
|
||||||
virReportOOMError();
|
|
||||||
goto endjob;
|
|
||||||
}
|
|
||||||
/* Start the QEMU daemon, with the same command-line arguments plus
|
/* Start the QEMU daemon, with the same command-line arguments plus
|
||||||
* -incoming unix:/path/to/file or exec:nc -U /path/to/file
|
* -incoming stdin (which qemu_command might convert to exec:cat or fd:n)
|
||||||
*/
|
*/
|
||||||
internalret = qemuProcessStart(dconn, driver, vm, migrateFrom, true,
|
internalret = qemuProcessStart(dconn, driver, vm, "stdin", true, dataFD[1],
|
||||||
-1, NULL, VIR_VM_OP_MIGRATE_IN_START);
|
NULL, VIR_VM_OP_MIGRATE_IN_START);
|
||||||
VIR_FREE(migrateFrom);
|
|
||||||
if (internalret < 0) {
|
if (internalret < 0) {
|
||||||
qemuAuditDomainStart(vm, "migrated", false);
|
qemuAuditDomainStart(vm, "migrated", false);
|
||||||
/* Note that we don't set an error here because qemuProcessStart
|
/* Note that we don't set an error here because qemuProcessStart
|
||||||
@ -335,9 +320,7 @@ qemuMigrationPrepareTunnel(struct qemud_driver *driver,
|
|||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virFDStreamConnectUNIX(st,
|
if (virFDStreamOpen(st, dataFD[0]) < 0) {
|
||||||
unixfile,
|
|
||||||
false) < 0) {
|
|
||||||
qemuAuditDomainStart(vm, "migrated", false);
|
qemuAuditDomainStart(vm, "migrated", false);
|
||||||
qemuProcessStop(driver, vm, 0);
|
qemuProcessStop(driver, vm, 0);
|
||||||
if (!vm->persistent) {
|
if (!vm->persistent) {
|
||||||
@ -345,9 +328,8 @@ qemuMigrationPrepareTunnel(struct qemud_driver *driver,
|
|||||||
virDomainRemoveInactive(&driver->domains, vm);
|
virDomainRemoveInactive(&driver->domains, vm);
|
||||||
vm = NULL;
|
vm = NULL;
|
||||||
}
|
}
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno, "%s",
|
||||||
_("cannot open unix socket '%s' for tunnelled migration"),
|
_("cannot pass pipe for tunnelled migration"));
|
||||||
unixfile);
|
|
||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -378,9 +360,8 @@ endjob:
|
|||||||
cleanup:
|
cleanup:
|
||||||
qemuCapsFree(qemuCaps);
|
qemuCapsFree(qemuCaps);
|
||||||
virDomainDefFree(def);
|
virDomainDefFree(def);
|
||||||
if (unixfile)
|
VIR_FORCE_CLOSE(dataFD[0]);
|
||||||
unlink(unixfile);
|
VIR_FORCE_CLOSE(dataFD[1]);
|
||||||
VIR_FREE(unixfile);
|
|
||||||
if (vm)
|
if (vm)
|
||||||
virDomainObjUnlock(vm);
|
virDomainObjUnlock(vm);
|
||||||
if (event)
|
if (event)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user