Giter Club home page Giter Club logo

Comments (1)

sihensel avatar sihensel commented on August 25, 2024

@CarstenLeue we stumbled over the same question.
NeedResults specifies whether the method should return the actual result list or not and is used as a boolean flag.

This behavior is implemented in libvirt here: https://github.com/libvirt/libvirt/blob/40ebade891a0d2c08e82dac126822d5ee57f4281/src/rpc/gendispatch.pl#L994
If need_results is set (i.e. contains any non-zero value) the result list will be returned, otherwise the return value is NULL.

Furthermore, most methods that fetch data from libvirt take a pointer to a data buffer as input. If the pointer is valid (i.e. not NULL), need_results will be set to 1:
https://github.com/libvirt/libvirt/blob/40ebade891a0d2c08e82dac126822d5ee57f4281/src/rpc/gendispatch.pl#L1729
Sidenote: !! converts any non-zero value to 1 while making sure that 0 remains 0.

This behavior is also documented in the docs, e.g. for virConnectListAllDomains:
https://libvirt.org/html/libvirt-libvirt-domain.html#virConnectListAllDomains
Note the description of the domains parameter:

Pointer to a variable to store the array containing domain objects or NULL if the list is not required (just returns number of guests).

Go-libvirt emulates this behavior and returns an empty list if NeedResults is set to 0, while returning the actual objects if it is set to 1.
This could have been mentioned in the docs here somewhere though.

from go-libvirt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.