Skip to content

Commit

Permalink
Provide VIR_DOMAIN_MEMORY_PARAM_UNLIMITED constant
Browse files Browse the repository at this point in the history
  • Loading branch information
cbosdo authored and Alex Zorin committed Sep 11, 2014
1 parent 3935a27 commit 6af9bd5
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 36 deletions.
12 changes: 7 additions & 5 deletions constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 5 additions & 5 deletions libvirt.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
50 changes: 25 additions & 25 deletions libvirt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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()
Expand All @@ -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 {
Expand All @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,3 @@ func (s *VirSecret) GetXMLDesc(flags uint32) (string, error) {
C.free(unsafe.Pointer(result))
return xml, nil
}

0 comments on commit 6af9bd5

Please sign in to comment.