提交 71483641 编写于 作者: J Jiri Denemark

qemu: Refactor the code to build -incoming command line

Move the code from qemuBuildCommandLine into dedicated functions.
Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
上级 6d1f8899
......@@ -9088,6 +9088,45 @@ qemuBuildTPMCommandLine(virDomainDefPtr def,
return 0;
}
static int
qemuBuildIncomingCheckProtocol(virQEMUCapsPtr qemuCaps,
const char *migrateFrom)
{
if (STRPREFIX(migrateFrom, "rdma")) {
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MIGRATE_RDMA)) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("incoming RDMA migration is not supported "
"with this QEMU binary"));
return -1;
}
} else if (!STRPREFIX(migrateFrom, "tcp") &&
!STRPREFIX(migrateFrom, "exec") &&
!STRPREFIX(migrateFrom, "fd") &&
!STRPREFIX(migrateFrom, "unix") &&
STRNEQ(migrateFrom, "stdio")) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("unknown migration protocol"));
return -1;
}
return 0;
}
static char *
qemuBuildIncomingURI(const char *migrateFrom,
int migrateFd)
{
char *uri = NULL;
if (STREQ(migrateFrom, "stdio"))
ignore_value(virAsprintf(&uri, "fd:%d", migrateFd));
else
ignore_value(VIR_STRDUP(uri, migrateFrom));
return uri;
}
qemuBuildCommandLineCallbacks buildCommandLineCallbacks = {
.qemuGetSCSIDeviceSgName = virSCSIDeviceGetSgName,
......@@ -10937,32 +10976,20 @@ qemuBuildCommandLine(virConnectPtr conn,
}
if (migrateFrom) {
virCommandAddArg(cmd, "-incoming");
if (STRPREFIX(migrateFrom, "tcp")) {
virCommandAddArg(cmd, migrateFrom);
} else if (STRPREFIX(migrateFrom, "rdma")) {
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MIGRATE_RDMA)) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("incoming RDMA migration is not supported "
"with this QEMU binary"));
goto error;
}
virCommandAddArg(cmd, migrateFrom);
} else if (STREQ(migrateFrom, "stdio")) {
virCommandAddArgFormat(cmd, "fd:%d", migrateFd);
virCommandPassFD(cmd, migrateFd, 0);
} else if (STRPREFIX(migrateFrom, "exec")) {
virCommandAddArg(cmd, migrateFrom);
} else if (STRPREFIX(migrateFrom, "fd")) {
virCommandAddArg(cmd, migrateFrom);
char *migrateURI;
if (qemuBuildIncomingCheckProtocol(qemuCaps, migrateFrom) < 0)
goto error;
if (STREQ(migrateFrom, "stdio") ||
STRPREFIX(migrateFrom, "fd"))
virCommandPassFD(cmd, migrateFd, 0);
} else if (STRPREFIX(migrateFrom, "unix")) {
virCommandAddArg(cmd, migrateFrom);
} else {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("unknown migration protocol"));
migrateURI = qemuBuildIncomingURI(migrateFrom, migrateFd);
if (!migrateURI)
goto error;
}
virCommandAddArgList(cmd, "-incoming", migrateURI, NULL);
VIR_FREE(migrateURI);
}
/* QEMU changed its default behavior to not include the virtio balloon
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册