Re: RFC [2/3]: The lock manager plugin driver API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



typedef struct _virLockManagerDriver virLockManagerDriver;
typedef virLockManagerDriver *virLockManagerDriverPtr;

/* Which callbacks are supported */
typedef enum {
    VIR_LOCK_MANAGER_DRIVER_RESOURCES = (1 << 0),
    VIR_LOCK_MANAGER_DRIVER_MIGRATE   = (1 << 0),
    VIR_LOCK_MANAGER_DRIVER_HOTPLUG   = (1 << 1),
};

struct _virLockManagerDriver {
    /**
     * @version: the newest implemented plugin ABI version
     * @flags: the implemented plugin optional extras
     */
    unsigned int version;
    unsigned int flags;

    /**
     * load_drv:
     * @version: the libvirt requested plugin ABI version
     * @flags: the libvirt requested plugin optional extras
     *
     * Allow the plugin to validate the libvirt requested
     * plugin version / flags. This allows it to reject
     * use of versions which are too old. A plugin may
     * be loaded multiple times, for different libvirt
     * drivers
     *
     * Returns -1 if the requested version/flags were inadequate
     */
    int (*load_drv)(unsigned int version,
                    unsigned int flags);

    /**
     * unload_drv:
     *
     * Called to release any resources prior to the plugin
     * being unloaded from memory. Returns -1 to prevent
     * plugin unloading.
     */
    int (*load_drv)(void);

    /* Mandatory callbacks */
    virLockManagerPtr (*new_drv)(unsigned int type,
                                 unsigned int flags);

    int (*set_parameter_drv)(virLockManagerPtr man,
                             const char *key,
                             const char *value);

    char *(*get_supervisor_path_drv)(virLockManagerPtr man);
    char *(*get_supervisor_context_drv)(virLockManagerPtr man);
    int (*get_supervisor_args_drv)(virLockManagerPtr man,
                                   char ***argv,
                                   int *argc,
                                   unsigned int flags);

    int (*connect_drv)(virLockManagerPtr man,
                       unsigned int flags);
    int (*startup_drv)(virLockManagerPtr man,
                       pid_t *pid,
                       unsigned int flags);
    int (*shutdown_drv)(virLockManagerPtr man,
                        unsigned int flags);
    void (*free_drv)(virLockManagerPtr man);
    /* End of mandatory callbacks */


    /* Only if VIR_LOCK_MANAGER_DRIVER_RESOURCES */
    int (*set_file_drv)(virLockManagerPtr man,
                        const char *file,
                        unsigned int flags);


    /* Only if VIR_LOCK_MANAGER_DRIVER_HOTPLUG */
    int (*add_file_drv)(virLockManagerPtr man,
                        const char *file,
                        unsigned int flags);
    int (*remove_file_drv)(virLockManagerPtr man,
                           const char *file,
                           unsigned int flags);


    /* Only if VIR_LOCK_MANAGER_DRIVER_MIGRATE */
    int (*prepare_migrate_drv)(virLockManagerPtr man,
                               const gchar *targetURI,
                               unsigned int flags);
    int (*complete_migrate_out_drv)(virLockManagerPtr man,
                                    const gchar *targetURI,
                                    unsigned int flags);
    int (*complete_migrate_in_drv)(virLockManagerPtr man,
                                   const gchar *sourceURI,
                                   unsigned int flags);

};

/**
 * virLockManagerPluginDriver:
 *
 * The signature of the function for obtaining a lock manager
 * driver from a dlopen()d plugin module. The plugin must contain
 * a symbol called "plugin_init" with this signature
 */
typedef virLockManagerDriverPtr (*virLockManagerPluginDriver)(void);

/**
 * virLockManagerPluginLoad:
 * @name: the name of the plugin
 *
 * Attempt to load the plugin $(libdir)/libvirt/lock-manager/@name.so
 * The plugin driver entry point will be resolved & invoked to obtain
 * the lock manager driver
 */
virLockManagerPluginPtr virLockManagerPluginLoad(const char *name);
int virLockManagerPluginUnload(virLockManagerPluginPtr);

-- 
|: Red Hat, Engineering, London    -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org        -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]