discover-image: rename image sidecar files from old paths
image_rename() updated the Image object name and path before computing the source paths for auxiliary files. As a result, the auxiliary rename loop looked for files with the new image name, while existing sidecars such as .roothash, .verity, and .raw.tpmstate still used the old image name. Delay updating the Image object until after renaming its settings and auxiliary files. This lets image_auxiliary_path() resolve existing sidecars from the old image name while rename_auxiliary_file() assigns the new name. Extend the import test raw image rename coverage to check representative sidecars are renamed together with the image.
This commit is contained in:
committed by
Yu Watanabe
parent
cd4379bb54
commit
ed22b5a77f
@@ -25,17 +25,32 @@ cmp /var/tmp/testimage.raw /var/tmp/testimage2.raw
|
||||
rm /var/tmp/testimage2.raw
|
||||
|
||||
# Test clone
|
||||
printf 'hash\n' >/var/lib/machines/testimage.roothash
|
||||
printf 'verity\n' >/var/lib/machines/testimage.verity
|
||||
printf 'tpmstate\n' >/var/lib/machines/testimage.raw.tpmstate
|
||||
machinectl clone testimage testimage3
|
||||
test -f /var/lib/machines/testimage3.raw
|
||||
test -f /var/lib/machines/testimage3.roothash
|
||||
test -f /var/lib/machines/testimage3.verity
|
||||
test -f /var/lib/machines/testimage3.raw.tpmstate
|
||||
machinectl image-status testimage3
|
||||
test -f /var/lib/machines/testimage.raw
|
||||
test -f /var/lib/machines/testimage.roothash
|
||||
test -f /var/lib/machines/testimage.verity
|
||||
test -f /var/lib/machines/testimage.raw.tpmstate
|
||||
machinectl image-status testimage
|
||||
cmp /var/tmp/testimage.raw /var/lib/machines/testimage.raw
|
||||
cmp /var/tmp/testimage.raw /var/lib/machines/testimage3.raw
|
||||
grep -Fx hash /var/lib/machines/testimage3.roothash
|
||||
grep -Fx verity /var/lib/machines/testimage3.verity
|
||||
grep -Fx tpmstate /var/lib/machines/testimage3.raw.tpmstate
|
||||
|
||||
# Test removal
|
||||
machinectl remove testimage
|
||||
test ! -f /var/lib/machines/testimage.raw
|
||||
test ! -f /var/lib/machines/testimage.roothash
|
||||
test ! -f /var/lib/machines/testimage.verity
|
||||
test ! -f /var/lib/machines/testimage.raw.tpmstate
|
||||
(! machinectl image-status testimage)
|
||||
|
||||
# Test export of clone
|
||||
@@ -46,10 +61,19 @@ rm /var/tmp/testimage3.raw
|
||||
# Test rename
|
||||
machinectl rename testimage3 testimage4
|
||||
test -f /var/lib/machines/testimage4.raw
|
||||
test -f /var/lib/machines/testimage4.roothash
|
||||
test -f /var/lib/machines/testimage4.verity
|
||||
test -f /var/lib/machines/testimage4.raw.tpmstate
|
||||
machinectl image-status testimage4
|
||||
test ! -f /var/lib/machines/testimage3.raw
|
||||
test ! -f /var/lib/machines/testimage3.roothash
|
||||
test ! -f /var/lib/machines/testimage3.verity
|
||||
test ! -f /var/lib/machines/testimage3.raw.tpmstate
|
||||
(! machinectl image-status testimage3)
|
||||
cmp /var/tmp/testimage.raw /var/lib/machines/testimage4.raw
|
||||
grep -Fx hash /var/lib/machines/testimage4.roothash
|
||||
grep -Fx verity /var/lib/machines/testimage4.verity
|
||||
grep -Fx tpmstate /var/lib/machines/testimage4.raw.tpmstate
|
||||
|
||||
# Test export of rename
|
||||
machinectl export-raw testimage4 /var/tmp/testimage4.raw
|
||||
@@ -59,6 +83,9 @@ rm /var/tmp/testimage4.raw
|
||||
# Test removal
|
||||
machinectl remove testimage4
|
||||
test ! -f /var/lib/machines/testimage4.raw
|
||||
test ! -f /var/lib/machines/testimage4.roothash
|
||||
test ! -f /var/lib/machines/testimage4.verity
|
||||
test ! -f /var/lib/machines/testimage4.raw.tpmstate
|
||||
(! machinectl image-status testimage4)
|
||||
|
||||
# → And now, let's test directory trees ← #
|
||||
|
||||
Reference in New Issue
Block a user