[PATCH 2/3] qemu: Use short domain name in qemuDomainGetPreservedMountPath

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Otherwise longer domain names might generate paths that are too long
to be created.  This follows what other parts of the code do as well.

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

Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx>
---
 src/qemu/qemu_domain.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index e2531cdcfeb8..a12f31808197 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -7721,14 +7721,18 @@ qemuDomainGetPreservedMountPath(virQEMUDriverConfigPtr cfg,
     char *path = NULL;
     char *tmp;
     const char *suffix = mountpoint + strlen(DEVPREFIX);
+    char *domname = virDomainObjGetShortName(vm->def);
     size_t off;
 
+    if (!domname)
+        return NULL;
+
     if (STREQ(mountpoint, "/dev"))
         suffix = "dev";
 
     if (virAsprintf(&path, "%s/%s.%s",
-                    cfg->stateDir, vm->def->name, suffix) < 0)
-        return NULL;
+                    cfg->stateDir, domname, suffix) < 0)
+        goto cleanup;
 
     /* Now consider that @mountpoint is "/dev/blah/blah2".
      * @suffix then points to "blah/blah2". However, caller
@@ -7744,6 +7748,8 @@ qemuDomainGetPreservedMountPath(virQEMUDriverConfigPtr cfg,
         tmp++;
     }
 
+ cleanup:
+    VIR_FREE(domname);
     return path;
 }
 
-- 
2.14.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux