[PATCH 2/3] Introduce NIC_MAC_CHANGE event

Michal Prívozník mprivozn at redhat.com
Wed Aug 2 07:15:36 UTC 2023


On 7/26/23 16:47, Martin Kletzander wrote:
> On Wed, Jun 28, 2023 at 12:53:36PM +0200, Michal Privoznik wrote:
>> The aim off this event is to notify management application that
>> guest changed MAC address on one of its vNICs so the app can
>> update its internal records, e.g. for finding match between
>> guest/host view of vNICs.
>>
>> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
>> ---
>> examples/c/misc/event-test.c        | 14 +++++
>> include/libvirt/libvirt-domain.h    | 28 +++++++++
>> src/conf/domain_event.c             | 93 +++++++++++++++++++++++++++++
>> src/conf/domain_event.h             | 12 ++++
>> src/libvirt_private.syms            |  2 +
>> src/remote/remote_daemon_dispatch.c | 32 ++++++++++
>> src/remote/remote_driver.c          | 34 +++++++++++
>> src/remote/remote_protocol.x        | 17 +++++-
>> tools/virsh-domain-event.c          | 20 +++++++
>> 9 files changed, 251 insertions(+), 1 deletion(-)
>>
> 
> [...]
> 
>> diff --git a/src/remote/remote_daemon_dispatch.c
>> b/src/remote/remote_daemon_dispatch.c
>> index 7144e9e7ca..f347e7bcce 100644
>> --- a/src/remote/remote_daemon_dispatch.c
>> +++ b/src/remote/remote_daemon_dispatch.c
>> @@ -1357,6 +1357,37 @@
>> remoteRelayDomainEventMemoryDeviceSizeChange(virConnectPtr conn,
>> }
>>
>>
>> +static int
>> +remoteRelayDomainEventNICMACChange(virConnectPtr conn,
>> +                                   virDomainPtr dom,
>> +                                   const char *alias,
>> +                                   const char *oldMAC,
>> +                                   const char *newMAC,
>> +                                   void *opaque)
>> +{
>> +    daemonClientEventCallback *callback = opaque;
>> +    remote_domain_event_nic_mac_change_msg data;
>> +
>> +    if (callback->callbackID < 0 ||
>> +        !remoteRelayDomainEventCheckACL(callback->client, conn, dom))
>> +        return -1;
>> +
>> +    /* build return data */
>> +    memset(&data, 0, sizeof(data));
> 
> Just a nit pick, but instead of this you should be able to do:
> 
>     remote_domain_event_nic_mac_change_msg data = {0};

Yep, you're right. This is what you get when you copy code from an event
introduced earlier :-)

Fixed locally.

Michal



More information about the libvir-list mailing list