#include <config.h>
+#include <sys/time.h>
+
#include "internal.h"
#include "moment_conf.h"
#include "domain_conf.h"
#include "virlog.h"
#include "viralloc.h"
+#include "virstring.h"
#define VIR_FROM_THIS VIR_FROM_DOMAIN
VIR_FREE(def->parent);
virDomainDefFree(def->dom);
}
+
+/* Provide defaults for creation time and moment name after parsing XML */
+int
+virDomainMomentDefPostParse(virDomainMomentDefPtr def)
+{
+ struct timeval tv;
+
+ gettimeofday(&tv, NULL);
+
+ if (!def->name &&
+ virAsprintf(&def->name, "%lld", (long long)tv.tv_sec) < 0)
+ return -1;
+
+ def->creationTime = tv.tv_sec;
+ return 0;
+}
#include <fcntl.h>
#include <sys/stat.h>
-#include <sys/time.h>
#include <unistd.h>
#include "internal.h"
size_t i;
int n;
char *creation = NULL, *state = NULL;
- struct timeval tv;
int active;
char *tmp;
char *memorySnapshot = NULL;
if (VIR_ALLOC(def) < 0)
goto cleanup;
- gettimeofday(&tv, NULL);
-
def->common.name = virXPathString("string(./name)", ctxt);
if (def->common.name == NULL) {
if (flags & VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE) {
_("a redefined snapshot must have a name"));
goto cleanup;
}
- if (virAsprintf(&def->common.name, "%lld", (long long)tv.tv_sec) < 0)
- goto cleanup;
}
def->common.description = virXPathString("string(./description)", ctxt);
} else {
VIR_WARN("parsing older snapshot that lacks domain");
}
- } else {
- def->common.creationTime = tv.tv_sec;
+ } else if (virDomainMomentDefPostParse(&def->common) < 0) {
+ goto cleanup;
}
memorySnapshot = virXPathString("string(./memory/@snapshot)", ctxt);