Add functionality to specify PE size when creating VG group.

This commit is contained in:
Chantara Tith 2016-07-18 07:06:56 +07:00
parent 10696c87a7
commit 7642a516c5
6 changed files with 18 additions and 10 deletions

View File

@ -354,11 +354,12 @@ bool LvmDevice::movePV(Report& report, LvmDevice& dev, const QString& pvPath, co
return (cmd.run(-1) && cmd.exitCode() == 0);
}
bool LvmDevice::createVG(Report& report, const QString vgname, const QStringList pvlist)
bool LvmDevice::createVG(Report& report, const QString vgname, const QStringList pvlist, const qint32 peSize)
{
//TODO: check that all the pv in pvlist is lvm2_pv
QStringList args = QStringList();
args << QStringLiteral("vgcreate") << vgname;
args << QStringLiteral("vgcreate") << QStringLiteral("--physicalextentsize") << QString::number(peSize);
args << vgname;
foreach (QString pvnode, pvlist) {
args << pvnode.trimmed();
}

View File

@ -73,7 +73,7 @@ public:
static bool movePV(Report& report, LvmDevice& dev, const QString& pvPath, const QStringList& destinations = QStringList());
static bool removeVG(Report& report, LvmDevice& dev);
static bool createVG(Report& report, const QString vgname, const QStringList pvlist);
static bool createVG(Report& report, const QString vgname, const QStringList pvlist, const qint32 peSize = 4); // peSize in megabytes
protected:
void initPartitions();

View File

@ -27,10 +27,11 @@
@param vgname
@parem pvList
*/
CreateVolumeGroupJob::CreateVolumeGroupJob(const QString& vgname, const QStringList& pvlist) :
CreateVolumeGroupJob::CreateVolumeGroupJob(const QString& vgname, const QStringList& pvlist, const qint32 pesize) :
Job(),
m_vgName(vgname),
m_pvList(pvlist)
m_pvList(pvlist),
m_PESize(pesize)
{
}
@ -40,7 +41,7 @@ bool CreateVolumeGroupJob::run(Report& parent)
Report* report = jobStarted(parent);
rval = LvmDevice::createVG(*report, vgName(), pvList());
rval = LvmDevice::createVG(*report, vgName(), pvList(), peSize());
jobFinished(*report, rval);

View File

@ -30,7 +30,7 @@ class QString;
class CreateVolumeGroupJob : public Job
{
public:
CreateVolumeGroupJob(const QString& vgname, const QStringList& pvlist);
CreateVolumeGroupJob(const QString& vgname, const QStringList& pvlist, const qint32 pesize);
public:
bool run(Report& parent) override;
@ -50,9 +50,14 @@ protected:
return m_pvList;
}
qint32 peSize() {
return m_PESize;
}
private:
QString m_vgName;
QStringList m_pvList;
qint32 m_PESize;
};
#endif

View File

@ -30,9 +30,9 @@
@param d the Device to create the new PartitionTable on
@param t the type for the new PartitionTable
*/
CreateVolumeGroupOperation::CreateVolumeGroupOperation(const QString& vgname, const QStringList& pvlist) :
CreateVolumeGroupOperation::CreateVolumeGroupOperation(const QString& vgname, const QStringList& pvlist, const qint32 pesize) :
Operation(),
m_CreateVolumeGroupJob(new CreateVolumeGroupJob(vgname, pvlist))
m_CreateVolumeGroupJob(new CreateVolumeGroupJob(vgname, pvlist, pesize))
{
addJob(createVolumeGroupJob());
}
@ -44,6 +44,7 @@ QString CreateVolumeGroupOperation::description() const
bool CreateVolumeGroupOperation::targets(const Partition& part) const
{
Q_UNUSED(part)
return false;
}

View File

@ -37,7 +37,7 @@ class LIBKPMCORE_EXPORT CreateVolumeGroupOperation : public Operation
friend class OperationStack;
public:
CreateVolumeGroupOperation(const QString& vgname, const QStringList& pvlist);
CreateVolumeGroupOperation(const QString& vgname, const QStringList& pvlist, const qint32 pesize = 4);
public:
QString iconName() const override {