| ... | ... |
@@ -353,6 +353,9 @@ func AttachLoopDevice(filename string) (*os.File, error) {
|
| 353 | 353 |
var fd C.int |
| 354 | 354 |
res := C.attach_loop_device(c_filename, &fd) |
| 355 | 355 |
if res == nil {
|
| 356 |
+ if os.Getenv("DEBUG") != "" {
|
|
| 357 |
+ C.perror(C.CString(fmt.Sprintf("[debug] Error attach_loop_device(%s, $#v)", c_filename, &fd)))
|
|
| 358 |
+ } |
|
| 356 | 359 |
return nil, ErrAttachLoopbackDevice |
| 357 | 360 |
} |
| 358 | 361 |
defer free(res) |
| ... | ... |
@@ -1,6 +1,7 @@ |
| 1 | 1 |
package docker |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 |
+ "path" |
|
| 4 | 5 |
"bytes" |
| 5 | 6 |
"fmt" |
| 6 | 7 |
"github.com/dotcloud/docker/devmapper" |
| ... | ... |
@@ -107,12 +108,15 @@ func removeDev(name string) error {
|
| 107 | 107 |
} |
| 108 | 108 |
|
| 109 | 109 |
func cleanupDevMapper() error {
|
| 110 |
+ filter := "docker-" + path.Base(unitTestStoreBase) |
|
| 111 |
+ utils.Debugf("Filtering out %s\n", filter)
|
|
| 110 | 112 |
// Unmount any leftover mounts from previous unit test runs |
| 111 | 113 |
if data, err := ioutil.ReadFile("/proc/mounts"); err != nil {
|
| 112 | 114 |
return err |
| 113 | 115 |
} else {
|
| 114 | 116 |
for _, line := range strings.Split(string(data), "\n") {
|
| 115 |
- if cols := strings.Split(line, " "); len(cols) >= 2 && strings.HasPrefix(cols[0], "/dev/mapper/docker-unit-tests-devices") {
|
|
| 117 |
+ if cols := strings.Split(line, " "); len(cols) >= 2 && strings.HasPrefix(cols[0], path.Join("/dev/mapper", filter)) {
|
|
| 118 |
+ utils.Debugf("[devmapper cleanup] Unmounting device: %s", cols[1])
|
|
| 116 | 119 |
if err := syscall.Unmount(cols[1], 0); err != nil {
|
| 117 | 120 |
return fmt.Errorf("Unable to unmount %s needed to get a freash unit test environment: %s", cols[1], err)
|
| 118 | 121 |
} |
| ... | ... |
@@ -120,6 +124,7 @@ func cleanupDevMapper() error {
|
| 120 | 120 |
} |
| 121 | 121 |
} |
| 122 | 122 |
|
| 123 |
+ utils.Debugf("[devmapper cleanup] looking for leftover devices")
|
|
| 123 | 124 |
// Remove any leftover devmapper devices from previous unit run tests |
| 124 | 125 |
infos, err := ioutil.ReadDir("/dev/mapper")
|
| 125 | 126 |
if err != nil {
|
| ... | ... |
@@ -131,8 +136,8 @@ func cleanupDevMapper() error {
|
| 131 | 131 |
} |
| 132 | 132 |
pools := []string{}
|
| 133 | 133 |
for _, info := range infos {
|
| 134 |
- if name := info.Name(); strings.HasPrefix(name, "docker-unit-tests-devices-") {
|
|
| 135 |
- if name == "docker-unit-tests-devices-pool" {
|
|
| 134 |
+ if name := info.Name(); strings.HasPrefix(name, filter + "-") {
|
|
| 135 |
+ if strings.HasSuffix(name, "-pool") {
|
|
| 136 | 136 |
pools = append(pools, name) |
| 137 | 137 |
} else {
|
| 138 | 138 |
if err := removeDev(name); err != nil {
|
| ... | ... |
@@ -143,6 +148,7 @@ func cleanupDevMapper() error {
|
| 143 | 143 |
} |
| 144 | 144 |
// We need to remove the pool last as the other devices block it |
| 145 | 145 |
for _, pool := range pools {
|
| 146 |
+ utils.Debugf("[devmapper cleanup] Removing pool: %s", pool)
|
|
| 146 | 147 |
if err := removeDev(pool); err != nil {
|
| 147 | 148 |
return err |
| 148 | 149 |
} |