mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-30 18:50:18 +03:00
qemu: Support O_DIRECT with mapped-ram on restore
When using the mapped-ram migration capability, direct IO is enabled by setting the "direct-io" migration parameter to "true" and passing QEMU an additional fd with O_DIRECT set. Signed-off-by: Jim Fehlig <jfehlig@suse.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
06bdb1b6c7
commit
da4273db05
@ -3110,7 +3110,8 @@ qemuMigrationDstPrepareCleanup(virQEMUDriver *driver,
|
||||
}
|
||||
|
||||
static qemuProcessIncomingDef *
|
||||
qemuMigrationDstPrepare(virDomainObj *vm,
|
||||
qemuMigrationDstPrepare(virQEMUDriver *driver,
|
||||
virDomainObj *vm,
|
||||
bool tunnel,
|
||||
const char *protocol,
|
||||
const char *listenAddress,
|
||||
@ -3170,9 +3171,9 @@ qemuMigrationDstPrepare(virDomainObj *vm,
|
||||
migrateFrom = g_strdup_printf(incFormat, protocol, listenAddress, port);
|
||||
}
|
||||
|
||||
return qemuProcessIncomingDefNew(vm, listenAddress,
|
||||
return qemuProcessIncomingDefNew(driver, vm, listenAddress,
|
||||
migrateFrom, fd,
|
||||
NULL, NULL);
|
||||
NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
|
||||
@ -3310,7 +3311,7 @@ qemuMigrationDstPrepareActive(virQEMUDriver *driver,
|
||||
goto error;
|
||||
stopProcess = true;
|
||||
|
||||
if (!(incoming = qemuMigrationDstPrepare(vm, tunnel, protocol,
|
||||
if (!(incoming = qemuMigrationDstPrepare(driver, vm, tunnel, protocol,
|
||||
listenAddress, port,
|
||||
&dataFD[0])))
|
||||
goto error;
|
||||
@ -3682,7 +3683,7 @@ qemuMigrationDstPrepareResume(virQEMUDriver *driver,
|
||||
|
||||
priv->origname = g_strdup(origname);
|
||||
|
||||
if (!(incoming = qemuMigrationDstPrepare(vm, false, protocol,
|
||||
if (!(incoming = qemuMigrationDstPrepare(driver, vm, false, protocol,
|
||||
listenAddress, port, NULL)))
|
||||
goto cleanup;
|
||||
|
||||
|
@ -4876,13 +4876,16 @@ qemuProcessIncomingDefFree(qemuProcessIncomingDef *inc)
|
||||
* qemuProcessIncomingDefFree will NOT close it.
|
||||
*/
|
||||
qemuProcessIncomingDef *
|
||||
qemuProcessIncomingDefNew(virDomainObj *vm,
|
||||
qemuProcessIncomingDefNew(virQEMUDriver *driver,
|
||||
virDomainObj *vm,
|
||||
const char *listenAddress,
|
||||
const char *migrateFrom,
|
||||
int *fd,
|
||||
const char *path,
|
||||
virQEMUSaveData *data)
|
||||
virQEMUSaveData *data,
|
||||
qemuMigrationParams *migParams)
|
||||
{
|
||||
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
|
||||
qemuDomainObjPrivate *priv = vm->privateData;
|
||||
qemuProcessIncomingDef *inc = NULL;
|
||||
|
||||
@ -4895,9 +4898,25 @@ qemuProcessIncomingDefNew(virDomainObj *vm,
|
||||
|
||||
if (data && data->header.format == QEMU_SAVE_FORMAT_SPARSE) {
|
||||
size_t offset = sizeof(virQEMUSaveHeader) + data->header.data_len;
|
||||
bool directio = false;
|
||||
|
||||
inc->fdPassMigrate = qemuFDPassNew("libvirt-incoming-migrate", priv);
|
||||
qemuFDPassAddFD(inc->fdPassMigrate, fd, "-fd");
|
||||
/* When using directio with mapped-ram, qemu needs an fd without
|
||||
* O_DIRECT set for reading small bits of unaligned state. */
|
||||
if (qemuMigrationParamsGetBool(migParams, QEMU_MIGRATION_PARAM_DIRECT_IO, &directio) < 0)
|
||||
goto error;
|
||||
|
||||
if (directio) {
|
||||
VIR_AUTOCLOSE bufferedFd = -1;
|
||||
|
||||
if ((bufferedFd = qemuDomainOpenFile(cfg, NULL, path, O_RDONLY, NULL)) < 0)
|
||||
goto error;
|
||||
|
||||
qemuFDPassAddFD(inc->fdPassMigrate, &bufferedFd, "-buffered-fd");
|
||||
qemuFDPassAddFD(inc->fdPassMigrate, fd, "direct-io-fd");
|
||||
} else {
|
||||
qemuFDPassAddFD(inc->fdPassMigrate, fd, "-buffered-fd");
|
||||
}
|
||||
inc->uri = g_strdup_printf("file:%s,offset=%#lx",
|
||||
qemuFDPassGetPath(inc->fdPassMigrate), offset);
|
||||
} else {
|
||||
@ -8605,7 +8624,7 @@ qemuProcessStartWithMemoryState(virConnectPtr conn,
|
||||
/* The fd passed to qemuProcessIncomingDefNew is used to create the migration
|
||||
* URI, so it must be called after starting the decompression program.
|
||||
*/
|
||||
incoming = qemuProcessIncomingDefNew(vm, NULL, "stdio", fd, path, data);
|
||||
incoming = qemuProcessIncomingDefNew(driver, vm, NULL, "stdio", fd, path, data, migParams);
|
||||
if (!incoming)
|
||||
return -1;
|
||||
|
||||
|
@ -57,12 +57,14 @@ struct _qemuProcessIncomingDef {
|
||||
const char *path; /* path associated with fd */
|
||||
};
|
||||
|
||||
qemuProcessIncomingDef *qemuProcessIncomingDefNew(virDomainObj *vm,
|
||||
qemuProcessIncomingDef *qemuProcessIncomingDefNew(virQEMUDriver *driver,
|
||||
virDomainObj *vm,
|
||||
const char *listenAddress,
|
||||
const char *migrateFrom,
|
||||
int *fd,
|
||||
const char *path,
|
||||
virQEMUSaveData *data);
|
||||
virQEMUSaveData *data,
|
||||
qemuMigrationParams *migParams);
|
||||
|
||||
void qemuProcessIncomingDefFree(qemuProcessIncomingDef *inc);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user