Skip to content

Conversation

@BigVan
Copy link
Member

@BigVan BigVan commented Dec 11, 2025

What this PR does / why we need it:

Add online snapshot functionality to overlaybd.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

Please check the following list:

  • Does the affected code have corresponding tests, e.g. unit test, E2E test?
  • Does this change require a documentation update?
  • Does this introduce breaking changes that would require an announcement or bumping the major version?
  • Do all new files have an appropriate license header?

This commit introduces a live snapshot feature for overlaybd with the following
key capabilities:

- Add HTTP API server (/snapshot endpoint) for creating snapshots on demand
- Implement create_snapshot() to dynamically restack RW layers
- Add device ID tracking system for image file management
- Support config_path;dev_id format in configuration strings
- Extend LSMT layer management with restack(), index manipulation, and file operations
- Add comprehensive tests for restacking, device registration, and snapshot creation

Co-authored-by: Xun Chen <[email protected]>
Co-authored-by: Yifan Yuan <[email protected]>

Signed-off-by: Yifan Yuan <[email protected]>
Add documentation for the live snapshot feature including:
- serviceConfig configuration options
- Device ID format and usage
- HTTP API endpoint (/snapshot)
- New config format requirements
- Usage examples and notes

Signed-off-by: Yifan Yuan <[email protected]>
@BigVan
Copy link
Member Author

BigVan commented Feb 10, 2026

@WaberZhuang @liulanzheng PTAL

photon::net::http::Response& resp,
std::string_view) override;
void parse_params(std::string_view query);
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's not necessary to expose ApiHandler in the header file. It's okay to just pass ImageService* to ApiServer.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you suggesting that I should define ApiHandler in the cpp file instead of the header, and then instantiate it inside the ApiServer constructor?

auto pos = target.find('?');
if (pos != std::string_view::npos) {
query = target.substr(pos + 1);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use req.query() instead.

}

auto upper = new_cfg.upper();
auto lowers = new_cfg.lowers();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lowers is unused

((LSMT::IFileRO *)m_lower_file)->index(combo_index->backing_index());
// set m_file->m_index->m_index0 = upper_file->m_index
auto upper_file_index = (LSMT::IMemoryIndex0 *)((LSMT::IFileRW *)upper_file)->index(); // upper_file->m_index
combo_index->front_index(upper_file_index);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we overwrite the config file in use at this time? Otherwise, the old files will be used again after the process restarts.

virtual int front_index(const IMemoryIndex0 *fi) override {
if (!fi) {
errno = EINVAL;
LOG_ERROR("Invalid index!");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOG_ERROR_RETURN

}
if (m_ownership && m_index0 != nullptr) { // !!!
delete m_index0;
m_index0 = nullptr;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

safe_delete

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants