[libvirt] [PATCH]: Give /dev/disk/by-{id,path} a chance to exist

Chris Lalancette clalance at redhat.com
Tue Nov 25 15:15:05 UTC 2008


All,
    When refreshing a storage pool (say, an iSCSI pool), one of the things it
does is to generate the stable path for each of the LUNs via
virStorageBackendStablePath.  That, in turn, has the following code:

    /* The pool is pointing somewhere like /dev/disk/by-path
     * or /dev/disk/by-id, so we need to check all symlinks in
     * the target directory and figure out which one points
     * to this device node
     */
    if ((dh = opendir(pool->def->target.path)) == NULL) {
         virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
                               _("cannot read dir %s: %s"),
                               pool->def->target.path,
                               strerror(errno));
         return NULL;
     }

For a normal machine, that code is totally legit; /dev/disk/by-{id,path} almost
certainly exists because of your hard drive, etc.  However, this may not be the
case in the stateless ovirt environment, since /dev/disk/by-{id,path} is created
on-demand by udev.  It's basically a race between udev creating the directory
and libvirt scanning the directory.
     The following patch just adds a retry to the code above so that if it
doesn't exist when we first get there, we give it time to come into being.  If
it still hasn't shown up 5 seconds after we started, we give up and throw the error.

Signed-off-by: Chris Lalancette <clalance at redhat.com>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: libvirt-stable-path-wait.patch
Type: text/x-patch
Size: 1909 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20081125/fa75312a/attachment-0001.bin>


More information about the libvir-list mailing list