1. 08 1月, 2014 1 次提交
    • L
      Fix bridge configuration when OUTPUT policy is DROP on the host · 538daf7f
      Lénaïc Huard 提交于
      When the host is configured with very restrictive firewall (default policy
      is DROP for all chains, including OUTPUT), the bridge driver for Linux
      adds netfilter entries to allow DHCP and DNS requests to go from the VM
      to the dnsmasq of the host.
      
      The issue that this commit fixes is the fact that a DROP policy on the OUTPUT
      chain blocks the DHCP replies from the host’s dnsmasq to the VM.
      As DHCP replies are sent in UDP, they are not caught by any --ctstate ESTABLISHED
      rule and so, need to be explicitly allowed.
      Signed-off-by: NLénaïc Huard <lenaic@lhuard.fr.eu.org>
      538daf7f
  2. 07 1月, 2014 1 次提交
    • E
      event: make deregister return value match docs · 31b5bad9
      Eric Blake 提交于
      Ever since their introduction (commit 1509b802 in v0.5.0 for
      virConnectDomainEventRegister, commit 44457238 in v0.8.0 for
      virConnectDomainEventDeregisterAny), the event deregistration
      functions have been documented as returning 0 on success;
      likewise for older registration (only the newer RegisterAny
      must return a non-zero callbackID).  And now that we are
      adding virConnectNetworkEventDeregisterAny for v1.2.1, it
      should have the same semantics.
      
      Fortunately, all of the stateful drivers have been obeying
      the docs and returning 0, thanks to the way the remote_driver
      tracks things (in fact, the RPC wire protocol is unable to
      send a return value for DomainEventRegisterAny, at least not
      without adding a new RPC number).  Well, except for vbox,
      which was always failing deregistration, due to failure to
      set the return value to anything besides its initial -1.
      
      But for local drivers, such as test:///default, we've been
      returning non-zero numbers; worse, the non-zero numbers have
      differed over time.  For example, in Fedora 12 (libvirt 0.8.2),
      calling Register twice would return 0 and 1 [the callbackID
      generated under the hood]; while in Fedora 20 (libvirt 1.1.3),
      it returns 1 and 2 [the number of callbacks registered for
      that event type].  Since we have changed the behavior over
      time, and since it differs by local vs. remote, we can safely
      argue that no one could have been reasonably relying on any
      particular behavior, so we might as well obey the docs, as well
      as prepare callers that might deal with older clients to not be
      surprised if the docs are not strictly followed.
      
      For consistency, this patch fixes the code for all drivers,
      even though it only makes an impact for vbox and for local
      drivers.  By fixing all drivers, future copy and paste from
      a remote driver to a local driver is less likely to
      reintroduce the bug.
      
      Finally, update the testsuite to gain some coverage of the
      issue for local drivers, including the first test of old-style
      domain event registration via function pointer instead of
      event id.
      
      * src/libvirt.c (virConnectDomainEventRegister)
      (virConnectDomainEventDeregister)
      (virConnectDomainEventDeregisterAny): Clarify docs.
      * src/libxl/libxl_driver.c (libxlConnectDomainEventRegister)
      (libxlConnectDomainEventDeregister)
      (libxlConnectDomainEventDeregisterAny): Match documentation.
      * src/lxc/lxc_driver.c (lxcConnectDomainEventRegister)
      (lxcConnectDomainEventDeregister)
      (lxcConnectDomainEventDeregisterAny): Likewise.
      * src/test/test_driver.c (testConnectDomainEventRegister)
      (testConnectDomainEventDeregister)
      (testConnectDomainEventDeregisterAny)
      (testConnectNetworkEventDeregisterAny): Likewise.
      * src/uml/uml_driver.c (umlConnectDomainEventRegister)
      (umlConnectDomainEventDeregister)
      (umlConnectDomainEventDeregisterAny): Likewise.
      * src/vbox/vbox_tmpl.c (vboxConnectDomainEventRegister)
      (vboxConnectDomainEventDeregister)
      (vboxConnectDomainEventDeregisterAny): Likewise.
      * src/xen/xen_driver.c (xenUnifiedConnectDomainEventRegister)
      (xenUnifiedConnectDomainEventDeregister)
      (xenUnifiedConnectDomainEventDeregisterAny): Likewise.
      * src/network/bridge_driver.c
      (networkConnectNetworkEventDeregisterAny): Likewise.
      * tests/objecteventtest.c (testDomainCreateXMLOld): New test.
      (mymain): Run it.
      (testDomainCreateXML): Check return values.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      31b5bad9
  3. 14 12月, 2013 1 次提交
  4. 11 12月, 2013 1 次提交
  5. 04 12月, 2013 1 次提交
  6. 28 11月, 2013 1 次提交
    • L
      network: properly update iptables rules during net-update · 54f94923
      Laine Stump 提交于
      This patch resolves:
      
        https://bugzilla.redhat.com/show_bug.cgi?id=1035336
      
      The basic problem is that during a network update, the required
      iptables rules sometimes change, and this was being handled by simply
      removing and re-adding the rules. However, the removal of the old
      rules was done based on the *new* state of the network, which would
      mean that some of the rules would not match those currently in the
      system, so the old rules wouldn't be removed.
      
      This patch removes the old rules prior to updating the network
      definition then adds the new rules as soon as the definition is
      updated. Note that this could lead to a stray packet or two during the
      interim, but that was already a problem before (the period of limbo is
      now just slightly longer).
      
      While moving the location for the rules, I added a few more sections
      that should result in the iptables rules being redone:
      
      DHCP_RANGE and DHCP_HOST - these are needed because adding/removing a dhcp
      host entry could lead to the dhcp service being started/stopped, which
      would require that the mangle rule that fixes up dhcp response
      checksums sould need to be added/removed, and this wasn't being done.
      54f94923
  7. 21 11月, 2013 1 次提交
    • E
      maint: fix comma style issues: remaining code · e44a9a70
      Eric Blake 提交于
      Most of our code base uses space after comma but not before;
      fix the remaining uses before adding a syntax check.
      
      * src/network/bridge_driver.c: Consistently use commas.
      * src/node_device/node_device_hal.c: Likewise.
      * src/node_device/node_device_udev.c: Likewise.
      * src/storage/storage_backend_rbd.c: Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      e44a9a70
  8. 15 11月, 2013 1 次提交
  9. 08 11月, 2013 1 次提交
  10. 06 11月, 2013 1 次提交
    • L
      network: fix connections count in case of allocate failure · b4e0299d
      Laine Stump 提交于
      This resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1020135
      
      If networkAllocateActualDevice() had failed due to a pool of hostdev
      or direct devices being depleted, the calling function could still
      call networkReleaseActualDevice() as part of its cleanup, and that
      function would then unconditionally decrement the connections count
      for the network, even though it hadn't been incremented (due to
      failure of allocate). This *was* necessary because the .actual member
      of the netdef was allocated with a "lazy" algorithm, only being
      created if there was a need to store data there (e.g. if a device was
      allocated from a pool, or bandwidth was allocated for the device), so
      there was no simple way for networkReleaseActualDevice() to tell if
      something really had been allocated (i.e. if "connections++" had been
      executed).
      
      This patch changes networkAllocateDevice() to *always* allocate an
      actual device for any netdef of type='network', even if it isn't
      needed for any other reason. This has no ill effects anywhere else in
      the code (except for using a small amount of memory), and
      networkReleaseActualDevice() can then determine if there was a
      previous successful allocate by checking for .actual != NULL (if not,
      it skips the "connections--").
      b4e0299d
  11. 23 10月, 2013 1 次提交
  12. 25 9月, 2013 1 次提交
  13. 18 9月, 2013 1 次提交
  14. 29 8月, 2013 1 次提交
  15. 28 8月, 2013 1 次提交
  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. 13 8月, 2013 1 次提交
  19. 02 8月, 2013 1 次提交
    • R
      bridge driver: extract platform specifics · 4ac708f2
      Roman Bogorodskiy 提交于
      * Move platform specific things (e.g. firewalling and route
        collision checks) into bridge_driver_platform
      * Create two platform specific implementations:
          - bridge_driver_linux: Linux implementation using iptables,
            it's actually the code moved from bridge_driver.c
          - bridge_driver_nop: dumb implementation that does nothing
      Signed-off-by: NEric Blake <eblake@redhat.com>
      4ac708f2
  20. 26 7月, 2013 1 次提交
  21. 23 7月, 2013 1 次提交
  22. 22 7月, 2013 1 次提交
    • R
      bridge driver: s/network_driver/virNetworkDriverState/ · 162e4779
      Roman Bogorodskiy 提交于
      This is another cleanup before extracting platform-specific
      parts from bridge_driver.
      
      Rename struct network_driver to _virNetworkDriverState and
      add appropriate typedefs: virNetworkDriverState and
      virNetworkDriverStatePtr.
      
      This will help us to avoid potential problems when moving
      this struct to the .h file.
      162e4779
  23. 11 7月, 2013 1 次提交
  24. 10 7月, 2013 1 次提交
  25. 03 7月, 2013 1 次提交
  26. 02 7月, 2013 1 次提交
    • R
      Drop iptablesContext · 477a619e
      Roman Bogorodskiy 提交于
      iptablesContext holds only 4 pairs of iptables
      (table, chain) and there's no need to pass
      it around.
      
      This is a first step towards separating bridge_driver.c
      in platform-specific parts.
      477a619e
  27. 27 6月, 2013 1 次提交
  28. 26 6月, 2013 1 次提交
    • L
      network: allow <vlan> in type='hostdev' networks · 4b42e3b9
      Laine Stump 提交于
      Although SRIOV network cards support setting a vlan tag on their
      virtual functions, and although setting this vlan tag via a <vlan>
      element in a domain's <interface> works, setting a vlan tag for these
      devices in a <network> definition, or in a network <portgroup>
      definition is also supposed to work (and the comment that validates
      <vlan> usage even says that!). However, the check to allow it only
      checked for an openvswitch network, so attempts to add <vlan> to a
      network of type='hostdev' would fail.
      4b42e3b9
  29. 24 6月, 2013 1 次提交
  30. 21 6月, 2013 1 次提交
    • L
      network: increase max number of routes · 2bdf548f
      Laine Stump 提交于
      This fixes the problem reported in:
      
         https://bugzilla.redhat.com/show_bug.cgi?id=972690
      
      When checking for a collision of a new libvirt network's subnet with
      any existing routes, we read all of /proc/net/route into memory, then
      parse all the entries. The function that we use to read this file
      requires a "maximum length" parameter, which had previously been set
      to 64*1024. As each line in /proc/net/route is 128 bytes, this would
      allow for a maximum of 512 entries in the routing table.
      
      This patch increases that number to 128 * 100000, which allows for
      100,000 routing table entries. This means that it's possible that 12MB
      would be allocated, but that would only happen if there really were
      100,000 route table entries on the system, it's only held for a very
      short time.
      
      Since there is no method of specifying and unlimited max (and that
      would create a potential denial of service anyway) hopefully this
      limit is large enough to accomodate everyone.
      2bdf548f
  31. 05 6月, 2013 1 次提交
    • E
      maint: don't use config.h in .h files · 1add9c78
      Eric Blake 提交于
      Enforce the rule that .h files don't need to (redundantly)
      include <config.h>.
      
      * cfg.mk (sc_prohibit_config_h_in_headers): New rule.
      (_virsh_includes): Delete; instead, inline a smaller number of
      exclusions...
      (exclude_file_name_regexp--sc_require_config_h)
      (exclude_file_name_regexp--sc_require_config_h_first): ...here.
      * daemon/libvirtd.h (includes): Fix offenders.
      * src/driver.h (includes): Likewise.
      * src/gnutls_1_0_compat.h (includes): Likewise.
      * src/libxl/libxl_conf.h (includes): Likewise.
      * src/libxl/libxl_driver.h (includes): Likewise.
      * src/lxc/lxc_conf.h (includes): Likewise.
      * src/lxc/lxc_driver.h (includes): Likewise.
      * src/lxc/lxc_fuse.h (includes): Likewise.
      * src/network/bridge_driver.h (includes): Likewise.
      * src/phyp/phyp_driver.h (includes): Likewise.
      * src/qemu/qemu_conf.h (includes): Likewise.
      * src/util/virnetlink.h (includes): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      1add9c78
  32. 22 5月, 2013 1 次提交
    • M
      qemu: Adapt qemuBuildInterfaceCommandLine to to multiqueue net · 1f24f682
      Michal Privoznik 提交于
      In order to learn libvirt multiqueue several things must be done:
      
      1) The '/dev/net/tun' device needs to be opened multiple times with
      IFF_MULTI_QUEUE flag passed to ioctl(fd, TUNSETIFF, &ifr);
      
      2) Similarly, '/dev/vhost-net' must be opened as many times as in 1)
      in order to keep 1:1 ratio recommended by qemu and kernel folks.
      
      3) The command line construction code needs to switch from 'fd=X' to
      'fds=X:Y:...:Z' and from 'vhostfd=X' to 'vhostfds=X:Y:...:Z'.
      
      4) The monitor handling code needs to learn to pass multiple FDs.
      1f24f682
  33. 21 5月, 2013 1 次提交
  34. 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
  35. 09 5月, 2013 1 次提交
  36. 03 5月, 2013 3 次提交
    • L
      network: fix network driver startup for qemu:///session · 2ffd87d8
      Laine Stump 提交于
      This should resolve https://bugzilla.redhat.com/show_bug.cgi?id=958907
      
      Recent new addition of code to read/write active network state to the
      NETWORK_STATE_DIR in the network driver broke startup for
      qemu:///session. The network driver had several state file paths
      hardcoded to /var, which could never possibly work in session mode.
      
      This patch modifies *all* state files to use a variable string that is
      set differently according to whether or not we're running
      privileged. (It turns out that logDir was never used, so it's been
      completely eliminated.)
      
      There are very definitely other problems preventing dnsmasq and radvd
      from running in non-privileged mode, but it's more consistent to have
      the directories used by them be determined in the same fashion.
      
      NB: I've noted before that the network driver is storing its state
      (including dnsmasq and radvd state) in /var/lib, while qemu stores its
      state in /var/run. It would probably have been better if the two
      matched, but it's been this way for a long time, and changing it would
      break running installations during an upgrade, so it's best to just
      leave it as it is.
      2ffd87d8
    • D
      Fix format string handling in network driver · 5c1678ab
      Daniel P. Berrange 提交于
      The call to virReportError conditionally switched between
      two format strings, with different numbers of placeholders.
      This meant the format string with no placeholders was not
      protected by a "%s".
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      5c1678ab
    • E
      build: avoid useless virAsprintf · 25ae3d30
      Eric Blake 提交于
      virAsprintf(&foo, "%s", bar) is wasteful compared to
      foo = strdup(bar) (or eventually, VIR_STRDUP(foo, bar),
      but one thing at a time...).
      
      Noticed while reviewing Laine's attempt to clean up broken
      qemu:///session.
      
      * cfg.mk (sc_prohibit_asprintf): Enhance rule.
      * src/esx/esx_storage_backend_vmfs.c
      (esxStorageBackendVMFSVolumeLookupByKey): Fix offender.
      * src/network/bridge_driver.c (networkStateInitialize): Likewise.
      * src/nwfilter/nwfilter_dhcpsnoop.c (virNWFilterSnoopDHCPOpen):
      Likewise.
      * src/storage/storage_backend_sheepdog.c
      (virStorageBackendSheepdogRefreshVol): Likewise.
      * src/util/vircgroup.c (virCgroupAddTaskStrController): Likewise.
      * src/util/virdnsmasq.c (addnhostsAdd): Likewise.
      * src/xen/block_stats.c (xenLinuxDomainDeviceID): Likewise.
      * src/xen/xen_driver.c (xenUnifiedConnectOpen): Likewise.
      * tools/virsh.c (vshGetTypedParamValue): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      25ae3d30
  37. 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
  38. 01 5月, 2013 1 次提交