mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 22:55:23 +00:00
qemu: allow simple domain save to use fd: protocol
This allows direct saves (no compression, no root-squash NFS) to use the more efficient fd: migration, which in turn avoids a race where qemu exec: migration can sometimes fail because qemu does a generic waitpid() that conflicts with the pclose() used by exec:. Further patches will solve compression and root-squash NFS. * src/qemu/qemu_driver.c (qemudDomainSaveFlag): Use new function when there is no compression.
This commit is contained in:
parent
d51023d4c2
commit
9497506fa0
@ -1823,6 +1823,7 @@ static int qemudDomainSaveFlag(struct qemud_driver *driver, virDomainPtr dom,
|
|||||||
int is_reg = 0;
|
int is_reg = 0;
|
||||||
unsigned long long offset;
|
unsigned long long offset;
|
||||||
virCgroupPtr cgroup = NULL;
|
virCgroupPtr cgroup = NULL;
|
||||||
|
virBitmapPtr qemuCaps = NULL;
|
||||||
|
|
||||||
memset(&header, 0, sizeof(header));
|
memset(&header, 0, sizeof(header));
|
||||||
memcpy(header.magic, QEMUD_SAVE_MAGIC, sizeof(header.magic));
|
memcpy(header.magic, QEMUD_SAVE_MAGIC, sizeof(header.magic));
|
||||||
@ -1853,6 +1854,11 @@ 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) {
|
||||||
@ -2013,10 +2019,23 @@ static int qemudDomainSaveFlag(struct qemud_driver *driver, virDomainPtr dom,
|
|||||||
|
|
||||||
if (header.compressed == QEMUD_SAVE_FORMAT_RAW) {
|
if (header.compressed == QEMUD_SAVE_FORMAT_RAW) {
|
||||||
const char *args[] = { "cat", NULL };
|
const char *args[] = { "cat", NULL };
|
||||||
|
/* XXX gross - why don't we reuse the fd already opened earlier */
|
||||||
|
int fd = -1;
|
||||||
|
|
||||||
|
if (qemuCapsGet(qemuCaps, QEMU_CAPS_MIGRATE_QEMU_FD) &&
|
||||||
|
priv->monConfig->type == VIR_DOMAIN_CHR_TYPE_UNIX)
|
||||||
|
fd = open(path, O_WRONLY);
|
||||||
qemuDomainObjEnterMonitorWithDriver(driver, vm);
|
qemuDomainObjEnterMonitorWithDriver(driver, vm);
|
||||||
rc = qemuMonitorMigrateToFile(priv->mon,
|
if (fd >= 0 && lseek(fd, offset, SEEK_SET) == offset) {
|
||||||
QEMU_MONITOR_MIGRATE_BACKGROUND,
|
rc = qemuMonitorMigrateToFd(priv->mon,
|
||||||
args, path, offset);
|
QEMU_MONITOR_MIGRATE_BACKGROUND,
|
||||||
|
fd);
|
||||||
|
} else {
|
||||||
|
rc = qemuMonitorMigrateToFile(priv->mon,
|
||||||
|
QEMU_MONITOR_MIGRATE_BACKGROUND,
|
||||||
|
args, path, offset);
|
||||||
|
}
|
||||||
|
VIR_FORCE_CLOSE(fd);
|
||||||
qemuDomainObjExitMonitorWithDriver(driver, vm);
|
qemuDomainObjExitMonitorWithDriver(driver, vm);
|
||||||
} else {
|
} else {
|
||||||
const char *prog = qemudSaveCompressionTypeToString(header.compressed);
|
const char *prog = qemudSaveCompressionTypeToString(header.compressed);
|
||||||
@ -2099,6 +2118,7 @@ endjob:
|
|||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
qemuCapsFree(qemuCaps);
|
||||||
VIR_FREE(xml);
|
VIR_FREE(xml);
|
||||||
if (ret != 0 && is_reg)
|
if (ret != 0 && is_reg)
|
||||||
unlink(path);
|
unlink(path);
|
||||||
|
Loading…
Reference in New Issue
Block a user