On 2012年07月18日 18:26, Guannan Ren wrote:
The option 'srcSpec' to virsh command
find-storage-pool-sources
s/to/of/
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
s/and/or/
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:
s/changed/is changed/
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..8486fdf 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 ||
Is "srcSpec" guaranteed not NULL? it will cause libvird to crash if not.
+ backend_type ==
VIR_STORAGE_POOL_NETFS)) {
+ virStorageReportError(VIR_ERR_INTERNAL_ERROR,
+ _("pool type '%s' needs option --srcSpec
"
+ "for source discovery"), type);
It should be changed to virReportError now.
+ goto cleanup;
+ }
+
The checking should be in virStoragePoolDefParseSourceString instead.
And it should error out regardless of the pool type. Any use of
the function will get error if srcSpec is NULL. Logical backend
doesn't get the error just because of it doesn't use it.
Regards,
Osier