diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index d068b36f4eaf3b3a753c80c945683a67038612c9..f9bc19078937a154f0d2f382917898878684a5b6 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1450,7 +1450,7 @@ qemuDomainSecretStorageSourcePrepare(virConnectPtr conn,
  * Returns 0 on success, -1 on failure
  */
 
-int
+static int
 qemuDomainSecretDiskPrepare(virConnectPtr conn,
                             qemuDomainObjPrivatePtr priv,
                             virDomainDiskDefPtr disk)
@@ -8008,7 +8008,7 @@ qemuDomainPrepareChardevSource(virDomainDefPtr def,
  *
  * Returns 0 on success, -1 on bad config/failure
  */
-int
+static int
 qemuDomainPrepareDiskSourceTLS(virStorageSourcePtr src,
                                virQEMUDriverConfigPtr cfg)
 {
@@ -10506,3 +10506,19 @@ qemuDomainCheckMigrationCapabilities(virQEMUDriverPtr driver,
     virStringListFree(caps);
     return ret;
 }
+
+
+int
+qemuDomainPrepareDiskSource(virConnectPtr conn,
+                            virDomainDiskDefPtr disk,
+                            qemuDomainObjPrivatePtr priv,
+                            virQEMUDriverConfigPtr cfg)
+{
+    if (qemuDomainPrepareDiskSourceTLS(disk->src, cfg) < 0)
+        return -1;
+
+    if (qemuDomainSecretDiskPrepare(conn, priv, disk) < 0)
+        return -1;
+
+    return 0;
+}
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 9066f5d0f54fcaf2494f9a57695b0b7d8ad433f3..146b27dd57e9640cd04ce58d4052806ffa475a43 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -839,11 +839,6 @@ qemuDomainSecretInfoTLSNew(virConnectPtr conn,
                            const char *srcAlias,
                            const char *secretUUID);
 
-int qemuDomainSecretDiskPrepare(virConnectPtr conn,
-                                qemuDomainObjPrivatePtr priv,
-                                virDomainDiskDefPtr disk)
-    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
-
 void qemuDomainSecretHostdevDestroy(virDomainHostdevDefPtr disk)
     ATTRIBUTE_NONNULL(1);
 
@@ -886,11 +881,6 @@ void qemuDomainPrepareChardevSource(virDomainDefPtr def,
                                     virQEMUDriverConfigPtr cfg)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
 
-int
-qemuDomainPrepareDiskSourceTLS(virStorageSourcePtr src,
-                               virQEMUDriverConfigPtr cfg)
-    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
-
 int qemuDomainPrepareShmemChardev(virDomainShmemDefPtr shmem)
     ATTRIBUTE_NONNULL(1);
 
@@ -1011,4 +1001,10 @@ qemuDomainCheckMigrationCapabilities(virQEMUDriverPtr driver,
                                      virDomainObjPtr vm,
                                      qemuDomainAsyncJob asyncJob);
 
+int
+qemuDomainPrepareDiskSource(virConnectPtr conn,
+                            virDomainDiskDefPtr disk,
+                            qemuDomainObjPrivatePtr priv,
+                            virQEMUDriverConfigPtr cfg);
+
 #endif /* __QEMU_DOMAIN_H__ */
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index a49480ecb45da4ecf92225612d4dcbbed1dca8dd..44d48ca95adb9e2c6ab966cb376d4f811d881442 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -384,7 +384,7 @@ qemuDomainAttachDiskGeneric(virConnectPtr conn,
     if (qemuAssignDeviceDiskAlias(vm->def, disk, priv->qemuCaps) < 0)
         goto error;
 
-    if (qemuDomainSecretDiskPrepare(conn, priv, disk) < 0)
+    if (qemuDomainPrepareDiskSource(conn, disk, priv, cfg) < 0)
         goto error;
 
     srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src);
@@ -401,9 +401,6 @@ qemuDomainAttachDiskGeneric(virConnectPtr conn,
     if (encinfo && qemuBuildSecretInfoProps(encinfo, &encobjProps) < 0)
         goto error;
 
-    if (qemuDomainPrepareDiskSourceTLS(disk->src, cfg) < 0)
-        goto error;
-
     if (disk->src->haveTLS &&
         qemuDomainAddDiskSrcTLSObject(driver, vm, disk->src,
                                       disk->info.alias) < 0)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 214f41dd8596503413dc16dbafc7a8f483f0127f..8574f2b413105f609aa9c141105bca772588252c 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -5388,10 +5388,7 @@ qemuProcessPrepareDomainStorage(virConnectPtr conn,
             continue;
         }
 
-        if (qemuDomainPrepareDiskSourceTLS(disk->src, cfg) < 0)
-            return -1;
-
-        if (qemuDomainSecretDiskPrepare(conn, priv, disk) < 0)
+        if (qemuDomainPrepareDiskSource(conn, disk, priv, cfg) < 0)
             return -1;
     }