Codebase list libblockdev / upstream/2.28
New upstream version 2.28 Michael Biebl 1 year, 7 months ago
23 changed file(s) with 657 addition(s) and 117 deletion(s). Raw diff Collapse all Expand all
0 name: Run static analysis using csmock
1
2 env:
3 CSMOCK_CHROOTS: "default"
4 CSMOCK_TOOLS: "clang cppcheck gcc"
5
6 on:
7 pull_request:
8 branches:
9 - master
10
11 jobs:
12 build:
13 name: csmock
14 runs-on: ubuntu-22.04
15 env:
16 CI_CONTAINER: libblockdev-ci-csmock
17 steps:
18 - name: Checkout libblockdev repository
19 uses: actions/checkout@v3
20
21 - name: Install podman
22 run: |
23 sudo apt -qq update
24 sudo apt -y -qq install podman
25
26 - name: Build the container
27 run: |
28 podman build --no-cache -t ${{ env.CI_CONTAINER }} -f misc/ci.Dockerfile .
29
30 - name: Start the container
31 run: |
32 podman run -d -t --name ${{ env.CI_CONTAINER }} --privileged --volume "$(pwd):/app" --workdir "/app" ${{ env.CI_CONTAINER }}
33
34 - name: Install test dependencies in the container
35 run: |
36 podman exec -it ${{ env.CI_CONTAINER }} bash -c "ansible-playbook -i "localhost," -c local misc/install-test-dependencies.yml"
37
38 - name: Run csmock build in the container
39 run: |
40 podman exec -it ${{ env.CI_CONTAINER }} bash -c "/ci/run_csmock_tests -c /ci/copr-builder.conf -p libblockdev-udisks -t ${{ env.CSMOCK_TOOLS }} -r ${{ env.CSMOCK_CHROOTS }}"
41
42 - name: Upload the csmock logs
43 if: always()
44 uses: actions/upload-artifact@v3
45 with:
46 name: csmock_logs
47 path: csmock_*/*
0 name: Build RPM packages
1
2 env:
3 MOCK_CHROOTS: "fedora-rawhide fedora-37 fedora-36"
4
5 on:
6 pull_request:
7 branches:
8 - master
9
10 jobs:
11 build:
12 name: rpmbuild
13 runs-on: ubuntu-22.04
14 env:
15 CI_CONTAINER: libblockdev-ci-rpmbuild
16 steps:
17 - name: Checkout libblockdev repository
18 uses: actions/checkout@v3
19
20 - name: Install podman
21 run: |
22 sudo apt -qq update
23 sudo apt -y -qq install podman
24
25 - name: Build the container
26 run: |
27 podman build --no-cache -t ${{ env.CI_CONTAINER }} -f misc/ci.Dockerfile .
28
29 - name: Start the container
30 run: |
31 podman run -d -t --name ${{ env.CI_CONTAINER }} --privileged --volume "$(pwd):/app" --workdir "/app" ${{ env.CI_CONTAINER }}
32
33 - name: Install test dependencies in the container
34 run: |
35 podman exec -it ${{ env.CI_CONTAINER }} bash -c "ansible-playbook -i "localhost," -c local misc/install-test-dependencies.yml"
36
37 - name: Run RPM mock builds in the container
38 run: |
39 podman exec -it ${{ env.CI_CONTAINER }} bash -c "/ci/run_rpmbuild_tests -c /ci/copr-builder.conf -p libblockdev-udisks -r ${{ env.MOCK_CHROOTS }}"
40
41 - name: Upload the rpmbuild logs
42 if: always()
43 uses: actions/upload-artifact@v3
44 with:
45 name: rpmbuild_logs
46 path: rpmbuild_*.log
0 extraction:
1 cpp:
2 prepare:
3 packages:
4 - "libblkid-dev"
5 - "libglib2.0-dev"
6 - "libcryptsetup-dev"
7 - "libpython3-dev"
8 - "libdevmapper-dev"
9 - "libudev-dev"
10 - "libkmod-dev"
11 - "libparted-dev"
12 - "libmount-dev"
13 - "libdmraid-dev"
14 - "libgirepository1.0-dev"
15 - "gobject-introspection"
16 - "libyaml-dev"
17 - "autoconf-archive"
18 - "libvolume-key-dev"
19 - "libbytesize-dev"
20 - "libnss3-dev"
21 - "libndctl-dev"
22 - "libext2fs-dev"
23 configure:
24 command: "./autogen.sh && ./configure"
0 Libblockdev 2.28
1 ----------------
2
3 New minor release of the libblockdev library with multiple fixes. See below
4 for details.
5
6 **Full list of changes**
7
8 Michael Biebl (1):
9
10 - Fix typos
11
12 Vojtech Trefny (17):
13
14 - lvm: Fix bd_lvm_get_supported_pe_sizes in Python on 32bit
15 - tests: Create bigger devices for XFS tests
16 - tests: Use ext instead of xfs in MountTestCase.test_mount_ro_device
17 - mpath: Memory leak fix
18 - spec: Require the same version utils from plugins
19 - mdraid: Try harder to get container UUID in bd_md_detail
20 - Add a test case for DDF arrays/containers
21 - mdraid: Do not ignore errors from bd_md_canonicalize_uuid in bd_md_examine
22 - mdraid: Try harder to get container UUID in bd_md_examine
23 - mdraid: Fix copy-paste error when checking return value
24 - tests: Wait for raid and mirrored LVs to be synced before removing
25 - tests: Make smaller images for test_lvcreate_type
26 - dm: Fix comparing DM RAID member devices UUID
27 - mdraid: Fix use after free
28 - ci: Add .lgtm.yaml config for LGTM
29 - ci: Add GitHub actions for running rpmbuilds and csmock
30 - mpath: Fix potential NULL pointer dereference
31
32 zhanghongtao (1):
33
34 - Fix mismatched functions return value type
35
36
037 Libblockdev 2.27
138 ----------------
239
00 # configure.ac for libblockdev
11
2 AC_INIT([libblockdev], [2.27], [vpodzime@redhat.com])
2 AC_INIT([libblockdev], [2.28], [vpodzime@redhat.com])
33
44 # Disable building static libraries.
55 # This needs to be set before initializing automake
123123 %define configure_opts %{?python2_copts} %{?python3_copts} %{?bcache_copts} %{?lvm_dbus_copts} %{?btrfs_copts} %{?crypto_copts} %{?dm_copts} %{?loop_copts} %{?lvm_copts} %{?lvm_dbus_copts} %{?mdraid_copts} %{?mpath_copts} %{?swap_copts} %{?kbd_copts} %{?part_copts} %{?fs_copts} %{?nvdimm_copts} %{?vdo_copts} %{?tools_copts} %{?gi_copts}
124124
125125 Name: libblockdev
126 Version: 2.27
126 Version: 2.28
127127 Release: 1%{?dist}
128128 Summary: A library for low-level manipulation with block devices
129129 License: LGPLv2+
226226 %package btrfs
227227 BuildRequires: libbytesize-devel
228228 Summary: The BTRFS plugin for the libblockdev library
229 Requires: %{name}-utils%{?_isa} >= 0.11
229 Requires: %{name}-utils%{?_isa} = %{version}-%{release}
230230 Requires: btrfs-progs
231231
232232 %description btrfs
237237 Summary: Development files for the libblockdev-btrfs plugin/library
238238 Requires: %{name}-btrfs%{?_isa} = %{version}-%{release}
239239 Requires: glib2-devel
240 Requires: %{name}-utils-devel%{?_isa}
240 Requires: %{name}-utils-devel%{?_isa} = %{version}-%{release}
241241
242242 %description btrfs-devel
243243 This package contains header files and pkg-config files needed for development
280280 %endif
281281 BuildRequires: systemd-devel
282282 Summary: The Device Mapper plugin for the libblockdev library
283 Requires: %{name}-utils%{?_isa} >= 0.11
283 Requires: %{name}-utils%{?_isa} = %{version}-%{release}
284284 Requires: device-mapper
285285 %if %{with_dmraid}
286286 Requires: dmraid
299299 %if %{with_dmraid}
300300 Requires: dmraid-devel
301301 %endif
302 Requires: %{name}-utils-devel%{?_isa}
302 Requires: %{name}-utils-devel%{?_isa} = %{version}-%{release}
303303
304304 %description dm-devel
305305 This package contains header files and pkg-config files needed for development
313313 BuildRequires: libblkid-devel
314314 BuildRequires: libmount-devel
315315 Summary: The FS plugin for the libblockdev library
316 Requires: %{name}-utils%{?_isa} >= 0.11
316 Requires: %{name}-utils%{?_isa} = %{version}-%{release}
317317
318318 %description fs
319319 The libblockdev library plugin (and in the same time a standalone library)
322322 %package fs-devel
323323 Summary: Development files for the libblockdev-fs plugin/library
324324 Requires: %{name}-fs%{?_isa} = %{version}-%{release}
325 Requires: %{name}-utils-devel%{?_isa}
325 Requires: %{name}-utils-devel%{?_isa} = %{version}-%{release}
326326 Requires: glib2-devel
327327 Requires: xfsprogs
328328 Requires: dosfstools
337337 %package kbd
338338 BuildRequires: libbytesize-devel
339339 Summary: The KBD plugin for the libblockdev library
340 Requires: %{name}-utils%{?_isa} >= 0.11
340 Requires: %{name}-utils%{?_isa} = %{version}-%{release}
341341 %if %{with_bcache}
342342 Requires: bcache-tools >= 1.0.8
343343 %endif
350350 %package kbd-devel
351351 Summary: Development files for the libblockdev-kbd plugin/library
352352 Requires: %{name}-kbd%{?_isa} = %{version}-%{release}
353 Requires: %{name}-utils-devel%{?_isa}
353 Requires: %{name}-utils-devel%{?_isa} = %{version}-%{release}
354354 Requires: glib2-devel
355355
356356 %description kbd-devel
362362 %if %{with_loop}
363363 %package loop
364364 Summary: The loop plugin for the libblockdev library
365 Requires: %{name}-utils%{?_isa} >= 0.11
365 Requires: %{name}-utils%{?_isa} = %{version}-%{release}
366366
367367 %description loop
368368 The libblockdev library plugin (and in the same time a standalone library)
371371 %package loop-devel
372372 Summary: Development files for the libblockdev-loop plugin/library
373373 Requires: %{name}-loop%{?_isa} = %{version}-%{release}
374 Requires: %{name}-utils-devel%{?_isa}
374 Requires: %{name}-utils-devel%{?_isa} = %{version}-%{release}
375375 Requires: glib2-devel
376376
377377 %description loop-devel
384384 %package lvm
385385 BuildRequires: device-mapper-devel
386386 Summary: The LVM plugin for the libblockdev library
387 Requires: %{name}-utils%{?_isa} >= 0.11
387 Requires: %{name}-utils%{?_isa} = %{version}-%{release}
388388 Requires: lvm2
389389
390390 %description lvm
406406 %package lvm-dbus
407407 BuildRequires: device-mapper-devel
408408 Summary: The LVM plugin for the libblockdev library
409 Requires: %{name}-utils%{?_isa} >= 1.4
409 Requires: %{name}-utils%{?_isa} = %{version}-%{release}
410410 Requires: lvm2-dbusd >= 2.02.156
411411
412412 %description lvm-dbus
429429 %package mdraid
430430 BuildRequires: libbytesize-devel
431431 Summary: The MD RAID plugin for the libblockdev library
432 Requires: %{name}-utils%{?_isa} >= 0.11
432 Requires: %{name}-utils%{?_isa} = %{version}-%{release}
433433 Requires: mdadm
434434
435435 %description mdraid
439439 %package mdraid-devel
440440 Summary: Development files for the libblockdev-mdraid plugin/library
441441 Requires: %{name}-mdraid%{?_isa} = %{version}-%{release}
442 Requires: %{name}-utils-devel%{?_isa}
442 Requires: %{name}-utils-devel%{?_isa} = %{version}-%{release}
443443 Requires: glib2-devel
444444
445445 %description mdraid-devel
452452 %package mpath
453453 BuildRequires: device-mapper-devel
454454 Summary: The multipath plugin for the libblockdev library
455 Requires: %{name}-utils%{?_isa} >= 0.11
455 Requires: %{name}-utils%{?_isa} = %{version}-%{release}
456456 Requires: device-mapper-multipath
457457
458458 %description mpath
462462 %package mpath-devel
463463 Summary: Development files for the libblockdev-mpath plugin/library
464464 Requires: %{name}-mpath%{?_isa} = %{version}-%{release}
465 Requires: %{name}-utils-devel%{?_isa}
465 Requires: %{name}-utils-devel%{?_isa} = %{version}-%{release}
466466 Requires: glib2-devel
467467
468468 %description mpath-devel
475475 BuildRequires: ndctl-devel
476476 BuildRequires: libuuid-devel
477477 Summary: The NVDIMM plugin for the libblockdev library
478 Requires: %{name}-utils%{?_isa} >= 0.11
478 Requires: %{name}-utils%{?_isa} = %{version}-%{release}
479479 Requires: ndctl
480480
481481 %description nvdimm
485485 %package nvdimm-devel
486486 Summary: Development files for the libblockdev-nvdimm plugin/library
487487 Requires: %{name}-nvdimm%{?_isa} = %{version}-%{release}
488 Requires: %{name}-utils-devel%{?_isa}
488 Requires: %{name}-utils-devel%{?_isa} = %{version}-%{release}
489489 Requires: glib2-devel
490490
491491 %description nvdimm-devel
498498 %package part
499499 BuildRequires: parted-devel
500500 Summary: The partitioning plugin for the libblockdev library
501 Requires: %{name}-utils%{?_isa} >= 0.11
501 Requires: %{name}-utils%{?_isa} = %{version}-%{release}
502502 Requires: gdisk
503503 Requires: util-linux
504504
509509 %package part-devel
510510 Summary: Development files for the libblockdev-part plugin/library
511511 Requires: %{name}-part%{?_isa} = %{version}-%{release}
512 Requires: %{name}-utils-devel%{?_isa}
512 Requires: %{name}-utils-devel%{?_isa} = %{version}-%{release}
513513 Requires: glib2-devel
514514
515515 %description part-devel
522522 %package swap
523523 BuildRequires: libblkid-devel
524524 Summary: The swap plugin for the libblockdev library
525 Requires: %{name}-utils%{?_isa} >= 0.11
525 Requires: %{name}-utils%{?_isa} = %{version}-%{release}
526526 Requires: util-linux
527527
528528 %description swap
532532 %package swap-devel
533533 Summary: Development files for the libblockdev-swap plugin/library
534534 Requires: %{name}-swap%{?_isa} = %{version}-%{release}
535 Requires: %{name}-utils-devel%{?_isa}
535 Requires: %{name}-utils-devel%{?_isa} = %{version}-%{release}
536536 Requires: glib2-devel
537537
538538 %description swap-devel
601601 %package s390-devel
602602 Summary: Development files for the libblockdev-s390 plugin/library
603603 Requires: %{name}-s390%{?_isa} = %{version}-%{release}
604 Requires: %{name}-utils-devel%{?_isa}
604 Requires: %{name}-utils-devel%{?_isa} = %{version}-%{release}
605605 Requires: glib2-devel
606606
607607 %description s390-devel
978978 %files plugins-all
979979
980980 %changelog
981 * Wed Sep 14 2022 Vojtech Trefny <vtrefny@redhat.com> - 2.28-1
982 - mpath: Fix potential NULL pointer dereference (vtrefny)
983 - ci: Add GitHub actions for running rpmbuilds and csmock (vtrefny)
984 - ci: Add .lgtm.yaml config for LGTM (vtrefny)
985 - mdraid: Fix use after free (vtrefny)
986 - dm: Fix comparing DM RAID member devices UUID (vtrefny)
987 - tests: Make smaller images for test_lvcreate_type (vtrefny)
988 - tests: Wait for raid and mirrored LVs to be synced before removing (vtrefny)
989 - mdraid: Fix copy-paste error when checking return value (vtrefny)
990 - mdraid: Try harder to get container UUID in bd_md_examine (vtrefny)
991 - mdraid: Do not ignore errors from bd_md_canonicalize_uuid in bd_md_examine (vtrefny)
992 - Add a test case for DDF arrays/containers (vtrefny)
993 - mdraid: Try harder to get container UUID in bd_md_detail (vtrefny)
994 - Fix mismatched functions return value type (zhanghongtao22)
995 - spec: Require the same version utils from plugins (vtrefny)
996 - mpath: Memory leak fix (vtrefny)
997 - tests: Use ext instead of xfs in MountTestCase.test_mount_ro_device (vtrefny)
998 - tests: Create bigger devices for XFS tests (vtrefny)
999 - lvm: Fix bd_lvm_get_supported_pe_sizes in Python on 32bit (vtrefny)
1000 - Fix typos (biebl)
1001
9811002 * Wed Jun 01 2022 Vojtech Trefny <vtrefny@redhat.com> - 2.27-1
9821003 - crypto: Remove unused and leaking error in write_escrow_data_file (vtrefny)
9831004 - kbd: Fix potential NULL pointer dereference in bd_kbd_bcache_create (vtrefny)
0 # latest fedora image for running some of our tests in GH actions
1
2 FROM registry.fedoraproject.org/fedora:latest
3
4 RUN set -e; \
5 dnf install -y ansible python3-pip rpm-build mock csmock git; \
6 pip3 install copr-builder; \
7 git clone --depth 1 https://github.com/storaged-project/ci.git;
8
9 WORKDIR /
0 # This is a simple ansible playbook for installing packages needed by the
1 # libblockdev test suite.
2 # You can do this by using 'make install-requires' or manually using
3 # 'ansible-playbook -K -i "localhost," -c local install-test-dependencies.yml'
4 # Currently only Fedora, CentOS 8 and Debian/Ubuntu are supported by this playbook.
5
6 ---
7 - hosts: all
8 become: true
9
10 tasks:
11 ####### Fedora
12 - name: Install basic build tools (Fedora)
13 package: name={{item}} state=present
14 with_items:
15 - gcc
16 - make
17 - libtool
18 - autoconf
19 - automake
20 when: ansible_distribution == 'Fedora'
21
22 - name: Install dnf-plugins-core for dnf builddep (Fedora)
23 package: name=dnf-plugins-core state=present
24 when: ansible_distribution == 'Fedora'
25
26 - name: Install build dependencies (Fedora)
27 command: "dnf -y builddep libblockdev --nogpgcheck"
28 args:
29 warn: false
30 when: ansible_distribution == 'Fedora'
31
32 - name: Install test dependencies (Fedora)
33 package: name={{item}} state=present
34 with_items:
35 - btrfs-progs
36 - bcache-tools
37 - cryptsetup
38 - device-mapper-multipath
39 - dosfstools
40 - e2fsprogs
41 - e2fsprogs-devel
42 - glibc-all-langpacks
43 - lvm2-dbusd
44 - mdadm
45 - ndctl
46 - nss-tools
47 - ntfsprogs
48 - python3-bytesize
49 - python3-dbus
50 - python3-packaging
51 - python3-pylint
52 - python3-yaml
53 - targetcli
54 - volume_key
55 - xfsprogs
56 when: ansible_distribution == 'Fedora'
57
58 ####### CentOS 8
59 - name: Install basic build tools (CentOS 8)
60 package: name={{item}} state=present
61 with_items:
62 - gcc
63 - make
64 - libtool
65 - autoconf
66 - automake
67 when: ansible_distribution == 'CentOS' and ansible_distribution_major_version == '8'
68
69 - name: Enable EPEL repository (CentOS 8)
70 package: name=epel-release state=present
71 when: ansible_distribution == 'CentOS' and ansible_distribution_major_version == '8'
72
73 - name: Enable powertools repository (CentOS 8)
74 command: yum config-manager --set-enabled powertools
75 when: ansible_distribution == 'CentOS' and ansible_distribution_major_version == '8'
76
77 - name: Install dnf-plugins-core for dnf builddep (CentOS 8)
78 package: name=dnf-plugins-core state=present
79 when: ansible_distribution == 'CentOS' and ansible_distribution_major_version == '8'
80
81 - name: Install build dependencies (CentOS 8)
82 command: "dnf -y builddep libblockdev --nogpgcheck"
83 args:
84 warn: false
85 when: ansible_distribution == 'CentOS' and ansible_distribution_major_version == '8'
86
87 - name: Install test dependencies (CentOS 8)
88 package: name={{item}} state=present
89 with_items:
90 - cryptsetup
91 - device-mapper-multipath
92 - dosfstools
93 - e2fsprogs
94 - e2fsprogs-devel
95 - glibc-all-langpacks
96 - kmod-kvdo
97 - lvm2-dbusd
98 - mdadm
99 - ndctl
100 - nss-tools
101 - ntfsprogs
102 - python3-bytesize
103 - python3-dbus
104 - python3-packaging
105 - python3-pylint
106 - python3-yaml
107 - targetcli
108 - vdo
109 - volume_key
110 - xfsprogs
111 when: ansible_distribution == 'CentOS' and ansible_distribution_major_version == '8'
112
113 ####### Debian/Ubuntu
114 - name: Update apt cache (Debian/Ubuntu)
115 apt:
116 update_cache: yes
117 when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
118
119 - name: Install basic build tools (Debian/Ubuntu)
120 package: name={{item}} state=present
121 with_items:
122 - gcc
123 - make
124 when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
125
126 - name: Add source repositories (Debian/Ubuntu)
127 shell: "grep '^deb ' /etc/apt/sources.list | perl -pe 's/deb /deb-src /' >> /etc/apt/sources.list"
128 when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
129
130 - name: Update apt cache (Debian/Ubuntu)
131 apt:
132 update_cache: yes
133 when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
134
135 - name: Install build dependencies (Debian/Ubuntu)
136 apt:
137 name: libblockdev
138 state: build-dep
139 when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
140
141 - name: Install test dependencies (Debian/Ubuntu)
142 package: name={{item}} state=present
143 with_items:
144 - bcache-tools
145 - btrfs-progs
146 - cryptsetup
147 - dosfstools
148 - e2fsprogs
149 - libext2fs-dev
150 - libnss3-tools
151 - locales-all
152 - lvm2-dbusd
153 - mdadm
154 - ndctl
155 - ntfs-3g
156 - pylint3
157 - python3-bytesize
158 - python3-packaging
159 - python3-pydbus
160 - python3-yaml
161 - targetcli-fb
162 - volume-key
163 - xfsprogs
164 when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
165
166 ####### Common actions
167
168 - name: Start LVM DBus service
169 service: name=lvm2-lvmdbusd state=started
170 ignore_errors: yes
636636 * bd_lvm_get_supported_pe_sizes:
637637 * @error: (out): place to store error (if any)
638638 *
639 * Returns: (transfer full) (array zero-terminated=1): list of supported PE sizes
639 * Returns: (transfer full) (array fixed-size=25): list of supported PE sizes
640640 *
641641 * Tech category: %BD_LVM_TECH_CALCS no mode (it is ignored)
642642 */
501501
502502 if (!check_deps (&avail_deps, DEPS_BTRFS_MASK, deps, DEPS_LAST, &deps_check_lock, error) ||
503503 !check_module_deps (&avail_module_deps, MODULE_DEPS_BTRFS_MASK, module_deps, MODULE_DEPS_LAST, &deps_check_lock, error))
504 return FALSE;
504 return 0;
505505
506506 regex = g_regex_new ("ID (\\d+) .*", 0, 0, error);
507507 if (!regex) {
622622
623623 if (!check_deps (&avail_deps, DEPS_BTRFS_MASK, deps, DEPS_LAST, &deps_check_lock, error) ||
624624 !check_module_deps (&avail_module_deps, MODULE_DEPS_BTRFS_MASK, module_deps, MODULE_DEPS_LAST, &deps_check_lock, error))
625 return FALSE;
625 return NULL;
626626
627627 regex = g_regex_new (pattern, G_REGEX_EXTENDED, 0, error);
628628 if (!regex) {
702702
703703 if (!check_deps (&avail_deps, DEPS_BTRFS_MASK, deps, DEPS_LAST, &deps_check_lock, error) ||
704704 !check_module_deps (&avail_module_deps, MODULE_DEPS_BTRFS_MASK, module_deps, MODULE_DEPS_LAST, &deps_check_lock, error))
705 return FALSE;
705 return NULL;
706706
707707 if (snapshots_only) {
708708 argv[4] = "-s";
816816
817817 if (!check_deps (&avail_deps, DEPS_BTRFS_MASK, deps, DEPS_LAST, &deps_check_lock, error) ||
818818 !check_module_deps (&avail_module_deps, MODULE_DEPS_BTRFS_MASK, module_deps, MODULE_DEPS_LAST, &deps_check_lock, error))
819 return FALSE;
819 return NULL;
820820
821821 regex = g_regex_new (pattern, G_REGEX_EXTENDED, 0, error);
822822 if (!regex) {
481481
482482 context = udev_new ();
483483 device = udev_device_new_from_subsystem_sysname (context, "block", dev_name);
484 dev_uuid = udev_device_get_property_value (device, "UUID");
484 dev_uuid = udev_device_get_property_value (device, "ID_FS_UUID");
485485 major_str = udev_device_get_property_value (device, "MAJOR");
486486 minor_str = udev_device_get_property_value (device, "MINOR");
487487
129129 perc = filter_line_fsck (line, 5, error);
130130 if (perc < 0) {
131131 g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_FAIL,
132 "An error occured when trying to parse a line with progress");
132 "An error occurred when trying to parse a line with progress");
133133 return FALSE;
134134 }
135135
289289 if (!probe) {
290290 g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_FAIL,
291291 "Failed to create a new probe");
292 return FALSE;
292 return NULL;
293293 }
294294
295295 fd = open (device, O_RDONLY|O_CLOEXEC);
297297 g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_FAIL,
298298 "Failed to open the device '%s'", device);
299299 blkid_free_probe (probe);
300 return FALSE;
300 return NULL;
301301 }
302302
303303 /* we may need to try mutliple times with some delays in case the device is
312312 "Failed to create a probe for the device '%s'", device);
313313 blkid_free_probe (probe);
314314 synced_close (fd);
315 return FALSE;
315 return NULL;
316316 }
317317
318318 blkid_probe_enable_partitions (probe, 1);
633633 BDKBDZramStats *ret = NULL;
634634
635635 if (!check_module_deps (&avail_module_deps, MODULE_DEPS_ZRAM_MASK, module_deps, MODULE_DEPS_LAST, &deps_check_lock, error))
636 return FALSE;
636 return NULL;
637637
638638 ret = g_new0 (BDKBDZramStats, 1);
639639
11721172 * bd_lvm_get_supported_pe_sizes:
11731173 * @error: (out): place to store error (if any)
11741174 *
1175 * Returns: (transfer full) (array zero-terminated=1): list of supported PE sizes
1175 * Returns: (transfer full) (array fixed-size=25): list of supported PE sizes
11761176 *
11771177 * Tech category: %BD_LVM_TECH_CALCS no mode (it is ignored)
11781178 */
30343034 g_set_error (error, BD_LVM_ERROR, BD_LVM_ERROR_CACHE_INVAL,
30353035 "Failed to determine cache pool name from: '%s'", ret);
30363036 g_free (ret);
3037 return FALSE;
3037 return NULL;
30383038 }
30393039 name_start++;
30403040
30433043 g_set_error (error, BD_LVM_ERROR, BD_LVM_ERROR_CACHE_INVAL,
30443044 "Failed to determine cache pool name from: '%s'", ret);
30453045 g_free (ret);
3046 return FALSE;
3046 return NULL;
30473047 }
30483048
30493049 pool_name = g_strndup (name_start, name_end - name_start);
707707 * bd_lvm_get_supported_pe_sizes:
708708 * @error: (out): place to store error (if any)
709709 *
710 * Returns: (transfer full) (array zero-terminated=1): list of supported PE sizes
710 * Returns: (transfer full) (array fixed-size=25): list of supported PE sizes
711711 *
712712 * Tech category: %BD_LVM_TECH_CALCS no mode (it is ignored)
713713 */
23592359 g_set_error (error, BD_LVM_ERROR, BD_LVM_ERROR_CACHE_INVAL,
23602360 "Failed to determine cache pool name from: '%s'", ret);
23612361 g_free (ret);
2362 return FALSE;
2362 return NULL;
23632363 }
23642364 name_start++;
23652365
23682368 g_set_error (error, BD_LVM_ERROR, BD_LVM_ERROR_CACHE_INVAL,
23692369 "Failed to determine cache pool name from: '%s'", ret);
23702370 g_free (ret);
2371 return FALSE;
2371 return NULL;
23722372 }
23732373
23742374 pool_name = g_strndup (name_start, name_end - name_start);
956956 gboolean found_array_line = FALSE;
957957
958958 if (!check_deps (&avail_deps, DEPS_MDADM_MASK, deps, DEPS_LAST, &deps_check_lock, error))
959 return FALSE;
959 return NULL;
960960
961961 success = bd_utils_exec_and_capture_output (argv, NULL, &output, error);
962962 if (!success)
963963 /* error is already populated */
964 return FALSE;
964 return NULL;
965965
966966 table = parse_mdadm_vars (output, "\n", ":", &num_items);
967967 g_free (output);
982982 orig_data = ret->uuid;
983983 if (orig_data) {
984984 ret->uuid = bd_md_canonicalize_uuid (orig_data, error);
985 if (!ret->uuid) {
986 g_prefix_error (error, "Failed to canonicalize MD UUID '%s': ", orig_data);
987 g_free (orig_data);
988 bd_md_examine_data_free (ret);
989 return NULL;
990 }
985991 g_free (orig_data);
986992 }
987993
988994 orig_data = ret->dev_uuid;
989995 if (orig_data) {
990996 ret->dev_uuid = bd_md_canonicalize_uuid (orig_data, error);
997 if (!ret->dev_uuid) {
998 g_prefix_error (error, "Failed to canonicalize MD UUID '%s': ", orig_data);
999 g_free (orig_data);
1000 bd_md_examine_data_free (ret);
1001 return NULL;
1002 }
9911003 g_free (orig_data);
9921004 }
9931005
9961008 if (!success) {
9971009 /* error is already populated */
9981010 bd_md_examine_data_free (ret);
999 return FALSE;
1011 return NULL;
10001012 }
10011013
10021014 /* try to get a better information about RAID level because it may be
10101022 value++;
10111023 g_free (ret->level);
10121024 ret->level = g_strdup (value);
1025 } else if (!ret->uuid && g_str_has_prefix (output_fields[i], "MD_UUID=")) {
1026 value = strchr (output_fields[i], '=');
1027 value++;
1028 ret->uuid = bd_md_canonicalize_uuid (value, error);
1029 if (!ret->uuid) {
1030 g_prefix_error (error, "Failed to canonicalize MD UUID '%s': ", value);
1031 bd_md_examine_data_free (ret);
1032 g_strfreev (output_fields);
1033 return NULL;
1034 }
10131035 }
10141036 g_strfreev (output_fields);
10151037
10181040 if (!success) {
10191041 /* error is already populated */
10201042 bd_md_examine_data_free (ret);
1021 return FALSE;
1043 return NULL;
10221044 }
10231045
10241046 /* try to find the "ARRAY /dev/md/something" pair in the output */
10691091 * Tech category: %BD_MD_TECH_MDRAID-%BD_MD_TECH_MODE_QUERY
10701092 */
10711093 BDMDDetailData* bd_md_detail (const gchar *raid_spec, GError **error) {
1072 const gchar *argv[] = {"mdadm", "--detail", NULL, NULL};
1094 const gchar *argv[] = {"mdadm", "--detail", NULL, NULL, NULL};
10731095 gchar *output = NULL;
10741096 gboolean success = FALSE;
10751097 GHashTable *table = NULL;
10761098 guint num_items = 0;
10771099 gchar *orig_uuid = NULL;
1078 gchar *mdadm_spec = NULL;
1100 g_autofree gchar *mdadm_spec = NULL;
1101 gchar *value = NULL;
1102 gchar **output_fields = NULL;
1103 guint i = 0;
10791104 BDMDDetailData *ret = NULL;
10801105
10811106 if (!check_deps (&avail_deps, DEPS_MDADM_MASK, deps, DEPS_LAST, &deps_check_lock, error))
1082 return FALSE;
1107 return NULL;
10831108
10841109 mdadm_spec = get_mdadm_spec_from_input (raid_spec, error);
10851110 if (!mdadm_spec)
10891114 argv[2] = mdadm_spec;
10901115
10911116 success = bd_utils_exec_and_capture_output (argv, NULL, &output, error);
1092 if (!success) {
1093 g_free (mdadm_spec);
1094 /* error is already populated */
1095 return NULL;
1096 }
1117 if (!success)
1118 /* error is already populated */
1119 return NULL;
10971120
10981121 table = parse_mdadm_vars (output, "\n", ":", &num_items);
10991122 g_free (output);
11001123 if (!table || (num_items == 0)) {
1101 g_free (mdadm_spec);
11021124 /* something bad happened or some expected items were missing */
11031125 g_set_error (error, BD_MD_ERROR, BD_MD_ERROR_PARSE, "Failed to parse mddetail data");
11041126 if (table)
11081130
11091131 ret = get_detail_data_from_table (table, TRUE);
11101132 if (!ret) {
1111 g_free (mdadm_spec);
11121133 g_set_error (error, BD_MD_ERROR, BD_MD_ERROR_PARSE, "Failed to get mddetail data");
11131134 return NULL;
11141135 }
11211142 g_free (orig_uuid);
11221143 }
11231144
1124 g_free (mdadm_spec);
1145 if (!ret->uuid) {
1146 argv[2] = "--export";
1147 argv[3] = mdadm_spec;
1148 success = bd_utils_exec_and_capture_output (argv, NULL, &output, error);
1149 if (!success) {
1150 /* error is already populated */
1151 bd_md_detail_data_free (ret);
1152 return NULL;
1153 }
1154
1155 /* try to get a better information about RAID level because it may be
1156 missing in the output without --export */
1157 output_fields = g_strsplit (output, "\n", 0);
1158 g_free (output);
1159 output = NULL;
1160 for (i = 0; (i < g_strv_length (output_fields) - 1); i++)
1161 if (g_str_has_prefix (output_fields[i], "MD_UUID=")) {
1162 value = strchr (output_fields[i], '=');
1163 value++;
1164 ret->uuid = bd_md_canonicalize_uuid (value, error);
1165 if (!ret->uuid) {
1166 g_prefix_error (error, "Failed to canonicalize MD UUID '%s': ", value);
1167 bd_md_detail_data_free (ret);
1168 g_strfreev (output_fields);
1169 return NULL;
1170 }
1171 }
1172 g_strfreev (output_fields);
1173 }
11251174
11261175 return ret;
11271176 }
406406 /* we are only interested in multipath maps */
407407 if (map_is_multipath (names->name, error)) {
408408 deps = get_map_deps (names->name, NULL, error);
409 if (*error) {
410 g_prefix_error (error, "Failed to determine deps for '%s'", names->name);
409 if (!deps) {
410 if (*error)
411 g_prefix_error (error, "Failed to determine deps for '%s'", names->name);
412 else
413 g_set_error (error, BD_MPATH_ERROR, BD_MPATH_ERROR_NOT_ROOT,
414 "No deps found for '%s'", names->name);
411415 g_free (dev_path);
412416 dm_task_destroy (task_names);
417 g_strfreev (deps);
413418 return FALSE;
414419 }
415420 for (dev_name = deps; !ret && *dev_name; dev_name++)
257257 if (success != 0) {
258258 g_set_error (error, BD_NVDIMM_ERROR, BD_NVDIMM_ERROR_NAMESPACE_FAIL,
259259 "Failed to create ndctl context");
260 return FALSE;
260 return NULL;
261261 }
262262
263263 ndctl_bus_foreach (ctx, bus) {
436436 break;
437437 default:
438438 g_set_error (error, BD_NVDIMM_ERROR, BD_NVDIMM_ERROR_NAMESPACE_FAIL,
439 "Failed to get information about namespaces: Unknow mode.");
439 "Failed to get information about namespaces: Unknown mode.");
440440 bd_nvdimm_namespace_info_free (info);
441441 return NULL;
442442 }
5555
5656 requested_plugins = BlockDev.plugin_specs_from_names(("fs", "loop"))
5757 _vfat_version = _get_dosfstools_version()
58 _loop_size = 100 * 1024**2
5859
5960 @classmethod
6061 def setUpClass(cls):
7677
7778 def setUp(self):
7879 self.addCleanup(self._clean_up)
79 self.dev_file = utils.create_sparse_tempfile("fs_test", 100 * 1024**2)
80 self.dev_file2 = utils.create_sparse_tempfile("fs_test", 100 * 1024**2)
80 self.dev_file = utils.create_sparse_tempfile("fs_test", self._loop_size)
81 self.dev_file2 = utils.create_sparse_tempfile("fs_test", self._loop_size)
8182 try:
8283 self.loop_dev = utils.create_lio_device(self.dev_file)
8384 except RuntimeError as e:
571572 resize_function=BlockDev.fs_ext4_resize)
572573
573574 class XfsTestMkfs(FSTestCase):
575 _loop_size = 500 * 1024**2
576
574577 @tag_test(TestTags.CORE)
575578 def test_xfs_mkfs(self):
576579 """Verify that it is possible to create a new xfs file system"""
592595 BlockDev.fs_wipe(self.loop_dev, True)
593596
594597 class XfsTestWipe(FSTestCase):
598 _loop_size = 500 * 1024**2
599
595600 def test_xfs_wipe(self):
596601 """Verify that it is possible to wipe an xfs file system"""
597602
622627 BlockDev.fs_wipe(self.loop_dev, True)
623628
624629 class XfsTestCheck(FSTestCase):
630 _loop_size = 500 * 1024**2
631
625632 def test_xfs_check(self):
626633 """Verify that it is possible to check an xfs file system"""
627634
641648 self.assertTrue(succ)
642649
643650 class XfsTestRepair(FSTestCase):
651 _loop_size = 500 * 1024**2
652
644653 def test_xfs_repair(self):
645654 """Verify that it is possible to repair an xfs file system"""
646655
658667 self.assertTrue(succ)
659668
660669 class XfsGetInfo(FSTestCase):
670 _loop_size = 500 * 1024**2
671
661672 @tag_test(TestTags.CORE)
662673 def test_xfs_get_info(self):
663674 """Verify that it is possible to get info about an xfs file system"""
672683 fi = BlockDev.fs_xfs_get_info(self.loop_dev)
673684
674685 self.assertEqual(fi.block_size, 4096)
675 self.assertEqual(fi.block_count, 100 * 1024**2 / 4096)
686 self.assertEqual(fi.block_count, 500 * 1024**2 / 4096)
676687 self.assertEqual(fi.label, "")
677688 # should be an non-empty string
678689 self.assertTrue(fi.uuid)
679690
680691 class XfsSetLabel(FSTestCase):
692 _loop_size = 500 * 1024**2
693
681694 def test_xfs_set_label(self):
682695 """Verify that it is possible to set label of an xfs file system"""
683696
711724 self.assertEqual(fi.label, "")
712725
713726 class XfsResize(FSTestCase):
727 _loop_size = 500 * 1024**2
728
714729 def _destroy_lvm(self):
715730 run("vgremove --yes libbd_fs_tests >/dev/null 2>&1")
716731 run("pvremove --yes %s >/dev/null 2>&1" % self.loop_dev)
720735
721736 run("pvcreate -ff -y %s >/dev/null 2>&1" % self.loop_dev)
722737 run("vgcreate -s10M libbd_fs_tests %s >/dev/null 2>&1" % self.loop_dev)
723 run("lvcreate -n xfs_test -L50M libbd_fs_tests >/dev/null 2>&1")
738 run("lvcreate -n xfs_test -L350M libbd_fs_tests >/dev/null 2>&1")
724739 self.addCleanup(self._destroy_lvm)
725740 lv = "/dev/libbd_fs_tests/xfs_test"
726741
730745 with mounted(lv, self.mount_dir):
731746 fi = BlockDev.fs_xfs_get_info(lv)
732747 self.assertTrue(fi)
733 self.assertEqual(fi.block_size * fi.block_count, 50 * 1024**2)
748 self.assertEqual(fi.block_size * fi.block_count, 350 * 1024**2)
734749
735750 # no change, nothing should happen
736751 with mounted(lv, self.mount_dir):
740755 with mounted(lv, self.mount_dir):
741756 fi = BlockDev.fs_xfs_get_info(lv)
742757 self.assertTrue(fi)
743 self.assertEqual(fi.block_size * fi.block_count, 50 * 1024**2)
758 self.assertEqual(fi.block_size * fi.block_count, 350 * 1024**2)
744759
745760 # (still) impossible to shrink an XFS file system
746761 xfs_version = _get_xfs_version()
749764 with self.assertRaises(GLib.GError):
750765 succ = BlockDev.fs_resize(lv, 40 * 1024**2)
751766
752 run("lvresize -L70M libbd_fs_tests/xfs_test >/dev/null 2>&1")
767 run("lvresize -L400M libbd_fs_tests/xfs_test >/dev/null 2>&1")
753768 # should grow
754769 with mounted(lv, self.mount_dir):
755770 succ = BlockDev.fs_xfs_resize(self.mount_dir, 0, None)
757772 with mounted(lv, self.mount_dir):
758773 fi = BlockDev.fs_xfs_get_info(lv)
759774 self.assertTrue(fi)
760 self.assertEqual(fi.block_size * fi.block_count, 70 * 1024**2)
761
762 run("lvresize -L90M libbd_fs_tests/xfs_test >/dev/null 2>&1")
763 # should grow just to 80 MiB
764 with mounted(lv, self.mount_dir):
765 succ = BlockDev.fs_xfs_resize(self.mount_dir, 80 * 1024**2 / fi.block_size, None)
775 self.assertEqual(fi.block_size * fi.block_count, 400 * 1024**2)
776
777 run("lvresize -L450M libbd_fs_tests/xfs_test >/dev/null 2>&1")
778 # should grow just to 430 MiB
779 with mounted(lv, self.mount_dir):
780 succ = BlockDev.fs_xfs_resize(self.mount_dir, 430 * 1024**2 / fi.block_size, None)
766781 self.assertTrue(succ)
767782 with mounted(lv, self.mount_dir):
768783 fi = BlockDev.fs_xfs_get_info(lv)
769784 self.assertTrue(fi)
770 self.assertEqual(fi.block_size * fi.block_count, 80 * 1024**2)
771
772 # should grow to 90 MiB
785 self.assertEqual(fi.block_size * fi.block_count, 430 * 1024**2)
786
787 # should grow to 450 MiB
773788 with mounted(lv, self.mount_dir):
774789 succ = BlockDev.fs_xfs_resize(self.mount_dir, 0, None)
775790 self.assertTrue(succ)
776791 with mounted(lv, self.mount_dir):
777792 fi = BlockDev.fs_xfs_get_info(lv)
778793 self.assertTrue(fi)
779 self.assertEqual(fi.block_size * fi.block_count, 90 * 1024**2)
794 self.assertEqual(fi.block_size * fi.block_count, 450 * 1024**2)
780795
781796 class VfatTestMkfs(FSTestCase):
782797 def test_vfat_mkfs(self):
11111126
11121127 backing_file = create_sparse_tempfile("ro_mount", 50 * 1024**2)
11131128 self.addCleanup(os.unlink, backing_file)
1114 self.assertTrue(BlockDev.fs_xfs_mkfs(backing_file, None))
1129 self.assertTrue(BlockDev.fs_ext2_mkfs(backing_file, None))
11151130
11161131 succ, dev = BlockDev.loop_setup(backing_file, 0, 0, True, False)
11171132 self.assertTrue(succ)
12761291
12771292 class GenericCheck(FSTestCase):
12781293 log = []
1294 _loop_size = 500 * 1024**2
12791295
12801296 def _test_generic_check(self, mkfs_function):
12811297 # clean the device
13251341 self._test_generic_check(mkfs_function=BlockDev.fs_ntfs_mkfs)
13261342
13271343 class GenericRepair(FSTestCase):
1344 _loop_size = 500 * 1024**2
1345
13281346 def _test_generic_repair(self, mkfs_function):
13291347 # clean the device
13301348 succ = BlockDev.fs_clean(self.loop_dev)
13511369 self._test_generic_repair(mkfs_function=BlockDev.fs_ntfs_mkfs)
13521370
13531371 class GenericSetLabel(FSTestCase):
1372 _loop_size = 500 * 1024**2
1373
13541374 def _test_generic_set_label(self, mkfs_function):
13551375 # clean the device
13561376 succ = BlockDev.fs_clean(self.loop_dev)
13771397 self._test_generic_set_label(mkfs_function=BlockDev.fs_ntfs_mkfs)
13781398
13791399 class GenericResize(FSTestCase):
1400 _loop_size = 500 * 1024**2
1401
13801402 def _test_generic_resize(self, mkfs_function, fs_info_func=None, info_size_func=None):
13811403 # clean the device
13821404 succ = BlockDev.fs_clean(self.loop_dev)
14611483
14621484 run("pvcreate -ff -y %s >/dev/null 2>&1" % self.loop_dev)
14631485 run("vgcreate -s10M libbd_fs_tests %s >/dev/null 2>&1" % self.loop_dev)
1464 run("lvcreate -n xfs_test -L50M libbd_fs_tests >/dev/null 2>&1")
1486 run("lvcreate -n xfs_test -L350M libbd_fs_tests >/dev/null 2>&1")
14651487 self.addCleanup(self._destroy_lvm)
14661488
14671489 lv = "/dev/libbd_fs_tests/xfs_test"
14751497 with mounted(lv, self.mount_dir):
14761498 fi = BlockDev.fs_xfs_get_info(lv)
14771499 self.assertTrue(fi)
1478 self.assertEqual(fi.block_size * fi.block_count, 50 * 1024**2)
1500 self.assertEqual(fi.block_size * fi.block_count, 350 * 1024**2)
14791501
14801502 # no change, nothing should happen
14811503 with mounted(lv, self.mount_dir):
14851507 with mounted(lv, self.mount_dir):
14861508 fi = BlockDev.fs_xfs_get_info(lv)
14871509 self.assertTrue(fi)
1488 self.assertEqual(fi.block_size * fi.block_count, 50 * 1024**2)
1510 self.assertEqual(fi.block_size * fi.block_count, 350 * 1024**2)
14891511
14901512 # (still) impossible to shrink an XFS file system
14911513 xfs_version = _get_xfs_version()
14941516 with self.assertRaises(GLib.GError):
14951517 succ = BlockDev.fs_resize(lv, 40 * 1024**2)
14961518
1497 run("lvresize -L70M libbd_fs_tests/xfs_test >/dev/null 2>&1")
1519 run("lvresize -L400M libbd_fs_tests/xfs_test >/dev/null 2>&1")
14981520 # should grow
14991521 with mounted(lv, self.mount_dir):
15001522 succ = BlockDev.fs_resize(lv, 0)
15021524 with mounted(lv, self.mount_dir):
15031525 fi = BlockDev.fs_xfs_get_info(lv)
15041526 self.assertTrue(fi)
1505 self.assertEqual(fi.block_size * fi.block_count, 70 * 1024**2)
1506
1507 run("lvresize -L90M libbd_fs_tests/xfs_test >/dev/null 2>&1")
1508 # should grow just to 80 MiB
1509 with mounted(lv, self.mount_dir):
1510 succ = BlockDev.fs_resize(lv, 80 * 1024**2)
1527 self.assertEqual(fi.block_size * fi.block_count, 400 * 1024**2)
1528
1529 run("lvresize -L450M libbd_fs_tests/xfs_test >/dev/null 2>&1")
1530 # should grow just to 430 MiB
1531 with mounted(lv, self.mount_dir):
1532 succ = BlockDev.fs_resize(lv, 430 * 1024**2)
15111533 self.assertTrue(succ)
15121534 with mounted(lv, self.mount_dir):
15131535 fi = BlockDev.fs_xfs_get_info(lv)
15141536 self.assertTrue(fi)
1515 self.assertEqual(fi.block_size * fi.block_count, 80 * 1024**2)
1516
1517 # should grow to 90 MiB
1537 self.assertEqual(fi.block_size * fi.block_count, 430 * 1024**2)
1538
1539 # should grow to 450 MiB
15181540 with mounted(lv, self.mount_dir):
15191541 succ = BlockDev.fs_resize(lv, 0)
15201542 self.assertTrue(succ)
15211543 with mounted(lv, self.mount_dir):
15221544 fi = BlockDev.fs_xfs_get_info(lv)
15231545 self.assertTrue(fi)
1524 self.assertEqual(fi.block_size * fi.block_count, 90 * 1024**2)
1546 self.assertEqual(fi.block_size * fi.block_count, 450 * 1024**2)
15251547
15261548
15271549 class FSFreezeTest(FSTestCase):
1550 _loop_size = 500 * 1024**2
15281551
15291552 def _clean_up(self):
15301553 try:
66 import re
77 import shutil
88 import subprocess
9 import time
10 from contextlib import contextmanager
911 from distutils.version import LooseVersion
1012 from itertools import chain
1113
1517 import dbus
1618 sb = dbus.SystemBus()
1719 lvm_dbus_running = any("lvmdbus" in name for name in chain(sb.list_names(), sb.list_activatable_names()))
20
21
22 @contextmanager
23 def wait_for_sync(vg_name, lv_name):
24 try:
25 yield
26 finally:
27 time.sleep(2)
28 while True:
29 ret, out, _err = run_command("LC_ALL=C lvs -o copy_percent --noheadings %s/%s" % (vg_name, lv_name))
30 if ret != 0:
31 break
32 if int(float(out)) == 100:
33 break
34 time.sleep(1)
1835
1936
2037 class LVMTestCase(unittest.TestCase):
6784 def test_get_supported_pe_sizes(self):
6885 """Verify that supported PE sizes are really supported"""
6986
70 for size in BlockDev.lvm_get_supported_pe_sizes():
87 supported = BlockDev.lvm_get_supported_pe_sizes()
88
89 for size in supported:
7190 self.assertTrue(BlockDev.lvm_is_supported_pe_size(size))
91
92 self.assertIn(4 * 1024, supported)
93 self.assertIn(4 * 1024 **2, supported)
94 self.assertIn(16 * 1024**3, supported)
7295
7396 @tag_test(TestTags.NOSTORAGE)
7497 def test_get_max_lv_size(self):
252275
253276 @unittest.skipUnless(lvm_dbus_running, "LVM DBus not running")
254277 class LvmPVonlyTestCase(LVMTestCase):
278
279 _sparse_size = 1024**3
280
255281 # :TODO:
256282 # * test pvmove (must create two PVs, a VG, a VG and some data in it
257283 # first)
258284 # * some complex test for pvs, vgs, lvs, pvinfo, vginfo and lvinfo
259285 def setUp(self):
260286 self.addCleanup(self._clean_up)
261 self.dev_file = create_sparse_tempfile("lvm_test", 1024**3)
262 self.dev_file2 = create_sparse_tempfile("lvm_test", 1024**3)
287 self.dev_file = create_sparse_tempfile("lvm_test", self._sparse_size)
288 self.dev_file2 = create_sparse_tempfile("lvm_test", self._sparse_size)
263289 try:
264290 self.loop_dev = create_lio_device(self.dev_file)
265291 except RuntimeError as e:
734760
735761 @unittest.skipUnless(lvm_dbus_running, "LVM DBus not running")
736762 class LvmTestLVcreateType(LvmPVVGLVTestCase):
763
764 _sparse_size = 200 * 1024**2
765
737766 def test_lvcreate_type(self):
738767 """Verify it's possible to create LVs with various types"""
739768
747776 self.assertTrue(succ)
748777
749778 # try to create a striped LV
750 succ = BlockDev.lvm_lvcreate("testVG", "testLV", 512 * 1024**2, "striped", [self.loop_dev, self.loop_dev2], None)
779 succ = BlockDev.lvm_lvcreate("testVG", "testLV", 100 * 1024**2, "striped", [self.loop_dev, self.loop_dev2], None)
751780 self.assertTrue(succ)
752781
753782 # verify that the LV has the requested segtype
757786 succ = BlockDev.lvm_lvremove("testVG", "testLV", True, None)
758787 self.assertTrue(succ)
759788
760 # try to create a mirrored LV
761 succ = BlockDev.lvm_lvcreate("testVG", "testLV", 512 * 1024**2, "mirror", [self.loop_dev, self.loop_dev2], None)
762 self.assertTrue(succ)
789 with wait_for_sync("testVG", "testLV"):
790 # try to create a mirrored LV
791 succ = BlockDev.lvm_lvcreate("testVG", "testLV", 100 * 1024**2, "mirror", [self.loop_dev, self.loop_dev2], None)
792 self.assertTrue(succ)
763793
764794 # verify that the LV has the requested segtype
765795 info = BlockDev.lvm_lvinfo("testVG", "testLV")
768798 succ = BlockDev.lvm_lvremove("testVG", "testLV", True, None)
769799 self.assertTrue(succ)
770800
771 # try to create a raid1 LV
772 succ = BlockDev.lvm_lvcreate("testVG", "testLV", 512 * 1024**2, "raid1", [self.loop_dev, self.loop_dev2], None)
773 self.assertTrue(succ)
801 with wait_for_sync("testVG", "testLV"):
802 # try to create a raid1 LV
803 succ = BlockDev.lvm_lvcreate("testVG", "testLV", 100 * 1024**2, "raid1", [self.loop_dev, self.loop_dev2], None)
804 self.assertTrue(succ)
774805
775806 # verify that the LV has the requested segtype
776807 info = BlockDev.lvm_lvinfo("testVG", "testLV")
66 import re
77 import shutil
88 import subprocess
9 import time
10 from contextlib import contextmanager
911 from distutils.version import LooseVersion
1012
1113 from utils import create_sparse_tempfile, create_lio_device, delete_lio_device, fake_utils, fake_path, TestTags, tag_test, run_command
1214 from gi.repository import BlockDev, GLib
15
16
17 @contextmanager
18 def wait_for_sync(vg_name, lv_name):
19 try:
20 yield
21 finally:
22 time.sleep(2)
23 while True:
24 info = BlockDev.lvm_lvinfo(vg_name, lv_name)
25 if not info:
26 break
27 if info.copy_percent == 100:
28 break
29 time.sleep(1)
1330
1431
1532 class LVMTestCase(unittest.TestCase):
6077 def test_get_supported_pe_sizes(self):
6178 """Verify that supported PE sizes are really supported"""
6279
63 for size in BlockDev.lvm_get_supported_pe_sizes():
80 supported = BlockDev.lvm_get_supported_pe_sizes()
81
82 for size in supported:
6483 self.assertTrue(BlockDev.lvm_is_supported_pe_size(size))
84
85 self.assertIn(4 * 1024, supported)
86 self.assertIn(4 * 1024 **2, supported)
87 self.assertIn(16 * 1024**3, supported)
6588
6689 @tag_test(TestTags.NOSTORAGE)
6790 def test_get_max_lv_size(self):
237260 BlockDev.lvm_cache_get_mode_from_str("bla")
238261
239262 class LvmPVonlyTestCase(LVMTestCase):
263
264 _sparse_size = 1024**3
265
240266 # :TODO:
241267 # * test pvmove (must create two PVs, a VG, a VG and some data in it
242268 # first)
243269 # * some complex test for pvs, vgs, lvs, pvinfo, vginfo and lvinfo
244270 def setUp(self):
245271 self.addCleanup(self._clean_up)
246 self.dev_file = create_sparse_tempfile("lvm_test", 1024**3)
247 self.dev_file2 = create_sparse_tempfile("lvm_test", 1024**3)
272 self.dev_file = create_sparse_tempfile("lvm_test", self._sparse_size)
273 self.dev_file2 = create_sparse_tempfile("lvm_test", self._sparse_size)
248274 try:
249275 self.loop_dev = create_lio_device(self.dev_file)
250276 except RuntimeError as e:
666692 self.assertTrue(succ)
667693
668694 class LvmTestLVcreateType(LvmPVVGLVTestCase):
695 _sparse_size = 200 * 1024**2
696
669697 def test_lvcreate_type(self):
670698 """Verify it's possible to create LVs with various types"""
671699
679707 self.assertTrue(succ)
680708
681709 # try to create a striped LV
682 succ = BlockDev.lvm_lvcreate("testVG", "testLV", 512 * 1024**2, "striped", [self.loop_dev, self.loop_dev2], None)
710 succ = BlockDev.lvm_lvcreate("testVG", "testLV", 100 * 1024**2, "striped", [self.loop_dev, self.loop_dev2], None)
683711 self.assertTrue(succ)
684712
685713 # verify that the LV has the requested segtype
689717 succ = BlockDev.lvm_lvremove("testVG", "testLV", True, None)
690718 self.assertTrue(succ)
691719
692 # try to create a mirrored LV
693 succ = BlockDev.lvm_lvcreate("testVG", "testLV", 512 * 1024**2, "mirror", [self.loop_dev, self.loop_dev2], None)
694 self.assertTrue(succ)
720 with wait_for_sync("testVG", "testLV"):
721 # try to create a mirrored LV
722 succ = BlockDev.lvm_lvcreate("testVG", "testLV", 100 * 1024**2, "mirror", [self.loop_dev, self.loop_dev2], None)
723 self.assertTrue(succ)
695724
696725 # verify that the LV has the requested segtype
697726 info = BlockDev.lvm_lvinfo("testVG", "testLV")
700729 succ = BlockDev.lvm_lvremove("testVG", "testLV", True, None)
701730 self.assertTrue(succ)
702731
703 # try to create a raid1 LV
704 succ = BlockDev.lvm_lvcreate("testVG", "testLV", 512 * 1024**2, "raid1", [self.loop_dev, self.loop_dev2], None)
705 self.assertTrue(succ)
732 with wait_for_sync("testVG", "testLV"):
733 # try to create a raid1 LV
734 succ = BlockDev.lvm_lvcreate("testVG", "testLV", 100 * 1024**2, "raid1", [self.loop_dev, self.loop_dev2], None)
735 self.assertTrue(succ)
706736
707737 # verify that the LV has the requested segtype
708738 info = BlockDev.lvm_lvinfo("testVG", "testLV")
55 import overrides_hack
66 import six
77
8 from utils import create_sparse_tempfile, create_lio_device, delete_lio_device, fake_utils, fake_path, TestTags, tag_test
8 from utils import create_sparse_tempfile, create_lio_device, delete_lio_device, fake_utils, fake_path, TestTags, tag_test, run_command
99 from gi.repository import BlockDev, GLib
1010
1111
8989
9090 class MDTestCase(MDTest):
9191
92 _sparse_size = 10 * 1024**2
93
9294 def setUp(self):
9395 if os.uname()[-1] == "i686":
9496 self.skipTest("Skipping hanging MD RAID tests on i686")
9597
9698 self.addCleanup(self._clean_up)
97 self.dev_file = create_sparse_tempfile("md_test", 10 * 1024**2)
98 self.dev_file2 = create_sparse_tempfile("md_test", 10 * 1024**2)
99 self.dev_file3 = create_sparse_tempfile("md_test", 10 * 1024**2)
99 self.dev_file = create_sparse_tempfile("md_test", self._sparse_size)
100 self.dev_file2 = create_sparse_tempfile("md_test", self._sparse_size)
101 self.dev_file3 = create_sparse_tempfile("md_test", self._sparse_size)
100102
101103 try:
102104 self.loop_dev = create_lio_device(self.dev_file)
585587 action = f.read().strip()
586588 self.assertEqual(action, "check")
587589
590
591 class MDTestDDFRAID(MDTestCase):
592
593 _sparse_size = 50 * 1024**2
594
595 def _clean_up(self):
596 try:
597 BlockDev.md_deactivate("bd_test_ddf")
598 except:
599 pass
600 try:
601 BlockDev.md_deactivate(BlockDev.md_node_from_name("bd_test_ddf"))
602 except:
603 pass
604
605 super(MDTestDDFRAID, self)._clean_up()
606
607 def test_examine_ddf_container(self):
608 succ = BlockDev.md_create("bd_test_md", "container",
609 [self.loop_dev, self.loop_dev2],
610 0, "ddf", False)
611 self.assertTrue(succ)
612
613 # we cannot create the array with libblockdev because we cannot pass the --raid-devices option
614 ret, _out, err = run_command("mdadm --create /dev/md/bd_test_ddf --run --level=raid0 --raid-devices=2 /dev/md/bd_test_md")
615 self.assertEqual(ret, 0, msg="Failed to create RAID for DDF test: %s" % err)
616
617 edata = BlockDev.md_examine(self.loop_dev)
618 self.assertIsNotNone(edata)
619 self.assertIsNotNone(edata.uuid)
620 self.assertEqual(edata.level, "container")
621 self.assertEqual(edata.metadata, "ddf")
622
623 ddata = BlockDev.md_detail("bd_test_md")
624 self.assertIsNotNone(ddata)
625 self.assertIsNotNone(ddata.uuid)
626 self.assertEqual(ddata.uuid, edata.uuid)
627 self.assertEqual(ddata.level, "container")
628 self.assertEqual(ddata.metadata, "ddf")
629
630
588631 class FakeMDADMutilTest(MDTest):
589632 # no setUp nor tearDown needed, we are gonna use fake utils
590633 @tag_test(TestTags.NOSTORAGE)