On Wed, Oct 01, 2008 at 01:19:03PM -0700, Dan Smith wrote: > This patch adds src/cgroup.{c,h} with support for creating and manipulating > cgroups. > > All groups created with the internal API are forced under $mount/libvirt/ > to keep everything together. The first time a group is created, the libvirt > directory is also created, and the settings from the root are inherited. > > The code creates groups in all mounts requires to get memory and devices > functionality. When setting a value, the appropriate mount is determined > and the value is set there. I have tested this with all controllers mounted > in a single location, as well as all of them mounted separately. > +int virCgroupForDomain(virDomainDefPtr def, virCgroupPtr *group) I think we should pass in a 2nd 'const char *driverName' arg here with "lxc" as its value > +{ > + int rc; > + virCgroupPtr typegrp = NULL; > + const char *typestr = virDomainVirtTypeToString(def->virtType); Rather than rely on this virt type string - virt type is not adding enough uniqueness - can still have a (virttype, name) clash between 2 libvirt drivers. Name is unique per host, per driver, so we'd want to have $CONTROLLER_MOUNT/libvirt/$DRIVER_NAME/$DOMAIN_NAME > + > + if (typestr == NULL) > + return -EINVAL; > + > + rc = virCgroupOpen(NULL, typestr, &typegrp); > + if (rc == -ENOENT) { > + rc = virCgroupCreate(NULL, typestr, &typegrp); > + if (rc != 0) > + goto out; > + } else if (rc != 0) > + goto out; > + > + rc = virCgroupOpen(typegrp, def->name, group); > + if (rc == -ENOENT) > + rc = virCgroupCreate(typegrp, def->name, group); > +out: > + virCgroupFree(&typegrp); > + > + return rc; > +} > + Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :| -- Libvir-list mailing list Libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list