If neither BLKID or PARTED is available and we're not writing, then
just return 0 which allows the underlying storage pool to generate
a failur. If both are unavailable and we're writing, then generate
a more generic error message.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/storage/storage_backend.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index 18433e9..6bdfbf1 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -2842,9 +2842,6 @@ virStorageBackendBLKIDFindEmpty(const char *device
ATTRIBUTE_UNUSED,
const char *format ATTRIBUTE_UNUSED,
bool writelabel ATTRIBUTE_UNUSED)
{
- virReportError(VIR_ERR_OPERATION_INVALID, "%s",
- _("probing for filesystems is unsupported "
- "by this build"));
return -2;
}
@@ -2868,11 +2865,10 @@ virStorageBackendPARTEDValidLabel(const char *device
ATTRIBUTE_UNUSED,
const char *format ATTRIBUTE_UNUSED,
bool writelabel ATTRIBUTE_UNUSED)
{
- virReportError(VIR_ERR_OPERATION_INVALID, "%s",
- _("PARTED is unsupported by this build"));
- return -1;
+ return -2;
}
+
#endif /* #if WITH_STORAGE_DISK */
@@ -2898,5 +2894,17 @@ virStorageBackendDeviceIsEmpty(const char *devpath,
writelabel)) == -2)
ret = virStorageBackendPARTEDValidLabel(devpath, format, writelabel);
+ /* Neither BLKID nor PARTED available, but we're not writing,
+ * so no mechanism to check, so allow a lower layer to reject. */
+ if (ret == -2 && !writelabel)
+ return 0;
+
+ if (ret == -2) {
+ virReportError(VIR_ERR_OPERATION_INVALID,
+ _("Unable to probe '%s' for existing data, "
+ "requires create/build using overwrite"),
+ devpath);
+ }
+
return ret == 0;
}
--
2.7.4