[libvirt] [go PATCH 0/2] add missing API and constants

Pavel Hrdina (2): Add VIR_FROM_BPF error constant Add support for virDomainAgentSetResponseTimeout API domain.go | 23 +++++++++++++++++++++++ domain_compat.h | 14 ++++++++++++++ domain_wrapper.go | 17 +++++++++++++++++ domain_wrapper.h | 6 ++++++ error.go | 3 +++ error_compat.h | 6 ++++++ 6 files changed, 69 insertions(+) -- 2.23.0

Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- error.go | 3 +++ error_compat.h | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/error.go b/error.go index d6b02e0..4b057fb 100644 --- a/error.go +++ b/error.go @@ -596,6 +596,9 @@ const ( // Error from TPM FROM_TPM = ErrorDomain(C.VIR_FROM_TPM) + + // Error from BPF + FROM_BPF = ErrorDomain(C.VIR_FROM_BPF) ) type Error struct { diff --git a/error_compat.h b/error_compat.h index 6727a0d..0383925 100644 --- a/error_compat.h +++ b/error_compat.h @@ -207,4 +207,10 @@ #define VIR_FROM_TPM 70 #endif +/* 5.10.0 */ + +#ifndef VIR_FROM_BPF +#define VIR_FROM_BPF 71 +#endif + #endif /* LIBVIRT_GO_ERROR_COMPAT_H__ */ -- 2.23.0

On Thu, Nov 28, 2019 at 11:30:31AM +0100, Pavel Hrdina wrote:
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- error.go | 3 +++ error_compat.h | 6 ++++++ 2 files changed, 9 insertions(+)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- domain.go | 23 +++++++++++++++++++++++ domain_compat.h | 14 ++++++++++++++ domain_wrapper.go | 17 +++++++++++++++++ domain_wrapper.h | 6 ++++++ 4 files changed, 60 insertions(+) diff --git a/domain.go b/domain.go index 360659d..7901d8d 100644 --- a/domain.go +++ b/domain.go @@ -886,6 +886,14 @@ const ( DOMAIN_GUEST_INFO_FILESYSTEM = DomainGuestInfoTypes(C.VIR_DOMAIN_GUEST_INFO_FILESYSTEM) ) +type DomainAgentSetResponseTimeoutValues int + +const ( + VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_BLOCK = DomainAgentSetResponseTimeoutValues(C.VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_BLOCK) + VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_DEFAULT = DomainAgentSetResponseTimeoutValues(C.VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_DEFAULT) + VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_NOWAIT = DomainAgentSetResponseTimeoutValues(C.VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_NOWAIT) +) + // See also https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainFree func (d *Domain) Free() error { var err C.virError @@ -5179,3 +5187,18 @@ func (d *Domain) GetGuestInfo(types DomainGuestInfoTypes, flags uint32) (*Domain return &info, nil } + +// See also https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainAgentSetRespon... +func (d *Domain) AgentSetResponseTimeout(timeout int, flags uint32) error { + if C.LIBVIR_VERSION_NUMBER < 5010000 { + return makeNotImplementedError("virDomainAgentSetResponseTimeout") + } + + var err C.virError + ret := C.virDomainAgentSetResponseTimeoutWrapper(d.ptr, C.int(timeout), C.uint(flags), &err) + if ret == -1 { + return makeError(&err) + } + + return nil +} diff --git a/domain_compat.h b/domain_compat.h index 98cf5e1..3b91b15 100644 --- a/domain_compat.h +++ b/domain_compat.h @@ -1006,4 +1006,18 @@ struct _virDomainInterface { #define VIR_DOMAIN_GUEST_INFO_FILESYSTEM (1 << 4) #endif +/* 5.10.0 */ + +#ifndef VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_BLOCK +#define VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_BLOCK -2 +#endif + +#ifndef VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_DEFAULT +#define VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_DEFAULT -1 +#endif + +#ifndef VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_NOWAIT +#define VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_NOWAIT 0 +#endif + #endif /* LIBVIRT_GO_DOMAIN_COMPAT_H__ */ diff --git a/domain_wrapper.go b/domain_wrapper.go index 0f521cb..63573c3 100644 --- a/domain_wrapper.go +++ b/domain_wrapper.go @@ -2419,5 +2419,22 @@ virDomainGetGuestInfoWrapper(virDomainPtr domain, #endif } +int +virDomainAgentSetResponseTimeoutWrapper(virDomainPtr domain, + int timeout, + unsigned int flags, + virErrorPtr err) +{ +#if LIBVIR_VERSION_NUMBER < 5010000 + assert(0); // Caller should have checked version +#else + int ret = virDomainAgentSetResponseTimeout(domain, timeout, flags); + if (ret < 0) { + virCopyLastError(err); + } + return ret; +#endif +} + */ import "C" diff --git a/domain_wrapper.h b/domain_wrapper.h index 61b63bb..568910e 100644 --- a/domain_wrapper.h +++ b/domain_wrapper.h @@ -1017,4 +1017,10 @@ virDomainGetGuestInfoWrapper(virDomainPtr domain, unsigned int flags, virErrorPtr err); +int +virDomainAgentSetResponseTimeoutWrapper(virDomainPtr domain, + int timeout, + unsigned int flags, + virErrorPtr err); + #endif /* LIBVIRT_GO_DOMAIN_WRAPPER_H__ */ -- 2.23.0

On Thu, Nov 28, 2019 at 11:30:32AM +0100, Pavel Hrdina wrote:
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- domain.go | 23 +++++++++++++++++++++++ domain_compat.h | 14 ++++++++++++++ domain_wrapper.go | 17 +++++++++++++++++ domain_wrapper.h | 6 ++++++ 4 files changed, 60 insertions(+)
diff --git a/domain.go b/domain.go index 360659d..7901d8d 100644 --- a/domain.go +++ b/domain.go @@ -886,6 +886,14 @@ const ( DOMAIN_GUEST_INFO_FILESYSTEM = DomainGuestInfoTypes(C.VIR_DOMAIN_GUEST_INFO_FILESYSTEM) )
+type DomainAgentSetResponseTimeoutValues int + +const ( + VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_BLOCK = DomainAgentSetResponseTimeoutValues(C.VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_BLOCK) + VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_DEFAULT = DomainAgentSetResponseTimeoutValues(C.VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_DEFAULT) + VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_NOWAIT = DomainAgentSetResponseTimeoutValues(C.VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_NOWAIT) +)
At the Go level the constants shouldn't have any VIR_ prefix, as they're already within the 'libvirt' package namespace. If you strip those then Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

On Thu, Nov 28, 2019 at 10:42:06AM +0000, Daniel P. Berrangé wrote:
On Thu, Nov 28, 2019 at 11:30:32AM +0100, Pavel Hrdina wrote:
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- domain.go | 23 +++++++++++++++++++++++ domain_compat.h | 14 ++++++++++++++ domain_wrapper.go | 17 +++++++++++++++++ domain_wrapper.h | 6 ++++++ 4 files changed, 60 insertions(+)
diff --git a/domain.go b/domain.go index 360659d..7901d8d 100644 --- a/domain.go +++ b/domain.go @@ -886,6 +886,14 @@ const ( DOMAIN_GUEST_INFO_FILESYSTEM = DomainGuestInfoTypes(C.VIR_DOMAIN_GUEST_INFO_FILESYSTEM) )
+type DomainAgentSetResponseTimeoutValues int + +const ( + VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_BLOCK = DomainAgentSetResponseTimeoutValues(C.VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_BLOCK) + VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_DEFAULT = DomainAgentSetResponseTimeoutValues(C.VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_DEFAULT) + VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_NOWAIT = DomainAgentSetResponseTimeoutValues(C.VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_NOWAIT) +)
At the Go level the constants shouldn't have any VIR_ prefix, as they're already within the 'libvirt' package namespace.
If you strip those then
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Fixed and pushed, thanks. Pavel
participants (2)
-
Daniel P. Berrangé
-
Pavel Hrdina