diff --git a/src/core/lvmdevice.cpp b/src/core/lvmdevice.cpp index 9e825f0..26ec0c4 100644 --- a/src/core/lvmdevice.cpp +++ b/src/core/lvmdevice.cpp @@ -333,7 +333,7 @@ bool LvmDevice::insertPV(Report& report, LvmDevice& dev, const QString& pvPath) return (cmd.run(-1) && cmd.exitCode() == 0); } -bool LvmDevice::movePV(Report& report, LvmDevice& dev, const QString& pvPath) +bool LvmDevice::movePV(Report& report, LvmDevice& dev, const QString& pvPath, const QStringList& destinations) { Q_UNUSED(dev); @@ -341,9 +341,16 @@ bool LvmDevice::movePV(Report& report, LvmDevice& dev, const QString& pvPath) return true; } - ExternalCommand cmd(report, QStringLiteral("lvm"), - { QStringLiteral("pvmove"), - pvPath}); + QStringList args = QStringList(); + args << QStringLiteral("pvmove"); + args << pvPath; + if (!destinations.isEmpty()) { + foreach (QString destPath, destinations) { + args << destPath.trimmed(); + } + } + + ExternalCommand cmd(report, QStringLiteral("lvm"), args); return (cmd.run(-1) && cmd.exitCode() == 0); } diff --git a/src/core/lvmdevice.h b/src/core/lvmdevice.h index 41816e9..ce30fee 100644 --- a/src/core/lvmdevice.h +++ b/src/core/lvmdevice.h @@ -70,7 +70,7 @@ public: static bool removePV(Report& report, LvmDevice& dev, const QString& pvPath); static bool insertPV(Report& report, LvmDevice& dev, const QString& pvPath); - static bool movePV(Report& report, LvmDevice& dev, const QString& pvPath); + 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); diff --git a/src/jobs/movephysicalvolumejob.cpp b/src/jobs/movephysicalvolumejob.cpp index 10c635e..6c945f4 100644 --- a/src/jobs/movephysicalvolumejob.cpp +++ b/src/jobs/movephysicalvolumejob.cpp @@ -41,8 +41,16 @@ bool MovePhysicalVolumeJob::run(Report& parent) Report* report = jobStarted(parent); //TODO:check that the provided list is legal + + QStringList destinations = LvmDevice::getPVs(device().name()); foreach (QString partPath, partList()) { - rval = LvmDevice::movePV(*report, device(), partPath); + if (destinations.contains(partPath)) { + destinations.removeAll(partPath); + } + } + + foreach (QString partPath, partList()) { + rval = LvmDevice::movePV(*report, device(), partPath, destinations); if (rval == false) { break; }