1. 28 2月, 2013 2 次提交
    • D
      Don't try to add non-existant devices to ACL · 7f544a4c
      Daniel P. Berrange 提交于
      The QEMU driver has a list of devices nodes that are whitelisted
      for all guests. The kernel has recently started returning an
      error if you try to whitelist a device which does not exist.
      This causes a warning in libvirt logs and an audit error for
      any missing devices. eg
      
      2013-02-27 16:08:26.515+0000: 29625: warning : virDomainAuditCgroup:451 : success=no virt=kvm resrc=cgroup reason=allow vm="vm031714" uuid=9d8f1de0-44f4-a0b1-7d50-e41ee6cd897b cgroup="/sys/fs/cgroup/devices/libvirt/qemu/vm031714/" class=path path=/dev/kqemu rdev=? acl=rw
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      7f544a4c
    • D
      Avoid spamming logs with cgroups warnings · 279336c5
      Daniel P. Berrange 提交于
      The code for putting the emulator threads in a separate cgroup
      would spam the logs with warnings
      
      2013-02-27 16:08:26.731+0000: 29624: warning : virCgroupMoveTask:887 : no vm cgroup in controller 3
      2013-02-27 16:08:26.731+0000: 29624: warning : virCgroupMoveTask:887 : no vm cgroup in controller 4
      2013-02-27 16:08:26.732+0000: 29624: warning : virCgroupMoveTask:887 : no vm cgroup in controller 6
      
      This is because it has only created child cgroups for 3 of the
      controllers, but was trying to move the processes from all the
      controllers. The fix is to only try to move threads in the
      controllers we actually created. Also remove the warning and
      make it return a hard error to avoid such lazy callers in the
      future.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      279336c5
  2. 22 2月, 2013 1 次提交
  3. 06 2月, 2013 2 次提交
  4. 05 2月, 2013 1 次提交
    • D
      Introduce a virQEMUDriverConfigPtr object · b090aa7d
      Daniel P. Berrange 提交于
      Currently the virQEMUDriverPtr struct contains an wide variety
      of data with varying access needs. Move all the static config
      data into a dedicated virQEMUDriverConfigPtr object. The only
      locking requirement is to hold the driver lock, while obtaining
      an instance of virQEMUDriverConfigPtr. Once a reference is held
      on the config object, it can be used completely lockless since
      it is immutable.
      
      NB, not all APIs correctly hold the driver lock while getting
      a reference to the config object in this patch. This is safe
      for now since the config is never updated on the fly. Later
      patches will address this fully.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      b090aa7d
  5. 10 1月, 2013 1 次提交
    • E
      maint: fix comment typo · 70345318
      Eric Blake 提交于
      While OOM can have knock-on effects that trash a system, generally
      the first symptom is one of memory thrashing.
      
      * src/qemu/qemu_cgroup.c (qemuSetupCgroup): Reword slightly.
      70345318
  6. 08 1月, 2013 1 次提交
    • M
      qemu: Relax hard RSS limit · 3c83df67
      Michal Privoznik 提交于
      Currently, if there's no hard memory limit defined for a domain,
      libvirt tries to calculate one, based on domain definition and magic
      equation and set it upon the domain startup. The rationale behind was,
      if there's a memory leak or exploit in qemu, we should prevent the
      host system trashing. However, the equation was too tightening, as it
      didn't reflect what the kernel counts into the memory used by a
      process. Since many hosts do have a swap, nobody hasn't noticed
      anything, because if hard memory limit is reached, process can
      continue allocating memory on a swap. However, if there is no swap on
      the host, the process gets killed by OOM killer. In our case, the qemu
      process it is.
      
      To prevent this, we need to relax the hard RSS limit. Moreover, we
      should reflect more precisely the kernel way of accounting the memory
      for process. That is, even the kernel caches are counted within the
      memory used by a process (within cgroups at least). Hence the magic
      equation has to be changed:
      
        limit = 1.5 * (domain memory + total video memory) + (32MB for cache
                per each disk) + 200MB
      3c83df67
  7. 21 12月, 2012 5 次提交
  8. 18 12月, 2012 1 次提交
  9. 29 11月, 2012 1 次提交
  10. 02 11月, 2012 1 次提交
  11. 24 10月, 2012 1 次提交
    • O
      qemu: Keep the affinity when creating cgroup for emulator thread · bb81021b
      Osier Yang 提交于
      When the cpu placement model is "auto", it sets the affinity for
      domain process with the advisory nodeset from numad, however,
      creating cgroup for the domain process (called emulator thread
      in some contexts) later overrides that with pinning it to all
      available pCPUs.
      
      How to reproduce:
      
        * Configure the domain with "auto" placement for <vcpu>, e.g.
          <vcpu placement='auto'>4</vcpu>
        * % virsh start dom
        * % cat /proc/$dompid/status
      
      Though the emulator cgroup cause conflicts, but we can't simply
      prohibit creating it, as other tunables are still useful, such
      as "emulator_period", which is used by API
      virDomainSetSchedulerParameter. So this patch doesn't prohibit
      creating the emulator cgroup, but inherit the nodeset from numad,
      and reset the affinity for domain process.
      
      * src/qemu/qemu_cgroup.h: Modify definition of qemuSetupCgroupForEmulator
                                to accept the passed nodenet
      * src/qemu/qemu_cgroup.c: Set the affinity with the passed nodeset
      bb81021b
  12. 20 10月, 2012 2 次提交
    • E
      blockjob: remove unused parameters after previous patch · 67aea3fb
      Eric Blake 提交于
      Minor cleanup made possible by previous simplifications.
      
      * src/qemu/qemu_cgroup.h (qemuSetupDiskCgroup)
      (qemuTeardownDiskCgroup): Alter signature.
      * src/qemu/qemu_cgroup.c (qemuSetupDiskCgroup)
      (qemuTeardownDiskCgroup, qemuSetupCgroup): Update all uses.
      * src/qemu/qemu_hotplug.c (qemuDomainDetachPciDiskDevice)
      (qemuDomainDetachDiskDevice): Likewise.
      * src/qemu/qemu_driver.c (qemuDomainAttachDeviceDiskLive)
      (qemuDomainChangeDiskMediaLive)
      (qemuDomainSnapshotCreateSingleDiskActive)
      (qemuDomainSnapshotUndoSingleDiskActive): Likewise.
      67aea3fb
    • E
      storage: use cache to walk backing chain · 38c4a9cc
      Eric Blake 提交于
      We used to walk the backing file chain at least twice per disk,
      once to set up cgroup device whitelisting, and once to set up
      security labeling.  Rather than walk the chain every iteration,
      which possibly includes calls to fork() in order to open root-squashed
      NFS files, we can exploit the cache of the previous patch.
      
      * src/conf/domain_conf.h (virDomainDiskDefForeachPath): Alter
      signature.
      * src/conf/domain_conf.c (virDomainDiskDefForeachPath): Require caller
      to supply backing chain via disk, if recursion is desired.
      * src/security/security_dac.c
      (virSecurityDACSetSecurityImageLabel): Adjust caller.
      * src/security/security_selinux.c
      (virSecuritySELinuxSetSecurityImageLabel): Likewise.
      * src/security/virt-aa-helper.c (get_files): Likewise.
      * src/qemu/qemu_cgroup.c (qemuSetupDiskCgroup)
      (qemuTeardownDiskCgroup): Likewise.
      (qemuSetupCgroup): Pre-populate chain.
      38c4a9cc
  13. 17 10月, 2012 1 次提交
    • M
      qemu: Pin the emulator when only cpuset is specified · ba63d8f7
      Martin Kletzander 提交于
      According to our recent changes (clarifications), we should be pinning
      qemu's emulator processes using the <vcpu> 'cpuset' attribute in case
      there is no <emulatorpin> specified.  This however doesn't work
      entirely as expected and this patch should resolve all the remaining
      issues.
      ba63d8f7
  14. 11 10月, 2012 1 次提交
  15. 21 9月, 2012 1 次提交
  16. 18 9月, 2012 2 次提交
  17. 12 9月, 2012 1 次提交
  18. 06 9月, 2012 1 次提交
    • M
      qemu: don't pin all the cpus · 9f86fb93
      Martin Kletzander 提交于
      This is another fix for the emulator-pin series. When going through
      the cputune pinning settings, the current code is trying to pin all
      the CPUs, even when not all of them are specified. This causes error
      in the subsequent function which, of course, cannot find the cpu to
      pin. Since it's enough to pass the correct VCPU ID to the function,
      the fix is trivial.
      9f86fb93
  19. 31 8月, 2012 1 次提交
    • J
      qemu: Don't ignore CPU tuning config if required cgroups are missing · 774eb45b
      Jiri Denemark 提交于
      When domain XML contains any of the elements for setting up CPU
      scheduling parameters (period, quota, emulator_period, or
      emulator_quota) we need cpu cgroup to enforce the configuration.
      However, the existing code would just ignore silently such settings if
      either cgroups were not available at all cpu cgroup was not available.
      Moreover, APIs for manipulating CPU scheduler parameters were already
      failing if cpu cgroup was not available. This patch makes cpu cgroup
      mandatory for all domains that use CPU scheduling elements in their XML.
      774eb45b
  20. 29 8月, 2012 1 次提交
    • J
      qemu: Fix starting domains with no cpu cgroup · 0c7cca36
      Jiri Denemark 提交于
      If cgroups are enabled in general but cpu cgroup is disabled in
      qemu.conf or not mounted at all, libvirt would refuse to start any
      domain even though scheduler parameters are not set in domain XML.
      
      This patch makes cpu cgroup mandatory only for domains that actually
      want to use it.
      0c7cca36
  21. 27 8月, 2012 1 次提交
    • M
      qemu: fix regression with pinning · 16ebec2b
      Martin Kletzander 提交于
      Commit 4b03d591 changed the pinning
      behavior in a way that makes some machines non-startable.
      
      The comment mentioning that we cannot control each vcpu when there is
      not VCPU<-> PID mapping available is true, however, this isn't
      necessarily an error, because this can be caused by old QEMU without
      support for "query-cpus" command as well as a software emulated
      machines that don't create more than one process.
      16ebec2b
  22. 22 8月, 2012 5 次提交
  23. 06 8月, 2012 1 次提交
    • M
      qemu: Set reasonable RSS limit on domain startup · addeb7cd
      Michal Privoznik 提交于
      If there's a memory leak in qemu or qemu is exploited the host's
      system will sooner or later start trashing instead of killing
      the bad process. This however has impact on performance and other
      guests as well. Therefore we should set a reasonable RSS limit
      even when user hasn't set any. It's better to be secure by default.
      addeb7cd
  24. 27 7月, 2012 1 次提交
    • E
      maint: don't permit format strings without % · 768007ae
      Eric Blake 提交于
      Any time we have a string with no % passed through gettext, a
      translator can inject a % to cause a stack overread.  When there
      is nothing to format, it's easier to ask for a string that cannot
      be used as a formatter, by using a trivial "%s" format instead.
      
      In the past, we have used --disable-nls to catch some of the
      offenders, but that doesn't get run very often, and many more
      uses have crept in.  Syntax check to the rescue!
      
      The syntax check can catch uses such as
      virReportError(code,
                     _("split "
                       "string"));
      by using a sed script to fold context lines into one pattern
      space before checking for a string without %.
      
      This patch is just mechanical insertion of %s; there are probably
      several messages touched by this patch where we would be better
      off giving the user more information than a fixed string.
      
      * cfg.mk (sc_prohibit_diagnostic_without_format): New rule.
      * src/datatypes.c (virUnrefConnect, virGetDomain)
      (virUnrefDomain, virGetNetwork, virUnrefNetwork, virGetInterface)
      (virUnrefInterface, virGetStoragePool, virUnrefStoragePool)
      (virGetStorageVol, virUnrefStorageVol, virGetNodeDevice)
      (virGetSecret, virUnrefSecret, virGetNWFilter, virUnrefNWFilter)
      (virGetDomainSnapshot, virUnrefDomainSnapshot): Add %s wrapper.
      * src/lxc/lxc_driver.c (lxcDomainSetBlkioParameters)
      (lxcDomainGetBlkioParameters): Likewise.
      * src/conf/domain_conf.c (virSecurityDeviceLabelDefParseXML)
      (virDomainDiskDefParseXML, virDomainGraphicsDefParseXML):
      Likewise.
      * src/conf/network_conf.c (virNetworkDNSHostsDefParseXML)
      (virNetworkDefParseXML): Likewise.
      * src/conf/nwfilter_conf.c (virNWFilterIsValidChainName):
      Likewise.
      * src/conf/nwfilter_params.c (virNWFilterVarValueCreateSimple)
      (virNWFilterVarAccessParse): Likewise.
      * src/libvirt.c (virDomainSave, virDomainSaveFlags)
      (virDomainRestore, virDomainRestoreFlags)
      (virDomainSaveImageGetXMLDesc, virDomainSaveImageDefineXML)
      (virDomainCoreDump, virDomainGetXMLDesc)
      (virDomainMigrateVersion1, virDomainMigrateVersion2)
      (virDomainMigrateVersion3, virDomainMigrate, virDomainMigrate2)
      (virStreamSendAll, virStreamRecvAll)
      (virDomainSnapshotGetXMLDesc): Likewise.
      * src/nwfilter/nwfilter_dhcpsnoop.c (virNWFilterSnoopReqLeaseDel)
      (virNWFilterDHCPSnoopReq): Likewise.
      * src/openvz/openvz_driver.c (openvzUpdateDevice): Likewise.
      * src/openvz/openvz_util.c (openvzKBPerPages): Likewise.
      * src/qemu/qemu_cgroup.c (qemuSetupCgroup): Likewise.
      * src/qemu/qemu_command.c (qemuBuildHubDevStr, qemuBuildChrChardevStr)
      (qemuBuildCommandLine): Likewise.
      * src/qemu/qemu_driver.c (qemuDomainGetPercpuStats): Likewise.
      * src/qemu/qemu_hotplug.c (qemuDomainAttachNetDevice): Likewise.
      * src/rpc/virnetsaslcontext.c (virNetSASLSessionGetIdentity):
      Likewise.
      * src/rpc/virnetsocket.c (virNetSocketNewConnectUNIX)
      (virNetSocketSendFD, virNetSocketRecvFD): Likewise.
      * src/storage/storage_backend_disk.c
      (virStorageBackendDiskBuildPool): Likewise.
      * src/storage/storage_backend_fs.c
      (virStorageBackendFileSystemProbe)
      (virStorageBackendFileSystemBuild): Likewise.
      * src/storage/storage_backend_rbd.c
      (virStorageBackendRBDOpenRADOSConn): Likewise.
      * src/storage/storage_driver.c (storageVolumeResize): Likewise.
      * src/test/test_driver.c (testInterfaceChangeBegin)
      (testInterfaceChangeCommit, testInterfaceChangeRollback):
      Likewise.
      * src/vbox/vbox_tmpl.c (vboxListAllDomains): Likewise.
      * src/xenxs/xen_sxpr.c (xenFormatSxprDisk, xenFormatSxpr):
      Likewise.
      * src/xenxs/xen_xm.c (xenXMConfigGetUUID, xenFormatXMDisk)
      (xenFormatXM): Likewise.
      768007ae
  25. 23 7月, 2012 1 次提交
    • O
      Desert the FSF address in copyright · f9ce7dad
      Osier Yang 提交于
      Per the FSF address could be changed from time to time, and GNU
      recommends the following now: (http://www.gnu.org/licenses/gpl-howto.html)
      
        You should have received a copy of the GNU General Public License
        along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
      
      This patch removes the explicit FSF address, and uses above instead
      (of course, with inserting 'Lesser' before 'General').
      
      Except a bunch of files for security driver, all others are changed
      automatically, the copyright for securify files are not complete,
      that's why to do it manually:
      
        src/security/security_selinux.h
        src/security/security_driver.h
        src/security/security_selinux.c
        src/security/security_apparmor.h
        src/security/security_apparmor.c
        src/security/security_driver.c
      f9ce7dad
  26. 19 7月, 2012 2 次提交
  27. 11 7月, 2012 1 次提交
    • E
      build: detect all improper uses of _("%s") · 0867a877
      Eric Blake 提交于
      The only useful translation of "%s" as a format string is "%s" (I
      suppose you could claim "%1$s" is also valid, but why bother).  So
      it is not worth translating; fixing this exposes some instances
      where we were failing to translate real error messages.  This makes
      the fix of commit 097da1ab more generic, as well as ensuring no
      future regressions.
      
      * cfg.mk (sc_prohibit_useless_translation): New rule.
      * src/lxc/lxc_driver.c (lxcSetVcpuBWLive): Fix offender.
      * src/openvz/openvz_conf.c (openvzReadFSConf): Likewise.
      * src/qemu/qemu_cgroup.c (qemuSetupCgroupForVcpu): Likewise.
      * src/qemu/qemu_driver.c (qemuSetVcpusBWLive): Likewise.
      * src/xenapi/xenapi_utils.c (xenapiSessionErrorHandle): Likewise.
      0867a877