From nobody Mon Apr 29 21:39:31 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) client-ip=209.132.183.37; envelope-from=libvir-list-bounces@redhat.com; helo=mx5-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) by mx.zohomail.com with SMTPS id 14886334608221.429721919782196; Sat, 4 Mar 2017 05:17:40 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v24DChoc056876; Sat, 4 Mar 2017 08:12:43 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v24DCftl029275 for ; Sat, 4 Mar 2017 08:12:41 -0500 Received: from localhost.localdomain.com (ovpn-116-78.phx2.redhat.com [10.3.116.78]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v24DCe03009154 for ; Sat, 4 Mar 2017 08:12:41 -0500 From: John Ferlan To: libvir-list@redhat.com Date: Sat, 4 Mar 2017 08:12:32 -0500 Message-Id: <20170304131235.2057-2-jferlan@redhat.com> In-Reply-To: <20170304131235.2057-1-jferlan@redhat.com> References: <20170304131235.2057-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/4] conf: Introduce virinterfaceobj X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Move all the InterfaceObj API's into their own module virinterfaceobj from the interface_conf Purely code motion at this point. Signed-off-by: John Ferlan --- po/POTFILES.in | 1 + src/Makefile.am | 3 +- src/conf/interface_conf.c | 166 -------------------------- src/conf/interface_conf.h | 45 ------- src/conf/virinterfaceobj.c | 201 ++++++++++++++++++++++++++++= ++++ src/conf/virinterfaceobj.h | 70 +++++++++++ src/interface/interface_backend_netcf.c | 1 + src/interface/interface_backend_udev.c | 1 + src/libvirt_private.syms | 19 +-- src/test/test_driver.c | 1 + 10 files changed, 288 insertions(+), 220 deletions(-) create mode 100644 src/conf/virinterfaceobj.c create mode 100644 src/conf/virinterfaceobj.h diff --git a/po/POTFILES.in b/po/POTFILES.in index 7c7f530..50289a5 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -42,6 +42,7 @@ src/conf/snapshot_conf.c src/conf/storage_conf.c src/conf/virchrdev.c src/conf/virdomainobjlist.c +src/conf/virinterfaceobj.c src/conf/virnodedeviceobj.c src/conf/virsecretobj.c src/cpu/cpu.c diff --git a/src/Makefile.am b/src/Makefile.am index 7d42eac..c85927f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -381,7 +381,8 @@ STORAGE_CONF_SOURCES =3D = \ =20 # Interface driver generic impl APIs INTERFACE_CONF_SOURCES =3D \ - conf/interface_conf.c conf/interface_conf.h + conf/interface_conf.c conf/interface_conf.h \ + conf/virinterfaceobj.c conf/virinterfaceobj.h =20 # Secret driver generic impl APIs SECRET_CONF_SOURCES =3D \ diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c index e1e6a25..dc2ddd4 100644 --- a/src/conf/interface_conf.c +++ b/src/conf/interface_conf.c @@ -1114,169 +1114,3 @@ char *virInterfaceDefFormat(const virInterfaceDef *= def) } return virBufferContentAndReset(&buf); } - -/* virInterfaceObj manipulation */ - -void virInterfaceObjLock(virInterfaceObjPtr obj) -{ - virMutexLock(&obj->lock); -} - -void virInterfaceObjUnlock(virInterfaceObjPtr obj) -{ - virMutexUnlock(&obj->lock); -} - -void virInterfaceObjFree(virInterfaceObjPtr iface) -{ - if (!iface) - return; - - virInterfaceDefFree(iface->def); - virMutexDestroy(&iface->lock); - VIR_FREE(iface); -} - -/* virInterfaceObjList manipulation */ - -int virInterfaceFindByMACString(virInterfaceObjListPtr interfaces, - const char *mac, - virInterfaceObjPtr *matches, int maxmatche= s) -{ - size_t i; - unsigned int matchct =3D 0; - - for (i =3D 0; i < interfaces->count; i++) { - - virInterfaceObjLock(interfaces->objs[i]); - if (STRCASEEQ(interfaces->objs[i]->def->mac, mac)) { - matchct++; - if (matchct <=3D maxmatches) { - matches[matchct - 1] =3D interfaces->objs[i]; - /* keep the lock if we're returning object to caller */ - /* it is the caller's responsibility to unlock *all* match= es */ - continue; - } - } - virInterfaceObjUnlock(interfaces->objs[i]); - - } - return matchct; -} - -virInterfaceObjPtr virInterfaceFindByName(virInterfaceObjListPtr interface= s, - const char *name) -{ - size_t i; - - for (i =3D 0; i < interfaces->count; i++) { - virInterfaceObjLock(interfaces->objs[i]); - if (STREQ(interfaces->objs[i]->def->name, name)) - return interfaces->objs[i]; - virInterfaceObjUnlock(interfaces->objs[i]); - } - - return NULL; -} - -void virInterfaceObjListFree(virInterfaceObjListPtr interfaces) -{ - size_t i; - - for (i =3D 0; i < interfaces->count; i++) - virInterfaceObjFree(interfaces->objs[i]); - - VIR_FREE(interfaces->objs); - interfaces->count =3D 0; -} - -int virInterfaceObjListClone(virInterfaceObjListPtr src, - virInterfaceObjListPtr dest) -{ - int ret =3D -1; - size_t i; - unsigned int cnt; - - if (!src || !dest) - goto cleanup; - - virInterfaceObjListFree(dest); /* start with an empty list */ - cnt =3D src->count; - for (i =3D 0; i < cnt; i++) { - virInterfaceDefPtr def =3D src->objs[i]->def; - virInterfaceDefPtr backup; - virInterfaceObjPtr iface; - char *xml =3D virInterfaceDefFormat(def); - - if (!xml) - goto cleanup; - - if ((backup =3D virInterfaceDefParseString(xml)) =3D=3D NULL) { - VIR_FREE(xml); - goto cleanup; - } - - VIR_FREE(xml); - if ((iface =3D virInterfaceAssignDef(dest, backup)) =3D=3D NULL) - goto cleanup; - virInterfaceObjUnlock(iface); /* was locked by virInterfaceAssignD= ef */ - } - - ret =3D cnt; - cleanup: - if ((ret < 0) && dest) - virInterfaceObjListFree(dest); - return ret; -} - -virInterfaceObjPtr virInterfaceAssignDef(virInterfaceObjListPtr interfaces, - virInterfaceDefPtr def) -{ - virInterfaceObjPtr iface; - - if ((iface =3D virInterfaceFindByName(interfaces, def->name))) { - virInterfaceDefFree(iface->def); - iface->def =3D def; - - return iface; - } - - if (VIR_ALLOC(iface) < 0) - return NULL; - if (virMutexInit(&iface->lock) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("cannot initialize mutex")); - VIR_FREE(iface); - return NULL; - } - virInterfaceObjLock(iface); - - if (VIR_APPEND_ELEMENT_COPY(interfaces->objs, - interfaces->count, iface) < 0) { - virInterfaceObjFree(iface); - return NULL; - } - - iface->def =3D def; - return iface; - -} - -void virInterfaceRemove(virInterfaceObjListPtr interfaces, - virInterfaceObjPtr iface) -{ - size_t i; - - virInterfaceObjUnlock(iface); - for (i =3D 0; i < interfaces->count; i++) { - virInterfaceObjLock(interfaces->objs[i]); - if (interfaces->objs[i] =3D=3D iface) { - virInterfaceObjUnlock(interfaces->objs[i]); - virInterfaceObjFree(interfaces->objs[i]); - - VIR_DELETE_ELEMENT(interfaces->objs, i, interfaces->count); - break; - } - virInterfaceObjUnlock(interfaces->objs[i]); - } -} diff --git a/src/conf/interface_conf.h b/src/conf/interface_conf.h index 2523207..7325d65 100644 --- a/src/conf/interface_conf.h +++ b/src/conf/interface_conf.h @@ -161,46 +161,7 @@ struct _virInterfaceDef { virInterfaceProtocolDefPtr *protos; /* ptr to array of protos[nprotos]= */ }; =20 -typedef struct _virInterfaceObj virInterfaceObj; -typedef virInterfaceObj *virInterfaceObjPtr; -struct _virInterfaceObj { - virMutex lock; - - bool active; /* true if interface is active (up) */ - virInterfaceDefPtr def; /* The interface definition */ -}; - -typedef struct _virInterfaceObjList virInterfaceObjList; -typedef virInterfaceObjList *virInterfaceObjListPtr; -struct _virInterfaceObjList { - size_t count; - virInterfaceObjPtr *objs; -}; - -static inline bool -virInterfaceObjIsActive(const virInterfaceObj *iface) -{ - return iface->active; -} - -int virInterfaceFindByMACString(virInterfaceObjListPtr interfaces, - const char *mac, - virInterfaceObjPtr *matches, int maxmatche= s); -virInterfaceObjPtr virInterfaceFindByName(virInterfaceObjListPtr interface= s, - const char *name); - - void virInterfaceDefFree(virInterfaceDefPtr def); -void virInterfaceObjFree(virInterfaceObjPtr iface); -void virInterfaceObjListFree(virInterfaceObjListPtr vms); -int virInterfaceObjListClone(virInterfaceObjListPtr src, - virInterfaceObjListPtr dest); - - -virInterfaceObjPtr virInterfaceAssignDef(virInterfaceObjListPtr interfaces, - virInterfaceDefPtr def); -void virInterfaceRemove(virInterfaceObjListPtr interfaces, - virInterfaceObjPtr iface); =20 virInterfaceDefPtr virInterfaceDefParseString(const char *xmlStr); virInterfaceDefPtr virInterfaceDefParseFile(const char *filename); @@ -209,12 +170,6 @@ virInterfaceDefPtr virInterfaceDefParseNode(xmlDocPtr = xml, =20 char *virInterfaceDefFormat(const virInterfaceDef *def); =20 -void virInterfaceObjLock(virInterfaceObjPtr obj); -void virInterfaceObjUnlock(virInterfaceObjPtr obj); - -typedef bool (*virInterfaceObjListFilter)(virConnectPtr conn, - virInterfaceDefPtr def); - # define VIR_CONNECT_LIST_INTERFACES_FILTERS_ACTIVE \ (VIR_CONNECT_LIST_INTERFACES_ACTIVE | \ VIR_CONNECT_LIST_INTERFACES_INACTIVE) diff --git a/src/conf/virinterfaceobj.c b/src/conf/virinterfaceobj.c new file mode 100644 index 0000000..6c18911 --- /dev/null +++ b/src/conf/virinterfaceobj.c @@ -0,0 +1,201 @@ +/* + * virinterfaceobj.c: interface object handling + * (derived from interface_conf.c) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#include + +#include "datatypes.h" +#include "interface_conf.h" + +#include "viralloc.h" +#include "virerror.h" +#include "virinterfaceobj.h" +#include "virlog.h" +#include "virstring.h" + +#define VIR_FROM_THIS VIR_FROM_INTERFACE + +VIR_LOG_INIT("conf.virinterfaceobj"); + + + +/* virInterfaceObj manipulation */ + +void virInterfaceObjLock(virInterfaceObjPtr obj) +{ + virMutexLock(&obj->lock); +} + +void virInterfaceObjUnlock(virInterfaceObjPtr obj) +{ + virMutexUnlock(&obj->lock); +} + +void virInterfaceObjFree(virInterfaceObjPtr iface) +{ + if (!iface) + return; + + virInterfaceDefFree(iface->def); + virMutexDestroy(&iface->lock); + VIR_FREE(iface); +} + +/* virInterfaceObjList manipulation */ + +int virInterfaceFindByMACString(virInterfaceObjListPtr interfaces, + const char *mac, + virInterfaceObjPtr *matches, int maxmatche= s) +{ + size_t i; + unsigned int matchct =3D 0; + + for (i =3D 0; i < interfaces->count; i++) { + + virInterfaceObjLock(interfaces->objs[i]); + if (STRCASEEQ(interfaces->objs[i]->def->mac, mac)) { + matchct++; + if (matchct <=3D maxmatches) { + matches[matchct - 1] =3D interfaces->objs[i]; + /* keep the lock if we're returning object to caller */ + /* it is the caller's responsibility to unlock *all* match= es */ + continue; + } + } + virInterfaceObjUnlock(interfaces->objs[i]); + + } + return matchct; +} + +virInterfaceObjPtr virInterfaceFindByName(virInterfaceObjListPtr interface= s, + const char *name) +{ + size_t i; + + for (i =3D 0; i < interfaces->count; i++) { + virInterfaceObjLock(interfaces->objs[i]); + if (STREQ(interfaces->objs[i]->def->name, name)) + return interfaces->objs[i]; + virInterfaceObjUnlock(interfaces->objs[i]); + } + + return NULL; +} + +void virInterfaceObjListFree(virInterfaceObjListPtr interfaces) +{ + size_t i; + + for (i =3D 0; i < interfaces->count; i++) + virInterfaceObjFree(interfaces->objs[i]); + + VIR_FREE(interfaces->objs); + interfaces->count =3D 0; +} + +int virInterfaceObjListClone(virInterfaceObjListPtr src, + virInterfaceObjListPtr dest) +{ + int ret =3D -1; + size_t i; + unsigned int cnt; + + if (!src || !dest) + goto cleanup; + + virInterfaceObjListFree(dest); /* start with an empty list */ + cnt =3D src->count; + for (i =3D 0; i < cnt; i++) { + virInterfaceDefPtr def =3D src->objs[i]->def; + virInterfaceDefPtr backup; + virInterfaceObjPtr iface; + char *xml =3D virInterfaceDefFormat(def); + + if (!xml) + goto cleanup; + + if ((backup =3D virInterfaceDefParseString(xml)) =3D=3D NULL) { + VIR_FREE(xml); + goto cleanup; + } + + VIR_FREE(xml); + if ((iface =3D virInterfaceAssignDef(dest, backup)) =3D=3D NULL) + goto cleanup; + virInterfaceObjUnlock(iface); /* was locked by virInterfaceAssignD= ef */ + } + + ret =3D cnt; + cleanup: + if ((ret < 0) && dest) + virInterfaceObjListFree(dest); + return ret; +} + +virInterfaceObjPtr virInterfaceAssignDef(virInterfaceObjListPtr interfaces, + virInterfaceDefPtr def) +{ + virInterfaceObjPtr iface; + + if ((iface =3D virInterfaceFindByName(interfaces, def->name))) { + virInterfaceDefFree(iface->def); + iface->def =3D def; + + return iface; + } + + if (VIR_ALLOC(iface) < 0) + return NULL; + if (virMutexInit(&iface->lock) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("cannot initialize mutex")); + VIR_FREE(iface); + return NULL; + } + virInterfaceObjLock(iface); + + if (VIR_APPEND_ELEMENT_COPY(interfaces->objs, + interfaces->count, iface) < 0) { + virInterfaceObjFree(iface); + return NULL; + } + + iface->def =3D def; + return iface; + +} + +void virInterfaceRemove(virInterfaceObjListPtr interfaces, + virInterfaceObjPtr iface) +{ + size_t i; + + virInterfaceObjUnlock(iface); + for (i =3D 0; i < interfaces->count; i++) { + virInterfaceObjLock(interfaces->objs[i]); + if (interfaces->objs[i] =3D=3D iface) { + virInterfaceObjUnlock(interfaces->objs[i]); + virInterfaceObjFree(interfaces->objs[i]); + + VIR_DELETE_ELEMENT(interfaces->objs, i, interfaces->count); + break; + } + virInterfaceObjUnlock(interfaces->objs[i]); + } +} diff --git a/src/conf/virinterfaceobj.h b/src/conf/virinterfaceobj.h new file mode 100644 index 0000000..51d7c75 --- /dev/null +++ b/src/conf/virinterfaceobj.h @@ -0,0 +1,70 @@ +/* + * virinterfaceobj.h: interface object handling entry points + * (derived from interface_conf.h) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#ifndef __VIRINTERFACEOBJ_H__ +# define __VIRINTERFACEOBJ_H__ + +# include "internal.h" + +typedef struct _virInterfaceObj virInterfaceObj; +typedef virInterfaceObj *virInterfaceObjPtr; +struct _virInterfaceObj { + virMutex lock; + + bool active; /* true if interface is active (up) */ + virInterfaceDefPtr def; /* The interface definition */ +}; + +typedef struct _virInterfaceObjList virInterfaceObjList; +typedef virInterfaceObjList *virInterfaceObjListPtr; +struct _virInterfaceObjList { + size_t count; + virInterfaceObjPtr *objs; +}; + +static inline bool +virInterfaceObjIsActive(const virInterfaceObj *iface) +{ + return iface->active; +} + +int virInterfaceFindByMACString(virInterfaceObjListPtr interfaces, + const char *mac, + virInterfaceObjPtr *matches, int maxmatche= s); +virInterfaceObjPtr virInterfaceFindByName(virInterfaceObjListPtr interface= s, + const char *name); + + +void virInterfaceObjFree(virInterfaceObjPtr iface); +void virInterfaceObjListFree(virInterfaceObjListPtr vms); +int virInterfaceObjListClone(virInterfaceObjListPtr src, + virInterfaceObjListPtr dest); + + +virInterfaceObjPtr virInterfaceAssignDef(virInterfaceObjListPtr interfaces, + virInterfaceDefPtr def); +void virInterfaceRemove(virInterfaceObjListPtr interfaces, + virInterfaceObjPtr iface); + +void virInterfaceObjLock(virInterfaceObjPtr obj); +void virInterfaceObjUnlock(virInterfaceObjPtr obj); + +typedef bool (*virInterfaceObjListFilter)(virConnectPtr conn, + virInterfaceDefPtr def); +#endif /* __VIRINTERFACEOBJ_H__ */ diff --git a/src/interface/interface_backend_netcf.c b/src/interface/interf= ace_backend_netcf.c index 0181635..700a8a0 100644 --- a/src/interface/interface_backend_netcf.c +++ b/src/interface/interface_backend_netcf.c @@ -33,6 +33,7 @@ #include "virlog.h" #include "virstring.h" #include "viraccessapicheck.h" +#include "virinterfaceobj.h" =20 #define VIR_FROM_THIS VIR_FROM_INTERFACE =20 diff --git a/src/interface/interface_backend_udev.c b/src/interface/interfa= ce_backend_udev.c index 5d0fc64..18a45fa 100644 --- a/src/interface/interface_backend_udev.c +++ b/src/interface/interface_backend_udev.c @@ -34,6 +34,7 @@ #include "viralloc.h" #include "virstring.h" #include "viraccessapicheck.h" +#include "virinterfaceobj.h" #include "virnetdev.h" =20 #define VIR_FROM_THIS VIR_FROM_INTERFACE diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index aed1d3d..b39e17d 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -594,19 +594,11 @@ virDomainConfVMNWFilterTeardown; =20 =20 # conf/interface_conf.h -virInterfaceAssignDef; virInterfaceDefFormat; virInterfaceDefFree; virInterfaceDefParseFile; virInterfaceDefParseNode; virInterfaceDefParseString; -virInterfaceFindByMACString; -virInterfaceFindByName; -virInterfaceObjListClone; -virInterfaceObjListFree; -virInterfaceObjLock; -virInterfaceObjUnlock; -virInterfaceRemove; =20 =20 # conf/netdev_bandwidth_conf.h @@ -948,6 +940,17 @@ virDomainObjListRemoveLocked; virDomainObjListRename; =20 =20 +# conf/virinterfaceobj.h +virInterfaceAssignDef; +virInterfaceFindByMACString; +virInterfaceFindByName; +virInterfaceObjListClone; +virInterfaceObjListFree; +virInterfaceObjLock; +virInterfaceObjUnlock; +virInterfaceRemove; + + # conf/virnodedeviceobj.h virNodeDeviceObjAssignDef; virNodeDeviceObjFindByName; diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 61c82b9..e72a91f 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -64,6 +64,7 @@ #include "virauth.h" #include "viratomic.h" #include "virdomainobjlist.h" +#include "virinterfaceobj.h" #include "virhostcpu.h" =20 #define VIR_FROM_THIS VIR_FROM_TEST --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 21:39:31 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) client-ip=209.132.183.37; envelope-from=libvir-list-bounces@redhat.com; helo=mx5-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) by mx.zohomail.com with SMTPS id 1488633457671697.5200448064478; Sat, 4 Mar 2017 05:17:37 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v24DDOXf056899; Sat, 4 Mar 2017 08:13:24 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v24DCgsO029280 for ; Sat, 4 Mar 2017 08:12:42 -0500 Received: from localhost.localdomain.com (ovpn-116-78.phx2.redhat.com [10.3.116.78]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v24DCe04009154 for ; Sat, 4 Mar 2017 08:12:41 -0500 From: John Ferlan To: libvir-list@redhat.com Date: Sat, 4 Mar 2017 08:12:33 -0500 Message-Id: <20170304131235.2057-3-jferlan@redhat.com> In-Reply-To: <20170304131235.2057-1-jferlan@redhat.com> References: <20170304131235.2057-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/4] conf: Adjust coding style for interface conf sources X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Alter the format of the code to follow more recent style guidelines of two empty lines between functions, function decls with "[static] type" on one line followed by function name with arguments to functions each on one line. Signed-off-by: John Ferlan --- src/conf/interface_conf.c | 73 ++++++++++++++++++++++++++++++++++++------= ---- src/conf/virinterfaceobj.c | 48 ++++++++++++++++++++---------- 2 files changed, 89 insertions(+), 32 deletions(-) diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c index dc2ddd4..8c46cf5 100644 --- a/src/conf/interface_conf.c +++ b/src/conf/interface_conf.c @@ -40,12 +40,13 @@ VIR_ENUM_IMPL(virInterface, =20 static virInterfaceDefPtr virInterfaceDefParseXML(xmlXPathContextPtr ctxt, int parentIfType); + static int virInterfaceDefDevFormat(virBufferPtr buf, const virInterfaceDef *def, virInterfaceType parentIfType); =20 -static -void virInterfaceIPDefFree(virInterfaceIPDefPtr def) +static void +virInterfaceIPDefFree(virInterfaceIPDefPtr def) { if (def =3D=3D NULL) return; @@ -53,8 +54,9 @@ void virInterfaceIPDefFree(virInterfaceIPDefPtr def) VIR_FREE(def); } =20 -static -void virInterfaceProtocolDefFree(virInterfaceProtocolDefPtr def) + +static void +virInterfaceProtocolDefFree(virInterfaceProtocolDefPtr def) { size_t i; =20 @@ -68,7 +70,9 @@ void virInterfaceProtocolDefFree(virInterfaceProtocolDefP= tr def) VIR_FREE(def); } =20 -void virInterfaceDefFree(virInterfaceDefPtr def) + +void +virInterfaceDefFree(virInterfaceDefPtr def) { size_t i; int pp; @@ -111,6 +115,7 @@ void virInterfaceDefFree(virInterfaceDefPtr def) VIR_FREE(def); } =20 + static int virInterfaceDefParseName(virInterfaceDefPtr def, xmlXPathContextPtr ctxt) @@ -127,6 +132,7 @@ virInterfaceDefParseName(virInterfaceDefPtr def, return 0; } =20 + static int virInterfaceDefParseMtu(virInterfaceDefPtr def, xmlXPathContextPtr ctxt) @@ -145,6 +151,7 @@ virInterfaceDefParseMtu(virInterfaceDefPtr def, return 0; } =20 + static int virInterfaceDefParseStartMode(virInterfaceDefPtr def, xmlXPathContextPtr ctxt) @@ -170,6 +177,7 @@ virInterfaceDefParseStartMode(virInterfaceDefPtr def, return 0; } =20 + static int virInterfaceDefParseBondMode(xmlXPathContextPtr ctxt) { @@ -202,6 +210,7 @@ virInterfaceDefParseBondMode(xmlXPathContextPtr ctxt) return ret; } =20 + static int virInterfaceDefParseBondMiiCarrier(xmlXPathContextPtr ctxt) { @@ -224,6 +233,7 @@ virInterfaceDefParseBondMiiCarrier(xmlXPathContextPtr c= txt) return ret; } =20 + static int virInterfaceDefParseBondArpValid(xmlXPathContextPtr ctxt) { @@ -248,6 +258,7 @@ virInterfaceDefParseBondArpValid(xmlXPathContextPtr ctx= t) return ret; } =20 + static int virInterfaceDefParseDhcp(virInterfaceProtocolDefPtr def, xmlNodePtr dhcp, xmlXPathContextPtr ctxt) @@ -280,6 +291,7 @@ virInterfaceDefParseDhcp(virInterfaceProtocolDefPtr def, return ret; } =20 + static int virInterfaceDefParseIP(virInterfaceIPDefPtr def, xmlXPathContextPtr ctxt) @@ -304,6 +316,7 @@ virInterfaceDefParseIP(virInterfaceIPDefPtr def, return 0; } =20 + static int virInterfaceDefParseProtoIPv4(virInterfaceProtocolDefPtr def, xmlXPathContextPtr ctxt) @@ -355,6 +368,7 @@ virInterfaceDefParseProtoIPv4(virInterfaceProtocolDefPt= r def, return ret; } =20 + static int virInterfaceDefParseProtoIPv6(virInterfaceProtocolDefPtr def, xmlXPathContextPtr ctxt) @@ -410,6 +424,7 @@ virInterfaceDefParseProtoIPv6(virInterfaceProtocolDefPt= r def, return ret; } =20 + static int virInterfaceDefParseIfAdressing(virInterfaceDefPtr def, xmlXPathContextPtr ctxt) @@ -480,6 +495,7 @@ virInterfaceDefParseIfAdressing(virInterfaceDefPtr def, =20 } =20 + static int virInterfaceDefParseBridge(virInterfaceDefPtr def, xmlXPathContextPtr ctxt) @@ -539,6 +555,7 @@ virInterfaceDefParseBridge(virInterfaceDefPtr def, return ret; } =20 + static int virInterfaceDefParseBondItfs(virInterfaceDefPtr def, xmlXPathContextPtr ctxt) @@ -581,6 +598,7 @@ virInterfaceDefParseBondItfs(virInterfaceDefPtr def, return ret; } =20 + static int virInterfaceDefParseBond(virInterfaceDefPtr def, xmlXPathContextPtr ctxt) @@ -653,6 +671,7 @@ virInterfaceDefParseBond(virInterfaceDefPtr def, return 0; } =20 + static int virInterfaceDefParseVlan(virInterfaceDefPtr def, xmlXPathContextPtr ctxt) @@ -674,8 +693,10 @@ virInterfaceDefParseVlan(virInterfaceDefPtr def, return 0; } =20 + static virInterfaceDefPtr -virInterfaceDefParseXML(xmlXPathContextPtr ctxt, int parentIfType) +virInterfaceDefParseXML(xmlXPathContextPtr ctxt, + int parentIfType) { virInterfaceDefPtr def; int type; @@ -795,8 +816,10 @@ virInterfaceDefParseXML(xmlXPathContextPtr ctxt, int p= arentIfType) return NULL; } =20 -virInterfaceDefPtr virInterfaceDefParseNode(xmlDocPtr xml, - xmlNodePtr root) + +virInterfaceDefPtr +virInterfaceDefParseNode(xmlDocPtr xml, + xmlNodePtr root) { xmlXPathContextPtr ctxt =3D NULL; virInterfaceDefPtr def =3D NULL; @@ -823,6 +846,7 @@ virInterfaceDefPtr virInterfaceDefParseNode(xmlDocPtr x= ml, return def; } =20 + static virInterfaceDefPtr virInterfaceDefParse(const char *xmlStr, const char *filename) @@ -838,18 +862,24 @@ virInterfaceDefParse(const char *xmlStr, return def; } =20 -virInterfaceDefPtr virInterfaceDefParseString(const char *xmlStr) + +virInterfaceDefPtr +virInterfaceDefParseString(const char *xmlStr) { return virInterfaceDefParse(xmlStr, NULL); } =20 -virInterfaceDefPtr virInterfaceDefParseFile(const char *filename) + +virInterfaceDefPtr +virInterfaceDefParseFile(const char *filename) { return virInterfaceDefParse(NULL, filename); } =20 + static int -virInterfaceBridgeDefFormat(virBufferPtr buf, const virInterfaceDef *def) +virInterfaceBridgeDefFormat(virBufferPtr buf, + const virInterfaceDef *def) { size_t i; int ret =3D 0; @@ -875,8 +905,10 @@ virInterfaceBridgeDefFormat(virBufferPtr buf, const vi= rInterfaceDef *def) return ret; } =20 + static int -virInterfaceBondDefFormat(virBufferPtr buf, const virInterfaceDef *def) +virInterfaceBondDefFormat(virBufferPtr buf, + const virInterfaceDef *def) { size_t i; int ret =3D 0; @@ -938,8 +970,10 @@ virInterfaceBondDefFormat(virBufferPtr buf, const virI= nterfaceDef *def) return ret; } =20 + static int -virInterfaceVlanDefFormat(virBufferPtr buf, const virInterfaceDef *def) +virInterfaceVlanDefFormat(virBufferPtr buf, + const virInterfaceDef *def) { if (def->data.vlan.tag =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -961,8 +995,10 @@ virInterfaceVlanDefFormat(virBufferPtr buf, const virI= nterfaceDef *def) return 0; } =20 + static int -virInterfaceProtocolDefFormat(virBufferPtr buf, const virInterfaceDef *def) +virInterfaceProtocolDefFormat(virBufferPtr buf, + const virInterfaceDef *def) { size_t i, j; =20 @@ -1006,6 +1042,7 @@ virInterfaceProtocolDefFormat(virBufferPtr buf, const= virInterfaceDef *def) return 0; } =20 + static int virInterfaceStartmodeDefFormat(virBufferPtr buf, virInterfaceStartMode startmode) @@ -1032,8 +1069,10 @@ virInterfaceStartmodeDefFormat(virBufferPtr buf, return 0; } =20 + static int -virInterfaceDefDevFormat(virBufferPtr buf, const virInterfaceDef *def, +virInterfaceDefDevFormat(virBufferPtr buf, + const virInterfaceDef *def, virInterfaceType parentIfType) { const char *type =3D NULL; @@ -1104,7 +1143,9 @@ virInterfaceDefDevFormat(virBufferPtr buf, const virI= nterfaceDef *def, return -1; } =20 -char *virInterfaceDefFormat(const virInterfaceDef *def) + +char * +virInterfaceDefFormat(const virInterfaceDef *def) { virBuffer buf =3D VIR_BUFFER_INITIALIZER; =20 diff --git a/src/conf/virinterfaceobj.c b/src/conf/virinterfaceobj.c index 6c18911..70f9001 100644 --- a/src/conf/virinterfaceobj.c +++ b/src/conf/virinterfaceobj.c @@ -36,17 +36,22 @@ VIR_LOG_INIT("conf.virinterfaceobj"); =20 /* virInterfaceObj manipulation */ =20 -void virInterfaceObjLock(virInterfaceObjPtr obj) +void +virInterfaceObjLock(virInterfaceObjPtr obj) { virMutexLock(&obj->lock); } =20 -void virInterfaceObjUnlock(virInterfaceObjPtr obj) + +void +virInterfaceObjUnlock(virInterfaceObjPtr obj) { virMutexUnlock(&obj->lock); } =20 -void virInterfaceObjFree(virInterfaceObjPtr iface) + +void +virInterfaceObjFree(virInterfaceObjPtr iface) { if (!iface) return; @@ -56,11 +61,12 @@ void virInterfaceObjFree(virInterfaceObjPtr iface) VIR_FREE(iface); } =20 -/* virInterfaceObjList manipulation */ =20 -int virInterfaceFindByMACString(virInterfaceObjListPtr interfaces, - const char *mac, - virInterfaceObjPtr *matches, int maxmatche= s) +/* virInterfaceObjList manipulation */ +int +virInterfaceFindByMACString(virInterfaceObjListPtr interfaces, + const char *mac, + virInterfaceObjPtr *matches, int maxmatches) { size_t i; unsigned int matchct =3D 0; @@ -83,8 +89,10 @@ int virInterfaceFindByMACString(virInterfaceObjListPtr i= nterfaces, return matchct; } =20 -virInterfaceObjPtr virInterfaceFindByName(virInterfaceObjListPtr interface= s, - const char *name) + +virInterfaceObjPtr +virInterfaceFindByName(virInterfaceObjListPtr interfaces, + const char *name) { size_t i; =20 @@ -98,7 +106,9 @@ virInterfaceObjPtr virInterfaceFindByName(virInterfaceOb= jListPtr interfaces, return NULL; } =20 -void virInterfaceObjListFree(virInterfaceObjListPtr interfaces) + +void +virInterfaceObjListFree(virInterfaceObjListPtr interfaces) { size_t i; =20 @@ -109,8 +119,10 @@ void virInterfaceObjListFree(virInterfaceObjListPtr in= terfaces) interfaces->count =3D 0; } =20 -int virInterfaceObjListClone(virInterfaceObjListPtr src, - virInterfaceObjListPtr dest) + +int +virInterfaceObjListClone(virInterfaceObjListPtr src, + virInterfaceObjListPtr dest) { int ret =3D -1; size_t i; @@ -148,8 +160,10 @@ int virInterfaceObjListClone(virInterfaceObjListPtr sr= c, return ret; } =20 -virInterfaceObjPtr virInterfaceAssignDef(virInterfaceObjListPtr interfaces, - virInterfaceDefPtr def) + +virInterfaceObjPtr +virInterfaceAssignDef(virInterfaceObjListPtr interfaces, + virInterfaceDefPtr def) { virInterfaceObjPtr iface; =20 @@ -181,8 +195,10 @@ virInterfaceObjPtr virInterfaceAssignDef(virInterfaceO= bjListPtr interfaces, =20 } =20 -void virInterfaceRemove(virInterfaceObjListPtr interfaces, - virInterfaceObjPtr iface) + +void +virInterfaceRemove(virInterfaceObjListPtr interfaces, + virInterfaceObjPtr iface) { size_t i; =20 --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 21:39:31 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) client-ip=209.132.183.37; envelope-from=libvir-list-bounces@redhat.com; helo=mx5-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) by mx.zohomail.com with SMTPS id 14886334586581011.2962371998624; Sat, 4 Mar 2017 05:17:38 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v24DDPXm056910; Sat, 4 Mar 2017 08:13:26 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v24DCgn3029285 for ; Sat, 4 Mar 2017 08:12:42 -0500 Received: from localhost.localdomain.com (ovpn-116-78.phx2.redhat.com [10.3.116.78]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v24DCe05009154 for ; Sat, 4 Mar 2017 08:12:42 -0500 From: John Ferlan To: libvir-list@redhat.com Date: Sat, 4 Mar 2017 08:12:34 -0500 Message-Id: <20170304131235.2057-4-jferlan@redhat.com> In-Reply-To: <20170304131235.2057-1-jferlan@redhat.com> References: <20170304131235.2057-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/4] conf: Use consistent function name prefixes for virinterfaceobj X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Use "virInterfaceObj" as a prefix for any external API in virinterfaceobj Signed-off-by: John Ferlan --- src/conf/virinterfaceobj.c | 24 ++++++++++++------------ src/conf/virinterfaceobj.h | 18 +++++++++--------- src/libvirt_private.syms | 8 ++++---- src/test/test_driver.c | 25 ++++++++++--------------- 4 files changed, 35 insertions(+), 40 deletions(-) diff --git a/src/conf/virinterfaceobj.c b/src/conf/virinterfaceobj.c index 70f9001..3af972b 100644 --- a/src/conf/virinterfaceobj.c +++ b/src/conf/virinterfaceobj.c @@ -64,9 +64,9 @@ virInterfaceObjFree(virInterfaceObjPtr iface) =20 /* virInterfaceObjList manipulation */ int -virInterfaceFindByMACString(virInterfaceObjListPtr interfaces, - const char *mac, - virInterfaceObjPtr *matches, int maxmatches) +virInterfaceObjFindByMACString(virInterfaceObjListPtr interfaces, + const char *mac, + virInterfaceObjPtr *matches, int maxmatches) { size_t i; unsigned int matchct =3D 0; @@ -91,8 +91,8 @@ virInterfaceFindByMACString(virInterfaceObjListPtr interf= aces, =20 =20 virInterfaceObjPtr -virInterfaceFindByName(virInterfaceObjListPtr interfaces, - const char *name) +virInterfaceObjFindByName(virInterfaceObjListPtr interfaces, + const char *name) { size_t i; =20 @@ -148,9 +148,9 @@ virInterfaceObjListClone(virInterfaceObjListPtr src, } =20 VIR_FREE(xml); - if ((iface =3D virInterfaceAssignDef(dest, backup)) =3D=3D NULL) + if ((iface =3D virInterfaceObjAssignDef(dest, backup)) =3D=3D NULL) goto cleanup; - virInterfaceObjUnlock(iface); /* was locked by virInterfaceAssignD= ef */ + virInterfaceObjUnlock(iface); /* locked by virInterfaceObjAssignDe= f */ } =20 ret =3D cnt; @@ -162,12 +162,12 @@ virInterfaceObjListClone(virInterfaceObjListPtr src, =20 =20 virInterfaceObjPtr -virInterfaceAssignDef(virInterfaceObjListPtr interfaces, - virInterfaceDefPtr def) +virInterfaceObjAssignDef(virInterfaceObjListPtr interfaces, + virInterfaceDefPtr def) { virInterfaceObjPtr iface; =20 - if ((iface =3D virInterfaceFindByName(interfaces, def->name))) { + if ((iface =3D virInterfaceObjFindByName(interfaces, def->name))) { virInterfaceDefFree(iface->def); iface->def =3D def; =20 @@ -197,8 +197,8 @@ virInterfaceAssignDef(virInterfaceObjListPtr interfaces, =20 =20 void -virInterfaceRemove(virInterfaceObjListPtr interfaces, - virInterfaceObjPtr iface) +virInterfaceObjRemove(virInterfaceObjListPtr interfaces, + virInterfaceObjPtr iface) { size_t i; =20 diff --git a/src/conf/virinterfaceobj.h b/src/conf/virinterfaceobj.h index 51d7c75..dfda748 100644 --- a/src/conf/virinterfaceobj.h +++ b/src/conf/virinterfaceobj.h @@ -44,11 +44,11 @@ virInterfaceObjIsActive(const virInterfaceObj *iface) return iface->active; } =20 -int virInterfaceFindByMACString(virInterfaceObjListPtr interfaces, - const char *mac, - virInterfaceObjPtr *matches, int maxmatche= s); -virInterfaceObjPtr virInterfaceFindByName(virInterfaceObjListPtr interface= s, - const char *name); +int virInterfaceObjFindByMACString(virInterfaceObjListPtr interfaces, + const char *mac, + virInterfaceObjPtr *matches, int maxmat= ches); +virInterfaceObjPtr virInterfaceObjFindByName(virInterfaceObjListPtr interf= aces, + const char *name); =20 =20 void virInterfaceObjFree(virInterfaceObjPtr iface); @@ -57,10 +57,10 @@ int virInterfaceObjListClone(virInterfaceObjListPtr src, virInterfaceObjListPtr dest); =20 =20 -virInterfaceObjPtr virInterfaceAssignDef(virInterfaceObjListPtr interfaces, - virInterfaceDefPtr def); -void virInterfaceRemove(virInterfaceObjListPtr interfaces, - virInterfaceObjPtr iface); +virInterfaceObjPtr virInterfaceObjAssignDef(virInterfaceObjListPtr interfa= ces, + virInterfaceDefPtr def); +void virInterfaceObjRemove(virInterfaceObjListPtr interfaces, + virInterfaceObjPtr iface); =20 void virInterfaceObjLock(virInterfaceObjPtr obj); void virInterfaceObjUnlock(virInterfaceObjPtr obj); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index b39e17d..2349ce0 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -941,14 +941,14 @@ virDomainObjListRename; =20 =20 # conf/virinterfaceobj.h -virInterfaceAssignDef; -virInterfaceFindByMACString; -virInterfaceFindByName; +virInterfaceObjAssignDef; +virInterfaceObjFindByMACString; +virInterfaceObjFindByName; virInterfaceObjListClone; virInterfaceObjListFree; virInterfaceObjLock; +virInterfaceObjRemove; virInterfaceObjUnlock; -virInterfaceRemove; =20 =20 # conf/virnodedeviceobj.h diff --git a/src/test/test_driver.c b/src/test/test_driver.c index e72a91f..2fd9776 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -1019,7 +1019,7 @@ testParseInterfaces(testDriverPtr privconn, if (!def) goto error; =20 - if (!(obj =3D virInterfaceAssignDef(&privconn->ifaces, def))) { + if (!(obj =3D virInterfaceObjAssignDef(&privconn->ifaces, def))) { virInterfaceDefFree(def); goto error; } @@ -3738,7 +3738,7 @@ static virInterfacePtr testInterfaceLookupByName(virC= onnectPtr conn, virInterfacePtr ret =3D NULL; =20 testDriverLock(privconn); - iface =3D virInterfaceFindByName(&privconn->ifaces, name); + iface =3D virInterfaceObjFindByName(&privconn->ifaces, name); testDriverUnlock(privconn); =20 if (iface =3D=3D NULL) { @@ -3763,7 +3763,7 @@ static virInterfacePtr testInterfaceLookupByMACString= (virConnectPtr conn, virInterfacePtr ret =3D NULL; =20 testDriverLock(privconn); - ifacect =3D virInterfaceFindByMACString(&privconn->ifaces, mac, &iface= , 1); + ifacect =3D virInterfaceObjFindByMACString(&privconn->ifaces, mac, &if= ace, 1); testDriverUnlock(privconn); =20 if (ifacect =3D=3D 0) { @@ -3791,7 +3791,7 @@ static int testInterfaceIsActive(virInterfacePtr ifac= e) int ret =3D -1; =20 testDriverLock(privconn); - obj =3D virInterfaceFindByName(&privconn->ifaces, iface->name); + obj =3D virInterfaceObjFindByName(&privconn->ifaces, iface->name); testDriverUnlock(privconn); if (!obj) { virReportError(VIR_ERR_NO_INTERFACE, NULL); @@ -3902,8 +3902,7 @@ static char *testInterfaceGetXMLDesc(virInterfacePtr = iface, virCheckFlags(0, NULL); =20 testDriverLock(privconn); - privinterface =3D virInterfaceFindByName(&privconn->ifaces, - iface->name); + privinterface =3D virInterfaceObjFindByName(&privconn->ifaces, iface->= name); testDriverUnlock(privconn); =20 if (privinterface =3D=3D NULL) { @@ -3934,7 +3933,7 @@ static virInterfacePtr testInterfaceDefineXML(virConn= ectPtr conn, const char *xm if ((def =3D virInterfaceDefParseString(xmlStr)) =3D=3D NULL) goto cleanup; =20 - if ((iface =3D virInterfaceAssignDef(&privconn->ifaces, def)) =3D=3D N= ULL) + if ((iface =3D virInterfaceObjAssignDef(&privconn->ifaces, def)) =3D= =3D NULL) goto cleanup; def =3D NULL; =20 @@ -3955,16 +3954,14 @@ static int testInterfaceUndefine(virInterfacePtr if= ace) int ret =3D -1; =20 testDriverLock(privconn); - privinterface =3D virInterfaceFindByName(&privconn->ifaces, - iface->name); + privinterface =3D virInterfaceObjFindByName(&privconn->ifaces, iface->= name); =20 if (privinterface =3D=3D NULL) { virReportError(VIR_ERR_NO_INTERFACE, NULL); goto cleanup; } =20 - virInterfaceRemove(&privconn->ifaces, - privinterface); + virInterfaceObjRemove(&privconn->ifaces, privinterface); ret =3D 0; =20 cleanup: @@ -3982,8 +3979,7 @@ static int testInterfaceCreate(virInterfacePtr iface, virCheckFlags(0, -1); =20 testDriverLock(privconn); - privinterface =3D virInterfaceFindByName(&privconn->ifaces, - iface->name); + privinterface =3D virInterfaceObjFindByName(&privconn->ifaces, iface->= name); =20 if (privinterface =3D=3D NULL) { virReportError(VIR_ERR_NO_INTERFACE, NULL); @@ -4015,8 +4011,7 @@ static int testInterfaceDestroy(virInterfacePtr iface, virCheckFlags(0, -1); =20 testDriverLock(privconn); - privinterface =3D virInterfaceFindByName(&privconn->ifaces, - iface->name); + privinterface =3D virInterfaceObjFindByName(&privconn->ifaces, iface->= name); =20 if (privinterface =3D=3D NULL) { virReportError(VIR_ERR_NO_INTERFACE, NULL); --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 21:39:31 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) client-ip=209.132.183.24; envelope-from=libvir-list-bounces@redhat.com; helo=mx3-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by mx.zohomail.com with SMTPS id 148863344091638.28546513296067; Sat, 4 Mar 2017 05:17:20 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v24DDOt4012111; Sat, 4 Mar 2017 08:13:24 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v24DChEs029295 for ; Sat, 4 Mar 2017 08:12:43 -0500 Received: from localhost.localdomain.com (ovpn-116-78.phx2.redhat.com [10.3.116.78]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v24DCe06009154 for ; Sat, 4 Mar 2017 08:12:42 -0500 From: John Ferlan To: libvir-list@redhat.com Date: Sat, 4 Mar 2017 08:12:35 -0500 Message-Id: <20170304131235.2057-5-jferlan@redhat.com> In-Reply-To: <20170304131235.2057-1-jferlan@redhat.com> References: <20170304131235.2057-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/4] conf: Alter coding style of interface function prototypes X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In an effort to be consistent with the source module, alter the function prototypes to follow the similar style of source with the "type" on one line followed by the function name and arguments on subsequent lines with with argument getting it's own line. Signed-off-by: John Ferlan --- src/conf/interface_conf.h | 19 ++++++++++++------ src/conf/virinterfaceobj.h | 48 ++++++++++++++++++++++++++++++------------= ---- 2 files changed, 44 insertions(+), 23 deletions(-) diff --git a/src/conf/interface_conf.h b/src/conf/interface_conf.h index 7325d65..76f37b6 100644 --- a/src/conf/interface_conf.h +++ b/src/conf/interface_conf.h @@ -161,14 +161,21 @@ struct _virInterfaceDef { virInterfaceProtocolDefPtr *protos; /* ptr to array of protos[nprotos]= */ }; =20 -void virInterfaceDefFree(virInterfaceDefPtr def); +void +virInterfaceDefFree(virInterfaceDefPtr def); =20 -virInterfaceDefPtr virInterfaceDefParseString(const char *xmlStr); -virInterfaceDefPtr virInterfaceDefParseFile(const char *filename); -virInterfaceDefPtr virInterfaceDefParseNode(xmlDocPtr xml, - xmlNodePtr root); +virInterfaceDefPtr +virInterfaceDefParseString(const char *xmlStr); =20 -char *virInterfaceDefFormat(const virInterfaceDef *def); +virInterfaceDefPtr +virInterfaceDefParseFile(const char *filename); + +virInterfaceDefPtr +virInterfaceDefParseNode(xmlDocPtr xml, + xmlNodePtr root); + +char * +virInterfaceDefFormat(const virInterfaceDef *def); =20 # define VIR_CONNECT_LIST_INTERFACES_FILTERS_ACTIVE \ (VIR_CONNECT_LIST_INTERFACES_ACTIVE | \ diff --git a/src/conf/virinterfaceobj.h b/src/conf/virinterfaceobj.h index dfda748..6c5e2e7 100644 --- a/src/conf/virinterfaceobj.h +++ b/src/conf/virinterfaceobj.h @@ -44,27 +44,41 @@ virInterfaceObjIsActive(const virInterfaceObj *iface) return iface->active; } =20 -int virInterfaceObjFindByMACString(virInterfaceObjListPtr interfaces, - const char *mac, - virInterfaceObjPtr *matches, int maxmat= ches); -virInterfaceObjPtr virInterfaceObjFindByName(virInterfaceObjListPtr interf= aces, - const char *name); +int +virInterfaceObjFindByMACString(virInterfaceObjListPtr interfaces, + const char *mac, + virInterfaceObjPtr *matches, int maxmatches= ); =20 +virInterfaceObjPtr +virInterfaceObjFindByName(virInterfaceObjListPtr interfaces, + const char *name); =20 -void virInterfaceObjFree(virInterfaceObjPtr iface); -void virInterfaceObjListFree(virInterfaceObjListPtr vms); -int virInterfaceObjListClone(virInterfaceObjListPtr src, - virInterfaceObjListPtr dest); +void +virInterfaceObjFree(virInterfaceObjPtr iface); =20 +void +virInterfaceObjListFree(virInterfaceObjListPtr vms); =20 -virInterfaceObjPtr virInterfaceObjAssignDef(virInterfaceObjListPtr interfa= ces, - virInterfaceDefPtr def); -void virInterfaceObjRemove(virInterfaceObjListPtr interfaces, - virInterfaceObjPtr iface); +int +virInterfaceObjListClone(virInterfaceObjListPtr src, + virInterfaceObjListPtr dest); =20 -void virInterfaceObjLock(virInterfaceObjPtr obj); -void virInterfaceObjUnlock(virInterfaceObjPtr obj); +virInterfaceObjPtr +virInterfaceObjAssignDef(virInterfaceObjListPtr interfaces, + virInterfaceDefPtr def); + +void +virInterfaceObjRemove(virInterfaceObjListPtr interfaces, + virInterfaceObjPtr iface); + +void +virInterfaceObjLock(virInterfaceObjPtr obj); + +void +virInterfaceObjUnlock(virInterfaceObjPtr obj); + +typedef bool +(*virInterfaceObjListFilter)(virConnectPtr conn, + virInterfaceDefPtr def); =20 -typedef bool (*virInterfaceObjListFilter)(virConnectPtr conn, - virInterfaceDefPtr def); #endif /* __VIRINTERFACEOBJ_H__ */ --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list