[libvirt] [PATCH v3 2/2] nwfilter: Rebuild filters only if new filter is different than current

Eric Blake eblake at redhat.com
Wed Jan 25 21:41:41 UTC 2012


On 01/25/2012 11:58 AM, Stefan Berger wrote:
> Compare two filters' XML for equality and only rebuild/instantiate the new
> filter if the new and current filters are found to be different. This
> improves performance during an update of a filter with no obvious change
> or the reloading of filters during a 'kill -SIGHUP'
> 
> ---
>  src/conf/nwfilter_conf.c |   37 +++++++++++++++++++++++++++++++++++++
>  1 file changed, 37 insertions(+)
> 
> Index: libvirt-iterator/src/conf/nwfilter_conf.c
> ===================================================================
> --- libvirt-iterator.orig/src/conf/nwfilter_conf.c
> +++ libvirt-iterator/src/conf/nwfilter_conf.c
> @@ -2809,6 +2809,35 @@ virNWFilterTestUnassignDef(virConnectPtr
>      return rc;
>  }
>  
> +static bool
> +virNWFilterDefEqual(const virNWFilterDefPtr def1, virNWFilterDefPtr def2,
> +                    bool cmpUUIDs)
> +{
> +    bool ret = false;
> +    unsigned char rem_uuid[VIR_UUID_BUFLEN];
> +    char *xml1, *xml2 = NULL;
> +
> +    if (!cmpUUIDs) {
> +        /* make sure the UUIDs are equal */
> +        memcpy(rem_uuid, def2->uuid, sizeof(rem_uuid));
> +        memcpy(def2->uuid, def1->uuid, sizeof(def2->uuid));
> +    }
> +
> +    if (!(xml1 = virNWFilterDefFormat(def1)) ||
> +        !(xml2 = virNWFilterDefFormat(def2)))
> +        goto cleanup;
> +
> +    ret = STREQ(xml1, xml2);
> +
> +    if (!cmpUUIDs)
> +        memcpy(def2->uuid, rem_uuid, sizeof(rem_uuid));
> +
> +cleanup:

Misplaced label.  You need to slide it up two lines, and unconditionally
call the memcpy() to undo things when !cmpUUIDs.

ACK with that fixed.

-- 
Eric Blake   eblake at redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120125/2757ec1e/attachment-0001.sig>


More information about the libvir-list mailing list