1. 17 3月, 2015 1 次提交
    • E
      daemon: avoid memleak when ListAll returns nothing · 117f60ca
      Eric Blake 提交于
      Commit 4f25146b (v1.2.8) managed to silence Coverity, but at the
      cost of a memory leak detected by valgrind:
      ==24129== 40 bytes in 5 blocks are definitely lost in loss record 355 of 637
      ==24129==    at 0x4A08B1C: realloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
      ==24129==    by 0x5084B8E: virReallocN (viralloc.c:245)
      ==24129==    by 0x514D5AA: virDomainObjListExport (domain_conf.c:22200)
      ==24129==    by 0x201227DB: qemuConnectListAllDomains (qemu_driver.c:18042)
      ==24129==    by 0x51CC1B6: virConnectListAllDomains (libvirt-domain.c:6797)
      ==24129==    by 0x14173D: remoteDispatchConnectListAllDomains (remote.c:1580)
      ==24129==    by 0x121BE1: remoteDispatchConnectListAllDomainsHelper (remote_dispatch.h:1072)
      
      In short, every time a client calls a ListAll variant and asks
      for the resulting list, but there are 0 elements to return, we
      end up leaking the 1-entry array that holds the NULL terminator.
      
      What's worse, a read-only client can access these functions in a
      tight loop to cause libvirtd to eventually run out of memory; and
      this can be considered a denial of service attack against more
      privileged clients.  Thankfully, the leak is so small (8 bytes per
      call) that you would already have some other denial of service with
      any guest calling the API that frequently, so an out-of-memory
      crash is unlikely enough that this did not warrant a CVE.
      
      * daemon/remote.c (remoteDispatchConnectListAllDomains)
      (remoteDispatchDomainListAllSnapshots)
      (remoteDispatchDomainSnapshotListAllChildren)
      (remoteDispatchConnectListAllStoragePools)
      (remoteDispatchStoragePoolListAllVolumes)
      (remoteDispatchConnectListAllNetworks)
      (remoteDispatchConnectListAllInterfaces)
      (remoteDispatchConnectListAllNodeDevices)
      (remoteDispatchConnectListAllNWFilters)
      (remoteDispatchConnectListAllSecrets)
      (remoteDispatchNetworkGetDHCPLeases): Plug leak.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      (cherry picked from commit 3c2ff502)
      117f60ca
  2. 10 3月, 2015 1 次提交
    • L
      qemu: don't fill in nicindexes for session mode libvirtd · a4613757
      Laine Stump 提交于
      Commit 4bbe1029 fixed a problem in commit f7afeddc by moving the call
      to virNetDevGetIndex() to a location common to all interface types (so
      that the nicindex array would be filled in for macvtap as well as tap
      interfaces), but the location was *too* common, as the original call
      to virNetDevGetIndex() had been in a section qualified by "if
      (cfg->privileged)". The result was that the "fixed" libvirtd would try
      to call virNetDevGetIndex() even for session mode libvirtd, and end up
      failing with the log message:
      
        Unable to open control socket: Operation not permitted
      
      To remedy that, this patch qualifies the call to virNetDevGetIndex()
      in its new location with cfg->privileged.
      
      This resolves https://bugzilla.redhat.com/show_bug.cgi?id=1198244
      
      (cherry picked from commit 705242f8)
      a4613757
  3. 02 3月, 2015 1 次提交
  4. 27 2月, 2015 3 次提交
  5. 26 2月, 2015 8 次提交
    • P
      util: storage: Fix error type in virStorageSourceParseBackingURI · ef2e6f40
      Peter Krempa 提交于
      The gluster volume name extraction code was copied from the XML parser
      without changing the VIR_ERR_XML_ERROR error code. Use
      VIR_ERR_CONFIG_UNSUPPORTED instead.
      ef2e6f40
    • P
      util: storagefile: Don't crash on gluster URIs without path · fc56ecd7
      Peter Krempa 提交于
      Similar to commit fdb80ed4 libvirtd
      would crash if a gluster URI without path would be used in the backing
      chain of a volume. The crash happens in the gluster specific part of the
      parser that extracts the gluster volume name from the path.
      
      Fix the crash by checking that the PATH is NULL.
      
      This patch does not contain a test case as it's not possible to test it
      with the current infrastructure as the test suite would attempt to
      contact the gluster server in the URI. I'm working on the test suite
      addition but that will be post-release material.
      
      Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1196528
      fc56ecd7
    • J
      conf: error out on missing dhcp host attributes · b15b21f3
      Ján Tomko 提交于
      In virNetworkDHCPHostDefParseXML an error is reported
      when partialOkay == true, and none of ip, mac, name
      were supplied.
      
      Add the missing goto and error out in this case.
      b15b21f3
    • L
      conf: error out on invalid host id · 719cd218
      Luyao Huang 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=1196503
      
      We already check whether the host id is valid or not, add a jump
      to forbid invalid host id.
      Signed-off-by: NLuyao Huang <lhuang@redhat.com>
      Signed-off-by: NJán Tomko <jtomko@redhat.com>
      719cd218
    • L
      qemu: fix ifindex array reported to systemd · 4bbe1029
      Laine Stump 提交于
      Commit f7afeddc added code to report to systemd an array of interface
      indexes for all tap devices used by a guest. Unfortunately it not only
      didn't add code to report the ifindexes for macvtap interfaces
      (interface type='direct') or the tap devices used by type='ethernet',
      it ended up sending "-1" as the ifindex for each macvtap or hostdev
      interface. This resulted in a failure to start any domain that had a
      macvtap or hostdev interface (or actually any type other than
      "network" or "bridge").
      
      This patch does the following with the nicindexes array:
      
      1) Modify qemuBuildInterfaceCommandLine() to only fill in the
      nicindexes array if given a non-NULL pointer to an array (and modifies
      the test jig calls to the function to send NULL). This is because
      there are tests in the test suite that have type='ethernet' and still
      have an ifname specified, but that device of course doesn't actually
      exist on the test system, so attempts to call virNetDevGetIndex() will
      fail.
      
      2) Even then, only add an entry to the nicindexes array for
      appropriate types, and to do so for all appropriate types ("network",
      "bridge", and "direct"), but only if the ifname is known (since that
      is required to call virNetDevGetIndex().
      4bbe1029
    • L
      util: check for null ifname inside virNetDevBandwidthSet() · 153b06c6
      Laine Stump 提交于
      Previously this function relied on having ATTRIBUTE_NONNULL(1) in its
      prototype rather than explicitly checking for a null
      ifname. Unfortunately, ATTRIBUTE_NONNULL is just a hint to the
      optimizer and code analyzers like Coverity, it doesn't actually check
      anything at execution time, so the result was possible warnings from
      Coverity, along with the possibility of null dereferences when ifname
      wasn't available.
      
      This patch removes the ATTRIBUTE_NONNULL from the prototype, and
      checks ifname inside the function, logging an error if it's NULL (once
      we've determined that the user really is trying to set a bandwidth).
      153b06c6
    • L
      network: only clear bandwidth if it has been set · 118b2408
      Laine Stump 提交于
      libvirt was unconditionally calling virNetDevBandwidthClear() for
      every interface (and network bridge) of a type that supported
      bandwidth, whether it actually had anything set or not. This doesn't
      hurt anything (unless ifname == NULL!), but is wasteful.
      
      This patch makes sure that all calls to virNetDevBandwidthClear() are
      qualified by checking that the interface really had some bandwidth
      setup done, and checks for a null ifname inside
      virNetDevBandwidthClear(), silently returning success if it is null
      (as well as removing the ATTRIBUTE_NONNULL from that function's
      prototype, since we can't guarantee that it is never null,
      e.g. sometimes a type='ethernet' interface has no ifname as it is
      provided on the fly by qemu).
      118b2408
    • P
      schema: Allow interleaving the /domain/os/type element · 18f9f69b
      Peter Krempa 提交于
      The element wasn't declared under the interleave thus it was required
      always to be first. This made it inconvenient when pasting new stuff to
      the XML manually in the "wrong" place.
      18f9f69b
  6. 25 2月, 2015 10 次提交
  7. 24 2月, 2015 5 次提交
  8. 23 2月, 2015 2 次提交
    • D
      po: Add config file for zanata · 4989d41b
      Daniel P. Berrange 提交于
      Add configuration file for use with https://fedora.zanata.org
      translation system
      4989d41b
    • M
      libvirt-guests: Allow time sync on guests resume · 0fa15b19
      Michal Privoznik 提交于
      Well, imagine domains were running, and as the host went down, they
      were managesaved. Later, after some time, the host went up again and
      domains got restored. But without correct time. And depending on how
      long was the host shut off, it may take some time for ntp to sync the
      time too. But hey, wait a minute. We have an API just for that! So:
      
      1) Introduce SYNC_TIME variable in libvirt-guests.sysconf to allow
      users control over the new functionality
      2) Call 'virsh domtime --sync $dom' in the libvirt-guests script.
      
      Unfortunately, this is all-or-nothing approach (just like anything
      else with the script). Domains are required to have configured and
      running qemu-ga inside.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      0fa15b19
  9. 22 2月, 2015 1 次提交
  10. 21 2月, 2015 8 次提交
    • M
      libxl: support backend domain setting for disk and net devices · d0106d58
      Marek Marczykowski 提交于
      This implement handling of <backenddomain name=''/>  parameter introduced
      in previous patch.
      
      Works on Xen >= 4.3, because only there libxl supports setting backend
      domain by name.  Specifying backend domain by ID or UUID is currently not
      supported.
      Signed-off-by: NMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
      d0106d58
    • M
      conf: support backend domain name in disk and network devices · c374353c
      Marek Marczykowski 提交于
      At least Xen supports backend drivers in another domain (aka "driver
      domain"). This patch introduces an XML config option for specifying the
      backend domain name for <disk> and <interface> devices.  E.g.
      
        <disk>
          <backenddomain name='diskvm'/>
          ...
        </disk>
        <interface type='bridge'>
          <backenddomain name='netvm'/>
          ...
        </interface>
      
      In the future, same option will be needed for USB devices (hostdev
      objects), but for now libxl doesn't have support for PVUSB.
      Signed-off-by: NMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
      c374353c
    • L
      network: allow <pf> together with <interface>/<address> in network status · 8f8e581a
      Laine Stump 提交于
      The function that parses the <forward> subelement of a network used to
      fail/log an error if the network definition contained both a <pf>
      element as well as at least one <interface> or <address> element. That
      check was present because the configuration of a network should have
      either one <pf>, one or more <interface>, or one or more <address>,
      but never combinations of multiple kinds.
      
      This caused a problem when libvirtd was restarted with a network
      already active - when a network with a <pf> element is started, the
      referenced PF (Physical Function of an SRIOV-capable network card) is
      checked for VFs (Virtual Functions), and the <forward> is filled in
      with a list of all VFs for that PF either in the form of their PCI
      addresses (a list of <address>) or their netdev names (a list of
      <interface>); the <pf> element is not removed though. When libvirtd is
      restarted, it parses the network status and finds both the original
      <pf> from the config, as well as the list of either <address> or
      <interface>, fails the parse, and the network is not added to the
      active list. This failure is often obscured because the network is
      marked as autostart so libvirt immediately restarts it.
      
      It seems odd to me that <interface> and <address> are stored in the
      same array rather than keeping two separate arrays, and having
      separate arrays would have made the check much simpler. However,
      changing to use two separate arrays would have required changes in
      more places, potentially creating more conflicts and (more
      importantly) more possible regressions in the event of a backport, so
      I chose to keep the existing data structure in order to localize the
      change.
      
      It appears that this problem has been in the code ever since support
      for <pf> was added (0.9.10), but until commit
      34cc3b2f (first in libvirt 1.2.4)
      networks with interface pools were not properly marked as active on
      restart anyway, so there is no point in backporting this patch any
      further than that.
      8f8e581a
    • P
      qemu: caps: Add capability bit for the "pc-dimm" device · 103707d4
      Peter Krempa 提交于
      The pc-dimm device represents a RAM memory module.
      103707d4
    • P
      conf: Hoist validation of memory size into the post parse callback · e5c7864c
      Peter Krempa 提交于
      Later patches will need to access the full definition to do check the
      memory size and thus the checking needs to be done after the whole
      definition including devices is known.
      e5c7864c
    • P
      conf: numa: Check ABI stability of NUMA configuration · b98596a7
      Peter Krempa 提交于
      Add helper to compare initial sizes of indivitual NUMA nodes and the map
      of belonging vCPUs. Other configuration is not ABI.
      b98596a7
    • P
      conf: ABI: Hugepage backing definition is not guest ABI · e431c3c0
      Peter Krempa 提交于
      The backing of the vm's memory isn't influencing the guest ABI thus
      shouldn't be checked.
      e431c3c0
    • P
      conf: Move all NUMA configuration to virDomainNuma · 181742d4
      Peter Krempa 提交于
      For historical reasons data regarding NUMA configuration were split
      between the CPU definition and numatune. We cannot do anything about the
      XML still being split, but we certainly can at least store the relevant
      data in one place.
      
      This patch moves the NUMA stuff to the right place.
      181742d4