避免nil指针访问

This commit is contained in:
ioito
2019-04-27 17:06:25 +08:00
parent c6681e6dbb
commit 9e1f577c08
+4 -1
View File
@@ -1175,7 +1175,10 @@ func (self *SGuest) PerformRebuildRoot(ctx context.Context, userCred mcclient.To
func (self *SGuest) GetTemplateId() string {
gdc := self.CategorizeDisks()
return gdc.Root.GetTemplateId()
if gdc.Root != nil {
gdc.Root.GetTemplateId()
}
return ""
}
func (self *SGuest) StartRebuildRootTask(ctx context.Context, userCred mcclient.TokenCredential, imageId string, needStop, autoStart bool, passwd string, resetPasswd bool, allDisk bool) error {