Skip to content

Commit

Permalink
[vm image] improve one function parameter name.
Browse files Browse the repository at this point in the history
  • Loading branch information
georgeliao committed May 8, 2024
1 parent 4b99bc9 commit f328b81
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion include/multipass/vm_image_vault.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class VMImageVault : private DisabledCopyMove
virtual void update_images(const FetchType& fetch_type, const PrepareAction& prepare,
const ProgressMonitor& monitor) = 0;
virtual MemorySize minimum_image_size_for(const std::string& id) = 0;
virtual void clone(const std::string& source_instance_name, const std::string& dist_instance_name) = 0;
virtual void clone(const std::string& source_instance_name, const std::string& destination_instance_name) = 0;
virtual VMImageHost* image_host_for(const std::string& remote_name) const = 0;
virtual std::vector<std::pair<std::string, VMImageInfo>> all_info_for(const Query& query) const = 0;

Expand Down
12 changes: 7 additions & 5 deletions src/daemon/default_vm_image_vault.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,8 @@ mp::MemorySize mp::DefaultVMImageVault::minimum_image_size_for(const std::string

throw std::runtime_error(fmt::format("Cannot determine minimum image size for id \'{}\'", id));
}
void mp::DefaultVMImageVault::clone(const std::string& source_instance_name, const std::string& dist_instance_name)
void mp::DefaultVMImageVault::clone(const std::string& source_instance_name,

Check warning on line 585 in src/daemon/default_vm_image_vault.cpp

View check run for this annotation

Codecov / codecov/patch

src/daemon/default_vm_image_vault.cpp#L585

Added line #L585 was not covered by tests
const std::string& destination_instance_name)
{
const auto source_iter = instance_image_records.find(source_instance_name);

Check warning on line 588 in src/daemon/default_vm_image_vault.cpp

View check run for this annotation

Codecov / codecov/patch

src/daemon/default_vm_image_vault.cpp#L588

Added line #L588 was not covered by tests

Expand All @@ -591,13 +592,14 @@ void mp::DefaultVMImageVault::clone(const std::string& source_instance_name, con
throw std::runtime_error(source_instance_name + " does not exist in the image records");

Check warning on line 592 in src/daemon/default_vm_image_vault.cpp

View check run for this annotation

Codecov / codecov/patch

src/daemon/default_vm_image_vault.cpp#L592

Added line #L592 was not covered by tests
}

if (instance_image_records.find(dist_instance_name) != instance_image_records.end())
if (instance_image_records.find(destination_instance_name) != instance_image_records.end())

Check warning on line 595 in src/daemon/default_vm_image_vault.cpp

View check run for this annotation

Codecov / codecov/patch

src/daemon/default_vm_image_vault.cpp#L595

Added line #L595 was not covered by tests
{
throw std::runtime_error(dist_instance_name + " already exists in the image records");
throw std::runtime_error(destination_instance_name + " already exists in the image records");

Check warning on line 597 in src/daemon/default_vm_image_vault.cpp

View check run for this annotation

Codecov / codecov/patch

src/daemon/default_vm_image_vault.cpp#L597

Added line #L597 was not covered by tests
}

auto& dest_vault_record = instance_image_records[dist_instance_name] = instance_image_records[source_instance_name];
dest_vault_record.image.image_path.replace(source_instance_name.c_str(), dist_instance_name.c_str());
auto& dest_vault_record = instance_image_records[destination_instance_name] =
instance_image_records[source_instance_name];
dest_vault_record.image.image_path.replace(source_instance_name.c_str(), destination_instance_name.c_str());

Check warning on line 602 in src/daemon/default_vm_image_vault.cpp

View check run for this annotation

Codecov / codecov/patch

src/daemon/default_vm_image_vault.cpp#L600-L602

Added lines #L600 - L602 were not covered by tests
// change last accessed?
persist_instance_records();

Check warning on line 604 in src/daemon/default_vm_image_vault.cpp

View check run for this annotation

Codecov / codecov/patch

src/daemon/default_vm_image_vault.cpp#L604

Added line #L604 was not covered by tests
}
Expand Down
2 changes: 1 addition & 1 deletion src/daemon/default_vm_image_vault.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class DefaultVMImageVault final : public BaseVMImageVault
void update_images(const FetchType& fetch_type, const PrepareAction& prepare,
const ProgressMonitor& monitor) override;
MemorySize minimum_image_size_for(const std::string& id) override;
void clone(const std::string& source_instance_name, const std::string& dist_instance_name) override;
void clone(const std::string& source_instance_name, const std::string& destination_instance_name) override;

private:
VMImage image_instance_from(const VMImage& prepared_image, const Path& dest_dir);
Expand Down
2 changes: 1 addition & 1 deletion src/platform/backends/lxd/lxd_vm_image_vault.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class LXDVMImageVault final : public BaseVMImageVault
void update_images(const FetchType& fetch_type, const PrepareAction& prepare,
const ProgressMonitor& monitor) override;
MemorySize minimum_image_size_for(const std::string& id) override;
void clone(const std::string& source_instance_name, const std::string& dist_instance_name) override
void clone(const std::string& source_instance_name, const std::string& destination_instance_name) override

Check warning on line 55 in src/platform/backends/lxd/lxd_vm_image_vault.h

View check run for this annotation

Codecov / codecov/patch

src/platform/backends/lxd/lxd_vm_image_vault.h#L55

Added line #L55 was not covered by tests
{
throw std::runtime_error("Clone methond is not supported in LXDVMImageVault yet.");

Check warning on line 57 in src/platform/backends/lxd/lxd_vm_image_vault.h

View check run for this annotation

Codecov / codecov/patch

src/platform/backends/lxd/lxd_vm_image_vault.h#L57

Added line #L57 was not covered by tests
}
Expand Down
2 changes: 1 addition & 1 deletion tests/stub_vm_image_vault.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ struct StubVMImageVault final : public multipass::VMImageVault
return {};
}

void clone(const std::string& source_instance_name, const std::string& dist_instance_name) override
void clone(const std::string& source_instance_name, const std::string& destination_instance_name) override
{
}

Expand Down

0 comments on commit f328b81

Please sign in to comment.