mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-24 06:03:52 +03:00
virDomainSnapshotDefParse: Avoid 'memoryfile' temporary variable
Assign directly into the definition. The cleanup code can deal with that. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
12b85a3611
commit
8a5a096d72
@ -221,7 +221,6 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
|
|||||||
size_t i;
|
size_t i;
|
||||||
int n;
|
int n;
|
||||||
g_autofree char *memorySnapshot = NULL;
|
g_autofree char *memorySnapshot = NULL;
|
||||||
g_autofree char *memoryFile = NULL;
|
|
||||||
bool offline = !!(flags & VIR_DOMAIN_SNAPSHOT_PARSE_OFFLINE);
|
bool offline = !!(flags & VIR_DOMAIN_SNAPSHOT_PARSE_OFFLINE);
|
||||||
virSaveCookieCallbacks *saveCookie = virDomainXMLOptionGetSaveCookie(xmlopt);
|
virSaveCookieCallbacks *saveCookie = virDomainXMLOptionGetSaveCookie(xmlopt);
|
||||||
int domainflags = VIR_DOMAIN_DEF_PARSE_INACTIVE |
|
int domainflags = VIR_DOMAIN_DEF_PARSE_INACTIVE |
|
||||||
@ -309,7 +308,7 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
|
|||||||
}
|
}
|
||||||
|
|
||||||
memorySnapshot = virXPathString("string(./memory/@snapshot)", ctxt);
|
memorySnapshot = virXPathString("string(./memory/@snapshot)", ctxt);
|
||||||
memoryFile = virXPathString("string(./memory/@file)", ctxt);
|
def->memorysnapshotfile = virXPathString("string(./memory/@file)", ctxt);
|
||||||
if (memorySnapshot) {
|
if (memorySnapshot) {
|
||||||
def->memory = virDomainSnapshotLocationTypeFromString(memorySnapshot);
|
def->memory = virDomainSnapshotLocationTypeFromString(memorySnapshot);
|
||||||
if (def->memory <= 0) {
|
if (def->memory <= 0) {
|
||||||
@ -318,20 +317,20 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
|
|||||||
memorySnapshot);
|
memorySnapshot);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (memoryFile &&
|
if (def->memorysnapshotfile &&
|
||||||
def->memory != VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) {
|
def->memory != VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) {
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
virReportError(VIR_ERR_XML_ERROR,
|
||||||
_("memory filename '%s' requires external snapshot"),
|
_("memory filename '%s' requires external snapshot"),
|
||||||
memoryFile);
|
def->memorysnapshotfile);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!memoryFile &&
|
if (!def->memorysnapshotfile &&
|
||||||
def->memory == VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) {
|
def->memory == VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) {
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
_("external memory snapshots require a filename"));
|
_("external memory snapshots require a filename"));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
} else if (memoryFile) {
|
} else if (def->memorysnapshotfile) {
|
||||||
def->memory = VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL;
|
def->memory = VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL;
|
||||||
} else if (flags & VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE) {
|
} else if (flags & VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE) {
|
||||||
def->memory = (offline ?
|
def->memory = (offline ?
|
||||||
@ -345,7 +344,6 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
|
|||||||
"disk-only snapshot"));
|
"disk-only snapshot"));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
def->memorysnapshotfile = g_steal_pointer(&memoryFile);
|
|
||||||
|
|
||||||
/* verify that memory path is absolute */
|
/* verify that memory path is absolute */
|
||||||
if (def->memorysnapshotfile && !g_path_is_absolute(def->memorysnapshotfile)) {
|
if (def->memorysnapshotfile && !g_path_is_absolute(def->memorysnapshotfile)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user