Fixes: #15279
Due to
https://github.com/golang/go/commit/7904946eeb35faece61bbf6f5b3cc8be2f519c17
the devices field is dropped.
This solution works on go1.4 and go1.5
Signed-off-by: Vincent Batts <vbatts@redhat.com>
| ... | ... |
@@ -1509,12 +1509,16 @@ func (devices *DeviceSet) deactivatePool() error {
|
| 1509 | 1509 |
if err != nil {
|
| 1510 | 1510 |
return err |
| 1511 | 1511 |
} |
| 1512 |
- if d, err := devicemapper.GetDeps(devname); err == nil {
|
|
| 1513 |
- // Access to more Debug output |
|
| 1514 |
- logrus.Debugf("[devmapper] devicemapper.GetDeps() %s: %#v", devname, d)
|
|
| 1512 |
+ |
|
| 1513 |
+ if devinfo.Exists == 0 {
|
|
| 1514 |
+ return nil |
|
| 1515 | 1515 |
} |
| 1516 |
- if devinfo.Exists != 0 {
|
|
| 1517 |
- return devicemapper.RemoveDevice(devname) |
|
| 1516 |
+ if err := devicemapper.RemoveDevice(devname); err != nil {
|
|
| 1517 |
+ return err |
|
| 1518 |
+ } |
|
| 1519 |
+ |
|
| 1520 |
+ if d, err := devicemapper.GetDeps(devname); err == nil {
|
|
| 1521 |
+ logrus.Warnf("[devmapper] device %s still has %d active dependents", devname, d.Count)
|
|
| 1518 | 1522 |
} |
| 1519 | 1523 |
|
| 1520 | 1524 |
return nil |
| ... | ... |
@@ -38,7 +38,10 @@ static void log_with_errno_init() |
| 38 | 38 |
*/ |
| 39 | 39 |
import "C" |
| 40 | 40 |
|
| 41 |
-import "unsafe" |
|
| 41 |
+import ( |
|
| 42 |
+ "reflect" |
|
| 43 |
+ "unsafe" |
|
| 44 |
+) |
|
| 42 | 45 |
|
| 43 | 46 |
type ( |
| 44 | 47 |
CDmTask C.struct_dm_task |
| ... | ... |
@@ -184,12 +187,21 @@ func dmTaskGetDepsFct(task *CDmTask) *Deps {
|
| 184 | 184 |
if Cdeps == nil {
|
| 185 | 185 |
return nil |
| 186 | 186 |
} |
| 187 |
+ |
|
| 188 |
+ // golang issue: https://github.com/golang/go/issues/11925 |
|
| 189 |
+ hdr := reflect.SliceHeader{
|
|
| 190 |
+ Data: uintptr(unsafe.Pointer(uintptr(unsafe.Pointer(Cdeps)) + unsafe.Sizeof(*Cdeps))), |
|
| 191 |
+ Len: int(Cdeps.count), |
|
| 192 |
+ Cap: int(Cdeps.count), |
|
| 193 |
+ } |
|
| 194 |
+ devices := *(*[]C.uint64_t)(unsafe.Pointer(&hdr)) |
|
| 195 |
+ |
|
| 187 | 196 |
deps := &Deps{
|
| 188 | 197 |
Count: uint32(Cdeps.count), |
| 189 | 198 |
Filler: uint32(Cdeps.filler), |
| 190 | 199 |
} |
| 191 |
- for _, device := range Cdeps.device {
|
|
| 192 |
- deps.Device = append(deps.Device, (uint64)(device)) |
|
| 200 |
+ for _, device := range devices {
|
|
| 201 |
+ deps.Device = append(deps.Device, uint64(device)) |
|
| 193 | 202 |
} |
| 194 | 203 |
return deps |
| 195 | 204 |
} |