1. 23 4月, 2011 1 次提交
  2. 18 4月, 2011 5 次提交
    • D
      Change some variable names to follow standard in daemon dispatcher · bf4883ca
      Daniel P. Berrange 提交于
      Replace some occurrances of
      
        virDomainPtr domain;
        virNetworkPtr network;
      
      With
      
        virDomainPtr dom;
        virNetworkPtr net;
      
      * daemon/remote.c: Fix variable naming to follow standard
      bf4883ca
    • D
      Write error check conditionals in more compact form for dispatcher · 05a6283c
      Daniel P. Berrange 提交于
      Replace cases of
      
           type = virConnectGetType(conn);
           if (type == NULL)
               goto cleanup;
      
      With
      
           if (!(type = virConnectGetType(conn)))
               goto cleanup;
      
      * daemon/remote.c: Write error checks in compat form
      05a6283c
    • D
      Remove curly braces on all single-line conditional jumps in dispatcher · 55c71a26
      Daniel P. Berrange 提交于
      Replace all occurrances of
      
         if (....) {
            goto cleanup;
         }
      
      With
      
         if (.....)
            goto cleanup;
      
      to save one line of code
      
      * daemon/remote.c: Remove curly braces on single line conditionals
      55c71a26
    • D
      Fix checking of return codes in dispatcher · c19295e5
      Daniel P. Berrange 提交于
      The libvirt APIs reserve any negative value for indicating an
      error. Thus checks
      
          if (virXXXX() == -1)
      
      Should instead be
      
          if (virXXXX() < 0)
      
      * daemon/remote.c: s/ == -1/ < 0/
      c19295e5
    • D
      Merge all returns paths from dispatcher into single path · 158ba873
      Daniel P. Berrange 提交于
      The dispatcher functions have numerous places where they
      return to the caller. This leads to duplicated cleanup
      code, often resulting in memory leaks. It makes it harder
      to ensure that errors are dispatched before freeing objects,
      which may overwrite the original error.
      
      The standard pattern is now
      
          remoteDispatchXXX(...) {
              int rv = -1;
      
              ....
              if (XXX < 0)
                goto cleanup;
              ...
              if (XXXX < 0)
                goto cleanup;
              ...
      
              rv = 0;
          cleanup:
              if (rv < 0)
                 remoteDispatchError(rerr);
              ...free all other stuff..
              return rv;
          }
      
      * daemon/remote.c: Centralize all cleanup paths
      * daemon/stream.c: s/remoteDispatchConnError/remoteDispatchError/
      * daemon/dispatch.c, daemon/dispatch.h: Replace
        remoteDispatchConnError with remoteDispatchError
        removing unused virConnectPtr
      158ba873
  3. 14 4月, 2011 4 次提交
  4. 05 4月, 2011 1 次提交
  5. 29 3月, 2011 1 次提交
    • D
      Remote protocol support for storage vol upload/download APIs · 230a5d8b
      Daniel P. Berrange 提交于
      * daemon/remote.c, src/remote/remote_driver.c: Implementation
        of storage vol upload/download APIs
      * src/remote/remote_protocol.x: Wire protocol definition for
        upload/download
      * daemon/remote_dispatch_args.h, daemon/remote_dispatch_prototypes.h,
        daemon/remote_dispatch_table.h, src/remote/remote_protocol.h,
        src/remote/remote_protocol.c: Re-generate
      230a5d8b
  6. 25 3月, 2011 2 次提交
    • J
      daemon: Avoid resetting errors before they are reported · 55cc591f
      Jiri Denemark 提交于
      Commit f44bfb7f was supposed to make sure no additional libvirt API (esp.
      *Free) is called before remoteDispatchConnError() is called on error.
      However, the patch missed two instances.
      55cc591f
    • E
      command: properly diagnose process exit via signal · 208a044a
      Eric Blake 提交于
      Child processes don't always reach _exit(); if they die from a
      signal, then any messages should still be accurate.  Most users
      either expect a 0 status (thankfully, if status==0, then
      WIFEXITED(status) is true and WEXITSTATUS(status)==0 for all
      known platforms) or were filtering on WIFEXITED before printing
      a status, but a few were missing this check.  Additionally,
      nwfilter_ebiptables_driver was making an assumption that works
      on Linux (where WEXITSTATUS shifts and WTERMSIG just masks)
      but fails on other platforms (where WEXITSTATUS just masks and
      WTERMSIG shifts).
      
      * src/util/command.h (virCommandTranslateStatus): New helper.
      * src/libvirt_private.syms (command.h): Export it.
      * src/util/command.c (virCommandTranslateStatus): New function.
      (virCommandWait): Use it to also diagnose status from signals.
      * src/security/security_apparmor.c (load_profile): Likewise.
      * src/storage/storage_backend.c
      (virStorageBackendQEMUImgBackingFormat): Likewise.
      * src/util/util.c (virExecDaemonize, virRunWithHook)
      (virFileOperation, virDirCreate): Likewise.
      * daemon/remote.c (remoteDispatchAuthPolkit): Likewise.
      * src/nwfilter/nwfilter_ebiptables_driver.c (ebiptablesExecCLI):
      Likewise.
      208a044a
  7. 24 3月, 2011 1 次提交
    • J
      Make error reporting in libvirtd thread safe · f44bfb7f
      Jiri Denemark 提交于
      Bug https://bugzilla.redhat.com/show_bug.cgi?id=689374 reported libvirtd
      crash during error dispatch.
      
      The reason is that libvirtd uses remoteDispatchConnError() with non-NULL
      conn parameter which means that virConnGetLastError() is used instead of
      its thread safe replacement virGetLastError().
      
      So when several libvirtd threads are reporting errors at the same time,
      the errors can get mixed or corrupted or in case of bad luck libvirtd
      itself crashes.
      
      Since Daniel B. is going to rewrite this code from scratch on top of his
      RPC infrastructure, I tried to come up with a minimal fix. Thus,
      remoteDispatchConnError() now just ignores its conn argument and always
      calls virGetLastError(). However, several callers had to be touched as
      well, since no libvirt API is allowed to be called before dispatching
      the error. Doing so would reset the error and we would have nothing to
      dispatch. As a result of that, the code is not very nice but that
      doesn't really make daemon/remote.c worse than it is now :-) And it will
      all die soon, which is good.
      
      The bug report also contains a reproducer in C which detects both mixed
      up error messages and libvirtd crash. Before this patch, I was able to
      crash libvirtd in about 20 seconds up to 3 minutes depending on number
      of CPU cores (more is better) and luck.
      f44bfb7f
  8. 22 3月, 2011 1 次提交
    • D
      Wire up virDomainMigrateSetSpeed for the remote RPC driver · 118dd7d0
      Daniel P. Berrange 提交于
      * src/remote/remote_protocol.x: Define wire protocol
      * daemon/remote.c, src/remote/remote_driver.c: Add new
        functions for virDomainMigrateSetSpeed API
      * src/remote/remote_protocol.c, src/remote/remote_protocol.h,
        daemon/remote_dispatch_args.h, daemon/remote_dispatch_prototypes.h,
        daemon/remote_dispatch_table.h: Re-generate files
      118dd7d0
  9. 11 3月, 2011 2 次提交
  10. 21 2月, 2011 1 次提交
    • E
      maint: kill all remaining uses of old DEBUG macro · 994e7567
      Eric Blake 提交于
      Done mechanically with:
      $ git grep -l '\bDEBUG0\? *(' | xargs -L1 sed -i 's/\bDEBUG0\? *(/VIR_&/'
      
      followed by manual deletion of qemudDebug in daemon/libvirtd.c, along
      with a single 'make syntax-check' fallout in the same file, and the
      actual deletion in src/util/logging.h.
      
      * src/util/logging.h (DEBUG, DEBUG0): Delete.
      * daemon/libvirtd.h (qemudDebug): Likewise.
      * global: Change remaining clients over to VIR_DEBUG counterpart.
      994e7567
  11. 10 2月, 2011 1 次提交
    • D
      Add a little more debugging for async events · 2222bd24
      Daniel P. Berrange 提交于
      To make it easier to investigate problems with async event
      delivery, add two more debugging lines
      
      * daemon/remote.c: Debug when an event is queued for dispatch
      * src/remote/remote_driver.c: Debug when an event is received
        for processing
      2222bd24
  12. 09 2月, 2011 1 次提交
    • E
      sysinfo: implement the remote protocol · 5c8deddd
      Eric Blake 提交于
      Done by editing the first three files, then running
      'make -C src rpcgen', then editing src/remote_protocol-structs
      to match.
      
      * daemon/remote.c (remoteDispatchGetSysinfo): New function.
      * src/remote/remote_driver.c (remoteGetSysinfo, remote_driver):
      Client side serialization.
      * src/remote/remote_protocol.x (remote_get_sysinfo_args)
      (remote_get_sysinfo_ret): New types.
      (REMOTE_PROC_GET_SYSINFO): New enum value.
      * daemon/remote_dispatch_args.h: Regenerate.
      * daemon/remote_dispatch_prototypes.h: Likewise.
      * daemon/remote_dispatch_ret.h: Likewise.
      * daemon/remote_dispatch_table.h: Likewise.
      * src/remote/remote_protocol.c: Likewise.
      * src/remote/remote_protocol.h: Likewise.
      * src/remote_protocol-structs: Likewise.
      5c8deddd
  13. 29 1月, 2011 1 次提交
  14. 24 11月, 2010 1 次提交
    • O
      implement the remote protocol · 313215e1
      Osier Yang 提交于
      * daemon/remote.c
      * daemon/remote_dispatch_args.h
      * daemon/remote_dispatch_prototypes.h
      * daemon/remote_dispatch_ret.h
      * daemon/remote_dispatch_table.h
      * src/remote/remote_driver.c
      * src/remote/remote_protocol.c
      * src/remote/remote_protocol.h
      * src/remote/remote_protocol.x
      * src/remote_protocol-structs
      313215e1
  15. 12 11月, 2010 1 次提交
  16. 03 11月, 2010 1 次提交
    • J
      Fix build with polkit 0 · 98b8424e
      Jim Fehlig 提交于
      Commit e8066d53 broke the build with polkit0:
      
      remote.c: In function 'remoteDispatchAuthPolkit':
      remote.c:4177: error: 'rv' undeclared (first use in this function)
      
      Add missing identifier.
      98b8424e
  17. 28 10月, 2010 1 次提交
  18. 26 10月, 2010 1 次提交
    • M
      Fix build for SystemTap 1.0 · cbe719fe
      Matthias Bolte 提交于
      With SystemTap 1.0 a part of the generated macros in probes.h
      expands to:
      
      volatile __typeof__(((name))) arg2 = (name);
      
      GCC reports an 'invalid initialize' error when name has type
      char[]. Therfore, add casts to char* to avoid this.
      cbe719fe
  19. 22 10月, 2010 4 次提交
    • D
      Include socket address in client probe data · 4b16b9c7
      Daniel P. Berrange 提交于
      It is useful to know where the client is connecting from,
      so include the socket address in probe data.
      
      * daemon/libvirtd.h: Use virSocketAddr for storing client
        address and keep printable address handy for logging
      * daemon/libvirtd.c: Include socket address in client
        connect/disconnect probes
      * daemon/probes.d: Add socket address to probes
      * examples/systemtap/client.stp: Print socket address
      * src/util/network.h: Add sockaddr_un to virSocketAddr union
      4b16b9c7
    • D
      Add dtrace static probes in libvirtd · 968eb4e5
      Daniel P. Berrange 提交于
      Adds initial support for dtrace static probes in libvirtd
      daemon, assuming use of systemtap dtrace compat shim on
      Linux. The probes are inserted for network client connect,
      disconnect, TLS handshake states and authentication protocol
      states.
      
      This can be tested by running the xample program and then
      attempting to connect with any libvirt client (virsh,
      virt-manager, etc).
      
       # stap examples/systemtap/client.stp
        Client fd=44 connected readonly=0
        Client fd=44 auth polkit deny pid:24997,uid:500
        Client fd=44 disconnected
        Client fd=46 connected readonly=1
        Client fd=46 auth sasl allow test
        Client fd=46 disconnected
      
      The libvirtd.stp file should also really not be required,
      since it is duplicated info that is already available in
      the main probes.d definition file. A script to autogenerate
      the .stp file is needed, either in libvirtd tree, or better
      as part of systemtap itself.
      
      * Makefile.am: Add examples/systemtap subdir
      * autobuild.sh: Disable dtrace for mingw32
      * configure.ac: Add check for dtrace
      * daemon/.gitignore: Ignore generated dtrace probe file
      * daemon/Makefile.am: Build dtrace probe header & object
        files
      * daemon/libvirtd.stp: SystemTAP convenience probeset
      * daemon/libvirtd.c: Add connect/disconnect & TLS probes
      * daemon/remote.c: Add SASL and PolicyKit auth probes
      * daemon/probes.d: Master probe definition
      * daemon/libvirtd.h: Add convenience macro for probes
        so that compilation is a no-op when dtrace is not available
      * examples/systemtap/Makefile.am, examples/systemtap/client.stp
        Example systemtap script using dtrace probe markers
      * libvirt.spec.in: Enable dtrace on F13/RHEL6
      * mingw32-libvirt.spec.in: Force disable dtrace
      968eb4e5
    • D
      Remove both addrToString methods · 640c5f19
      Daniel P. Berrange 提交于
      The addrToString functionality is now available via the
      virSocketFormatAddrFull method.
      
      * daemon/remote.c, src/remote/remote_driver.c: Remove
        addrToString methods
      640c5f19
    • D
      Remove useless code in error path of getnameinfo() · 9e42b40a
      Daniel P. Berrange 提交于
      If getnameinfo() with NI_NUMERICHOST set fails, there are no
      grounds to expect inet_ntop to succeed, since these calls
      are functionally equivalent. Remove useless inet_ntop code
      in the getnameinfo() error path.
      
      * daemon/remote.c, src/remote/remote_driver.c: Remove
        calls to inet_ntop
      9e42b40a
  20. 20 10月, 2010 3 次提交
    • M
      83e57114
    • M
      Audit VM start/stop/suspend/resume · a8b5f9bd
      Miloslav Trmač 提交于
      Most operations are audited at the libvirtd level; auditing in
      src/libvirt.c would result in two audit entries per operation (one in
      the client, one in libvirtd).
      
      The only exception is a domain stopping of its own will (e.g. because
      the user clicks on "shutdown" inside the interface).  There can often be
      no client connected at the time the domain stops, so libvirtd does not
      have any virConnectPtr object on which to attach an event watch.  This
      patch therefore adds auditing directly inside the qemu driver (other
      drivers are not supported).
      a8b5f9bd
    • E
      vcpu: implement the remote protocol · eb826444
      Eric Blake 提交于
      Done by editing the first three files, then running
      'make -C src rpcgen', then editing src/remote_protocol-structs
      to match.
      
      * daemon/remote.c (remoteDispatchDomainSetVcpusFlags)
      (remoteDispatchDomainGetVcpusFlags): New functions.
      * src/remote/remote_driver.c (remoteDomainSetVcpusFlags)
      (remoteDomainGetVcpusFlags, remote_driver): Client side
      serialization.
      * src/remote/remote_protocol.x
      (remote_domain_set_vcpus_flags_args)
      (remote_domain_get_vcpus_flags_args)
      (remote_domain_get_vcpus_flags_ret)
      (REMOTE_PROC_DOMAIN_SET_VCPUS_FLAGS)
      (REMOTE_PROC_DOMAIN_GET_VCPUS_FLAGS): Define wire format.
      * daemon/remote_dispatch_args.h: Regenerate.
      * daemon/remote_dispatch_prototypes.h: Likewise.
      * daemon/remote_dispatch_table.h: Likewise.
      * src/remote/remote_protocol.c: Likewise.
      * src/remote/remote_protocol.h: Likewise.
      * src/remote_protocol-structs: Likewise.
      eb826444
  21. 13 10月, 2010 1 次提交
  22. 23 9月, 2010 2 次提交
    • D
      Make SASL work over UNIX domain sockets · 3a73eaeb
      Daniel P. Berrange 提交于
      The addrToString methods were not coping with UNIX domain sockets
      which have no normal host+port address. Hardcode special handling
      for these so that SASL routines can work over UNIX sockets. Also
      fix up SSF logic in remote client so that it presumes that a UNIX
      socket is secure
      
      * daemon/remote.c: Fix addrToString for UNIX sockets.
      * src/remote/remote_driver.c: Fix addrToString for UNIX sockets
        and fix SSF logic to work for TLS + UNIX sockets in the same
        manner
      3a73eaeb
    • D
      Refactor some daemon code to facilitate introduction of static probes · e8066d53
      Daniel P. Berrange 提交于
      Refactor some daemon code to facilitate the introductioin of static
      probes, sanitizing function exit paths in many places
      
      * daemon/libvirtd.c: Pass the dname string into remoteCheckDN
        to let caller deal with failure paths. Add separate exit paths
        to remoteCheckCertificate for auth failure vs denial. Merge
        all exit paths in qemudDispatchServer to one cleanup block
      * daemon/remote.c: Add separate exit paths to SASL & PolicyKit
        functions for auth failure vs denial
      e8066d53
  23. 24 7月, 2010 1 次提交
    • C
      Qemu remote protocol. · 337d201e
      Chris Lalancette 提交于
      Since we are adding a new "per-hypervisor" protocol, we
      make it so that the qemu remote protocol uses a new
      PROTOCOL and PROGRAM number.  This allows us to easily
      distinguish it from the normal REMOTE protocol.
      
      This necessitates changing the proc in remote_message_header
      from a "remote_procedure" to an "unsigned", which should
      be the same size (and thus preserve the on-wire protocol).
      
      Changes since v1:
       - Fixed up a couple of script problems in remote_generate_stubs.pl
       - Switch an int flag to a bool in dispatch.c
      
      Changes since v2:
       - None
      
      Changes since v3:
       - Change unsigned proc to signed proc, to conform to spec
      Signed-off-by: NChris Lalancette <clalance@redhat.com>
      337d201e
  24. 26 6月, 2010 1 次提交
  25. 17 6月, 2010 1 次提交
    • M
      Add several missing vir*Free calls in libvirtd's remote code · 08d42b52
      Matthias Bolte 提交于
      Justin Clift reported a problem with adding virStoragePoolIsPersistent
      to virsh's pool-info command, resulting in a strange problem. Here's
      an example:
      
          virsh # pool-create-as images_dir3 dir - - - - "/home/images2"
          Pool images_dir3 created
      
          virsh # pool-info images_dir3
          Name:           images_dir3
          UUID:           90301885-94eb-4ca7-14c2-f30b25a29a36
          State:          running
          Capacity:       395.20 GB
          Allocation:     30.88 GB
          Available:      364.33 GB
      
          virsh # pool-destroy images_dir3
          Pool images_dir3 destroyed
      
      At this point the images_dir3 pool should be gone (because it was
      transient) and we should be able to create a new pool with the same name:
      
          virsh # pool-create-as images_dir3 dir - - - - "/home/images2"
          Pool images_dir3 created
      
          virsh # pool-info images_dir3
          Name:           images_dir3
          UUID:           90301885-94eb-4ca7-14c2-f30b25a29a36
          error: Storage pool not found
      
      The new pool got the same UUID as the first one, but we didn't specify
      one. libvirt should have picked a random UUID, but it didn't.
      
      It turned out that virStoragePoolIsPersistent leaks a reference to the
      storage pool object (actually remoteDispatchStoragePoolIsPersistent does).
      As a result, pool-destroy doesn't remove the virStoragePool for the
      "images_dir3" pool from the virConnectPtr's storagePools hash on libvirtd's
      side. Then the second pool-create-as get's the stale virStoragePool object
      associated with the "images_dir3" name. But this object has the old UUID.
      
      This commit ensures that all get_nonnull_* and make_nonnull_* calls for
      libvirt objects are matched properly with vir*Free calls. This fixes the
      reference leaks and the reported problem.
      
      All remoteDispatch*IsActive and remoteDispatch*IsPersistent functions were
      affected. But also remoteDispatchDomainMigrateFinish2 was affected in the
      success path. I wonder why that didn't surface earlier. Probably because
      domainMigrateFinish2 is executed on the destination host and in the common
      case this connection is opened especially for the migration and gets closed
      after the migration is done. So there was no chance to run into a problem
      because of the leaked reference.
      08d42b52