Skip to content

Commit

Permalink
Merge pull request #121 from penberg/fix-osx-build
Browse files Browse the repository at this point in the history
Fix O_DIRECT build breakage on OS X
  • Loading branch information
penberg committed Oct 4, 2014
2 parents 5a5aa56 + 7f9d73a commit b231f35
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 8 deletions.
9 changes: 1 addition & 8 deletions hypervisor/qemu/qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"regexp"
"runtime"
"strconv"
"syscall"
)

type VMConfig struct {
Expand Down Expand Up @@ -227,14 +226,8 @@ func ParseVersion(text string) (*Version, error) {
}, nil
}

func isDirectIOSupported(path string) bool {
f, err := os.OpenFile(path, syscall.O_DIRECT, 0)
defer f.Close()
return err == nil
}

func (c *VMConfig) vmDriveCache() string {
if isDirectIOSupported(c.Image) {
if util.IsDirectIOSupported(c.Image) {
return "none"
}
return "unsafe"
Expand Down
12 changes: 12 additions & 0 deletions util/util_darwin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright (C) 2014 Cloudius Systems, Ltd.
*
* This work is open source software, licensed under the terms of the
* BSD license as described in the LICENSE file in the top-level directory.
*/

package util

func IsDirectIOSupported(path string) bool {
return false
}
19 changes: 19 additions & 0 deletions util/util_linux.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright (C) 2014 Cloudius Systems, Ltd.
*
* This work is open source software, licensed under the terms of the
* BSD license as described in the LICENSE file in the top-level directory.
*/

package util

import (
"os"
"syscall"
)

func IsDirectIOSupported(path string) bool {
f, err := os.OpenFile(path, syscall.O_DIRECT, 0)
defer f.Close()
return err == nil
}
4 changes: 4 additions & 0 deletions util/util_win.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ import (
func Connect(network, path string) (net.Conn, error) {
return npipe.Dial(path)
}

func IsDirectIOSupported(path string) bool {
return false
}

0 comments on commit b231f35

Please sign in to comment.