]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
storage: Add readflags for backend error processing
authorJohn Ferlan <jferlan@redhat.com>
Tue, 24 Nov 2015 15:08:29 +0000 (10:08 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Wed, 9 Dec 2015 21:31:14 +0000 (16:31 -0500)
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.

src/storage/storage_backend.c
src/storage/storage_backend.h
src/storage/storage_backend_disk.c
src/storage/storage_backend_fs.c
src/storage/storage_backend_logical.c
src/storage/storage_backend_mpath.c
src/storage/storage_backend_scsi.c

index 194736bf577ff72a69f44b28502c679a42c15c51..94b0b3f6c659cbe850e20b509bbddb53ffa073a8 100644 (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;
index 96b5f39161dd76b8831305caf7716a3e6a067eed..64c46ee98f6ee0357095ac4cb0cf5a7bf3c2df93 100644 (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);
index 7baecc1e47bf863d3bad0b80e565f6feaa862a9a..a83e34080e1fb17d38a3fc2539f51eae6a502de8 100644 (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;
     }
 
index 99ea394029c9bef6b14364968b1d2fe51d703862..c71c7249e576e3560f7addfaac89b36037e3b5d3 100644 (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;
 
index 536e617319d706b80ad0930909d8ecddbf4ab64d..96bc4c6024aa3c14e9be83d4a5f474882efb0525 100644 (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;
index ca9a62fbe6f97204919c3e0de877fe1e299d3628..b5b4bb6587132c09efda8cb35c758627cc33de77 100644 (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;
     }
 
index 7dd7674f88febf3af69ebfb2edcbcd68f86168bb..cc2c5d7159f7678c1ae7cb8564d55b0b77f2d105 100644 (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)))