]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Use per-domain private memoryBackingDir for new memory backends
authorMartin Kletzander <mkletzan@redhat.com>
Wed, 18 Sep 2024 08:46:47 +0000 (10:46 +0200)
committerMartin Kletzander <mkletzan@redhat.com>
Tue, 24 Sep 2024 08:12:08 +0000 (10:12 +0200)
The function qemuGetMemoryBackingPath() does not need the @def any more
and priv->memoryBackingDir can be used instead of constructing the path
by calling qemuGetMemoryBackingDomainPath().

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_command.c
src/qemu/qemu_domain.c
src/qemu/qemu_domain.h
src/qemu/qemu_process.c

index f36b02b76b351314fc3103535fe02cff7c45a032..167ee8240b2293f898da99397d34b7558a731719 100644 (file)
@@ -3222,7 +3222,7 @@ qemuBuildMemoryBackendProps(virJSONValue **backendProps,
         } else {
             /* We can have both pagesize and mem source. If that's the case,
              * prefer hugepages as those are more specific. */
-            if (qemuGetMemoryBackingPath(priv, def, mem->info.alias, &memPath) < 0)
+            if (qemuGetMemoryBackingPath(priv, mem->info.alias, &memPath) < 0)
                 return -1;
         }
 
@@ -7116,7 +7116,7 @@ qemuBuildMemPathStr(const virDomainDef *def,
             return -1;
         prealloc = true;
     } else if (def->mem.source == VIR_DOMAIN_MEMORY_SOURCE_FILE) {
-        if (qemuGetMemoryBackingPath(priv, def, "ram", &mem_path) < 0)
+        if (qemuGetMemoryBackingPath(priv, "ram", &mem_path) < 0)
             return -1;
     }
 
index b05b1c9647a8098df0fd68ee0ab96e1c6e300f1c..3e80313ab7488ce44d6160522d2711617f79b989 100644 (file)
@@ -1762,7 +1762,6 @@ qemuGetMemoryBackingDomainPath(qemuDomainObjPrivate *priv,
 /**
  * qemuGetMemoryBackingPath:
  * @priv: domain private data
- * @def: domain definition
  * @alias: memory object alias
  * @memPath: constructed path
  *
@@ -1773,12 +1772,9 @@ qemuGetMemoryBackingDomainPath(qemuDomainObjPrivate *priv,
  */
 int
 qemuGetMemoryBackingPath(qemuDomainObjPrivate *priv,
-                         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",
@@ -1786,10 +1782,8 @@ qemuGetMemoryBackingPath(qemuDomainObjPrivate *priv,
         return -1;
     }
 
-    if (qemuGetMemoryBackingDomainPath(priv, def, &domainPath) < 0)
-        return -1;
+    *memPath = g_strdup_printf("%s/%s", priv->memoryBackingDir, alias);
 
-    *memPath = g_strdup_printf("%s/%s", domainPath, alias);
     return 0;
 }
 
index 8f41c4af81c0ea38dd88dc031f00ea3e5f98512c..dcff4272b86916247fcb8f522c6873ec726e1407 100644 (file)
@@ -944,7 +944,6 @@ int qemuGetMemoryBackingDomainPath(qemuDomainObjPrivate *priv,
                                    char **path);
 
 int qemuGetMemoryBackingPath(qemuDomainObjPrivate *priv,
-                             const virDomainDef *def,
                              const char *alias,
                              char **memPath);
 
index 1d3a905dd854653988a4f950e1605321e9b0b955..dd3afbeb39ac94d6b3c95d47dff51a35b85860ac 100644 (file)
@@ -4094,12 +4094,9 @@ qemuProcessBuildDestroyMemoryPaths(virQEMUDriver *driver,
     }
 
     if (!build || shouldBuildMB) {
-        g_autofree char *path = NULL;
-        if (qemuGetMemoryBackingDomainPath(QEMU_DOMAIN_PRIVATE(vm), vm->def, &path) < 0)
-            return -1;
-
         if (qemuProcessBuildDestroyMemoryPathsImpl(driver, vm,
-                                                   path, build) < 0)
+                                                   QEMU_DOMAIN_PRIVATE(vm)->memoryBackingDir,
+                                                   build) < 0)
             return -1;
     }
 
@@ -4113,7 +4110,7 @@ qemuProcessDestroyMemoryBackingPath(virDomainObj *vm,
 {
     g_autofree char *path = NULL;
 
-    if (qemuGetMemoryBackingPath(QEMU_DOMAIN_PRIVATE(vm), vm->def, mem->info.alias, &path) < 0)
+    if (qemuGetMemoryBackingPath(QEMU_DOMAIN_PRIVATE(vm), mem->info.alias, &path) < 0)
         return -1;
 
     if (unlink(path) < 0 &&