[libvirt] [PATCH 2/2] qemu: Use same create/define overwrite logic for migration prepare.

Daniel P. Berrange berrange at redhat.com
Mon Nov 9 11:00:02 UTC 2009


On Fri, Nov 06, 2009 at 02:26:04PM +0100, Daniel Veillard wrote:
> On Wed, Nov 04, 2009 at 03:06:59PM -0500, Cole Robinson wrote:
> > 
> > Signed-off-by: Cole Robinson <crobinso at 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

Yes that is the correct behaviour - if the admin renames the guest on B,
then they should either undefine its config on A, or rename it on A too.


Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|




More information about the libvir-list mailing list