From cd61fb2e6f9d2a7bbd3c4db2ab9091674746126d Mon Sep 17 00:00:00 2001 From: Solomon Hykes Date: Tue, 15 Oct 2013 23:56:04 +0000 Subject: [PATCH] WIP: debugging dm-base-hash + dm-refactor-init --- devmapper/devmapper.go | 3 +++ runtime_test.go | 12 +++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/devmapper/devmapper.go b/devmapper/devmapper.go index a925c1a996..c08e10171c 100644 --- a/devmapper/devmapper.go +++ b/devmapper/devmapper.go @@ -353,6 +353,9 @@ func AttachLoopDevice(filename string) (*os.File, error) { var fd C.int res := C.attach_loop_device(c_filename, &fd) if res == nil { + if os.Getenv("DEBUG") != "" { + C.perror(C.CString(fmt.Sprintf("[debug] Error attach_loop_device(%s, $#v)", c_filename, &fd))) + } return nil, ErrAttachLoopbackDevice } defer free(res) diff --git a/runtime_test.go b/runtime_test.go index d0c489de7a..dfb6306c5f 100644 --- a/runtime_test.go +++ b/runtime_test.go @@ -1,6 +1,7 @@ package docker import ( + "path" "bytes" "fmt" "github.com/dotcloud/docker/devmapper" @@ -107,12 +108,15 @@ func removeDev(name string) error { } func cleanupDevMapper() error { + filter := "docker-" + path.Base(unitTestStoreBase) + utils.Debugf("Filtering out %s\n", filter) // Unmount any leftover mounts from previous unit test runs if data, err := ioutil.ReadFile("/proc/mounts"); err != nil { return err } else { for _, line := range strings.Split(string(data), "\n") { - if cols := strings.Split(line, " "); len(cols) >= 2 && strings.HasPrefix(cols[0], "/dev/mapper/docker-unit-tests-devices") { + if cols := strings.Split(line, " "); len(cols) >= 2 && strings.HasPrefix(cols[0], path.Join("/dev/mapper", filter)) { + utils.Debugf("[devmapper cleanup] Unmounting device: %s", cols[1]) if err := syscall.Unmount(cols[1], 0); err != nil { return fmt.Errorf("Unable to unmount %s needed to get a freash unit test environment: %s", cols[1], err) } @@ -120,6 +124,7 @@ func cleanupDevMapper() error { } } + utils.Debugf("[devmapper cleanup] looking for leftover devices") // Remove any leftover devmapper devices from previous unit run tests infos, err := ioutil.ReadDir("/dev/mapper") if err != nil { @@ -131,8 +136,8 @@ func cleanupDevMapper() error { } pools := []string{} for _, info := range infos { - if name := info.Name(); strings.HasPrefix(name, "docker-unit-tests-devices-") { - if name == "docker-unit-tests-devices-pool" { + if name := info.Name(); strings.HasPrefix(name, filter + "-") { + if strings.HasSuffix(name, "-pool") { pools = append(pools, name) } else { if err := removeDev(name); err != nil { @@ -143,6 +148,7 @@ func cleanupDevMapper() error { } // We need to remove the pool last as the other devices block it for _, pool := range pools { + utils.Debugf("[devmapper cleanup] Removing pool: %s", pool) if err := removeDev(pool); err != nil { return err }