Update moby tool and qemu fixes

- no longer uses several of the `mkimage-*` tools in favour of dogfooding
with `linuxkit` and using the `mkimage` package.
- fix the qemu docker container fallbacks to work better when multiple
paths are used for disks and the image.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
This commit is contained in:
Justin Cormack
2017-06-02 16:41:36 +01:00
parent 62cb96dec1
commit e782a469d5
14 changed files with 60 additions and 286 deletions

View File

@@ -208,24 +208,32 @@ func runQemuLocal(config QemuConfig) error {
}
func runQemuContainer(config QemuConfig) error {
var wd string
cwd, err := os.Getwd()
if err != nil {
return err
}
var binds []string
if filepath.IsAbs(config.Path) {
// Split the path
wd, config.Path = filepath.Split(config.Path)
log.Debugf("Path: %s", config.Path)
binds = append(binds, "-v", fmt.Sprintf("%[1]s:%[1]s", filepath.Dir(config.Path)))
} else {
var err error
wd, err = os.Getwd()
if err != nil {
return err
binds = append(binds, "-v", fmt.Sprintf("%[1]s:%[1]s", cwd))
}
// also try to bind mount disk paths so the command works
for _, d := range config.Disks {
if filepath.IsAbs(d.Path) {
binds = append(binds, "-v", fmt.Sprintf("%[1]s:%[1]s", filepath.Dir(d.Path)))
} else {
binds = append(binds, "-v", fmt.Sprintf("%[1]s:%[1]s", cwd))
}
}
var args []string
config, args = buildQemuCmdline(config)
dockerArgs := []string{"run", "--interactive", "--rm", "-v", fmt.Sprintf("%s:%s", wd, "/tmp"), "-w", "/tmp"}
dockerArgsImg := []string{"run", "--rm", "-v", fmt.Sprintf("%s:%s", wd, "/tmp"), "-w", "/tmp"}
dockerArgs := append([]string{"run", "--interactive", "--rm", "-w", cwd}, binds...)
dockerArgsImg := append([]string{"run", "--rm", "-w", cwd}, binds...)
if terminal.IsTerminal(int(os.Stdin.Fd())) {
dockerArgs = append(dockerArgs, "--tty")
@@ -327,8 +335,8 @@ func buildQemuCmdline(config QemuConfig) (QemuConfig, []string) {
// build kernel boot config from kernel/initrd/cmdline
if config.Kernel {
qemuKernelPath := buildPath(config.Path, "-kernel")
qemuInitrdPath := buildPath(config.Path, "-initrd.img")
qemuKernelPath := config.Path + "-kernel"
qemuInitrdPath := config.Path + "-initrd.img"
qemuArgs = append(qemuArgs, "-kernel", qemuKernelPath)
qemuArgs = append(qemuArgs, "-initrd", qemuInitrdPath)
cmdlineString, err := ioutil.ReadFile(config.Path + "-cmdline")
@@ -377,16 +385,6 @@ func discoverBackend(config QemuConfig) QemuConfig {
return config
}
func buildPath(prefix string, postfix string) string {
path := prefix + postfix
if filepath.IsAbs(path) {
if _, err := os.Stat(path); os.IsNotExist(err) {
log.Fatalf("File [%s] does not exist in current directory", path)
}
}
return path
}
type multipleFlag []string
type publishedPorts struct {