[libvirt-go PATCH] Add virDomainSetIOThreadParams binding

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 
 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

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



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux