Skip to content

Commit a3882af

Browse files
author
Daniel Hiltgen
committed
Add disk cach/io tunables
Often for test scenarios the reliability of the VM isn't important, but running faster is, so lets expose a few more I/O tunables.
1 parent 8d63cea commit a3882af

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

kvm.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ const (
4848
<readonly/>
4949
</disk>
5050
<disk type='file' device='disk'>
51+
<driver name='qemu' type='raw' cache='{{.CacheMode}}' io='{{.IOMode}}' />
5152
<source file='{{.DiskPath}}'/>
5253
<target dev='hda' bus='ide'/>
5354
</disk>
@@ -85,6 +86,8 @@ type Driver struct {
8586
CaCertPath string
8687
PrivateKeyPath string
8788
DiskPath string
89+
CacheMode string
90+
IOMode string
8891
connectionString string
8992
conn *libvirt.VirConnection
9093
VM *libvirt.VirDomain
@@ -120,6 +123,16 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
120123
Usage: "The URL of the boot2docker image. Defaults to the latest available version",
121124
Value: "",
122125
},
126+
mcnflag.StringFlag{
127+
Name: "kvm-cache-mode",
128+
Usage: "Disk cache mode: default, none, writethrough, writeback, directsync, or unsafe",
129+
Value: "default",
130+
},
131+
mcnflag.StringFlag{
132+
Name: "kvm-io-mode",
133+
Usage: "Disk IO mode: threads, native",
134+
Value: "threads",
135+
},
123136
/* Not yet implemented
124137
mcnflag.Flag{
125138
Name: "kvm-no-share",
@@ -168,6 +181,8 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
168181
d.CPU = flags.Int("kvm-cpu-count")
169182
d.Network = flags.String("kvm-network")
170183
d.Boot2DockerURL = flags.String("kvm-boot2docker-url")
184+
d.CacheMode = flags.String("kvm-cache-mode")
185+
d.IOMode = flags.String("kvm-io-mode")
171186

172187
d.SwarmMaster = flags.Bool("swarm-master")
173188
d.SwarmHost = flags.String("swarm-host")

0 commit comments

Comments
 (0)