]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Move domain-related functions to qemu_domain
authorMartin Kletzander <mkletzan@redhat.com>
Wed, 18 Sep 2024 07:25:52 +0000 (09:25 +0200)
committerMartin Kletzander <mkletzan@redhat.com>
Tue, 24 Sep 2024 08:12:08 +0000 (10:12 +0200)
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_conf.c
src/qemu/qemu_conf.h
src/qemu/qemu_domain.c
src/qemu/qemu_domain.h

index b36bede6c3c610511d1b231a11fac7f905d9aa8f..0d90a87392028d219de884dd7987d9cec272dfdb 100644 (file)
@@ -1603,64 +1603,6 @@ qemuGetDomainHupageMemPath(virQEMUDriver *driver,
 }
 
 
-int
-qemuGetMemoryBackingDomainPath(virQEMUDriver *driver,
-                               const virDomainDef *def,
-                               char **path)
-{
-    g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
-    const char *root = driver->embeddedRoot;
-    g_autofree char *shortName = NULL;
-
-    if (!(shortName = virDomainDefGetShortName(def)))
-        return -1;
-
-    if (root && !STRPREFIX(cfg->memoryBackingDir, root)) {
-        g_autofree char * hash = virDomainDriverGenerateRootHash("qemu", root);
-        *path = g_strdup_printf("%s/%s-%s", cfg->memoryBackingDir, hash, shortName);
-    } else {
-        *path = g_strdup_printf("%s/%s", cfg->memoryBackingDir, shortName);
-    }
-
-    return 0;
-}
-
-
-/**
- * qemuGetMemoryBackingPath:
- * @driver: the qemu driver
- * @def: domain definition
- * @alias: memory object alias
- * @memPath: constructed path
- *
- * Constructs path to memory backing dir and stores it at @memPath.
- *
- * Returns: 0 on success,
- *          -1 otherwise (with error reported).
- */
-int
-qemuGetMemoryBackingPath(virQEMUDriver *driver,
-                         const virDomainDef *def,
-                         const char *alias,
-                         char **memPath)
-{
-    g_autofree char *domainPath = NULL;
-
-    if (!alias) {
-        /* This should never happen (TM) */
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("memory device alias is not assigned"));
-        return -1;
-    }
-
-    if (qemuGetMemoryBackingDomainPath(driver, def, &domainPath) < 0)
-        return -1;
-
-    *memPath = g_strdup_printf("%s/%s", domainPath, alias);
-    return 0;
-}
-
-
 int
 qemuHugepageMakeBasedir(virQEMUDriver *driver,
                         virHugeTLBFS *hugepage)
index aa1e1a626c1aa054a1a773e45af0741f48d130d2..c98b6137c1fd39fb12d7d5e97dc0993560a79ca8 100644 (file)
@@ -368,14 +368,6 @@ int qemuGetDomainHupageMemPath(virQEMUDriver *driver,
                                unsigned long long pagesize,
                                char **memPath);
 
-int qemuGetMemoryBackingDomainPath(virQEMUDriver *driver,
-                                   const virDomainDef *def,
-                                   char **path);
-int qemuGetMemoryBackingPath(virQEMUDriver *driver,
-                             const virDomainDef *def,
-                             const char *alias,
-                             char **memPath);
-
 int qemuHugepageMakeBasedir(virQEMUDriver *driver,
                             virHugeTLBFS *hugepage);
 
index ed305d9427f5cce1eb26e8bef6312b204e773057..cd891fd58f52b423c43149607624fb25d01437b9 100644 (file)
@@ -1735,6 +1735,64 @@ qemuDomainSecretPrepare(virQEMUDriver *driver,
 }
 
 
+int
+qemuGetMemoryBackingDomainPath(virQEMUDriver *driver,
+                               const virDomainDef *def,
+                               char **path)
+{
+    g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
+    const char *root = driver->embeddedRoot;
+    g_autofree char *shortName = NULL;
+
+    if (!(shortName = virDomainDefGetShortName(def)))
+        return -1;
+
+    if (root && !STRPREFIX(cfg->memoryBackingDir, root)) {
+        g_autofree char * hash = virDomainDriverGenerateRootHash("qemu", root);
+        *path = g_strdup_printf("%s/%s-%s", cfg->memoryBackingDir, hash, shortName);
+    } else {
+        *path = g_strdup_printf("%s/%s", cfg->memoryBackingDir, shortName);
+    }
+
+    return 0;
+}
+
+
+/**
+ * qemuGetMemoryBackingPath:
+ * @driver: the qemu driver
+ * @def: domain definition
+ * @alias: memory object alias
+ * @memPath: constructed path
+ *
+ * Constructs path to memory backing dir and stores it at @memPath.
+ *
+ * Returns: 0 on success,
+ *          -1 otherwise (with error reported).
+ */
+int
+qemuGetMemoryBackingPath(virQEMUDriver *driver,
+                         const virDomainDef *def,
+                         const char *alias,
+                         char **memPath)
+{
+    g_autofree char *domainPath = NULL;
+
+    if (!alias) {
+        /* This should never happen (TM) */
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("memory device alias is not assigned"));
+        return -1;
+    }
+
+    if (qemuGetMemoryBackingDomainPath(driver, def, &domainPath) < 0)
+        return -1;
+
+    *memPath = g_strdup_printf("%s/%s", domainPath, alias);
+    return 0;
+}
+
+
 /* This is the old way of setting up per-domain directories */
 static void
 qemuDomainSetPrivatePathsOld(virQEMUDriver *driver,
index d799f6c086761f7615fbfbc9159b87475cacc1c4..9d897b761e3ae06206432116d338f401d199d543 100644 (file)
@@ -936,6 +936,15 @@ void qemuDomainCleanupStorageSourceFD(virStorageSource *src);
 
 void qemuDomainStartupCleanup(virDomainObj *vm);
 
+int qemuGetMemoryBackingDomainPath(virQEMUDriver *driver,
+                                   const virDomainDef *def,
+                                   char **path);
+
+int qemuGetMemoryBackingPath(virQEMUDriver *driver,
+                             const virDomainDef *def,
+                             const char *alias,
+                             char **memPath);
+
 int qemuDomainSecretPrepare(virQEMUDriver *driver,
                             virDomainObj *vm)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);