From c37c321cc2e938372345c45aed25363da01ac0f7 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Wed, 19 May 2010 06:47:47 -0400 Subject: [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 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 9e5872ed28..bc8dcfaf02 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -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; }