[libvirt] [libvirt-go PATCH 0/2] Add VIR_MIGRATE_PARAM_BANDWIDTH_POSTCOPY constant

Erik Skultety (2): Add VIR_MIGRATE_PARAM_BANDWIDTH_POSTCOPY constant Introduce DomainMigrateMaxSpeedFlags constant domain.go | 14 ++++++++++++-- domain_compat.h | 9 +++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) -- 2.20.1

Signed-off-by: Erik Skultety <eskultet@redhat.com> --- domain.go | 4 ++++ domain_compat.h | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/domain.go b/domain.go index 98dd290..f4546b8 100644 --- a/domain.go +++ b/domain.go @@ -2309,6 +2309,10 @@ func getMigrateParameterFieldInfo(params *DomainMigrateParameters) map[string]ty set: ¶ms.BandwidthSet, ul: ¶ms.Bandwidth, }, + C.VIR_MIGRATE_PARAM_BANDWIDTH_POSTCOPY: typedParamsFieldInfo{ + set: ¶ms.BandwidthSet, + ul: ¶ms.Bandwidth, + }, C.VIR_MIGRATE_PARAM_GRAPHICS_URI: typedParamsFieldInfo{ set: ¶ms.GraphicsURISet, s: ¶ms.GraphicsURI, diff --git a/domain_compat.h b/domain_compat.h index d869865..7589f41 100644 --- a/domain_compat.h +++ b/domain_compat.h @@ -939,4 +939,9 @@ struct _virDomainInterface { #define VIR_DOMAIN_JOB_MEMORY_POSTCOPY_REQS "memory_postcopy_requests" #endif +/* 5.1.0 */ +#ifndef VIR_MIGRATE_PARAM_BANDWIDTH_POSTCOPY +#define VIR_MIGRATE_PARAM_BANDWIDTH_POSTCOPY "bandwidth.postcopy" +#endif + #endif /* LIBVIRT_GO_DOMAIN_COMPAT_H__ */ -- 2.20.1

On Mon, Feb 11, 2019 at 04:11:54PM +0100, Erik Skultety wrote:
Signed-off-by: Erik Skultety <eskultet@redhat.com> --- domain.go | 4 ++++ domain_compat.h | 5 +++++ 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 :|

Also enforce the enum type for MigrateSetMaxSpeed and MigrateGetMaxSpeed functions which previously accepted generic uint32 type since the flags haven't been in use. Signed-off-by: Erik Skultety <eskultet@redhat.com> --- domain.go | 10 ++++++++-- domain_compat.h | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/domain.go b/domain.go index f4546b8..91b8399 100644 --- a/domain.go +++ b/domain.go @@ -811,6 +811,12 @@ const ( MIGRATE_TLS = DomainMigrateFlags(C.VIR_MIGRATE_TLS) ) +type DomainMigrateMaxSpeedFlags int + +const ( + MIGRATE_MAX_SPEED_POSTCOPY = DomainMigrateMaxSpeedFlags(C.VIR_DOMAIN_MIGRATE_MAX_SPEED_POSTCOPY) +) + type VcpuState int const ( @@ -2484,7 +2490,7 @@ func (d *Domain) MigrateSetCompressionCache(size uint64, flags uint32) error { } // See also https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainMigrateGetMaxS... -func (d *Domain) MigrateGetMaxSpeed(flags uint32) (uint64, error) { +func (d *Domain) MigrateGetMaxSpeed(flags DomainMigrateMaxSpeedFlags) (uint64, error) { var maxSpeed C.ulong var err C.virError @@ -2497,7 +2503,7 @@ func (d *Domain) MigrateGetMaxSpeed(flags uint32) (uint64, error) { } // See also https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainMigrateSetMaxS... -func (d *Domain) MigrateSetMaxSpeed(speed uint64, flags uint32) error { +func (d *Domain) MigrateSetMaxSpeed(speed uint64, flags DomainMigrateMaxSpeedFlags) error { var err C.virError ret := C.virDomainMigrateSetMaxSpeedWrapper(d.ptr, C.ulong(speed), C.uint(flags), &err) if ret == -1 { diff --git a/domain_compat.h b/domain_compat.h index 7589f41..9a30e8f 100644 --- a/domain_compat.h +++ b/domain_compat.h @@ -944,4 +944,8 @@ struct _virDomainInterface { #define VIR_MIGRATE_PARAM_BANDWIDTH_POSTCOPY "bandwidth.postcopy" #endif +#ifndef VIR_DOMAIN_MIGRATE_MAX_SPEED_POSTCOPY +#define VIR_DOMAIN_MIGRATE_MAX_SPEED_POSTCOPY (1 << 0) +#endif + #endif /* LIBVIRT_GO_DOMAIN_COMPAT_H__ */ -- 2.20.1

On Mon, Feb 11, 2019 at 04:11:55PM +0100, Erik Skultety wrote:
Also enforce the enum type for MigrateSetMaxSpeed and MigrateGetMaxSpeed functions which previously accepted generic uint32 type since the flags haven't been in use.
FWIW, Erik asked me about this change off-list. Technically changing the flags parameter from uint32 to the named enum type is considered an API incompatible change. In practice though, the flags parameter was unused in the past, so applications should normally have been passing an untyped '0' inline.eg dom.MigrateSetMaxSpeed(1024*1024, 0) Go will happily do type inference there, so with this change it will simply interpret '0' as being a value in the enum type. There should not be any compile breakage in this case. Where it could be a problem is if the app used an intermediate typed variable var flags uint32 flags = 0 dom.MigrateSetMaxSpeed(1024*1024, flags) This could conceivably affect some app, but I think it is fairly unlikely since there's no compelling reason for the app to have used a variable for flags given that it was unused. On balance with previous cases like this I took the view that it is preferrable to change the enum type so we get better type checking over the long term, despite this small risk/
Signed-off-by: Erik Skultety <eskultet@redhat.com> --- domain.go | 10 ++++++++-- domain_compat.h | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-)
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 Mon, Feb 11, 2019 at 03:23:31PM +0000, Daniel P. Berrangé wrote:
On Mon, Feb 11, 2019 at 04:11:55PM +0100, Erik Skultety wrote:
Also enforce the enum type for MigrateSetMaxSpeed and MigrateGetMaxSpeed functions which previously accepted generic uint32 type since the flags haven't been in use.
FWIW, Erik asked me about this change off-list.
Technically changing the flags parameter from uint32 to the named enum type is considered an API incompatible change. In practice though, the flags parameter was unused in the past, so applications should normally have been passing an untyped '0' inline.eg
dom.MigrateSetMaxSpeed(1024*1024, 0)
Go will happily do type inference there, so with this change it will simply interpret '0' as being a value in the enum type. There should not be any compile breakage in this case.
Where it could be a problem is if the app used an intermediate typed variable
var flags uint32 flags = 0 dom.MigrateSetMaxSpeed(1024*1024, flags)
This could conceivably affect some app, but I think it is fairly unlikely since there's no compelling reason for the app to have used a variable for flags given that it was unused. On balance with previous cases like this I took the view that it is preferrable to change the enum type so we get better type checking over the long term, despite this small risk/
I'll include this in the commit message so that it doesn't get lost on the list and is easier to be found. Thanks, Erik
participants (2)
-
Daniel P. Berrangé
-
Erik Skultety