[libvirt] [libvirt-go PATCH 3/3] Enforce new flags types in DomainSaveImageGetXMLDesc and GetXMLDesc

Erik Skultety posted 3 patches 6 years, 11 months ago
[libvirt] [libvirt-go PATCH 3/3] Enforce new flags types in DomainSaveImageGetXMLDesc and GetXMLDesc
Posted by Erik Skultety 6 years, 11 months ago
This breaks API compatibility! Recently libvirt introduced 2 new
separate flag enums in order to stop recycling the old virDomainXMLFlags
since 2/3 flags were discouraged to use. While it's fine for libvirt
to introduce such a change since it uses plain 'int' for flags, not so
much for the Go bindings which already enforced the now deprecated
DomainXMLFlags type.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
---
 connect.go         | 2 +-
 domain_snapshot.go | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/connect.go b/connect.go
index f77d10d..0d5118c 100644
--- a/connect.go
+++ b/connect.go
@@ -2038,7 +2038,7 @@ func (c *Connect) DomainSaveImageDefineXML(file string, xml string, flags Domain
 }
 
 // See also https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainSaveImageGetXMLDesc
-func (c *Connect) DomainSaveImageGetXMLDesc(file string, flags DomainXMLFlags) (string, error) {
+func (c *Connect) DomainSaveImageGetXMLDesc(file string, flags DomainSaveImageXMLFlags) (string, error) {
 	cfile := C.CString(file)
 	defer C.free(unsafe.Pointer(cfile))
 
diff --git a/domain_snapshot.go b/domain_snapshot.go
index 86c7c51..282217f 100644
--- a/domain_snapshot.go
+++ b/domain_snapshot.go
@@ -161,7 +161,7 @@ func (s *DomainSnapshot) HasMetadata(flags uint32) (bool, error) {
 }
 
 // See also https://libvirt.org/html/libvirt-libvirt-domain-snapshot.html#virDomainSnapshotGetXMLDesc
-func (s *DomainSnapshot) GetXMLDesc(flags DomainXMLFlags) (string, error) {
+func (s *DomainSnapshot) GetXMLDesc(flags DomainSnapshotXMLFlags) (string, error) {
 	var err C.virError
 	result := C.virDomainSnapshotGetXMLDescWrapper(s.ptr, C.uint(flags), &err)
 	if result == nil {
-- 
2.20.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [libvirt-go PATCH 3/3] Enforce new flags types in DomainSaveImageGetXMLDesc and GetXMLDesc
Posted by Eric Blake 6 years, 11 months ago
On 2/22/19 9:32 AM, Erik Skultety wrote:
> This breaks API compatibility! Recently libvirt introduced 2 new
> separate flag enums in order to stop recycling the old virDomainXMLFlags
> since 2/3 flags were discouraged to use. While it's fine for libvirt
> to introduce such a change since it uses plain 'int' for flags, not so
> much for the Go bindings which already enforced the now deprecated
> DomainXMLFlags type.

And a quick google search says that Go lacks function overloading (use
of variadic functions to provide optional arguments being as much as it
is willing to support).  Can you declare some sort of meta-type which is
a union between the old enum and new enum types, where you can pass in
either enum value and still satisfy the function type?  Otherwise, I
don't know Go well enough to make any suggestions on how to avoid the
API break.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list