storage: let format probing work on root-squash NFS
Yet another instance of where using plain open() mishandles files that live on root-squash NFS, and where improving the API can improve the chance of a successful probe. * src/util/storage_file.h (virStorageFileProbeFormat): Alter signature. * src/util/storage_file.c (virStorageFileProbeFormat): Use better method for opening file. * src/qemu/qemu_driver.c (qemuDomainGetBlockInfo): Update caller. * src/storage/storage_backend_fs.c (virStorageBackendProbeTarget): Likewise.
This commit is contained in:
parent
e0ad466983
commit
d9d77bfa80
@ -9310,7 +9310,8 @@ static int qemuDomainGetBlockInfo(virDomainPtr dom,
|
|||||||
format = disk->format;
|
format = disk->format;
|
||||||
} else {
|
} else {
|
||||||
if (driver->allowDiskFormatProbing) {
|
if (driver->allowDiskFormatProbing) {
|
||||||
if ((format = virStorageFileProbeFormat(disk->src)) < 0)
|
if ((format = virStorageFileProbeFormat(disk->src, driver->user,
|
||||||
|
driver->group)) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else {
|
} else {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
@ -104,7 +104,7 @@ virStorageBackendProbeTarget(virStorageVolTargetPtr target,
|
|||||||
meta->backingStore = NULL;
|
meta->backingStore = NULL;
|
||||||
if (meta->backingStoreFormat == VIR_STORAGE_FILE_AUTO &&
|
if (meta->backingStoreFormat == VIR_STORAGE_FILE_AUTO &&
|
||||||
meta->backingStoreIsFile) {
|
meta->backingStoreIsFile) {
|
||||||
if ((ret = virStorageFileProbeFormat(*backingStore)) < 0) {
|
if ((ret = virStorageFileProbeFormat(*backingStore, -1, -1)) < 0) {
|
||||||
/* If the backing file is currently unavailable, only log an error,
|
/* If the backing file is currently unavailable, only log an error,
|
||||||
* but continue. Returning -1 here would disable the whole storage
|
* but continue. Returning -1 here would disable the whole storage
|
||||||
* pool, making it unavailable for even maintenance. */
|
* pool, making it unavailable for even maintenance. */
|
||||||
|
@ -830,11 +830,11 @@ cleanup:
|
|||||||
* Best option: Don't use this function
|
* Best option: Don't use this function
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
virStorageFileProbeFormat(const char *path)
|
virStorageFileProbeFormat(const char *path, uid_t uid, gid_t gid)
|
||||||
{
|
{
|
||||||
int fd, ret;
|
int fd, ret;
|
||||||
|
|
||||||
if ((fd = open(path, O_RDONLY)) < 0) {
|
if ((fd = virFileOpenAs(path, O_RDONLY, 0, uid, gid, 0)) < 0) {
|
||||||
virReportSystemError(errno, _("cannot open file '%s'"), path);
|
virReportSystemError(errno, _("cannot open file '%s'"), path);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ struct _virStorageFileMetadata {
|
|||||||
# define DEV_BSIZE 512
|
# define DEV_BSIZE 512
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
int virStorageFileProbeFormat(const char *path);
|
int virStorageFileProbeFormat(const char *path, uid_t uid, gid_t gid);
|
||||||
int virStorageFileProbeFormatFromFD(const char *path,
|
int virStorageFileProbeFormatFromFD(const char *path,
|
||||||
int fd);
|
int fd);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user