1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-04-01 20:05:19 +00:00

storage: Add readflags for backend error processing

Similar to the openflags which allow VIR_STORAGE_VOL_OPEN_NOERROR to be
passed to avoid open errors, add a 'readflags' variable so that in the
future read failures could also be ignored.
This commit is contained in:
John Ferlan 2015-11-24 10:08:29 -05:00
parent 8df2f1d874
commit 22346003dc
7 changed files with 23 additions and 15 deletions

View File

@ -1391,7 +1391,8 @@ static struct diskType const disk_types[] = {
static int
virStorageBackendDetectBlockVolFormatFD(virStorageSourcePtr target,
int fd)
int fd,
unsigned int readflags ATTRIBUTE_UNUSED)
{
size_t i;
off_t start;
@ -1580,7 +1581,8 @@ virStorageBackendVolOpen(const char *path, struct stat *sb,
int
virStorageBackendUpdateVolTargetInfo(virStorageSourcePtr target,
bool withBlockVolFormat,
unsigned int openflags)
unsigned int openflags,
unsigned int readflags)
{
int ret, fd = -1;
struct stat sb;
@ -1622,7 +1624,8 @@ virStorageBackendUpdateVolTargetInfo(virStorageSourcePtr target,
}
if (withBlockVolFormat) {
if ((ret = virStorageBackendDetectBlockVolFormatFD(target, fd)) < 0)
if ((ret = virStorageBackendDetectBlockVolFormatFD(target, fd,
readflags)) < 0)
goto cleanup;
}
@ -1636,20 +1639,22 @@ virStorageBackendUpdateVolTargetInfo(virStorageSourcePtr target,
int
virStorageBackendUpdateVolInfo(virStorageVolDefPtr vol,
bool withBlockVolFormat,
unsigned int openflags)
unsigned int openflags,
unsigned int readflags)
{
int ret;
if ((ret = virStorageBackendUpdateVolTargetInfo(&vol->target,
withBlockVolFormat,
openflags)) < 0)
openflags, readflags)) < 0)
return ret;
if (vol->target.backingStore &&
(ret = virStorageBackendUpdateVolTargetInfo(vol->target.backingStore,
withBlockVolFormat,
VIR_STORAGE_VOL_OPEN_DEFAULT |
VIR_STORAGE_VOL_OPEN_NOERROR) < 0))
VIR_STORAGE_VOL_OPEN_NOERROR,
readflags) < 0))
return ret;
return 0;

View File

@ -192,10 +192,12 @@ int virStorageBackendVolOpen(const char *path, struct stat *sb,
int virStorageBackendUpdateVolInfo(virStorageVolDefPtr vol,
bool withBlockVolFormat,
unsigned int openflags);
unsigned int openflags,
unsigned int readflags);
int virStorageBackendUpdateVolTargetInfo(virStorageSourcePtr target,
bool withBlockVolFormat,
unsigned int openflags);
unsigned int openflags,
unsigned int readflags);
int virStorageBackendUpdateVolTargetInfoFD(virStorageSourcePtr target,
int fd,
struct stat *sb);

View File

@ -154,14 +154,15 @@ virStorageBackendDiskMakeDataVol(virStoragePoolObjPtr pool,
if (vol->source.partType == VIR_STORAGE_VOL_DISK_TYPE_EXTENDED) {
if (virStorageBackendUpdateVolInfo(vol, false,
VIR_STORAGE_VOL_OPEN_DEFAULT |
VIR_STORAGE_VOL_OPEN_NOERROR) == -1)
VIR_STORAGE_VOL_OPEN_NOERROR,
0) == -1)
return -1;
vol->target.allocation = 0;
vol->target.capacity =
(vol->source.extents[0].end - vol->source.extents[0].start);
} else {
if (virStorageBackendUpdateVolInfo(vol, false,
VIR_STORAGE_VOL_OPEN_DEFAULT) < 0)
VIR_STORAGE_VOL_OPEN_DEFAULT, 0) < 0)
return -1;
}

View File

@ -921,7 +921,7 @@ virStorageBackendFileSystemRefresh(virConnectPtr conn ATTRIBUTE_UNUSED,
if (vol->target.backingStore) {
ignore_value(virStorageBackendUpdateVolTargetInfo(vol->target.backingStore,
false,
VIR_STORAGE_VOL_OPEN_DEFAULT));
VIR_STORAGE_VOL_OPEN_DEFAULT, 0));
/* If this failed, the backing file is currently unavailable,
* the capacity, allocation, owner, group and mode are unknown.
* An error message was raised, but we just continue. */
@ -1245,7 +1245,7 @@ virStorageBackendFileSystemVolRefresh(virConnectPtr conn,
/* Refresh allocation / capacity / permissions info in case its changed */
ret = virStorageBackendUpdateVolInfo(vol, false,
VIR_STORAGE_VOL_FS_OPEN_FLAGS);
VIR_STORAGE_VOL_FS_OPEN_FLAGS, 0);
if (ret < 0)
return ret;

View File

@ -162,7 +162,7 @@ virStorageBackendLogicalMakeVol(char **const groups,
goto cleanup;
if (virStorageBackendUpdateVolInfo(vol, false,
VIR_STORAGE_VOL_OPEN_DEFAULT) < 0)
VIR_STORAGE_VOL_OPEN_DEFAULT, 0) < 0)
goto cleanup;
nextents = 1;

View File

@ -61,7 +61,7 @@ virStorageBackendMpathNewVol(virStoragePoolObjPtr pool,
goto cleanup;
if (virStorageBackendUpdateVolInfo(vol, true,
VIR_STORAGE_VOL_OPEN_DEFAULT) < 0) {
VIR_STORAGE_VOL_OPEN_DEFAULT, 0) < 0) {
goto cleanup;
}

View File

@ -225,7 +225,7 @@ virStorageBackendSCSINewLun(virStoragePoolObjPtr pool,
}
if (virStorageBackendUpdateVolInfo(vol, true,
VIR_STORAGE_VOL_OPEN_DEFAULT) < 0)
VIR_STORAGE_VOL_OPEN_DEFAULT, 0) < 0)
goto cleanup;
if (!(vol->key = virStorageBackendSCSISerial(vol->target.path)))