remove duplicate file operations from virt-launcher
In monitor.go#InitializePrivateDirectories, we call Mkdir and
Chmod twice for the same folder (that contains unix sockets for
the serial and VNC connections). This patch removes those
duplicated calls.
@@ -108,26 +108,12 @@ func GracefulShutdownTriggerInitiate(triggerFile string) error {
}
func InitializePrivateDirectories(baseDir string) error {
- unixPathVNC := filepath.Join(baseDir, "virt-vnc")
- unixPathConsole := filepath.Join(baseDir, "virt-serial0")
-
- err := os.MkdirAll(filepath.Dir(unixPathVNC), 0755)
- if err != nil {
- return err
- }
- err = os.MkdirAll(filepath.Dir(unixPathConsole), 0755)
- if err != nil {
+ if err := os.MkdirAll(baseDir, 0755); err != nil {
return err
}
- err = diskutils.SetFileOwnership("qemu", filepath.Dir(unixPathVNC))
- if err != nil {
+ if err := diskutils.SetFileOwnership("qemu", baseDir); err != nil {
return err
}
- err = diskutils.SetFileOwnership("qemu", filepath.Dir(unixPathConsole))
- if err != nil {
- return err
- }
-
return nil
}
