On Mon, Feb 16, 2026 at 11:23:10 +0100, Michal Privoznik wrote:
> From: Michal Privoznik <[email protected]>
> 
> Adding a storage volume into a pool is done by calling
> virStoragePoolObjAddVol(). This function may fail if another
> volume already exists with the same key/name/target. In some
> cases the storage driver does check for duplicates before calling
> the function. But in some cases (e.g. when refreshing an RBD pool
> in virStorageBackendRBDRefreshPool()) it doesn't.
> 
> The problem here is that the function reports no error upon
> failure and leaves it as an exercise for caller. Well, no caller
> does that.
> 
> Therefore, make the function report an error. The advantage of
> this approach is - the function can report more accurate error
> message than any caller ever could.
> 
> NB¸ this stems from a discussion on the users list [1], and while
> this does NOT solve the original issue, it fixes one of the
> symptoms.
> 
> 1: 
> https://lists.libvirt.org/archives/list/[email protected]/message/BALVNCRQM4KBKGV4RQ7BMKSX7UIJKLQH/
> Signed-off-by: Michal Privoznik <[email protected]>
> ---
> 
> This can be very easily reproduced with test driver. No need for ceph.
> Just duplicate a volume in a custom test driver XML.
> 
> Before this patch you'd get:
> 
> error: failed to connect to the hypervisor
> error: An error occurred, but the cause is unknown
> 
> After:
> 
> error: failed to connect to the hypervisor
> error: operation failed: volume with target path 
> '/dev/disk/by-path/pci-0000:00:17.0-ata-30' already exist
> 
>  src/conf/virstorageobj.c | 45 +++++++++++++++++++++++++++++++++-------
>  1 file changed, 37 insertions(+), 8 deletions(-)

Reviewed-by: Jiri Denemark <[email protected]>

Reply via email to