Added: - Methods for relaying metadata change callbacks. - Enums representing the same.
Signed-off-by: K Shiva <shiva...@riseup.net> --- src/remote/remote_daemon_dispatch.c | 39 +++++++++++++++++++++++++++++ src/remote/remote_driver.c | 32 +++++++++++++++++++++++ src/remote/remote_protocol.x | 15 ++++++++++- src/remote_protocol-structs | 6 +++++ 4 files changed, 91 insertions(+), 1 deletion(-) diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c index 7144e9e7ca..3e5eaec9e6 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -1420,8 +1420,47 @@ remoteRelayNetworkEventLifecycle(virConnectPtr conn, return 0; } +static int +remoteRelayNetworkEventMetadataChange(virConnectPtr conn, + virNetworkPtr net, + int type, + const char *nsuri, + void *opaque) +{ + daemonClientEventCallback *callback = opaque; + remote_network_event_callback_metadata_change_msg data; + + if (callback->callbackID < 0 || + !remoteRelayNetworkEventCheckACL(callback->client, conn, net)) + return -1; + + VIR_DEBUG("Relaying network metadata change %s %d %s, callback %d", + net->name, type, NULLSTR(nsuri), callback->callbackID); + + /* build return data */ + memset(&data, 0, sizeof(data)); + + data.type = type; + if (nsuri) { + data.nsuri = g_new0(remote_nonnull_string, 1); + *(data.nsuri) = g_strdup(nsuri); + } + + make_nonnull_network(&data.net, net); + data.callbackID = callback->callbackID; + + remoteDispatchObjectEventSend(callback->client, callback->program, + REMOTE_PROC_NETWORK_EVENT_CALLBACK_METADATA_CHANGE, + (xdrproc_t)xdr_remote_network_event_callback_metadata_change_msg, + &data); + + return 0; +} + + static virConnectNetworkEventGenericCallback networkEventCallbacks[] = { VIR_NETWORK_EVENT_CALLBACK(remoteRelayNetworkEventLifecycle), + VIR_NETWORK_EVENT_CALLBACK(remoteRelayNetworkEventMetadataChange), }; G_STATIC_ASSERT(G_N_ELEMENTS(networkEventCallbacks) == VIR_NETWORK_EVENT_ID_LAST); diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 65ec239fb7..310f53fe5e 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -378,6 +378,12 @@ remoteNetworkBuildEventLifecycle(virNetClientProgram *prog G_GNUC_UNUSED, virNetClient *client G_GNUC_UNUSED, void *evdata, void *opaque); +static void +remoteNetworkBuildEventCallbackMetadataChange(virNetClientProgram *prog, + virNetClient *client, + void *evdata, void *opaque); + + static void remoteStoragePoolBuildEventLifecycle(virNetClientProgram *prog G_GNUC_UNUSED, virNetClient *client G_GNUC_UNUSED, @@ -505,6 +511,10 @@ static virNetClientProgramEvent remoteEvents[] = { remoteNetworkBuildEventLifecycle, sizeof(remote_network_event_lifecycle_msg), (xdrproc_t)xdr_remote_network_event_lifecycle_msg }, + { REMOTE_PROC_NETWORK_EVENT_CALLBACK_METADATA_CHANGE, + remoteNetworkBuildEventCallbackMetadataChange, + sizeof(remote_network_event_callback_metadata_change_msg), + (xdrproc_t)xdr_remote_network_event_callback_metadata_change_msg }, { REMOTE_PROC_DOMAIN_EVENT_CALLBACK_LIFECYCLE, remoteDomainBuildEventCallbackLifecycle, sizeof(remote_domain_event_callback_lifecycle_msg), @@ -4951,6 +4961,28 @@ remoteNetworkBuildEventLifecycle(virNetClientProgram *prog G_GNUC_UNUSED, virObjectEventStateQueueRemote(priv->eventState, event, msg->callbackID); } +static void +remoteNetworkBuildEventCallbackMetadataChange(virNetClientProgram *prog G_GNUC_UNUSED, + virNetClient *client G_GNUC_UNUSED, + void *evdata, void *opaque) +{ + virConnectPtr conn = opaque; + remote_network_event_callback_metadata_change_msg *msg = evdata; + struct private_data *priv = conn->privateData; + virNetworkPtr net; + virObjectEvent *event = NULL; + + if (!(net = get_nonnull_network(conn, msg->net))) + return; + + event = virNetworkEventMetadataChangeNewFromNet(net, msg->type, msg->nsuri ? *msg->nsuri : NULL); + + virObjectUnref(net); + + virObjectEventStateQueueRemote(priv->eventState, event, msg->callbackID); +} + + static void remoteStoragePoolBuildEventLifecycle(virNetClientProgram *prog G_GNUC_UNUSED, virNetClient *client G_GNUC_UNUSED, diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index 5d86a51116..72aa69e580 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -3323,6 +3323,13 @@ struct remote_network_event_lifecycle_msg { int detail; }; +struct remote_network_event_callback_metadata_change_msg { + int callbackID; + remote_nonnull_network net; + int type; + remote_string nsuri; +}; + struct remote_connect_storage_pool_event_register_any_args { int eventID; remote_storage_pool pool; @@ -6974,5 +6981,11 @@ enum remote_procedure { * @generate: none * @acl: domain:write */ - REMOTE_PROC_DOMAIN_FD_ASSOCIATE = 443 + REMOTE_PROC_DOMAIN_FD_ASSOCIATE = 443, + + /** + * @generate: both + * @acl: none + */ + REMOTE_PROC_NETWORK_EVENT_CALLBACK_METADATA_CHANGE = 444 }; diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index 3c6c230a16..3f7256051e 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -2687,6 +2687,12 @@ struct remote_network_event_lifecycle_msg { int event; int detail; }; +struct remote_network_event_callback_metadata_change_msg { + int callbackID; + remote_nonnull_network net; + int type; + remote_string nsuri; +}; struct remote_connect_storage_pool_event_register_any_args { int eventID; remote_storage_pool pool; -- 2.41.0