Commit Graph

17 Commits

Author SHA1 Message Date
Michal Privoznik
10c68f5dd4 virInterfaceObjListAssignDef: Transfer definition ownership
Upon successful return from virInterfaceObjListAssignDef() the
virInterfaceObj is the owner of secret definition. To make this
ownership transfer even more visible, lets pass the definition as
a double pointer and use g_steal_pointer().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-11-24 13:12:20 +01:00
Michal Privoznik
c8238579fb lib: Drop internal virXXXPtr typedefs
Historically, we declared pointer type to our types:

  typedef struct _virXXX virXXX;
  typedef virXXX *virXXXPtr;

But usefulness of such declaration is questionable, at best.
Unfortunately, we can't drop every such declaration - we have to
carry some over, because they are part of public API (e.g.
virDomainPtr). But for internal types - we can do drop them and
use what every other C project uses 'virXXX *'.

This change was generated by a very ugly shell script that
generated sed script which was then called over each file in the
repository. For the shell script refer to the cover letter:

https://listman.redhat.com/archives/libvir-list/2021-March/msg00537.html

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-04-13 17:00:38 +02:00
Jonathon Jongsma
222e0f0f08 conf: misc: use #pragma once in headers
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-06-13 17:05:09 +02:00
Daniel P. Berrangé
568a417224 Enforce a standard header file guard symbol name
Require that all headers are guarded by a symbol named

  LIBVIRT_$FILENAME

where $FILENAME is the uppercased filename, with all characters
outside a-z changed into '_'.

Note we do not use a leading __ because that is technically a
namespace reserved for the toolchain.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-12-14 10:47:13 +00:00
Cole Robinson
a33e20c734 test: Implement virConnectListAllInterfaces
This adds some generic virinterfaceobj code, roughly matching what
is used by other stateful drivers like network, storage, etc.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2018-07-19 09:47:01 -04:00
John Ferlan
4102e22864 interface: Make _virInterfaceObjList virObjectRWLockable
Modify the allocation to be a real RWLockable object and add the
various RWLock{Read|Write} and RWUnlock calls to process the list
of interfaces.
2017-10-19 15:39:44 -04:00
John Ferlan
46f5eca4b2 interface: Convert virInterfaceObj to use virObjectLockable
Now that we have a bit more control, let's convert our object into
a lockable object and let that magic handle the create and lock/unlock.

This commit also introduces virInterfaceObjEndAPI in order to handle the
lock unlock and object unref in one call for consumers returning a NULL
obj upon return. This removes the need for virInterfaceObj{Lock|Unlock}
external API's.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-06-06 12:05:00 -04:00
John Ferlan
9c9a12ca31 interface: Clean up virInterfaceObjListFindByMACString
Alter the algorithm to return a list of matching names rather than a
list of match virInterfaceObjPtr which are then just dereferenced
extracting the def->name and def->mac. Since the def->mac would be
the same as the passed @mac, just return a list of names and as long
as there's only one, extract the [0] entry from the passed list.
Also alter the error message on failure to include the mac that wasn't
found.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-06-02 15:50:14 -04:00
John Ferlan
e2f3e6c38e interface: Rename some virInterfaceObj* API's
Prefix should have been virInterfaceObjList since the API is operating
on the list of interfaces.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-06-02 15:50:14 -04:00
John Ferlan
5374a1ca80 interface: Make _virInterfaceObjList struct private
Move the structs into virinterfaceobj.c, create necessary accessors, and
initializers.

This also includes reworking virInterfaceObjListClone to handle receiving
a source interfaces list pointer, creating the destination interfaces object,
and copying everything from source into dest.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-06-02 15:50:14 -04:00
John Ferlan
3b6de6c0cb interface: Make _virInterfaceObj struct private
Move the struct into virinterfaceobj.c, create necessary accessors, and
initializers.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-06-02 15:50:14 -04:00
John Ferlan
3a18ee91b7 interface: Consistently use 'obj' for a virInterfaceObjPtr
Alter variable names to be obj rather than 'iface' and/or 'obj'.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-06-02 15:50:14 -04:00
John Ferlan
a9d33be34e interface: Introduce virInterfaceObjGetNames
Unlike other drivers, this is a test driver only API. Still combining
the logic of testConnectListInterfaces and testConnectListDefinedInterfaces
makes things a bit easier in the long run.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-04-10 07:30:00 -04:00
John Ferlan
7dc4513808 interface: Introduce virInterfaceObjNumOfInterfaces
Unlike other drivers, this is a test driver only API. Still combining
the logic of testConnectNumOfInterfaces and testConnectNumOfDefinedInterfaces
makes things a bit easier in the long run.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-04-10 07:30:00 -04:00
John Ferlan
5adbbdc173 conf: Alter coding style of interface function prototypes
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.
2017-03-06 07:07:01 -05:00
John Ferlan
e858232e4d conf: Use consistent function name prefixes for virinterfaceobj
Use "virInterfaceObj" as a prefix for any external API in virinterfaceobj
2017-03-06 07:07:01 -05:00
John Ferlan
eabeff8ea3 conf: Introduce virinterfaceobj
Move all the InterfaceObj API's into their own module virinterfaceobj
from the interface_conf

Purely code motion at this point.
2017-03-06 07:07:01 -05:00