]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
disk: Allow settling to occur after reading partitions
authorJohn Ferlan <jferlan@redhat.com>
Thu, 24 May 2018 15:10:57 +0000 (11:10 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Fri, 25 May 2018 12:26:41 +0000 (08:26 -0400)
https://bugzilla.redhat.com/show_bug.cgi?id=1400475

In order to avoid a possible error as a result of kernel interactions
with the partition helper, let's use virWaitForDevices to force things
to settle down before attempting to open and read the partition. This
is related to https://bugzilla.redhat.com/show_bug.cgi?id=1264719.

Although perhaps overkill to have too many places to settle, since
we know that the act of reading the partitions via libvirt_parthelper
will cause udev activity/events - we just need to ensure udev has
been settled before proceding with usage of the device.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
src/storage/storage_backend_disk.c

index 7b4549c34d65b6a250e2d0f5ab14fbd11e8ea6fc..2e3d1e04a4b9c2ee65884a6c23ad823dd5ef408f 100644 (file)
@@ -183,7 +183,16 @@ virStorageBackendDiskMakeDataVol(virStoragePoolObjPtr pool,
      * after an extended partition is created an open on the extended
      * partition will fail, so pass the NOERROR flag and only error if a
      * -1 was returned indicating some other error than an open error.
+     *
+     * NB: A small window exists in some cases where the just created
+     * partition disappears, but then reappears. Since we were given
+     * vol->target.path from parthelper, let's just be sure that any
+     * kernel magic that occurs as a result of parthelper doesn't cause
+     * us to fail with some sort of ENOENT failure since that would be
+     * quite "unexpected". So rather than just fail, let's use the
+     * virWaitForDevices to ensure everything has settled properly.
      */
+    virWaitForDevices();
     if (vol->source.partType == VIR_STORAGE_VOL_DISK_TYPE_EXTENDED) {
         if (virStorageBackendUpdateVolInfo(vol, false,
                                            VIR_STORAGE_VOL_OPEN_DEFAULT |