[libvirt] [PATCH] Fix pool-create for netfs format 'auto'

Trying to pool-create a netfs pool with the format type 'auto' (as in, to autodetect the format) runs the command mount -t auto munged-source-path '-t auto' seems to do its job for regular file systems, but actually fails with nfs or cifs (I assume anything that required an external mount program). Strangely though, the command mount munged-source-path will do the right thing. The attached patch fixes the generated command to work in the above case, fully removing the '-t type' piece if auto is specified for a netfs pool. I tested the intended case, as well as regular fs pools format=auto, and netfs format=nfs, and all seemed to work fine. Thanks, Cole diff --git a/src/storage_backend_fs.c b/src/storage_backend_fs.c index 9926493..f195034 100644 --- a/src/storage_backend_fs.c +++ b/src/storage_backend_fs.c @@ -487,7 +487,23 @@ static int virStorageBackendFileSystemMount(virConnectPtr conn, virStoragePoolObjPtr pool) { char *src; - const char *mntargv[] = { + const char **mntargv; + + /* 'mount -t auto' doesn't seem to auto determine nfs (or cifs), + * while plain 'mount' does. We have to craft separate argvs to + * accommodate this */ + int netauto = (pool->def->type == VIR_STORAGE_POOL_NETFS && + pool->def->source.format == VIR_STORAGE_POOL_NETFS_AUTO); + int source_index; + + const char *netfs_auto_argv[] = { + MOUNT, + NULL, /* source path */ + pool->def->target.path, + NULL, + }; + + const char *fs_argv[] = { MOUNT, "-t", pool->def->type == VIR_STORAGE_POOL_FS ? @@ -495,10 +511,20 @@ virStorageBackendFileSystemMount(virConnectPtr conn, pool->def->source.format) : virStorageBackendFileSystemNetPoolFormatToString(conn, pool->def->source.format), - NULL, /* Fill in shortly - careful not to add extra fields before this */ + NULL, /* Fill in shortly - careful not to add extra fields + before this */ pool->def->target.path, NULL, }; + + if (netauto) { + mntargv = netfs_auto_argv; + source_index = 1; + } else { + mntargv = fs_argv; + source_index = 3; + } + int ret; if (pool->def->type == VIR_STORAGE_POOL_NETFS) { @@ -543,7 +569,7 @@ virStorageBackendFileSystemMount(virConnectPtr conn, return -1; } } - mntargv[3] = src; + mntargv[source_index] = src; if (virRun(conn, (char**)mntargv, NULL) < 0) { VIR_FREE(src);

On Wed, Jul 16, 2008 at 01:30:33PM -0400, Cole Robinson wrote:
Trying to pool-create a netfs pool with the format type 'auto' (as in, to autodetect the format) runs the command
mount -t auto munged-source-path
'-t auto' seems to do its job for regular file systems, but actually fails with nfs or cifs (I assume anything that required an external mount program). Strangely though, the command
mount munged-source-path
will do the right thing.
The attached patch fixes the generated command to work in the above case, fully removing the '-t type' piece if auto is specified for a netfs pool.
I tested the intended case, as well as regular fs pools format=auto, and netfs format=nfs, and all seemed to work fine.
ACK. I actually thought we'd fixed this already, since Chris came across it a while back.. Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

Daniel P. Berrange wrote:
ACK. I actually thought we'd fixed this already, since Chris came across it a while back..
I thought so too, but then I think I remember that I didn't actually change the code, just configured around it. In any case, this seems to be a good change to me too, so ACK. Chris Lalancette

On Thu, Jul 17, 2008 at 04:53:22PM +0200, Chris Lalancette wrote:
Daniel P. Berrange wrote:
ACK. I actually thought we'd fixed this already, since Chris came across it a while back..
I thought so too, but then I think I remember that I didn't actually change the code, just configured around it.
In any case, this seems to be a good change to me too, so ACK.
Okidoc, applied and commited ! thanks everybody :-) Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
participants (4)
-
Chris Lalancette
-
Cole Robinson
-
Daniel P. Berrange
-
Daniel Veillard