storage: netfs: Handle backend errors

Commit id '18642d10' caused a virt-test regression for NFS backend
storage error path checks when running the command:

    'virsh find-storage-pool-sources-as netfs Unknown  '

when the host did not have Gluster installed. Prior to the commit,
the test would fail with the error:

    error: internal error: Child process (/usr/sbin/showmount --no-headers
    --exports Unknown) unexpected exit status 1: clnt_create: RPC: Unknown host

After the commit, the error would be ignored, the call would succeed,
and an empty list of pool sources returned. This was tucked into the
commit message as an expected outcome.

When the target host does not have a GLUSTER_CLI this is a regression
over the previous release. Furthermore, even if Gluster CLI was present,
but had a failure to get devices, the API would return a failure even if
the NFS backend had found devices.

Modify the logic to return failure when the NFS backend check fails and
there's no GLUSTER_CLI or when both backend checks fail.

If either returns success and GLUSTER_CLI is defined, then fetch and return
a list of source devices even if it's empty
This commit is contained in:
John Ferlan 2014-04-09 12:17:39 -04:00
parent 8fb446754d
commit 4090e15399

View File

@ -234,9 +234,11 @@ virStorageBackendFileSystemNetFindPoolSourcesFunc(char **const groups,
}
static void
static int
virStorageBackendFileSystemNetFindNFSPoolSources(virNetfsDiscoverState *state)
{
int ret = -1;
/*
* # showmount --no-headers -e HOSTNAME
* /tmp *
@ -263,9 +265,13 @@ virStorageBackendFileSystemNetFindNFSPoolSources(virNetfsDiscoverState *state)
if (virCommandRunRegex(cmd, 1, regexes, vars,
virStorageBackendFileSystemNetFindPoolSourcesFunc,
state, NULL) < 0)
virResetLastError();
goto cleanup;
ret = 0;
cleanup:
virCommandFree(cmd);
return ret;
}
@ -285,6 +291,7 @@ virStorageBackendFileSystemNetFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSE
virStoragePoolSourcePtr source = NULL;
char *ret = NULL;
size_t i;
int retNFS = -1, retGluster = -1;
virCheckFlags(0, NULL);
@ -306,11 +313,16 @@ virStorageBackendFileSystemNetFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSE
state.host = source->hosts[0].name;
virStorageBackendFileSystemNetFindNFSPoolSources(&state);
retNFS = virStorageBackendFileSystemNetFindNFSPoolSources(&state);
if (virStorageBackendFindGlusterPoolSources(state.host,
# ifdef GLUSTER_CLI
retGluster =
virStorageBackendFindGlusterPoolSources(state.host,
VIR_STORAGE_POOL_NETFS_GLUSTERFS,
&state.list) < 0)
&state.list);
# endif
/* If both fail, then we won't return an empty list - return an error */
if (retNFS < 0 && retGluster < 0)
goto cleanup;
if (!(ret = virStoragePoolSourceListFormat(&state.list)))