Merge pull request #2705 from swordqiu/automated-cherry-pick-of-#2703-upstream-release-2.11

Automated cherry pick of #2703: fix: guest get host nil pointer panic
This commit is contained in:
yunion-ci-robot
2019-09-02 21:41:16 +08:00
committed by GitHub

View File

@@ -686,7 +686,9 @@ func (guest *SGuest) CustomizeCreate(ctx context.Context, userCred mcclient.Toke
func (guest *SGuest) GetHost() *SHost {
if len(guest.HostId) > 0 && regutils.MatchUUID(guest.HostId) {
host, _ := HostManager.FetchById(guest.HostId)
return host.(*SHost)
if host != nil {
return host.(*SHost)
}
}
return nil
}