提交 fdda3760 编写于 作者: J John Ferlan

storage: Prior to creating a volume, refresh the pool

https://bugzilla.redhat.com/show_bug.cgi?id=1233003

Although perhaps bordering on a don't do that type scenario, if
someone creates a volume in a pool outside of libvirt, then uses that
same name to create a volume in the pool via libvirt, then the creation
will fail and in some cases cause the same name volume to be deleted.

This patch will refresh the pool just prior to checking whether the
named volume exists prior to creating the volume in the pool. While
it's still possible to have a timing window to create a file after the
check - at least we tried.  At that point, someone is being malicious.
上级 cb19cff4
...@@ -1796,6 +1796,15 @@ storageVolCreateXML(virStoragePoolPtr obj, ...@@ -1796,6 +1796,15 @@ storageVolCreateXML(virStoragePoolPtr obj,
if (virStorageVolCreateXMLEnsureACL(obj->conn, pool->def, voldef) < 0) if (virStorageVolCreateXMLEnsureACL(obj->conn, pool->def, voldef) < 0)
goto cleanup; goto cleanup;
/* While not perfect, refresh the list of volumes in the pool and
* then check that the incoming name isn't already in the pool.
*/
if (backend->refreshPool) {
virStoragePoolObjClearVols(pool);
if (backend->refreshPool(obj->conn, pool) < 0)
goto cleanup;
}
if (virStorageVolDefFindByName(pool, voldef->name)) { if (virStorageVolDefFindByName(pool, voldef->name)) {
virReportError(VIR_ERR_STORAGE_VOL_EXIST, virReportError(VIR_ERR_STORAGE_VOL_EXIST,
_("'%s'"), voldef->name); _("'%s'"), voldef->name);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册