On Mon, Nov 26, 2012 at 06:21:42PM +0800, Osier Yang wrote: > This prevent the domain starting if the shared disk's setting conflicts > with other active domain(s), E.g. A domain with unpriv_sgio set as > "yes", however, another active domain is using it set as "no". > --- > src/conf/domain_conf.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ > src/conf/domain_conf.h | 3 +++ > src/libvirt_private.syms | 1 + > src/qemu/qemu_process.c | 14 +++++++++++++- > 4 files changed, 62 insertions(+), 1 deletions(-) > > diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c > index 02df96e..fb7bb1f 100644 > --- a/src/conf/domain_conf.c > +++ b/src/conf/domain_conf.c > @@ -15763,3 +15763,48 @@ virDomainDiskIsUsed(const virDomainObjList doms, > > return false; > } > + > +static int > +virDomainSharedDiskCompare(const void *payload, > + const void *name ATTRIBUTE_UNUSED, > + const void *opaque) > +{ > + virDomainObjPtr obj = (virDomainObjPtr)payload; > + const virDomainDiskDefPtr disk = (virDomainDiskDefPtr)opaque; > + int i; > + > + virDomainObjLock(obj); > + > + /* Ingores the inactive ones */ > + if (!virDomainObjIsActive(obj)) > + return 0; > + > + for (i = 0; i < obj->def->ndisks; i++) { > + if (STRNEQ(obj->def->disks[i]->src, disk->src)) > + continue; > + > + if (obj->def->disks[i]->unpriv_sgio != disk->unpriv_sgio) { > + virDomainObjUnlock(obj); > + return 1; > + } > + } > + > + virDomainObjUnlock(obj); > + return 0; > +} > + > +/* Validate if the shared disk conf is conflicted with other domains, > + * currently only validates the unpriv_sgio setting > + */ > +bool > +virDomainSharedDiskValidate(const virDomainObjList doms, > + const virDomainDiskDefPtr disk) > +{ > + virDomainObjPtr obj; > + > + obj = virHashSearch(doms.objs, virDomainSharedDiskCompare, disk); > + if (obj) > + return false; > + > + return true; > +} This code is rather undesirable since it requires locking every single VM known to the QEMU driver. Better to use the model we have for PCI/USB devices where the driver maintains a central list of the devices Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list