Merge pull request #14952 from wanyaoqi/fix/check-existing-path

fix(region): format and check existing path
This commit is contained in:
Zexi Li
2022-09-09 10:01:05 +08:00
committed by GitHub
+8
View File
@@ -19,6 +19,7 @@ import (
"database/sql"
"fmt"
"path"
"path/filepath"
"strings"
"time"
@@ -1884,6 +1885,13 @@ func parseDiskInfo(ctx context.Context, userCred mcclient.TokenCredential, info
}
}
}
if info.ExistingPath != "" {
info.ExistingPath = strings.TrimSpace(info.ExistingPath)
_, err := filepath.Rel("/", info.ExistingPath)
if err != nil {
return nil, errors.Wrap(err, "invaild existing path")
}
}
// XXX: do not set default disk size here, set it by each hypervisor driver
// if len(diskConfig.ImageId) > 0 && diskConfig.SizeMb == 0 {
// diskConfig.SizeMb = options.Options.DefaultDiskSize // MB