mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 07:59:00 +00:00
Make QEMU migration use cached qemu capabilities data
* src/qemu/qemu_migration.c, src/qemu/qemu_migration.h: Remove qemuCaps parameters & use cached data * src/qemu/qemu_driver.c: Don't create & pass qemuCaps to migration methods
This commit is contained in:
parent
a623bff450
commit
7c31e1ef0f
@ -1881,7 +1881,6 @@ static int qemudDomainSaveFlag(struct qemud_driver *driver, virDomainPtr dom,
|
|||||||
struct stat sb;
|
struct stat sb;
|
||||||
bool is_reg = false;
|
bool is_reg = false;
|
||||||
unsigned long long offset;
|
unsigned long long offset;
|
||||||
virBitmapPtr qemuCaps = NULL;
|
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
|
|
||||||
memset(&header, 0, sizeof(header));
|
memset(&header, 0, sizeof(header));
|
||||||
@ -1913,11 +1912,6 @@ static int qemudDomainSaveFlag(struct qemud_driver *driver, virDomainPtr dom,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemuCapsExtractVersionInfo(vm->def->emulator, vm->def->os.arch,
|
|
||||||
NULL,
|
|
||||||
&qemuCaps) < 0)
|
|
||||||
goto endjob;
|
|
||||||
|
|
||||||
/* Get XML for the domain */
|
/* Get XML for the domain */
|
||||||
xml = virDomainDefFormat(vm->def, VIR_DOMAIN_XML_SECURE);
|
xml = virDomainDefFormat(vm->def, VIR_DOMAIN_XML_SECURE);
|
||||||
if (!xml) {
|
if (!xml) {
|
||||||
@ -2043,7 +2037,7 @@ static int qemudDomainSaveFlag(struct qemud_driver *driver, virDomainPtr dom,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Perform the migration */
|
/* Perform the migration */
|
||||||
if (qemuMigrationToFile(driver, vm, qemuCaps, fd, offset, path,
|
if (qemuMigrationToFile(driver, vm, fd, offset, path,
|
||||||
qemuCompressProgramName(compressed),
|
qemuCompressProgramName(compressed),
|
||||||
is_reg, bypassSecurityDriver) < 0)
|
is_reg, bypassSecurityDriver) < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
@ -2081,7 +2075,6 @@ endjob:
|
|||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
qemuCapsFree(qemuCaps);
|
|
||||||
VIR_FORCE_CLOSE(fd);
|
VIR_FORCE_CLOSE(fd);
|
||||||
VIR_FREE(xml);
|
VIR_FREE(xml);
|
||||||
if (ret != 0 && is_reg)
|
if (ret != 0 && is_reg)
|
||||||
@ -2299,7 +2292,7 @@ static int doCoreDump(struct qemud_driver *driver,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemuMigrationToFile(driver, vm, NULL, fd, 0, path,
|
if (qemuMigrationToFile(driver, vm, fd, 0, path,
|
||||||
qemuCompressProgramName(compress), true, false) < 0)
|
qemuCompressProgramName(compress), true, false) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
@ -255,7 +255,6 @@ qemuMigrationPrepareTunnel(struct qemud_driver *driver,
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
int internalret;
|
int internalret;
|
||||||
int dataFD[2] = { -1, -1 };
|
int dataFD[2] = { -1, -1 };
|
||||||
virBitmapPtr qemuCaps = NULL;
|
|
||||||
qemuDomainObjPrivatePtr priv = NULL;
|
qemuDomainObjPrivatePtr priv = NULL;
|
||||||
struct timeval now;
|
struct timeval now;
|
||||||
|
|
||||||
@ -307,14 +306,6 @@ qemuMigrationPrepareTunnel(struct qemud_driver *driver,
|
|||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check that this qemu version supports the interactive exec */
|
|
||||||
if (qemuCapsExtractVersionInfo(vm->def->emulator, vm->def->os.arch,
|
|
||||||
NULL, &qemuCaps) < 0) {
|
|
||||||
qemuReportError(VIR_ERR_INTERNAL_ERROR,
|
|
||||||
_("Cannot determine QEMU argv syntax %s"),
|
|
||||||
vm->def->emulator);
|
|
||||||
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 stdio (which qemu_command might convert to exec:cat or fd:n)
|
* -incoming stdio (which qemu_command might convert to exec:cat or fd:n)
|
||||||
*/
|
*/
|
||||||
@ -371,7 +362,6 @@ endjob:
|
|||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
qemuCapsFree(qemuCaps);
|
|
||||||
virDomainDefFree(def);
|
virDomainDefFree(def);
|
||||||
VIR_FORCE_CLOSE(dataFD[0]);
|
VIR_FORCE_CLOSE(dataFD[0]);
|
||||||
VIR_FORCE_CLOSE(dataFD[1]);
|
VIR_FORCE_CLOSE(dataFD[1]);
|
||||||
@ -703,7 +693,6 @@ static int doTunnelMigrate(struct qemud_driver *driver,
|
|||||||
virStreamPtr st = NULL;
|
virStreamPtr st = NULL;
|
||||||
char *unixfile = NULL;
|
char *unixfile = NULL;
|
||||||
int internalret;
|
int internalret;
|
||||||
virBitmapPtr qemuCaps = NULL;
|
|
||||||
int status;
|
int status;
|
||||||
unsigned long long transferred, remaining, total;
|
unsigned long long transferred, remaining, total;
|
||||||
unsigned int background_flags = QEMU_MONITOR_MIGRATE_BACKGROUND;
|
unsigned int background_flags = QEMU_MONITOR_MIGRATE_BACKGROUND;
|
||||||
@ -764,16 +753,9 @@ static int doTunnelMigrate(struct qemud_driver *driver,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* check that this qemu version supports the unix migration */
|
/* check that this qemu version supports the unix migration */
|
||||||
if (qemuCapsExtractVersionInfo(vm->def->emulator, vm->def->os.arch,
|
|
||||||
NULL, &qemuCaps) < 0) {
|
|
||||||
qemuReportError(VIR_ERR_INTERNAL_ERROR,
|
|
||||||
_("Cannot extract Qemu version from '%s'"),
|
|
||||||
vm->def->emulator);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!qemuCapsGet(qemuCaps, QEMU_CAPS_MIGRATE_QEMU_UNIX) &&
|
if (!qemuCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATE_QEMU_UNIX) &&
|
||||||
!qemuCapsGet(qemuCaps, QEMU_CAPS_MIGRATE_QEMU_EXEC)) {
|
!qemuCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATE_QEMU_EXEC)) {
|
||||||
qemuReportError(VIR_ERR_OPERATION_FAILED,
|
qemuReportError(VIR_ERR_OPERATION_FAILED,
|
||||||
"%s", _("Source qemu is too old to support tunnelled migration"));
|
"%s", _("Source qemu is too old to support tunnelled migration"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -815,11 +797,11 @@ static int doTunnelMigrate(struct qemud_driver *driver,
|
|||||||
background_flags |= QEMU_MONITOR_MIGRATE_NON_SHARED_DISK;
|
background_flags |= QEMU_MONITOR_MIGRATE_NON_SHARED_DISK;
|
||||||
if (flags & VIR_MIGRATE_NON_SHARED_INC)
|
if (flags & VIR_MIGRATE_NON_SHARED_INC)
|
||||||
background_flags |= QEMU_MONITOR_MIGRATE_NON_SHARED_INC;
|
background_flags |= QEMU_MONITOR_MIGRATE_NON_SHARED_INC;
|
||||||
if (qemuCapsGet(qemuCaps, QEMU_CAPS_MIGRATE_QEMU_UNIX)) {
|
if (qemuCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATE_QEMU_UNIX)) {
|
||||||
internalret = qemuMonitorMigrateToUnix(priv->mon, background_flags,
|
internalret = qemuMonitorMigrateToUnix(priv->mon, background_flags,
|
||||||
unixfile);
|
unixfile);
|
||||||
}
|
}
|
||||||
else if (qemuCapsGet(qemuCaps, QEMU_CAPS_MIGRATE_QEMU_EXEC)) {
|
else if (qemuCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATE_QEMU_EXEC)) {
|
||||||
const char *args[] = { "nc", "-U", unixfile, NULL };
|
const char *args[] = { "nc", "-U", unixfile, NULL };
|
||||||
internalret = qemuMonitorMigrateToCommand(priv->mon, QEMU_MONITOR_MIGRATE_BACKGROUND, args);
|
internalret = qemuMonitorMigrateToCommand(priv->mon, QEMU_MONITOR_MIGRATE_BACKGROUND, args);
|
||||||
} else {
|
} else {
|
||||||
@ -889,7 +871,6 @@ finish:
|
|||||||
cleanup:
|
cleanup:
|
||||||
VIR_FORCE_CLOSE(client_sock);
|
VIR_FORCE_CLOSE(client_sock);
|
||||||
VIR_FORCE_CLOSE(qemu_sock);
|
VIR_FORCE_CLOSE(qemu_sock);
|
||||||
qemuCapsFree(qemuCaps);
|
|
||||||
|
|
||||||
if (ddomain)
|
if (ddomain)
|
||||||
virUnrefDomain(ddomain);
|
virUnrefDomain(ddomain);
|
||||||
@ -1289,7 +1270,6 @@ cleanup:
|
|||||||
/* Helper function called while driver lock is held and vm is active. */
|
/* Helper function called while driver lock is held and vm is active. */
|
||||||
int
|
int
|
||||||
qemuMigrationToFile(struct qemud_driver *driver, virDomainObjPtr vm,
|
qemuMigrationToFile(struct qemud_driver *driver, virDomainObjPtr vm,
|
||||||
virBitmapPtr qemuCaps,
|
|
||||||
int fd, off_t offset, const char *path,
|
int fd, off_t offset, const char *path,
|
||||||
const char *compressor,
|
const char *compressor,
|
||||||
bool is_reg, bool bypassSecurityDriver)
|
bool is_reg, bool bypassSecurityDriver)
|
||||||
@ -1302,7 +1282,7 @@ qemuMigrationToFile(struct qemud_driver *driver, virDomainObjPtr vm,
|
|||||||
virCommandPtr cmd = NULL;
|
virCommandPtr cmd = NULL;
|
||||||
int pipeFD[2] = { -1, -1 };
|
int pipeFD[2] = { -1, -1 };
|
||||||
|
|
||||||
if (qemuCaps && qemuCapsGet(qemuCaps, QEMU_CAPS_MIGRATE_QEMU_FD) &&
|
if (qemuCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATE_QEMU_FD) &&
|
||||||
(!compressor || pipe(pipeFD) == 0)) {
|
(!compressor || pipe(pipeFD) == 0)) {
|
||||||
/* All right! We can use fd migration, which means that qemu
|
/* All right! We can use fd migration, which means that qemu
|
||||||
* doesn't have to open() the file, so while we still have to
|
* doesn't have to open() the file, so while we still have to
|
||||||
@ -1348,7 +1328,7 @@ qemuMigrationToFile(struct qemud_driver *driver, virDomainObjPtr vm,
|
|||||||
if (!compressor) {
|
if (!compressor) {
|
||||||
const char *args[] = { "cat", NULL };
|
const char *args[] = { "cat", NULL };
|
||||||
|
|
||||||
if (qemuCaps && qemuCapsGet(qemuCaps, QEMU_CAPS_MIGRATE_QEMU_FD) &&
|
if (qemuCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATE_QEMU_FD) &&
|
||||||
priv->monConfig->type == VIR_DOMAIN_CHR_TYPE_UNIX) {
|
priv->monConfig->type == VIR_DOMAIN_CHR_TYPE_UNIX) {
|
||||||
rc = qemuMonitorMigrateToFd(priv->mon,
|
rc = qemuMonitorMigrateToFd(priv->mon,
|
||||||
QEMU_MONITOR_MIGRATE_BACKGROUND,
|
QEMU_MONITOR_MIGRATE_BACKGROUND,
|
||||||
|
@ -61,7 +61,6 @@ virDomainPtr qemuMigrationFinish(struct qemud_driver *driver,
|
|||||||
|
|
||||||
|
|
||||||
int qemuMigrationToFile(struct qemud_driver *driver, virDomainObjPtr vm,
|
int qemuMigrationToFile(struct qemud_driver *driver, virDomainObjPtr vm,
|
||||||
virBitmapPtr qemuCaps,
|
|
||||||
int fd, off_t offset, const char *path,
|
int fd, off_t offset, const char *path,
|
||||||
const char *compressor,
|
const char *compressor,
|
||||||
bool is_reg, bool bypassSecurityDriver)
|
bool is_reg, bool bypassSecurityDriver)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user