mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-30 17:45:23 +00:00
storage: Error out earlier if the volume target path already exists
https://bugzilla.redhat.com/show_bug.cgi?id=832302
It's odd to fall through to buildVol, and the existed file is
removed when buildVol fails. This checks if the volume target
path already exists in createVol. The reason for not using
error like "Volume already exists" is that there isn't volume
maintained by libvirt for the path until a operation like
pool-refresh, using error like that will just cause confusion.
(cherry picked from commit d1f3d14974
)
This commit is contained in:
parent
9774343564
commit
9b625cbcf0
@ -1006,6 +1006,13 @@ virStorageBackendFileSystemVolCreate(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (virFileExists(vol->target.path)) {
|
||||||
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||||
|
_("volume target path '%s' already exists"),
|
||||||
|
vol->target.path);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
VIR_FREE(vol->key);
|
VIR_FREE(vol->key);
|
||||||
vol->key = strdup(vol->target.path);
|
vol->key = strdup(vol->target.path);
|
||||||
if (vol->key == NULL) {
|
if (vol->key == NULL) {
|
||||||
|
Loading…
Reference in New Issue
Block a user