]> xenbits.xensource.com Git - libvirt.git/commitdiff
Shorten domain name for automatic coredump
authorMartin Kletzander <mkletzan@redhat.com>
Tue, 26 Apr 2016 07:44:18 +0000 (09:44 +0200)
committerMartin Kletzander <mkletzan@redhat.com>
Wed, 27 Apr 2016 13:08:10 +0000 (15:08 +0200)
If the domain name is long enough, the timestamp can prolong the
filename for automatic coredump to more than the filesystem's limit.
Simply shorten it like we do in other places.  The timestamp helps with
the unification, but having the ID in the name won't hurt.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
src/qemu/qemu_driver.c

index 542d13c2ac707e3d5fd373a7099ded5d432f574b..5992492ebddc747d9fb72d9e714026e23fb0f027 100644 (file)
@@ -3965,13 +3965,17 @@ doCoreDumpToAutoDumpPath(virQEMUDriverPtr driver,
     char timestr[100];
     struct tm time_info;
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
+    char *domname = virDomainObjGetShortName(vm);
+
+    if (!domname)
+        goto cleanup;
 
     localtime_r(&curtime, &time_info);
     strftime(timestr, sizeof(timestr), "%Y-%m-%d-%H:%M:%S", &time_info);
 
     if (virAsprintf(&dumpfile, "%s/%s-%s",
                     cfg->autoDumpPath,
-                    vm->def->name,
+                    domname,
                     timestr) < 0)
         goto cleanup;
 
@@ -3984,6 +3988,7 @@ doCoreDumpToAutoDumpPath(virQEMUDriverPtr driver,
                        "%s", _("Dump failed"));
  cleanup:
     VIR_FREE(dumpfile);
+    VIR_FREE(domname);
     virObjectUnref(cfg);
     return ret;
 }