Review comments
This commit is contained in:
parent
96763e5316
commit
f0eaf10a26
@ -4,10 +4,10 @@
|
||||
* To regenerate, run 'go generate' in internal/lvgen.
|
||||
*/
|
||||
|
||||
// Package constants contains libvirt procedure identifiers and other enums and
|
||||
// constants.
|
||||
package constants
|
||||
|
||||
// libvirt procedure identifiers and other enums
|
||||
//
|
||||
// These are libvirt procedure numbers which correspond to each respective
|
||||
// API call between remote_internal driver and libvirtd. Each procedure is
|
||||
// identified by a unique number which *may change in any future libvirt
|
||||
|
@ -17,7 +17,7 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/digitalocean/go-libvirt/internal/lvgen"
|
||||
)
|
||||
@ -30,7 +30,7 @@ func main() {
|
||||
fmt.Println("set $LIBVIRT_SOURCE to point to the root of the libvirt sources and retry")
|
||||
os.Exit(1)
|
||||
}
|
||||
lvFile := path.Join(lvPath, protoPath)
|
||||
lvFile := filepath.Join(lvPath, protoPath)
|
||||
rdr, err := os.Open(lvFile)
|
||||
if err != nil {
|
||||
fmt.Printf("failed to open protocol file at %v: %v\n", lvFile, err)
|
||||
|
@ -1,9 +1,8 @@
|
||||
package lvgen
|
||||
|
||||
// This file contains the instructions for regenerating the libvirt bindings.
|
||||
// We do this by parsing the remote_protocol.x file included in the libvirt
|
||||
// sources. Bindings will be generated if you run `go generate` in this
|
||||
// Package lvgen contains the instructions for regenerating the libvirt
|
||||
// bindings. We do this by parsing the remote_protocol.x file included in the
|
||||
// libvirt sources. Bindings will be generated if you run `go generate` in this
|
||||
// directory.
|
||||
package lvgen
|
||||
|
||||
// Before running `go generate`:
|
||||
// 1) Make sure goyacc is installed from golang.org/x/tools (you can use this
|
||||
|
@ -124,7 +124,6 @@ func (l *Lexer) Lex(st *yySymType) int {
|
||||
s := <-l.items
|
||||
l.lastItem = s
|
||||
st.val = s.val
|
||||
// fmt.Println("Lex returning", s)
|
||||
return int(s.typ)
|
||||
}
|
||||
|
||||
|
82
libvirt.go
82
libvirt.go
@ -96,88 +96,6 @@ const (
|
||||
FlagTypedParamStringOkay
|
||||
)
|
||||
|
||||
// Consts relating to TypedParams:
|
||||
const (
|
||||
// TypeParamInt is a C int.
|
||||
TypeParamInt = iota + 1
|
||||
// TypeParamUInt is a C unsigned int.
|
||||
TypeParamUInt
|
||||
// TypeParamLLong is a C long long int.
|
||||
TypeParamLLong
|
||||
// TypeParamULLong is a C unsigned long long int.
|
||||
TypeParamULLong
|
||||
// TypeParamDouble is a C double.
|
||||
TypeParamDouble
|
||||
// TypeParamBoolean is a C char.
|
||||
TypeParamBoolean
|
||||
// TypeParamString is a C char*.
|
||||
TypeParamString
|
||||
|
||||
// TypeParamLast is just an end-of-enum marker.
|
||||
TypeParamLast
|
||||
)
|
||||
|
||||
// TypedParamULongLong contains a 64-bit unsigned integer.
|
||||
type TypedParamULongLong struct {
|
||||
Fld string
|
||||
PType int32
|
||||
Val uint64
|
||||
}
|
||||
|
||||
// Field returns the field name, a string name for the parameter.
|
||||
func (tp *TypedParamULongLong) Field() string {
|
||||
return tp.Fld
|
||||
}
|
||||
|
||||
// Value returns the value for the typed parameter, as an empty interface.
|
||||
func (tp *TypedParamULongLong) Value() interface{} {
|
||||
return tp.Val
|
||||
}
|
||||
|
||||
// NewTypedParamULongLong returns a TypedParam encoding for an unsigned long long.
|
||||
func NewTypedParamULongLong(name string, v uint64) *TypedParamULongLong {
|
||||
// Truncate the field name if it's longer than the limit.
|
||||
if len(name) > constants.TypedParamFieldLength {
|
||||
name = name[:constants.TypedParamFieldLength]
|
||||
}
|
||||
tp := TypedParamULongLong{
|
||||
Fld: name,
|
||||
PType: TypeParamULLong,
|
||||
Val: v,
|
||||
}
|
||||
return &tp
|
||||
}
|
||||
|
||||
// TypedParamString contains a string parameter.
|
||||
type TypedParamString struct {
|
||||
Fld string
|
||||
PType int
|
||||
Val string
|
||||
}
|
||||
|
||||
// Field returns the field name, a string name for the parameter.
|
||||
func (tp *TypedParamString) Field() string {
|
||||
return tp.Fld
|
||||
}
|
||||
|
||||
// Value returns the value for the typed parameter, as an empty interface.
|
||||
func (tp *TypedParamString) Value() interface{} {
|
||||
return tp.Val
|
||||
}
|
||||
|
||||
// NewTypedParamString returns a typed parameter containing the passed string.
|
||||
// func NewTypedParamString(name string, v string) TypedParam {
|
||||
// if len(name) > constants.TypedParamFieldLength {
|
||||
// name = name[:constants.TypedParamFieldLength]
|
||||
// }
|
||||
// tp := TypedParamString{
|
||||
// Fld: name,
|
||||
// PType: TypeParamString,
|
||||
// Val: v,
|
||||
// }
|
||||
// return &tp
|
||||
// }
|
||||
|
||||
const (
|
||||
// DomainXMLFlagSecure dumps XML with sensitive information included.
|
||||
DomainXMLFlagSecure DomainXMLFlags = 1 << iota
|
||||
|
Loading…
Reference in New Issue
Block a user