Blob Blame History Raw
From baf6fbbba2c6cfbf4abe6e038900e9b5b3f8d7e1 Mon Sep 17 00:00:00 2001
Message-Id: <baf6fbbba2c6cfbf4abe6e038900e9b5b3f8d7e1@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Wed, 5 Apr 2017 13:04:04 +0200
Subject: [PATCH] qemu: Simplify qemuMigrationResetTLS

It's only called from qemuMigrationReset now so it doesn't need to be
exported and {tls,sec}Alias are always NULL.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
(cherry picked from commit 4097de405e5ea5fae3867028ee901c03f80eb15b)

https://bugzilla.redhat.com/show_bug.cgi?id=1425003

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/qemu/qemu_migration.c | 37 +++++++++++++------------------------
 src/qemu/qemu_migration.h |  7 -------
 2 files changed, 13 insertions(+), 31 deletions(-)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 27156cc78..3e9c35e4c 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -2406,45 +2406,36 @@ qemuMigrationSetParams(virQEMUDriverPtr driver,
  * @driver: pointer to qemu driver
  * @vm: domain object
  * @asyncJob: migration job to join
- * @tlsAlias: alias generated for TLS object (may be NULL)
- * @secAlias: alias generated for a secinfo object (may be NULL)
  *
  * Deconstruct all the setup possibly done for TLS - delete the TLS and
- * security objects, fre the secinfo, and reset the migration params to "".
+ * security objects, free the secinfo, and reset the migration params to "".
  *
  * Returns 0 on success, -1 on failure
  */
-int
+static int
 qemuMigrationResetTLS(virQEMUDriverPtr driver,
                       virDomainObjPtr vm,
-                      qemuDomainAsyncJob asyncJob,
-                      char *in_tlsAlias,
-                      char *in_secAlias)
+                      qemuDomainAsyncJob asyncJob)
 {
     qemuDomainObjPrivatePtr priv = vm->privateData;
-    char *tlsAlias = in_tlsAlias;
-    char *secAlias = in_secAlias;
+    char *tlsAlias = NULL;
+    char *secAlias = NULL;
     qemuMonitorMigrationParams migParams = { 0 };
     int ret = -1;
 
-    /* If coming from a path that doesn't know whether it's been used or not,
-     * let's first check we need to do this. If the tls-creds doesn't exist
-     * or if they're set to "" then there's nothing to do since we never set
-     * anything up */
-    if (!in_tlsAlias && qemuMigrationCheckTLSCreds(driver, vm, asyncJob) < 0)
+    if (qemuMigrationCheckTLSCreds(driver, vm, asyncJob) < 0)
         return -1;
 
+    /* If the tls-creds doesn't exist or if they're set to "" then there's
+     * nothing to do since we never set anything up */
     if (!priv->migTLSAlias || !*priv->migTLSAlias)
         return 0;
 
     /* NB: If either or both fail to allocate memory we can still proceed
      *     since the next time we migrate another deletion attempt will be
      *     made after successfully generating the aliases. */
-    if (!tlsAlias)
-        tlsAlias = qemuAliasTLSObjFromSrcAlias(QEMU_MIGRATION_TLS_ALIAS_BASE);
-    if (!secAlias)
-        secAlias = qemuDomainGetSecretAESAlias(QEMU_MIGRATION_TLS_ALIAS_BASE,
-                                               false);
+    tlsAlias = qemuAliasTLSObjFromSrcAlias(QEMU_MIGRATION_TLS_ALIAS_BASE);
+    secAlias = qemuDomainGetSecretAESAlias(QEMU_MIGRATION_TLS_ALIAS_BASE, false);
 
     qemuDomainDelTLSObjects(driver, vm, asyncJob, secAlias, tlsAlias);
     qemuDomainSecretInfoFree(&priv->migSecinfo);
@@ -2457,10 +2448,8 @@ qemuMigrationResetTLS(virQEMUDriverPtr driver,
     ret = 0;
 
  cleanup:
-    if (!in_tlsAlias)
-        VIR_FREE(tlsAlias);
-    if (!in_secAlias)
-        VIR_FREE(secAlias);
+    VIR_FREE(tlsAlias);
+    VIR_FREE(secAlias);
     qemuMigrationParamsClear(&migParams);
 
     return ret;
@@ -5887,6 +5876,6 @@ qemuMigrationReset(virQEMUDriverPtr driver,
     if (!virDomainObjIsActive(vm))
         return;
 
-    if (qemuMigrationResetTLS(driver, vm, job, NULL, NULL) < 0)
+    if (qemuMigrationResetTLS(driver, vm, job) < 0)
         return;
 }
diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h
index 28eb55056..b392b8fff 100644
--- a/src/qemu/qemu_migration.h
+++ b/src/qemu/qemu_migration.h
@@ -278,13 +278,6 @@ int qemuMigrationRunIncoming(virQEMUDriverPtr driver,
 void qemuMigrationPostcopyFailed(virQEMUDriverPtr driver,
                                  virDomainObjPtr vm);
 
-int
-qemuMigrationResetTLS(virQEMUDriverPtr driver,
-                      virDomainObjPtr vm,
-                      qemuDomainAsyncJob asyncJob,
-                      char *in_tlsAlias,
-                      char *in_secAlias);
-
 void
 qemuMigrationReset(virQEMUDriverPtr driver,
                    virDomainObjPtr vm,
-- 
2.12.2