Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:dirkmueller:acdc:as_python3_module
kubevirt
0004-Update-libvirt-go-to-fix-memory-leak.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0004-Update-libvirt-go-to-fix-memory-leak.patch of Package kubevirt
From 9ca2790f503f51fa16bb571dec978ca33eb0308e Mon Sep 17 00:00:00 2001 From: "L. Pivarc" <lpivarc@redhat.com> Date: Tue, 2 Aug 2022 20:25:29 +0200 Subject: [PATCH] Update libvirt-go to fix memory leak For more info see https://gitlab.com/libvirt/libvirt-go-module/-/merge_requests/33 Signed-off-by: L. Pivarc <lpivarc@redhat.com> --- go.mod | 2 +- go.sum | 4 +- vendor/libvirt.org/go/libvirt/.gitlab-ci.yml | 4 +- vendor/libvirt.org/go/libvirt/connect.go | 35 +++- .../libvirt.org/go/libvirt/connect_compat.h | 6 + .../libvirt.org/go/libvirt/connect_wrapper.go | 30 ++++ .../libvirt.org/go/libvirt/connect_wrapper.h | 10 ++ vendor/libvirt.org/go/libvirt/domain.go | 158 ++++++++++++++---- vendor/libvirt.org/go/libvirt/domain_compat.h | 69 ++++++++ .../libvirt.org/go/libvirt/domain_snapshot.go | 7 +- .../go/libvirt/domain_snapshot_compat.h | 7 + .../libvirt.org/go/libvirt/domain_wrapper.go | 36 ++++ .../libvirt.org/go/libvirt/domain_wrapper.h | 12 ++ vendor/libvirt.org/go/libvirt/error.go | 1 - vendor/libvirt.org/go/libvirt/events.go | 19 ++- vendor/libvirt.org/go/libvirt/qemu.go | 40 +++++ vendor/libvirt.org/go/libvirt/qemu_wrapper.go | 23 +++ vendor/libvirt.org/go/libvirt/qemu_wrapper.h | 11 ++ vendor/libvirt.org/go/libvirt/typedparams.go | 5 + vendor/modules.txt | 2 +- 20 files changed, 433 insertions(+), 48 deletions(-) diff --git a/go.mod b/go.mod index 1ca93ba9a..529edf0cb 100644 --- a/go.mod +++ b/go.mod @@ -77,7 +77,7 @@ require ( kubevirt.io/containerized-data-importer-api v1.47.0 kubevirt.io/controller-lifecycle-operator-sdk v0.2.2 kubevirt.io/qe-tools v0.1.8 - libvirt.org/go/libvirt v1.8000.0 + libvirt.org/go/libvirt v1.8006.0 mvdan.cc/sh/v3 v3.1.1 sigs.k8s.io/yaml v1.3.0 ) diff --git a/go.sum b/go.sum index 1a5ebddb8..76d15cc32 100644 --- a/go.sum +++ b/go.sum @@ -2072,8 +2072,8 @@ kubevirt.io/controller-lifecycle-operator-sdk/api v0.0.0-20220329064328-f3cc58c6 kubevirt.io/qe-tools v0.1.6/go.mod h1:PJyH/YXC4W0AmxfheDmXWMbLNsMSboVGXKpMAwfKzVE= kubevirt.io/qe-tools v0.1.8 h1:Ar7qicmzHdd+Ia+6rjHDg3D7GReIyq7QFXoC4F7TjhQ= kubevirt.io/qe-tools v0.1.8/go.mod h1:+Tr/WZGHIDQa/4pQgzM7+4J6YeVbUWAXESXtL2/zxqc= -libvirt.org/go/libvirt v1.8000.0 h1:1sOyBCZA7t0xHrih3lF3h3CFDAlZFaulIzFtNDVtnW0= -libvirt.org/go/libvirt v1.8000.0/go.mod h1:1WiFE8EjZfq+FCVog+rvr1yatKbKZ9FaFMZgEqxEJqQ= +libvirt.org/go/libvirt v1.8006.0 h1:VtHRGSMAXjLzVFnaXqZLNTV9pZT6GOT94ai6JMVbU4E= +libvirt.org/go/libvirt v1.8006.0/go.mod h1:1WiFE8EjZfq+FCVog+rvr1yatKbKZ9FaFMZgEqxEJqQ= mvdan.cc/editorconfig v0.1.1-0.20200121172147-e40951bde157 h1:VBYz8greWWP8BDpRX0v7SDv/8rNlZVmdHdO4ZSsHj/E= mvdan.cc/editorconfig v0.1.1-0.20200121172147-e40951bde157/go.mod h1:Ge4atmRUYqueGppvJ7JNrtqpqokoJEFxYbP0Z+WeKS8= mvdan.cc/sh/v3 v3.1.1 h1:niuYC5Ug0KzLuN6CNX3ru37v4MkVD5Wm9T4Mk2eJr9A= diff --git a/vendor/libvirt.org/go/libvirt/.gitlab-ci.yml b/vendor/libvirt.org/go/libvirt/.gitlab-ci.yml index 0edbcd40e..c96c88415 100644 --- a/vendor/libvirt.org/go/libvirt/.gitlab-ci.yml +++ b/vendor/libvirt.org/go/libvirt/.gitlab-ci.yml @@ -38,10 +38,10 @@ stages: include: '/ci/gitlab.yml' api-coverage: - image: $CI_REGISTRY_IMAGE/ci-centos-8:latest + image: $CI_REGISTRY_IMAGE/ci-almalinux-8:latest stage: sanity_checks needs: - - job: x86_64-centos-8-git + - job: x86_64-almalinux-8-git artifacts: true before_script: - *git_build_vars diff --git a/vendor/libvirt.org/go/libvirt/connect.go b/vendor/libvirt.org/go/libvirt/connect.go index 5736919cf..0289f677a 100644 --- a/vendor/libvirt.org/go/libvirt/connect.go +++ b/vendor/libvirt.org/go/libvirt/connect.go @@ -41,10 +41,6 @@ import ( */ import "C" -func init() { - C.virInitialize() -} - const ( VERSION_NUMBER = uint32(C.LIBVIR_VERSION_NUMBER) ) @@ -2495,6 +2491,27 @@ func (c *Connect) DomainRestoreFlags(srcFile, xmlConf string, flags DomainSaveRe return nil } +// See also https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainRestoreParams +func (c *Connect) DomainRestoreParams(params DomainSaveRestoreParams, flags DomainSaveRestoreFlags) error { + if C.LIBVIR_VERSION_NUMBER < 8004000 { + return makeNotImplementedError("virDomainRestoreParams") + } + + info := getDomainSaveRestoreParametersFieldInfo(¶ms) + cparams, cnparams, gerr := typedParamsPackNew(info) + if gerr != nil { + return gerr + } + + defer C.virTypedParamsFree(cparams, cnparams) + + var err C.virError + if result := C.virDomainRestoreParamsWrapper(c.ptr, cparams, cnparams, C.uint(flags), &err); result == -1 { + return makeError(&err) + } + return nil +} + // See also https://libvirt.org/html/libvirt-libvirt-stream.html#virStreamNew func (c *Connect) NewStream(flags StreamFlags) (*Stream, error) { var err C.virError @@ -3052,7 +3069,7 @@ func getDomainStatsMemoryBandwidthMonitorNodeFieldInfo(idx1, idx2 int, params *D type DomainStatsDirtyRate struct { CalcStatusSet bool - CalcStatus uint + CalcStatus int CalcStartTimeSet bool CalcStartTime int64 CalcPeriodSet bool @@ -3065,7 +3082,7 @@ func getDomainStatsDirtyRateFieldInfo(params *DomainStatsDirtyRate) map[string]t return map[string]typedParamsFieldInfo{ "dirtyrate.calc_status": typedParamsFieldInfo{ set: ¶ms.CalcStatusSet, - ui: ¶ms.CalcStatus, + i: ¶ms.CalcStatus, }, "dirtyrate.calc_start_time": typedParamsFieldInfo{ set: ¶ms.CalcStartTimeSet, @@ -3360,6 +3377,8 @@ type NodeSEVParameters struct { MaxGuests uint MaxEsGuestsSet bool MaxEsGuests uint + CPU0IDSet bool + CPU0ID string } func getNodeSEVFieldInfo(params *NodeSEVParameters) map[string]typedParamsFieldInfo { @@ -3388,6 +3407,10 @@ func getNodeSEVFieldInfo(params *NodeSEVParameters) map[string]typedParamsFieldI set: ¶ms.MaxEsGuestsSet, ui: ¶ms.MaxEsGuests, }, + C.VIR_NODE_SEV_CPU0_ID: typedParamsFieldInfo{ + set: ¶ms.CPU0IDSet, + s: ¶ms.CPU0ID, + }, } } diff --git a/vendor/libvirt.org/go/libvirt/connect_compat.h b/vendor/libvirt.org/go/libvirt/connect_compat.h index 5b89c6fd7..752bbb273 100644 --- a/vendor/libvirt.org/go/libvirt/connect_compat.h +++ b/vendor/libvirt.org/go/libvirt/connect_compat.h @@ -310,5 +310,11 @@ typedef struct _virNWFilterBinding *virNWFilterBindingPtr; #define VIR_NODE_SEV_MAX_ES_GUESTS "max-es-guests" #endif +/* 8.4.0 */ + +#ifndef VIR_NODE_SEV_CPU0_ID +#define VIR_NODE_SEV_CPU0_ID "cpu0-id" +#endif + #endif /* LIBVIRT_GO_CONNECT_COMPAT_H__ */ diff --git a/vendor/libvirt.org/go/libvirt/connect_wrapper.go b/vendor/libvirt.org/go/libvirt/connect_wrapper.go index 31e9b560e..87ace576f 100644 --- a/vendor/libvirt.org/go/libvirt/connect_wrapper.go +++ b/vendor/libvirt.org/go/libvirt/connect_wrapper.go @@ -33,6 +33,17 @@ package libvirt #include "connect_wrapper.h" #include "callbacks_wrapper.h" +int +virInitializeWrapper(virErrorPtr err) +{ + int ret = virInitialize(); + if (ret < 0) { + virCopyLastError(err); + } + return ret; +} + + extern void closeCallback(virConnectPtr, int, long); void closeCallbackHelper(virConnectPtr conn, int reason, void *opaque) { @@ -1030,6 +1041,25 @@ virDomainRestoreFlagsWrapper(virConnectPtr conn, } +int +virDomainRestoreParamsWrapper(virConnectPtr conn, + virTypedParameterPtr params, + int nparams, + unsigned int flags, + virErrorPtr err) +{ +#if LIBVIR_VERSION_NUMBER < 8004000 + assert(0); // Caller should have checked version +#else + int ret = virDomainRestoreParams(conn, params, nparams, flags); + if (ret < 0) { + virCopyLastError(err); + } + return ret; +#endif +} + + int virDomainSaveImageDefineXMLWrapper(virConnectPtr conn, const char *file, diff --git a/vendor/libvirt.org/go/libvirt/connect_wrapper.h b/vendor/libvirt.org/go/libvirt/connect_wrapper.h index 35a6df1d7..93bba58ab 100644 --- a/vendor/libvirt.org/go/libvirt/connect_wrapper.h +++ b/vendor/libvirt.org/go/libvirt/connect_wrapper.h @@ -31,6 +31,9 @@ #include <libvirt/virterror.h> #include "connect_compat.h" +int +virInitializeWrapper(virErrorPtr err); + void closeCallbackHelper(virConnectPtr conn, int reason, @@ -429,6 +432,13 @@ virDomainRestoreFlagsWrapper(virConnectPtr conn, unsigned int flags, virErrorPtr err); +int +virDomainRestoreParamsWrapper(virConnectPtr conn, + virTypedParameterPtr params, + int nparams, + unsigned int flags, + virErrorPtr err); + int virDomainSaveImageDefineXMLWrapper(virConnectPtr conn, const char *file, diff --git a/vendor/libvirt.org/go/libvirt/domain.go b/vendor/libvirt.org/go/libvirt/domain.go index be74a6cc6..ec5cbdd52 100644 --- a/vendor/libvirt.org/go/libvirt/domain.go +++ b/vendor/libvirt.org/go/libvirt/domain.go @@ -99,8 +99,9 @@ const ( type DomainDestroyFlags uint const ( - DOMAIN_DESTROY_DEFAULT = DomainDestroyFlags(C.VIR_DOMAIN_DESTROY_DEFAULT) - DOMAIN_DESTROY_GRACEFUL = DomainDestroyFlags(C.VIR_DOMAIN_DESTROY_GRACEFUL) + DOMAIN_DESTROY_DEFAULT = DomainDestroyFlags(C.VIR_DOMAIN_DESTROY_DEFAULT) + DOMAIN_DESTROY_GRACEFUL = DomainDestroyFlags(C.VIR_DOMAIN_DESTROY_GRACEFUL) + DOMAIN_DESTROY_REMOVE_LOGS = DomainDestroyFlags(C.VIR_DOMAIN_DESTROY_REMOVE_LOGS) ) type DomainShutdownFlags uint @@ -142,6 +143,7 @@ const ( DOMAIN_START_BYPASS_CACHE = DomainCreateFlags(C.VIR_DOMAIN_START_BYPASS_CACHE) DOMAIN_START_FORCE_BOOT = DomainCreateFlags(C.VIR_DOMAIN_START_FORCE_BOOT) DOMAIN_START_VALIDATE = DomainCreateFlags(C.VIR_DOMAIN_START_VALIDATE) + DOMAIN_START_RESET_NVRAM = DomainCreateFlags(C.VIR_DOMAIN_START_RESET_NVRAM) ) const DOMAIN_MEMORY_PARAM_UNLIMITED = C.VIR_DOMAIN_MEMORY_PARAM_UNLIMITED @@ -267,6 +269,7 @@ const ( DOMAIN_RUNNING_WAKEUP = DomainRunningReason(C.VIR_DOMAIN_RUNNING_WAKEUP) /* returned from pmsuspended due to wakeup event */ DOMAIN_RUNNING_CRASHED = DomainRunningReason(C.VIR_DOMAIN_RUNNING_CRASHED) /* resumed from crashed */ DOMAIN_RUNNING_POSTCOPY = DomainRunningReason(C.VIR_DOMAIN_RUNNING_POSTCOPY) /* running in post-copy migration mode */ + DOMAIN_RUNNING_POSTCOPY_FAILED = DomainRunningReason(C.VIR_DOMAIN_RUNNING_POSTCOPY_FAILED) /* running in post-copy migration mode after failure */ ) type DomainPausedReason int @@ -340,10 +343,11 @@ const ( type DomainEventResumedDetailType int const ( - DOMAIN_EVENT_RESUMED_UNPAUSED = DomainEventResumedDetailType(C.VIR_DOMAIN_EVENT_RESUMED_UNPAUSED) - DOMAIN_EVENT_RESUMED_MIGRATED = DomainEventResumedDetailType(C.VIR_DOMAIN_EVENT_RESUMED_MIGRATED) - DOMAIN_EVENT_RESUMED_FROM_SNAPSHOT = DomainEventResumedDetailType(C.VIR_DOMAIN_EVENT_RESUMED_FROM_SNAPSHOT) - DOMAIN_EVENT_RESUMED_POSTCOPY = DomainEventResumedDetailType(C.VIR_DOMAIN_EVENT_RESUMED_POSTCOPY) + DOMAIN_EVENT_RESUMED_UNPAUSED = DomainEventResumedDetailType(C.VIR_DOMAIN_EVENT_RESUMED_UNPAUSED) + DOMAIN_EVENT_RESUMED_MIGRATED = DomainEventResumedDetailType(C.VIR_DOMAIN_EVENT_RESUMED_MIGRATED) + DOMAIN_EVENT_RESUMED_FROM_SNAPSHOT = DomainEventResumedDetailType(C.VIR_DOMAIN_EVENT_RESUMED_FROM_SNAPSHOT) + DOMAIN_EVENT_RESUMED_POSTCOPY = DomainEventResumedDetailType(C.VIR_DOMAIN_EVENT_RESUMED_POSTCOPY) + DOMAIN_EVENT_RESUMED_POSTCOPY_FAILED = DomainEventResumedDetailType(C.VIR_DOMAIN_EVENT_RESUMED_POSTCOPY_FAILED) ) type DomainEventStoppedDetailType int @@ -754,6 +758,7 @@ const ( DOMAIN_SAVE_BYPASS_CACHE = DomainSaveRestoreFlags(C.VIR_DOMAIN_SAVE_BYPASS_CACHE) DOMAIN_SAVE_RUNNING = DomainSaveRestoreFlags(C.VIR_DOMAIN_SAVE_RUNNING) DOMAIN_SAVE_PAUSED = DomainSaveRestoreFlags(C.VIR_DOMAIN_SAVE_PAUSED) + DOMAIN_SAVE_RESET_NVRAM = DomainSaveRestoreFlags(C.VIR_DOMAIN_SAVE_RESET_NVRAM) ) type DomainSetTimeFlags uint @@ -824,6 +829,8 @@ const ( MIGRATE_TLS = DomainMigrateFlags(C.VIR_MIGRATE_TLS) MIGRATE_PARALLEL = DomainMigrateFlags(C.VIR_MIGRATE_PARALLEL) MIGRATE_NON_SHARED_SYNCHRONOUS_WRITES = DomainMigrateFlags(C.VIR_MIGRATE_NON_SHARED_SYNCHRONOUS_WRITES) + MIGRATE_POSTCOPY_RESUME = DomainMigrateFlags(C.VIR_MIGRATE_POSTCOPY_RESUME) + MIGRATE_ZEROCOPY = DomainMigrateFlags(C.VIR_MIGRATE_ZEROCOPY) ) type DomainMigrateMaxSpeedFlags uint @@ -977,6 +984,20 @@ const ( DOMAIN_DIRTYRATE_MEASURED = DomainDirtyRateStatus(C.VIR_DOMAIN_DIRTYRATE_MEASURED) ) +type DomainDirtyRateCalcFlags uint + +const ( + DOMAIN_DIRTYRATE_MODE_PAGE_SAMPLING = DomainDirtyRateCalcFlags(C.VIR_DOMAIN_DIRTYRATE_MODE_PAGE_SAMPLING) + DOMAIN_DIRTYRATE_MODE_DIRTY_BITMAP = DomainDirtyRateCalcFlags(C.VIR_DOMAIN_DIRTYRATE_MODE_DIRTY_BITMAP) + DOMAIN_DIRTYRATE_MODE_DIRTY_RING = DomainDirtyRateCalcFlags(C.VIR_DOMAIN_DIRTYRATE_MODE_DIRTY_RING) +) + +type DomainAbortJobFlags uint + +const ( + DOMAIN_ABORT_JOB_POSTCOPY = DomainAbortJobFlags(C.VIR_DOMAIN_ABORT_JOB_POSTCOPY) +) + // See also https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainFree func (d *Domain) Free() error { var err C.virError @@ -1578,6 +1599,21 @@ func (d *Domain) AbortJob() error { return nil } +// See also https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainAbortJobFlags +func (d *Domain) AbortJobFlags(flags DomainAbortJobFlags) error { + var err C.virError + + if C.LIBVIR_VERSION_NUMBER < 8005000 { + return makeNotImplementedError("virDomainAbortJobFlags") + } + + result := C.virDomainAbortJobFlagsWrapper(d.ptr, C.uint(flags), &err) + if result == -1 { + return makeError(&err) + } + return nil +} + // See also https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainDestroyFlags func (d *Domain) DestroyFlags(flags DomainDestroyFlags) error { var err C.virError @@ -4179,19 +4215,24 @@ func (d *Domain) HasCurrentSnapshot(flags uint32) (bool, error) { // See also https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainFSFreeze func (d *Domain) FSFreeze(mounts []string, flags uint32) error { + var err C.virError + var ret C.int if C.LIBVIR_VERSION_NUMBER < 1002005 { return makeNotImplementedError("virDomainFSFreeze") } - cmounts := make([](*C.char), len(mounts)) + if len(mounts) == 0 { + ret = C.virDomainFSFreezeWrapper(d.ptr, nil, 0, C.uint(flags), &err) + } else { + cmounts := make([](*C.char), len(mounts)) - for i := 0; i < len(mounts); i++ { - cmounts[i] = C.CString(mounts[i]) - defer C.free(unsafe.Pointer(cmounts[i])) - } + for i := 0; i < len(mounts); i++ { + cmounts[i] = C.CString(mounts[i]) + defer C.free(unsafe.Pointer(cmounts[i])) + } - nmounts := len(mounts) - var err C.virError - ret := C.virDomainFSFreezeWrapper(d.ptr, (**C.char)(unsafe.Pointer(&cmounts[0])), C.uint(nmounts), C.uint(flags), &err) + nmounts := len(mounts) + ret = C.virDomainFSFreezeWrapper(d.ptr, (**C.char)(unsafe.Pointer(&cmounts[0])), C.uint(nmounts), C.uint(flags), &err) + } if ret == -1 { return makeError(&err) } @@ -4201,19 +4242,24 @@ func (d *Domain) FSFreeze(mounts []string, flags uint32) error { // See also https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainFSThaw func (d *Domain) FSThaw(mounts []string, flags uint32) error { + var err C.virError + var ret C.int if C.LIBVIR_VERSION_NUMBER < 1002005 { return makeNotImplementedError("virDomainFSThaw") } - cmounts := make([](*C.char), len(mounts)) + if len(mounts) == 0 { + ret = C.virDomainFSThawWrapper(d.ptr, nil, 0, C.uint(flags), &err) + } else { + cmounts := make([](*C.char), len(mounts)) - for i := 0; i < len(mounts); i++ { - cmounts[i] = C.CString(mounts[i]) - defer C.free(unsafe.Pointer(cmounts[i])) - } + for i := 0; i < len(mounts); i++ { + cmounts[i] = C.CString(mounts[i]) + defer C.free(unsafe.Pointer(cmounts[i])) + } - nmounts := len(mounts) - var err C.virError - ret := C.virDomainFSThawWrapper(d.ptr, (**C.char)(unsafe.Pointer(&cmounts[0])), C.uint(nmounts), C.uint(flags), &err) + nmounts := len(mounts) + ret = C.virDomainFSThawWrapper(d.ptr, (**C.char)(unsafe.Pointer(&cmounts[0])), C.uint(nmounts), C.uint(flags), &err) + } if ret == -1 { return makeError(&err) } @@ -4335,12 +4381,16 @@ func (d *Domain) DelIOThread(id uint, flags DomainModificationImpact) error { // 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 uint + PollMaxNsSet bool + PollMaxNs uint64 + PollGrowSet bool + PollGrow uint + PollShrinkSet bool + PollShrink uint + ThreadPoolMinSet bool + ThreadPoolMin int + ThreadPoolMaxSet bool + ThreadPoolMax int } func getSetIOThreadParamsFieldInfo(params *DomainSetIOThreadParams) map[string]typedParamsFieldInfo { @@ -4357,6 +4407,14 @@ func getSetIOThreadParamsFieldInfo(params *DomainSetIOThreadParams) map[string]t set: ¶ms.PollShrinkSet, ui: ¶ms.PollShrink, }, + C.VIR_DOMAIN_IOTHREAD_THREAD_POOL_MIN: typedParamsFieldInfo{ + set: ¶ms.ThreadPoolMinSet, + i: ¶ms.ThreadPoolMin, + }, + C.VIR_DOMAIN_IOTHREAD_THREAD_POOL_MAX: typedParamsFieldInfo{ + set: ¶ms.ThreadPoolMaxSet, + i: ¶ms.ThreadPoolMax, + }, } } @@ -4654,6 +4712,48 @@ func (d *Domain) SaveFlags(destFile string, destXml string, flags DomainSaveRest return nil } +type DomainSaveRestoreParams struct { + FileSet bool + File string + DXMLSet bool + DXML string +} + +func getDomainSaveRestoreParametersFieldInfo(params *DomainSaveRestoreParams) map[string]typedParamsFieldInfo { + return map[string]typedParamsFieldInfo{ + C.VIR_DOMAIN_SAVE_PARAM_FILE: typedParamsFieldInfo{ + set: ¶ms.FileSet, + s: ¶ms.File, + }, + C.VIR_DOMAIN_SAVE_PARAM_DXML: typedParamsFieldInfo{ + set: ¶ms.DXMLSet, + s: ¶ms.DXML, + }, + } +} + +// See also https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainSaveParams +func (d *Domain) SaveParams(params DomainSaveRestoreParams, flags DomainSaveRestoreFlags) error { + if C.LIBVIR_VERSION_NUMBER < 8004000 { + return makeNotImplementedError("virDomainSaveParams") + } + + info := getDomainSaveRestoreParametersFieldInfo(¶ms) + cparams, cnparams, gerr := typedParamsPackNew(info) + if gerr != nil { + return gerr + } + + defer C.virTypedParamsFree(cparams, cnparams) + + var err C.virError + result := C.virDomainSaveParamsWrapper(d.ptr, cparams, cnparams, C.uint(flags), &err) + if result == -1 { + return makeError(&err) + } + return nil +} + type DomainGuestVcpus struct { VcpusSet bool Vcpus []bool @@ -5712,7 +5812,7 @@ func (d *Domain) GetMessages(flags DomainMessageType) ([]string, error) { return msgs, nil } -func (d *Domain) StartDirtyRateCalc(secs int, flags uint) error { +func (d *Domain) StartDirtyRateCalc(secs int, flags DomainDirtyRateCalcFlags) error { if C.LIBVIR_VERSION_NUMBER < 7002000 { return makeNotImplementedError("virDomainStartDirtyRateCalc") } diff --git a/vendor/libvirt.org/go/libvirt/domain_compat.h b/vendor/libvirt.org/go/libvirt/domain_compat.h index 680ac242a..95df83f17 100644 --- a/vendor/libvirt.org/go/libvirt/domain_compat.h +++ b/vendor/libvirt.org/go/libvirt/domain_compat.h @@ -1238,5 +1238,74 @@ struct _virDomainInterface { #define VIR_DOMAIN_LAUNCH_SECURITY_SEV_SECRET_SET_ADDRESS "sev-secret-set-address" #endif +/* 8.1.0 */ + +#ifndef VIR_DOMAIN_SAVE_RESET_NVRAM +#define VIR_DOMAIN_SAVE_RESET_NVRAM 1 << 3 +#endif + +#ifndef VIR_DOMAIN_START_RESET_NVRAM +#define VIR_DOMAIN_START_RESET_NVRAM 1 << 5 +#endif + + +#ifndef VIR_DOMAIN_DIRTYRATE_MODE_PAGE_SAMPLING +#define VIR_DOMAIN_DIRTYRATE_MODE_PAGE_SAMPLING 0 +#endif + +#ifndef VIR_DOMAIN_DIRTYRATE_MODE_DIRTY_BITMAP +#define VIR_DOMAIN_DIRTYRATE_MODE_DIRTY_BITMAP 1 << 0 +#endif + +#ifndef VIR_DOMAIN_DIRTYRATE_MODE_DIRTY_RING +#define VIR_DOMAIN_DIRTYRATE_MODE_DIRTY_RING 1 << 1 +#endif + +/* 8.3.0 */ + +#ifndef VIR_DOMAIN_DESTROY_REMOVE_LOGS +#define VIR_DOMAIN_DESTROY_REMOVE_LOGS 1 << 1 +#endif + +/* 8.4.0 */ + +#ifndef VIR_DOMAIN_SAVE_PARAM_FILE +#define VIR_DOMAIN_SAVE_PARAM_FILE "file" +#endif + +#ifndef VIR_DOMAIN_SAVE_PARAM_DXML +#define VIR_DOMAIN_SAVE_PARAM_DXML "dxml" +#endif + +/* 8.5.0 */ + +#ifndef VIR_DOMAIN_ABORT_JOB_POSTCOPY +#define VIR_DOMAIN_ABORT_JOB_POSTCOPY (1 << 0) +#endif + + +#ifndef VIR_DOMAIN_EVENT_RESUMED_POSTCOPY_FAILED +#define VIR_DOMAIN_EVENT_RESUMED_POSTCOPY_FAILED 4 +#endif + +#ifndef VIR_DOMAIN_RUNNING_POSTCOPY_FAILED +#define VIR_DOMAIN_RUNNING_POSTCOPY_FAILED 11 +#endif + +#ifndef VIR_MIGRATE_POSTCOPY_RESUME +#define VIR_MIGRATE_POSTCOPY_RESUME 19 +#endif + +#ifndef VIR_MIGRATE_ZEROCOPY +#define VIR_MIGRATE_ZEROCOPY 20 +#endif + +#ifndef VIR_DOMAIN_IOTHREAD_THREAD_POOL_MIN +#define VIR_DOMAIN_IOTHREAD_THREAD_POOL_MIN "thread_pool_min" +#endif + +#ifndef VIR_DOMAIN_IOTHREAD_THREAD_POOL_MAX +#define VIR_DOMAIN_IOTHREAD_THREAD_POOL_MAX "thread_pool_max" +#endif #endif /* LIBVIRT_GO_DOMAIN_COMPAT_H__ */ diff --git a/vendor/libvirt.org/go/libvirt/domain_snapshot.go b/vendor/libvirt.org/go/libvirt/domain_snapshot.go index 72c484bed..b3c9011fd 100644 --- a/vendor/libvirt.org/go/libvirt/domain_snapshot.go +++ b/vendor/libvirt.org/go/libvirt/domain_snapshot.go @@ -73,9 +73,10 @@ const ( type DomainSnapshotRevertFlags uint const ( - DOMAIN_SNAPSHOT_REVERT_RUNNING = DomainSnapshotRevertFlags(C.VIR_DOMAIN_SNAPSHOT_REVERT_RUNNING) - DOMAIN_SNAPSHOT_REVERT_PAUSED = DomainSnapshotRevertFlags(C.VIR_DOMAIN_SNAPSHOT_REVERT_PAUSED) - DOMAIN_SNAPSHOT_REVERT_FORCE = DomainSnapshotRevertFlags(C.VIR_DOMAIN_SNAPSHOT_REVERT_FORCE) + DOMAIN_SNAPSHOT_REVERT_RUNNING = DomainSnapshotRevertFlags(C.VIR_DOMAIN_SNAPSHOT_REVERT_RUNNING) + DOMAIN_SNAPSHOT_REVERT_PAUSED = DomainSnapshotRevertFlags(C.VIR_DOMAIN_SNAPSHOT_REVERT_PAUSED) + DOMAIN_SNAPSHOT_REVERT_FORCE = DomainSnapshotRevertFlags(C.VIR_DOMAIN_SNAPSHOT_REVERT_FORCE) + DOMAIN_SNAPSHOT_REVERT_RESET_NVRAM = DomainSnapshotRevertFlags(C.VIR_DOMAIN_SNAPSHOT_REVERT_RESET_NVRAM) ) type DomainSnapshotDeleteFlags uint diff --git a/vendor/libvirt.org/go/libvirt/domain_snapshot_compat.h b/vendor/libvirt.org/go/libvirt/domain_snapshot_compat.h index 44fea6881..80c6dbb2c 100644 --- a/vendor/libvirt.org/go/libvirt/domain_snapshot_compat.h +++ b/vendor/libvirt.org/go/libvirt/domain_snapshot_compat.h @@ -37,4 +37,11 @@ # define VIR_DOMAIN_SNAPSHOT_CREATE_VALIDATE (1 << 9) #endif +/* 8.1.0 */ + +#ifndef VIR_DOMAIN_SNAPSHOT_REVERT_RESET_NVRAM +#define VIR_DOMAIN_SNAPSHOT_REVERT_RESET_NVRAM 1 << 3 +#endif + + #endif /* LIBVIRT_GO_DOMAIN_SNAPSHOT_COMPAT_H__ */ diff --git a/vendor/libvirt.org/go/libvirt/domain_wrapper.go b/vendor/libvirt.org/go/libvirt/domain_wrapper.go index 88aa57276..c437411f5 100644 --- a/vendor/libvirt.org/go/libvirt/domain_wrapper.go +++ b/vendor/libvirt.org/go/libvirt/domain_wrapper.go @@ -43,6 +43,23 @@ virDomainAbortJobWrapper(virDomainPtr domain, } +int +virDomainAbortJobFlagsWrapper(virDomainPtr domain, + unsigned int flags, + virErrorPtr err) +{ +#if LIBVIR_VERSION_NUMBER < 8005000 + assert(0); // Caller should have checked version +#else + int ret = virDomainAbortJobFlags(domain, flags); + if (ret < 0) { + virCopyLastError(err); + } + return ret; +#endif +} + + int virDomainAddIOThreadWrapper(virDomainPtr domain, unsigned int iothread_id, @@ -1803,6 +1820,25 @@ virDomainSaveFlagsWrapper(virDomainPtr domain, } +int +virDomainSaveParamsWrapper(virDomainPtr domain, + virTypedParameterPtr params, + int nparams, + unsigned int flags, + virErrorPtr err) +{ +#if LIBVIR_VERSION_NUMBER < 8004000 + assert(0); // Caller should have checked version +#else + int ret = virDomainSaveParams(domain, params, nparams, flags); + if (ret < 0) { + virCopyLastError(err); + } + return ret; +#endif +} + + char * virDomainScreenshotWrapper(virDomainPtr domain, virStreamPtr stream, diff --git a/vendor/libvirt.org/go/libvirt/domain_wrapper.h b/vendor/libvirt.org/go/libvirt/domain_wrapper.h index f7113c647..11c93af15 100644 --- a/vendor/libvirt.org/go/libvirt/domain_wrapper.h +++ b/vendor/libvirt.org/go/libvirt/domain_wrapper.h @@ -36,6 +36,11 @@ int virDomainAbortJobWrapper(virDomainPtr domain, virErrorPtr err); +int +virDomainAbortJobFlagsWrapper(virDomainPtr domain, + unsigned int flags, + virErrorPtr err); + int virDomainAddIOThreadWrapper(virDomainPtr domain, unsigned int iothread_id, @@ -764,6 +769,13 @@ virDomainSaveFlagsWrapper(virDomainPtr domain, unsigned int flags, virErrorPtr err); +int +virDomainSaveParamsWrapper(virDomainPtr domain, + virTypedParameterPtr params, + int nparams, + unsigned int flags, + virErrorPtr err); + char * virDomainScreenshotWrapper(virDomainPtr domain, virStreamPtr stream, diff --git a/vendor/libvirt.org/go/libvirt/error.go b/vendor/libvirt.org/go/libvirt/error.go index 803ba23da..0ad7f44bb 100644 --- a/vendor/libvirt.org/go/libvirt/error.go +++ b/vendor/libvirt.org/go/libvirt/error.go @@ -44,7 +44,6 @@ import ( func init() { C.virSetErrorFunc(nil, (C.virErrorFunc)(C.ignoreErrorFunc)) - C.virInitialize() } type ErrorLevel int diff --git a/vendor/libvirt.org/go/libvirt/events.go b/vendor/libvirt.org/go/libvirt/events.go index 5a2fe0235..3ccaf41cb 100644 --- a/vendor/libvirt.org/go/libvirt/events.go +++ b/vendor/libvirt.org/go/libvirt/events.go @@ -30,6 +30,7 @@ package libvirt #cgo pkg-config: libvirt #include <stdint.h> #include "events_wrapper.h" +#include "connect_wrapper.h" */ import "C" @@ -43,9 +44,14 @@ const ( ) // See also https://libvirt.org/html/libvirt-libvirt-event.html#virEventRegisterDefaultImpl +// +// Note that registering an event loop implementation must be +// done before creating any Connect object instance func EventRegisterDefaultImpl() error { var err C.virError - C.virInitialize() + if C.virInitializeWrapper(&err) < 0 { + return makeError(&err) + } if i := int(C.virEventRegisterDefaultImplWrapper(&err)); i != 0 { return makeError(&err) } @@ -187,10 +193,17 @@ type EventLoop interface { var eventLoopImpl EventLoop // See also https://libvirt.org/html/libvirt-libvirt-event.html#virEventRegisterImpl -func EventRegisterImpl(impl EventLoop) { +// +// Note that registering an event loop implementation must be +// done before creating any Connect object instance +func EventRegisterImpl(impl EventLoop) error { + var err C.virError eventLoopImpl = impl - C.virInitialize() + if C.virInitializeWrapper(&err) < 0 { + return makeError(&err) + } C.virEventRegisterImplWrapper() + return nil } //export eventAddHandleFunc diff --git a/vendor/libvirt.org/go/libvirt/qemu.go b/vendor/libvirt.org/go/libvirt/qemu.go index 065e053cc..41a54fe17 100644 --- a/vendor/libvirt.org/go/libvirt/qemu.go +++ b/vendor/libvirt.org/go/libvirt/qemu.go @@ -39,6 +39,7 @@ package libvirt import "C" import ( + "os" "unsafe" ) @@ -94,6 +95,45 @@ func (d *Domain) QemuMonitorCommand(command string, flags DomainQemuMonitorComma return rstring, nil } +// See also https://libvirt.org/html/libvirt-libvirt-qemu.html#virDomainQemuMonitorCommandWithFiles +func (d *Domain) QemuMonitorCommandWithFiles(command string, infiles []os.File, flags DomainQemuMonitorCommandFlags) (string, []*os.File, error) { + if C.LIBVIR_VERSION_NUMBER < 8002000 { + return "", []*os.File{}, makeNotImplementedError("virDomainQemuMonitorCommandWithFiles") + } + + cninfiles := C.uint(len(infiles)) + cinfiles := make([]C.int, len(infiles)) + for i := 0; i < len(infiles); i++ { + cinfiles[i] = C.int(infiles[i].Fd()) + } + cCommand := C.CString(command) + defer C.free(unsafe.Pointer(cCommand)) + + var cResult *C.char + var cnoutfiles C.uint + var coutfiles *C.int + var err C.virError + result := C.virDomainQemuMonitorCommandWithFilesWrapper(d.ptr, cCommand, + cninfiles, &cinfiles[0], &cnoutfiles, &coutfiles, + &cResult, C.uint(flags), &err) + + if result != 0 { + return "", []*os.File{}, makeError(&err) + } + + outfiles := []*os.File{} + for i := 0; i < int(cnoutfiles); i++ { + coutfile := *(*C.int)(unsafe.Pointer(uintptr(unsafe.Pointer(coutfiles)) + (unsafe.Sizeof(*coutfiles) * uintptr(i)))) + + outfiles = append(outfiles, os.NewFile(uintptr(coutfile), "mon-cmd-out")) + } + C.free(unsafe.Pointer(coutfiles)) + + rstring := C.GoString(cResult) + C.free(unsafe.Pointer(cResult)) + return rstring, outfiles, nil +} + // See also https://libvirt.org/html/libvirt-libvirt-qemu.html#virDomainQemuAgentCommand func (d *Domain) QemuAgentCommand(command string, timeout DomainQemuAgentCommandTimeout, flags uint32) (string, error) { cCommand := C.CString(command) diff --git a/vendor/libvirt.org/go/libvirt/qemu_wrapper.go b/vendor/libvirt.org/go/libvirt/qemu_wrapper.go index 2e91a83e8..5e984cacc 100644 --- a/vendor/libvirt.org/go/libvirt/qemu_wrapper.go +++ b/vendor/libvirt.org/go/libvirt/qemu_wrapper.go @@ -131,5 +131,28 @@ virDomainQemuMonitorCommandWrapper(virDomainPtr domain, } +int +virDomainQemuMonitorCommandWithFilesWrapper(virDomainPtr domain, + const char *cmd, + unsigned int ninfiles, + int *infiles, + unsigned int *noutfiles, + int **outfiles, + char **result, + unsigned int flags, + virErrorPtr err) +{ +#if LIBVIR_VERSION_NUMBER < 8002000 + assert(0); // Caller should have checked version +#else + int ret = virDomainQemuMonitorCommandWithFiles(domain, cmd, ninfiles, infiles, noutfiles, outfiles, result, flags); + if (ret < 0) { + virCopyLastError(err); + } + return ret; +#endif +} + + */ import "C" diff --git a/vendor/libvirt.org/go/libvirt/qemu_wrapper.h b/vendor/libvirt.org/go/libvirt/qemu_wrapper.h index bec1fe624..d4c0533ac 100644 --- a/vendor/libvirt.org/go/libvirt/qemu_wrapper.h +++ b/vendor/libvirt.org/go/libvirt/qemu_wrapper.h @@ -74,5 +74,16 @@ virDomainQemuMonitorCommandWrapper(virDomainPtr domain, unsigned int flags, virErrorPtr err); +int +virDomainQemuMonitorCommandWithFilesWrapper(virDomainPtr domain, + const char *cmd, + unsigned int ninfiles, + int *infiles, + unsigned int *noutfiles, + int **outfiles, + char **result, + unsigned int flags, + virErrorPtr err); + #endif /* LIBVIRT_GO_DOMAIN_EVENTS_WRAPPER_H__ */ diff --git a/vendor/libvirt.org/go/libvirt/typedparams.go b/vendor/libvirt.org/go/libvirt/typedparams.go index 761fe315a..a39199166 100644 --- a/vendor/libvirt.org/go/libvirt/typedparams.go +++ b/vendor/libvirt.org/go/libvirt/typedparams.go @@ -71,6 +71,8 @@ func typedParamsUnpack(cparams *C.virTypedParameter, cnparams C.int, infomap map *value.sl = append(*value.sl, C.GoString(cs)) *value.set = true count++ + } else if ret < 0 { + break } } } else { @@ -126,6 +128,9 @@ func typedParamsUnpack(cparams *C.virTypedParameter, cnparams C.int, infomap map count++ } } + if ret < 0 { + return count, makeError(&err) + } } return count, nil diff --git a/vendor/modules.txt b/vendor/modules.txt index 49dc79d62..198560e4f 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1152,7 +1152,7 @@ kubevirt.io/controller-lifecycle-operator-sdk/pkg/sdk/api ## explicit; go 1.16 kubevirt.io/qe-tools/pkg/ginkgo-reporters kubevirt.io/qe-tools/pkg/polarion-xml -# libvirt.org/go/libvirt v1.8000.0 +# libvirt.org/go/libvirt v1.8006.0 ## explicit; go 1.11 libvirt.org/go/libvirt # mvdan.cc/editorconfig v0.1.1-0.20200121172147-e40951bde157 -- 2.37.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor