Add libdm and dmctl support for dm-user targets

dm-user is very much a WIP and while this may change (we need to figure out how
to get credentials to the dm-user daemon, for example) it seems like a somewhat
safe bet to assume that the behavior will at least include a start/end range.

Test: I just ran "dmctl create palmer user 0 1024", which created the device.
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
Change-Id: Ic5f84de6a4f09bf906246035d450edd637cc38ed
This commit is contained in:
Palmer Dabbelt 2020-06-22 12:34:45 -07:00 committed by David Anderson
parent 3d246cced8
commit 2def03a2b9
3 changed files with 17 additions and 0 deletions

View file

@ -280,5 +280,12 @@ std::string DmTargetDefaultKey::GetParameterString() const {
return android::base::Join(argv, " ");
}
std::string DmTargetUser::GetParameterString() const {
std::vector<std::string> argv;
argv.push_back(std::to_string(start()));
argv.push_back(std::to_string(size()));
return android::base::Join(argv, " ");
}
} // namespace dm
} // namespace android

View file

@ -309,6 +309,14 @@ class DmTargetDefaultKey final : public DmTarget {
bool is_hw_wrapped_ = false;
};
class DmTargetUser final : public DmTarget {
public:
DmTargetUser(uint64_t start, uint64_t length) : DmTarget(start, length) {}
std::string name() const override { return "user"; }
std::string GetParameterString() const override;
};
} // namespace dm
} // namespace android

View file

@ -174,6 +174,8 @@ class TargetParser final {
}
return std::make_unique<DmTargetSnapshot>(start_sector, num_sectors, base_device,
cow_device, mode, chunk_size);
} else if (target_type == "user") {
return std::make_unique<DmTargetUser>(start_sector, num_sectors);
} else {
std::cerr << "Unrecognized target type: " << target_type << std::endl;
return nullptr;