More conversion from QStringList to QList<const Partition*>.
This commit is contained in:
parent
c41b008dc1
commit
28478ee0ad
|
@ -29,8 +29,8 @@
|
||||||
#include "fs/lvm2_pv.h"
|
#include "fs/lvm2_pv.h"
|
||||||
|
|
||||||
#include "util/externalcommand.h"
|
#include "util/externalcommand.h"
|
||||||
|
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
/** Constructs a DeviceScanner
|
/** Constructs a DeviceScanner
|
||||||
@param ostack the OperationStack where the devices will be created
|
@param ostack the OperationStack where the devices will be created
|
||||||
|
@ -78,5 +78,10 @@ void DeviceScanner::scan()
|
||||||
operationStack().physicalVolumes().append(FS::lvm2_pv::getPVinNode(d->partitionTable()));
|
operationStack().physicalVolumes().append(FS::lvm2_pv::getPVinNode(d->partitionTable()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Store list of physical volumes in LvmDevice
|
||||||
|
for (const auto &d : lvmList)
|
||||||
|
for (const auto &p : operationStack().physicalVolumes())
|
||||||
|
if (p.first == d->name())
|
||||||
|
d->physicalVolumes().append(p.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ LvmDevice::LvmDevice(const QString& vgName, const QString& iconName)
|
||||||
* shared list of PV's paths that will be added to any VGs.
|
* shared list of PV's paths that will be added to any VGs.
|
||||||
* (have been added to an operation, but not yet applied)
|
* (have been added to an operation, but not yet applied)
|
||||||
*/
|
*/
|
||||||
QStringList LvmDevice::s_DirtyPVs;
|
QList<const Partition*> LvmDevice::s_DirtyPVs;
|
||||||
|
|
||||||
LvmDevice::~LvmDevice()
|
LvmDevice::~LvmDevice()
|
||||||
{
|
{
|
||||||
|
@ -409,13 +409,13 @@ bool LvmDevice::movePV(Report& report, const QString& pvPath, const QStringList&
|
||||||
return (cmd.run(-1) && cmd.exitCode() == 0);
|
return (cmd.run(-1) && cmd.exitCode() == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LvmDevice::createVG(Report& report, const QString vgName, const QStringList pvList, const qint32 peSize)
|
bool LvmDevice::createVG(Report& report, const QString vgName, const QList<const Partition*>& pvList, const qint32 peSize)
|
||||||
{
|
{
|
||||||
QStringList args = QStringList();
|
QStringList args = QStringList();
|
||||||
args << QStringLiteral("vgcreate") << QStringLiteral("--physicalextentsize") << QString::number(peSize);
|
args << QStringLiteral("vgcreate") << QStringLiteral("--physicalextentsize") << QString::number(peSize);
|
||||||
args << vgName;
|
args << vgName;
|
||||||
for (const auto &pvNode : pvList)
|
for (const auto &p : pvList)
|
||||||
args << pvNode.trimmed();
|
args << p->partitionPath();
|
||||||
|
|
||||||
ExternalCommand cmd(report, QStringLiteral("lvm"), args);
|
ExternalCommand cmd(report, QStringLiteral("lvm"), args);
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ public:
|
||||||
const QStringList partitionNodes() const override;
|
const QStringList partitionNodes() const override;
|
||||||
qint64 partitionSize(QString& partitionPath) const override;
|
qint64 partitionSize(QString& partitionPath) const override;
|
||||||
|
|
||||||
static QStringList s_DirtyPVs;
|
static QList<const Partition*> s_DirtyPVs;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static QList<LvmDevice*> scanSystemLVM();
|
static QList<LvmDevice*> scanSystemLVM();
|
||||||
|
@ -81,7 +81,7 @@ public:
|
||||||
static bool movePV(Report& report, const QString& pvPath, const QStringList& destinations = QStringList());
|
static bool movePV(Report& report, const QString& pvPath, const QStringList& destinations = QStringList());
|
||||||
|
|
||||||
static bool removeVG(Report& report, LvmDevice& d);
|
static bool removeVG(Report& report, LvmDevice& d);
|
||||||
static bool createVG(Report& report, const QString vgName, const QStringList pvList, const qint32 peSize = 4); // peSize in megabytes
|
static bool createVG(Report& report, const QString vgName, const QList<const Partition*>& pvList, const qint32 peSize = 4); // peSize in megabytes
|
||||||
static bool deactivateVG(Report& report, const LvmDevice& d);
|
static bool deactivateVG(Report& report, const LvmDevice& d);
|
||||||
static bool activateVG(Report& report, const LvmDevice& d);
|
static bool activateVG(Report& report, const LvmDevice& d);
|
||||||
|
|
||||||
|
@ -108,12 +108,13 @@ public:
|
||||||
QString UUID() const {
|
QString UUID() const {
|
||||||
return m_UUID;
|
return m_UUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList* LVPathList() const {
|
QStringList* LVPathList() const {
|
||||||
return m_LVPathList;
|
return m_LVPathList;
|
||||||
}
|
}
|
||||||
|
QList <const Partition*>& physicalVolumes() {
|
||||||
const QList <const Partition*> physicalVolumes() const {
|
return m_PVs;
|
||||||
|
}
|
||||||
|
const QList <const Partition*>& physicalVolumes() const {
|
||||||
return m_PVs;
|
return m_PVs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +131,7 @@ private:
|
||||||
QString m_UUID;
|
QString m_UUID;
|
||||||
|
|
||||||
mutable QStringList* m_LVPathList;
|
mutable QStringList* m_LVPathList;
|
||||||
mutable QList <const Partition*> m_PVs;
|
QList <const Partition*> m_PVs;
|
||||||
mutable QMap<QString, qint64>* m_LVSizeMap;
|
mutable QMap<QString, qint64>* m_LVSizeMap;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
* @param pvList List of LVM Physical Volumes used to create Volume Group
|
* @param pvList List of LVM Physical Volumes used to create Volume Group
|
||||||
* @param peSize LVM Physical Extent size in MiB
|
* @param peSize LVM Physical Extent size in MiB
|
||||||
*/
|
*/
|
||||||
CreateVolumeGroupJob::CreateVolumeGroupJob(const QString& vgName, const QStringList& pvList, const qint32 peSize) :
|
CreateVolumeGroupJob::CreateVolumeGroupJob(const QString& vgName, const QList<const Partition*>& pvList, const qint32 peSize) :
|
||||||
Job(),
|
Job(),
|
||||||
m_vgName(vgName),
|
m_vgName(vgName),
|
||||||
m_pvList(pvList),
|
m_pvList(pvList),
|
||||||
|
@ -52,8 +52,9 @@ bool CreateVolumeGroupJob::run(Report& parent)
|
||||||
QString CreateVolumeGroupJob::description() const
|
QString CreateVolumeGroupJob::description() const
|
||||||
{
|
{
|
||||||
QString tmp = QString();
|
QString tmp = QString();
|
||||||
for (const auto &name : pvList()) {
|
for (const auto &p : pvList()) {
|
||||||
tmp += QStringLiteral("\n") + name;
|
tmp += QStringLiteral(", ") + p->deviceNode();
|
||||||
}
|
}
|
||||||
|
tmp.chop(2);
|
||||||
return xi18nc("@info/plain", "Create a new Volume Group: <filename>%1</filename> with PV: %2", vgName(), tmp);
|
return xi18nc("@info/plain", "Create a new Volume Group: <filename>%1</filename> with PV: %2", vgName(), tmp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,10 +19,11 @@
|
||||||
|
|
||||||
#define CREATEVOLUMEGROUPJOB_H
|
#define CREATEVOLUMEGROUPJOB_H
|
||||||
|
|
||||||
|
#include "core/partition.h"
|
||||||
|
|
||||||
#include "jobs/job.h"
|
#include "jobs/job.h"
|
||||||
|
|
||||||
class LvmDevice;
|
class LvmDevice;
|
||||||
class Partition;
|
|
||||||
class Report;
|
class Report;
|
||||||
|
|
||||||
class QString;
|
class QString;
|
||||||
|
@ -30,7 +31,7 @@ class QString;
|
||||||
class CreateVolumeGroupJob : public Job
|
class CreateVolumeGroupJob : public Job
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CreateVolumeGroupJob(const QString& vgName, const QStringList& pvList, const qint32 peSize);
|
CreateVolumeGroupJob(const QString& vgName, const QList<const Partition*>& pvList, const qint32 peSize);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool run(Report& parent) override;
|
bool run(Report& parent) override;
|
||||||
|
@ -43,10 +44,10 @@ protected:
|
||||||
const QString vgName() const {
|
const QString vgName() const {
|
||||||
return m_vgName;
|
return m_vgName;
|
||||||
}
|
}
|
||||||
QStringList pvList() {
|
QList<const Partition*>& pvList() {
|
||||||
return m_pvList;
|
return m_pvList;
|
||||||
}
|
}
|
||||||
const QStringList pvList() const {
|
const QList<const Partition*>& pvList() const {
|
||||||
return m_pvList;
|
return m_pvList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +57,7 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_vgName;
|
QString m_vgName;
|
||||||
QStringList m_pvList;
|
QList<const Partition*> m_pvList;
|
||||||
qint32 m_PESize;
|
qint32 m_PESize;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
/** Creates a new MovePhysicalVolumeJob
|
/** Creates a new MovePhysicalVolumeJob
|
||||||
* @param d Device representing LVM Volume Group
|
* @param d Device representing LVM Volume Group
|
||||||
*/
|
*/
|
||||||
MovePhysicalVolumeJob::MovePhysicalVolumeJob(LvmDevice& d, const QStringList partList) :
|
MovePhysicalVolumeJob::MovePhysicalVolumeJob(LvmDevice& d, const QList <const Partition*>& partList) :
|
||||||
Job(),
|
Job(),
|
||||||
m_Device(d),
|
m_Device(d),
|
||||||
m_PartList(partList)
|
m_PartList(partList)
|
||||||
|
@ -40,14 +40,14 @@ bool MovePhysicalVolumeJob::run(Report& parent)
|
||||||
Report* report = jobStarted(parent);
|
Report* report = jobStarted(parent);
|
||||||
|
|
||||||
QStringList destinations = device().deviceNodes();
|
QStringList destinations = device().deviceNodes();
|
||||||
for (const auto &partPath : partList()) {
|
for (const auto &p : partList()) {
|
||||||
if (destinations.contains(partPath)) {
|
if (destinations.contains(p->partitionPath())) {
|
||||||
destinations.removeAll(partPath);
|
destinations.removeAll(p->partitionPath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto &partPath : partList()) {
|
for (const auto &p : partList()) {
|
||||||
rval = LvmDevice::movePV(*report, partPath, destinations);
|
rval = LvmDevice::movePV(*report, p->partitionPath(), destinations);
|
||||||
if (rval == false) {
|
if (rval == false) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -60,5 +60,9 @@ bool MovePhysicalVolumeJob::run(Report& parent)
|
||||||
|
|
||||||
QString MovePhysicalVolumeJob::description() const
|
QString MovePhysicalVolumeJob::description() const
|
||||||
{
|
{
|
||||||
return xi18nc("@info/plain", "Move used PE in %1 on %2 to other available Physical Volumes", partList().join(QStringLiteral(", ")), device().name());
|
QString movedPartitions = QString();
|
||||||
|
for (const auto &p : partList())
|
||||||
|
movedPartitions += QStringLiteral(", ") + p->deviceNode();
|
||||||
|
movedPartitions.chop(2);
|
||||||
|
return xi18nc("@info/plain", "Move used PE in %1 on %2 to other available Physical Volumes", movedPartitions, device().name());
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#define MOVEPHYSICALVOLUMEJOB_H
|
#define MOVEPHYSICALVOLUMEJOB_H
|
||||||
|
|
||||||
|
#include "core/partition.h"
|
||||||
#include "jobs/job.h"
|
#include "jobs/job.h"
|
||||||
|
|
||||||
class LvmDevice;
|
class LvmDevice;
|
||||||
|
@ -29,7 +30,7 @@ class QString;
|
||||||
class MovePhysicalVolumeJob : public Job
|
class MovePhysicalVolumeJob : public Job
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MovePhysicalVolumeJob(LvmDevice& dev, const QStringList partlist);
|
MovePhysicalVolumeJob(LvmDevice& dev, const QList <const Partition*>& partlist);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool run(Report& parent) override;
|
bool run(Report& parent) override;
|
||||||
|
@ -43,13 +44,13 @@ protected:
|
||||||
const LvmDevice& device() const {
|
const LvmDevice& device() const {
|
||||||
return m_Device;
|
return m_Device;
|
||||||
}
|
}
|
||||||
const QStringList partList() const {
|
const QList <const Partition*>& partList() const {
|
||||||
return m_PartList;
|
return m_PartList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LvmDevice& m_Device;
|
LvmDevice& m_Device;
|
||||||
const QStringList m_PartList;
|
const QList <const Partition*> m_PartList;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
/** Creates a new ResizeVolumeGroupJob
|
/** Creates a new ResizeVolumeGroupJob
|
||||||
*/
|
*/
|
||||||
ResizeVolumeGroupJob::ResizeVolumeGroupJob(LvmDevice& dev, const QStringList partlist, const Type type) :
|
ResizeVolumeGroupJob::ResizeVolumeGroupJob(LvmDevice& dev, const QList <const Partition*>& partlist, const Type type) :
|
||||||
Job(),
|
Job(),
|
||||||
m_Device(dev),
|
m_Device(dev),
|
||||||
m_PartList(partlist),
|
m_PartList(partlist),
|
||||||
|
@ -39,15 +39,14 @@ bool ResizeVolumeGroupJob::run(Report& parent)
|
||||||
|
|
||||||
Report* report = jobStarted(parent);
|
Report* report = jobStarted(parent);
|
||||||
|
|
||||||
for (const auto &pvpath : partList()) {
|
for (const auto &p : partList()) {
|
||||||
if (type() == ResizeVolumeGroupJob::Grow) {
|
if (type() == ResizeVolumeGroupJob::Grow)
|
||||||
rval = LvmDevice::insertPV(*report, device(), pvpath);
|
rval = LvmDevice::insertPV(*report, device(), p->partitionPath());
|
||||||
} else if (type() == ResizeVolumeGroupJob::Shrink) {
|
else if (type() == ResizeVolumeGroupJob::Shrink)
|
||||||
rval = LvmDevice::removePV(*report, device(), pvpath);
|
rval = LvmDevice::removePV(*report, device(), p->partitionPath());
|
||||||
}
|
|
||||||
if (rval == false) {
|
if (rval == false)
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
jobFinished(*report, rval);
|
jobFinished(*report, rval);
|
||||||
|
@ -57,7 +56,11 @@ bool ResizeVolumeGroupJob::run(Report& parent)
|
||||||
|
|
||||||
QString ResizeVolumeGroupJob::description() const
|
QString ResizeVolumeGroupJob::description() const
|
||||||
{
|
{
|
||||||
const QString partitionList = partList().join(QStringLiteral(", "));
|
QString partitionList = QString();
|
||||||
|
for (const auto &p : partList()) {
|
||||||
|
partitionList += QStringLiteral(", ") + p->deviceNode();
|
||||||
|
}
|
||||||
|
partitionList.chop(2);
|
||||||
const qint32 count = partList().count();
|
const qint32 count = partList().count();
|
||||||
|
|
||||||
if (type() == ResizeVolumeGroupJob::Grow) {
|
if (type() == ResizeVolumeGroupJob::Grow) {
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#define RESIZEVOLUMEGROUPJOB_H
|
#define RESIZEVOLUMEGROUPJOB_H
|
||||||
|
|
||||||
|
#include "core/partition.h"
|
||||||
#include "jobs/job.h"
|
#include "jobs/job.h"
|
||||||
|
|
||||||
class LvmDevice;
|
class LvmDevice;
|
||||||
|
@ -36,7 +37,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ResizeVolumeGroupJob(LvmDevice& dev, const QStringList partlist, const Type type);
|
ResizeVolumeGroupJob(LvmDevice& dev, const QList <const Partition*>& partlist, const Type type);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool run(Report& parent) override;
|
bool run(Report& parent) override;
|
||||||
|
@ -50,7 +51,7 @@ protected:
|
||||||
return m_Device;
|
return m_Device;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QStringList partList() const {
|
const QList <const Partition*>& partList() const {
|
||||||
return m_PartList;
|
return m_PartList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +61,7 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LvmDevice& m_Device;
|
LvmDevice& m_Device;
|
||||||
const QStringList m_PartList;
|
const QList <const Partition*> m_PartList;
|
||||||
ResizeVolumeGroupJob::Type m_Type;
|
ResizeVolumeGroupJob::Type m_Type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
* @param pvList List of LVM Physical Volumes used to create Volume Group
|
* @param pvList List of LVM Physical Volumes used to create Volume Group
|
||||||
* @param peSize LVM Physical Extent size in MiB
|
* @param peSize LVM Physical Extent size in MiB
|
||||||
*/
|
*/
|
||||||
CreateVolumeGroupOperation::CreateVolumeGroupOperation(const QString& vgName, const QStringList& pvList, const qint32 peSize) :
|
CreateVolumeGroupOperation::CreateVolumeGroupOperation(const QString& vgName, const QList<const Partition*>& pvList, const qint32 peSize) :
|
||||||
Operation(),
|
Operation(),
|
||||||
m_CreateVolumeGroupJob(new CreateVolumeGroupJob(vgName, pvList, peSize)),
|
m_CreateVolumeGroupJob(new CreateVolumeGroupJob(vgName, pvList, peSize)),
|
||||||
m_PVList(pvList)
|
m_PVList(pvList)
|
||||||
|
|
|
@ -37,7 +37,7 @@ class LIBKPMCORE_EXPORT CreateVolumeGroupOperation : public Operation
|
||||||
friend class OperationStack;
|
friend class OperationStack;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CreateVolumeGroupOperation(const QString& vgName, const QStringList& pvList, const qint32 peSize = 4);
|
CreateVolumeGroupOperation(const QString& vgName, const QList<const Partition*>& pvList, const qint32 peSize = 4);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString iconName() const override {
|
QString iconName() const override {
|
||||||
|
@ -61,13 +61,13 @@ protected:
|
||||||
return m_CreateVolumeGroupJob;
|
return m_CreateVolumeGroupJob;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QStringList PVList() {
|
const QList<const Partition*>& PVList() {
|
||||||
return m_PVList;
|
return m_PVList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CreateVolumeGroupJob* m_CreateVolumeGroupJob;
|
CreateVolumeGroupJob* m_CreateVolumeGroupJob;
|
||||||
QStringList m_PVList;
|
const QList<const Partition*> m_PVList;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#include "core/lvmdevice.h"
|
#include "core/lvmdevice.h"
|
||||||
#include "fs/lvm2_pv.h"
|
#include "fs/lvm2_pv.h"
|
||||||
|
#include "fs/luks.h"
|
||||||
#include "core/partition.h"
|
#include "core/partition.h"
|
||||||
|
|
||||||
#include "jobs/resizevolumegroupjob.h"
|
#include "jobs/resizevolumegroupjob.h"
|
||||||
|
@ -30,38 +31,55 @@
|
||||||
|
|
||||||
/** Creates a new ResizeVolumeGroupOperation.
|
/** Creates a new ResizeVolumeGroupOperation.
|
||||||
@param d the Device to create the new PartitionTable on
|
@param d the Device to create the new PartitionTable on
|
||||||
@param partlist list of LVM Physical Volumes that should be in LVM Volume Group
|
@param partList list of LVM Physical Volumes that should be in LVM Volume Group
|
||||||
*/
|
*/
|
||||||
ResizeVolumeGroupOperation::ResizeVolumeGroupOperation(LvmDevice& d, const QStringList partlist)
|
ResizeVolumeGroupOperation::ResizeVolumeGroupOperation(LvmDevice& d, const QList<const Partition*>& partList)
|
||||||
: Operation()
|
: Operation()
|
||||||
, m_Device(d)
|
, m_Device(d)
|
||||||
, m_TargetList(partlist)
|
, m_TargetList(partList)
|
||||||
, m_CurrentList(d.deviceNodes())
|
, m_CurrentList(d.physicalVolumes())
|
||||||
|
, m_TargetSize(0)
|
||||||
|
, m_CurrentSize(0)
|
||||||
, m_GrowVolumeGroupJob(nullptr)
|
, m_GrowVolumeGroupJob(nullptr)
|
||||||
, m_ShrinkVolumeGroupJob(nullptr)
|
, m_ShrinkVolumeGroupJob(nullptr)
|
||||||
, m_MovePhysicalVolumeJob(nullptr)
|
, m_MovePhysicalVolumeJob(nullptr)
|
||||||
{
|
{
|
||||||
const QStringList curList = currentList();
|
for (const auto &p : targetList())
|
||||||
m_TargetSize = FS::lvm2_pv::getPVSize(targetList());
|
m_TargetSize += p->capacity();
|
||||||
m_CurrentSize = FS::lvm2_pv::getPVSize(currentList());
|
for (const auto &p : currentList())
|
||||||
|
m_CurrentSize += p->capacity();
|
||||||
|
|
||||||
QStringList toRemoveList = curList;
|
QList<const Partition*> toRemoveList;
|
||||||
for (const QString &path : partlist)
|
for (const auto &p : currentList())
|
||||||
if (toRemoveList.contains(path))
|
if (!targetList().contains(p))
|
||||||
toRemoveList.removeAll(path);
|
toRemoveList.append(p);
|
||||||
|
|
||||||
QStringList toInsertList = partlist;
|
QList<const Partition*> toInsertList;
|
||||||
for (const QString &path : curList)
|
for (const auto &p : targetList())
|
||||||
if (toInsertList.contains(path))
|
if (!currentList().contains(p))
|
||||||
toInsertList.removeAll(path);
|
toInsertList.append(p);
|
||||||
|
|
||||||
qint64 freePE = FS::lvm2_pv::getFreePE(curList) - FS::lvm2_pv::getFreePE(toRemoveList);
|
qint64 currentFreePE = 0;
|
||||||
qint64 movePE = FS::lvm2_pv::getAllocatedPE(toRemoveList);
|
for (const auto &p : currentList())
|
||||||
qint64 growPE = FS::lvm2_pv::getPVSize(toInsertList) / LvmDevice::getPeSize(d.name());
|
currentFreePE += FS::lvm2_pv::getFreePE(p->partitionPath());
|
||||||
|
qint64 removedFreePE = 0;
|
||||||
|
for (const auto &p : toRemoveList) // FIXME: qAsConst
|
||||||
|
removedFreePE += FS::lvm2_pv::getFreePE(p->partitionPath());
|
||||||
|
qint64 freePE = currentFreePE - removedFreePE;
|
||||||
|
qint64 movePE = 0;
|
||||||
|
for (const auto &p : toRemoveList) { // FIXME: qAsConst
|
||||||
|
const FS::lvm2_pv* lvm2PVFs = p->roles().has(PartitionRole::Luks) ?
|
||||||
|
static_cast<const FS::lvm2_pv*>(static_cast<const FS::luks*>(&p->fileSystem())->innerFS()) : // LVM inside LUKS partition
|
||||||
|
static_cast<const FS::lvm2_pv*>(&p->fileSystem()); // simple LVM
|
||||||
|
movePE += lvm2PVFs->allocatedPE();
|
||||||
|
}
|
||||||
|
qint64 growPE = 0;
|
||||||
|
for (const auto &p : toInsertList) // FIXME: qAsConst
|
||||||
|
growPE += FS::lvm2_pv::getPVSize(p->partitionPath()) / LvmDevice::getPeSize(d.name());
|
||||||
|
|
||||||
if ( movePE > (freePE + growPE)) {
|
if ( movePE > (freePE + growPE)) {
|
||||||
// *ABORT* can't move
|
// *ABORT* can't move
|
||||||
} else if (partlist == curList) {
|
} else if (partList == currentList()) {
|
||||||
// *DO NOTHING*
|
// *DO NOTHING*
|
||||||
} else {
|
} else {
|
||||||
if (!toInsertList.isEmpty()) {
|
if (!toInsertList.isEmpty()) {
|
||||||
|
@ -79,8 +97,16 @@ ResizeVolumeGroupOperation::ResizeVolumeGroupOperation(LvmDevice& d, const QStri
|
||||||
|
|
||||||
QString ResizeVolumeGroupOperation::description() const
|
QString ResizeVolumeGroupOperation::description() const
|
||||||
{
|
{
|
||||||
QString tList = targetList().join(QStringLiteral(", "));
|
QString tList = QString();
|
||||||
QString curList = currentList().join(QStringLiteral(", "));
|
for (const auto &p : targetList()) {
|
||||||
|
tList += p->deviceNode() + QStringLiteral(", ");
|
||||||
|
}
|
||||||
|
tList.chop(2);
|
||||||
|
QString curList = QString();
|
||||||
|
for (const auto &p : currentList()) {
|
||||||
|
curList += p->deviceNode() + QStringLiteral(", ");
|
||||||
|
}
|
||||||
|
curList.chop(2);
|
||||||
|
|
||||||
return xi18nc("@info/plain", "Resize volume %1 from %2 to %3", device().name(), curList, tList);
|
return xi18nc("@info/plain", "Resize volume %1 from %2 to %3", device().name(), curList, tList);
|
||||||
}
|
}
|
||||||
|
@ -92,8 +118,8 @@ bool ResizeVolumeGroupOperation::targets(const Device& d) const
|
||||||
|
|
||||||
bool ResizeVolumeGroupOperation::targets(const Partition& p) const
|
bool ResizeVolumeGroupOperation::targets(const Partition& p) const
|
||||||
{
|
{
|
||||||
for (const QString &partPath : targetList()) {
|
for (const auto &partition : targetList()) {
|
||||||
if (partPath == p.partitionPath()) {
|
if (partition->partitionPath() == p.partitionPath()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ class LIBKPMCORE_EXPORT ResizeVolumeGroupOperation : public Operation
|
||||||
friend class OperationStack;
|
friend class OperationStack;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ResizeVolumeGroupOperation(LvmDevice& dev, const QStringList partlist);
|
ResizeVolumeGroupOperation(LvmDevice& dev, const QList<const Partition*>& partlist);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString iconName() const override {
|
QString iconName() const override {
|
||||||
|
@ -64,11 +64,11 @@ protected:
|
||||||
const LvmDevice& device() const {
|
const LvmDevice& device() const {
|
||||||
return m_Device;
|
return m_Device;
|
||||||
}
|
}
|
||||||
const QStringList targetList() const {
|
const QList<const Partition*>& targetList() const {
|
||||||
return m_TargetList;
|
return m_TargetList;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QStringList currentList() const {
|
const QList<const Partition*>& currentList() const {
|
||||||
return m_CurrentList;
|
return m_CurrentList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,8 +95,8 @@ protected:
|
||||||
private:
|
private:
|
||||||
LvmDevice& m_Device;
|
LvmDevice& m_Device;
|
||||||
|
|
||||||
const QStringList m_TargetList;
|
QList<const Partition*> m_TargetList;
|
||||||
const QStringList m_CurrentList;
|
QList<const Partition*> m_CurrentList;
|
||||||
qint64 m_TargetSize;
|
qint64 m_TargetSize;
|
||||||
qint64 m_CurrentSize;
|
qint64 m_CurrentSize;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue