fix: guest get host nil pointer panic

This commit is contained in:
Qiu Jian
2019-09-02 18:17:55 +08:00
parent ce63ff455f
commit 4a5ab0cc19
+3 -1
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
}