Re: [PATCH 3/7] Add 'detail' arg to network lifecycle event internals

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

 



On Thu, 2013-12-12 at 18:04 +0000, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>
> 
> While the public API & wire protocol included the 'detail'
> arg for network lifecycle events, the internal event handling
> code did not process it. This meant that if a future libvirtd
> server starts sending non-0 'detail' args, the current libvirt
> client will not process them.
> 
> Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
> ---
>  src/conf/network_event.c    |  7 +++++--
>  src/conf/network_event.h    |  3 ++-
>  src/network/bridge_driver.c | 15 ++++++++++-----
>  src/remote/remote_driver.c  |  2 +-
>  src/test/test_driver.c      | 15 ++++++++++-----
>  5 files changed, 28 insertions(+), 14 deletions(-)
> 
> diff --git a/src/conf/network_event.c b/src/conf/network_event.c
> index 4a02523..b885ced 100644
> --- a/src/conf/network_event.c
> +++ b/src/conf/network_event.c
> @@ -32,6 +32,7 @@ struct _virNetworkEventLifecycle {
>      virObjectEvent parent;
>  
>      int type;
> +    int detail;
>  };
>  typedef struct _virNetworkEventLifecycle virNetworkEventLifecycle;
>  typedef virNetworkEventLifecycle *virNetworkEventLifecyclePtr;
> @@ -80,7 +81,7 @@ virNetworkEventDispatchDefaultFunc(virConnectPtr conn,
>              networkLifecycleEvent = (virNetworkEventLifecyclePtr)event;
>              ((virConnectNetworkEventLifecycleCallback)cb)(conn, net,
>                                                            networkLifecycleEvent->type,
> -                                                          0,
> +                                                          networkLifecycleEvent->detail,
>                                                            cbopaque);
>              goto cleanup;
>          }
> @@ -135,7 +136,8 @@ virNetworkEventStateRegisterID(virConnectPtr conn,
>  virObjectEventPtr
>  virNetworkEventLifecycleNew(const char *name,
>                              const unsigned char *uuid,
> -                            int type)
> +                            int type,
> +                            int detail)
>  {
>      virNetworkEventLifecyclePtr event;
>      int eventId = (VIR_EVENT_NAMESPACE_NETWORK << 8) + VIR_NETWORK_EVENT_ID_LIFECYCLE;
> @@ -149,6 +151,7 @@ virNetworkEventLifecycleNew(const char *name,
>          return NULL;
>  
>      event->type = type;
> +    event->detail = detail;
>  
>      return (virObjectEventPtr)event;
>  }
> diff --git a/src/conf/network_event.h b/src/conf/network_event.h
> index 44b762e..1eef771 100644
> --- a/src/conf/network_event.h
> +++ b/src/conf/network_event.h
> @@ -40,7 +40,8 @@ virNetworkEventStateRegisterID(virConnectPtr conn,
>  virObjectEventPtr
>  virNetworkEventLifecycleNew(const char *name,
>                              const unsigned char *uuid,
> -                            int type);
> +                            int type,
> +                            int detail);
>  
>  void
>  virNetworkEventDispatchDefaultFunc(virConnectPtr conn,
> diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
> index 1bde7d7..3e10758 100644
> --- a/src/network/bridge_driver.c
> +++ b/src/network/bridge_driver.c
> @@ -2559,7 +2559,8 @@ static virNetworkPtr networkCreateXML(virConnectPtr conn, const char *xml) {
>  
>      event = virNetworkEventLifecycleNew(network->def->name,
>                                          network->def->uuid,
> -                                        VIR_NETWORK_EVENT_STARTED);
> +                                        VIR_NETWORK_EVENT_STARTED,
> +                                        0);
>  
>      VIR_INFO("Creating network '%s'", network->def->name);
>      ret = virGetNetwork(conn, network->def->name, network->def->uuid);
> @@ -2621,7 +2622,8 @@ static virNetworkPtr networkDefineXML(virConnectPtr conn, const char *xml) {
>      }
>  
>      event = virNetworkEventLifecycleNew(def->name, def->uuid,
> -                                        VIR_NETWORK_EVENT_DEFINED);
> +                                        VIR_NETWORK_EVENT_DEFINED,
> +                                        0);
>  
>      VIR_INFO("Defining network '%s'", def->name);
>      ret = virGetNetwork(conn, def->name, def->uuid);
> @@ -2673,7 +2675,8 @@ networkUndefine(virNetworkPtr net) {
>  
>      event = virNetworkEventLifecycleNew(network->def->name,
>                                          network->def->uuid,
> -                                        VIR_NETWORK_EVENT_UNDEFINED);
> +                                        VIR_NETWORK_EVENT_UNDEFINED,
> +                                        0);
>  
>      VIR_INFO("Undefining network '%s'", network->def->name);
>      if (!active) {
> @@ -2890,7 +2893,8 @@ static int networkCreate(virNetworkPtr net) {
>  
>      event = virNetworkEventLifecycleNew(network->def->name,
>                                          network->def->uuid,
> -                                        VIR_NETWORK_EVENT_STARTED);
> +                                        VIR_NETWORK_EVENT_STARTED,
> +                                        0);
>  
>  cleanup:
>      if (event)
> @@ -2930,7 +2934,8 @@ static int networkDestroy(virNetworkPtr net) {
>  
>      event = virNetworkEventLifecycleNew(network->def->name,
>                                          network->def->uuid,
> -                                        VIR_NETWORK_EVENT_STOPPED);
> +                                        VIR_NETWORK_EVENT_STOPPED,
> +                                        0);
>  
>      if (!network->persistent) {
>          if (networkRemoveInactive(driver, network) < 0) {
> diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
> index 7bd4b24..be282d6 100644
> --- a/src/remote/remote_driver.c
> +++ b/src/remote/remote_driver.c
> @@ -4918,7 +4918,7 @@ remoteNetworkBuildEventLifecycle(virNetClientProgramPtr prog ATTRIBUTE_UNUSED,
>      if (!net)
>          return;
>  
> -    event = virNetworkEventLifecycleNew(net->name, net->uuid, msg->event);
> +    event = virNetworkEventLifecycleNew(net->name, net->uuid, msg->event, msg->detail);
>      virNetworkFree(net);
>  
>      remoteDomainEventQueue(priv, event);
> diff --git a/src/test/test_driver.c b/src/test/test_driver.c
> index 30d2636..a48404a 100644
> --- a/src/test/test_driver.c
> +++ b/src/test/test_driver.c
> @@ -3542,7 +3542,8 @@ static virNetworkPtr testNetworkCreateXML(virConnectPtr conn, const char *xml) {
>      net->active = 1;
>  
>      event = virNetworkEventLifecycleNew(net->def->name, net->def->uuid,
> -                                        VIR_NETWORK_EVENT_STARTED);
> +                                        VIR_NETWORK_EVENT_STARTED,
> +                                        0);
>  
>      ret = virGetNetwork(conn, net->def->name, net->def->uuid);
>  
> @@ -3575,7 +3576,8 @@ virNetworkPtr testNetworkDefineXML(virConnectPtr conn, const char *xml)
>      net->persistent = 1;
>  
>      event = virNetworkEventLifecycleNew(net->def->name, net->def->uuid,
> -                                        VIR_NETWORK_EVENT_DEFINED);
> +                                        VIR_NETWORK_EVENT_DEFINED,
> +                                        0);
>  
>      ret = virGetNetwork(conn, net->def->name, net->def->uuid);
>  
> @@ -3611,7 +3613,8 @@ static int testNetworkUndefine(virNetworkPtr network) {
>      }
>  
>      event = virNetworkEventLifecycleNew(network->name, network->uuid,
> -                                        VIR_NETWORK_EVENT_UNDEFINED);
> +                                        VIR_NETWORK_EVENT_UNDEFINED,
> +                                        0);
>  
>      virNetworkRemoveInactive(&privconn->networks,
>                               privnet);
> @@ -3699,7 +3702,8 @@ static int testNetworkCreate(virNetworkPtr network) {
>  
>      privnet->active = 1;
>      event = virNetworkEventLifecycleNew(privnet->def->name, privnet->def->uuid,
> -                                        VIR_NETWORK_EVENT_STARTED);
> +                                        VIR_NETWORK_EVENT_STARTED,
> +                                        0);
>      ret = 0;
>  
>  cleanup:
> @@ -3727,7 +3731,8 @@ static int testNetworkDestroy(virNetworkPtr network) {
>  
>      privnet->active = 0;
>      event = virNetworkEventLifecycleNew(privnet->def->name, privnet->def->uuid,
> -                                        VIR_NETWORK_EVENT_STOPPED);
> +                                        VIR_NETWORK_EVENT_STOPPED,
> +                                        0);
>      if (!privnet->persistent) {
>          virNetworkRemoveInactive(&privconn->networks,
>                                   privnet);

ACK

--
Cedric

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