]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Use short domain name in qemuDomainGetPreservedMountPath
authorMartin Kletzander <mkletzan@redhat.com>
Wed, 23 Aug 2017 08:39:57 +0000 (10:39 +0200)
committerMartin Kletzander <mkletzan@redhat.com>
Tue, 29 Aug 2017 09:17:16 +0000 (11:17 +0200)
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@redhat.com>
src/qemu/qemu_domain.c

index 05bf1c7d0250bd4da3e364365e4dd1bd80a72efe..77ae450b76f9bc36c77164f819477f8e9137dee1 100644 (file)
@@ -7827,14 +7827,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
@@ -7850,6 +7854,8 @@ qemuDomainGetPreservedMountPath(virQEMUDriverConfigPtr cfg,
         tmp++;
     }
 
+ cleanup:
+    VIR_FREE(domname);
     return path;
 }