1. 11 7月, 2017 1 次提交
    • D
      rpc: improve error message for bounds check · c8fb3c31
      Daniel P. Berrange 提交于
      If we exceed a fixed limit in RPC code we get a horrible message
      like this, if the parameter type is a 'string', because we forgot
      to initialize the error message type field:
      
        $ virsh snapshot-list ostack1
        error: too many remote undefineds: 1329 > 1024
      
      It would also be useful to know which RPC call and field was
      exceeded. So this patch makes us report:
      
        $ virsh snapshot-list ostack1
        error: too many remote undefineds: 1329 > 1024,
        in parameter 'names' for 'virDomainSnapshotListNames'
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      c8fb3c31
  2. 18 5月, 2017 3 次提交
    • M
      gendispatch: Introduce @sparseflag for our calls · 8f08f28f
      Michal Privoznik 提交于
      Now, not all APIs are going to support sparse streams. To some it
      makes no sense at all, e.g. virDomainOpenConsole() or
      virDomainOpenChannel(). To others, we will need a special flag to
      indicate that client wants to enable sparse streams. Instead of
      having to write RPC dispatchers by hand we can just annotate in
      our .x files that a certain flag to certain RPC call enables this
      feature. For instance:
      
           /**
            * @generate: both
            * @ReadStream: 1
            * @sparseflag: VIR_SPARSE_STREAM
            * @acl: storage_vol:data_read
            */
           REMOTE_PROC_DOMAIN_SOME_API = XXX,
      
      Therefore, whenever client calls virDomainSomeAPI(..,
      VIR_SPARSE_STREAM); daemon will mark that down and send stream
      skips when possible.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      8f08f28f
    • M
      Add new flag to daemonCreateClientStream and virNetClientStreamNew · 5f4f9d87
      Michal Privoznik 提交于
      Add a new argument to daemonCreateClientStream in order to allow for
      future expansion to mark that a specific stream can be used to skip
      data, such as the case with sparsely populated files. The new flag will
      be the eventual decision point between client/server to decide whether
      both ends can support and want to use sparse streams.
      
      A new bool 'allowSkip' is added to both _virNetClientStream and
      daemonClientStream in order to perform the tracking.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      5f4f9d87
    • M
      virNetClientStreamNew: Track origin stream · 8b6ffe40
      Michal Privoznik 提交于
      Add a virStreamPtr pointer to the _virNetClientStream
      in order to reverse track the parent stream.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      8b6ffe40
  3. 22 6月, 2016 1 次提交
  4. 03 5月, 2016 1 次提交
  5. 24 3月, 2016 1 次提交
    • M
      gendispatch: Avoid comparing signed and unsigned vars · 9b48ef9c
      Michal Privoznik 提交于
      The adminDispatchConnectListServers() function is generated by
      our great perl script. However, it has a tiny flaw: if
      adminConnectListServers() it calls fails, the control jumps onto
      cleanup label where we try to free any list of servers built so
      far. However, in the loop @i is unsigned (size_t) while @nresults
      is signed (int). Currently, it does no harm because of the check
      for @result being non-NULL. But if that ever changes in the
      future, this bug will be hard to chase.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      9b48ef9c
  6. 11 3月, 2016 6 次提交
  7. 08 2月, 2016 1 次提交
  8. 03 2月, 2016 3 次提交
    • E
      util: Export remoteSerializeTypedParameters internally via util · 8cd1d546
      Erik Skultety 提交于
      Same as for deserializer, this method might get handy for admin one day.
      The major reason for this patch is to stay consistent with idea, i.e.
      when deserializer can be shared, why not serializer as well. The only
      problem to be solved was that the daemon side serializer uses a code
      snippet which handles sparse arrays returned by some APIs as well as
      removes any string parameters that can't be returned to older clients.
      This patch makes of the new virTypedParameterRemote datatype introduced
      by one of the pvious patches.
      8cd1d546
    • E
      util: Export remoteFreeTypedParameters internally via util · 9afc115f
      Erik Skultety 提交于
      Since the method is static to remote_driver, it can't even be used by our
      daemon. Other than that, it would be useful to be able to use it with admin as
      well. This patch uses the new virTypedParameterRemote datatype introduced in
      one of previous patches.
      9afc115f
    • E
      util: Export remoteDeserializeTypedParameters internally via util · 0472cef6
      Erik Skultety 提交于
      Currently, the deserializer is hardcoded into remote_driver which makes
      it impossible for admin to use it. One way to achieve a shared implementation
      (besides moving the code to another module) would be pass @ret_params_val as a
      void pointer as opposed to the remote_typed_param pointer and add a new extra
      argument specifying which of those two protocols is being used and typecast
      the pointer at the function entry. An example from remote_protocol:
      
      struct remote_typed_param_value {
              int type;
              union {
                      int i;
                      u_int ui;
                      int64_t l;
                      uint64_t ul;
                      double d;
                      int b;
                      remote_nonnull_string s;
              } remote_typed_param_value_u;
      };
      typedef struct remote_typed_param_value remote_typed_param_value;
      
      struct remote_typed_param {
              remote_nonnull_string field;
              remote_typed_param_value value;
      };
      
      That would leave us with a bunch of if-then-elses that needed to be used across
      the method. This patch takes the other approach using the new datatype
      introduced in one of earlier commits.
      0472cef6
  9. 29 1月, 2016 1 次提交
  10. 21 12月, 2015 1 次提交
    • E
      Revert "admin: Rename virAdmConnect to virAdmDaemon" · 3245e178
      Erik Skultety 提交于
      Commmit df8192aa introduced admin related rename and some minor
      (caused by automated approach, aka sed) and some more severe isues along with
      it. First reason to revert is the inconsistency with libvirt library.
      Although we deal with the daemon directly rather than with a specific
      hypervisor, we still do have a connection. That being said, contributors might
      get under the impression that AdmDaemonNew would spawn/start a new daemon
      (since it's admin API, why not...), or AdmDaemonClose would do the exact
      opposite or they might expect DaemonIsAlive report overall status of the daemon
      which definitely isn't the case.
      The second reason to revert this patch is renaming virt-admin client. The
      client tool does not necessarily have to reflect the names of the API's it's
      using in his internals. An example would be 's/vshAdmConnect/vshAdmDaemon'
      where noone can be certain of what the latter function really does. The former
      is quite expressive about some connection magic it performs, but the latter does
      not say anything, especially when vshAdmReconnect and vshAdmDisconnect were
      left untouched.
      3245e178
  11. 01 12月, 2015 1 次提交
    • M
      admin: Rename virAdmConnect to virAdmDaemon · df8192aa
      Martin Kletzander 提交于
      virAdmConnect was named after virConnect, but after some discussions,
      most of the APIs called will be working with remote daemon and starting
      them virAdmDaemon will make more sense.  Only possibly controversal name
      is CloseCallback (de)registration, and connecting to the daemon (which
      will still be Open/Close), but even this makes sense if one thinks about
      the daemon being opened and closed, e.g. as file, etc.
      
      This way all the APIs working with the daemon will start with
      virAdmDaemon prefix, they will accept virAdmDaemonPtr as first parameter
      and that will better suit with other namings as well (virDomain*,
      virAdmServer*, etc.).
      
      Because in virt-admin, the connection name does not refer to a struct
      that would have a connect in its name, also adjust 'connname' in
      clients.  And because it is not used anywhere in the vsh code, move it
      from there into each client.
      Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
      df8192aa
  12. 30 11月, 2015 1 次提交
    • E
      admin: Introduce virAdmConnectGetLibVersion · a474371f
      Erik Skultety 提交于
      Introduce a new API to get libvirt version. It is worth noting, that
      libvirt-admin and libvirt share the same version number. Unfortunately,
      our existing API isn't generic enough to be used with virAdmConnectPtr
      as well. Also this patch wires up this API to the virt-admin client
      as a generic cmdVersion command.
      a474371f
  13. 16 6月, 2015 1 次提交
  14. 14 5月, 2015 1 次提交
  15. 26 3月, 2015 1 次提交
  16. 25 3月, 2015 1 次提交
  17. 12 3月, 2015 1 次提交
  18. 06 3月, 2015 1 次提交
  19. 03 12月, 2014 1 次提交
  20. 24 11月, 2014 1 次提交
  21. 07 11月, 2014 1 次提交
  22. 26 8月, 2014 1 次提交
    • E
      maint: drop spurious semicolons · 28de556d
      Eric Blake 提交于
      I noticed a line 'int nparams = 0;;' in remote_dispatch.h, and
      tracked down where it was generated.  While at it, I found a
      couple of other double semicolons.  Additionally, I noticed that
      commit df0b57a9 left a stale reference to the file name
      remote_dispatch_bodies.h.
      
      * src/conf/numatune_conf.c (virDomainNumatuneNodeParseXML): Drop
      empty statement.
      * tests/virdbustest.c (testMessageStruct, testMessageSimple):
      Likewise.
      * src/rpc/gendispatch.pl (remote_dispatch_bodies.h): Likewise, and
      update stale comments.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      28de556d
  23. 24 6月, 2014 1 次提交
    • N
      net-dhcp-leases: Implement the remote protocol · 990c3b65
      Nehal J Wani 提交于
      Implement RPC calls for virNetworkGetDHCPLeases, virNetworkGetDHCPLeasesForMAC
      
      daemon/remote.c
         * Define remoteSerializeNetworkDHCPLeases,
                  remoteDispatchNetworkGetDHCPLeases
         * Define remoteDispatchNetworkGetDHCPLeasesForMAC
         * Define helper function remoteSerializeDHCPLease
      
      src/remote/remote_driver.c
         * Define remoteNetworkGetDHCPLeases
         * Define remoteNetworkGetDHCPLeasesForMAC
         * Define helper function remoteSerializeDHCPLease
      
      src/remote/remote_protocol.x
         * New RPC procedure: REMOTE_PROC_NETWORK_GET_DHCP_LEASES
         * Define structs remote_network_dhcp_leases, remote_network_get_dhcp_leases_args,
                          remote_network_get_dhcp_leases_ret
         * New RPC procedure: REMOTE_PROC_NETWORK_GET_DHCP_LEASES_FOR_MAC
         * Define structs remote_network_dhcp_leases_for_mac, remote_network_get_dhcp_leases_for_mac_args,
                          remote_network_get_dhcp_leases_for_mac_ret
      
      src/remote_protocol-structs
         * New structs added
      
      src/rpc/gendispatch.pl
         * Add exception (s/Dhcp/DHCP) for auto-generating names of the remote functions
           in daemon/remote_dispatch.h
      990c3b65
  24. 07 5月, 2014 1 次提交
  25. 21 3月, 2014 1 次提交
    • E
      qemu: wire up RPC for qemu monitor events · e7708a1c
      Eric Blake 提交于
      These are the first async events in the qemu protocol, so this
      patch looks rather big compared to most RPC additions.  However,
      a large majority of this patch is just mechanical copy-and-paste
      from recently-added network events.  It didn't help that this
      is also the first virConnect rather than virDomain prefix
      associated with a qemu-specific API.
      
      * src/remote/qemu_protocol.x (qemu_*_domain_monitor_event_*): New
      structs and RPC messages.
      * src/rpc/gendispatch.pl: Adjust naming conventions.
      * daemon/libvirtd.h (daemonClientPrivate): Track qemu events.
      * daemon/remote.c (remoteClientFreeFunc): Likewise.
      (remoteRelayDomainQemuMonitorEvent)
      (qemuDispatchConnectDomainMonitorEventRegister)
      (qemuDispatchConnectDomainMonitorEventDeregister): New functions.
      * src/remote/remote_driver.c (qemuEvents): Handle qemu events.
      (doRemoteOpen): Register for events.
      (remoteNetworkBuildEventLifecycle)
      (remoteConnectDomainQemuMonitorEventRegister)
      (remoteConnectDomainQemuMonitorEventDeregister): New functions.
      * src/qemu_protocol-structs: Regenerate.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      e7708a1c
  26. 10 8月, 2013 1 次提交
  27. 08 8月, 2013 1 次提交
    • D
      Add info about access control checks into API reference · 664ab280
      Daniel P. Berrange 提交于
      So that app developers / admins know what access control checks
      are performed for each API, this patch extends the API docs
      generator to include details of the ACLs for each.
      
      The gendispatch.pl script is extended so that it generates
      a simple XML describing ACL rules, eg.
      
        <aclinfo>
          ...
          <api name='virConnectNumOfDomains'>
            <check object='connect' perm='search_domains'/>
            <filter object='domain' perm='getattr'/>
          </api>
          <api name='virDomainAttachDeviceFlags'>
            <check object='domain' perm='write'/>
            <check object='domain' perm='save' flags='!VIR_DOMAIN_AFFECT_CONFIG|VIR_DOMAIN_AFFECT_LIVE'/>
            <check object='domain' perm='save' flags='VIR_DOMAIN_AFFECT_CONFIG'/>
          </api>
          ...
        </aclinfo>
      
      The newapi.xsl template loads the XML files containing the ACL
      rules and generates a short block of HTML for each API describing
      the parameter checks and return value filters (if any).
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      664ab280
  28. 11 7月, 2013 1 次提交
  29. 10 7月, 2013 1 次提交
  30. 03 7月, 2013 1 次提交
  31. 24 6月, 2013 1 次提交
    • D
      Auto-generate helpers for checking access control rules · 68602622
      Daniel P. Berrange 提交于
      Extend the 'gendispatch.pl' script to be able to generate
      three new types of file.
      
      - 'aclheader' - defines signatures of helper APIs for
        doing authorization checks. There is one helper API
        for each API requiring an auth check. Any @acl
        annotations result in a method being generated with
        a suffix of 'EnsureACL'. If the ACL check requires
        examination of flags, an extra 'flags' param will be
        present. Some examples
      
        extern int virConnectBaselineCPUEnsureACL(void);
        extern int virConnectDomainEventDeregisterEnsureACL(virDomainDefPtr domain);
        extern int virDomainAttachDeviceFlagsEnsureACL(virDomainDefPtr domain, unsigned int flags);
      
        Any @aclfilter annotations resuilt in a method being
        generated with a suffix of 'CheckACL'.
      
        extern int virConnectListAllDomainsCheckACL(virDomainDefPtr domain);
      
        These are used for filtering individual objects from APIs
        which return a list of objects
      
      - 'aclbody' - defines the actual implementation of the
        methods described above. This calls into the access
        manager APIs. A complex example:
      
          /* Returns: -1 on error (denied==error), 0 on allowed */
          int virDomainAttachDeviceFlagsEnsureACL(virConnectPtr conn,
                                                  virDomainDefPtr domain,
                                                  unsigned int flags)
          {
              virAccessManagerPtr mgr;
              int rv;
      
              if (!(mgr = virAccessManagerGetDefault()))
                  return -1;
      
              if ((rv = virAccessManagerCheckDomain(mgr,
                                                    conn->driver->name,
                                                    domain,
                                                    VIR_ACCESS_PERM_DOMAIN_WRITE)) <= 0) {
                  virObjectUnref(mgr);
                  if (rv == 0)
                      virReportError(VIR_ERR_ACCESS_DENIED, NULL);
                  return -1;
              }
              if (((flags & (VIR_DOMAIN_AFFECT_CONFIG|VIR_DOMAIN_AFFECT_LIVE)) == 0) &&
                  (rv = virAccessManagerCheckDomain(mgr,
                                                    conn->driver->name,
                                                    domain,
                                                    VIR_ACCESS_PERM_DOMAIN_SAVE)) <= 0) {
                  virObjectUnref(mgr);
                  if (rv == 0)
                      virReportError(VIR_ERR_ACCESS_DENIED, NULL);
                  return -1;
              }
              if (((flags & (VIR_DOMAIN_AFFECT_CONFIG)) == (VIR_DOMAIN_AFFECT_CONFIG)) &&
                  (rv = virAccessManagerCheckDomain(mgr,
                                                    conn->driver->name,
                                                    domain,
                                                    VIR_ACCESS_PERM_DOMAIN_SAVE)) <= 0) {
                  virObjectUnref(mgr);
                  if (rv == 0)
                      virReportError(VIR_ERR_ACCESS_DENIED, NULL);
                  return -1;
              }
              virObjectUnref(mgr);
              return 0;
          }
      
      - 'aclsyms' - generates a linker script to export the
         APIs to drivers. Some examples
      
        virConnectBaselineCPUEnsureACL;
        virConnectCompareCPUEnsureACL;
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      68602622