mirror of https://gitee.com/openkylin/libvirt.git
storage: improve directory support in gluster pool
Take advantage of the previous patch's addition of 'netdir' as a distinct volume type, to expose rather than silently skip directories embedded in a gluster pool. Also serves as an XML validation for the previous patch. * src/storage/storage_backend_gluster.c (virStorageBackendGlusterRefreshVol): Don't skip directories. * tests/storagevolxml2xmltest.c (mymain): Add test. * tests/storagevolxml2xmlin/vol-gluster-dir.xml: New file. * tests/storagevolxml2xmlout/vol-gluster-dir.xml: Likewise. Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
ecd881b7a7
commit
1458b2e963
|
@ -165,9 +165,6 @@ virStorageBackendGlusterRefreshVol(virStorageBackendGlusterStatePtr state,
|
|||
/* Silently skip '.' and '..'. */
|
||||
if (STREQ(name, ".") || STREQ(name, ".."))
|
||||
return 0;
|
||||
/* FIXME: support directories. For now, silently skip them. */
|
||||
if (S_ISDIR(st->st_mode))
|
||||
return 0;
|
||||
|
||||
if (VIR_ALLOC(vol) < 0)
|
||||
goto cleanup;
|
||||
|
@ -177,7 +174,6 @@ virStorageBackendGlusterRefreshVol(virStorageBackendGlusterStatePtr state,
|
|||
vol->name) < 0)
|
||||
goto cleanup;
|
||||
|
||||
vol->type = VIR_STORAGE_VOL_NETWORK;
|
||||
tmp = state->uri->path;
|
||||
state->uri->path = vol->key;
|
||||
if (!(vol->target.path = virURIFormat(state->uri))) {
|
||||
|
@ -186,7 +182,17 @@ virStorageBackendGlusterRefreshVol(virStorageBackendGlusterStatePtr state,
|
|||
}
|
||||
state->uri->path = tmp;
|
||||
|
||||
if (S_ISDIR(st->st_mode)) {
|
||||
vol->type = VIR_STORAGE_VOL_NETDIR;
|
||||
vol->target.format = VIR_STORAGE_FILE_DIR;
|
||||
*volptr = vol;
|
||||
vol = NULL;
|
||||
ret = 0;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* FIXME - must open files to determine if they are non-raw */
|
||||
vol->type = VIR_STORAGE_VOL_NETWORK;
|
||||
vol->target.format = VIR_STORAGE_FILE_RAW;
|
||||
vol->capacity = vol->allocation = st->st_size;
|
||||
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
<volume type='netdir'>
|
||||
<name>dir</name>
|
||||
<key>vol/dir</key>
|
||||
<source>
|
||||
</source>
|
||||
<capacity unit='bytes'>0</capacity>
|
||||
<allocation unit='bytes'>0</allocation>
|
||||
<target>
|
||||
<format type='dir'/>
|
||||
<path>gluster://example.com/vol/dir</path>
|
||||
</target>
|
||||
</volume>
|
|
@ -0,0 +1,17 @@
|
|||
<volume type='netdir'>
|
||||
<name>dir</name>
|
||||
<key>vol/dir</key>
|
||||
<source>
|
||||
</source>
|
||||
<capacity unit='bytes'>0</capacity>
|
||||
<allocation unit='bytes'>0</allocation>
|
||||
<target>
|
||||
<path>gluster://example.com/vol/dir</path>
|
||||
<format type='dir'/>
|
||||
<permissions>
|
||||
<mode>0600</mode>
|
||||
<owner>4294967295</owner>
|
||||
<group>4294967295</group>
|
||||
</permissions>
|
||||
</target>
|
||||
</volume>
|
|
@ -121,6 +121,7 @@ mymain(void)
|
|||
DO_TEST("pool-logical", "vol-logical");
|
||||
DO_TEST("pool-logical", "vol-logical-backing");
|
||||
DO_TEST("pool-sheepdog", "vol-sheepdog");
|
||||
DO_TEST("pool-gluster", "vol-gluster-dir");
|
||||
|
||||
return ret==0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue