1. 04 3月, 2015 5 次提交
  2. 26 2月, 2015 2 次提交
  3. 24 2月, 2015 1 次提交
    • M
      network_conf: Forbid commas in DNS TXT · 39df9d2f
      Michal Privoznik 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=1151942
      
      While the restriction doesn't have origin in any RFC, it matters
      to us while constructing the dnsmasq config file (or command line
      previously). For better picture, this is how the corresponding
      part of network XML look like:
      
        <dns>
          <forwarder addr='8.8.4.4'/>
          <txt name='example' value='example value'/>
        </dns>
      
      And this is how the config file looks like then:
      
        server=8.8.4.4
        txt-record=example,example value
      
      Now we can see why there can't be any commas in the TXT name.
      They are used by dnsmasq to separate @name and @value.
      
      Funny, we have it in the documentation, but the code (which was
      pushed back in 2011) didn't reflect that.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      39df9d2f
  4. 21 2月, 2015 1 次提交
    • 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
  5. 20 1月, 2015 1 次提交
    • J
      network: Let domains be restricted to local DNS · 298fa485
      Josh Stone 提交于
      This adds a new "localOnly" attribute on the domain element of the
      network xml.  With this set to "yes", DNS requests under that domain
      will only be resolved by libvirt's dnsmasq, never forwarded upstream.
      
      This was how it worked before commit f69a6b98, and I found that
      functionality useful.  For example, I have my host's NetworkManager
      dnsmasq configured to forward that domain to libvirt's dnsmasq, so I can
      easily resolve guest names from outside.  But if libvirt's dnsmasq
      doesn't know a name and forwards it to the host, I'd get an endless
      forwarding loop.  Now I can set localOnly="yes" to prevent the loop.
      Signed-off-by: NJosh Stone <jistone@redhat.com>
      298fa485
  6. 16 1月, 2015 2 次提交
  7. 14 1月, 2015 1 次提交
    • M
      conf: Increase virNetDevBandwidthParse intelligence · a605025c
      Michal Privoznik 提交于
      There's this function virNetDevBandwidthParse which parses the
      bandwidth XML snippet. But it's not clever much. For the
      following XML it allocates the virNetDevBandwidth structure even
      though it's completely empty:
      
          <bandwidth>
          </bandwidth>
      
      Later in the code there are some places where we check if
      bandwidth was set or not. And since we obtained pointer from the
      parsing function we think that it is when in fact it isn't.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      a605025c
  8. 09 12月, 2014 2 次提交
    • K
      network: don't allow multiple dhcp sections · 5adc6031
      Kyle DeFrancia 提交于
      This resolves: https://bugzilla.redhat.com/show_bug.cgi?id=907779
      
      A <dhcp> element can exist in only one IPv4 address and one IPv6
      address per network.  This patch enforces that in virNetworkUpdate.
      5adc6031
    • L
      conf: new network bridge device attribute macTableManager · 40961978
      Laine Stump 提交于
      The macTableManager attribute of a network's bridge subelement tells
      libvirt how the bridge's MAC address table (used to determine the
      egress port for packets) is managed. In the default mode, "kernel",
      management is left to the kernel, which usually determines entries in
      part by turning on promiscuous mode on all ports of the bridge,
      flooding packets to all ports when the correct destination is unknown,
      and adding/removing entries to the fdb as it sees incoming traffic
      from particular MAC addresses.  In "libvirt" mode, libvirt turns off
      learning and flooding on all the bridge ports connected to guest
      domain interfaces, and adds/removes entries according to the MAC
      addresses in the domain interface configurations. A side effect of
      turning off learning and unicast_flood on the ports of a bridge is
      that (with Linux kernel 3.17 and newer), the kernel can automatically
      turn off promiscuous mode on one or more of the bridge's ports
      (usually only the one interface that is used to connect the bridge to
      the physical network). The result is better performance (because
      packets aren't being flooded to all ports, and can be dropped earlier
      when they are of no interest) and slightly better security (a guest
      can still send out packets with a spoofed source MAC address, but will
      only receive traffic intended for the guest interface's configured MAC
      address).
      
      The attribute looks like this in the configuration:
      
        <network>
          <name>test</name>
          <bridge name='br0' macTableManager='libvirt'/>
          ...
      
      This patch only adds the config knob, documentation, and test
      cases. The functionality behind this knob is added in later patches.
      40961978
  9. 02 12月, 2014 3 次提交
    • J
      Generate a MAC when loading a config instead of package update · a47ae7c0
      Ján Tomko 提交于
      Partially reverts commit 5754dbd5.
      
      The code in the specfile adds a MAC address to every <bridge>,
      even for <forward mode='bridge'> for which we don't support
      changing MAC addresses.
      
      Remove it completely. For new networks, we have been adding
      MAC addresses on definition/creation since the commit mentioned above.
      For existing networks (pre-0.9.0), the MAC is added by this commit.
      
      https://bugzilla.redhat.com/show_bug.cgi?id=1156367
      a47ae7c0
    • J
      Silently ignore MAC in NetworkLoadConfig · c9c7a2bd
      Ján Tomko 提交于
      Libvirt's RPMs have been adding it to networks which don't support it.
      
      https://bugzilla.redhat.com/show_bug.cgi?id=1156367
      c9c7a2bd
    • L
      conf: replace call to virNetworkFree() with virObjectUnref() · c2d5bca1
      Laine Stump 提交于
      The function virNetworkObjListExport() in network_conf.c had a call to
      the public API virNetworkFree() which was causing a link error:
      
      CCLD     libvirt_driver_vbox_network_impl.la
       ./.libs/libvirt_conf.a(libvirt_conf_la-network_conf.o): In function `virNetworkObjListExport':
      /home/laine/devel/libvirt/src/conf/network_conf.c:4496: undefined reference to `virNetworkFree'
      
      This would happen when I added
      
        #include "network_conf.h"
      
      into domain_conf.h, then attempted to call a new function from that
      file (and enum converter, similar to virNetworkForwardTypeToString())
      
      In the end, virNetworkFree() ends up just calling virObjectUnref(obj)
      anyway (after clearing all pending errors, which we probably *don't*
      want to do in the cleanup of a utility function), so this is likely
      more correct than the original code as well.
      c2d5bca1
  10. 15 11月, 2014 1 次提交
  11. 06 10月, 2014 1 次提交
    • L
      conf: add trustGuestRxFilters attribute to network and domain interface · 07450cd4
      Laine Stump 提交于
      This new attribute will control whether or not libvirt will pay
      attention to guest notifications about changes to network device mac
      addresses and receive filters. The default for this is 'no' (for
      security reasons). If it is set to 'yes' *and* the specified device
      model and connection support it (currently only macvtap+virtio) then
      libvirt will watch for NIC_RX_FILTER_CHANGED events, and when it
      receives one, it will issue a query-rx-filter command, retrieve the
      result, and modify the host-side macvtap interface's mac address and
      unicast/multicast filters accordingly.
      
      The functionality behind this attribute will be in a later patch. This
      patch merely adds the attribute to the top-level of a domain's
      <interface> as well as to <network> and <portgroup>, and adds
      documentation and schema/xml2xml tests. Rather than adding even more
      test files, I've just added the net attribute in various applicable
      places of existing test files.
      07450cd4
  12. 15 9月, 2014 1 次提交
    • E
      network: check for invalid forward delay time · 3aa05241
      Erik Skultety 提交于
      When spanning tree protocol is allowed in bridge settings, forward delay
      value is set as well (default is 0 if omitted). Until now, there was no
      check for delay value validity. Delay makes sense only as a positive
      numerical value.
      
      Note: However, even if you provide positive  numerical value, brctl
      utility only uses values from range <2,30>, so the number provided can
      be modified (kernel most likely) to fall within this range.
      
      Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1125764
      3aa05241
  13. 11 9月, 2014 1 次提交
    • J
      network_conf: Resolve Coverity FORWARD_NULL · 8ffab101
      John Ferlan 提交于
      The code compares def->forwarders when deciding to return 0 at a
      couple of points, then uses "def->nfwds" as a way to index into
      the def->forwarders array.  That reference results in Coverity
      complaining that def->forwarders being NULL was checked as part
      of an arithmetic OR operation where failure could be any one 5
      conditions, but that is not checked when entering the loop to
      dereference the array.  Changing the comparisons to use nfwds
      will clear the warnings
      Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
      8ffab101
  14. 28 8月, 2014 1 次提交
  15. 21 8月, 2014 1 次提交
  16. 23 7月, 2014 1 次提交
    • J
      Introduce virTristateBool enum type · bb018ce6
      Ján Tomko 提交于
      Replace all three-state (default/yes/no) enums with it:
      virDomainBIOSUseserial
      virDomainBootMenu
      virDomainPMState
      virDomainGraphicsSpiceClipboardCopypaste
      virDomainGraphicsSpiceAgentFileTransfer
      virNetworkDNSForwardPlainNames
      bb018ce6
  17. 09 7月, 2014 1 次提交
  18. 03 7月, 2014 1 次提交
    • J
      Use virBufferCheckError everywhere we report OOM error · 92a8e72f
      Ján Tomko 提交于
      Replace:
      if (virBufferError(&buf)) {
          virBufferFreeAndReset(&buf);
          virReportOOMError();
          ...
      }
      
      with:
      if (virBufferCheckError(&buf) < 0)
          ...
      
      This should not be a functional change (unless some callers
      misused the virBuffer APIs - a different error would be reported
      then)
      92a8e72f
  19. 06 6月, 2014 1 次提交
  20. 06 5月, 2014 1 次提交
  21. 29 4月, 2014 1 次提交
    • E
      conf: use virDirRead API · 6b9f40e8
      Eric Blake 提交于
      When reading configuration files, we were silently ignoring
      directory read failures.  While unlikely, we might as well
      report them.
      
      * src/conf/domain_conf.c (virDomainObjListLoadAllConfigs): Report
      readdir errors.
      * src/conf/network_conf.c (virNetworkLoadAllState)
      (virNetworkLoadAllConfigs): Likewise.
      * src/conf/nwfilter_conf.c (virNWFilterLoadAllConfigs): Likewise.
      * src/conf/storage_conf.c (virStoragePoolLoadAllConfigs):
      Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      6b9f40e8
  22. 27 4月, 2014 2 次提交
    • L
      network: set macvtap/hostdev networks active if their state file exists · 411c5486
      Laine Stump 提交于
      libvirt attempts to determine at startup time which networks are
      already active, and set their active flags. Previously it has done
      this by assuming that all networks are inactive, then setting the
      active flag if the network has a bridge device associated with it and
      that bridge device exists. This is not useful for macvtap and hostdev
      based networks, since they do not use a bridge device.
      
      Of course the reason that such a check had to be done was that the
      presence of a status file in the network "stateDir" couldn't be
      trusted as an indicator of whether or not a network was active. This
      was due to the network driver mistakenly using
      /var/lib/libvirt/network to store the status files, rather than
      /var/run/libvirt/network (similar to what is done by every other
      libvirt driver that stores status xml for its objects). The difference
      is that /var/run is cleared out when the host reboots, so you can be
      assured that the state file you are seeing isn't just left over from a
      previous boot of the host.
      
      Now that the network driver has been switched to using
      /var/run/libvirt/network for status, we can also modify it to assume
      that any network with an existing status file is by definition active
      - we do this when reading the status file. To fine tune the results,
      networkFindActiveConfigs() is changed to networkUpdateAllState(),
      and only sets active = 0 if the conditions for particular network
      types are *not* met.
      
      The result is that during the first run of libvirtd after the host
      boots, there are no status files, so no networks are active. Any time
      libvirtd is restarted, any network with a status file will be marked
      as active (unless the network uses a bridge device and that device for
      some reason doesn't exist).
      411c5486
    • 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
  23. 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
  24. 25 3月, 2014 1 次提交
  25. 14 3月, 2014 1 次提交
  26. 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
  27. 18 2月, 2014 2 次提交
  28. 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
  29. 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