Skip to content
Snippets Groups Projects
  1. Jan 16, 2025
  2. Dec 19, 2024
  3. Nov 18, 2024
  4. Nov 01, 2024
  5. Sep 25, 2024
  6. Sep 17, 2024
  7. Aug 05, 2024
  8. Jul 15, 2024
  9. May 15, 2024
  10. Apr 19, 2024
  11. Mar 26, 2024
    • Michal Privoznik's avatar
    • Michal Privoznik's avatar
      wrapper: Alter name of dlopen function prototypes · dbcd8207
      Michal Privoznik authored
      
      The way our wrapper code generator works is the following:
      
      1) Libvirt public API function pointer is declared, e.g.:
      
        typedef int
        (*virDomainAttachDeviceType)(virDomainPtr domain,
                                     const char *xml);
      
        where the type name is constructed as "${funcName}Type".
      
      2) A wrapper function is generated, e.g.
      
        int
        virDomainAttachDeviceWrapper(virDomainPtr domain.
                                     const char *xml,
                                     virErrorPtr err)
      
        which inside its body has a static variable:
      
        static virDomainGraphicsReloadType virDomainGraphicsReloadSymbol;
      
        which is then set to a corresponding libvirt API via dlopen().
      
      This works beautifully, except it makes an assumption about
      naming that no longer works in our favor. Specifically, another
      part of our generator that handles generating typedefs for
      function arguments (that are enums really, though uint
      officially), uses the same naming scheme:
      
        ${funcName}${argName}
      
      This is guaranteed to clash with each other when ${argName} =
      "type" (the first letter of ${argName} is capitalized to follow
      golang's naming scheme).
      
      And we can already see an example of this in our code:
      
      libvirt_generated_functions_dlopen_domain.go has:
      
        typedef int
        (*virDomainGraphicsReloadType)(virDomainPtr domain,
                                       unsigned int type,
                                       unsigned int flags);
      
      and libvirt_generated_typedefs.h has:
      
        #if !LIBVIR_CHECK_VERSION(10, 2, 0)
        typedef int virDomainGraphicsReloadType;
        #endif
      
      To make this kind of conflicts harder to hit, generate the
      function type as:
      
        ${funcName}FuncType
      
      and hope there won't be any API with 'funcType' as an argument
      any time soon.
      
      Signed-off-by: default avatarMichal Privoznik <mprivozn@redhat.com>
      dbcd8207
    • Michal Privoznik's avatar
  12. Mar 01, 2024
  13. Jan 03, 2024
  14. Nov 27, 2023
  15. Oct 25, 2023
  16. Oct 19, 2023
  17. Oct 18, 2023
    • Michal Privoznik's avatar
      docs: go fmt · 6c9bec23
      Michal Privoznik authored
      
      go fmt made some changes in doc.go.
      
      Signed-off-by: default avatarMichal Privoznik <mprivozn@redhat.com>
      6c9bec23
    • Michal Privoznik's avatar
      connect: Allow obtaining raw connect pointer · b3d06a0b
      Michal Privoznik authored
      
      I have a C library that has a function that accepts virConnectPtr
      and I want to write Golang bindings for it. For instance:
      
        struct VirtLint *virt_lint_new(virConnectPtr conn);
      
      Ideally, any consumer would use libvirt's Golang bindings to open
      the connection and then just merely pass it to my library. But
      since the raw connection pointer is not accessible outside of the
      module, it's impossible to do so.
      
      Therefore, introduce new RawPtr() function, that returns the raw
      pointer. But since this is potentially dangerous (e.g. it can
      mess up the global state we keep in @connections map) document
      the function unsafe and discourage people from using it.
      
      Signed-off-by: default avatarMichal Privoznik <mprivozn@redhat.com>
      b3d06a0b
  18. Sep 01, 2023
Loading