Use specific int sizes ([u]int[32|64])

Always use sized types (i.e. int32, uint64) because the base C types are
always sized.

int (C) != int (Go)

but,

int (C) == int32 (Go)

Signed-off-by: Crístian Deives <cristiandeives@gmail.com>
fix: test: Use a running domain to test ID

Only domains which are running have IDs. The function "TestDomainID"
didn't start its domain so it could never have a valid ID anyway.

Signed-off-by: Crístian Deives <cristiandeives@gmail.com>
fix: Don't try to create native error in Domain.ID

The native function "virDomainGetID" doesn't create an error when the
domain doesn't have an ID, it just returns -1. Therefore the call to
"virGetLastError" wouldn't return an error there.

Create a non-libvirt error when "virDomainGetID" fails. Also, fix the
corresponding test to deal with the different error type.

Signed-off-by: Crístian Deives <cristiandeives@gmail.com>
Add a constant for the default connection URI

Signed-off-by: Crístian Deives <cristiandeives@gmail.com>
Parameterize the function "Open"

Instead of having two functions to open a libvirt connection (i.e. Open
and OpenReadOnly) with different behaviours, use only one with all
required parameters. This will make adding more connections parameter
easier in the future.

Also, add a function which will connect to libvirt using only default
values.

Signed-off-by: Crístian Deives <cristiandeives@gmail.com>
Add log messages

Every function will print messages to the connection's log, including
the moments when entering and leaving, its parameters and return values.

Another parameter was added to the function "Open" to set the log
output. The function "OpenDefault" will discard its log messages.

Signed-off-by: Crístian Deives <cristiandeives@gmail.com>
Supress native libvirt error output

Set a function which does nothing to "virtSetErrorFunc".

Signed-off-by: Crístian Deives <cristiandeives@gmail.com>
Use error type "error" as return type

A few errors on this library are not native libvirt errors (i.e.
"Error"), so in order to make the error types standard, this patch
changes the functions' signatures to use "error" instead.

Signed-off-by: Crístian Deives <cristiandeives@gmail.com>
Add documentation to all exported types

Signed-off-by: Crístian Deives <cristiandeives@gmail.com>
fix: Use correct const variable names

Signed-off-by: Crístian Deives <cristiandeives@gmail.com>
Use native const values instead of Go's iota

Signed-off-by: Crístian Deives <cristiandeives@gmail.com>
Rename flag types

The following types were renamed:

- DomainFlag -> DomainListFlag
- DomainMemoryFlag -> DomainMemoryModifyFlag

The following type had its const value names modified:

- DomainCreateFlag: DomCreateStart* -> DomCreate*

Signed-off-by: Crístian Deives <cristiandeives@gmail.com>
test: Include original file name in test functions

This makes it easier to test functions only from specific original
files. For example, "go test -run TestConnection" will only test the
functions defined in connection.go.

Signed-off-by: Crístian Deives <cristiandeives@gmail.com>
test: Use inline XML

Instead of keeping separate files for the XML descriptors, use them
inline in the test code.

Signed-off-by: Crístian Deives <cristiandeives@gmail.com>
test: Refactor and improve tests

Signed-off-by: Crístian Deives <cristiandeives@gmail.com>
test: Create a consistent test environment

Signed-off-by: Crístian Deives <cristiandeives@gmail.com>
test: Use "qemu:///session" as the default URI

Using "qemu:///session" instead of "qemu:///system" is faster and it
doesn't require root access. Other "QEMU" URIs should still work,
though.

Signed-off-by: Crístian Deives <cristiandeives@gmail.com>
test: Add a disk when creating a test domain

Signed-off-by: Crístian Deives <cristiandeives@gmail.com>
Add initial domain snapshot support

The functions "ListSnapshots" and "Free" are now available.

Signed-off-by: Crístian Deives <cristiandeives@gmail.com>
Add snapshot functions "CreateSnapshot" and "Delete"

Signed-off-by: Crístian Deives <cristiandeives@gmail.com>