From cc9a458be93e6152b0b047170cfb033a260cfad7 Mon Sep 17 00:00:00 2001 From: wanyaoqi Date: Mon, 16 Sep 2019 12:09:24 +0800 Subject: [PATCH] fix init listen interface --- pkg/hostman/hostinfo/hostinfo.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pkg/hostman/hostinfo/hostinfo.go b/pkg/hostman/hostinfo/hostinfo.go index 73606f29ca..6683dccb41 100644 --- a/pkg/hostman/hostinfo/hostinfo.go +++ b/pkg/hostman/hostinfo/hostinfo.go @@ -139,11 +139,6 @@ func (h *SHostInfo) parseConfig() error { if h.GetMemory() < 64 { // MB return fmt.Errorf("Not enough memory!") } - if len(options.HostOptions.ListenInterface) > 0 { - h.MasterNic = netutils2.NewNetInterface(options.HostOptions.ListenInterface) - } else { - h.MasterNic = nil - } for _, n := range options.HostOptions.Networks { nic, err := NewNIC(n) if err != nil { @@ -156,6 +151,14 @@ func (h *SHostInfo) parseConfig() error { return err } } + if len(options.HostOptions.ListenInterface) > 0 { + h.MasterNic = netutils2.NewNetInterface(options.HostOptions.ListenInterface) + if len(h.MasterNic.Addr) == 0 { + return fmt.Errorf("Listen interface %s master not have IP", options.HostOptions.ListenInterface) + } + } else { + h.MasterNic = nil + } if man, err := isolated_device.NewManager(h); err != nil { return fmt.Errorf("NewIsolatedManager: %v", err)