1. 27 6月, 2016 13 次提交
    • 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 6 次提交