mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
storage: Generate correct parameters for CIFS
https://bugzilla.redhat.com/show_bug.cgi?id=1186969 When generating the path to the dir for a CIFS/Samba driver, the code would generate a source path for the mount using "%s:%s" while the mount.cifs expects to see "//%s/%s". So check for the cifsfs and format the source path appropriately. Additionally, since there is no means to authenticate, the mount needs a "-o guest" on the command line in order to anonymously mount the Samba directory.
This commit is contained in:
parent
257250f764
commit
29230951f1
@ -124,11 +124,14 @@
|
|||||||
<span class="since">Since 0.4.1</span></dd>
|
<span class="since">Since 0.4.1</span></dd>
|
||||||
<dt><code>dir</code></dt>
|
<dt><code>dir</code></dt>
|
||||||
<dd>Provides the source for pools backed by directories (pool
|
<dd>Provides the source for pools backed by directories (pool
|
||||||
type <code>dir</code>), or optionally to select a subdirectory
|
types <code>dir</code>, <code>netfs</code>, <code>gluster</code>),
|
||||||
|
or optionally to select a subdirectory
|
||||||
within a pool that resembles a filesystem (pool
|
within a pool that resembles a filesystem (pool
|
||||||
type <code>gluster</code>). May
|
type <code>gluster</code>). May
|
||||||
only occur once. Contains a single attribute <code>path</code>
|
only occur once. Contains a single attribute <code>path</code>
|
||||||
which is the fully qualified path to the backing directory.
|
which is the fully qualified path to the backing directory or
|
||||||
|
for a <code>netfs</code> pool type using <code>format</code>
|
||||||
|
type "cifs", the path to the Samba share without the leading slash.
|
||||||
<span class="since">Since 0.4.1</span></dd>
|
<span class="since">Since 0.4.1</span></dd>
|
||||||
<dt><code>adapter</code></dt>
|
<dt><code>adapter</code></dt>
|
||||||
<dd>Provides the source for pools backed by SCSI adapters (pool
|
<dd>Provides the source for pools backed by SCSI adapters (pool
|
||||||
|
@ -291,7 +291,8 @@
|
|||||||
the <a href="#StorageBackendGluster">gluster</a> pool.)
|
the <a href="#StorageBackendGluster">gluster</a> pool.)
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<code>cifs</code> - use the SMB (samba) or CIFS file system
|
<code>cifs</code> - use the SMB (samba) or CIFS file system.
|
||||||
|
The mount will use "-o guest" to mount the directory anonymously.
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
@ -426,6 +426,8 @@ virStorageBackendFileSystemMount(virStoragePoolObjPtr pool)
|
|||||||
pool->def->source.format == VIR_STORAGE_POOL_NETFS_AUTO);
|
pool->def->source.format == VIR_STORAGE_POOL_NETFS_AUTO);
|
||||||
bool glusterfs = (pool->def->type == VIR_STORAGE_POOL_NETFS &&
|
bool glusterfs = (pool->def->type == VIR_STORAGE_POOL_NETFS &&
|
||||||
pool->def->source.format == VIR_STORAGE_POOL_NETFS_GLUSTERFS);
|
pool->def->source.format == VIR_STORAGE_POOL_NETFS_GLUSTERFS);
|
||||||
|
bool cifsfs = (pool->def->type == VIR_STORAGE_POOL_NETFS &&
|
||||||
|
pool->def->source.format == VIR_STORAGE_POOL_NETFS_CIFS);
|
||||||
virCommandPtr cmd = NULL;
|
virCommandPtr cmd = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
int rc;
|
int rc;
|
||||||
@ -444,11 +446,17 @@ virStorageBackendFileSystemMount(virStoragePoolObjPtr pool)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pool->def->type == VIR_STORAGE_POOL_NETFS) {
|
if (pool->def->type == VIR_STORAGE_POOL_NETFS) {
|
||||||
if (virAsprintf(&src, "%s:%s",
|
if (pool->def->source.format == VIR_STORAGE_POOL_NETFS_CIFS) {
|
||||||
pool->def->source.hosts[0].name,
|
if (virAsprintf(&src, "//%s/%s",
|
||||||
pool->def->source.dir) == -1)
|
pool->def->source.hosts[0].name,
|
||||||
return -1;
|
pool->def->source.dir) == -1)
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
if (virAsprintf(&src, "%s:%s",
|
||||||
|
pool->def->source.hosts[0].name,
|
||||||
|
pool->def->source.dir) == -1)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (VIR_STRDUP(src, pool->def->source.devices[0].path) < 0)
|
if (VIR_STRDUP(src, pool->def->source.devices[0].path) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -468,6 +476,15 @@ virStorageBackendFileSystemMount(virStoragePoolObjPtr pool)
|
|||||||
"direct-io-mode=1",
|
"direct-io-mode=1",
|
||||||
pool->def->target.path,
|
pool->def->target.path,
|
||||||
NULL);
|
NULL);
|
||||||
|
else if (cifsfs)
|
||||||
|
cmd = virCommandNewArgList(MOUNT,
|
||||||
|
"-t",
|
||||||
|
virStoragePoolFormatFileSystemNetTypeToString(pool->def->source.format),
|
||||||
|
src,
|
||||||
|
pool->def->target.path,
|
||||||
|
"-o",
|
||||||
|
"guest",
|
||||||
|
NULL);
|
||||||
else
|
else
|
||||||
cmd = virCommandNewArgList(MOUNT,
|
cmd = virCommandNewArgList(MOUNT,
|
||||||
"-t",
|
"-t",
|
||||||
|
Loading…
Reference in New Issue
Block a user