6d3351
From baf6fbbba2c6cfbf4abe6e038900e9b5b3f8d7e1 Mon Sep 17 00:00:00 2001
6d3351
Message-Id: <baf6fbbba2c6cfbf4abe6e038900e9b5b3f8d7e1@dist-git>
6d3351
From: Jiri Denemark <jdenemar@redhat.com>
6d3351
Date: Wed, 5 Apr 2017 13:04:04 +0200
6d3351
Subject: [PATCH] qemu: Simplify qemuMigrationResetTLS
6d3351
6d3351
It's only called from qemuMigrationReset now so it doesn't need to be
6d3351
exported and {tls,sec}Alias are always NULL.
6d3351
6d3351
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
6d3351
(cherry picked from commit 4097de405e5ea5fae3867028ee901c03f80eb15b)
6d3351
6d3351
https://bugzilla.redhat.com/show_bug.cgi?id=1425003
6d3351
6d3351
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
6d3351
---
6d3351
 src/qemu/qemu_migration.c | 37 +++++++++++++------------------------
6d3351
 src/qemu/qemu_migration.h |  7 -------
6d3351
 2 files changed, 13 insertions(+), 31 deletions(-)
6d3351
6d3351
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
6d3351
index 27156cc78..3e9c35e4c 100644
6d3351
--- a/src/qemu/qemu_migration.c
6d3351
+++ b/src/qemu/qemu_migration.c
6d3351
@@ -2406,45 +2406,36 @@ qemuMigrationSetParams(virQEMUDriverPtr driver,
6d3351
  * @driver: pointer to qemu driver
6d3351
  * @vm: domain object
6d3351
  * @asyncJob: migration job to join
6d3351
- * @tlsAlias: alias generated for TLS object (may be NULL)
6d3351
- * @secAlias: alias generated for a secinfo object (may be NULL)
6d3351
  *
6d3351
  * Deconstruct all the setup possibly done for TLS - delete the TLS and
6d3351
- * security objects, fre the secinfo, and reset the migration params to "".
6d3351
+ * security objects, free the secinfo, and reset the migration params to "".
6d3351
  *
6d3351
  * Returns 0 on success, -1 on failure
6d3351
  */
6d3351
-int
6d3351
+static int
6d3351
 qemuMigrationResetTLS(virQEMUDriverPtr driver,
6d3351
                       virDomainObjPtr vm,
6d3351
-                      qemuDomainAsyncJob asyncJob,
6d3351
-                      char *in_tlsAlias,
6d3351
-                      char *in_secAlias)
6d3351
+                      qemuDomainAsyncJob asyncJob)
6d3351
 {
6d3351
     qemuDomainObjPrivatePtr priv = vm->privateData;
6d3351
-    char *tlsAlias = in_tlsAlias;
6d3351
-    char *secAlias = in_secAlias;
6d3351
+    char *tlsAlias = NULL;
6d3351
+    char *secAlias = NULL;
6d3351
     qemuMonitorMigrationParams migParams = { 0 };
6d3351
     int ret = -1;
6d3351
 
6d3351
-    /* If coming from a path that doesn't know whether it's been used or not,
6d3351
-     * let's first check we need to do this. If the tls-creds doesn't exist
6d3351
-     * or if they're set to "" then there's nothing to do since we never set
6d3351
-     * anything up */
6d3351
-    if (!in_tlsAlias && qemuMigrationCheckTLSCreds(driver, vm, asyncJob) < 0)
6d3351
+    if (qemuMigrationCheckTLSCreds(driver, vm, asyncJob) < 0)
6d3351
         return -1;
6d3351
 
6d3351
+    /* If the tls-creds doesn't exist or if they're set to "" then there's
6d3351
+     * nothing to do since we never set anything up */
6d3351
     if (!priv->migTLSAlias || !*priv->migTLSAlias)
6d3351
         return 0;
6d3351
 
6d3351
     /* NB: If either or both fail to allocate memory we can still proceed
6d3351
      *     since the next time we migrate another deletion attempt will be
6d3351
      *     made after successfully generating the aliases. */
6d3351
-    if (!tlsAlias)
6d3351
-        tlsAlias = qemuAliasTLSObjFromSrcAlias(QEMU_MIGRATION_TLS_ALIAS_BASE);
6d3351
-    if (!secAlias)
6d3351
-        secAlias = qemuDomainGetSecretAESAlias(QEMU_MIGRATION_TLS_ALIAS_BASE,
6d3351
-                                               false);
6d3351
+    tlsAlias = qemuAliasTLSObjFromSrcAlias(QEMU_MIGRATION_TLS_ALIAS_BASE);
6d3351
+    secAlias = qemuDomainGetSecretAESAlias(QEMU_MIGRATION_TLS_ALIAS_BASE, false);
6d3351
 
6d3351
     qemuDomainDelTLSObjects(driver, vm, asyncJob, secAlias, tlsAlias);
6d3351
     qemuDomainSecretInfoFree(&priv->migSecinfo);
6d3351
@@ -2457,10 +2448,8 @@ qemuMigrationResetTLS(virQEMUDriverPtr driver,
6d3351
     ret = 0;
6d3351
 
6d3351
  cleanup:
6d3351
-    if (!in_tlsAlias)
6d3351
-        VIR_FREE(tlsAlias);
6d3351
-    if (!in_secAlias)
6d3351
-        VIR_FREE(secAlias);
6d3351
+    VIR_FREE(tlsAlias);
6d3351
+    VIR_FREE(secAlias);
6d3351
     qemuMigrationParamsClear(&migParams);
6d3351
 
6d3351
     return ret;
6d3351
@@ -5887,6 +5876,6 @@ qemuMigrationReset(virQEMUDriverPtr driver,
6d3351
     if (!virDomainObjIsActive(vm))
6d3351
         return;
6d3351
 
6d3351
-    if (qemuMigrationResetTLS(driver, vm, job, NULL, NULL) < 0)
6d3351
+    if (qemuMigrationResetTLS(driver, vm, job) < 0)
6d3351
         return;
6d3351
 }
6d3351
diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h
6d3351
index 28eb55056..b392b8fff 100644
6d3351
--- a/src/qemu/qemu_migration.h
6d3351
+++ b/src/qemu/qemu_migration.h
6d3351
@@ -278,13 +278,6 @@ int qemuMigrationRunIncoming(virQEMUDriverPtr driver,
6d3351
 void qemuMigrationPostcopyFailed(virQEMUDriverPtr driver,
6d3351
                                  virDomainObjPtr vm);
6d3351
 
6d3351
-int
6d3351
-qemuMigrationResetTLS(virQEMUDriverPtr driver,
6d3351
-                      virDomainObjPtr vm,
6d3351
-                      qemuDomainAsyncJob asyncJob,
6d3351
-                      char *in_tlsAlias,
6d3351
-                      char *in_secAlias);
6d3351
-
6d3351
 void
6d3351
 qemuMigrationReset(virQEMUDriverPtr driver,
6d3351
                    virDomainObjPtr vm,
6d3351
-- 
6d3351
2.12.2
6d3351