• P
    lib: Add public api to enable atomic listing of guest · 747f64ee
    Peter Krempa 提交于
    This patch adds a new public api that lists domains. The new approach is
    different from those used before. There are key points to this:
    
    1) The list is acquired atomically and contains both active and inactive
    domains (guests). This eliminates the need to call two different list
    APIs, where the state might change in between the calls.
    
    2) The returned list consists of virDomainPtrs instead of names or ID's
    that have to be converted to virDomainPtrs anyways using separate calls
    for each one of them. This is more convenient and saves hypervisor calls.
    
    3) The returned list is auto-allocated. This saves a lot of hassle for
    the users.
    
    4) Built in support for filtering. The API call supports various
    filtering flags that modify the output list according to user needs.
    
    Available filter groups:
        Domain status:
        VIR_CONNECT_LIST_DOMAINS_ACTIVE, VIR_CONNECT_LIST_DOMAINS_INACTIVE
    
        Domain persistence:
        VIR_CONNECT_LIST_DOMAINS_PERSISTENT,
        VIR_CONNECT_LIST_DOMAINS_TRANSIENT
    
        Domain state:
        VIR_CONNECT_LIST_DOMAINS_RUNNING, VIR_CONNECT_LIST_DOMAINS_PAUSED,
        VIR_CONNECT_LIST_DOMAINS_SHUTOFF, VIR_CONNECT_LIST_DOMAINS_OTHER
    
        Existence of managed save image:
        VIR_CONNECT_LIST_DOMAINS_MANAGEDSAVE,
        VIR_CONNECT_LIST_DOMAINS_NO_MANAGEDSAVE
    
        Auto-start option:
        VIR_CONNECT_LIST_DOMAINS_AUTOSTART,
        VIR_CONNECT_LIST_DOMAINS_NO_AUTOSTART
    
        Existence of snapshot:
        VIR_CONNECT_LIST_DOMAINS_HAS_SNAPSHOT,
        VIR_CONNECT_LIST_DOMAINS_NO_SNAPSHOT
    
    5) The python binding returns a list of domain objects that is very neat
    to work with.
    
    The only problem with this approach is no support from code generators
    so both RPC code and python bindings had to be written manually.
    
    *include/libvirt/libvirt.h.in: - add API prototype
                                   - clean up whitespace mistakes nearby
    *python/generator.py: - inhibit generation of the bindings for the new
                            api
    *src/driver.h: - add driver prototype
                   - clean up some whitespace mistakes nearby
    *src/libvirt.c: - add public implementation
    *src/libvirt_public.syms: - export the new symbol
    747f64ee
driver.h 63.8 KB