提交 d04bb05f 编写于 作者: J John Ferlan

storage: Fix virStorageBackendUpdateVolTargetInfo type check

For volume processing in virStorageBackendUpdateVolTargetInfo to get
the capacity commit id 'a760ba3a' added the ability to probe a volume
that didn't list a target format. Unfortunately, the code used the
virStorageSource  (e.g. target->type - virStorageType) rather than
virStorageVolDef (e.g. vol->type - virStorageVolType) in order to
make the comparison. As it turns out target->type for a volume is
not filled in at all for a voldef as the code relies on vol->type.
Ironically the result is that only VIR_STORAGE_VOL_BLOCK's would get
their capacity updated.

This patch will adjust the code to check the "vol->type" field instead
as an argument. This way for a voldef, the correct comparison is made.

Additionally for a backingStore, the 'type' field is never filled in;
however, since we know that the provided path is a location at which
the backing store can be accessed on the local filesystem thus just
pass VIR_STORAGE_VOL_FILE in order to satisfy the adjusted voltype
check. Whether it's a FILE or a BLOCK only matters if we're trying to
get more data based on the target->format.
上级 77831d21
......@@ -1869,6 +1869,7 @@ virStorageBackendRedoPloopUpdate(virStorageSourcePtr target, struct stat *sb,
/*
* virStorageBackendUpdateVolTargetInfo
* @voltype: Volume type
* @target: target definition ptr of volume to update
* @withBlockVolFormat: true if caller determined a block file
* @openflags: various VolOpenCheckMode flags to handle errors on open
......@@ -1881,7 +1882,8 @@ virStorageBackendRedoPloopUpdate(virStorageSourcePtr target, struct stat *sb,
* be returned if the caller passed a readflagsflag.
*/
int
virStorageBackendUpdateVolTargetInfo(virStorageSourcePtr target,
virStorageBackendUpdateVolTargetInfo(virStorageVolType voltype,
virStorageSourcePtr target,
bool withBlockVolFormat,
unsigned int openflags,
unsigned int readflags)
......@@ -1898,7 +1900,7 @@ virStorageBackendUpdateVolTargetInfo(virStorageSourcePtr target,
if ((ret = virStorageBackendUpdateVolTargetInfoFD(target, fd, &sb)) < 0)
goto cleanup;
if (target->type == VIR_STORAGE_VOL_FILE &&
if (voltype == VIR_STORAGE_VOL_FILE &&
target->format != VIR_STORAGE_FILE_NONE) {
if (S_ISDIR(sb.st_mode)) {
if (virStorageBackendIsPloopDir(target->path)) {
......@@ -1969,13 +1971,15 @@ virStorageBackendUpdateVolInfo(virStorageVolDefPtr vol,
{
int ret;
if ((ret = virStorageBackendUpdateVolTargetInfo(&vol->target,
if ((ret = virStorageBackendUpdateVolTargetInfo(vol->type,
&vol->target,
withBlockVolFormat,
openflags, readflags)) < 0)
return ret;
if (vol->target.backingStore &&
(ret = virStorageBackendUpdateVolTargetInfo(vol->target.backingStore,
(ret = virStorageBackendUpdateVolTargetInfo(VIR_STORAGE_VOL_FILE,
vol->target.backingStore,
withBlockVolFormat,
VIR_STORAGE_VOL_OPEN_DEFAULT |
VIR_STORAGE_VOL_OPEN_NOERROR,
......
......@@ -226,7 +226,8 @@ int virStorageBackendUpdateVolInfo(virStorageVolDefPtr vol,
bool withBlockVolFormat,
unsigned int openflags,
unsigned int readflags);
int virStorageBackendUpdateVolTargetInfo(virStorageSourcePtr target,
int virStorageBackendUpdateVolTargetInfo(virStorageVolType voltype,
virStorageSourcePtr target,
bool withBlockVolFormat,
unsigned int openflags,
unsigned int readflags);
......
......@@ -875,7 +875,8 @@ virStorageBackendFileSystemRefresh(virConnectPtr conn ATTRIBUTE_UNUSED,
vol->type = VIR_STORAGE_VOL_PLOOP;
if (vol->target.backingStore) {
ignore_value(virStorageBackendUpdateVolTargetInfo(vol->target.backingStore,
ignore_value(virStorageBackendUpdateVolTargetInfo(VIR_STORAGE_VOL_FILE,
vol->target.backingStore,
false,
VIR_STORAGE_VOL_OPEN_DEFAULT, 0));
/* If this failed, the backing file is currently unavailable,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册