Skip to content

Commit 4852a3e

Browse files
author
Daniel Hiltgen
committed
Minor hardening
1 parent d860ddf commit 4852a3e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

kvm.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import (
2727
const (
2828
connectionString = "qemu:///system"
2929
privateNetworkName = "docker-machines"
30-
dockerConfigDir = "/var/lib/boot2docker"
3130
isoFilename = "boot2docker.iso"
3231
dnsmasqLeases = "/var/lib/libvirt/dnsmasq/%s.leases"
3332
dnsmasqStatus = "/var/lib/libvirt/dnsmasq/%s.status"
@@ -517,7 +516,10 @@ func (d *Driver) getMAC() (string, error) {
517516
return "", err
518517
}
519518
// Always assume the second interface is the one we want
520-
// TODO harden
519+
if len(dom.Devices.Interfaces) < 2 {
520+
return "", fmt.Errorf("VM doesn't have enough network interfaces. Expected at least 2, found %d",
521+
len(dom.Devices.Interfaces))
522+
}
521523
return dom.Devices.Interfaces[1].Mac.Address, nil
522524
}
523525

@@ -580,6 +582,7 @@ func (d *Driver) getIPByMacFromSettings(mac string) (string, error) {
580582
}
581583

582584
func (d *Driver) GetIP() (string, error) {
585+
log.Debugf("GetIP called for %s", d.MachineName)
583586
mac, err := d.getMAC()
584587
if err != nil {
585588
return "", err

0 commit comments

Comments
 (0)