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

Re: [libvirt] [PATCHv2 2/5] conf: rename interface "usageCount" to "connections"



Looks good to me.

Acked-by: Kyle Mestery <kmestery cisco com>

On Aug 14, 2012, at 2:10 AM, Laine Stump wrote:

> I want to include this count in the xml output of networks, but
> calling it "connections" in the XML sounds better than "usageCount", and it
> would be better if the name in the XML matched the variable name.
> 
> In a few places, usageCount was being initialized to 0, but this is
> unnecessary, because VIR_ALLOC_N zero-fills everything anyway.
> ---
> src/conf/network_conf.c     |  2 --
> src/conf/network_conf.h     |  2 +-
> src/network/bridge_driver.c | 46 ++++++++++++++++++++++-----------------------
> 3 files changed, 24 insertions(+), 26 deletions(-)
> 
> diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
> index 666118c..905c644 100644
> --- a/src/conf/network_conf.c
> +++ b/src/conf/network_conf.c
> @@ -1137,7 +1137,6 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
>             }
> 
>             if (forwardDev) {
> -                def->forwardIfs[0].usageCount = 0;
>                 def->forwardIfs[0].dev = forwardDev;
>                 forwardDev = NULL;
>                 def->nForwardIfs++;
> @@ -1169,7 +1168,6 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
> 
>                 def->forwardIfs[ii].dev = forwardDev;
>                 forwardDev = NULL;
> -                def->forwardIfs[ii].usageCount = 0;
>                 def->nForwardIfs++;
>             }
>         }
> diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h
> index 040d912..23f1632 100644
> --- a/src/conf/network_conf.h
> +++ b/src/conf/network_conf.h
> @@ -132,7 +132,7 @@ typedef struct _virNetworkForwardIfDef virNetworkForwardIfDef;
> typedef virNetworkForwardIfDef *virNetworkForwardIfDefPtr;
> struct _virNetworkForwardIfDef {
>     char *dev;      /* name of device */
> -    int usageCount; /* how many guest interfaces are bound to this device? */
> +    int   connections; /* how many guest interfaces are connected to this device? */
> };
> 
> typedef struct _virNetworkForwardPfDef virNetworkForwardPfDef;
> diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
> index ec99e4d..77b38d2 100644
> --- a/src/network/bridge_driver.c
> +++ b/src/network/bridge_driver.c
> @@ -2914,10 +2914,11 @@ networkAllocateActualDevice(virDomainNetDefPtr iface)
>         } else {
>             /* pick an interface from the pool */
> 
> -            /* PASSTHROUGH mode, and PRIVATE Mode + 802.1Qbh both require
> -             * exclusive access to a device, so current usageCount must be
> -             * 0.  Other modes can share, so just search for the one with
> -             * the lowest usageCount.
> +            /* PASSTHROUGH mode, and PRIVATE Mode + 802.1Qbh both
> +             * require exclusive access to a device, so current
> +             * connections count must be 0.  Other modes can share, so
> +             * just search for the one with the lowest number of
> +             * connections.
>              */
>             if (netdef->forwardType == VIR_NETWORK_FORWARD_PASSTHROUGH) {
>                 if ((netdef->nForwardPfs > 0) && (netdef->nForwardIfs <= 0)) {
> @@ -2949,14 +2950,13 @@ networkAllocateActualDevice(virDomainNetDefPtr iface)
>                             virReportOOMError();
>                             goto cleanup;
>                         }
> -                        netdef->forwardIfs[ii].usageCount = 0;
>                     }
>                 }
> 
> -                /* pick first dev with 0 usageCount */
> +                /* pick first dev with 0 connections */
> 
>                 for (ii = 0; ii < netdef->nForwardIfs; ii++) {
> -                    if (netdef->forwardIfs[ii].usageCount == 0) {
> +                    if (netdef->forwardIfs[ii].connections == 0) {
>                         dev = &netdef->forwardIfs[ii];
>                         break;
>                     }
> @@ -2966,9 +2966,9 @@ networkAllocateActualDevice(virDomainNetDefPtr iface)
>                        (iface->data.network.actual->virtPortProfile->virtPortType
>                         == VIR_NETDEV_VPORT_PROFILE_8021QBH)) {
> 
> -                /* pick first dev with 0 usageCount */
> +                /* pick first dev with 0 connections */
>                 for (ii = 0; ii < netdef->nForwardIfs; ii++) {
> -                    if (netdef->forwardIfs[ii].usageCount == 0) {
> +                    if (netdef->forwardIfs[ii].connections == 0) {
>                         dev = &netdef->forwardIfs[ii];
>                         break;
>                     }
> @@ -2977,7 +2977,7 @@ networkAllocateActualDevice(virDomainNetDefPtr iface)
>                 /* pick least used dev */
>                 dev = &netdef->forwardIfs[0];
>                 for (ii = 1; ii < netdef->nForwardIfs; ii++) {
> -                    if (netdef->forwardIfs[ii].usageCount < dev->usageCount)
> +                    if (netdef->forwardIfs[ii].connections < dev->connections)
>                         dev = &netdef->forwardIfs[ii];
>                 }
>             }
> @@ -3002,9 +3002,9 @@ networkAllocateActualDevice(virDomainNetDefPtr iface)
> 
>     if (dev) {
>         /* we are now assured of success, so mark the allocation */
> -        dev->usageCount++;
> -        VIR_DEBUG("Using physical device %s, usageCount %d",
> -                  dev->dev, dev->usageCount);
> +        dev->connections++;
> +        VIR_DEBUG("Using physical device %s, %d connections",
> +                  dev->dev, dev->connections);
>     }
>     ret = 0;
> cleanup:
> @@ -3077,7 +3077,7 @@ networkNotifyActualDevice(virDomainNetDefPtr iface)
>         int ii;
>         virNetworkForwardIfDefPtr dev = NULL;
> 
> -        /* find the matching interface in the pool and increment its usageCount */
> +        /* find the matching interface and increment its connections */
> 
>         for (ii = 0; ii < netdef->nForwardIfs; ii++) {
>             if (STREQ(actualDev, netdef->forwardIfs[ii].dev)) {
> @@ -3094,10 +3094,10 @@ networkNotifyActualDevice(virDomainNetDefPtr iface)
>         }
> 
>         /* PASSTHROUGH mode, and PRIVATE Mode + 802.1Qbh both require
> -         * exclusive access to a device, so current usageCount must be
> -         * 0 in those cases.
> +         * exclusive access to a device, so current connections count
> +         * must be 0 in those cases.
>          */
> -        if ((dev->usageCount > 0) &&
> +        if ((dev->connections > 0) &&
>             ((netdef->forwardType == VIR_NETWORK_FORWARD_PASSTHROUGH) ||
>              ((netdef->forwardType == VIR_NETWORK_FORWARD_PRIVATE) &&
>               iface->data.network.actual->virtPortProfile &&
> @@ -3109,9 +3109,9 @@ networkNotifyActualDevice(virDomainNetDefPtr iface)
>             goto cleanup;
>         }
>         /* we are now assured of success, so mark the allocation */
> -        dev->usageCount++;
> -        VIR_DEBUG("Using physical device %s, usageCount %d",
> -                  dev->dev, dev->usageCount);
> +        dev->connections++;
> +        VIR_DEBUG("Using physical device %s, %d connections",
> +                  dev->dev, dev->connections);
>     }
> 
>     ret = 0;
> @@ -3194,9 +3194,9 @@ networkReleaseActualDevice(virDomainNetDefPtr iface)
>             goto cleanup;
>         }
> 
> -        dev->usageCount--;
> -        VIR_DEBUG("Releasing physical device %s, usageCount %d",
> -                  dev->dev, dev->usageCount);
> +        dev->connections--;
> +        VIR_DEBUG("Releasing physical device %s, %d connections",
> +                  dev->dev, dev->connections);
>     }
> 
>     ret = 0;
> -- 
> 1.7.11.2
> 
> --
> libvir-list mailing list
> libvir-list redhat com
> https://www.redhat.com/mailman/listinfo/libvir-list



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