Re: [PATCH 07/36] virclosecallbacks: Add new close callbacks APIs

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

 



On Thu, Jan 05, 2023 at 05:29:56PM +0100, Peter Krempa wrote:
> The new APIs store the list of callbacks for a VM inside the
> virDomainObj and also allow registering multiple callbacks for a single
> domain and also for multiple connections.
> 
> For now this code is dormant until each driver using the old APIs is not
> refactored to use the new APIs.
> 
> Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
> ---
>  src/hypervisor/virclosecallbacks.c | 336 +++++++++++++++++++++++++++++
>  src/hypervisor/virclosecallbacks.h |  24 +++
>  src/libvirt_private.syms           |   5 +
>  3 files changed, 365 insertions(+)
> 
> diff --git a/src/hypervisor/virclosecallbacks.c b/src/hypervisor/virclosecallbacks.c
> index a08464438a..21b97cce12 100644
> --- a/src/hypervisor/virclosecallbacks.c
> +++ b/src/hypervisor/virclosecallbacks.c
> @@ -310,3 +310,339 @@ virCloseCallbacksRun(virCloseCallbacks *closeCallbacks,
>      VIR_FREE(list->entries);
>      VIR_FREE(list);
>  }
> +
> +
> +struct _virCloseCallbacksDomainData {
> +    virConnectPtr conn;
> +    virCloseCallback cb;
> +};
> +typedef struct _virCloseCallbacksDomainData virCloseCallbacksDomainData;
> +
> +
> +static void
> +virCloseCallbacksDomainDataFree(virCloseCallbacksDomainData* data)
> +{
> +    g_free(data);
> +}
> +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virCloseCallbacksDomainData, virCloseCallbacksDomainDataFree);
> +
> +
> +virClass *virCloseCallbacksDomainListClass;
> +
> +struct _virCloseCallbacksDomainList {
> +    virObjectLockable parent;
> +
> +    GList *callbacks;
> +};
> +typedef struct _virCloseCallbacksDomainList virCloseCallbacksDomainList;
> +
> +
> +static void
> +virCloseCallbacksDomainListDispose(void *obj G_GNUC_UNUSED)
> +{
> +    virCloseCallbacksDomainList *cc = obj;
> +
> +    g_list_free_full(cc->callbacks, (GDestroyNotify) virCloseCallbacksDomainDataFree);
> +}
> +
> +
> +static int
> +virCloseCallbacksDomainListOnceInit(void)
> +{
> +    if (!(VIR_CLASS_NEW(virCloseCallbacksDomainList, virClassForObjectLockable())))
> +        return -1;
> +
> +    return 0;
> +}
> +
> +VIR_ONCE_GLOBAL_INIT(virCloseCallbacksDomainList);
> +
> +
> +/**
> + * virCloseCallbacksDomainAlloc:
> + *
> + * Allocates and returns a data structure for holding close callback data in
> + * a virDomainObj.
> + */
> +virObject *
> +virCloseCallbacksDomainAlloc(void)
> +{
> +    if (virCloseCallbacksDomainListInitialize() < 0)
> +        abort();
> +
> +    return virObjectNew(virCloseCallbacksDomainListClass);
> +}
> +
> +
> +/**
> + * virCloseCallbacksDomainAdd:
> + * @vm: domain object
> + * @conn: pointer to the connection which should trigger the close callback
> + * @cb: pointer to the callback function
> + *
> + * Registers @cb as a connection close callback for the @conn connection with
> + * the @vm domain. Duplicate registrations are ignored.
> + *
> + * Caller must hold lock on @vm.
> + */
> +void
> +virCloseCallbacksDomainAdd(virDomainObj *vm,
> +                          virConnectPtr conn,
> +                          virCloseCallback cb)

Incorrect indentation.

Reviewed-by: Pavel Hrdina <phrdina@xxxxxxxxxx>

Attachment: signature.asc
Description: PGP signature


[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]

  Powered by Linux