Skip to content

Commit

Permalink
Merge pull request #1327 from ancorgs/export_thin
Browse files Browse the repository at this point in the history
Ensure thin LVM volumes are exported when cloning the system
  • Loading branch information
ancorgs committed Apr 3, 2023
2 parents 7d67d4a + 285387c commit cb39f48
Show file tree
Hide file tree
Showing 3 changed files with 332 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/y2storage/autoinst_profile/drive_section.rb
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ def init_from_vg(vg)
@type = :CT_LVM
@device = vg.name

@partitions = partitions_from_collection(vg.lvm_lvs)
@partitions = partitions_from_collection(vg.all_lvm_lvs)
return false if @partitions.empty?

@enable_snapshots = enabled_snapshots?(vg.lvm_lvs.map(&:filesystem).compact)
Expand Down
307 changes: 307 additions & 0 deletions test/data/devicegraphs/bug_1209725.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,307 @@
<?xml version="1.0"?>
<Devicegraph>
<Devices>
<Disk>
<sid>42</sid>
<name>/dev/sda</name>
<sysfs-name>sda</sysfs-name>
<region>
<length>134217728</length>
<block-size>512</block-size>
</region>
<range>256</range>
</Disk>
<LvmVg>
<sid>43</sid>
<vg-name>system</vg-name>
<region>
<length>16127</length>
<block-size>4194304</block-size>
</region>
<reserved-extents>30</reserved-extents>
</LvmVg>
<LvmPv>
<sid>44</sid>
<pe-start>1048576</pe-start>
</LvmPv>
<LvmLv>
<sid>45</sid>
<name>/dev/system/boot</name>
<region>
<length>512</length>
<block-size>4194304</block-size>
</region>
<dm-table-name>system-boot</dm-table-name>
<lv-name>boot</lv-name>
<lv-type>normal</lv-type>
<used-extents>512</used-extents>
</LvmLv>
<LvmLv>
<sid>46</sid>
<name>/dev/system/swap</name>
<region>
<length>1024</length>
<block-size>4194304</block-size>
</region>
<dm-table-name>system-swap</dm-table-name>
<lv-name>swap</lv-name>
<lv-type>normal</lv-type>
<used-extents>1024</used-extents>
</LvmLv>
<LvmLv>
<sid>47</sid>
<name>/dev/system/thin_pool00</name>
<active>false</active>
<region>
<length>14561</length>
<block-size>4194304</block-size>
</region>
<dm-table-name>system-thin_pool00</dm-table-name>
<lv-name>thin_pool00</lv-name>
<lv-type>thin-pool</lv-type>
<used-extents>14561</used-extents>
<chunk-size>65536</chunk-size>
</LvmLv>
<LvmLv>
<sid>49</sid>
<name>/dev/system/home</name>
<region>
<length>1024</length>
<block-size>4194304</block-size>
</region>
<dm-table-name>system-home</dm-table-name>
<lv-name>home</lv-name>
<lv-type>thin</lv-type>
</LvmLv>
<LvmLv>
<sid>51</sid>
<name>/dev/system/root</name>
<region>
<length>4096</length>
<block-size>4194304</block-size>
</region>
<dm-table-name>system-root</dm-table-name>
<lv-name>root</lv-name>
<lv-type>thin</lv-type>
</LvmLv>
<LvmLv>
<sid>53</sid>
<name>/dev/system/var</name>
<region>
<length>1024</length>
<block-size>4194304</block-size>
</region>
<dm-table-name>system-var</dm-table-name>
<lv-name>var</lv-name>
<lv-type>thin</lv-type>
</LvmLv>
<Gpt>
<sid>54</sid>
</Gpt>
<Partition>
<sid>55</sid>
<name>/dev/sda1</name>
<region>
<start>2048</start>
<length>2097152</length>
<block-size>512</block-size>
</region>
<id>0xef</id>
</Partition>
<Partition>
<sid>56</sid>
<name>/dev/sda2</name>
<region>
<start>2099200</start>
<length>132118495</length>
<block-size>512</block-size>
</region>
<id>0x8e</id>
</Partition>
<Xfs>
<sid>57</sid>
<uuid>4a6598ea-264a-486e-a944-cf3a2fe341f6</uuid>
</Xfs>
<MountPoint>
<sid>58</sid>
<path>/boot</path>
<rootprefixed>true</rootprefixed>
<mount-by>device</mount-by>
<mount-type>xfs</mount-type>
<active>true</active>
<in-etc-fstab>true</in-etc-fstab>
<freq>0</freq>
<passno>0</passno>
</MountPoint>
<Swap>
<sid>59</sid>
<uuid>39910b90-7745-413f-b8a5-0308bd76fd7d</uuid>
</Swap>
<MountPoint>
<sid>60</sid>
<path>swap</path>
<rootprefixed>true</rootprefixed>
<mount-by>device</mount-by>
<mount-type>swap</mount-type>
<active>true</active>
<in-etc-fstab>true</in-etc-fstab>
<freq>0</freq>
<passno>0</passno>
</MountPoint>
<Xfs>
<sid>63</sid>
<uuid>ecc25fb9-0d72-4448-a688-565697b732b0</uuid>
</Xfs>
<MountPoint>
<sid>64</sid>
<path>/home</path>
<rootprefixed>true</rootprefixed>
<mount-by>device</mount-by>
<mount-type>xfs</mount-type>
<active>true</active>
<in-etc-fstab>true</in-etc-fstab>
<freq>0</freq>
<passno>0</passno>
</MountPoint>
<Xfs>
<sid>67</sid>
<uuid>3c130ca3-7380-4f4d-81ee-6d352476fa50</uuid>
</Xfs>
<MountPoint>
<sid>68</sid>
<path>/</path>
<rootprefixed>true</rootprefixed>
<mount-by>device</mount-by>
<mount-type>xfs</mount-type>
<active>true</active>
<in-etc-fstab>true</in-etc-fstab>
<freq>0</freq>
<passno>0</passno>
</MountPoint>
<Xfs>
<sid>71</sid>
<uuid>fcc83f3c-46da-4c12-8170-a7f1bd43a4aa</uuid>
</Xfs>
<MountPoint>
<sid>72</sid>
<path>/var</path>
<rootprefixed>true</rootprefixed>
<mount-by>device</mount-by>
<mount-type>xfs</mount-type>
<active>true</active>
<in-etc-fstab>true</in-etc-fstab>
<freq>0</freq>
<passno>0</passno>
</MountPoint>
<Vfat>
<sid>73</sid>
<uuid>D7AE-91FD</uuid>
</Vfat>
<MountPoint>
<sid>74</sid>
<path>/boot/efi</path>
<rootprefixed>true</rootprefixed>
<mount-by>uuid</mount-by>
<mount-options>utf8</mount-options>
<mount-type>vfat</mount-type>
<active>true</active>
<in-etc-fstab>true</in-etc-fstab>
<freq>0</freq>
<passno>0</passno>
</MountPoint>
</Devices>
<Holders>
<Subdevice>
<source-sid>44</source-sid>
<target-sid>43</target-sid>
</Subdevice>
<Subdevice>
<source-sid>43</source-sid>
<target-sid>45</target-sid>
</Subdevice>
<Subdevice>
<source-sid>43</source-sid>
<target-sid>46</target-sid>
</Subdevice>
<Subdevice>
<source-sid>43</source-sid>
<target-sid>47</target-sid>
</Subdevice>
<Subdevice>
<source-sid>47</source-sid>
<target-sid>49</target-sid>
</Subdevice>
<Subdevice>
<source-sid>47</source-sid>
<target-sid>51</target-sid>
</Subdevice>
<Subdevice>
<source-sid>47</source-sid>
<target-sid>53</target-sid>
</Subdevice>
<User>
<source-sid>42</source-sid>
<target-sid>54</target-sid>
</User>
<Subdevice>
<source-sid>54</source-sid>
<target-sid>55</target-sid>
</Subdevice>
<Subdevice>
<source-sid>54</source-sid>
<target-sid>56</target-sid>
</Subdevice>
<User>
<source-sid>56</source-sid>
<target-sid>44</target-sid>
</User>
<FilesystemUser>
<source-sid>45</source-sid>
<target-sid>57</target-sid>
</FilesystemUser>
<User>
<source-sid>57</source-sid>
<target-sid>58</target-sid>
</User>
<FilesystemUser>
<source-sid>46</source-sid>
<target-sid>59</target-sid>
</FilesystemUser>
<User>
<source-sid>59</source-sid>
<target-sid>60</target-sid>
</User>
<FilesystemUser>
<source-sid>49</source-sid>
<target-sid>63</target-sid>
</FilesystemUser>
<User>
<source-sid>63</source-sid>
<target-sid>64</target-sid>
</User>
<FilesystemUser>
<source-sid>51</source-sid>
<target-sid>67</target-sid>
</FilesystemUser>
<User>
<source-sid>67</source-sid>
<target-sid>68</target-sid>
</User>
<FilesystemUser>
<source-sid>53</source-sid>
<target-sid>71</target-sid>
</FilesystemUser>
<User>
<source-sid>71</source-sid>
<target-sid>72</target-sid>
</User>
<FilesystemUser>
<source-sid>55</source-sid>
<target-sid>73</target-sid>
</FilesystemUser>
<User>
<source-sid>73</source-sid>
<target-sid>74</target-sid>
</User>
</Holders>
</Devicegraph>
24 changes: 24 additions & 0 deletions test/y2storage/autoinst_profile/partitioning_section_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,30 @@
expect(drive.device).to eq("/dev/md/Volume0_0")
end
end

# Regression test for bug#1209725, thin volumes were not exported
context "in a scenario that combines normal and thin volumes" do
before { fake_scenario("bug_1209725.xml") }

it "includes the thin pool as a partition of the CT_LVM drive" do
section = described_class.new_from_storage(fake_devicegraph)
drive = section.drives.find { |d| d.type == :CT_LVM }

pool = drive.partitions.find(&:pool)
expect(pool.lv_name).to eq "thin_pool00"
end

it "includes all the volumes (normal and thin ones) as partitions in the CT_LVM drive" do
section = described_class.new_from_storage(fake_devicegraph)
drive = section.drives.find { |d| d.type == :CT_LVM }

lvs = drive.partitions.reject(&:pool).map { |d| [d.mount, d.used_pool] }
expect(lvs).to contain_exactly(
["/boot", nil], ["swap", nil],
["/home", "thin_pool00"], ["/", "thin_pool00"], ["/var", "thin_pool00"]
)
end
end
end

describe "#to_hashes" do
Expand Down

0 comments on commit cb39f48

Please sign in to comment.