1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
package libvirt
import (
"os"
"github.com/libvirt/libvirt-go-xml"
)
func newFilesystemDef() libvirtxml.DomainFilesystem {
return libvirtxml.DomainFilesystem{
Type: "mount", // This is the only type used by qemu/kvm
AccessMode: "mapped", // A safe default value
ReadOnly: &libvirtxml.DomainFilesystemReadOnly{},
}
}
// Creates a domain definition with the defaults
// the provider uses
func newDomainDef() libvirtxml.Domain {
domainDef := libvirtxml.Domain{
OS: &libvirtxml.DomainOS{
Type: &libvirtxml.DomainOSType{
Type: "hvm",
},
},
Memory: &libvirtxml.DomainMemory{
Unit: "MiB",
Value: 512,
},
VCPU: &libvirtxml.DomainVCPU{
Placement: "static",
Value: 1,
},
CPU: &libvirtxml.DomainCPU{},
Devices: &libvirtxml.DomainDeviceList{
Graphics: []libvirtxml.DomainGraphic{
libvirtxml.DomainGraphic{
Type: "spice",
AutoPort: "yes",
},
},
Channels: []libvirtxml.DomainChannel{
libvirtxml.DomainChannel{
Type: "unix",
Source: &libvirtxml.DomainChardevSource{
Mode: "bind",
},
Target: &libvirtxml.DomainChannelTarget{
Type: "virtio",
Name: "org.qemu.guest_agent.0",
},
},
},
RNGs: []libvirtxml.DomainRNG{
libvirtxml.DomainRNG{
Model: "virtio",
Backend: &libvirtxml.DomainRNGBackend{
Model: "random",
},
},
},
},
Features: &libvirtxml.DomainFeatureList{
PAE: &libvirtxml.DomainFeature{},
ACPI: &libvirtxml.DomainFeature{},
APIC: &libvirtxml.DomainFeatureAPIC{},
},
}
if v := os.Getenv("TERRAFORM_LIBVIRT_TEST_DOMAIN_TYPE"); v != "" {
domainDef.Type = v
} else {
domainDef.Type = "kvm"
}
return domainDef
}
|