1. 29 6月, 2011 6 次提交
    • D
      Improve two log messages in virNetMessage · b7337d03
      Daniel P. Berrange 提交于
      Improve log messages issued when encountering a bogus
      message length to include the actual length and the
      limit violated
      
      * src/rpc/virnetmessage.c: Improve log messages
      b7337d03
    • D
      Ensure empty payload is written upon stream completion · 59b877b6
      Daniel P. Berrange 提交于
      On stream completion it is neccessary to send back a
      message with an empty payload. The message header was
      not being filled out correctly, since we were not writing
      any payload. Add a method for encoding an empty payload
      which updates the message headers correctly.
      
      * src/rpc/virnetmessage.c, src/rpc/virnetmessage.h: Add
        a virNetMessageEncodePayloadEmpty method
      * src/rpc/virnetserverprogram.c: Write empty payload on
        stream completion
      59b877b6
    • D
      Lower logging level when failing to register socket watch · d550277c
      Daniel P. Berrange 提交于
      The RPC client treats failure to register a socket watch
      as non-fatal, since we do not mandate that a libvirt client
      application provide an event loop implementation. It is
      thus inappropriate to a log a message at VIR_LOG_WARN
      
      * src/rpc/virnetsocket.c: Lower logging level
      d550277c
    • D
      Fix propagation of RPC errors from streams · 16c6e2b4
      Daniel P. Berrange 提交于
      If a streams error is raised, virNetClientIOEventLoop
      returns 0, but an error is set. Check for this and
      propagate it if present
      
      * src/rpc/virnetclient.c: Propagate streams error
      16c6e2b4
    • D
      Convert libvirtd over to the new RPC handling APIs · df0b57a9
      Daniel P. Berrange 提交于
      This guts the libvirtd daemon, removing all its networking and
      RPC handling code. Instead it calls out to the new virServerPtr
      APIs for all its RPC & networking work
      
      As a fallout all libvirtd daemon error reporting now takes place
      via the normal internal error reporting APIs. There is no need
      to call separate error reporting APIs in RPC code, nor should
      code use VIR_WARN/VIR_ERROR for reporting fatal problems anymore.
      
      * daemon/qemu_dispatch_*.h, daemon/remote_dispatch_*.h: Remove
        old generated dispatcher code
      * daemon/qemu_dispatch.h, daemon/remote_dispatch.h: New dispatch
        code
      * daemon/dispatch.c, daemon/dispatch.h: Remove obsoleted code
      * daemon/remote.c, daemon/remote.h: Rewrite for new dispatch
        APIs
      * daemon/libvirtd.c, daemon/libvirtd.h: Remove all networking
        code
      * daemon/stream.c, daemon/stream.h: Update for new APIs
      * daemon/Makefile.am: Link to libvirt-net-rpc-server.la
      df0b57a9
    • D
      Convert the remote driver to new RPC client APIs · c1b22644
      Daniel P. Berrange 提交于
      This guts the current remote driver, removing all its networking
      handling code. Instead it calls out to the new virClientPtr and
      virClientProgramPtr APIs for all RPC & networking work.
      
      * src/Makefile.am: Link remote driver with generic RPC code
      * src/remote/remote_driver.c: Gut code, replacing with RPC
        API calls
      * src/rpc/gendispatch.pl: Update for changes in the way
        streams are handled
      c1b22644
  2. 24 6月, 2011 10 次提交
    • D
      Move the RPC generator scripts into src/rpc · b17b4afa
      Daniel P. Berrange 提交于
      Move the daemon/remote_generator.pl to src/rpc/gendispatch.pl
      and move the src/remote/rpcgen_fix.pl to src/rpc/genprotocol.pl
      
      * daemon/Makefile.am: Update for new name/location of generator
      * src/Makefile.am: Update for new name/location of generator
      b17b4afa
    • D
      Introduce generic RPC client objects · 434de30d
      Daniel P. Berrange 提交于
      To facilitate creation of new clients using XDR RPC services,
      pull alot of the remote driver code into a set of reusable
      objects.
      
       - virNetClient: Encapsulates a socket connection to a
         remote RPC server. Handles all the network I/O for
         reading/writing RPC messages. Delegates RPC encoding
         and decoding to the registered programs
      
       - virNetClientProgram: Handles processing and dispatch
         of RPC messages for a single RPC (program,version).
         A program can register to receive async events
         from a client
      
       - virNetClientStream: Handles generic I/O stream
         integration to RPC layer
      
      Each new client program now merely needs to define the list of
      RPC procedures & events it wants and their handlers. It does
      not need to deal with any of the network I/O functionality at
      all.
      434de30d
    • D
      Introduce generic RPC module for advertising via MDNS · e23ec81d
      Daniel P. Berrange 提交于
      Allow RPC servers to advertise themselves using MDNS,
      via Avahi
      
      * src/rpc/virnetserver.c, src/rpc/virnetserver.h: Allow
        registration of MDNS services via avahi
      * src/rpc/virnetserverservice.c, src/rpc/virnetserverservice.h: Add
        API to fetch the listen port number
      * src/rpc/virnetsocket.c, src/rpc/virnetsocket.h: Add API to
        fetch the local port number
      * src/rpc/virnetservermdns.c, src/rpc/virnetservermdns.h: Represent
        an MDNS advertisement
      e23ec81d
    • D
      Introduce generic RPC server objects · 4e00b1da
      Daniel P. Berrange 提交于
      To facilitate creation of new daemons providing XDR RPC services,
      pull a lot of the libvirtd daemon code into a set of reusable
      objects.
      
       * virNetServer: A server contains one or more services which
         accept incoming clients. It maintains the list of active
         clients. It has a list of RPC programs which can be used
         by clients. When clients produce a complete RPC message,
         the server passes this onto the corresponding program for
         handling, and queues any response back with the client.
      
       * virNetServerClient: Encapsulates a single client connection.
         All I/O for the client is handled, reading & writing RPC
         messages.
      
       * virNetServerProgram: Handles processing and dispatch of
         RPC method calls for a single RPC (program,version).
         Multiple programs can be registered with the server.
      
       * virNetServerService: Encapsulates socket(s) listening for
         new connections. Each service listens on a single host/port,
         but may have multiple sockets if on a dual IPv4/6 host.
      
      Each new daemon now merely has to define the list of RPC procedures
      & their handlers. It does not need to deal with any network related
      functionality at all.
      4e00b1da
    • D
      Integrate TLS/SASL directly into the socket APIs · f5fa167e
      Daniel P. Berrange 提交于
      This extends the basic virNetSocket APIs to allow them to have
      a handle to the TLS/SASL session objects, once established.
      This ensures that any data reads/writes are automagically
      passed through the TLS/SASL encryption layers if required.
      
      * src/rpc/virnetsocket.c, src/rpc/virnetsocket.h: Wire up
        SASL/TLS encryption
      f5fa167e
    • D
      Generic module for handling SASL authentication & encryption · bb1c9296
      Daniel P. Berrange 提交于
      This provides two modules for handling SASL
      
       * virNetSASLContext provides the process-wide state, currently
         just a whitelist of usernames on the server and a one time
         library init call
      
       * virNetTLSSession provides the per-connection state, ie the
         SASL session itself. This also include APIs for providing
         data encryption/decryption once the session is established
      
      * src/Makefile.am: Add to libvirt-net-rpc.la
      * src/rpc/virnetsaslcontext.c, src/rpc/virnetsaslcontext.h: Generic
        SASL handling code
      bb1c9296
    • D
      Generic module for handling TLS encryption and x509 certs · 30fd0bbb
      Daniel P. Berrange 提交于
      This provides two modules for handling TLS
      
       * virNetTLSContext provides the process-wide state, in particular
         all the x509 credentials, DH params and x509 whitelists
       * virNetTLSSession provides the per-connection state, ie the
         TLS session itself.
      
      The virNetTLSContext provides APIs for validating a TLS session's
      x509 credentials. The virNetTLSSession includes APIs for performing
      the initial TLS handshake and sending/recving encrypted data
      
      * src/Makefile.am: Add to libvirt-net-rpc.la
      * src/rpc/virnettlscontext.c, src/rpc/virnettlscontext.h: Generic
        TLS handling code
      30fd0bbb
    • D
      Introduce a generic object for using network sockets · 58b5b14e
      Daniel P. Berrange 提交于
      Introduces a simple wrapper around the raw POSIX sockets APIs
      and name resolution APIs. Allows for easy creation of client
      and server sockets with correct usage of name resolution APIs
      for protocol agnostic socket setup.
      
      It can listen for UNIX and TCP stream sockets.
      
      It can connect to UNIX, TCP streams directly, or indirectly
      to UNIX sockets via an SSH tunnel or external command
      
      * src/Makefile.am: Add to libvirt-net-rpc.la
      * src/rpc/virnetsocket.c, src/rpc/virnetsocket.h: Generic
        sockets APIs
      * tests/Makefile.am: Add socket test
      * tests/virnetsockettest.c: New test case
      * tests/testutils.c: Avoid overriding LIBVIRT_DEBUG settings
      * tests/ssh.c: Dumb helper program for SSH tunnelling tests
      58b5b14e
    • D
      Provide a simple object for encoding/decoding RPC messages · ceacc1dd
      Daniel P. Berrange 提交于
      This provides a new struct that contains a buffer for the RPC
      message header+payload, as well as a decoded copy of the message
      header. There is an API for applying a XDR encoding & decoding
      of the message headers and payloads. There are also APIs for
      maintaining a simple FIFO queue of message instances.
      
      Expected usage scenarios are:
      
      To send a message
      
         msg = virNetMessageNew()
      
         ...fill in msg->header fields..
         virNetMessageEncodeHeader(msg)
         ...loook at msg->header fields to determine payload filter
         virNetMessageEncodePayload(msg, xdrfilter, data)
         ...send msg->bufferLength worth of data from buffer
      
      To receive a message
      
         msg = virNetMessageNew()
         ...read VIR_NET_MESSAGE_LEN_MAX of data into buffer
         virNetMessageDecodeLength(msg)
         ...read msg->bufferLength-msg->bufferOffset of data into buffer
         virNetMessageDecodeHeader(msg)
         ...look at msg->header fields to determine payload filter
         virNetMessageDecodePayload(msg, xdrfilter, data)
         ...run payload processor
      
      * src/Makefile.am: Add to libvirt-net-rpc.la
      * src/rpc/virnetmessage.c, src/rpc/virnetmessage.h: Internal
        message handling API.
      * testutils.c, testutils.h: Helper for printing binary differences
      * virnetmessagetest.c: Validate all XDR encoding/decoding
      ceacc1dd
    • D
      Defines the basics of a generic RPC protocol in XDR · 980a132a
      Daniel P. Berrange 提交于
      This patch defines the basics of a generic RPC protocol in XDR.
      This is wire ABI compatible with the original remote_protocol.x.
      It takes everything except for the RPC calls / events from that
      protocol
      
       - The basic header virNetMessageHeader (aka remote_message_header)
       - The error object virNetMessageError  (aka remote_error)
       - Two dummy objects virNetMessageDomain & virNetMessageNetwork
         sadly needed to keep virNetMessageError ABI compatible with
         the old remote_error
      
      The RPC protocol supports method calls, async events and
      bidirectional data streams as before
      
      * src/Makefile.am: Add rules for generating RPC code from
        protocol & define a new libvirt-net-rpc.la helper library
      * src/rpc/virnetprotocol.x: New generic RPC protocol
      980a132a