+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
*/
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;
}
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) {