virStoragePoolPtr virStoragePoolLookupByUUIDString(virConnectPtr conn,
const char *uuid);
virStoragePoolPtr virStoragePoolLookupByVolume (virStorageVolPtr vol);
+virStoragePoolPtr virStoragePoolLookupByTargetPath(virConnectPtr conn,
+ const char *path);
/*
* Creating/destroying pools
typedef virStoragePoolPtr
(*virDrvStoragePoolLookupByVolume)(virStorageVolPtr vol);
+typedef virStoragePoolPtr
+(*virDrvStoragePoolLookupByTargetPath)(virConnectPtr conn,
+ const char *path);
+
typedef virStoragePoolPtr
(*virDrvStoragePoolCreateXML)(virConnectPtr conn,
const char *xmlDesc,
virDrvStoragePoolLookupByName storagePoolLookupByName;
virDrvStoragePoolLookupByUUID storagePoolLookupByUUID;
virDrvStoragePoolLookupByVolume storagePoolLookupByVolume;
+ virDrvStoragePoolLookupByTargetPath storagePoolLookupByTargetPath;
virDrvStoragePoolCreateXML storagePoolCreateXML;
virDrvStoragePoolDefineXML storagePoolDefineXML;
virDrvStoragePoolBuild storagePoolBuild;
}
+/**
+ * virStoragePoolLookupByTargetPath:
+ * @conn: pointer to hypervisor connection
+ * @path: path at which the pool is exposed
+ *
+ * Fetch a storage pool which maps to a particular target directory.
+ * If more than one pool maps to the path, it is undefined which
+ * will be returned first.
+ *
+ * virStoragePoolFree should be used to free the resources after the
+ * storage pool object is no longer needed.
+ *
+ * Returns a virStoragePoolPtr object, or NULL if no matching pool is found
+ */
+virStoragePoolPtr
+virStoragePoolLookupByTargetPath(virConnectPtr conn,
+ const char *path)
+{
+ VIR_DEBUG("conn=%p, path=%s", conn, NULLSTR(path));
+
+ virResetLastError();
+
+ virCheckConnectReturn(conn, NULL);
+ virCheckNonNullArgGoto(path, error);
+
+ if (conn->storageDriver && conn->storageDriver->storagePoolLookupByTargetPath) {
+ virStoragePoolPtr ret;
+ ret = conn->storageDriver->storagePoolLookupByTargetPath(conn, path);
+ if (!ret)
+ goto error;
+ return ret;
+ }
+
+ virReportUnsupportedError();
+
+ error:
+ virDispatchError(conn);
+ return NULL;
+}
+
/**
* virStoragePoolCreateXML:
* @conn: pointer to hypervisor connection
global:
virDomainSetLifecycleAction;
} LIBVIRT_3.7.0;
+
+LIBVIRT_4.1.0 {
+ global:
+ virStoragePoolLookupByTargetPath;
+} LIBVIRT_3.9.0;
+
# .... define new API here using predicted next version number ....
*volName = '\0';
volName++;
- if (!(pool = storagePoolLookupByTargetPath(conn, basePath)))
+ if (!(pool = virStoragePoolLookupByTargetPath(conn, basePath)))
goto cleanup;
format = virStorageFileFormatTypeToString(disk->src->format);
if (disk->src->format == VIR_STORAGE_FILE_QCOW2)
.storagePoolLookupByName = remoteStoragePoolLookupByName, /* 0.4.1 */
.storagePoolLookupByUUID = remoteStoragePoolLookupByUUID, /* 0.4.1 */
.storagePoolLookupByVolume = remoteStoragePoolLookupByVolume, /* 0.4.1 */
+ .storagePoolLookupByTargetPath = remoteStoragePoolLookupByTargetPath, /* 4.1.0 */
.storagePoolCreateXML = remoteStoragePoolCreateXML, /* 0.4.1 */
.storagePoolDefineXML = remoteStoragePoolDefineXML, /* 0.4.1 */
.storagePoolBuild = remoteStoragePoolBuild, /* 0.4.1 */
remote_nonnull_storage_pool pool;
};
+struct remote_storage_pool_lookup_by_target_path_args {
+ remote_nonnull_string path;
+};
+
+struct remote_storage_pool_lookup_by_target_path_ret {
+ remote_nonnull_storage_pool pool;
+};
+
struct remote_storage_pool_create_xml_args {
remote_nonnull_string xml;
unsigned int flags;
* @generate: both
* @acl: domain:write
*/
- REMOTE_PROC_DOMAIN_SET_LIFECYCLE_ACTION = 390
+ REMOTE_PROC_DOMAIN_SET_LIFECYCLE_ACTION = 390,
+
+ /**
+ * @generate: both
+ * @priority: high
+ * @acl: storage_pool:getattr
+ */
+ REMOTE_PROC_STORAGE_POOL_LOOKUP_BY_TARGET_PATH = 391
};
struct remote_storage_pool_lookup_by_volume_ret {
remote_nonnull_storage_pool pool;
};
+struct remote_storage_pool_lookup_by_target_path_args {
+ remote_nonnull_string path;
+};
+struct remote_storage_pool_lookup_by_target_path_ret {
+ remote_nonnull_storage_pool pool;
+};
struct remote_storage_pool_create_xml_args {
remote_nonnull_string xml;
u_int flags;
REMOTE_PROC_DOMAIN_MANAGED_SAVE_GET_XML_DESC = 388,
REMOTE_PROC_DOMAIN_MANAGED_SAVE_DEFINE_XML = 389,
REMOTE_PROC_DOMAIN_SET_LIFECYCLE_ACTION = 390,
+ REMOTE_PROC_STORAGE_POOL_LOOKUP_BY_TARGET_PATH = 391,
};
storagePoolLookupByTargetPathCallback,
cleanpath))) {
def = virStoragePoolObjGetDef(obj);
+ if (virStoragePoolLookupByTargetPathEnsureACL(conn, def) < 0)
+ goto cleanup;
+
pool = virGetStoragePool(conn, def->name, def->uuid, NULL, NULL);
virStoragePoolObjEndAPI(&obj);
}
}
}
+ cleanup:
VIR_FREE(cleanpath);
return pool;
}
.storagePoolLookupByName = storagePoolLookupByName, /* 0.4.0 */
.storagePoolLookupByUUID = storagePoolLookupByUUID, /* 0.4.0 */
.storagePoolLookupByVolume = storagePoolLookupByVolume, /* 0.4.0 */
+ .storagePoolLookupByTargetPath = storagePoolLookupByTargetPath, /* 4.1.0 */
.storagePoolCreateXML = storagePoolCreateXML, /* 0.4.0 */
.storagePoolDefineXML = storagePoolDefineXML, /* 0.4.0 */
.storagePoolBuild = storagePoolBuild, /* 0.4.0 */