Commit 2a80233c authored by Daniel P. Berrangé's avatar Daniel P. Berrangé

Add binding for virNetworkPortGetNetwork API

Signed-off-by: 's avatarDaniel P. Berrangé <berrange@redhat.com>
parent 1757705e
......@@ -28,6 +28,7 @@ package libvirt
/*
#cgo pkg-config: libvirt
#include <stdlib.h>
#include "network_wrapper.h"
#include "network_port_wrapper.h"
*/
import "C"
......@@ -74,6 +75,26 @@ func (c *NetworkPort) Ref() error {
return nil
}
// See also https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkPortGetNetwork
//
// Contrary to the native C API behaviour, the Go API will
// acquire a reference on the returned Network, which must
// be released by calling Free()
func (n *NetworkPort) GetNetwork() (*Network, error) {
var err C.virError
ptr := C.virNetworkPortGetNetworkWrapper(n.ptr, &err)
if ptr == nil {
return nil, makeError(&err)
}
ret := C.virNetworkRefWrapper(ptr, &err)
if ret == -1 {
return nil, makeError(&err)
}
return &Network{ptr: ptr}, nil
}
// See also https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkPortGetUUID
func (n *NetworkPort) GetUUID() ([]byte, error) {
if C.LIBVIR_VERSION_NUMBER < 5005000 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment