Set up the IP address for the qemu driver

Assume "user" networking, for now at least.
pull/13639/head
Anders F Björklund 2022-04-04 20:12:12 +02:00
parent 77ed383578
commit 69653073da
2 changed files with 10 additions and 0 deletions

View File

@ -58,6 +58,10 @@ func HostIP(host *host.Host, clusterName string) (net.IP, error) {
return []byte{}, errors.Wrap(err, "Error converting VM/Host IP address to IPv4 address")
}
return net.IPv4(vmIP[0], vmIP[1], vmIP[2], byte(1)), nil
case driver.QEMU2:
return net.ParseIP("10.0.2.2"), nil
case driver.QEMU:
return net.ParseIP("10.0.2.2"), nil
case driver.HyperV:
v := reflect.ValueOf(host.Driver).Elem()
var hypervVirtualSwitch string
@ -147,6 +151,9 @@ func DriverIP(api libmachine.API, machineName string) (net.IP, error) {
if driver.IsKIC(host.DriverName) {
ipStr = oci.DefaultBindIPV4
}
if driver.IsQEMU(host.DriverName) {
ipStr = "127.0.0.1"
}
ip := net.ParseIP(ipStr)
if ip == nil {
return nil, fmt.Errorf("parsing IP: %s", ipStr)

View File

@ -122,6 +122,9 @@ func saveHost(api libmachine.API, h *host.Host, cfg *config.ClusterConfig, n *co
if err != nil {
return err
}
if ip == "127.0.0.1" && driver.IsQEMU(h.Driver.DriverName()) {
ip = "10.0.2.15"
}
n.IP = ip
return config.SaveNode(cfg, n)
}