mirror of https://gitee.com/openkylin/libvirt.git
xen-xm: fix data loss in domain edit
On CentOS5: If "virsh edit $DOM" is used and an error happens (for example changing any live cycle action to a non-existing value), libvirt forgets that $DOM exists, since it is already removed from the internal hash tables, which are used for domain lookup. In once case (unreproducible) even the persistent configuration /etc/xen/$DOM was deleted. Instead of using the compound function xenXMConfigSaveFile() explicitly use xenFomatXM() and virConfWriteFile() to distinguish between a failure in converting the libvirt definition to the xen-xm format and a problem when writing the file. Signed-off-by: Philipp Hahn <hahn@univention.de>
This commit is contained in:
parent
c052d8a89f
commit
700102c992
|
@ -1073,6 +1073,7 @@ virDomainPtr xenXMDomainDefineXML(virConnectPtr conn, const char *xml)
|
||||||
char *filename;
|
char *filename;
|
||||||
const char *oldfilename;
|
const char *oldfilename;
|
||||||
virDomainDefPtr def = NULL;
|
virDomainDefPtr def = NULL;
|
||||||
|
virConfPtr conf = NULL;
|
||||||
xenXMConfCachePtr entry = NULL;
|
xenXMConfCachePtr entry = NULL;
|
||||||
xenUnifiedPrivatePtr priv = (xenUnifiedPrivatePtr) conn->privateData;
|
xenUnifiedPrivatePtr priv = (xenUnifiedPrivatePtr) conn->privateData;
|
||||||
|
|
||||||
|
@ -1101,6 +1102,9 @@ virDomainPtr xenXMDomainDefineXML(virConnectPtr conn, const char *xml)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!(conf = xenFormatXM(conn, def, priv->xendConfigVersion)))
|
||||||
|
goto error;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* check that if there is another domain defined with the same uuid
|
* check that if there is another domain defined with the same uuid
|
||||||
* it has the same name
|
* it has the same name
|
||||||
|
@ -1156,7 +1160,7 @@ virDomainPtr xenXMDomainDefineXML(virConnectPtr conn, const char *xml)
|
||||||
if (!(filename = virFileBuildPath(priv->configDir, def->name, NULL)))
|
if (!(filename = virFileBuildPath(priv->configDir, def->name, NULL)))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (xenXMConfigSaveFile(conn, filename, def) < 0)
|
if (virConfWriteFile(filename, conf) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (VIR_ALLOC(entry) < 0) {
|
if (VIR_ALLOC(entry) < 0) {
|
||||||
|
@ -1199,6 +1203,7 @@ virDomainPtr xenXMDomainDefineXML(virConnectPtr conn, const char *xml)
|
||||||
if (entry)
|
if (entry)
|
||||||
VIR_FREE(entry->filename);
|
VIR_FREE(entry->filename);
|
||||||
VIR_FREE(entry);
|
VIR_FREE(entry);
|
||||||
|
virConfFree(conf);
|
||||||
virDomainDefFree(def);
|
virDomainDefFree(def);
|
||||||
xenUnifiedUnlock(priv);
|
xenUnifiedUnlock(priv);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
Loading…
Reference in New Issue