Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support alternatives to default (rtl8139) NIC type #74

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ PREFIX=docker-machine-driver-kvm
MACHINE_VERSION=v0.10.0
GO_VERSION=1.8.1
DESCRIBE=$(shell git describe --tags)
ORIGIN=$(shell git remote -v | grep '(push)$$' | sed -e 's!\S\S*\s\s*\(\S\S*\)\s.*!\1!')
REPOSITORY=$(shell echo '$(ORIGIN)' | sed -e 's!\(https://\|\S\S*@\)\([^/:][^/:]*\)[/:]\(.*\)\.git$$!https://\2/\3!')

TARGETS=$(addprefix $(PREFIX)-, alpine3.4 alpine3.5 ubuntu14.04 ubuntu16.04 centos7)

Expand All @@ -27,11 +29,15 @@ release: build
@echo ""
@for bin in $(PREFIX)-* ; do \
target=$$(echo $${bin} | cut -f5- -d-) ; \
md5=$$(md5sum $${bin}) ; \
echo "* $${target} - md5: $${md5}" ; \
md5=$$(md5sum $${bin} | cut -f1 -d' ') ; \
sha256=$$(sha256sum $${bin} | cut -f1 -d' ') ; \
echo "#### $${target}" ; \
echo "$${bin}" ; \
echo "* SHA-256: $${sha256}" ; \
echo "* MD5: $${md5}" ; \
echo '```' ; \
echo " curl -L https://github.com/dhiltgen/docker-machine-kvm/releases/download/$(DESCRIBE)/$${bin} > /usr/local/bin/$(PREFIX) \\ " ; \
echo " chmod +x /usr/local/bin/$(PREFIX)" ; \
echo "curl -L $(REPOSITORY)/releases/download/$(DESCRIBE)/$${bin} > /usr/local/bin/$(PREFIX) && \\"; \
echo "chmod +x /usr/local/bin/$(PREFIX)" ; \
echo '```' ; \
done

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ Here are all currently driver parameters listed that you can use.
| **--kvm-boot2docker-url** | Sets the url from which host the image is loaded. By default it's not set. |
| **--kvm-cache-mode** | Sets the caching mode of the kvm machine. Defaults to `default`. |
| **--kvm-io-mode-url** | Sets the disk io mode of the kvm machine. Defaults to `threads`. |
| **--kvm-nic-type** | Sets the model of the network interfaces of the kvm machine. Defaults to `default`. |



14 changes: 14 additions & 0 deletions kvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ const (
<listen type='address' address='127.0.0.1'/>
</graphics>
<interface type='network'>
{{.NICModelElement}}
<source network='{{.Network}}'/>
</interface>
<interface type='network'>
{{.NICModelElement}}
<source network='{{.PrivateNetwork}}'/>
</interface>
</devices>
Expand Down Expand Up @@ -91,6 +93,7 @@ type Driver struct {
DiskPath string
CacheMode string
IOMode string
NICModelElement string
connectionString string
conn *libvirt.Connect
VM *libvirt.Domain
Expand Down Expand Up @@ -136,6 +139,11 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
Usage: "Disk IO mode: threads, native",
Value: "threads",
},
mcnflag.StringFlag{
Name: "kvm-nic-type",
Usage: "Network interface model type: default, e1000, rtl8139, virtio, etc.",
Value: "default",
},
mcnflag.StringFlag{
EnvVar: "KVM_SSH_USER",
Name: "kvm-ssh-user",
Expand Down Expand Up @@ -200,6 +208,12 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
d.SSHUser = flags.String("kvm-ssh-user")
d.SSHPort = 22
d.DiskPath = d.ResolveStorePath(fmt.Sprintf("%s.img", d.MachineName))

if flags.String("kvm-nic-type") == "default" {
d.NICModelElement = ""
} else {
d.NICModelElement = fmt.Sprintf("<model type='%s'/>", flags.String("kvm-nic-type"))
}
return nil
}

Expand Down