1. 07 8月, 2019 1 次提交
  2. 19 7月, 2019 1 次提交
    • D
      remote: increase daemon shutdown timer to 2 minutes · 9d7fcdbf
      Daniel P. Berrangé 提交于
      Shutting down the daemon after 30 seconds of being idle is a little bit
      too aggressive. Especially when using 'virsh' in single-shot mode, as
      opposed to interactive shell mode, it would not be unusual to have
      more than 30 seconds between commands. This will lead to the daemon
      shutting down and starting up between a series of commands.
      
      Increasing the shutdown timer to 2 minutes will make it less likely that
      the daemon will shutdown while the user is in the middle of a series of
      commands.
      Reviewed-by: NJim Fehlig <jfehlig@suse.com>
      Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
      9d7fcdbf
  3. 12 7月, 2019 2 次提交
  4. 11 7月, 2019 2 次提交
    • D
      rpc: always pass "-T -e none" args to ssh · 1939bcd5
      Daniel P. Berrangé 提交于
      Way back in the past, the "no_tty=1" option was added for the remote
      driver to disable local password prompting by disabling use of the local
      tty:
      
        commit b32f4298
        Author: Daniel P. Berrange <berrange@redhat.com>
        Date:   Fri Sep 21 20:17:09 2007 +0000
      
          Added a no_tty param to remote URIs to stop SSH prompting for password
      
      This was done by adding "-T -o BatchMode=yes -e none" args to ssh. This
      achieved the desired results but is none the less semantically flawed
      because it is mixing up config parameters for the local tty vs the
      remote tty.
      
      The "-T" arg stops allocation of a TTY on the remote host. This is good
      for all libvirt SSH tunnels as we never require a TTY for our usage
      model, so we should have just passed this unconditionally.
      
      The "-e none" option disables the escape character for sessions with a
      TTY. If we pass "-T" this is not required, but it also not harmful to
      add it, so we should just pass it unconditionally too.
      
      Only the "-o BatchMode=yes" option is related to disabling local
      password prompts and thus needs control via the no_tty URI param.
      Reviewed-by: NAndrea Bolognani <abologna@redhat.com>
      Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
      1939bcd5
    • D
  5. 04 2月, 2019 1 次提交
  6. 14 12月, 2018 1 次提交
    • D
      Remove all Author(s): lines from source file headers · 60046283
      Daniel P. Berrangé 提交于
      In many files there are header comments that contain an Author:
      statement, supposedly reflecting who originally wrote the code.
      In a large collaborative project like libvirt, any non-trivial
      file will have been modified by a large number of different
      contributors. IOW, the Author: comments are quickly out of date,
      omitting people who have made significant contribitions.
      
      In some places Author: lines have been added despite the person
      merely being responsible for creating the file by moving existing
      code out of another file. IOW, the Author: lines give an incorrect
      record of authorship.
      
      With this all in mind, the comments are useless as a means to identify
      who to talk to about code in a particular file. Contributors will always
      be better off using 'git log' and 'git blame' if they need to  find the
      author of a particular bit of code.
      
      This commit thus deletes all Author: comments from the source and adds
      a rule to prevent them reappearing.
      
      The Copyright headers are similarly misleading and inaccurate, however,
      we cannot delete these as they have legal meaning, despite being largely
      inaccurate. In addition only the copyright holder is permitted to change
      their respective copyright statement.
      Reviewed-by: NErik Skultety <eskultet@redhat.com>
      Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
      60046283
  7. 25 7月, 2018 2 次提交
  8. 23 7月, 2018 1 次提交
    • A
      src: Make virStr*cpy*() functions return an int · 6c0d0210
      Andrea Bolognani 提交于
      Currently, the functions return a pointer to the
      destination buffer on success or NULL on failure.
      
      Not only does this kind of error handling look quite
      alien in the context of libvirt, where most functions
      return zero on success and a negative int on failure,
      but it's also somewhat pointless because unless there's
      been a failure the returned pointer will be the same
      one passed in by the user, thus offering no additional
      value.
      
      Change the functions so that they return an int
      instead.
      Signed-off-by: NAndrea Bolognani <abologna@redhat.com>
      6c0d0210
  9. 04 5月, 2018 1 次提交
  10. 18 4月, 2018 1 次提交
    • M
      virobject: Introduce VIR_CLASS_NEW() macro · 10f94828
      Michal Privoznik 提交于
      So far we are repeating the following lines over and over:
      
        if (!(virSomeObjectClass = virClassNew(virClassForObject(),
                                   "virSomeObject",
                                   sizeof(virSomeObject),
                                   virSomeObjectDispose)))
            return -1;
      
      While this works, it is impossible to do some checking. Firstly,
      the class name (the 2nd argument) doesn't match the name in the
      code in all cases (the 3rd argument). Secondly, the current style
      is needlessly verbose. This commit turns example into following:
      
        if (!(VIR_CLASS_NEW(virSomeObject,
                            virClassForObject)))
            return -1;
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      Reviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
      10f94828
  11. 06 4月, 2018 1 次提交
    • J
      util: introduce virSocketAddrParseAny · 412afdb8
      Jim Fehlig 提交于
      When preparing for migration, the libxl driver creates a new TCP listen
      socket for the incoming migration by calling virNetSocketNewListenTCP,
      passing the destination host name. virNetSocketNewListenTCP calls
      virSocketAddrParse to check if the host name is a wildcard address, in
      which case it avoids adding the AI_ADDRCONFIG flag to the hints passed to
      getaddrinfo. If the host name is not an IP address, virSocketAddrParse
      reports an error
      
      error : virSocketAddrParseInternal:121 : Cannot parse socket address
      'myhost.example.com': Name or service not known
      
      But virNetSocketNewListenTCP succeeds regardless and the overall migration
      operation succeeds.
      
      Introduce virSocketAddrParseAny and use it when simply testing if a host
      name/addr is parsable.
      Signed-off-by: NJim Fehlig <jfehlig@suse.com>
      Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
      412afdb8
  12. 26 1月, 2018 1 次提交
    • D
      rpc: fix race sending and encoding sasl data · 4e13fb02
      Daniel P. Berrange 提交于
      The virNetSocketWriteSASL method has to encode the buffer it is given and then
      write it to the underlying socket. This write is not guaranteed to send the
      full amount of data that was encoded by SASL. We cache the SASL encoded data so
      that on the next invocation of virNetSocketWriteSASL we carry on sending it.
      
      The subtle problem is that the 'len' value passed into virNetSocketWriteSASL on
      the 2nd call may be larger than the original value. So when we've completed
      sending the SASL encoded data we previously cached, we must return the original
      length we encoded, not the new length.
      
      This flaw means we could potentially have been discarded queued data without
      sending it. This would have exhibited itself as a libvirt client never receiving
      the reply to a method it invokes, async events silently going missing, or worse
      stream data silently getting dropped.
      
      For this to be a problem libvirtd would have to be queued data to send to the
      client, while at the same time the TCP socket send buffer is full (due to a very
      slow client). This is quite unlikely so if this bug was ever triggered by a real
      world user it would be almost impossible to reproduce or diagnose, if indeed it
      was ever noticed at all.
      Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      4e13fb02
  13. 30 8月, 2017 1 次提交
    • D
      rpc: avoid ssh interpreting malicious hostname as arguments · e4cb8500
      Daniel P. Berrange 提交于
      Inspired by the recent GIT / Mercurial security flaws
      (http://blog.recurity-labs.com/2017-08-10/scm-vulns),
      consider someone/something manages to feed libvirt a bogus
      URI such as:
      
        virsh -c qemu+ssh://-oProxyCommand=gnome-calculator/system
      
      In this case, the hosname "-oProxyCommand=gnome-calculator"
      will get interpreted as an argument to ssh, not a hostname.
      Fortunately, due to the set of args we have following the
      hostname, SSH will then interpret our bit of shell script
      that runs 'nc' on the remote host as a cipher name, which is
      clearly invalid. This makes ssh exit during argv parsing and
      so it never tries to run gnome-calculator.
      
      We are lucky this time, but lets be more paranoid, by using
      '--' to explicitly tell SSH when it has finished seeing
      command line options. This forces it to interpret
      "-oProxyCommand=gnome-calculator" as a hostname, and thus
      see a fail from hostname lookup.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      e4cb8500
  14. 18 3月, 2017 1 次提交
  15. 15 11月, 2016 2 次提交
    • P
      remote: expose a new libssh transport · 22eaee8e
      Pino Toscano 提交于
      Implement in virtNetClient and VirNetSocket the needed functions to
      expose a new libssh transport, providing all the options that the
      libssh2 transport supports.
      22eaee8e
    • P
      virNetSocket: allow to not close FD · 0e9fec97
      Pino Toscano 提交于
      Add an internal variable to mark the FD as "not owned" by the
      virNetSocket, in case the internal implementation takes the actual
      ownership of the descriptor; this avoids a warning when closing the
      socket, as the FD would be invalid.
      0e9fec97
  16. 24 6月, 2016 4 次提交
  17. 03 5月, 2016 1 次提交
    • E
      virnetsocket: Provide socket address format in a more standard form · 9b45c9f0
      Erik Skultety 提交于
      Our socket address format is in a rather non-standard format and that is
      because sasl library requires the IP address and service to be delimited by a
      semicolon. The string form is a completely internal matter, however once the
      admin interfaces to retrieve client identity information are merged, we should
      return the socket address string in a common format, e.g. format defined by
      URI rfc-3986, i.e. the IP address and service are delimited by a colon and
      in case of an IPv6 address, square brackets are added:
      
      Examples:
          127.0.0.1:1234
          [::1]:1234
      
      This patch changes our default format to the one described above, while adding
      separate methods to request the non-standard SASL format using semicolon as a
      delimiter.
      Signed-off-by: NErik Skultety <eskultet@redhat.com>
      9b45c9f0
  18. 17 3月, 2016 1 次提交
  19. 12 1月, 2016 4 次提交
  20. 04 11月, 2015 1 次提交
  21. 12 8月, 2015 1 次提交
  22. 17 7月, 2015 1 次提交
    • D
      rpc: ensure daemon is spawn even if dead socket exists · 406ee8c2
      Daniel P. Berrange 提交于
      The auto-spawn code would originally attempt to spawn the
      daemon for both ENOENT and ECONNREFUSED errors from connect().
      The various refactorings eventually lost this so we only
      spawn the daemon on ENOENT. The result is if the daemon exits
      uncleanly, so that the socket is left in the filesystem, we
      will never be able to auto-spawn the daemon again.
      406ee8c2
  23. 19 6月, 2015 2 次提交
    • M
      virNetSocket: Fix @watch corner case · 9ee5a798
      Michal Privoznik 提交于
      Although highly unlikely, nobody says that virEventAddHandle()
      can't return 0 as a handle to socket callback. It can't happen
      with our default implementation since all watches will have value
      1 or greater, but users can register their own callback functions
      (which can re-use unused watch IDs for instance). If this is the
      case, weird things may happen.
      
      Also, there's a little bug I'm fixing too, upon
      virNetSocketRemoveIOCallback(), the variable holding callback ID
      was not reset. Therefore calling AddIOCallback() once again would
      fail. Not that we are doing it right now, but we might.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      9ee5a798
    • M
      virNetSocketRemoveIOCallback: Be explicit about unref · 899e49a2
      Michal Privoznik 提交于
      When going through the code I've notice that
      virNetSocketAddIOCallback() increases the reference counter of
      @socket. However, its counter part RemoveIOCallback does not. It took
      me a while to realize this disproportion. The AddIOCallback registers
      our own callback which eventually calls the desired callback and then
      unref the @sock. Yeah, a bit complicated but it works. So, lets note
      this hard learned fact in a comment in RemoveIOCallback().
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      899e49a2
  24. 11 6月, 2015 2 次提交
  25. 24 4月, 2015 1 次提交
    • J
      Fix memory leak in virNetSocketNewConnectUNIX · da4d7c30
      Jiri Denemark 提交于
      ==26726==    by 0x673CD67: __vasprintf_chk (vasprintf_chk.c:80)
      ==26726==    by 0x5673605: UnknownInlinedFun (stdio2.h:210)
      ==26726==    by 0x5673605: virVasprintfInternal (virstring.c:476)
      ==26726==    by 0x56736EE: virAsprintfInternal (virstring.c:497)
      ==26726==    by 0x5680C37: virGetUserRuntimeDirectory (virutil.c:866)
      ==26726==    by 0x5783A89: virNetSocketNewConnectUNIX (virnetsocket.c:572)
      ==26726==    by 0x57751AF: virNetClientNewUNIX (virnetclient.c:344)
      ==26726==    by 0x57689B3: doRemoteOpen (remote_driver.c:895)
      ==26726==    by 0x5769F8E: remoteConnectOpen (remote_driver.c:1195)
      ==26726==    by 0x57092DF: do_open (libvirt.c:1189)
      ==26726==    by 0x570A7BF: virConnectOpenAuth (libvirt.c:1341)
      
      https://bugzilla.redhat.com/show_bug.cgi?id=1215042Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
      da4d7c30
  26. 17 4月, 2015 1 次提交
  27. 15 4月, 2015 1 次提交
    • M
      virNetSocketNewConnectUNIX: Use flocks when spawning a daemon · be78814a
      Michal Privoznik 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=1200149
      
      Even though we have a mutex mechanism so that two clients don't spawn
      two daemons, it's not strong enough. It can happen that while one
      client is spawning the daemon, the other one fails to connect.
      Basically two possible errors can happen:
      
        error: Failed to connect socket to '/home/mprivozn/.cache/libvirt/libvirt-sock': Connection refused
      
      or:
      
        error: Failed to connect socket to '/home/mprivozn/.cache/libvirt/libvirt-sock': No such file or directory
      
      The problem in both cases is, the daemon is only starting up, while we
      are trying to connect (and fail). We should postpone the connecting
      phase until the daemon is started (by the other thread that is
      spawning it). In order to do that, create a file lock 'libvirt-lock'
      in the directory where session daemon would create its socket. So even
      when called from multiple processes, spawning a daemon will serialize
      on the file lock. So only the first to come will spawn the daemon.
      Tested-by: NRichard W. M. Jones <rjones@redhat.com>
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      be78814a
  28. 20 11月, 2014 1 次提交