1. 17 6月, 2016 2 次提交
  2. 06 6月, 2016 1 次提交
  3. 05 4月, 2016 2 次提交
  4. 23 3月, 2016 2 次提交
  5. 18 3月, 2016 1 次提交
    • E
      qapi: Don't special-case simple union wrappers · 32bafa8f
      Eric Blake 提交于
      Simple unions were carrying a special case that hid their 'data'
      QMP member from the resulting C struct, via the hack method
      QAPISchemaObjectTypeVariant.simple_union_type().  But by using
      the work we started by unboxing flat union and alternate
      branches, coupled with the ability to visit the members of an
      implicit type, we can now expose the simple union's implicit
      type in qapi-types.h:
      
      | struct q_obj_ImageInfoSpecificQCow2_wrapper {
      |     ImageInfoSpecificQCow2 *data;
      | };
      |
      | struct q_obj_ImageInfoSpecificVmdk_wrapper {
      |     ImageInfoSpecificVmdk *data;
      | };
      ...
      | struct ImageInfoSpecific {
      |     ImageInfoSpecificKind type;
      |     union { /* union tag is @type */
      |         void *data;
      |-        ImageInfoSpecificQCow2 *qcow2;
      |-        ImageInfoSpecificVmdk *vmdk;
      |+        q_obj_ImageInfoSpecificQCow2_wrapper qcow2;
      |+        q_obj_ImageInfoSpecificVmdk_wrapper vmdk;
      |     } u;
      | };
      
      Doing this removes asymmetry between QAPI's QMP side and its
      C side (both sides now expose 'data'), and means that the
      treatment of a simple union as sugar for a flat union is now
      equivalent in both languages (previously the two approaches used
      a different layer of dereferencing, where the simple union could
      be converted to a flat union with equivalent C layout but
      different {} on the wire, or to an equivalent QMP wire form
      but with different C representation).  Using the implicit type
      also lets us get rid of the simple_union_type() hack.
      
      Of course, now all clients of simple unions have to adjust from
      using su->u.member to using su->u.member.data; while this touches
      a number of files in the tree, some earlier cleanup patches
      helped minimize the change to the initialization of a temporary
      variable rather than every single member access.  The generated
      qapi-visit.c code is also affected by the layout change:
      
      |@@ -7393,10 +7393,10 @@ void visit_type_ImageInfoSpecific_member
      |     }
      |     switch (obj->type) {
      |     case IMAGE_INFO_SPECIFIC_KIND_QCOW2:
      |-        visit_type_ImageInfoSpecificQCow2(v, "data", &obj->u.qcow2, &err);
      |+        visit_type_q_obj_ImageInfoSpecificQCow2_wrapper_members(v, &obj->u.qcow2, &err);
      |         break;
      |     case IMAGE_INFO_SPECIFIC_KIND_VMDK:
      |-        visit_type_ImageInfoSpecificVmdk(v, "data", &obj->u.vmdk, &err);
      |+        visit_type_q_obj_ImageInfoSpecificVmdk_wrapper_members(v, &obj->u.vmdk, &err);
      |         break;
      |     default:
      |         abort();
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1458254921-17042-13-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      32bafa8f
  6. 17 3月, 2016 1 次提交
  7. 16 3月, 2016 1 次提交
    • P
      replay: character devices · 33577b47
      Pavel Dovgalyuk 提交于
      This patch implements record and replay of character devices.
      It records chardevs communication in replay mode. Recorded information
      include data read from backend and counter of bytes written
      from frontend to backend to preserve frontend internal state.
      If character device was configured through the command line in record mode,
      then in replay mode it should be also added to command line. Backend of
      the character device could be changed in replay mode.
      Replaying of devices that perform ioctl and get_msgfd operations is not
      supported.
      gdbstub which also acts as a backend is not recorded to allow controlling
      the replaying through gdb. Monitor backends are also not recorded.
      Signed-off-by: NPavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
      Message-Id: <20160314074436.4980.83856.stgit@PASHA-ISP>
      [Add stubs. - Paolo]
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      33577b47
  8. 11 3月, 2016 6 次提交
  9. 05 3月, 2016 3 次提交
    • E
      chardev: Drop useless ChardevDummy type · b1918fbb
      Eric Blake 提交于
      Commit d0d7708b made ChardevDummy be an empty wrapper type around
      ChardevCommon.  But there is no technical reason for this indirection,
      so simplify the code by directly using the base type.
      
      Also change the fallback assignment to assign u.null rather than
      u.data, since a future patch will remove the data member of the C
      struct generated for QAPI unions.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NDaniel P. Berrange <berrange@redhat.com>
      Message-Id: <1457106160-23614-1-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      b1918fbb
    • E
      util: Shorten references into SocketAddress · 0399293e
      Eric Blake 提交于
      An upcoming patch will alter how simple unions, like SocketAddress,
      are laid out, which will impact all lines of the form 'addr->u.XXX'
      (expanding it to the longer 'addr->u.XXX.data').  For better
      legibility in that patch, and less need for line wrapping, it's better
      to use a temporary variable to reduce the effect of a layout change to
      just the variable initializations, rather than every reference within
      a SocketAddress.  Also, take advantage of some C99 initialization where
      it makes sense (simplifying g_new0() to g_new()).
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1457021813-10704-7-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      0399293e
    • E
      chardev: Shorten references into ChardevBackend · f194a1ae
      Eric Blake 提交于
      An upcoming patch will alter how simple unions, like ChardevBackend,
      are laid out, which will impact all lines of the form 'backend->u.XXX'
      (expanding it to the longer 'backend->u.XXX.data').  For better
      legibility in that patch, and less need for line wrapping, it's better
      to use a temporary variable to reduce the effect of a layout change to
      just the variable initializations, rather than every reference within
      a ChardevBackend.  It doesn't hurt that this also makes the code more
      consistent: some clients touched here already had a temporary variable
      but weren't using it.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-By: NDaniel P. Berrange <berrange@redhat.com>
      Message-Id: <1457021813-10704-6-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      f194a1ae
  10. 25 2月, 2016 1 次提交
  11. 16 2月, 2016 2 次提交
    • D
      char: fix handling of QIO_CHANNEL_ERR_BLOCK · e046fb44
      Daniel P. Berrange 提交于
      If io_channel_send_full gets QIO_CHANNEL_ERR_BLOCK it
      and has already sent some of the data, it should return
      that amount of data, not EAGAIN, as that would cause
      the caller to re-try already sent data.
      
      Unfortunately due to a previous rebase conflict resolution
      error, the code for dealing with this was in the wrong
      part of the conditional, and so mistakenly ran on other
      I/O errors.
      
      This be seen running
      
         qemu-system-x86_64 -monitor stdio
      
      and entering 'info mtree', when running on a slow console
      (eg a slow remote ssh session). The monitor would get into
      an indefinite loop writing the same data until it managed
      to send it all without getting EAGAIN.
      Reported-by: NIgor Mammedov <imammedo@redhat.com>
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Message-Id: <1455288410-27046-1-git-send-email-berrange@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      e046fb44
    • P
      Revert "qemu-char: Keep pty slave file descriptor open until the master is closed" · 837a183f
      Paolo Bonzini 提交于
      This reverts commit 34689e20.
      
      Marc-André Lureau provided the following commentary: "It looks like if
      a the slave is opened, then Linux will buffer the master writes, up to
      a few kb and then throttle, so it's not entirely blocked but eventually
      the guest VM dies.  However, not having any slave open it will simply let
      the write go and discard the data.  At least, virt-install configures
      a pty for the serial but viewers like virt-manager do not necessarily
      open it.  And, if there are no viewers, it will just hang.  If qemu
      starts reading all the data from the slave, I don't think interactions
      with other slaves will work. I don't see much options but to close the
      slave, thus reverting this patch."
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      837a183f
  12. 11 2月, 2016 1 次提交
  13. 10 2月, 2016 1 次提交
  14. 09 2月, 2016 2 次提交
    • D
      char: fix repeated registration of tcp chardev I/O handlers · 1e94f23d
      Daniel P. Berrange 提交于
      In previous commit:
      
        commit f2001a7e
        Author: Daniel P. Berrange <berrange@redhat.com>
        Date:   Tue Jan 19 11:14:30 2016 +0000
      
          char: don't assume telnet initialization will not block
      
      The code which writes the telnet initialization sequence moved
      to an event loop callback. If the TCP chardev is opened as a
      server in blocking mode (ie -serial telnet:0.0.0.0:3000,server,wait)
      this results in a state where the TCP chardev is connected, but not
      yet ready to send/recv data when virtual hardware is created.
      
      When the virtual hardware initialization registers its chardev
      callbacks, it triggers tcp_chr_update_read_handler, which will
      add I/O watches to the connection.
      
      When the telnet initialization finally runs, it will then call
      tcp_chr_connect to finish the connection setup. This will in
      turn add I/O watches to the connection too.
      
      There are now two sets of I/O watches registered on the same
      connection. This ultimately causes data loss on the connection,
      for example, when typing into the telnet console only every
      second byte is echoed back to the client.
      
      The same flaw can affect channels running with TLS encryption
      too, since they also have delayed connection setup completion.
      
      The fix is to update tcp_chr_update_read_handler so that it
      avoids registering watches if the connection is not fully
      setup yet.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Message-Id: <1454939707-10869-1-git-send-email-berrange@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      1e94f23d
    • P
      qemu-char: Keep pty slave file descriptor open until the master is closed · 34689e20
      Paolo Bonzini 提交于
      If a process opens the slave pts device, writes data to it, then
      immediately closes it, the data doesn't reliably get delivered to the
      emulated serial port. This seems to be because a read of the master
      pty device returns EIO on Linux if no process has the pts device open,
      even when data is waiting "in the pipe".
      
      A fix seems to be for QEMU to keep the pts file descriptor open until
      the pty is closed, as per the below patch.
      Signed-off-by: NAshley Jonathan <jonathan.ashley@altran.com>
      Message-Id: <AC19797808C8D548ABDE0CA4A97AA30A30DEB409@XMB-DCFR-37.europe.corp.altran.com>
      Reviewed-by: NMichael Tokarev <mjt@tls.msk.ru>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      34689e20
  15. 05 2月, 2016 1 次提交
    • P
      all: Clean up includes · d38ea87a
      Peter Maydell 提交于
      Clean up includes so that osdep.h is included first and headers
      which it implies are not included manually.
      
      This commit was created with scripts/clean-includes.
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      Message-id: 1454089805-5470-16-git-send-email-peter.maydell@linaro.org
      d38ea87a
  16. 02 2月, 2016 1 次提交
  17. 26 1月, 2016 5 次提交
    • P
      qemu-char: avoid leak in qemu_chr_open_pp_fd · 27ef9cb0
      Paolo Bonzini 提交于
      drv leaks if qemu_chr_alloc returns an error.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      27ef9cb0
    • D
      char: introduce support for TLS encrypted TCP chardev backend · a8fb5427
      Daniel P. Berrange 提交于
      This integrates support for QIOChannelTLS object in the TCP
      chardev backend. If the 'tls-creds=NAME' option is passed with
      the '-chardev tcp' argument, then it will setup the chardev
      such that the client is required to establish a TLS handshake
      when connecting. There is no support for checking the client
      certificate against ACLs in this initial patch. This is pending
      work to QOM-ify the ACL object code.
      
      A complete invocation to run QEMU as the server for a TLS
      encrypted serial dev might be
      
        $ qemu-system-x86_64 \
            -nodefconfig -nodefaults -device sga -display none \
            -chardev socket,id=s0,host=127.0.0.1,port=9000,tls-creds=tls0,server \
            -device isa-serial,chardev=s0 \
            -object tls-creds-x509,id=tls0,endpoint=server,verify-peer=off,\
               dir=/home/berrange/security/qemutls
      
      To test with the gnutls-cli tool as the client:
      
        $ gnutls-cli --priority=NORMAL -p 9000 \
             --x509cafile=/home/berrange/security/qemutls/ca-cert.pem \
             127.0.0.1
      
      If QEMU was told to use 'anon' credential type, then use the
      priority string 'NORMAL:+ANON-DH' with gnutls-cli
      
      Alternatively, if setting up a chardev to operate as a client,
      then the TLS credentials registered must be for the client
      endpoint. First a TLS server must be setup, which can be done
      with the gnutls-serv tool
      
        $ gnutls-serv --priority=NORMAL -p 9000 --echo \
             --x509cafile=/home/berrange/security/qemutls/ca-cert.pem \
             --x509certfile=/home/berrange/security/qemutls/server-cert.pem \
             --x509keyfile=/home/berrange/security/qemutls/server-key.pem
      
      Then QEMU can connect with
      
        $ qemu-system-x86_64 \
            -nodefconfig -nodefaults -device sga -display none \
            -chardev socket,id=s0,host=127.0.0.1,port=9000,tls-creds=tls0 \
            -device isa-serial,chardev=s0 \
            -object tls-creds-x509,id=tls0,endpoint=client,\
              dir=/home/berrange/security/qemutls
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Message-Id: <1453202071-10289-5-git-send-email-berrange@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      a8fb5427
    • D
      char: don't assume telnet initialization will not block · f2001a7e
      Daniel P. Berrange 提交于
      The current code for doing telnet initialization is writing to
      a socket without checking the return status. While it is highly
      unlikely to be a problem when writing to a bare socket, as the
      buffers are large enough to prevent blocking, this cannot be
      assumed safe with TLS sockets. So write the telnet initialization
      code into a memory buffer and then use an I/O watch to fully
      send the data.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Message-Id: <1453202071-10289-4-git-send-email-berrange@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      f2001a7e
    • D
      char: convert from GIOChannel to QIOChannel · 9894dc0c
      Daniel P. Berrange 提交于
      In preparation for introducing TLS support to the TCP chardev
      backend, convert existing chardev code from using GIOChannel
      to QIOChannel. This simplifies the chardev code by removing
      most of the OS platform conditional code for dealing with
      file descriptor passing.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Message-Id: <1453202071-10289-3-git-send-email-berrange@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      9894dc0c
    • D
      char: remove fixed length filename allocation · 0ff0fad2
      Daniel P. Berrange 提交于
      A variety of places were snprintf()ing into a fixed length
      filename buffer. Some of the buffers were stack allocated,
      while another was heap allocated with g_malloc(). Switch
      them all to heap allocated using g_strdup_printf() avoiding
      arbitrary length restrictions.
      
      This also facilitates later patches which will want to
      populate the filename by calling external functions
      which do not support use of a pre-allocated buffer.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Message-Id: <1453202071-10289-2-git-send-email-berrange@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      0ff0fad2
  18. 16 1月, 2016 3 次提交
    • P
      qemu-char: do not leak QemuMutex when freeing a character device · fefd749c
      Paolo Bonzini 提交于
      The leak is only apparent on Win32.  On POSIX platforms destroying a
      mutex is not necessary.
      Reported-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NDaniel P. Berrange <berrange@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      fefd749c
    • D
      qemu-char: add logfile facility to all chardev backends · d0d7708b
      Daniel P. Berrange 提交于
      Typically a UNIX guest OS will log boot messages to a serial
      port in addition to any graphical console. An admin user
      may also wish to use the serial port for an interactive
      console. A virtualization management system may wish to
      collect system boot messages by logging the serial port,
      but also wish to allow admins interactive access.
      
      Currently providing such a feature forces the mgmt app
      to either provide 2 separate serial ports, one for
      logging boot messages and one for interactive console
      login, or to proxy all output via a separate service
      that can multiplex the two needs onto one serial port.
      While both are valid approaches, they each have their
      own downsides. The former causes confusion and extra
      setup work for VM admins creating disk images. The latter
      places an extra burden to re-implement much of the QEMU
      chardev backends logic in libvirt or even higher level
      mgmt apps and adds extra hops in the data transfer path.
      
      A simpler approach that is satisfactory for many use
      cases is to allow the QEMU chardev backends to have a
      "logfile" property associated with them.
      
       $QEMU -chardev socket,host=localhost,port=9000,\
                      server=on,nowait,id-charserial0,\
      		logfile=/var/log/libvirt/qemu/test-serial0.log
             -device isa-serial,chardev=charserial0,id=serial0
      
      This patch introduces a 'ChardevCommon' struct which
      is setup as a base for all the ChardevBackend types.
      Ideally this would be registered directly as a base
      against ChardevBackend, rather than each type, but
      the QAPI generator doesn't allow that since the
      ChardevBackend is a non-discriminated union. The
      ChardevCommon struct provides the optional 'logfile'
      parameter, as well as 'logappend' which controls
      whether QEMU truncates or appends (default truncate).
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Message-Id: <1452516281-27519-1-git-send-email-berrange@redhat.com>
      [Call qemu_chr_parse_common if cd->parse is NULL. - Paolo]
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      d0d7708b
    • D
      qemu-char: delete send_all/recv_all helper methods · 46f296cd
      Daniel P. Berrange 提交于
      The qemu-char.c contains two helper methods send_all
      and recv_all. These are in fact declared in sockets.h
      so ought to have been in util/qemu-sockets.c. For added
      fun the impl of recv_all is completely missing on Win32.
      
      Fortunately there is only a single caller of these
      methods, the TPM passthrough code, which is only
      ever compiled on Linux. With only a single caller
      these helpers are not compelling enough to keep so
      inline them in the TPM code, avoiding the need to
      fix the missing recv_all on Win32.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Message-Id: <1450879144-17111-1-git-send-email-berrange@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      46f296cd
  19. 19 12月, 2015 1 次提交
  20. 18 12月, 2015 1 次提交
  21. 02 12月, 2015 1 次提交
  22. 02 11月, 2015 1 次提交
    • E
      char: Convert to new qapi union layout · 130257dc
      Eric Blake 提交于
      We have two issues with our qapi union layout:
      1) Even though the QMP wire format spells the tag 'type', the
      C code spells it 'kind', requiring some hacks in the generator.
      2) The C struct uses an anonymous union, which places all tag
      values in the same namespace as all non-variant members. This
      leads to spurious collisions if a tag value matches a non-variant
      member's name.
      
      Make the conversion to the new layout for character-related
      code.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1445898903-12082-19-git-send-email-eblake@redhat.com>
      [Commit message tweaked slightly]
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      130257dc