forked from canonical/lxd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
storage.sh
971 lines (785 loc) · 57 KB
/
storage.sh
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
test_storage() {
ensure_import_testimage
# shellcheck disable=2039,3043
local LXD_STORAGE_DIR lxd_backend
lxd_backend=$(storage_backend "$LXD_DIR")
LXD_STORAGE_DIR=$(mktemp -d -p "${TEST_DIR}" XXXXXXXXX)
chmod +x "${LXD_STORAGE_DIR}"
spawn_lxd "${LXD_STORAGE_DIR}" false
# edit storage and pool description
# shellcheck disable=2039,3043
local storage_pool storage_volume
storage_pool="lxdtest-$(basename "${LXD_DIR}")-pool"
storage_volume="${storage_pool}-vol"
lxc storage create "$storage_pool" "$lxd_backend"
lxc storage show "$storage_pool" | sed 's/^description:.*/description: foo/' | lxc storage edit "$storage_pool"
lxc storage show "$storage_pool" | grep -q 'description: foo'
lxc storage volume create "$storage_pool" "$storage_volume"
# Test setting description on a storage volume
lxc storage volume show "$storage_pool" "$storage_volume" | sed 's/^description:.*/description: bar/' | lxc storage volume edit "$storage_pool" "$storage_volume"
lxc storage volume show "$storage_pool" "$storage_volume" | grep -q 'description: bar'
# Validate get/set
lxc storage set "$storage_pool" user.abc def
[ "$(lxc storage get "$storage_pool" user.abc)" = "def" ]
lxc storage volume set "$storage_pool" "$storage_volume" user.abc def
[ "$(lxc storage volume get "$storage_pool" "$storage_volume" user.abc)" = "def" ]
lxc storage volume delete "$storage_pool" "$storage_volume"
# Test copying pool volume.* key to the volume with prefix stripped at volume creation time
lxc storage set "$storage_pool" volume.snapshots.expiry 3d
lxc storage volume create "$storage_pool" "$storage_volume"
[ "$(lxc storage volume get "$storage_pool" "$storage_volume" snapshots.expiry)" = "3d" ]
lxc storage volume delete "$storage_pool" "$storage_volume"
lxc storage delete "$storage_pool"
# Test btrfs resize
if [ "$lxd_backend" = "lvm" ] || [ "$lxd_backend" = "ceph" ]; then
# shellcheck disable=2039,3043
local btrfs_storage_pool btrfs_storage_volume
btrfs_storage_pool="lxdtest-$(basename "${LXD_DIR}")-pool-btrfs"
btrfs_storage_volume="${storage_pool}-vol"
lxc storage create "$btrfs_storage_pool" "$lxd_backend" volume.block.filesystem=btrfs volume.size=200MiB
lxc storage volume create "$btrfs_storage_pool" "$btrfs_storage_volume"
lxc storage volume show "$btrfs_storage_pool" "$btrfs_storage_volume"
lxc storage volume set "$btrfs_storage_pool" "$btrfs_storage_volume" size 256MiB
lxc storage volume delete "$btrfs_storage_pool" "$btrfs_storage_volume"
# Test generation of unique UUID.
lxc init testimage uuid1 -s "lxdtest-$(basename "${LXD_DIR}")-pool-btrfs"
POOL="lxdtest-$(basename "${LXD_DIR}")-pool-btrfs"
lxc copy uuid1 uuid2
lxc start uuid1
lxc start uuid2
if [ "$lxd_backend" = "lvm" ]; then
[ "$(blkid -s UUID -o value -p /dev/"${POOL}"/containers_uuid1)" != "$(blkid -s UUID -o value -p /dev/"${POOL}"/containers_uuid2)" ]
elif [ "$lxd_backend" = "ceph" ]; then
[ "$(blkid -s UUID -o value -p /dev/rbd/"${POOL}"/container_uuid1)" != "$(blkid -s UUID -o value -p /dev/rbd/"${POOL}"/container_uuid2)" ]
fi
lxc delete --force uuid1
lxc delete --force uuid2
# Test UUID re-generation in case of restore.
lxc init testimage uuid1 -s "${POOL}"
lxc snapshot uuid1
lxc start uuid1
if [ "$lxd_backend" = "lvm" ]; then
uuid="$(blkid -s UUID -o value -p /dev/"${POOL}"/containers_uuid1)"
elif [ "$lxd_backend" = "ceph" ]; then
uuid="$(blkid -s UUID -o value -p /dev/rbd/"${POOL}"/container_uuid1)"
fi
lxc restore uuid1 snap0
if [ "$lxd_backend" = "lvm" ]; then
[ "$(blkid -s UUID -o value -p /dev/"${POOL}"/containers_uuid1)" != "$uuid" ]
elif [ "$lxd_backend" = "ceph" ]; then
[ "$(blkid -s UUID -o value -p /dev/rbd/"${POOL}"/container_uuid1)" != "$uuid" ]
fi
lxc delete --force uuid1
lxc image delete testimage
lxc storage delete "$btrfs_storage_pool"
fi
ensure_import_testimage
(
set -e
# shellcheck disable=2030
LXD_DIR="${LXD_STORAGE_DIR}"
# shellcheck disable=SC1009
if [ "$lxd_backend" = "zfs" ]; then
# Create loop file zfs pool.
lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool1" zfs
# Check that we can't create a loop file in a non-LXD owned location.
INVALID_LOOP_FILE="$(mktemp -p "${LXD_DIR}" XXXXXXXXX)-invalid-loop-file"
! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool1" zfs source="${INVALID_LOOP_FILE}" || false
# Let LXD use an already existing dataset.
zfs create -p -o mountpoint=none "lxdtest-$(basename "${LXD_DIR}")-pool1/existing-dataset-as-pool"
lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool7" zfs source="lxdtest-$(basename "${LXD_DIR}")-pool1/existing-dataset-as-pool"
# Let LXD use an already existing storage pool.
configure_loop_device loop_file_4 loop_device_4
# shellcheck disable=SC2154
zpool create -f -m none -O compression=on "lxdtest-$(basename "${LXD_DIR}")-pool9-existing-pool" "${loop_device_4}"
lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool9" zfs source="lxdtest-$(basename "${LXD_DIR}")-pool9-existing-pool"
# Let LXD create a new dataset and use as pool.
lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool8" zfs source="lxdtest-$(basename "${LXD_DIR}")-pool1/non-existing-dataset-as-pool"
# Create device backed zfs pool
configure_loop_device loop_file_1 loop_device_1
# shellcheck disable=SC2154
lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool2" zfs source="${loop_device_1}"
# Test that no invalid zfs storage pool configuration keys can be set.
! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-zfs-pool-config" zfs lvm.thinpool_name=bla || false
! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-zfs-pool-config" zfs lvm.use_thinpool=false || false
! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-zfs-pool-config" zfs lvm.vg_name=bla || false
# Test that all valid zfs storage pool configuration keys can be set.
lxc storage create "lxdtest-$(basename "${LXD_DIR}")-valid-zfs-pool-config" zfs volume.zfs.remove_snapshots=true
lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-valid-zfs-pool-config"
lxc storage create "lxdtest-$(basename "${LXD_DIR}")-valid-zfs-pool-config" zfs volume.zfs.use_refquota=true
lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-valid-zfs-pool-config"
lxc storage create "lxdtest-$(basename "${LXD_DIR}")-valid-zfs-pool-config" zfs zfs.clone_copy=true
lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-valid-zfs-pool-config"
lxc storage create "lxdtest-$(basename "${LXD_DIR}")-valid-zfs-pool-config" zfs zfs.pool_name="lxdtest-$(basename "${LXD_DIR}")-valid-zfs-pool-config"
lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-valid-zfs-pool-config"
lxc storage create "lxdtest-$(basename "${LXD_DIR}")-valid-zfs-pool-config" zfs rsync.bwlimit=1024
lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-valid-zfs-pool-config"
fi
if [ "$lxd_backend" = "btrfs" ]; then
# Create loop file btrfs pool.
lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool3" btrfs
# Create device backed btrfs pool.
configure_loop_device loop_file_2 loop_device_2
# shellcheck disable=SC2154
lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool4" btrfs source="${loop_device_2}"
# Check that we cannot create storage pools inside of ${LXD_DIR} other than ${LXD_DIR}/storage-pools/{pool_name}.
! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool5_under_lxd_dir" btrfs source="${LXD_DIR}" || false
# Test that no invalid btrfs storage pool configuration keys can be set.
! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-btrfs-pool-config" btrfs lvm.thinpool_name=bla || false
! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-btrfs-pool-config" btrfs lvm.use_thinpool=false || false
! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-btrfs-pool-config" btrfs lvm.vg_name=bla || false
! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-btrfs-pool-config" btrfs volume.block.filesystem=ext4 || false
! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-btrfs-pool-config" btrfs volume.block.mount_options=discard || false
! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-btrfs-pool-config" btrfs volume.zfs.remove_snapshots=true || false
! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-btrfs-pool-config" btrfs volume.zfs.use_refquota=true || false
! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-btrfs-pool-config" btrfs zfs.clone_copy=true || false
! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-btrfs-pool-config" btrfs zfs.pool_name=bla || false
lxc storage create "lxdtest-$(basename "${LXD_DIR}")-valid-btrfs-pool-config" btrfs rsync.bwlimit=1024
lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-valid-btrfs-pool-config"
lxc storage create "lxdtest-$(basename "${LXD_DIR}")-valid-btrfs-pool-config" btrfs btrfs.mount_options="rw,strictatime,user_subvol_rm_allowed"
lxc storage set "lxdtest-$(basename "${LXD_DIR}")-valid-btrfs-pool-config" btrfs.mount_options "rw,relatime,user_subvol_rm_allowed"
lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-valid-btrfs-pool-config"
fi
# Create dir pool.
lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool5" dir
# Check that we cannot create storage pools inside of ${LXD_DIR} other than ${LXD_DIR}/storage-pools/{pool_name}.
! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool5_under_lxd_dir" dir source="${LXD_DIR}" || false
# Check that we can create storage pools inside of ${LXD_DIR}/storage-pools/{pool_name}.
lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool5_under_lxd_dir" dir source="${LXD_DIR}/storage-pools/lxdtest-$(basename "${LXD_DIR}")-pool5_under_lxd_dir"
lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-pool5_under_lxd_dir"
# Test that no invalid dir storage pool configuration keys can be set.
! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-dir-pool-config" dir lvm.thinpool_name=bla || false
! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-dir-pool-config" dir lvm.use_thinpool=false || false
! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-dir-pool-config" dir lvm.vg_name=bla || false
! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-dir-pool-config" dir size=1GiB || false
! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-dir-pool-config" dir volume.block.filesystem=ext4 || false
! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-dir-pool-config" dir volume.block.mount_options=discard || false
! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-dir-pool-config" dir volume.zfs.remove_snapshots=true || false
! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-dir-pool-config" dir volume.zfs.use_refquota=true || false
! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-dir-pool-config" dir zfs.clone_copy=true || false
! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-dir-pool-config" dir zfs.pool_name=bla || false
lxc storage create "lxdtest-$(basename "${LXD_DIR}")-valid-dir-pool-config" dir rsync.bwlimit=1024
lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-valid-dir-pool-config"
if [ "$lxd_backend" = "lvm" ]; then
# Create lvm pool.
configure_loop_device loop_file_3 loop_device_3
# shellcheck disable=SC2154
lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool6" lvm source="${loop_device_3}" volume.size=25MiB
configure_loop_device loop_file_5 loop_device_5
# shellcheck disable=SC2154
# Should fail if vg does not exist, since we have no way of knowing where
# to create the vg without a block device path set.
! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool10" lvm source=test_vg_1 volume.size=25MiB || false
# shellcheck disable=SC2154
deconfigure_loop_device "${loop_file_5}" "${loop_device_5}"
configure_loop_device loop_file_6 loop_device_6
# shellcheck disable=SC2154
pvcreate "${loop_device_6}"
vgcreate "lxdtest-$(basename "${LXD_DIR}")-pool11-test_vg_2" "${loop_device_6}"
# Reuse existing volume group "test_vg_2" on existing physical volume.
lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool11" lvm source="lxdtest-$(basename "${LXD_DIR}")-pool11-test_vg_2" volume.size=25MiB
configure_loop_device loop_file_7 loop_device_7
# shellcheck disable=SC2154
pvcreate "${loop_device_7}"
vgcreate "lxdtest-$(basename "${LXD_DIR}")-pool12-test_vg_3" "${loop_device_7}"
# Reuse existing volume group "test_vg_3" on existing physical volume.
lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool12" lvm source="lxdtest-$(basename "${LXD_DIR}")-pool12-test_vg_3" volume.size=25MiB
configure_loop_device loop_file_8 loop_device_8
# shellcheck disable=SC2154
# Create new volume group "test_vg_4".
lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool13" lvm source="${loop_device_8}" lvm.vg_name="lxdtest-$(basename "${LXD_DIR}")-pool13-test_vg_4" volume.size=25MiB
lxc storage create "lxdtest-$(basename "${LXD_DIR}")-pool14" lvm volume.size=25MiB
lxc storage create "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15" lvm lvm.use_thinpool=false volume.size=25MiB
# Test that no invalid lvm storage pool configuration keys can be set.
! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-lvm-pool-config" lvm volume.zfs.remove_snapshots=true || false
! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-lvm-pool-config" lvm volume.zfs_use_refquota=true || false
! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-lvm-pool-config" lvm zfs.clone_copy=true || false
! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-lvm-pool-config" lvm zfs.pool_name=bla || false
! lxc storage create "lxdtest-$(basename "${LXD_DIR}")-invalid-lvm-pool-config" lvm lvm.use_thinpool=false lvm.thinpool_name="lxdtest-$(basename "${LXD_DIR}")-invalid-lvm-pool-config" || false
# Test that all valid lvm storage pool configuration keys can be set.
lxc storage create "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool16" lvm lvm.thinpool_name="lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config"
lxc storage create "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool17" lvm lvm.vg_name="lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config"
lxc storage create "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool18" lvm size=1GiB
lxc storage create "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool19" lvm volume.block.filesystem=ext4
lxc storage create "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool20" lvm volume.block.mount_options=discard
lxc storage create "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool21" lvm volume.size=25MiB
lxc storage create "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool22" lvm lvm.use_thinpool=true
lxc storage create "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool23" lvm lvm.use_thinpool=true lvm.thinpool_name="lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config"
lxc storage create "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool24" lvm rsync.bwlimit=1024
lxc storage create "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool25" lvm volume.block.mount_options="rw,strictatime,discard"
lxc storage set "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool25" volume.block.mount_options "rw,lazytime"
lxc storage create "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool26" lvm volume.block.filesystem=btrfs
fi
# Set default storage pool for image import.
lxc profile device add default root disk path="/" pool="lxdtest-$(basename "${LXD_DIR}")-pool5"
# Import image into default storage pool.
ensure_import_testimage
# Muck around with some containers on various pools.
if [ "$lxd_backend" = "zfs" ]; then
lxc init testimage c1pool1 -s "lxdtest-$(basename "${LXD_DIR}")-pool1"
lxc list -c b c1pool1 | grep "lxdtest-$(basename "${LXD_DIR}")-pool1"
lxc init testimage c2pool2 -s "lxdtest-$(basename "${LXD_DIR}")-pool2"
lxc list -c b c2pool2 | grep "lxdtest-$(basename "${LXD_DIR}")-pool2"
lxc launch testimage c3pool1 -s "lxdtest-$(basename "${LXD_DIR}")-pool1"
lxc list -c b c3pool1 | grep "lxdtest-$(basename "${LXD_DIR}")-pool1"
lxc launch testimage c4pool2 -s "lxdtest-$(basename "${LXD_DIR}")-pool2"
lxc list -c b c4pool2 | grep "lxdtest-$(basename "${LXD_DIR}")-pool2"
lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool1" c1pool1
lxc storage volume set "lxdtest-$(basename "${LXD_DIR}")-pool1" c1pool1 zfs.use_refquota true
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool1" c1pool1 c1pool1 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool1" c1pool1 c1pool1 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool1" c1pool1 c1pool1
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool1" custom/c1pool1 c1pool1 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool1" custom/c1pool1 c1pool1 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool1" c1pool1 c1pool1
lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool1" c2pool2
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool1" c2pool2 c2pool2 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool1" c2pool2 c2pool2 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool1" c2pool2 c2pool2
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool1" custom/c2pool2 c2pool2 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool1" custom/c2pool2 c2pool2 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool1" c2pool2 c2pool2
lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool2" c3pool1
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool2" c3pool1 c3pool1 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool2" c3pool1 c3pool1 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool2" c3pool1 c3pool1
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool2" c3pool1 c3pool1 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool2" c3pool1 c3pool1 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool2" c3pool1 c3pool1
lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool2" c4pool2
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool2" c4pool2 c4pool2 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool2" c4pool2 c4pool2 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool2" c4pool2 c4pool2
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool2" custom/c4pool2 c4pool2 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool2" custom/c4pool2 c4pool2 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool2" c4pool2 c4pool2
lxc storage volume rename "lxdtest-$(basename "${LXD_DIR}")-pool2" c4pool2 c4pool2-renamed
lxc storage volume rename "lxdtest-$(basename "${LXD_DIR}")-pool2" c4pool2-renamed c4pool2
fi
if [ "$lxd_backend" = "btrfs" ]; then
lxc init testimage c5pool3 -s "lxdtest-$(basename "${LXD_DIR}")-pool3"
lxc list -c b c5pool3 | grep "lxdtest-$(basename "${LXD_DIR}")-pool3"
lxc init testimage c6pool4 -s "lxdtest-$(basename "${LXD_DIR}")-pool4"
lxc list -c b c6pool4 | grep "lxdtest-$(basename "${LXD_DIR}")-pool4"
lxc launch testimage c7pool3 -s "lxdtest-$(basename "${LXD_DIR}")-pool3"
lxc list -c b c7pool3 | grep "lxdtest-$(basename "${LXD_DIR}")-pool3"
lxc launch testimage c8pool4 -s "lxdtest-$(basename "${LXD_DIR}")-pool4"
lxc list -c b c8pool4 | grep "lxdtest-$(basename "${LXD_DIR}")-pool4"
lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool3" c5pool3
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool3" c5pool3 c5pool3 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool3" c5pool3 c5pool3 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool3" c5pool3 c5pool3 testDevice
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool3" custom/c5pool3 c5pool3 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool3" custom/c5pool3 c5pool3 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool3" c5pool3 c5pool3 testDevice
lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool4" c6pool4
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool4" c6pool4 c5pool3 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool4" c6pool4 c5pool3 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool4" c6pool4 c5pool3 testDevice
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool4" custom/c6pool4 c5pool3 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool4" custom/c6pool4 c5pool3 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool4" c6pool4 c5pool3 testDevice
lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool3" c7pool3
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool3" c7pool3 c7pool3 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool3" c7pool3 c7pool3 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool3" c7pool3 c7pool3 testDevice
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool3" custom/c7pool3 c7pool3 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool3" custom/c7pool3 c7pool3 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool3" c7pool3 c7pool3 testDevice
lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool4" c8pool4
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool4" c8pool4 c8pool4 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool4" c8pool4 c8pool4 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool4" c8pool4 c8pool4 testDevice
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool4" custom/c8pool4 c8pool4 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool4" custom/c8pool4 c8pool4 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool4" c8pool4 c8pool4 testDevice
lxc storage volume rename "lxdtest-$(basename "${LXD_DIR}")-pool4" c8pool4 c8pool4-renamed
lxc storage volume rename "lxdtest-$(basename "${LXD_DIR}")-pool4" c8pool4-renamed c8pool4
fi
lxc init testimage c9pool5 -s "lxdtest-$(basename "${LXD_DIR}")-pool5"
lxc list -c b c9pool5 | grep "lxdtest-$(basename "${LXD_DIR}")-pool5"
lxc launch testimage c11pool5 -s "lxdtest-$(basename "${LXD_DIR}")-pool5"
lxc list -c b c11pool5 | grep "lxdtest-$(basename "${LXD_DIR}")-pool5"
lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool5" c9pool5
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool5" c9pool5 c9pool5 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool5" c9pool5 c9pool5 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool5" c9pool5 c9pool5 testDevice
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool5" custom/c9pool5 c9pool5 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool5" custom/c9pool5 c9pool5 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool5" c9pool5 c9pool5 testDevice
lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool5" c11pool5
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool5" c11pool5 c11pool5 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool5" c11pool5 c11pool5 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool5" c11pool5 c11pool5 testDevice
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool5" custom/c11pool5 c11pool5 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool5" custom/c11pool5 c11pool5 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool5" c11pool5 c11pool5 testDevice
lxc storage volume rename "lxdtest-$(basename "${LXD_DIR}")-pool5" c11pool5 c11pool5-renamed
lxc storage volume rename "lxdtest-$(basename "${LXD_DIR}")-pool5" c11pool5-renamed c11pool5
lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool5" c12pool5
# should create snap0
lxc storage volume snapshot "lxdtest-$(basename "${LXD_DIR}")-pool5" c12pool5
# should create snap1
lxc storage volume snapshot "lxdtest-$(basename "${LXD_DIR}")-pool5" c12pool5
if [ "$lxd_backend" = "lvm" ]; then
lxc init testimage c10pool6 -s "lxdtest-$(basename "${LXD_DIR}")-pool6"
lxc list -c b c10pool6 | grep "lxdtest-$(basename "${LXD_DIR}")-pool6"
# Test if volume group renaming works by setting lvm.vg_name.
lxc storage set "lxdtest-$(basename "${LXD_DIR}")-pool6" lvm.vg_name "lxdtest-$(basename "${LXD_DIR}")-pool6-newName"
lxc storage set "lxdtest-$(basename "${LXD_DIR}")-pool6" lvm.thinpool_name "lxdtest-$(basename "${LXD_DIR}")-pool6-newThinpoolName"
lxc launch testimage c12pool6 -s "lxdtest-$(basename "${LXD_DIR}")-pool6"
lxc list -c b c12pool6 | grep "lxdtest-$(basename "${LXD_DIR}")-pool6"
# grow lv
lxc config device set c12pool6 root size 30MiB
lxc restart c12pool6 --force
# shrink lv
lxc config device set c12pool6 root size 25MiB
lxc restart c12pool6 --force
lxc init testimage c10pool11 -s "lxdtest-$(basename "${LXD_DIR}")-pool11"
lxc list -c b c10pool11 | grep "lxdtest-$(basename "${LXD_DIR}")-pool11"
lxc launch testimage c12pool11 -s "lxdtest-$(basename "${LXD_DIR}")-pool11"
lxc list -c b c12pool11 | grep "lxdtest-$(basename "${LXD_DIR}")-pool11"
lxc init testimage c10pool12 -s "lxdtest-$(basename "${LXD_DIR}")-pool12"
lxc list -c b c10pool12 | grep "lxdtest-$(basename "${LXD_DIR}")-pool12"
lxc launch testimage c12pool12 -s "lxdtest-$(basename "${LXD_DIR}")-pool12"
lxc list -c b c12pool12 | grep "lxdtest-$(basename "${LXD_DIR}")-pool12"
lxc init testimage c10pool13 -s "lxdtest-$(basename "${LXD_DIR}")-pool13"
lxc list -c b c10pool13 | grep "lxdtest-$(basename "${LXD_DIR}")-pool13"
lxc launch testimage c12pool13 -s "lxdtest-$(basename "${LXD_DIR}")-pool13"
lxc list -c b c12pool13 | grep "lxdtest-$(basename "${LXD_DIR}")-pool13"
lxc init testimage c10pool14 -s "lxdtest-$(basename "${LXD_DIR}")-pool14"
lxc list -c b c10pool14 | grep "lxdtest-$(basename "${LXD_DIR}")-pool14"
lxc launch testimage c12pool14 -s "lxdtest-$(basename "${LXD_DIR}")-pool14"
lxc list -c b c12pool14 | grep "lxdtest-$(basename "${LXD_DIR}")-pool14"
lxc init testimage c10pool15 -s "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15"
lxc list -c b c10pool15 | grep "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15"
lxc launch testimage c12pool15 -s "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15"
lxc list -c b c12pool15 | grep "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15"
# Test that changing block filesystem works
lxc storage set "lxdtest-$(basename "${LXD_DIR}")-pool6" volume.block.filesystem xfs
lxc init testimage c1pool6 -s "lxdtest-$(basename "${LXD_DIR}")-pool6"
lxc storage set "lxdtest-$(basename "${LXD_DIR}")-pool6" volume.block.filesystem btrfs
lxc storage set "lxdtest-$(basename "${LXD_DIR}")-pool6" volume.size 120MiB
lxc init testimage c2pool6 -s "lxdtest-$(basename "${LXD_DIR}")-pool6"
lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool6" c10pool6
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool6" c10pool6 c10pool6 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool6" c10pool6 c10pool6 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool6" c10pool6 c10pool6 testDevice
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool6" custom/c10pool6 c10pool6 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool6" custom/c10pool6 c10pool6 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool6" c10pool6 c10pool6 testDevice
lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool6" c12pool6
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool6" c12pool6 c12pool6 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool6" c12pool6 c12pool6 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool6" c12pool6 c12pool6 testDevice
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool6" custom/c12pool6 c12pool6 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool6" custom/c12pool6 c12pool6 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool6" c12pool6 c12pool6 testDevice
lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool11" c10pool11
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool11" c10pool11 c10pool11 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool11" c10pool11 c10pool11 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool11" c10pool11 c10pool11 testDevice
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool11" custom/c10pool11 c10pool11 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool11" custom/c10pool11 c10pool11 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool11" c10pool11 c10pool11 testDevice
lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool11" c12pool11
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool11" c12pool11 c10pool11 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool11" c12pool11 c10pool11 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool11" c12pool11 c10pool11 testDevice
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool11" custom/c12pool11 c10pool11 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool11" custom/c12pool11 c10pool11 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool11" c12pool11 c10pool11 testDevice
lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool12" c10pool12
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool12" c10pool12 c10pool12 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool12" c10pool12 c10pool12 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool12" c10pool12 c10pool12 testDevice
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool12" custom/c10pool12 c10pool12 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool12" custom/c10pool12 c10pool12 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool12" c10pool12 c10pool12 testDevice
lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool12" c12pool12
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool12" c12pool12 c12pool12 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool12" c12pool12 c12pool12 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool12" c12pool12 c12pool12 testDevice
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool12" custom/c12pool12 c12pool12 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool12" custom/c12pool12 c12pool12 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool12" c12pool12 c12pool12 testDevice
lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool13" c10pool13
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool13" c10pool13 c10pool13 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool13" c10pool13 c10pool13 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool13" c10pool13 c10pool13 testDevice
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool13" custom/c10pool13 c10pool13 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool13" custom/c10pool13 c10pool13 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool13" c10pool13 c10pool13 testDevice
lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool13" c12pool13
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool13" c12pool13 c12pool13 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool13" c12pool13 c12pool13 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool13" c12pool13 c12pool13 testDevice
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool13" custom/c12pool13 c12pool13 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool13" custom/c12pool13 c12pool13 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool13" c12pool13 c12pool13 testDevice
lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool14" c10pool14
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool14" c10pool14 c10pool14 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool14" c10pool14 c10pool14 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool14" c10pool14 c10pool14 testDevice
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool14" custom/c10pool14 c10pool14 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool14" custom/c10pool14 c10pool14 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool14" c10pool14 c10pool14 testDevice
lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool14" c12pool14
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool14" c12pool14 c12pool14 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool14" c12pool14 c12pool14 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool14" c12pool14 c12pool14 testDevice
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool14" custom/c12pool14 c12pool14 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool14" custom/c12pool14 c12pool14 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool14" c12pool14 c12pool14 testDevice
lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15" c10pool15
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15" c10pool15 c10pool15 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15" c10pool15 c10pool15 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15" c10pool15 c10pool15 testDevice
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15" custom/c10pool15 c10pool15 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15" custom/c10pool15 c10pool15 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15" c10pool15 c10pool15 testDevice
lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15" c12pool15
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15" c12pool15 c12pool15 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15" c12pool15 c12pool15 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15" c12pool15 c12pool15 testDevice
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15" custom/c12pool15 c12pool15 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15" custom/c12pool15 c12pool15 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15" c12pool15 c12pool15 testDevice
fi
if [ "$lxd_backend" = "zfs" ]; then
lxc launch testimage c13pool7 -s "lxdtest-$(basename "${LXD_DIR}")-pool7"
lxc launch testimage c14pool7 -s "lxdtest-$(basename "${LXD_DIR}")-pool7"
lxc launch testimage c15pool8 -s "lxdtest-$(basename "${LXD_DIR}")-pool8"
lxc launch testimage c16pool8 -s "lxdtest-$(basename "${LXD_DIR}")-pool8"
lxc launch testimage c17pool9 -s "lxdtest-$(basename "${LXD_DIR}")-pool9"
lxc launch testimage c18pool9 -s "lxdtest-$(basename "${LXD_DIR}")-pool9"
lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool7" c13pool7
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool7" c13pool7 c13pool7 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool7" c13pool7 c13pool7 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool7" c13pool7 c13pool7 testDevice
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool7" custom/c13pool7 c13pool7 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool7" custom/c13pool7 c13pool7 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool7" c13pool7 c13pool7 testDevice
lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool7" c14pool7
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool7" c14pool7 c14pool7 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool7" c14pool7 c14pool7 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool7" c14pool7 c14pool7 testDevice
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool7" custom/c14pool7 c14pool7 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool7" custom/c14pool7 c14pool7 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool7" c14pool7 c14pool7 testDevice
lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool8" c15pool8
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool8" c15pool8 c15pool8 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool8" c15pool8 c15pool8 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool8" c15pool8 c15pool8 testDevice
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool8" custom/c15pool8 c15pool8 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool8" custom/c15pool8 c15pool8 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool8" c15pool8 c15pool8 testDevice
lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool8" c16pool8
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool8" c16pool8 c16pool8 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool8" c16pool8 c16pool8 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool8" c16pool8 c16pool8 testDevice
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool8" custom/c16pool8 c16pool8 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool8" custom/c16pool8 c16pool8 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool8" c16pool8 c16pool8 testDevice
lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool9" c17pool9
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool9" c17pool9 c17pool9 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool9" c17pool9 c17pool9 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool9" c17pool9 c17pool9 testDevice
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool9" custom/c17pool9 c17pool9 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool9" custom/c17pool9 c17pool9 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool9" c17pool9 c17pool9 testDevice
lxc storage volume create "lxdtest-$(basename "${LXD_DIR}")-pool9" c18pool9
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool9" c18pool9 c18pool9 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool9" c18pool9 c18pool9 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool9" c18pool9 c18pool9 testDevice
lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool9" custom/c18pool9 c18pool9 testDevice /opt
! lxc storage volume attach "lxdtest-$(basename "${LXD_DIR}")-pool9" custom/c18pool9 c18pool9 testDevice2 /opt || false
lxc storage volume detach "lxdtest-$(basename "${LXD_DIR}")-pool9" c18pool9 c18pool9 testDevice
lxc storage volume rename "lxdtest-$(basename "${LXD_DIR}")-pool9" c18pool9 c18pool9-renamed
lxc storage volume rename "lxdtest-$(basename "${LXD_DIR}")-pool9" c18pool9-renamed c18pool9
fi
if [ "$lxd_backend" = "zfs" ]; then
lxc delete -f c1pool1
lxc delete -f c3pool1
lxc delete -f c4pool2
lxc delete -f c2pool2
lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool1" c1pool1
lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool1" c2pool2
lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool2" c3pool1
lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool2" c4pool2
fi
if [ "$lxd_backend" = "btrfs" ]; then
lxc delete -f c5pool3
lxc delete -f c7pool3
lxc delete -f c8pool4
lxc delete -f c6pool4
lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool3" c5pool3
lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool4" c6pool4
lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool3" c7pool3
lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool4" c8pool4
fi
lxc delete -f c9pool5
lxc delete -f c11pool5
lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool5" c9pool5
lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool5" c11pool5
lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool5" c12pool5
if [ "$lxd_backend" = "lvm" ]; then
lxc delete -f c1pool6
lxc delete -f c2pool6
lxc delete -f c10pool6
lxc delete -f c12pool6
lxc delete -f c10pool11
lxc delete -f c12pool11
lxc delete -f c10pool12
lxc delete -f c12pool12
lxc delete -f c10pool13
lxc delete -f c12pool13
lxc delete -f c10pool14
lxc delete -f c12pool14
lxc delete -f c10pool15
lxc delete -f c12pool15
lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool6" c10pool6
lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool6" c12pool6
lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool11" c10pool11
lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool11" c12pool11
lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool12" c10pool12
lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool12" c12pool12
lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool13" c10pool13
lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool13" c12pool13
lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool14" c10pool14
lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool14" c12pool14
lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15" c10pool15
lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15" c12pool15
fi
if [ "$lxd_backend" = "zfs" ]; then
lxc delete -f c13pool7
lxc delete -f c14pool7
lxc delete -f c15pool8
lxc delete -f c16pool8
lxc delete -f c17pool9
lxc delete -f c18pool9
lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool7" c13pool7
lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool7" c14pool7
lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool8" c15pool8
lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool8" c16pool8
lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool9" c17pool9
lxc storage volume delete "lxdtest-$(basename "${LXD_DIR}")-pool9" c18pool9
fi
lxc image delete testimage
if [ "$lxd_backend" = "zfs" ]; then
lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-pool7"
lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-pool8"
lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-pool9"
# shellcheck disable=SC2154
deconfigure_loop_device "${loop_file_4}" "${loop_device_4}"
lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-pool1"
lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-pool2"
# shellcheck disable=SC2154
deconfigure_loop_device "${loop_file_1}" "${loop_device_1}"
fi
if [ "$lxd_backend" = "btrfs" ]; then
lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-pool4"
# shellcheck disable=SC2154
deconfigure_loop_device "${loop_file_2}" "${loop_device_2}"
fi
if [ "$lxd_backend" = "lvm" ]; then
lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-pool6"
# shellcheck disable=SC2154
pvremove -ff "${loop_device_3}" || true
# shellcheck disable=SC2154
deconfigure_loop_device "${loop_file_3}" "${loop_device_3}"
lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-pool11"
# shellcheck disable=SC2154
vgremove -ff "lxdtest-$(basename "${LXD_DIR}")-pool11-test_vg_2" || true
pvremove -ff "${loop_device_6}" || true
# shellcheck disable=SC2154
deconfigure_loop_device "${loop_file_6}" "${loop_device_6}"
lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-pool12"
vgremove -ff "lxdtest-$(basename "${LXD_DIR}")-pool12-test_vg_3" || true
pvremove -ff "${loop_device_7}" || true
# shellcheck disable=SC2154
deconfigure_loop_device "${loop_file_7}" "${loop_device_7}"
lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-pool13"
vgremove -ff "lxdtest-$(basename "${LXD_DIR}")-pool13-test_vg_4" || true
pvremove -ff "${loop_device_8}" || true
# shellcheck disable=SC2154
deconfigure_loop_device "${loop_file_8}" "${loop_device_8}"
lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-pool14"
vgremove -ff "lxdtest-$(basename "${LXD_DIR}")-pool14" || true
lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15"
vgremove -ff "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool15" || true
lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool16"
vgremove -ff "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool16" || true
lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool17"
vgremove -ff "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool17" || true
lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool18"
vgremove -ff "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool18" || true
lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool19"
vgremove -ff "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool19" || true
lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool20"
vgremove -ff "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool20" || true
lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool21"
vgremove -ff "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool21" || true
lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool22"
vgremove -ff "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool22" || true
lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool23"
vgremove -ff "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool23" || true
lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool24"
vgremove -ff "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool24" || true
lxc storage delete "lxdtest-$(basename "${LXD_DIR}")-valid-lvm-pool-config-pool25"
vgremove -ff "lxdtest-$(basename "${LXD_DIR}")-non-thinpool-pool25" || true
fi
)
# Test applying quota (expected size ranges are in KiB and have an allowable range to account for allocation variations).
QUOTA1="20MiB"
rootMinKiB1="13800"
rootMaxKiB1="23000"
QUOTA2="25MiB"
rootMinKiB2="18900"
rootMaxKiB2="28000"
if [ "$lxd_backend" != "dir" ]; then
lxc launch testimage quota1
rootOrigSizeKiB=$(lxc exec quota1 -- df -P / | tail -n1 | awk '{print $2}')
rootOrigMinSizeKiB=$((rootOrigSizeKiB-2000))
rootOrigMaxSizeKiB=$((rootOrigSizeKiB+2000))
lxc profile device set default root size "${QUOTA1}"
lxc stop -f quota1
lxc start quota1
# BTRFS quota isn't accessible with the df tool.
if [ "$lxd_backend" != "btrfs" ]; then
rootSizeKiB=$(lxc exec quota1 -- df -P / | tail -n1 | awk '{print $2}')
if [ "$rootSizeKiB" -gt "$rootMaxKiB1" ] || [ "$rootSizeKiB" -lt "$rootMinKiB1" ] ; then
echo "root size not within quota range"
false
fi
fi
lxc launch testimage quota2
lxc stop -f quota2
lxc start quota2
lxc init testimage quota3
lxc start quota3
lxc profile device set default root size "${QUOTA2}"
lxc stop -f quota1
lxc start quota1
lxc stop -f quota2
lxc start quota2
if [ "$lxd_backend" != "btrfs" ]; then
rootSizeKiB=$(lxc exec quota2 -- df -P / | tail -n1 | awk '{print $2}')
if [ "$rootSizeKiB" -gt "$rootMaxKiB2" ] || [ "$rootSizeKiB" -lt "$rootMinKiB2" ] ; then
echo "root size not within quota range"
false
fi
fi
lxc stop -f quota3
lxc start quota3
lxc profile device unset default root size
# Only ZFS supports hot quota changes (LVM requires a reboot).
if [ "$lxd_backend" = "zfs" ]; then
rootSizeKiB=$(lxc exec quota1 -- df -P / | tail -n1 | awk '{print $2}')
if [ "$rootSizeKiB" -gt "$rootOrigMaxSizeKiB" ] || [ "$rootSizeKiB" -lt "$rootOrigMinSizeKiB" ] ; then
echo "original root size not restored"
false
fi
fi
lxc stop -f quota1
lxc start quota1
if [ "$lxd_backend" = "zfs" ]; then
rootSizeKiB=$(lxc exec quota1 -- df -P / | tail -n1 | awk '{print $2}')
if [ "$rootSizeKiB" -gt "$rootOrigMaxSizeKiB" ] || [ "$rootSizeKiB" -lt "$rootOrigMinSizeKiB" ] ; then
echo "original root size not restored"
false
fi
fi
lxc stop -f quota2
lxc start quota2
lxc stop -f quota3
lxc start quota3
lxc delete -f quota1
lxc delete -f quota2
lxc delete -f quota3
fi
if [ "${lxd_backend}" = "btrfs" ]; then
# shellcheck disable=SC2031
pool_name="lxdtest-$(basename "${LXD_DIR}")-quota"
# shellcheck disable=SC1009
lxc storage create "${pool_name}" btrfs
# Import image into default storage pool.
ensure_import_testimage
# Launch container.
lxc launch -s "${pool_name}" testimage c1
# Disable quotas. The usage should be 0.
# shellcheck disable=SC2031
btrfs quota disable "${LXD_DIR}/storage-pools/${pool_name}"
usage=$(lxc query /1.0/instances/c1/state | jq '.disk.root')
[ "${usage}" = "null" ]
# Enable quotas. The usage should then be > 0.
# shellcheck disable=SC2031
btrfs quota enable "${LXD_DIR}/storage-pools/${pool_name}"
usage=$(lxc query /1.0/instances/c1/state | jq '.disk.root.usage')
[ "${usage}" -gt 0 ]
# Clean up everything.
lxc rm -f c1
lxc storage delete "${pool_name}"
fi
# Test removing storage pools only containing image volumes
# shellcheck disable=SC2031,2269
LXD_DIR="${LXD_DIR}"
storage_pool="lxdtest-$(basename "${LXD_DIR}")-pool26"
lxc storage create "$storage_pool" "$lxd_backend"
lxc init -s "${storage_pool}" testimage c1
# The storage pool will not be removed since it has c1 attached to it
! lxc storage delete "${storage_pool}" || false
lxc delete c1
# The storage pool will be deleted since the testimage is also attached to
# the default pool
lxc storage delete "${storage_pool}"
lxc image show testimage
# Test storage pool resize
if [ "${lxd_backend}" = "btrfs" ] || [ "${lxd_backend}" = "lvm" ] || [ "${lxd_backend}" = "zfs" ]; then
# shellcheck disable=SC1009
pool_name="lxdtest-$(basename "${LXD_DIR}")-pool1"
lxc storage create "${pool_name}" "${lxd_backend}" size=1GiB
lxc launch testimage c1 -s "${pool_name}"
expected_size=1073741824
# +/- 5% of the expected size
expected_size_min=1020054732
expected_size_max=1127428916
# Check pool file size
[ "$(stat --format="%s" "${LXD_DIR}/disks/${pool_name}.img")" = "${expected_size}" ]
if [ "${lxd_backend}" = "btrfs" ]; then
actual_size="$(btrfs filesystem show --raw "${LXD_DIR}/disks/${pool_name}.img" | awk '/devid/{print $4}')"
elif [ "${lxd_backend}" = "lvm" ]; then
actual_size="$(lvs --noheadings --nosuffix --units b --options='lv_size' "lxdtest-$(basename "${LXD_DIR}")/LXDThinPool")"
elif [ "${lxd_backend}" = "zfs" ]; then
actual_size="$(zpool list -Hp "${pool_name}" | awk '{print $2}')"
fi
# Check that pool size is within the expected range
[ "${actual_size}" -ge "${expected_size_min}" ] || [ "${actual_size}" -le "${expected_size_max}" ]
# Grow pool
lxc storage set "${pool_name}" size=2GiB
expected_size=2147483648
# +/- 5% of the expected size
expected_size_min=2040109465
expected_size_max=2254857831
# Check pool file size
[ "$(stat --format="%s" "${LXD_DIR}/disks/${pool_name}.img")" = "${expected_size}" ]
if [ "${lxd_backend}" = "btrfs" ]; then
actual_size="$(btrfs filesystem show --raw "${LXD_DIR}/disks/${pool_name}.img" | awk '/devid/{print $4}')"
elif [ "${lxd_backend}" = "lvm" ]; then
actual_size="$(lvs --noheadings --nosuffix --units b --options='lv_size' "lxdtest-$(basename "${LXD_DIR}")/LXDThinPool")"
elif [ "${lxd_backend}" = "zfs" ]; then
actual_size="$(zpool list -Hp "${pool_name}" | awk '{print $2}')"
fi
# Check that pool size is within the expected range
[ "${actual_size}" -ge "${expected_size_min}" ] || [ "${actual_size}" -le "${expected_size_max}" ]
# Shrinking the pool should fail
! lxc storage set "${pool_name}" size=1GiB || false
# Ensure the pool is still usable after resizing by launching an instance
lxc launch testimage c2 -s "${pool_name}"
lxc rm -f c1 c2
lxc storage rm "${pool_name}"
fi
# shellcheck disable=SC2031,2269
LXD_DIR="${LXD_DIR}"
kill_lxd "${LXD_STORAGE_DIR}"
}