]> xenbits.xensource.com Git - libvirt.git/commitdiff
storage: netfs and iscsi need option srcSpec for resource discovery
authorGuannan Ren <gren@redhat.com>
Tue, 31 Jul 2012 08:56:41 +0000 (16:56 +0800)
committerGuannan Ren <gren@redhat.com>
Thu, 2 Aug 2012 03:06:02 +0000 (11:06 +0800)
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.

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

after:
error: pool type 'iscsi' requires option --srcSpec for source discovery

src/remote/remote_driver.c
src/storage/storage_backend_fs.c
src/storage/storage_backend_iscsi.c

index 9ac27b2e07dc5a76a9e39672704dec48abfe84fa..9354cb4d12a58629b2f4179af852f1060198c20b 100644 (file)
@@ -2648,23 +2648,11 @@ remoteFindStoragePoolSources (virConnectPtr conn,
     remote_find_storage_pool_sources_args args;
     remote_find_storage_pool_sources_ret ret;
     struct private_data *priv = conn->storagePrivateData;
-    const char *emptyString = "";
 
     remoteDriverLock(priv);
 
     args.type = (char*)type;
-    /*
-     * I'd think the following would work here:
-     *    args.srcSpec = (char**)&srcSpec;
-     * since srcSpec is a remote_string (not a remote_nonnull_string).
-     *
-     * But when srcSpec is NULL, this yields:
-     *    libvir: Remote error : marshaling args
-     *
-     * So for now I'm working around this by turning NULL srcSpecs
-     * into empty strings.
-     */
-    args.srcSpec = srcSpec ? (char **)&srcSpec : (char **)&emptyString;
+    args.srcSpec = srcSpec ? (char **)&srcSpec : NULL;
     args.flags = flags;
 
     memset (&ret, 0, sizeof(ret));
index 01b517ae2d8ecdbcfd598fa2a3db41803abce9ee..92a322810d2aa9573f3bc131b81f954a3c58ae79 100644 (file)
@@ -258,10 +258,15 @@ virStorageBackendFileSystemNetFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSE
 
     virCheckFlags(0, NULL);
 
-    source = virStoragePoolDefParseSourceString(srcSpec,
-                                                VIR_STORAGE_POOL_NETFS);
-    if (!source)
-        goto cleanup;
+    if (!srcSpec) {
+        virReportError(VIR_ERR_INVALID_ARG,
+                       "%s", _("hostname must be specified for netfs sources"));
+        return NULL;
+    }
+
+    if (!(source = virStoragePoolDefParseSourceString(srcSpec,
+                                                      VIR_STORAGE_POOL_NETFS)))
+        return NULL;
 
     if (source->nhost != 1) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
index b2f0c6c91b4a2f47205a3af5cd34fbd1d8c05530..75c2e52da1205851a3d15daf780ec92e3df78b8b 100644 (file)
@@ -582,6 +582,13 @@ virStorageBackendISCSIFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSED,
 
     virCheckFlags(0, NULL);
 
+    if (!srcSpec) {
+        virReportError(VIR_ERR_INVALID_ARG,
+                       "%s", _("hostname and device path "
+                               "must be specified for iscsi sources"));
+        return NULL;
+    }
+
     if (!(source = virStoragePoolDefParseSourceString(srcSpec,
                                                       list.type)))
         return NULL;