From 4cc7e0862826e6703642cfbf6440e3ef8fd8da0e Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Sat, 17 Jun 2017 12:23:52 +0200 Subject: all: use osutil.IsExist instead of os.Stat --- vm/kvm/kvm.go | 6 +++--- vm/odroid/odroid.go | 8 ++++---- vm/qemu/qemu.go | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) (limited to 'vm') diff --git a/vm/kvm/kvm.go b/vm/kvm/kvm.go index c18ed27c7..5c4c0f036 100644 --- a/vm/kvm/kvm.go +++ b/vm/kvm/kvm.go @@ -78,8 +78,8 @@ func ctor(env *vmimpl.Env) (vmimpl.Pool, error) { if _, err := exec.LookPath(cfg.Lkvm); err != nil { return nil, err } - if _, err := os.Stat(cfg.Kernel); err != nil { - return nil, fmt.Errorf("kernel file '%v' does not exist: %v", cfg.Kernel, err) + if !osutil.IsExist(cfg.Kernel) { + return nil, fmt.Errorf("kernel file '%v' does not exist", cfg.Kernel) } if cfg.Cpu < 1 || cfg.Cpu > 1024 { return nil, fmt.Errorf("invalid config param cpu: %v, want [1-1024]", cfg.Cpu) @@ -268,7 +268,7 @@ func (inst *instance) Run(timeout time.Duration, stop <-chan bool, command strin resultErr = vmimpl.TimeoutErr break loop case <-secondTicker.C: - if _, err := os.Stat(cmdFile); err != nil { + if !osutil.IsExist(cmdFile) { resultErr = nil break loop } diff --git a/vm/odroid/odroid.go b/vm/odroid/odroid.go index dcc4135b6..69c77b9c6 100644 --- a/vm/odroid/odroid.go +++ b/vm/odroid/odroid.go @@ -76,11 +76,11 @@ func ctor(env *vmimpl.Env) (vmimpl.Pool, error) { if cfg.Hub_Port == 0 { return nil, fmt.Errorf("config param hub_port is empty") } - if _, err := os.Stat(cfg.Sshkey); err != nil { - return nil, fmt.Errorf("ssh key '%v' does not exist: %v", cfg.Sshkey, err) + if !osutil.IsExist(cfg.Sshkey) { + return nil, fmt.Errorf("ssh key '%v' does not exist", cfg.Sshkey) } - if _, err := os.Stat(cfg.Console); err != nil { - return nil, fmt.Errorf("console file '%v' does not exist: %v", cfg.Console, err) + if !osutil.IxExist(cfg.Console) { + return nil, fmt.Errorf("console file '%v' does not exist", cfg.Console) } pool := &Pool{ cfg: cfg, diff --git a/vm/qemu/qemu.go b/vm/qemu/qemu.go index ba0cb6f78..62fb408f9 100644 --- a/vm/qemu/qemu.go +++ b/vm/qemu/qemu.go @@ -83,11 +83,11 @@ func ctor(env *vmimpl.Env) (vmimpl.Pool, error) { return nil, fmt.Errorf("9p image requires kernel") } } else { - if _, err := os.Stat(env.Image); err != nil { - return nil, fmt.Errorf("image file '%v' does not exist: %v", env.Image, err) + if !osutil.IsExist(env.Image) { + return nil, fmt.Errorf("image file '%v' does not exist", env.Image) } - if _, err := os.Stat(cfg.Sshkey); err != nil { - return nil, fmt.Errorf("ssh key '%v' does not exist: %v", cfg.Sshkey, err) + if !osutil.IsExist(cfg.Sshkey) { + return nil, fmt.Errorf("ssh key '%v' does not exist", cfg.Sshkey) } } if cfg.Cpu <= 0 || cfg.Cpu > 1024 { -- cgit mrf-deployment