prepare to use the multifd helper.
Signed-off-by: Claudio Fontana <cfontana(a)suse.de>
---
src/qemu/qemu_saveimage.c | 41 ++++++++++++++++++++++++++++++++++-----
1 file changed, 36 insertions(+), 5 deletions(-)
diff --git a/src/qemu/qemu_saveimage.c b/src/qemu/qemu_saveimage.c
index 6418114d8a..8af9b92b35 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"
@@ -542,7 +543,7 @@ qemuSaveImageCreate(virQEMUDriver *driver,
const char *path,
virQEMUSaveData *data,
virCommand *compressor,
- int nconn G_GNUC_UNUSED,
+ int nconn,
unsigned int flags,
virDomainAsyncJob asyncJob)
{
@@ -566,10 +567,40 @@ qemuSaveImageCreate(virQEMUDriver *driver,
goto cleanup;
if (virQEMUSaveDataWrite(data, saveFd.fd, saveFd.path) < 0)
goto cleanup;
-
- /* Perform the migration */
- if (qemuMigrationSrcToFile(driver, vm, saveFd.fd, compressor, asyncJob) < 0)
- goto cleanup;
+ if (nconn > 0) {
+ if (virQEMUSaveFdAddChannels(&saveFd, nconn) < 0)
+ 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, saveFd.path, NULL);
+ virCommandAddArgFormat(cmd, "%d", nconn);
+ virCommandAddArgFormat(cmd, "%d", saveFd.fd);
+ virCommandPassFD(cmd, saveFd.fd, 0);
+ virCommandSetOutputFD(cmd, &helper_out); /* should create pipe automagically
*/
+ 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)
+ goto cleanup;
+ } else {
+ /* Perform non-parallel migration to file */
+ if (qemuMigrationSrcToFile(driver, vm, saveFd.fd, compressor, asyncJob) < 0)
+ goto cleanup;
+ }
if (virQEMUSaveFdClose(&saveFd, vm) < 0)
goto cleanup;
--
2.26.2