summaryrefslogtreecommitdiff
path: root/libvirt/volume_def.go
blob: 3f4a9012e1f0af08f03b752c98f5485664e73d93 (plain)
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
package libvirt

import (
	"encoding/xml"
)

type defBackingStore struct {
	Path   string `xml:"path"`
	Format struct {
		Type string `xml:"type,attr"`
	} `xml:"format"`
}

type defVolume struct {
	XMLName xml.Name `xml:"volume"`
	Name    string   `xml:"name"`
	Target  struct {
		Format struct {
			Type string `xml:"type,attr"`
		} `xml:"format"`
		Permissions struct {
			Mode int `xml:"mode,omitempty"`
		} `xml:"permissions,omitempty"`
	} `xml:"target"`
	Allocation int `xml:"allocation"`
	Capacity   struct {
		Unit   string `xml:"unit,attr"`
		Amount int    `xml:"chardata"`
	} `xml:"capacity"`
	BackingStore *defBackingStore `xml:"backingStore,omitempty"`
}

func newDefVolume() defVolume {
	volumeDef := defVolume{}
	volumeDef.Target.Format.Type = "qcow2"
	volumeDef.Target.Permissions.Mode = 644
	volumeDef.Capacity.Unit = "bytes"
	volumeDef.Capacity.Amount = 1
	return volumeDef
}