summaryrefslogtreecommitdiffstats
path: root/qa/workunits/rbd/qemu_rebuild_object_map.sh
blob: 2647dcdcdec05ae721dbfc15b2c220ec8a0c1669 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env bash
set -ex

if [[ -z "${IMAGE_NAME}" ]]; then
  echo image name must be provided
  exit 1
fi

is_qemu_running() {
  rbd status ${IMAGE_NAME} | grep -v "Watchers: none"
}

wait_for_qemu() {
  while ! is_qemu_running ; do
    echo "*** Waiting for QEMU"
    sleep 30
  done
}

wait_for_qemu
rbd feature disable ${IMAGE_NAME} journaling || true
rbd feature disable ${IMAGE_NAME} fast-diff || true
rbd feature disable ${IMAGE_NAME} object-map || true
rbd feature disable ${IMAGE_NAME} exclusive-lock || true

rbd feature enable ${IMAGE_NAME} exclusive-lock
rbd feature enable ${IMAGE_NAME} object-map

while is_qemu_running ; do
  echo "*** Rebuilding object map"
  rbd object-map rebuild ${IMAGE_NAME}

  if is_qemu_running ; then
    sleep 60
  fi
done