Adding PVs that are member of VGs that are going to be deleted soon in CreateVolumeGroupDialog and ResizeVolumeGroupDialog. Avoiding segfault because of devices partition tables in CreateVolumeGroupDialog and ResizeVolumeGroupDialog.

This commit is contained in:
Caio Carvalho 2018-07-23 13:38:30 -03:00
parent 9bcde2c7de
commit f21b42d10e
2 changed files with 38 additions and 26 deletions

View File

@ -76,24 +76,30 @@ void CreateVolumeGroupDialog::setupDialog()
}
for (const Device *d : qAsConst(m_Devices)) {
for (const Partition *p : qAsConst(d->partitionTable()->children())) {
// Looking if there is another VG creation that contains this partition
if (LvmDevice::s_DirtyPVs.contains(p))
continue;
if (d->partitionTable() != nullptr) {
for (const Partition *p : qAsConst(d->partitionTable()->children())) {
// Looking if there is another VG creation that contains this partition
if (LvmDevice::s_DirtyPVs.contains(p))
continue;
// Including new LVM PVs (that are currently in OperationStack and that aren't at other VG creation)
if (p->state() == Partition::State::New) {
if (p->fileSystem().type() == FileSystem::Type::Lvm2_PV)
dialogWidget().listPV().addPartition(*p, false);
else if (p->fileSystem().type() == FileSystem::Type::Luks || p->fileSystem().type() == FileSystem::Type::Luks2) {
FileSystem *fs = static_cast<const FS::luks *>(&p->fileSystem())->innerFS();
if (fs->type() == FileSystem::Type::Lvm2_PV)
// Including new LVM PVs (that are currently in OperationStack and that aren't at other VG creation)
if (p->state() == Partition::State::New) {
if (p->fileSystem().type() == FileSystem::Type::Lvm2_PV)
dialogWidget().listPV().addPartition(*p, false);
else if (p->fileSystem().type() == FileSystem::Type::Luks || p->fileSystem().type() == FileSystem::Type::Luks2) {
FileSystem *fs = static_cast<const FS::luks *>(&p->fileSystem())->innerFS();
if (fs->type() == FileSystem::Type::Lvm2_PV)
dialogWidget().listPV().addPartition(*p, false);
}
}
}
}
}
for (const Partition *p : qAsConst(LvmDevice::s_OrphanPVs))
if (!LvmDevice::s_DirtyPVs.contains(p))
dialogWidget().listPV().addPartition(*p, false);
}
void CreateVolumeGroupDialog::setupConnections()

View File

@ -77,25 +77,31 @@ void ResizeVolumeGroupDialog::setupDialog()
dialogWidget().listPV().addPartition(*p.partition(), false);
}
for (const Device *d : qAsConst(m_Devices)) {
for (const Partition *p : qAsConst(d->partitionTable()->children())) {
// Looking if there is another VG creation that contains this partition
if (LvmDevice::s_DirtyPVs.contains(p))
continue;
for (const Device *d : qAsConst(m_Devices)) {
if (d->partitionTable() != nullptr) {
for (const Partition *p : qAsConst(d->partitionTable()->children())) {
// Looking if there is another VG creation that contains this partition
if (LvmDevice::s_DirtyPVs.contains(p))
continue;
// Including new LVM PVs (that are currently in OperationStack and that aren't at other VG creation)
if (p->state() == Partition::State::New) {
if (p->fileSystem().type() == FileSystem::Type::Lvm2_PV)
dialogWidget().listPV().addPartition(*p, false);
else if (p->fileSystem().type() == FileSystem::Type::Luks || p->fileSystem().type() == FileSystem::Type::Luks2) {
FileSystem *fs = static_cast<const FS::luks *>(&p->fileSystem())->innerFS();
// Including new LVM PVs (that are currently in OperationStack and that aren't at other VG creation)
if (p->state() == Partition::State::New) {
if (p->fileSystem().type() == FileSystem::Type::Lvm2_PV)
dialogWidget().listPV().addPartition(*p, false);
else if (p->fileSystem().type() == FileSystem::Type::Luks || p->fileSystem().type() == FileSystem::Type::Luks2) {
FileSystem *fs = static_cast<const FS::luks *>(&p->fileSystem())->innerFS();
if (fs->type() == FileSystem::Type::Lvm2_PV)
dialogWidget().listPV().addPartition(*p, false);
if (fs->type() == FileSystem::Type::Lvm2_PV)
dialogWidget().listPV().addPartition(*p, false);
}
}
}
}
}
}
for (const Partition *p : qAsConst(LvmDevice::s_OrphanPVs))
if (!LvmDevice::s_DirtyPVs.contains(p))
dialogWidget().listPV().addPartition(*p, false);
}
//update used size and LV infos