Commit Graph

43 Commits

Author SHA1 Message Date
Yuriy Taraday
8965adaafb Expand some comments by Geoff's request 2018-03-02 00:26:38 +04:00
Yuriy Taraday
16e61b53a7 Remove unused parts of ProcMeta
Also replace if-else if chain with switch and fix error strings.
2018-03-01 20:22:28 +04:00
Yuriy Taraday
81923720d1 Fix golint errors 2018-03-01 10:57:28 +04:00
Yuriy Taraday
02e0818aef Add streams to proc arguments, use requestStream
This makes functions look just like in actual libvirt API, except
virStreamPtr is replaced with io.Reader for outgoing streams and
io.Writer for incoming streams.
2018-03-01 10:12:56 +04:00
Yuriy Taraday
3613b30fe2 Parse proc annotations and store in Proc struct 2018-03-01 10:06:40 +04:00
Yuriy Taraday
5d8cdfc854 Capture comment before libvirt proc declaration
It contains annotations that we can use to insert streams in proc
arguments.
2018-03-01 10:06:40 +04:00
Ben LeMasurier
0978bc3291
Adds DomainUpdateDeviceFlags to translation table (#62)
* Adds DomainUpdateDeviceFlags to translation table

* Updates generated code

libvirt-4.0.0

* fixes merge conflict
2018-02-28 15:00:59 -07:00
Yuriy Taraday
38a1eeb6c3 Return []byte from encode, use it instead of bytes.Buffer
We only use Buffer for its internal buffer returned by Bytes() outside
encode() anyway, so there's no reason to hold on to whole Buffer object.
2018-02-24 12:08:15 +04:00
Yuriy Taraday
47db3dbbbc Move fetching response from channel to request() method
Also parse error on bad status in request method.
This pattern was scattered all over the place.
2018-02-23 10:36:58 +04:00
Geoff Hickey
59d541f193
Generate the remaining consts. (#55)
* Generate the remaining consts.

There were a number of hand-written consts in go-libvirt, including flag
values for various libvirt functions. Remove these and generate them
instead, so that we now have a complete set, and the naming is
consistent. I used c-for-go to do this generation, but turned off any
cgo usage by the generated code - we don't want or need to introduce a
dependency on cgo just to get constants from C headers. All code is
still generated using 'go generate ./...', which now calls a wrapper
script for added robustness.

This change also returns to using Go types for flags for most libvirt
functions, instead of plain integers.
2018-01-03 15:19:28 -05:00
Geoff Hickey
fcd4f72b3c Rename the main structure types for clarity
libvirt follows a convention where structure types used in its API are
named "remote_nonnull_domain", and optional values for those  structures
are called "remote_domain". The generator was translating these into go
names like "NonnullDomain" and "Domain". In go this seems unnatural, and
doesn't match the way the pre-generator version of go-libvirt named
things. So this commit changes the names: "remote_nonnull_domain" will
now be "Domain" in go; "remote_domain" will be "OptDomain". This pattern
is applied to all types.
2017-11-20 13:50:32 -05:00
Geoff Hickey
1e71d0e45e Shorten an error path 2017-11-16 19:27:00 -05:00
Geoff Hickey
3c5bd59dc7 Build changes:
- Bump the minimum libvirt version from 1.2.2 to 1.2.12, because
virDomainDefineXMLFlags wasn't introduced until that version.
- Use the correct format for the generated file notice, so that golint
ignores the generated files.
2017-11-16 19:14:34 -05:00
Geoff Hickey
57b9cae05d add licenses and fix the license checking script. 2017-11-16 18:44:11 -05:00
Geoff Hickey
71f606ddd7 Add comments to generated code, fix integration test. 2017-11-16 17:14:05 -05:00
Geoff Hickey
4ec9ce0aea git add parser output files in lvgen 2017-11-16 15:56:36 -05:00
Geoff Hickey
f0eaf10a26 Review comments 2017-11-16 15:49:40 -05:00
Geoff Hickey
96763e5316 Rename "String" type to "OptString" 2017-11-16 14:36:31 -05:00
Geoff Hickey
b59e9d42f4 Migrate all libvirt calls to the generated code.
- Update libvirt.go so that all libvirt calls now go through the
generated routines.
- Remove some libvirt routines that had the same name as generated ones,
leave the rest as convenience routines.
- Fix the handling of Optional-values (the declarations of which in the
.x file look like pointers)
2017-11-16 14:17:46 -05:00
Geoff Hickey
a3bd42a5b1 Cleanup, and fix decoding of TypedParams. 2017-11-14 18:59:55 -05:00
Geoff Hickey
deb7a54ff8 Generate libvirt procedure wrappers.
The generated wrappers have an argument for every field in their "Args"
struct, and return everything in their "Ret" struct (these structs are
defined in the protocol file, and identified by procedure name).
Marshaling and unmarshaling is handled inside the generated procedures.
2017-11-13 15:18:18 -05:00
Geoff Hickey
fb16117ff9 Generate libvirt structs, unions, typedefs. 2017-11-07 16:05:12 -05:00
Geoff Hickey
f88cbd7a8e Move the constants.go template to its own file. 2017-11-03 13:58:41 -04:00
Geoff Hickey
6e924657b1 Move the rpcgen lexer to its own file. 2017-11-03 13:37:16 -04:00
Geoff Hickey
5a6654f07a Generate libvirt constants from libvirt sources.
- Add a yacc-based parser and a hand-written lexer to read the
remote_protocol.x file from libvirt's sources.
- Use the new parser to generate the constants used to communicate with
libvirt.
2017-11-02 19:42:44 -04:00
Geoff Hickey
c8e4b6a7b8 Add Get/SetBlockIoTune to go-libvirt API. (#45)
* Add Get/SetBlockIoTune to go-libvirt API.

This adds two libvirt entry points to the go-libvirt API:
virDomainSetBlockIoTune and virDomainGetBlockIoTune. These can be used
to control block device throttling for a VM.
2017-08-31 11:21:31 -04:00
Amanda H. L. de Andrade
9ca7034516 Add DomainMemoryStats method (#38) (#39) 2017-06-02 11:28:20 -06:00
Alexander Polakov
c09ce7b21d Add Reboot and Reset methods (#37) 2017-05-04 11:30:22 -05:00
Alexander Polakov
208ef2aff1 Add Shutdown() method (#36)
* Add Shutdown() method
2017-05-04 10:39:45 -05:00
Alexander Polakov
d41d9eb855 Add DomainCreate method (#35)
* Adds DomainCreateWithFlags
2017-05-04 10:17:25 -05:00
Ben LeMasurier
2609dd2697 Add Secrets() (#29)
This adds the `Secrets()` method, used to retrieve all secrets managed
by the libvirt daemon.
2017-01-19 20:40:31 -06:00
Ben LeMasurier
cfa567708b Adds StoragePool(), StoragePoolRefresh() (#28)
This adds two new methods:
- `StoragePool()`, used to lookup a storage pool by name.
- `StoragePoolRefresh()`, used to refresh a storage pool by name.
2017-01-09 14:54:30 -07:00
Ben LeMasurier
591f6798f1 Adds StoragePools() (#27)
* Adds StoragePools()

This adds the ability to list storage pools.
2017-01-06 15:58:27 -06:00
Michael Bruskov
85674d25f7 Add DefineXML() (#26) 2016-12-09 09:49:14 -07:00
Michael Bruskov
fe0f99a7c1 Add DomainState method. (#23)
Returns state of the domain.
2016-12-02 10:54:04 -07:00
Ben LeMasurier
5a1fe4c14a Adds Capabilities()
This adds a new method, Capabilities(), which returns an XML
definition of the hypervisor's system capabilities, much like
`virsh capabilities`.

I've only included integration tests for these two methods due to the
large amount of data returned by the capabilities call.
2016-12-01 14:09:24 -07:00
Ben LeMasurier
c6e0d02f28 Adds support for dumping domain XML
This adds support for dumping a domain's XML definition, akin to `virsh
dumpxml <domain>`. The returned data is quite large so I've included an
integration test rather than adding a huge blob of hex to `libvirttest`.
2016-11-30 19:31:45 -07:00
Simarpreet Singh
693bffa997
destroy: Adding the ability to destroy a domain.
Signed-off-by: Simarpreet Singh <simar@linux.com>
2016-11-02 20:47:37 -07:00
Ben LeMasurier
d556125e20 Add support for undefining a domain 2016-09-28 15:37:06 -06:00
Charlie Drage
4603ca308d Add note to constants
Adds a small note to the constants.go file for creating a new api call
within libvirt.go
2016-08-31 13:34:49 -04:00
Ben LeMasurier
128bc7d448
Add support for domain migrations
This adds basic support for domain migrations from one hypervisor to
another. Migration options, e.g., live, tunneled, compressed, etc..,
are specified by the constants described `constants.Migrate*`.

Two unknowns remain, Libvirt specifies `RemoteParameters` and `CookieIn`.
In testing both values are always set to 0 by `virsh` and the source
does not provide clear definitions of their purpose. For now, using
the same zero'd values used by `virsh` will be Good Enough.
2016-08-21 09:10:30 -06:00
ricky
92abb8c314 adding virsh migrate-setspeed 2016-08-04 14:29:29 -04:00
Ben LeMasurier
65d878e075 Adds test package
This splits out the mock libvirt server for testing within
other packages. Constants from the main libvirt package
have been moved to a separate package, constants, for shared access.
2016-05-20 10:50:10 -06:00