]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
Avoid libvirtd crash when cgroups is not configured on host
authorJim Fehlig <jfehlig@novell.com>
Mon, 22 Mar 2010 15:42:14 +0000 (09:42 -0600)
committerJim Fehlig <jfehlig@novell.com>
Mon, 22 Mar 2010 15:42:14 +0000 (09:42 -0600)
Invoking virDomainSetMemory() on lxc driver results in libvirtd
segfault when cgroups has not been configured on the host.

Ensure driver->cgroup is non-null before invoking
virCgroupForDomain().  To prevent similar segfaults in the future,
ensure driver parameter to virCgroupForDomain() is non-null before
dereferencing.

src/lxc/lxc_driver.c
src/util/cgroup.c

index aeec593bb051381a665e31c1121d2618a4078c0c..ba13065288e0f2d1592f7c21c39c1e1b7083b890 100644 (file)
@@ -625,6 +625,12 @@ static int lxcDomainSetMemory(virDomainPtr dom, unsigned long newmem) {
     }
 
     if (virDomainObjIsActive(vm)) {
+        if (driver->cgroup == NULL) {
+            lxcError(VIR_ERR_NO_SUPPORT,
+                     "%s", _("cgroups must be configured on the host"));
+            goto cleanup;
+        }
+
         if (virCgroupForDomain(driver->cgroup, vm->def->name, &cgroup, 0) != 0) {
             lxcError(VIR_ERR_INTERNAL_ERROR,
                      _("Unable to get cgroup for %s\n"), vm->def->name);
index 87777814d63b69ed485df5c7537a3f1780dae59d..496d9d308b03a188ba918097db5c4923df8c2364 100644 (file)
@@ -692,6 +692,9 @@ int virCgroupForDomain(virCgroupPtr driver,
     int rc;
     char *path;
 
+    if (driver == NULL)
+        return -EINVAL;
+
     if (virAsprintf(&path, "%s/%s", driver->path, name) < 0)
         return -ENOMEM;