mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 11:22:23 +00:00
storage: Introduce storagePoolLookupByTargetPath
While this could be exposed as a public API, it's not done yet as there's no demand for that yet. Anyway, this is just preparing the environment for easier volume creation on the destination. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
c8230c4ded
commit
5ab746b83a
@ -1464,6 +1464,48 @@ storageVolLookupByPath(virConnectPtr conn,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virStoragePoolPtr
|
||||||
|
storagePoolLookupByTargetPath(virConnectPtr conn,
|
||||||
|
const char *path)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
virStoragePoolPtr ret = NULL;
|
||||||
|
char *cleanpath;
|
||||||
|
|
||||||
|
cleanpath = virFileSanitizePath(path);
|
||||||
|
if (!cleanpath)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
storageDriverLock();
|
||||||
|
for (i = 0; i < driver->pools.count && !ret; i++) {
|
||||||
|
virStoragePoolObjPtr pool = driver->pools.objs[i];
|
||||||
|
|
||||||
|
virStoragePoolObjLock(pool);
|
||||||
|
|
||||||
|
if (!virStoragePoolObjIsActive(pool)) {
|
||||||
|
virStoragePoolObjUnlock(pool);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (STREQ(path, pool->def->target.path)) {
|
||||||
|
ret = virGetStoragePool(conn, pool->def->name, pool->def->uuid,
|
||||||
|
NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
virStoragePoolObjUnlock(pool);
|
||||||
|
}
|
||||||
|
storageDriverUnlock();
|
||||||
|
|
||||||
|
if (!ret) {
|
||||||
|
virReportError(VIR_ERR_NO_STORAGE_VOL,
|
||||||
|
_("no storage pool with matching target path '%s'"),
|
||||||
|
path);
|
||||||
|
}
|
||||||
|
|
||||||
|
VIR_FREE(cleanpath);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
storageVolDeleteInternal(virStorageVolPtr obj,
|
storageVolDeleteInternal(virStorageVolPtr obj,
|
||||||
|
@ -57,6 +57,11 @@ int virStorageFileGetMetadata(virStorageSourcePtr src,
|
|||||||
int virStorageTranslateDiskSourcePool(virConnectPtr conn,
|
int virStorageTranslateDiskSourcePool(virConnectPtr conn,
|
||||||
virDomainDiskDefPtr def);
|
virDomainDiskDefPtr def);
|
||||||
|
|
||||||
|
virStoragePoolPtr
|
||||||
|
storagePoolLookupByTargetPath(virConnectPtr conn,
|
||||||
|
const char *path)
|
||||||
|
ATTRIBUTE_NONNULL(2);
|
||||||
|
|
||||||
int storageRegister(void);
|
int storageRegister(void);
|
||||||
|
|
||||||
#endif /* __VIR_STORAGE_DRIVER_H__ */
|
#endif /* __VIR_STORAGE_DRIVER_H__ */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user