1. 17 8月, 2017 2 次提交
  2. 15 7月, 2017 1 次提交
  3. 25 6月, 2017 1 次提交
    • J
      events: Avoid double free possibility on remote call failure · 2065499b
      John Ferlan 提交于
      If a remote call fails during event registration (more than likely from
      a network failure or remote libvirtd restart timed just right), then when
      calling the virObjectEventStateDeregisterID we don't want to call the
      registered @freecb function because that breaks our contract that we
      would only call it after succesfully returning.  If the @freecb routine
      were called, it could result in a double free from properly coded
      applications that free their opaque data on failure to register, as seen
      in the following details:
      
          Program terminated with signal 6, Aborted.
          #0  0x00007fc45cba15d7 in raise
          #1  0x00007fc45cba2cc8 in abort
          #2  0x00007fc45cbe12f7 in __libc_message
          #3  0x00007fc45cbe86d3 in _int_free
          #4  0x00007fc45d8d292c in PyDict_Fini
          #5  0x00007fc45d94f46a in Py_Finalize
          #6  0x00007fc45d960735 in Py_Main
          #7  0x00007fc45cb8daf5 in __libc_start_main
          #8  0x0000000000400721 in _start
      
      The double dereference of 'pyobj_cbData' is triggered in the following way:
      
          (1) libvirt_virConnectDomainEventRegisterAny is invoked.
          (2) the event is successfully added to the event callback list
              (virDomainEventStateRegisterClient in
              remoteConnectDomainEventRegisterAny returns 1 which means ok).
          (3) when function remoteConnectDomainEventRegisterAny is hit,
              network connection disconnected coincidently (or libvirtd is
              restarted) in the context of function 'call' then the connection
              is lost and the function 'call' failed, the branch
              virObjectEventStateDeregisterID is therefore taken.
          (4) 'pyobj_conn' is dereferenced the 1st time in
              libvirt_virConnectDomainEventFreeFunc.
          (5) 'pyobj_cbData' (refered to pyobj_conn) is dereferenced the
               2nd time in libvirt_virConnectDomainEventRegisterAny.
          (6) the double free error is triggered.
      
      Resolve this by adding a @doFreeCb boolean in order to avoid calling the
      freeCb in virObjectEventStateDeregisterID for any remote call failure in
      a remoteConnect*EventRegister* API. For remoteConnect*EventDeregister* calls,
      the passed value would be true indicating they should run the freecb if it
      exists; whereas, it's false for the remote call failure path.
      
      Patch based on the investigation and initial patch posted by
      fangying <fangying1@huawei.com>.
      2065499b
  4. 28 4月, 2017 2 次提交
    • L
      network: better log message when network is inactive during reconnect · 7949de96
      Laine Stump 提交于
      If the network isn't active during networkNotifyActualDevice(), we
      would log an error message stating that the bridge device didn't
      exist. This patch adds a check to see if the network is active, making
      the logs more useful in the case that it isn't.
      
      Partially resolves: https://bugzilla.redhat.com/1442700
      7949de96
    • L
      qemu: don't kill qemu process on restart if networkNotify fails · cb182eb1
      Laine Stump 提交于
      Nothing that could happen during networkNotifyActualDevice() could
      justify unceremoniously killing the qemu process, but that's what we
      were doing.
      
      In particular, new code added in commit 85bcc022 (first appearred in
      libvirt-3.2.0) attempts to reattach tap devices to their assigned
      bridge devices when libvirtd restarts (to make it easier to recover
      from a restart of a libvirt network). But if the network has been
      stopped and *not* restarted, the bridge device won't exist and
      networkNotifyActualDevice() will fail.
      
      This patch changes networkNotifyActualDevice() and
      qemuProcessNotifyNets() to return void, so that qemuProcessReconnect()
      will soldier on regardless of what happens (any errors will still be
      logged though).
      
      Partially resolves: https://bugzilla.redhat.com/1442700
      cb182eb1
  5. 21 4月, 2017 1 次提交
  6. 19 4月, 2017 3 次提交
  7. 03 4月, 2017 1 次提交
    • M
      networkUpdateState: Create virMacMap module more frequently · 3054dacf
      Michal Privoznik 提交于
      The virMacMap module is there for dumping [domain, <list of is
      MACs>] pairs into a file so that libvirt_guest NSS module can use
      it. Whenever a interface is allocated from network (e.g. on
      domain<F2> startup or NIC hotplug), network is notified and so is
      virMacMap module subsequently. The module update functions
      networkMacMgrAdd() and networkMacMgrDel() gracefully handle the
      case when there's no module. The problem is, the module is
      created if and only if network is freshly started, or if the
      daemon restarts and network previously had the module.
      
      This is not very user friendly - if users want to use the NSS
      module they need to destroy their network and bring it up again
      (and subsequently all the domains using it).
      
      One disadvantage of this approach implemented here is that one
      may get just partial results: any already running network does
      not record mac maps, thus only newly plugged domains will be
      stored in the module. The network restart scenario is not touched
      by this of course. But one can argue that older libvirts had
      never recorded the mac maps anyway.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      3054dacf
  8. 29 3月, 2017 1 次提交
    • M
      network: Don't crash on domain destroy · 2fe93123
      Michal Privoznik 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=1434882
      
      Imagine the following scenario:
      
      1) virsh net-start default
      2) virsh start myFavouriteDomain
      3) virsh net-destroy default
      4) virsh destroy myFavouriteDomain
      
      (assuming myFavouriteDomain has an interface from default
      network)
      
      Regardless of how unlikely this scenario looks like, we should
      not crash. The problem is, on net-destroy in
      networkShutdownNetworkVirtual() the virMacMap module is unrefed,
      but the stale pointer is kept around. Thus when the domain
      destroy procedure comes in, networkReleaseActualDevice() and
      subsequently networkMacMgrDel() is called. This function sees the
      stale pointer and starts calling the virMacMap module APIs which
      work over freed memory.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      2fe93123
  9. 28 3月, 2017 1 次提交
  10. 24 3月, 2017 1 次提交
    • L
      network: only check for IPv6 RA routes when the network has an IPv6 address · a1f46c71
      Laine Stump 提交于
      commit 00d28a78 added a check to see if there were any IPv6 routes
      added by RA (Router Advertisement) via an interface that had accept_ra
      set to something other than "2". The check was being done
      unconditionally, but it's only relevant if IPv6 forwarding is going to
      be turned on, and that will only happen if the network has an IPv6
      address.
      a1f46c71
  11. 23 3月, 2017 2 次提交
    • J
      network: Remove null newBandwidth check from networkBandwidthUpdate · 802579b5
      John Ferlan 提交于
      The prototype requires a NONNULL argument and the only caller passes in
      a non-null parameter. Besides the "else if" condition would deref it anyway.
      Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
      802579b5
    • L
      network: reconnect tap devices during networkNotifyActualDevice · 85bcc022
      Laine Stump 提交于
      If a network is destroyed and restarted, or its bridge is changed, any
      tap devices that had previously been connected to the bridge will no
      longer be connected. As a first step in automating a reconnection of
      all tap devices when this happens, this patch modifies
      networkNotifyActualDevice() (which is called once for every
      <interface> of every active domain whenever libvirtd is restarted) to
      reconnect any tap devices that it finds disconnected.
      
      With this patch in place, you will need to restart libvirtd to
      reconnect all the taps to their proper bridges. A future patch will
      add a callback that hypervisor drivers can register with the network
      driver to that the network driver can trigger this behavior
      automatically whenever a network is started.
      85bcc022
  12. 22 3月, 2017 2 次提交
  13. 21 3月, 2017 1 次提交
    • L
      network: don't add "no-resolv" if we still need DNS servers from resolv.conf · 15b5902d
      Laine Stump 提交于
      It was pointed out here:
      
        https://bugzilla.redhat.com/show_bug.cgi?id=1331796#c4
      
      that we shouldn't be adding a "no-resolv" to the dnsmasq.conf file for
      a network if there isn't any <forwarder> element that specifies an IP
      address but no qualifying domain. If there is such an element, it will
      handle all DNS requests that weren't otherwise handled by one of the
      forwarder entries with a matching domain attribute. If not, then DNS
      requests that don't match the domain of any <forwarder> would not be
      resolved if we added no-resolv.
      
      So, only add "no-resolv" when there is at least one <forwarder>
      element that specifies an IP address but no qualifying domain.
      15b5902d
  14. 23 2月, 2017 1 次提交
    • D
      Add ATTRIBUTE_FALLTHROUGH for switch cases without break · 5d84f596
      Daniel P. Berrange 提交于
      In GCC 7 there is a new warning triggered when a switch
      case has a conditional statement (eg if ... else...) and
      some of the code paths fallthrough to the next switch
      statement. e.g.
      
      conf/domain_conf.c: In function 'virDomainChrEquals':
      conf/domain_conf.c:14926:12: error: this statement may fall through [-Werror=implicit-fallthrough=]
               if (src->targetTypeAttr != tgt->targetTypeAttr)
                  ^
      conf/domain_conf.c:14928:5: note: here
           case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE:
           ^~~~
      conf/domain_conf.c: In function 'virDomainChrDefFormat':
      conf/domain_conf.c:22143:12: error: this statement may fall through [-Werror=implicit-fallthrough=]
               if (def->targetTypeAttr) {
                  ^
      conf/domain_conf.c:22151:5: note: here
           default:
           ^~~~~~~
      
      GCC introduced a __attribute__((fallthrough)) to let you
      indicate that this is intentionale behaviour rather than
      a bug.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      5d84f596
  15. 08 2月, 2017 2 次提交
    • L
      c0f70686
    • L
      util: add MTU arg to virNetDevTapCreateInBridgePort() · dd8ac030
      Laine Stump 提交于
      virNetDevTapCreateInBridgePort() has always set the new tap device to
      the current MTU of the bridge it's being attached to. There is one
      case where we will want to set the new tap device to a different
      (usually larger) MTU - if that's done with the very first device added
      to the bridge, the bridge's MTU will be set to the device's MTU. This
      patch allows for that possibility by adding "int mtu" to the arg list
      for virNetDevTapCreateInBridgePort(), but all callers are sending -1,
      so it doesn't yet have any effect.
      
      Since the requested MTU isn't necessarily what is used in the end (for
      example, if there is no MTU requested, the tap device will be set to
      the current MTU of the bridge), and the hypervisor may want to know
      the actual MTU used, we also return the actual MTU to the caller (if
      actualMTU is non-NULL).
      dd8ac030
  16. 02 1月, 2017 1 次提交
  17. 19 12月, 2016 1 次提交
  18. 06 12月, 2016 2 次提交
  19. 03 11月, 2016 1 次提交
  20. 29 10月, 2016 1 次提交
  21. 20 10月, 2016 1 次提交
  22. 12 10月, 2016 1 次提交
  23. 11 10月, 2016 1 次提交
    • M
      network: add dnsmasq option 'dhcp-authoritative' · 4ac20b3a
      Martin Wilck 提交于
      The dnsmasq man page recommends that dhcp-authoritative "should be
      set when dnsmasq is definitely the only DHCP server on a network".
      This is the case for libvirt-managed virtual networks.
      
      The effect of this is that VMs that fail to renew their DHCP lease
      in time (e.g. if the VM or host is suspended) will be able to
      re-acquire the lease even if it's expired, unless the IP address has
      been taken by some other host. This avoids various annoyances caused
      by changing VM IP addresses.
      4ac20b3a
  24. 23 8月, 2016 1 次提交
  25. 20 8月, 2016 3 次提交
    • L
      network: allow limiting a <forwarder> element to certain domains · 0b6336c2
      Laine Stump 提交于
      For some unknown reason the original implementation of the <forwarder>
      element only took advantage of part of the functionality in the
      dnsmasq feature it exposes - it allowed specifying the ip address of a
      DNS server which *all* DNS requests would be forwarded to, like this:
      
         <forwarder addr='192.168.123.25'/>
      
      This is a frontend for dnsmasq's "server" option, which also allows
      you to specify a domain that must be matched in order for a request to
      be forwarded to a particular server. This patch adds support for
      specifying the domain. For example:
      
         <forwarder domain='example.com' addr='192.168.1.1'/>
         <forwarder domain='www.example.com'/>
         <forwarder domain='travesty.org' addr='10.0.0.1'/>
      
      would forward requests for bob.example.com, ftp.example.com and
      joe.corp.example.com all to the DNS server at 192.168.1.1, but would
      forward requests for travesty.org and www.travesty.org to
      10.0.0.1. And due to the second line, requests for www.example.com,
      and odd.www.example.com would be resolved by the libvirt network's own
      DNS server (i.e. thery wouldn't be immediately forwarded) even though
      they also match 'example.com' - the match is given to the entry with
      the longest matching domain. DNS requests not matching any of the
      entries would be resolved by the libvirt network's own DNS server.
      
      Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1331796
      0b6336c2
    • L
      network: allow disabling dnsmasq's DNS server · 9065cfaa
      Laine Stump 提交于
      If you define a libvirt virtual network with one or more IP addresses,
      it starts up an instance of dnsmasq. It's always been possible to
      avoid dnsmasq's dhcp server (simply don't include a <dhcp> element),
      but until now it wasn't possible to avoid having the DNS server
      listening; even if the network has no <dns> element, it is started
      using default settings.
      
      This patch adds a new attribute to <dns>: enable='yes|no'. For
      backward compatibility, it defaults to 'yes', but if you don't want a
      DNS server created for the network, you can simply add:
      
         <dns enable='no'/>
      
      to the network configuration, and next time the network is started
      there will be no dns server created (if there is dhcp configuration,
      dnsmasq will be started with "port=0" which disables the DNS server;
      if there is no dhcp configuration, dnsmasq won't be started at all).
      9065cfaa
    • L
      network: new network forward mode 'open' · 25e8112d
      Laine Stump 提交于
      The new forward mode 'open' is just like mode='route', except that no
      firewall rules are added to assure that any traffic does or doesn't
      pass. It is assumed that either they aren't necessary, or they will be
      setup outside the scope of libvirt.
      
      Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=846810
      25e8112d
  26. 27 7月, 2016 1 次提交
  27. 13 7月, 2016 1 次提交
    • M
      dnsmasq: disable IPv6 default gateway in RA for isolated networks · 527968d4
      Maxim Perevedentsev 提交于
      IPv6 RA always contains an implicit default route via
      the link-local address of the source of RA. This forces
      the guest to install a route via isolated network, which
      may disturb the guest's networking in case of multiple interfaces.
      More info in 013427e6.
      
      The validity of this route is controlled by "default [route] lifetime"
      field of RA. If the lifetime is set to 0 seconds, then no route
      is installed by receiver.
      
      dnsmasq 2.67+ supports "ra-param=<interface>,<RA interval>,<default
      lifetime>" option. We pass "ra-param=*,0,0"
      (here, RA_interval=0 means default) to disable default gateway in RA
      for isolated networks.
      527968d4
  28. 27 6月, 2016 3 次提交
    • 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
      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