]> xenbits.xensource.com Git - libvirt.git/commitdiff
storage: let format probing work on root-squash NFS
authorEric Blake <eblake@redhat.com>
Sat, 20 Oct 2012 19:56:35 +0000 (13:56 -0600)
committerEric Blake <eblake@redhat.com>
Mon, 22 Oct 2012 15:04:57 +0000 (09:04 -0600)
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.

src/qemu/qemu_driver.c
src/storage/storage_backend_fs.c
src/util/storage_file.c
src/util/storage_file.h

index 2f83626127b64ec42471d06864c183faf7cdc894..d1dc2b8051e80b082f134963923053cc1689b396 100644 (file)
@@ -9310,7 +9310,8 @@ static int qemuDomainGetBlockInfo(virDomainPtr dom,
         format = disk->format;
     } else {
         if (driver->allowDiskFormatProbing) {
-            if ((format = virStorageFileProbeFormat(disk->src)) < 0)
+            if ((format = virStorageFileProbeFormat(disk->src, driver->user,
+                                                    driver->group)) < 0)
                 goto cleanup;
         } else {
             virReportError(VIR_ERR_INTERNAL_ERROR,
index cecc2d2bccc82a55848863beb14905545bb2c8a4..30e203ca37380c58ba2c39c1e3d07803ab6413fd 100644 (file)
@@ -104,7 +104,7 @@ virStorageBackendProbeTarget(virStorageVolTargetPtr target,
         meta->backingStore = NULL;
         if (meta->backingStoreFormat == VIR_STORAGE_FILE_AUTO &&
             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,
                  * but continue. Returning -1 here would disable the whole storage
                  * pool, making it unavailable for even maintenance. */
index 882df6ef11a126a4268cf24fc913efafb425ff2e..e0b41781b07226c47e9f59bd60f52ab675bd19eb 100644 (file)
@@ -830,11 +830,11 @@ cleanup:
  * Best option: Don't use this function
  */
 int
-virStorageFileProbeFormat(const char *path)
+virStorageFileProbeFormat(const char *path, uid_t uid, gid_t gid)
 {
     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);
         return -1;
     }
index 9b00dba28c9774c96b6f9608e536b0c04757f2f2..abfaca96bc95a8dc2cc7a4271452a3ddabd87209 100644 (file)
@@ -66,7 +66,7 @@ struct _virStorageFileMetadata {
 #  define DEV_BSIZE 512
 # endif
 
-int virStorageFileProbeFormat(const char *path);
+int virStorageFileProbeFormat(const char *path, uid_t uid, gid_t gid);
 int virStorageFileProbeFormatFromFD(const char *path,
                                     int fd);