1. 25 7月, 2017 1 次提交
  2. 09 1月, 2017 1 次提交
    • D
      lxc: ensure libvirt_lxc and qemu-nbd move into systemd machine slice · 44f79a0b
      Daniel P. Berrange 提交于
      Currently when spawning containers with systemd, the container PID 1
      will get moved into the systemd machine slice. Libvirt then manually
      moves the libvirt_lxc and qemu-nbd processes into the cgroups associated
      with the slice, but skips the systemd controller cgroup. This means that
      from systemd's POV, libvirt_lxc and qemu-nbd are still part of the
      libvirtd.service unit.
      
      On systemctl daemon-reload, it will notice that libvirt_lxc & qemu-nbd
      are in the libvirtd.service unit for the systemd controller, but in the
      machine cgroups for resources. Systemd will thus move them back into
      the libvirtd.service resource cgroups next time libvirtd is restarted.
      This causes libvirtd to kill off the container due to incorrect cgroup
      placement.
      
      The solution is to ensure that when moving libvirt_lxc & qemu-nbd, we
      also move the systemd cgroup controller placement. Normally this is
      not something we ever want todo, but this is a special case as we are
      intentionally wanting to move them to a different systemd unit.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      44f79a0b
  3. 25 8月, 2016 1 次提交
  4. 01 3月, 2016 1 次提交
  5. 17 2月, 2016 2 次提交
    • P
      util: cgroup: Allow ignoring EACCES in virCgroup(Allow|Deny)DevicePath · cf113e8d
      Peter Krempa 提交于
      When adding disk images to ACL we may call those functions on NFS
      shares. In that case we might get an EACCES, which isn't really relevant
      since NFS would not hold a block device. This patch adds a flag that
      allows to stop reporting an error on EACCES to avoid spaming logs.
      
      Currently there's no functional change.
      cf113e8d
    • P
      util: cgroup: Drop virCgroup(Allow|Deny)DeviceMajor · 9cd5da71
      Peter Krempa 提交于
      Since commit 47e5b5ae virCgroupAllowDevice allows to pass -1 as either
      the minor or major device number and it automatically uses '*' in place
      of that. Reuse the new approach through the code and drop the duplicated
      functions.
      9cd5da71
  6. 08 2月, 2016 1 次提交
  7. 06 2月, 2016 1 次提交
  8. 05 2月, 2016 1 次提交
    • M
      systemd: Modernize machine naming · c3bd0019
      Martin Kletzander 提交于
      So, systemd-machined has this philosophy that machine names are like
      hostnames and hence should follow the same rules.  But we always allowed
      international characters in domain names.  Thus we need to modify the
      machine name we are passing to systemd.
      
      In order to change some machine names that we will be passing to systemd,
      we also need to call TerminateMachine at the end of a lifetime of a
      domain.  Even for domains that were started with older libvirt.  That
      can be achieved thanks to virSystemdGetMachineNameByPID().  And because
      we can change machine names, we can get rid of the inconsistent and
      pointless escaping of domain names when creating machine names.
      
      So this patch modifies the naming in the following way.  It creates the
      name as <drivername>-<id>-<name> where invalid hostname characters are
      stripped out of the name and if the resulting name is longer, it
      truncates it to 64 characters.  That way we can start domains we
      couldn't start before.  Well, at least on systemd.
      
      To make it work all together, the machineName (which is needed only with
      systemd) is saved in domain's private data.  That way the generation is
      moved to the driver and we don't need to pass various unnecessary
      arguments to cgroup functions.
      
      The only thing this complicates a bit is the scope generation when
      validating a cgroup where we must check both old and new naming, so a
      slight modification was needed there.
      
      Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1282846Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
      c3bd0019
  9. 27 1月, 2016 1 次提交
    • D
      lxc: don't try to hide parent cgroups inside container · dc576025
      Daniel P. Berrange 提交于
      On the host when we start a container, it will be
      placed in a cgroup path of
      
         /machine.slice/machine-lxc\x2ddemo.scope
      
      under /sys/fs/cgroup/*
      
      Inside the containers' namespace we need to setup
      /sys/fs/cgroup mounts, and currently will bind
      mount /machine.slice/machine-lxc\x2ddemo.scope on
      the host to appear as / in the container.
      
      While this may sound nice, it confuses applications
      dealing with cgroups, because /proc/$PID/cgroup
      now does not match the directory in /sys/fs/cgroup
      
      This particularly causes problems for systems and
      will make it create repeated path components in
      the cgroup for apps run in the container eg
      
        /machine.slice/machine-lxc\x2ddemo.scope/machine.slice/machine-lxc\x2ddemo.scope/user.slice/user-0.slice/session-61.scope
      
      This also causes any systemd service that uses
      sd-notify to fail to start, because when systemd
      receives the notification it won't be able to
      identify the corresponding unit it came from.
      In particular this break rabbitmq-server startup
      
      Future kernels will provide proper cgroup namespacing
      which will handle this problem, but until that time
      we should not try to play games with hiding parent
      cgroups.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      dc576025
  10. 19 8月, 2015 1 次提交
  11. 22 7月, 2015 1 次提交
    • P
      cgroup: Drop resource partition from virSystemdMakeScopeName · 88f6c007
      Peter Krempa 提交于
      The scope name, even according to our docs is
      "machine-$DRIVER\x2d$VMNAME.scope" virSystemdMakeScopeName would use the
      resource partition name instead of "machine-" if it was specified thus
      creating invalid scope paths.
      
      This makes libvirt drop cgroups for a VM that uses custom resource
      partition upon reconnecting since the detected scope name would not
      match the expected name generated by virSystemdMakeScopeName.
      
      The error is exposed by the following log entry:
      
      debug : virCgroupValidateMachineGroup:302 : Name 'machine-qemu\x2dtestvm.scope' for controller 'cpu' does not match 'testvm', 'testvm.libvirt-qemu' or 'machine-test-qemu\x2dtestvm.scope'
      
      for a "/machine/test" resource and "testvm" vm.
      
      Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1238570
      88f6c007
  12. 10 4月, 2015 2 次提交
  13. 08 4月, 2015 1 次提交
  14. 30 3月, 2015 1 次提交
    • M
      virCgroupController: Check the enum fits into 'int' · 771e6e5a
      Michal Privoznik 提交于
      Throughout our code, the virCgroupController enum is used in two ways.
      First as an index to an array of cgroup controllers:
      
      struct virCgroup {
          char *path;
      
          struct virCgroupController controllers[VIR_CGROUP_CONTROLLER_LAST];
      };
      
      Second way is that when calling virCgroupNew() a bitmask of the enum
      items can be passed to selectively detect only some controllers. For
      instance:
      
      int
      virCgroupNewVcpu(virCgroupPtr domain,
                       int vcpuid,
                       bool create,
                       virCgroupPtr *group)
      {
          ...
          controllers = ((1 << VIR_CGROUP_CONTROLLER_CPU) |
                         (1 << VIR_CGROUP_CONTROLLER_CPUACCT) |
                         (1 << VIR_CGROUP_CONTROLLER_CPUSET));
      
          if (virCgroupNew(-1, name, domain, controllers, group) < 0)
              goto cleanup;
      }
      
      Even though it's highly unlikely that so many new controllers will be
      invented so that we would overflow when constructing the bitmask, it
      doesn't hurt to check at compile time either.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      771e6e5a
  15. 20 3月, 2015 1 次提交
  16. 15 1月, 2015 1 次提交
    • D
      Add support for systemd-machined CreateMachineWithNetwork · 318df5a0
      Daniel P. Berrange 提交于
      systemd-machined introduced a new method CreateMachineWithNetwork
      that obsoletes CreateMachine. It expects to be given a list of
      VETH/TAP device indexes for the host side device(s) associated
      with a container/machine.
      
      This falls back to the old CreateMachine method when the new
      one is not supported.
      318df5a0
  17. 16 12月, 2014 1 次提交
  18. 02 10月, 2014 1 次提交
    • G
      qemu: use systemd's TerminateMachine to kill all processes · 4882618e
      Guido Günther 提交于
      If we don't properly clean up all processes in the
      machine-<vmname>.scope systemd won't remove the cgroup and subsequent vm
      starts fail with
      
        'CreateMachine: File exists'
      
      Additional processes can e.g. be added via
      
        echo $PID > /sys/fs/cgroup/systemd/machine.slice/machine-${VMNAME}.scope/tasks
      
      but there are other cases like
      
        http://bugs.debian.org/761521
      
      Invoke TerminateMachine to be on the safe side since systemd tracks the
      cgroup anyway. This is a noop if all processes have terminated already.
      4882618e
  19. 16 9月, 2014 1 次提交
  20. 23 7月, 2014 1 次提交
    • C
      lxc: allow to keep or drop capabilities · 47e5b5ae
      Cédric Bosdonnat 提交于
      Added <capabilities> in the <features> section of LXC domains
      configuration. This section can contain elements named after the
      capabilities like:
      
        <mknod state="on"/>, keep CAP_MKNOD capability
        <sys_chroot state="off"/> drop CAP_SYS_CHROOT capability
      
      Users can restrict or give more capabilities than the default using
      this mechanism.
      47e5b5ae
  21. 08 7月, 2014 1 次提交
  22. 09 4月, 2014 1 次提交
    • J
      Extend virCgroupGetPercpuStats to fill in vcputime too · 897808e7
      Ján Tomko 提交于
      Currently, virCgroupGetPercpuStats is only used by the LXC driver,
      filling out the CPUTIME stats. qemuDomainGetPercpuStats does this
      and also filles out VCPUTIME stats.
      
      Extend virCgroupGetPercpuStats to also report VCPUTIME stats if
      nvcpupids is non-zero. In the LXC driver, we don't have cpupids.
      In the QEMU driver, there is at least one cpupid for a running domain,
      so the behavior shouldn't change for QEMU either.
      
      Also rename getSumVcpuPercpuStats to virCgroupGetPercpuVcpuSum.
      897808e7
  23. 24 2月, 2014 1 次提交
  24. 20 2月, 2014 3 次提交
  25. 20 1月, 2014 1 次提交
  26. 16 9月, 2013 1 次提交
  27. 13 8月, 2013 1 次提交
    • E
      cgroup: functional sort · 2ff9e54c
      Eric Blake 提交于
      Make future patches smaller by matching a sane header listing in
      the first place.  No semantic change.
      
      * src/util/vircgroup.h: Move free next to new, and controller
      functions next to each other.
      * src/util/vircgroup.c (virCgroupFree, virCgroupHasController)
      (virCgroupPathOfController, virCgroupRemoveRecursively)
      (virCgroupRemove): Sort implementation to be closer to header.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      2ff9e54c
  28. 01 8月, 2013 2 次提交
    • D
      Enable support for systemd-machined in cgroups creation · 2fe24701
      Daniel P. Berrange 提交于
      Make the virCgroupNewMachine method try to use systemd-machined
      first. If that fails, then fallback to using the traditional
      cgroup setup code path.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      2fe24701
    • D
      Add support for systemd cgroup mount · aedd46e7
      Daniel P. Berrange 提交于
      Systemd uses a named cgroup mount for tracking processes. Add
      it as another type of controller, albeit one which we have to
      special case in a number of places. In particular we must
      never create/delete directories there, nor add tasks. Essentially
      the systemd mount is to be considered read-only for libvirt.
      
      With this change both the virCgroupDetectPlacement and
      virCgroupCopyPlacement methods must be invoked. The copy
      placement method will copy setup for resource controllers
      only. The detect placement method will probe for any
      named controllers, or resource controllers not already
      setup.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      aedd46e7
  29. 26 7月, 2013 3 次提交
  30. 25 7月, 2013 1 次提交
  31. 24 7月, 2013 3 次提交