Fix cgroup setup code to cope with root squashing NFS

When a disk is on a root squashed NFS server, it may not be
possible to stat() the disk file in virCgroupAllowDevice.
The virStorageFileGetMeta method may also fail to extract
the parent backing store. Both of these errors have to be
ignored to avoid breaking NFS deployments

* src/qemu/qemu_driver.c: Ignore errors in cgroup setup to
   keep root squash NFS happy
This commit is contained in:
Daniel P. Berrange 2010-05-19 06:47:47 -04:00
parent c09f663a47
commit c37c321cc2

View File

@ -3027,6 +3027,8 @@ static int qemuSetupDiskCgroup(virCgroupPtr cgroup,
/* Get this for non-block devices */
if (rc == -EINVAL) {
VIR_DEBUG("Ignoring EINVAL for %s", path);
} else if (rc == -EACCES) { /* Get this for root squash NFS */
VIR_DEBUG("Ignoring EACCES for %s", path);
} else {
virReportSystemError(-rc,
_("Unable to allow device %s for %s"),
@ -3038,13 +3040,15 @@ static int qemuSetupDiskCgroup(virCgroupPtr cgroup,
}
rc = virStorageFileGetMetadata(path, &meta);
if (rc < 0)
VIR_WARN("Unable to lookup parent image for %s", path);
if (path != disk->src)
VIR_FREE(path);
path = NULL;
if (rc < 0)
goto cleanup;
break; /* Treating as non fatal */
path = meta.backingStore;
}
@ -3073,6 +3077,8 @@ static int qemuTeardownDiskCgroup(virCgroupPtr cgroup,
/* Get this for non-block devices */
if (rc == -EINVAL) {
VIR_DEBUG("Ignoring EINVAL for %s", path);
} else if (rc == -EACCES) { /* Get this for root squash NFS */
VIR_DEBUG("Ignoring EACCES for %s", path);
} else {
virReportSystemError(-rc,
_("Unable to deny device %s for %s"),
@ -3084,13 +3090,15 @@ static int qemuTeardownDiskCgroup(virCgroupPtr cgroup,
}
rc = virStorageFileGetMetadata(path, &meta);
if (rc < 0)
VIR_WARN("Unable to lookup parent image for %s", path);
if (path != disk->src)
VIR_FREE(path);
path = NULL;
if (rc < 0)
goto cleanup;
break; /* Treating as non fatal */
path = meta.backingStore;
}