1. 27 4月, 2014 1 次提交
    • L
      network: fix virNetworkObjAssignDef and persistence · 440beeb7
      Laine Stump 提交于
      Experimentation showed that if virNetworkCreateXML() was called for a
      network that was already defined, and then the network was
      subsequently shutdown, the network would continue to be persistent
      after the shutdown (expected/desired), but the original config would
      be lost in favor of the transient config sent in with
      virNetworkCreateXML() (which would then be the new persistent config)
      (obviously unexpected/not desired).
      
      To fix this, virNetworkObjAssignDef() has been changed to
      
      1) properly save/free network->def and network->newDef for all the
      various combinations of live/active/persistent, including some
      combinations that were previously considered to be an error but didn't
      need to be (e.g. setting a "live" config for a network that isn't yet
      active but soon will be - that was previously considered an error,
      even though in practice it can be very useful).
      
      2) automatically set the persistent flag whenever a new non-live
      config is assigned to the network (and clear it when the non-live
      config is set to NULL). the libvirt network driver no longer directly
      manipulates network->persistent, but instead relies entirely on
      virNetworkObjAssignDef() to do the right thing automatically.
      
      After this patch, the following sequence will behave as expected:
      
      virNetworkDefineXML(X)
      virNetworkCreateXML(X') (same name but some config different)
      virNetworkDestroy(X)
      
      At the end of these calls, the network config will remain as it was
      after the initial virNetworkDefine(), whereas previously it would take
      on the changes given during virNetworkCreateXML().
      
      Another effect of this tighter coupling between a) setting a !live def
      and b) setting/clearing the "persistent" flag, is that future patches
      which change the details of network lifecycle management
      (e.g. upcoming patches to fix detection of "active" networks when
      libvirtd is restarted) will find it much more difficult to break
      persistence functionality.
      440beeb7
  2. 26 3月, 2014 1 次提交
    • L
      network: fix problems with SRV records · 6612d1ad
      Laine Stump 提交于
      A patch submitted by Steven Malin last week pointed out a problem with
      libvirt's DNS SRV record configuration:
      
        https://www.redhat.com/archives/libvir-list/2014-March/msg00536.html
      
      When searching for that message later, I found another series that had
      been posted by Guannan Ren back in 2012 that somehow slipped between
      the cracks:
      
        https://www.redhat.com/archives/libvir-list/2012-July/msg00236.html
      
      That patch was very much out of date, but also pointed out some real
      problems.
      
      This patch fixes all the noted problems by refactoring
      virNetworkDNSSrvDefParseXML() and networkDnsmasqConfContents(), then
      verifies those fixes by added several new records to the test case.
      
      Problems fixed:
      
      * both service and protocol now have an underscore ("_") prepended on
        the commandline, as required by RFC2782.
      
        <srv service='sip' protocol='udp' domain='example.com'
             target='tests.example.com' port='5060' priority='10'
             weight='150'/>
      
        before: srv-host=sip.udp.example.com,tests.example.com,5060,10,150
        after:  srv-host=_sip._udp.example.com,tests.example.com,5060,10,150
      
      * if "domain" wasn't specified in the <srv> element, the extra
        trailing "." will no longer be added to the dnsmasq commandline.
      
        <srv service='sip' protocol='udp' target='tests.example.com'
             port='5060' priority='10' weight='150'/>
      
        before: srv-host=sip.udp.,tests.example.com,5060,10,150
        after:  srv-host=_sip._udp,tests.example.com,5060,10,150
      
      * when optional attributes aren't specified, the separating comma is
        also now not placed on the dnsmasq commandline. If optional
        attributes in the middle of the line are not specified, they are
        replaced with a default value in the commandline (1 for port, 0 for
        priority and weight).
      
        <srv service='sip' protocol='udp' target='tests.example.com'
             port='5060'/>
      
        before: srv-host=sip.udp.,tests.example.com,5060,,
        after:  srv-host=_sip._udp,tests.example.com,5060
      
        (actually the would have generated an error, because "optional"
        attributes weren't really optional.)
      
      * The allowed characters for both service and protocol are now limited
        to alphanumerics, plus a few special characters that are found in
        existing names in /etc/services and /etc/protocols. (One exception
        is that both of these files contain names with an embedded ".", but
        "."  can't be used in these fields of an SRV record because it is
        used as a field separator and there is no method to escape a "."
        into a field.) (Previously only the strings "tcp" and "udp" were
        allowed for protocol, but this restriction has been removed, since
        RFC2782 specifically says that it isn't limited to those, and that
        anyway it is case insensitive.)
      
      * the "domain" attribute is no longer required in order to recognize
        the port, priority, and weight attributes during parsing. Only
        "target" is required for this.
      
      * if "target" isn't specified, port, priority, and weight are not
        allowed (since they are meaningless - an empty target means "this
        service is *not available* for this domain").
      
      * port, priority, and weight are now truly optional, as the comments
        originally suggested, but which was not actually true.
      6612d1ad
  3. 25 3月, 2014 1 次提交
  4. 14 3月, 2014 1 次提交
  5. 10 3月, 2014 1 次提交
    • M
      conf: Utilize more of VIR_(APPEND|INSERT|DELETE)_ELEMENT · 2133441a
      Michal Privoznik 提交于
      This fixes a possible double free. In virNetworkAssignDef() if
      virBitmapNew() fails, then virNetworkObjFree(network) is called.
      However, with network->def pointing to actual @def. So if caller
      frees @def again, ...
      
      Moreover, this fixes one possible memory leak too. In
      virInterfaceAssignDef() if appending to the list of interfaces
      fails, we ought to call virInterfaceObjFree() instead of bare
      VIR_FREE().
      
      Although, in order to do that some array size variables needs
      to be turned into size_t rather than int.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      2133441a
  6. 18 2月, 2014 2 次提交
  7. 11 2月, 2014 1 次提交
    • M
      virNetworkLoadState: Disallow mangled 'floor' element · 28900766
      Michal Privoznik 提交于
      In the network status XML we may have the <floor/> element with the
      'sum' attribute. The attribute represents sum of all 'floor'-s of
      computed over each interface connected to the network (this is needed to
      guarantee certain bandwidth for certain domain). The sum is therefore a
      number. However, if the number was mangled (e.g. by an user's
      interference to network status file), we've just ignored it without
      refusing to parse such file. This was all due to 'goto error' missing.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      28900766
  8. 04 2月, 2014 1 次提交
    • L
      network: change default of forwardPlainNames to 'yes' · 66f75925
      Laine Stump 提交于
      The previous patch fixed "forwardPlainNames" so that it really is
      doing only what is intended, but left the default to be
      "forwardPlainNames='no'". Discussion around the initial version of
      that patch led to the decision that the default should instead be
      "forwardPlainNames='yes'" (i.e. the original behavior before commit
      f3886825). This patch makes that change to the default.
      66f75925
  9. 16 1月, 2014 1 次提交
  10. 21 11月, 2013 1 次提交
    • E
      maint: fix comma style issues: conf · 6f4901e1
      Eric Blake 提交于
      Most of our code base uses space after comma but not before;
      fix the remaining uses before adding a syntax check.
      
      * src/conf/capabilities.c: Consistently use commas.
      * src/conf/domain_conf.c: Likewise.
      * src/conf/network_conf.c: Likewise.
      * src/conf/storage_conf.c: Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      6f4901e1
  11. 15 10月, 2013 1 次提交
    • E
      maint: avoid 'const fooPtr' in conf · 539a9fae
      Eric Blake 提交于
      'const fooPtr' is the same as 'foo * const' (the pointer won't
      change, but it's contents can).  But in general, if an interface
      is trying to be const-correct, it should be using 'const foo *'
      (the pointer is to data that can't be changed).
      
      Fix up remaining offenders in src/conf, and their fallout.
      
      * src/conf/snapshot_conf.h (virDomainSnapshotAssignDef)
      (virDomainSnapshotFindByName): Drop attempt at const.
      * src/conf/interface_conf.h (virInterfaceObjIsActive)
      (virInterfaceDefFormat): Use intended type.
      (virInterfaceFindByMACString, virInterfaceFindByName)
      (virInterfaceAssignDef, virInterfaceRemove): Drop attempt at
      const.
      * src/conf/network_conf.h (virNetworkObjIsActive)
      (virNetworkDefFormat, virNetworkDefForwardIf)
      (virNetworkDefGetIpByIndex, virNetworkIpDefPrefix)
      (virNetworkIpDefNetmask): Use intended type.
      (virNetworkFindByUUID, virNetworkFindByName, virNetworkAssignDef)
      (virNetworkObjAssignDef, virNetworkRemoveInactive)
      (virNetworkBridgeInUse, virNetworkSetBridgeName)
      (virNetworkAllocateBridge): Drop attempt at const.
      * src/conf/netdev_vlan_conf.h (virNetDevVlanFormat): Make
      const-correct.
      * src/conf/node_device_conf.h (virNodeDeviceHasCap)
      (virNodeDeviceDefFormat): Use intended type.
      (virNodeDeviceFindByName, virNodeDeviceFindBySysfsPath)
      (virNodeDeviceAssignDef, virNodeDeviceObjRemove)
      (virNodeDeviceGetParentHost): Drop attempt at const.
      * src/conf/secret_conf.h (virSecretDefFormat): Use intended type.
      * src/conf/snapshot_conf.c (virDomainSnapshotAssignDef)
      (virDomainSnapshotFindByName): Fix fallout.
      * src/conf/interface_conf.c (virInterfaceBridgeDefFormat)
      (virInterfaceBondDefFormat, virInterfaceVlanDefFormat)
      (virInterfaceProtocolDefFormat, virInterfaceDefDevFormat)
      (virInterfaceDefFormat, virInterfaceFindByMACString)
      (virInterfaceFindByName, virInterfaceAssignDef)
      (virInterfaceRemove): Likewise.
      * src/conf/network_conf.c
      (VIR_ENUM_IMPL, virNetworkFindByName, virNetworkObjAssignDef)
      (virNetworkAssignDef, virNetworkRemoveInactive)
      (virNetworkDefGetIpByIndex, virNetworkIpDefPrefix)
      (virNetworkIpDefNetmask, virNetworkDHCPHostDefParseXML)
      (virNetworkIpDefFormat, virNetworkRouteDefFormat)
      (virPortGroupDefFormat, virNetworkForwardNatDefFormat)
      (virNetworkDefFormatInternal, virNetworkBridgeInUse)
      (virNetworkAllocateBridge, virNetworkSetBridgeName)
      (virNetworkDNSDefFormat, virNetworkDefFormat): Likewise.
      * src/conf/netdev_vlan_conf.c (virNetDevVlanFormat): Likewise.
      * src/conf/node_device_conf.c (virNodeDeviceHasCap)
      (virNodeDeviceFindBySysfsPath, virNodeDeviceFindByName)
      (virNodeDeviceAssignDef, virNodeDeviceObjRemove)
      (virNodeDeviceDefFormat, virNodeDeviceGetParentHost): Likewise.
      * src/conf/secret_conf.c (virSecretDefFormatUsage)
      (virSecretDefFormat): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      539a9fae
  12. 24 9月, 2013 1 次提交
  13. 18 9月, 2013 1 次提交
  14. 05 9月, 2013 1 次提交
  15. 28 8月, 2013 2 次提交
  16. 22 8月, 2013 1 次提交
  17. 14 8月, 2013 1 次提交
    • L
      network: permit upstream forwarding of unqualified DNS names · 4f595ba6
      Laine Stump 提交于
      This resolves the issue that prompted the filing of
      
        https://bugzilla.redhat.com/show_bug.cgi?id=928638
      
      (although the request there is for something much larger and more
      general than this patch).
      
      commit f3868259 disabled the
      forwarding to upstream DNS servers of unresolved DNS requests for
      names that had no domain, but were just simple host names (no "."
      character anywhere in the name). While this behavior is frowned upon
      by DNS root servers (that's why it was changed in libvirt), it is
      convenient in some cases, and since dnsmasq can be configured to allow
      it, it must not be strictly forbidden.
      
      This patch restores the old behavior, but since it is usually
      undesirable, restoring it requires specification of a new option in
      the network config. Adding the attribute "forwardPlainNames='yes'" to
      the <dns> elemnt does the trick - when that attribute is added to a
      network config, any simple hostnames that can't be resolved by the
      network's dnsmasq instance will be forwarded to the DNS servers listed
      in the host's /etc/resolv.conf for an attempt at resolution (just as
      any FQDN would be forwarded).
      
      When that attribute *isn't* specified, unresolved simple names will
      *not* be forwarded to the upstream DNS server - this is the default
      behavior.
      4f595ba6
  18. 07 8月, 2013 1 次提交
    • J
      Reverse logic allowing partial DHCP host XML · cf602e7c
      Ján Tomko 提交于
      Before, missing attributes were only OK when adding entries;
      modification and deletion required all of them.
      
      Now, only deletion works with missing attributes, as long as
      the host is uniquely identified.
      cf602e7c
  19. 31 7月, 2013 1 次提交
  20. 26 7月, 2013 4 次提交
  21. 11 7月, 2013 1 次提交
  22. 10 7月, 2013 2 次提交
  23. 03 7月, 2013 1 次提交
  24. 06 6月, 2013 1 次提交
  25. 21 5月, 2013 1 次提交
  26. 14 5月, 2013 1 次提交
    • G
      Support for static routes on a virtual bridge · ccff335f
      Gene Czarcinski 提交于
      network: static route support for <network>
      
      This patch adds the <route> subelement of <network> to define a static
      route.  the address and prefix (or netmask) attribute identify the
      destination network, and the gateway attribute specifies the next hop
      address (which must be directly reachable from the containing
      <network>) which is to receive the packets destined for
      "address/(prefix|netmask)".
      
      These attributes are translated into an "ip route add" command that is
      executed when the network is started. The command used is of the
      following form:
      
        ip route add <address>/<prefix> via <gateway> \
                     dev <virbr-bridge> proto static metric <metric>
      
      Tests are done to validate that the input data are correct.  For
      example, for a static route ip definition, the address must be a
      network address and not a host address.  Additional checks are added
      to ensure that the specified gateway is directly reachable via this
      network (i.e. that the gateway IP address is in the same subnet as one
      of the IP's defined for the network).
      
      prefix='0' is supported for both family='ipv4' address='0.0.0.0'
      netmask='0.0.0.0' or prefix='0', and for family='ipv6' address='::',
      prefix=0', although care should be taken to not override a desired
      system default route.
      
      Anytime an attempt is made to define a static route which *exactly*
      duplicates an existing static route (for example, address=::,
      prefix=0, metric=1), the following error message will be sent to
      syslog:
      
          RTNETLINK answers: File exists
      
      This can be overridden by decreasing the metric value for the route
      that should be preferred, or increasing the metric for the route that
      shouldn't be preferred (and is thus in place only in anticipation that
      the preferred route may be removed in the future).  Caution should be
      used when manipulating route metrics, especially for a default route.
      
      Note: The use of the command-line interface should be replaced by
      direct use of libnl so that error conditions can be handled better.  But,
      that is being left as an exercise for another day.
      Signed-off-by: NGene Czarcinski <gene@czarc.net>
      Signed-off-by: NLaine Stump <laine@laine.org>
      ccff335f
  27. 07 5月, 2013 1 次提交
  28. 02 5月, 2013 1 次提交
    • M
      virutil: Move string related functions to virstring.c · 7c9a2d88
      Michal Privoznik 提交于
      The source code base needs to be adapted as well. Some files
      include virutil.h just for the string related functions (here,
      the include is substituted to match the new file), some include
      virutil.h without any need (here, the include is removed), and
      some require both.
      7c9a2d88
  29. 27 4月, 2013 1 次提交
    • L
      network: support <driver name='vfio'/> in network definitions · d64e114f
      Laine Stump 提交于
      I remembered to document this bit, but somehow forgot to implement it.
      
      This adds <driver name='kvm|vfio'/> as a subelement to the <forward>
      element of a network (this puts it parallel to the match between
      mode='hostdev' attribute in a network and type='hostdev' in an
      <interface>).
      
      Since it's already documented, only the parser, formatter, backend
      driver recognition (it just translates/moves the flag into the
      <interface> at the appropriate time), and a test case were needed.
      
      (I used a separate enum for the values both because the original is
      defined in domain_conf.h, which is unavailable from network_conf.h,
      and because in the future it's possible that we may want to support
      other non-hostdev oriented driver names in the network parser; this
      makes sure that one can be expanded without the other).
      d64e114f
  30. 23 4月, 2013 2 次提交
    • G
      update input ip processing · 1e5306c7
      Gene Czarcinski 提交于
      1. Handle invalid ULong prefix specified.
      When parsing for @prefix as a ULong, a -2 can be returned
      if the specification is not a valid ULong.
      
      2.  Error out if address= is not specified.
      
      3.  Merge netmask process/tests under family tests.
      
      4. Max sure that prefix does not exceed maximum.
      .
      Signed-off-by: NGene Czarcinski <gene@czarc.net>
      1e5306c7
    • G
      create virSocketAddrGetIpPrefix utility function · bd7c7c1b
      Gene Czarcinski 提交于
      Create the utility function virSocketAddrGetIpPrefix() to
      determine the prefix for this network.  The code in this
      function was adapted from virNetworkIpDefPrefix().
      
      Update virNetworkIpDefPrefix() in src/conf/network_conf.c
      to use the new utility function.
      Signed-off-by: NGene Czarcinski <gene@czarc.net>
      bd7c7c1b
  31. 19 4月, 2013 1 次提交
    • P
      network: bridge_driver: don't lose transient networks on daemon restart · 446dd66b
      Peter Krempa 提交于
      Until now tranisent networks weren't really useful as libvirtd wasn't
      able to remember them across restarts. This patch adds support for
      loading status files of transient networks (that already were generated)
      so that the status isn't lost.
      
      This patch chops up virNetworkObjUpdateParseFile and turns it into
      virNetworkLoadState and a few friends that will help us to load status
      XMLs and refactors the functions that are loading the configs to use
      them.
      446dd66b
  32. 13 4月, 2013 1 次提交
  33. 11 4月, 2013 1 次提交
    • G
      conf: fix a memory leak when parsing nat port XML nodes · 2fff3801
      Guannan Ren 提交于
       ==5306== 8 bytes in 1 blocks are definitely lost in loss record 24 of 277
       ==5306==    at 0x4C28B2F: calloc (vg_replace_malloc.c:593)
       ==5306==    by 0x5293CAF: virAllocN (viralloc.c:152)
       ==5306==    by 0x52DFEAE: virXPathNodeSet (virxml.c:611)
       ==5306==    by 0x5313DD9: virNetworkDefParseXML (network_conf.c:1408)
       ==5306==    by 0x53170F6: virNetworkObjUpdateParseFile (network_conf.c:2031)
       ==5306==    by 0x131DA63C: networkStartup (bridge_driver.c:279)
       ==5306==    by 0x53481DF: virStateInitialize (libvirt.c:822)
       ==5306==    by 0x40DF44: daemonRunStateInit (libvirtd.c:877)
       ==5306==    by 0x52D2FF5: virThreadHelper (virthreadpthread.c:161)
       ==5306==    by 0x5D00C52: start_thread (in /usr/lib64/libpthread-2.17.so)
       ==5306==    by 0x6410ECC: clone (in /usr/lib64/libc-2.17.so)
      2fff3801