
On Wed, Nov 04, 2009 at 03:06:59PM -0500, Cole Robinson wrote:
Signed-off-by: Cole Robinson <crobinso@redhat.com> --- src/qemu/qemu_driver.c | 30 ++++-------------------------- 1 files changed, 4 insertions(+), 26 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 20621d1..53f7398 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5978,19 +5978,8 @@ qemudDomainMigratePrepareTunnel(virConnectPtr dconn, /* Target domain name, maybe renamed. */ dname = dname ? dname : def->name;
- /* Ensure the name and UUID don't already exist in an active VM */ - vm = virDomainFindByUUID(&driver->domains, def->uuid); - - if (!vm) vm = virDomainFindByName(&driver->domains, dname); - if (vm) { - if (virDomainObjIsActive(vm)) { - qemudReportError(dconn, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _("domain with the same name or UUID already exists as '%s'"), - vm->def->name); - goto cleanup; - } - virDomainObjUnlock(vm); - } + if (virDomainObjIsDuplicate(&driver->domains, def, 1) < 0) + goto cleanup;
if (!(vm = virDomainAssignDef(dconn, driver->caps, @@ -6202,19 +6191,8 @@ qemudDomainMigratePrepare2 (virConnectPtr dconn, /* Target domain name, maybe renamed. */ dname = dname ? dname : def->name;
- /* Ensure the name and UUID don't already exist in an active VM */ - vm = virDomainFindByUUID(&driver->domains, def->uuid); - - if (!vm) vm = virDomainFindByName(&driver->domains, dname); - if (vm) { - if (virDomainObjIsActive(vm)) { - qemudReportError (dconn, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _("domain with the same name or UUID already exists as '%s'"), - vm->def->name); - goto cleanup; - } - virDomainObjUnlock(vm); - } + if (virDomainObjIsDuplicate(&driver->domains, def, 1) < 0) + goto cleanup;
if (!(vm = virDomainAssignDef(dconn, driver->caps,
Hum, there is a slight change of semantic in that case, if VM migrated from A to B, then gets renamed on B, if you try to migrate it back to A that will fail because the uuid match/name mismatch failure will be raised while this won't be the case with current code, right ? Maybe it's the right thing to do, but that's a change I think Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/