[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH] storage: netfs and iscsi need option srcSpec for resource discovery



The option 'srcSpec' to virsh command find-storage-pool-sources
is optional for logical type of storage pool, but mandatory for
netfs and iscsi type.
When missing the option for netfs and iscsi, libvirt reports XML
parsing error due to null string option srcSpec.

error: Failed to find any netfs pool sources
error: (storage_source_specification):1: Document is empty
(null)

This patch adds a check for it, error info changed to:
error: Failed to find any netfs pool sources
error: internal error pool type 'netfs' need option \
       --srcSpec for source discovery
---
 src/storage/storage_driver.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index fbc630d..e5f3e1b 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -458,6 +458,14 @@ storageFindPoolSources(virConnectPtr conn,
         goto cleanup;
     }
 
+    if ((*srcSpec == '\0') && (backend_type == VIR_STORAGE_POOL_ISCSI ||
+                               backend_type == VIR_STORAGE_POOL_NETFS)) {
+        virStorageReportError(VIR_ERR_INTERNAL_ERROR,
+                              _("pool type '%s' need option --srcSpec "
+                                "for source discovery"), type);
+        goto cleanup;
+    }
+
     ret = backend->findPoolSources(conn, srcSpec, flags);
 
 cleanup:
-- 
1.7.7.5


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]