Re: [RFC PATCH v3 2/6] qemu_capabilities: Added logic for retrieving eBPF objects from QEMU.

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

 



On 5/12/24 21:45, Andrew Melnychenko wrote:
> eBPF objects stored in the hash table during runtime.
> eBPF objects cached encoded in base64 in the .xml cache file.
> 
> Signed-off-by: Andrew Melnychenko <andrew@xxxxxxxxxx>
> ---
>  src/qemu/qemu_capabilities.c | 122 +++++++++++++++++++++++++++++++++++
>  src/qemu/qemu_capabilities.h |   3 +
>  2 files changed, 125 insertions(+)

'meson test' fails after this one.

> 
> diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
> index 45525db803..09bb6ca36e 100644
> --- a/src/qemu/qemu_capabilities.c
> +++ b/src/qemu/qemu_capabilities.c
> @@ -799,6 +799,9 @@ struct _virQEMUCaps {
>      virQEMUCapsAccel kvm;
>      virQEMUCapsAccel hvf;
>      virQEMUCapsAccel tcg;
> +
> +    /* Hash of ebpf objects encoded in base64 */
> +    GHashTable *ebpfObjects;
>  };
>  
>  struct virQEMUCapsSearchData {
> @@ -846,6 +849,13 @@ const char *virQEMUCapsArchToString(virArch arch)
>  }
>  
>  
> +const char *
> +virQEMUCapsGetEbpf(virQEMUCaps *qemuCaps, const char *id)
> +{
> +    return virHashLookup(qemuCaps->ebpfObjects, id);
> +}
> +
> +
>  /* Checks whether a domain with @guest arch can run natively on @host.
>   */
>  bool
> @@ -1823,6 +1833,8 @@ virQEMUCapsNew(void)
>      qemuCaps->invalidation = true;
>      qemuCaps->flags = virBitmapNew(QEMU_CAPS_LAST);
>  
> +    qemuCaps->ebpfObjects = virHashNew(g_free);
> +
>      return qemuCaps;
>  }
>  
> @@ -1965,6 +1977,9 @@ virQEMUCaps *virQEMUCapsNewCopy(virQEMUCaps *qemuCaps)
>  {
>      g_autoptr(virQEMUCaps) ret = virQEMUCapsNewBinary(qemuCaps->binary);
>      size_t i;
> +    GHashTableIter iter;
> +    const char *key;
> +    const char *value;
>  
>      ret->invalidation = qemuCaps->invalidation;
>      ret->kvmSupportsNesting = qemuCaps->kvmSupportsNesting;
> @@ -2003,6 +2018,12 @@ virQEMUCaps *virQEMUCapsNewCopy(virQEMUCaps *qemuCaps)
>      ret->hypervCapabilities = g_memdup(qemuCaps->hypervCapabilities,
>                                         sizeof(virDomainCapsFeatureHyperv));
>  
> +    ret->ebpfObjects = virHashNew(g_free);
> +    g_hash_table_iter_init(&iter, qemuCaps->ebpfObjects);
> +    while (g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer *) &value)) {
> +        g_hash_table_insert(ret->ebpfObjects, g_strdup(key), g_strdup(value));
> +    }
> +

I'd move this into a separate function for code estetics purpose.

>      return g_steal_pointer(&ret);
>  }

Michal



[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