Discussion:
[libvirt] [libvirt-go PATCH] Add virDomainSetIOThreadParams binding
John Ferlan
2018-11-20 18:50:03 UTC
Permalink
Signed-off-by: John Ferlan <***@redhat.com>
---

Well I've given it a "go", hopefully it's (more or less) right. The build
and test at least pass ;-)

domain.go | 52 +++++++++++++++++++++++++++++++++++++++++++++++
domain_wrapper.go | 20 ++++++++++++++++++
domain_wrapper.h | 8 ++++++++
3 files changed, 80 insertions(+)

diff --git a/domain.go b/domain.go
index e011980..3a6811f 100644
--- a/domain.go
+++ b/domain.go
@@ -769,6 +769,7 @@ const (
DOMAIN_STATS_INTERFACE = DomainStatsTypes(C.VIR_DOMAIN_STATS_INTERFACE)
DOMAIN_STATS_BLOCK = DomainStatsTypes(C.VIR_DOMAIN_STATS_BLOCK)
DOMAIN_STATS_PERF = DomainStatsTypes(C.VIR_DOMAIN_STATS_PERF)
+ DOMAIN_STATS_IOTHREAD = DomainStatsTypes(C.VIR_DOMAIN_STATS_IOTHREAD)
)

type DomainCoreDumpFlags int
@@ -4207,6 +4208,57 @@ func (d *Domain) DelIOThread(id uint, flags DomainModificationImpact) error {
return nil
}

+// See also https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainSetIOThreadParams
+
+type DomainSetIOThreadParams struct {
+ PollMaxNsSet bool
+ PollMaxNs uint64
+ PollGrowSet bool
+ PollGrow uint
+ PollShrinkSet bool
+ PollShrink uint64
+}
+
+func getSetIOThreadParamsFieldInfo(params *DomainSetIOThreadParams) map[string]typedParamsFieldInfo {
+ return map[string]typedParamsFieldInfo{
+ C.VIR_DOMAIN_IOTHREAD_POLL_MAX_NS: typedParamsFieldInfo{
+ set: &params.PollMaxNsSet,
+ ul: &params.PollMaxNs,
+ },
+ C.VIR_DOMAIN_IOTHREAD_POLL_GROW: typedParamsFieldInfo{
+ set: &params.PollGrowSet,
+ ui: &params.PollGrow,
+ },
+ C.VIR_DOMAIN_IOTHREAD_POLL_SHRINK: typedParamsFieldInfo{
+ set: &params.PollShrinkSet,
+ ul: &params.PollShrink,
+ },
+ }
+}
+
+func (d *Domain) SetIOThreadParams(iothreadid uint, params *DomainSetIOThreadParams, flags DomainModificationImpact) error {
+ if C.LIBVIR_VERSION_NUMBER < 4010000 {
+ return makeNotImplementedError("virDomainSetIOThreadParams")
+ }
+ info := getSetIOThreadParamsFieldInfo(params)
+
+ cparams, gerr := typedParamsPackNew(info)
+ if gerr != nil {
+ return gerr
+ }
+ nparams := len(*cparams)
+
+ defer C.virTypedParamsClear((*C.virTypedParameter)(unsafe.Pointer(&(*cparams)[0])), C.int(nparams))
+
+ var err C.virError
+ ret := C.virDomainSetIOThreadParamsWrapper(d.ptr, C.uint(iothreadid), (*C.virTypedParameter)(unsafe.Pointer(&(*cparams)[0])), C.int(nparams), C.uint(flags), &err)
+ if ret == -1 {
+ return makeError(&err)
+ }
+
+ return nil
+}
+
// See also https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetEmulatorPinInfo
func (d *Domain) GetEmulatorPinInfo(flags DomainModificationImpact) ([]bool, error) {
var cnodeinfo C.virNodeInfo
diff --git a/domain_wrapper.go b/domain_wrapper.go
index b42dd42..f674bd5 100644
--- a/domain_wrapper.go
+++ b/domain_wrapper.go
@@ -1913,6 +1913,26 @@ virDomainSetGuestVcpusWrapper(virDomainPtr domain,
}


+int
+virDomainSetIOThreadParamsWrapper(virDomainPtr domain,
+ unsigned int iothread_id,
+ virTypedParameterPtr params,
+ int nparams,
+ unsigned int flags,
+ virErrorPtr err)
+{
+#if LIBVIR_VERSION_NUMBER < 4010000
+ assert(0); // Caller should have checked version
+#else
+ int ret = virDomainSetIOThreadParams(domain, iothread_id, params, nparams, flags);
+ if (ret < 0) {
+ virCopyLastError(err);
+ }
+ return ret;
+#endif
+}
+
+
int
virDomainSetInterfaceParametersWrapper(virDomainPtr domain,
const char *device,
diff --git a/domain_wrapper.h b/domain_wrapper.h
index 7bd8282..48a4cd3 100644
--- a/domain_wrapper.h
+++ b/domain_wrapper.h
@@ -813,6 +813,14 @@ virDomainSetGuestVcpusWrapper(virDomainPtr domain,
unsigned int flags,
virErrorPtr err);

+int
+virDomainSetIOThreadParamsWrapper(virDomainPtr domain,
+ unsigned int iothread_id,
+ virTypedParameterPtr params,
+ int nparams,
+ unsigned int flags,
+ virErrorPtr err);
+
int
virDomainSetInterfaceParametersWrapper(virDomainPtr domain,
const char *device,
--
2.17.2
Daniel P. Berrangé
2018-11-21 09:24:29 UTC
Permalink
Post by John Ferlan
---
Well I've given it a "go", hopefully it's (more or less) right. The build
and test at least pass ;-)
Code looks good apart from a data type mixup
Post by John Ferlan
domain.go | 52 +++++++++++++++++++++++++++++++++++++++++++++++
domain_wrapper.go | 20 ++++++++++++++++++
domain_wrapper.h | 8 ++++++++
3 files changed, 80 insertions(+)
diff --git a/domain.go b/domain.go
index e011980..3a6811f 100644
--- a/domain.go
+++ b/domain.go
@@ -769,6 +769,7 @@ const (
DOMAIN_STATS_INTERFACE = DomainStatsTypes(C.VIR_DOMAIN_STATS_INTERFACE)
DOMAIN_STATS_BLOCK = DomainStatsTypes(C.VIR_DOMAIN_STATS_BLOCK)
DOMAIN_STATS_PERF = DomainStatsTypes(C.VIR_DOMAIN_STATS_PERF)
+ DOMAIN_STATS_IOTHREAD = DomainStatsTypes(C.VIR_DOMAIN_STATS_IOTHREAD)
)
type DomainCoreDumpFlags int
@@ -4207,6 +4208,57 @@ func (d *Domain) DelIOThread(id uint, flags DomainModificationImpact) error {
return nil
}
+// See also https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainSetIOThreadParams
+
+type DomainSetIOThreadParams struct {
+ PollMaxNsSet bool
+ PollMaxNs uint64
+ PollGrowSet bool
+ PollGrow uint
+ PollShrinkSet bool
+ PollShrink uint64
+}
In the QEMU driver code, MAX_NS is a uint64 but GROW
and SHRINK are both uints, so this type is wrong.

Incidentally the data types should be mentioned in
the header file docs comments for the constants.
Post by John Ferlan
+
+func getSetIOThreadParamsFieldInfo(params *DomainSetIOThreadParams) map[string]typedParamsFieldInfo {
+ return map[string]typedParamsFieldInfo{
+ C.VIR_DOMAIN_IOTHREAD_POLL_MAX_NS: typedParamsFieldInfo{
+ set: &params.PollMaxNsSet,
+ ul: &params.PollMaxNs,
+ },
+ C.VIR_DOMAIN_IOTHREAD_POLL_GROW: typedParamsFieldInfo{
+ set: &params.PollGrowSet,
+ ui: &params.PollGrow,
+ },
+ C.VIR_DOMAIN_IOTHREAD_POLL_SHRINK: typedParamsFieldInfo{
+ set: &params.PollShrinkSet,
+ ul: &params.PollShrink,
+ },
And here s/ul/ui/
Post by John Ferlan
+ }
+}
If that is fixed

Reviewed-by: Daniel P. Berrangé <***@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 :|
Loading...