From 6af9bd50e7afa07c470c0d701b61cf8d0ff035bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Bosdonnat?= Date: Thu, 11 Sep 2014 09:29:50 +0200 Subject: [PATCH] Provide VIR_DOMAIN_MEMORY_PARAM_UNLIMITED constant --- constants.go | 12 +++++++----- libvirt.go | 10 +++++----- libvirt_test.go | 50 ++++++++++++++++++++++++------------------------- secret.go | 1 - 4 files changed, 37 insertions(+), 36 deletions(-) diff --git a/constants.go b/constants.go index be7b7be..2fe88e4 100644 --- a/constants.go +++ b/constants.go @@ -136,9 +136,11 @@ const ( // virDomainCreateFlags const ( - VIR_DOMAIN_NONE = C.VIR_DOMAIN_NONE - VIR_DOMAIN_START_PAUSED = C.VIR_DOMAIN_START_PAUSED - VIR_DOMAIN_START_AUTODESTROY = C.VIR_DOMAIN_START_AUTODESTROY - VIR_DOMAIN_START_BYPASS_CACHE = C.VIR_DOMAIN_START_BYPASS_CACHE - VIR_DOMAIN_START_FORCE_BOOT = C.VIR_DOMAIN_START_FORCE_BOOT + VIR_DOMAIN_NONE = C.VIR_DOMAIN_NONE + VIR_DOMAIN_START_PAUSED = C.VIR_DOMAIN_START_PAUSED + VIR_DOMAIN_START_AUTODESTROY = C.VIR_DOMAIN_START_AUTODESTROY + VIR_DOMAIN_START_BYPASS_CACHE = C.VIR_DOMAIN_START_BYPASS_CACHE + VIR_DOMAIN_START_FORCE_BOOT = C.VIR_DOMAIN_START_FORCE_BOOT ) + +const VIR_DOMAIN_MEMORY_PARAM_UNLIMITED = C.VIR_DOMAIN_MEMORY_PARAM_UNLIMITED diff --git a/libvirt.go b/libvirt.go index 0b18d70..ec4403f 100644 --- a/libvirt.go +++ b/libvirt.go @@ -101,11 +101,11 @@ func (c *VirConnection) GetHostname() (string, error) { } func (c *VirConnection) GetLibVersion() (uint32, error) { - var version C.ulong - if err := C.virConnectGetLibVersion(c.ptr, &version); err < 0 { - return 0, errors.New(GetLastError()) - } - return uint32(version), nil + var version C.ulong + if err := C.virConnectGetLibVersion(c.ptr, &version); err < 0 { + return 0, errors.New(GetLastError()) + } + return uint32(version), nil } func (c *VirConnection) GetType() (string, error) { diff --git a/libvirt_test.go b/libvirt_test.go index a982ac5..4e79d5b 100644 --- a/libvirt_test.go +++ b/libvirt_test.go @@ -149,15 +149,15 @@ func TestHostname(t *testing.T) { func TestLibVersion(t *testing.T) { conn := buildTestConnection() defer conn.CloseConnection() - version, err := conn.GetLibVersion() - if err != nil { - t.Error(err) - return - } - if version == 0 { - t.Error("Version was 0") - return - } + version, err := conn.GetLibVersion() + if err != nil { + t.Error(err) + return + } + if version == 0 { + t.Error("Version was 0") + return + } } func TestListDefinedDomains(t *testing.T) { @@ -272,7 +272,7 @@ func TestLookupInvalidDomainByName(t *testing.T) { func TestDomainCreateXML(t *testing.T) { conn := buildTestConnection() - nodom := VirDomain{} + nodom := VirDomain{} defer conn.CloseConnection() // Test a minimally valid xml defName := time.Now().String() @@ -289,10 +289,10 @@ func TestDomainCreateXML(t *testing.T) { return } defer func() { - if dom != nodom { - dom.Destroy() - dom.Free() - } + if dom != nodom { + dom.Destroy() + dom.Free() + } }() name, err := dom.GetName() if err != nil { @@ -304,18 +304,18 @@ func TestDomainCreateXML(t *testing.T) { return } - // Destroy the domain: it should not be persistent - if err := dom.Destroy(); err != nil { - t.Error(err) - return - } - dom = nodom + // Destroy the domain: it should not be persistent + if err := dom.Destroy(); err != nil { + t.Error(err) + return + } + dom = nodom - testeddom, err := conn.LookupDomainByName(defName) - if testeddom != nodom { - t.Fatal("Created domain is persisting") - return - } + testeddom, err := conn.LookupDomainByName(defName) + if testeddom != nodom { + t.Fatal("Created domain is persisting") + return + } } func TestDomainDefineXML(t *testing.T) { diff --git a/secret.go b/secret.go index c973f02..409e464 100644 --- a/secret.go +++ b/secret.go @@ -77,4 +77,3 @@ func (s *VirSecret) GetXMLDesc(flags uint32) (string, error) { C.free(unsafe.Pointer(result)) return xml, nil } -