[libvirt] [PATCH v5 14/24] network: add public APIs for network port object
Laine Stump
laine at laine.org
Thu May 23 15:59:59 UTC 2019
On 5/14/19 11:48 AM, Daniel P. Berrangé wrote:
> Introduce a new virNetworPort object that will present an attachment to
> a virtual network from a VM.
>
> Signed-off-by: Daniel P. Berrangé <berrange at redhat.com>
> ---
> include/libvirt/libvirt-network.h | 122 ++++++++
> include/libvirt/virterror.h | 3 +
> src/datatypes.c | 60 ++++
> src/datatypes.h | 41 +++
> src/driver-network.h | 41 +++
> src/libvirt-network.c | 444 ++++++++++++++++++++++++++++++
> src/libvirt_private.syms | 2 +
> src/libvirt_public.syms | 15 +
> src/util/virerror.c | 9 +
> 9 files changed, 737 insertions(+)
>
> diff --git a/include/libvirt/libvirt-network.h b/include/libvirt/libvirt-network.h
> index 5115251fbe..97eceef754 100644
> --- a/include/libvirt/libvirt-network.h
> +++ b/include/libvirt/libvirt-network.h
> @@ -46,6 +46,22 @@ typedef struct _virNetwork virNetwork;
> */
> typedef virNetwork *virNetworkPtr;
>
> +/**
> + * virNetworkPort:
> + *
> + * a virNetworkPort is a private structure representing a virtual network
> + * port
> + */
> +typedef struct _virNetworkPort virNetworkPort;
> +
> +/**
> + * virNetworkPortPtr:
> + *
> + * a virNetworkPortPtr is pointer to a virNetworkPort private structure,
> + * this is the type used to reference a virtual network port in the API.
> + */
> +typedef virNetworkPort *virNetworkPortPtr;
> +
> /*
> * Get connection from network.
> */
> @@ -333,4 +349,110 @@ int virConnectNetworkEventRegisterAny(virConnectPtr conn,
> int virConnectNetworkEventDeregisterAny(virConnectPtr conn,
> int callbackID);
>
> +
> +virNetworkPortPtr
> +virNetworkPortLookupByUUID(virNetworkPtr net,
> + const unsigned char *uuid);
> +
> +virNetworkPortPtr
> +virNetworkPortLookupByUUIDString(virNetworkPtr net,
> + const char *uuidstr);
> +
> +typedef enum {
> + VIR_NETWORK_PORT_CREATE_RECLAIM = (1 << 0), /* reclaim existing used resources */
> +} virNetworkPortCreateFlags;
> +
> +virNetworkPortPtr
> +virNetworkPortCreateXML(virNetworkPtr net,
> + const char *xmldesc,
> + unsigned int flags);
So this is used as a replacement for both the Allocate and the Notify
functions that are currently there (via the RECLAIM flag).
> +
> +virNetworkPtr
> +virNetworkPortGetNetwork(virNetworkPortPtr port);
> +
> +char *
> +virNetworkPortGetXMLDesc(virNetworkPortPtr port,
> + unsigned int flags);
> +
> +int
> +virNetworkPortGetUUID(virNetworkPortPtr port,
> + unsigned char *uuid);
> +int
> +virNetworkPortGetUUIDString(virNetworkPortPtr port,
> + char *buf);
> +
> +/* Management of interface parameters */
> +
> +/**
> + * VIR_NETWORK_PORT_BANDWIDTH_IN_AVERAGE:
> + *
> + * Macro represents the inbound average of NIC bandwidth, as a uint.
> + */
> +# define VIR_NETWORK_PORT_BANDWIDTH_IN_AVERAGE "inbound.average"
> +
> +/**
> + * VIR_NETWORK_PORT_BANDWIDTH_IN_PEAK:
> + *
> + * Macro represents the inbound peak of NIC bandwidth, as a uint.
> + */
> +# define VIR_NETWORK_PORT_BANDWIDTH_IN_PEAK "inbound.peak"
> +
> +/**
> + * VIR_NETWORK_PORT_BANDWIDTH_IN_BURST:
> + *
> + * Macro represents the inbound burst of NIC bandwidth, as a uint.
> + */
> +# define VIR_NETWORK_PORT_BANDWIDTH_IN_BURST "inbound.burst"
> +
> +/**
> + * VIR_NETWORK_PORT_BANDWIDTH_IN_FLOOR:
> + *
> + * Macro represents the inbound floor of NIC bandwidth, as a uint.
> + */
> +# define VIR_NETWORK_PORT_BANDWIDTH_IN_FLOOR "inbound.floor"
> +
> +/**
> + * VIR_NETWORK_PORT_BANDWIDTH_OUT_AVERAGE:
> + *
> + * Macro represents the outbound average of NIC bandwidth, as a uint.
> + */
> +# define VIR_NETWORK_PORT_BANDWIDTH_OUT_AVERAGE "outbound.average"
> +
> +/**
> + * VIR_NETWORK_PORT_BANDWIDTH_OUT_PEAK:
> + *
> + * Macro represents the outbound peak of NIC bandwidth, as a uint.
> + */
> +# define VIR_NETWORK_PORT_BANDWIDTH_OUT_PEAK "outbound.peak"
> +
> +/**
> + * VIR_NETWORK_PORT_BANDWIDTH_OUT_BURST:
> + *
> + * Macro represents the outbound burst of NIC bandwidth, as a uint.
> + */
> +# define VIR_NETWORK_PORT_BANDWIDTH_OUT_BURST "outbound.burst"
> +
> +int
> +virNetworkPortSetParameters(virNetworkPortPtr port,
> + virTypedParameterPtr params,
> + int nparams,
> + unsigned int flags);
> +int
> +virNetworkPortGetParameters(virNetworkPortPtr port,
> + virTypedParameterPtr *params,
> + int *nparams,
> + unsigned int flags);
> +
> +int
> +virNetworkPortDelete(virNetworkPortPtr port,
> + unsigned int flags);
So you're following the pattern of nwfilter bindings here - using
...CreateXML and ...Delete. Makes sense, since they are similar concepts
(after getting past the initial automatic alarm bells due to using the
verb "Delete" rather than "Destroy" :-))
> [ tons more boilerplate... ]
> diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
> index dbce3336d5..c629528fbd 100644
> --- a/src/libvirt_public.syms
> +++ b/src/libvirt_public.syms
> @@ -819,4 +819,19 @@ LIBVIRT_5.2.0 {
> virConnectGetStoragePoolCapabilities;
> } LIBVIRT_4.10.0;
>
> +LIBVIRT_5.3.0 {
This needs to be 5.4.0, right?
Reviewed-by: Laine Stump <laine at laine.org>
(NB: Patches 05/24 - 13/24 already had my ack, and that stands (I'm
assuming that if you'd changed anything significant, you would have
removed the Reviewed-by: :-))
More information about the libvir-list
mailing list