1. 27 6月, 2016 18 次提交
    • L
      qemu: forbid setting guest-side IP address/route info of <interface> · d987f63a
      Laine Stump 提交于
      libvirt's qemu driver doesn't have direct access to the config on the
      guest side of a network interface, and currently doesn't have any
      method in place to even inform the guest of the desired config. In the
      future, an unenforceable attempt to set the guest-side IP info could
      be made by adding a static host entry to the appropriate dnsmasq
      configuration (or changing the default dhcp client address on the qemu
      commandline for type='user' interfaces), or enhancing the guest agent
      to allow setting an IP address, but for now it can't have any effect,
      and we don't want to give the illusion that it does.
      
      To prevent the "disappearance" of any existing configs with ip
      address/route info (due to parser failure), this check is added in the
      newly implemented qemuDomainDeviceDefValidate(), which is only called
      when a domain is defined or started, *not* when it is reread from disk
      at libvirtd startup.
      d987f63a
    • L
      conf: use virNetDevIPInfo for guest-side <interface> config · fbc1843d
      Laine Stump 提交于
      All the same information was already there, just in slightly different
      places in the virDomainNetDef.
      fbc1843d
    • L
      conf: use virNetDevIPInfo in virDomainHostdevCaps · 69e04044
      Laine Stump 提交于
      a.k.a. <hostdev mode='capabilities' type='net'>.
      
      This replaces the existing nips, ips, nroutes, and routes with a
      single virNetDevIPInfo, and simplifies the code by calling that
      object's parse/format/clear functions instead of open coding.
      69e04044
    • L
      conf: single object containing list of IP addresses, list of routes · 9911562a
      Laine Stump 提交于
      There are currently two places in the domain where this combination is
      used, and there is about to be another. This patch puts them together
      for brevity and uniformity.
      
      As with the newly-renamed virNetDevIPAddr and virNetDevIPRoute
      objects, the new virNetDevIPInfo object will need to be accessed by a
      utility function that calls low level Netlink functions (so we don't
      want it to be in the conf directory) and will be called from multiple
      hypervisor drivers (so it can't be in any hypervisor directory); the
      most appropriate place is thus once again the util directory.
      
      The parse and format functions are in conf/domain_conf.c because only
      the domain XML (i.e. *not* the network XML) has this exact combination
      of IP addresses plus routes. Note that virDomainNetIPInfoFormat() will
      end up being the only caller to virDomainNetRoutesFormat() and
      virDomainNetIPsFormat(), so it will just subsume those functions in a
      later patch, but we can't do that until they are no longer called.
      
      (It would have been nice to include the interface name within the
      virNetDevIPInfo object (with a slight name change), but that can't
      be done cleanly, because in each case the interface name is provided
      in a different place in the XML relative to the routes and IP
      addresses, so putting it in this object would actually make the code
      more confused rather than simpler).
      9911562a
    • L
      util: move IP route & address object-related functions to virnetdevip.c · fa18e814
      Laine Stump 提交于
      These functions all need to be called from a utility function that
      must be located in the util directory, so we move them all into
      util/virnetdevip.[ch] now that it exists.
      
      Function and struct names were appropriately changed for the new
      location, but all code is unchanged aside from motion and renaming.
      fa18e814
    • L
      util: new files virnetdevip.[ch] for IP-related netdev functions · cf0568b0
      Laine Stump 提交于
      This patch splits virnetdev.[ch] into multiple files, with the new
      virnetdevip.[ch] containing all the functions related to setting and
      retrieving IP-related info for a device (both addresses and routes).
      cf0568b0
    • L
      conf/openvz: eliminate incorrect/undocumented use of <source dev='blah'/> · 9658e70f
      Laine Stump 提交于
      When support for <interface type='ethernet'> was added in commit
      9a4b705f back in 2010, it erroneously looked at <source dev='blah'/>
      for a user-specified guest-side interface name. This was never
      documented though. (that attribute already existed at the time in the
      data.ethernet union member of virDomainNetDef, but apparently had no
      practical use - it was only used as a storage place for a NetDef's
      bridge name during qemuDomainXMLToNative(), but even then that was
      never used for anything).
      
      When support for similar guest-side device naming was added to the lxc
      driver several years later, it was put in a new subelement <guest
      dev='blah'/>.
      
      In the intervening years, since there was no validation that
      ethernet.dev was NULL in the other drivers that didn't actually use
      it, innocent souls who were adding other features assuming they needed
      to account for non-NULL ethernet.dev when really they didn't, so
      little bits of the usual pointless cargo-cult code showed up.
      
      This patch not only switches the openvz driver to use the documented
      <guest dev='blah'/> notation for naming the guest-side device (just in
      case anyone is still using the openvz driver), and logs an error if
      anyone tries to set <source dev='blah'/> for a type='ethernet'
      interface, it also removes the cargo-cult uses of ethernet.dev and
      <source dev='blah'/>, and eliminates if from the RNG and from
      virDomainNetDef.
      
      NB: I decided on this course of action after mentioning the
      inconsistency here:
      
        https://www.redhat.com/archives/libvir-list/2016-May/msg02038.html
      
      and getting encouragement do eliminate it in a later IRC discussion
      with danpb.
      9658e70f
    • L
      qemu: eliminate memory leaks when converting NetDefs to type='ethernet' · a71fd239
      Laine Stump 提交于
      in qemuConnectDomainXMLToNative. This function was only accounting for
      about 1/10 of all the allocated items in the NetDef prior to memseting
      it to all 0's. On top of that, it was going to great pains to learn
      the name of the bridge device, but then never doing anything useful
      with it (just putting it into data.ethernet.dev, which is *never* used
      when building a qemu commandline). (I think this again all started off
      as code with good intentions, but it was never completed, and instead
      was just Frankensteinically cargo-culted into the odd mish mash we
      have today).
      
      The resulting code is much simpler, produces exactly the same output,
      and doesn't leak memory.
      a71fd239
    • L
      qemu: don't set/clear NetDef IP addresses in qemuConnectDomainXMLToNative() · 91045092
      Laine Stump 提交于
      This patch removes the expanded and duplicated code that all sprung
      out of two well-intentioned-but-useless settings of
      net->data.(bridge|ethernet).ipaddr.
      
      qemu has never supported even a single IP address in the interface
      config, much less a list of them. All of the instances of "clearing
      out the IP addresses" that are now in this function originated with
      commit d8dbd6 "Basic domain XML conversions for Xen/QEMU drivers" in
      May 2009, but even then the single "ipaddr" in the struct for
      type='ethernet' and type='bridge' wasn't used in the qemu driver (only
      in xen and openvz). Since then anyone who added a new interface type
      also tacked on another unnecessary clearing of ipaddr, and when it was
      made into a list of IPs (so far supported only by the LXC driver) this
      simple setting was turned into a loop (well, multiple loops) to clear
      them all.
      91045092
    • L
      conf: new function virDomainNetDefClear · 7cfbaad1
      Laine Stump 提交于
      We need to clear these out without freeing the object completely.
      7cfbaad1
    • L
      lxc: use correct prefix when setting veth IP address · 70a2c7e0
      Laine Stump 提交于
      Commit c9a641 (first appearred in 1.2.12) added support for setting
      the guest-side IP address of veth devices in lxc domains.
      Unfortunately, it hardcoded the assumption that the proper prefix for
      any IP address with no explicit prefix in the config should be "24";
      that is only correct for class C IPv4 addresses, but not for any other
      IPv4 address, nor for any IPv6 address.
      
      The good news is that there is already a function in libvirt that will
      determine the proper default prefix for any IP address. This patch
      replaces the use of the ill-fated VIR_SOCKET_ADDR_DEFAULT_PREFIX with
      calls to virSocketAddrGetIPPrefix().
      70a2c7e0
    • L
      lxc: eliminate extraneous free of netDef->ifname_guest · f03a4a2a
      Laine Stump 提交于
      lxcContainerRenameAndEnableInterfaces() isn't making a copy of the
      interface's ifname_guest (into newname), it's just copying the pointer
      to it. This means that when it later calls VIR_FREE(newname), it's
      actually freeing up (and fortunately NULLing out, so at least we don't
      try to access free'd memory) netDef->ifname_guest.
      f03a4a2a
    • L
      util: allow calling virSocketAddrGetIPPrefix with NULL netmask or address · 9359167e
      Laine Stump 提交于
      There are times when we don't have a netmask pointer to give to
      virSocketAddrGetIPPrefix() (e.g. the IP addresses in domain interfaces
      only have a prefix, no netmask), but it would have caused a segv if we
      called it with NULL instead of a pointer to a netmask. This patch
      qualifies the code that would use the netmask or address pointers to
      check for NULL first.
      9359167e
    • L
      tests: mock virNetDevSetIPAddress · e1219b6f
      Laine Stump 提交于
      Now that we can include <interface type='ethernet'> in tests, we could
      almost test XML that has an <ip> element in an interface. Except that
      the test fails when it tries to actually set the IP address for the
      interface's tap device. This patch mocks virNetDevSetIPAddress() to
      just return success.
      e1219b6f
    • L
      conf: clean up virDomainNetIPParseXML() · bfd2de6e
      Laine Stump 提交于
      Rearrange this function to be better organized and more correct:
      
      * the error codes were changed from the incorrect INVALID_ARG to
        XML_ERROR
      
      * prefix still isn't required, but if present it must be valid or an
        error will be logged.
      
      * don't emit a debug log just because prefix is missing - this
        is valid.
      
      * group everything related to setting prefix in one place rather than
        scattered through the function.
      bfd2de6e
    • L
      global: consistently use IP rather than Ip in identifiers · 22a6873a
      Laine Stump 提交于
      I'm tired of mistyping this all the time, so let's do it the same all
      the time (similar to how we changed all "Pci" to "PCI" awhile back).
      
      (NB: I've left alone some things in the esx and vbox drivers because
      I'm unable to compile them and they weren't obviously *not* a part of
      some API. I also didn't change a couple of variables named,
      e.g. "somethingIptables", because they were derived from the name of
      the "iptables" command)
      22a6873a
    • L
      util: move virInterface(State|Link)/virNetDevFeature from conf to util · 638c6e5b
      Laine Stump 提交于
      These had been declared in conf/device_conf.h, but then used in
      util/virnetdev.c, meaning that we had to #include conf/device_conf.h
      in virnetdev.c (which we have for a long time said shouldn't be done.
      
      This caused a bigger problem when I tried to #include util/virnetdev.h
      in a file in src/conf (which is allowed) - for some reason the
      "device_conf.h: File not found" error.
      
      The solution is to move the data types and functions used in util
      sources from conf to util. Some names were adjusted during the move
      ("virInterface" --> "virNetDevIf", and "VIR_INTERFACE" -->
      "VIR_NETDEV_IF")
      638c6e5b
    • L
      util: move virNetDevLinkDump to virnetlink.c · 943a400c
      Laine Stump 提交于
      virNetDevLinkDump should have been in virnetlink.c, but that file
      didn't exist yet when the function was created. It didn't really
      matter until now - I found that having virnetlink.h included by
      virnetdev.h caused build problems when trying to #include virnetdev.h
      in a .c file in src/conf (due to missing directory in -I). Rather than
      fix that to further institutionalize the incorrect placement of this
      one function, this patch moves the function.
      943a400c
  2. 26 6月, 2016 21 次提交
  3. 25 6月, 2016 1 次提交
    • Q
      cpu_map.xml: add cmt/mbm feature to x86 · f294b83e
      Qiaowei Ren 提交于
      Some Intel processor families (e.g. the Intel Xeon processor E5 v3
      family) introduced some PQos (Platform Qos) features, including CMT
      (Cache Monitoring technology) and MBM (Memory Bandwidth Monitoring),
      to monitor or control shared resource. This patch add them into x86
      part of cpu_map.xml to be used for applications based on libvirt to
      get cpu capabilities. For example, Nova in OpenStack schedules guests
      based on the CPU features that the host has.
      Signed-off-by: NQiaowei Ren <qiaowei.ren@intel.com>
      f294b83e