Signed-off-by: Claudio Fontana <cfontana@xxxxxxx> --- src/qemu/qemu_saveimage.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_saveimage.c b/src/qemu/qemu_saveimage.c index 6a65d72fb3..bb23788a5e 100644 --- a/src/qemu/qemu_saveimage.c +++ b/src/qemu/qemu_saveimage.c @@ -17,6 +17,7 @@ */ #include <config.h> +#include <configmake.h> #include "qemu_saveimage.h" #include "qemu_domain.h" @@ -412,7 +413,8 @@ static int qemuSaveImageCloseMultiFd(virQEMUSaveFd *multiFd, int nconn, virDomai static virQEMUSaveFd * qemuSaveImageCreateMultiFd(virQEMUDriver *driver, virDomainObj *vm, - const char *path, uid_t user, gid_t group, + virCommand *cmd, const char *path, + uid_t user, gid_t group, int nconn, unsigned int flags) { virQEMUSaveFd *multiFd = g_new0(virQEMUSaveFd, nconn); @@ -426,6 +428,8 @@ qemuSaveImageCreateMultiFd(virQEMUDriver *driver, virDomainObj *vm, virQEMUSaveFdFini(m, vm, -1); goto error; } + virCommandAddArgFormat(cmd, "%d", m->fd); + virCommandPassFD(cmd, m->fd, 0); } return multiFd; @@ -463,8 +467,30 @@ qemuSaveImageCreate(virQEMUDriver *driver, goto cleanup; if (flags & VIR_DOMAIN_SAVE_PARALLEL) { + g_autoptr(virCommand) cmd = NULL; + g_autofree char *helper_path = NULL; + qemuDomainObjPrivate *priv = vm->privateData; + g_autofree char *sun_path = g_strdup_printf("%s/save-multifd.sock", priv->libDir); + char buf[1]; + int helper_out = -1; + if (!(helper_path = virFileFindResource("libvirt_multifd_helper", + abs_top_builddir "/src", + LIBEXECDIR))) + goto cleanup; + cmd = virCommandNewArgList(helper_path, sun_path, NULL); + virCommandAddArgFormat(cmd, "%d", nconn); + virCommandAddArgFormat(cmd, "%d", saveFd.fd); + virCommandPassFD(cmd, saveFd.fd, 0); + virCommandSetOutputFD(cmd, &helper_out); /* should create pipe automagically */ + /* Perform parallel multifd migration to files (main fd + channels) */ - if (!(multiFd = qemuSaveImageCreateMultiFd(driver, vm, saveFd.path, cfg->user, cfg->group, nconn, flags))) + if (!(multiFd = qemuSaveImageCreateMultiFd(driver, vm, cmd, saveFd.path, cfg->user, cfg->group, nconn, flags))) + goto cleanup; + if (virCommandRunAsync(cmd, NULL) < 0) + goto cleanup; + if (saferead(helper_out, &buf, 1) != 1 || buf[0] != 'R') + goto cleanup; + if (chown(sun_path, cfg->user, cfg->group) < 0) goto cleanup; /* still using single fd migration for now */ if (qemuMigrationSrcToFile(driver, vm, saveFd.fd, compressor, asyncJob) < 0) -- 2.34.1