On 12/03/2015 09:35 AM, Matthias Gatto wrote: > Add a new function which return true if a virStorageSourcePtr is > a RAID. > > For now, quorum is the only RAID we have. > > This function is usefull, because, a lot of code access directly > to a virStorageSource internal member (like path) with some functions > like "virDomainDiskGetSource". > This beavious won't work with Quorum, and so we need to add > exeptions for these functions, but I'm not convinced by the idea to add a lot > of "disk->format == QUORUM" in all the code that deserve > exeption for Quorum, so I've add a generic function for this. > > Signed-off-by: Matthias Gatto <matthias.gatto@xxxxxxxxxxxx> > --- > src/libvirt_private.syms | 1 + > src/util/virstoragefile.c | 27 +++++++++++++++++++++++++++ > src/util/virstoragefile.h | 2 ++ > 3 files changed, 30 insertions(+) > > diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms > index d3baee8..571b6f7 100644 > --- a/src/libvirt_private.syms > +++ b/src/libvirt_private.syms > @@ -2195,6 +2195,7 @@ virStorageSourceGetSecurityLabelDef; > virStorageSourceInitChainElement; > virStorageSourceIsEmpty; > virStorageSourceIsLocalStorage; > +virStorageSourceIsRAID; > virStorageSourceNewFromBacking; > virStorageSourceParseRBDColonString; > virStorageSourcePoolDefFree; > diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c > index 8c05786..0d27ca6 100644 > --- a/src/util/virstoragefile.c > +++ b/src/util/virstoragefile.c > @@ -1808,6 +1808,33 @@ virStorageSourcePoolDefCopy(const virStorageSourcePoolDef *src) > return NULL; > } > > +/** > + * virStorageSourceIsRAID: > + * return true if the backingStores field inside @src is use > + * as a child of a contener > + */ > +bool virStorageSourceIsRAID(virStorageSourcePtr src) > +{ > + virStorageType type; > + > + if (!src) > + return false; > + type = virStorageSourceGetActualType(src); > + switch (type) { > + case VIR_STORAGE_TYPE_NONE: > + case VIR_STORAGE_TYPE_FILE: > + case VIR_STORAGE_TYPE_BLOCK: > + case VIR_STORAGE_TYPE_DIR: > + case VIR_STORAGE_TYPE_NETWORK: > + case VIR_STORAGE_TYPE_VOLUME: > + case VIR_STORAGE_TYPE_LAST: > + return false; > + > + case VIR_STORAGE_TYPE_QUORUM: This isn't defined until patch 7... John I'm going to stop here, but since I saw this as well I figured I'd note it. Each patch needs to be compilable and bisectable. > + return true; > + } > + return false; > +} > > /** > * virStorageSourceGetBackingStore: > diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h > index 290c20f..68a21d0 100644 > --- a/src/util/virstoragefile.h > +++ b/src/util/virstoragefile.h > @@ -290,6 +290,8 @@ struct _virStorageSource { > # define DEV_BSIZE 512 > # endif > > +bool virStorageSourceIsRAID(virStorageSourcePtr src); > + > int virStorageSourceSetBackingStore(virStorageSourcePtr src, > virStorageSourcePtr backingStore, > size_t pos); > -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list