[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH] 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
---
 src/qemu/qemu_driver.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index c537ed1..b6e9506 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3385,6 +3385,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"),
@@ -3398,13 +3400,15 @@ static int qemuSetupDiskCgroup(virCgroupPtr cgroup,
         memset(&meta, 0, sizeof(meta));
 
         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;
     } while (path != NULL);
@@ -3433,6 +3437,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"),
@@ -3446,13 +3452,15 @@ static int qemuTeardownDiskCgroup(virCgroupPtr cgroup,
         memset(&meta, 0, sizeof(meta));
 
         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;
     } while (path != NULL);
-- 
1.6.6.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]