提交 3b0acf56 编写于 作者: D Daniel P. Berrange

Allow overwrite of existing guest config

上级 f58ac222
Mon May 21 20:38:00 EST 2007 Daniel P. Berrange <berrange@redhat.com>
* src/xm_internal.c: Allow xenXMDomainDefineXML to overwrite
an existing guest config to match semantics of XenD and QEMU
drivers. Patch from Hugh Brock.
Fri May 18 14:36:00 EST 2007 Daniel P. Berrange <berrange@redhat.com>
* qemud/conf.c, qemud/internal.h, qemud/qemud.c: Save VM output
......
......@@ -2072,7 +2072,9 @@ virConfPtr xenXMParseXMLToConfig(virConnectPtr conn, const char *xml) {
*/
virDomainPtr xenXMDomainDefineXML(virConnectPtr conn, const char *xml) {
virDomainPtr ret;
virDomainPtr olddomain;
char filename[PATH_MAX];
const char * oldfilename;
unsigned char uuid[VIR_UUID_BUFLEN];
virConfPtr conf = NULL;
xenXMConfCachePtr entry = NULL;
......@@ -2103,8 +2105,39 @@ virDomainPtr xenXMDomainDefineXML(virConnectPtr conn, const char *xml) {
}
if (virHashLookup(nameConfigMap, value->str)) {
xenXMError(conn, VIR_ERR_INTERNAL_ERROR, "domain with name already exists");
goto error;
/* domain exists, we will overwrite it */
if (!(oldfilename = (char *)virHashLookup(nameConfigMap, value->str))) {
xenXMError(conn, VIR_ERR_INTERNAL_ERROR, "can't retrieve config filename for domain to overwrite");
goto error;
}
if (!(entry = virHashLookup(configCache, oldfilename))) {
xenXMError(conn, VIR_ERR_INTERNAL_ERROR, "can't retrieve config entry for domain to overwrite");
goto error;
}
if (xenXMConfigGetUUID(entry->conf, "uuid", uuid) < 0) {
xenXMError(conn, VIR_ERR_INTERNAL_ERROR, "uuid config parameter is missing");
goto error;
}
if (!(olddomain = virGetDomain(conn, value->str, uuid)))
goto error;
/* Remove the name -> filename mapping */
if (virHashRemoveEntry(nameConfigMap, value->str, NULL) < 0) {
xenXMError(conn, VIR_ERR_INTERNAL_ERROR, "failed to remove old domain from config map");
goto error;
}
/* Remove the config record itself */
if (virHashRemoveEntry(configCache, oldfilename, xenXMConfigFree) < 0) {
xenXMError(conn, VIR_ERR_INTERNAL_ERROR, "failed to remove old domain from config map");
goto error;
}
entry = NULL;
}
if ((strlen(configDir) + 1 + strlen(value->str) + 1) > PATH_MAX) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册