[PATCH] qemu: Don't compare local and remote hostnames on migration
by Michal Privoznik
Libvirt tries to forbid migration onto the same host and it does
that by checking if local and remote hostnames are the same and
whether local and remote UUIDs are the same. Well, the latter
makes sense but the former doesn't really because libvirtd can be
running inside an UTS namespace and hostnames can appear the same
on both sides of migration. On the other hand, host UUIDs are
unique, so rely on them when trying to prevent migration onto the
same host.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1639596
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_migration_cookie.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_cookie.c
index a5a9edffc3..1d88ac1d22 100644
--- a/src/qemu/qemu_migration_cookie.c
+++ b/src/qemu/qemu_migration_cookie.c
@@ -1230,19 +1230,17 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig,
}
VIR_FREE(tmp);
- /* Check & forbid "localhost" migration */
if (!(mig->remoteHostname = virXPathString("string(./hostname[1])", ctxt))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("missing hostname element in migration data"));
goto error;
}
- if (STREQ(mig->remoteHostname, mig->localHostname)) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Attempt to migrate guest to the same host %s"),
- mig->remoteHostname);
- goto error;
- }
+ /* Historically, this is the place where we checked whether remoteHostname
+ * and localHostname are the same. But even if they were, it doesn't mean
+ * the domain is migrating onto the same host. Rely on UUID which can tell
+ * for sure. */
+ /* Check & forbid localhost migration */
if (!(tmp = virXPathString("string(./hostuuid[1])", ctxt))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("missing hostuuid element in migration data"));
--
2.24.1
5 years
[PATCH] admin: use g_autofree
by Gaurav Agrawal
Signed-off-by: Gaurav Agrawal <agrawalgaurav(a)gnome.org>
---
src/admin/libvirt-admin.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/src/admin/libvirt-admin.c b/src/admin/libvirt-admin.c
index 4099a54854..e272d7a422 100644
--- a/src/admin/libvirt-admin.c
+++ b/src/admin/libvirt-admin.c
@@ -111,7 +111,7 @@ getSocketPath(virURIPtr uri)
virURIParamPtr param = &uri->params[i];
if (STREQ(param->name, "socket")) {
- VIR_FREE(sock_path);
+ g_free(sock_path);
sock_path = g_strdup(param->value);
} else {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
@@ -203,11 +203,11 @@ virAdmGetDefaultURI(virConfPtr conf, char **uristr)
virAdmConnectPtr
virAdmConnectOpen(const char *name, unsigned int flags)
{
- char *sock_path = NULL;
+ g_autofree char *sock_path = NULL;
char *alias = NULL;
virAdmConnectPtr conn = NULL;
g_autoptr(virConf) conf = NULL;
- char *uristr = NULL;
+ g_autofree char *uristr = NULL;
if (virAdmInitialize() < 0)
goto error;
@@ -233,7 +233,7 @@ virAdmConnectOpen(const char *name, unsigned int flags)
goto error;
if (alias) {
- VIR_FREE(uristr);
+ g_free(uristr);
uristr = alias;
}
@@ -251,16 +251,11 @@ virAdmConnectOpen(const char *name, unsigned int flags)
if (remoteAdminConnectOpen(conn, flags) < 0)
goto error;
- cleanup:
- VIR_FREE(sock_path);
- VIR_FREE(uristr);
- return conn;
error:
virDispatchError(NULL);
virObjectUnref(conn);
- conn = NULL;
- goto cleanup;
+ return NULL;
}
/**
--
2.24.1
5 years