mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
util: Add function to check if a virStorageSource is "empty"
To express empty drive we historically use storage source with empty path. Unfortunately NBD disks may be declared without a path. Add a helper to wrap this logic.
This commit is contained in:
parent
3c07693aa2
commit
5e3e991928
@ -1941,6 +1941,7 @@ virStorageSourceFree;
|
||||
virStorageSourceGetActualType;
|
||||
virStorageSourceGetSecurityLabelDef;
|
||||
virStorageSourceInitChainElement;
|
||||
virStorageSourceIsEmpty;
|
||||
virStorageSourceIsLocalStorage;
|
||||
virStorageSourceNewFromBacking;
|
||||
virStorageSourcePoolDefFree;
|
||||
|
@ -1975,6 +1975,27 @@ virStorageSourceIsLocalStorage(virStorageSourcePtr src)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* virStorageSourceIsEmpty:
|
||||
*
|
||||
* @src: disk source to check
|
||||
*
|
||||
* Returns true if the guest disk has no associated host storage source
|
||||
* (such as an empty cdrom drive).
|
||||
*/
|
||||
bool
|
||||
virStorageSourceIsEmpty(virStorageSourcePtr src)
|
||||
{
|
||||
if (virStorageSourceIsLocalStorage(src) && !src->path)
|
||||
return true;
|
||||
|
||||
if (src->type == VIR_STORAGE_TYPE_NONE)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* virStorageSourceBackingStoreClear:
|
||||
*
|
||||
|
@ -353,6 +353,7 @@ void virStorageSourcePoolDefFree(virStorageSourcePoolDefPtr def);
|
||||
void virStorageSourceClear(virStorageSourcePtr def);
|
||||
int virStorageSourceGetActualType(virStorageSourcePtr def);
|
||||
bool virStorageSourceIsLocalStorage(virStorageSourcePtr src);
|
||||
bool virStorageSourceIsEmpty(virStorageSourcePtr src);
|
||||
void virStorageSourceFree(virStorageSourcePtr def);
|
||||
void virStorageSourceBackingStoreClear(virStorageSourcePtr def);
|
||||
virStorageSourcePtr virStorageSourceNewFromBacking(virStorageSourcePtr parent);
|
||||
|
Loading…
x
Reference in New Issue
Block a user