Raw block device passthrough support
This commit is contained in:
parent
0870f8113a
commit
003b562e48
7 changed files with 133 additions and 26 deletions
|
|
@ -4,7 +4,11 @@ package vm
|
|||
|
||||
import (
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func prepareVMCmd(cmd *exec.Cmd) {
|
||||
|
|
@ -17,3 +21,26 @@ func prepareVMCmd(cmd *exec.Cmd) {
|
|||
func terminateProcess(pid int) error {
|
||||
return syscall.Kill(-pid, syscall.SIGTERM)
|
||||
}
|
||||
|
||||
// This is never used except for a band-aid that would check
|
||||
// that there are no double-mounts.
|
||||
func checkDeviceSeemsMounted(devPathPrefix string) (bool, error) {
|
||||
absDevPathPrefix, err := filepath.Abs(devPathPrefix)
|
||||
if err != nil {
|
||||
return false, errors.Wrap(err, "get abs path")
|
||||
}
|
||||
|
||||
mounts, err := exec.Command("mount").Output()
|
||||
if err != nil {
|
||||
return false, errors.Wrap(err, "run mount command")
|
||||
}
|
||||
|
||||
for _, line := range strings.Split(string(mounts), "\n") {
|
||||
// I know, I know, this is a rare band-aid.
|
||||
if strings.HasPrefix(line, devPathPrefix) || strings.HasPrefix(line, absDevPathPrefix) {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
|
||||
return false, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue