Commit 7b226865 authored by Nicholas Verne's avatar Nicholas Verne Committed by Commit Bot

crostini_upgrader: Stop the VM before upgrading the container.

This will ensure any processes which are holding dpkg locks
release them. It is still possible that an init process in the
container will grab the locks again before upgrade_container can run, so
this doesn't ensure dpkg locks are always available, but it should fix the
case of processes lingering and failing to release them.

Bug: 1082075
Change-Id: I138d97b3a3f4ae1a1e4ce13232aef39cc75357a7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2217761
Commit-Queue: Nicholas Verne <nverne@chromium.org>
Reviewed-by: default avatarDavid Munro <davidmunro@google.com>
Cr-Commit-Position: refs/heads/master@{#772594}
parent dac2e3b4
......@@ -269,10 +269,29 @@ void CrostiniUpgrader::DoPrechecks() {
void CrostiniUpgrader::Upgrade(const ContainerId& container_id) {
container_id_ = container_id;
CrostiniManager::GetForProfile(profile_)->UpgradeContainer(
container_id_, ContainerVersion::STRETCH, ContainerVersion::BUSTER,
base::BindOnce(&CrostiniUpgrader::OnUpgrade,
weak_ptr_factory_.GetWeakPtr()));
// Shut down the existing VM then upgrade. StopVm doesn't give an error if
// the VM doesn't exist. That's fine.
CrostiniManager::GetForProfile(profile_)->StopVm(
container_id.vm_name,
base::BindOnce(
[](base::WeakPtr<CrostiniUpgrader> weak_this, CrostiniResult result) {
if (!weak_this) {
return;
}
if (result != CrostiniResult::SUCCESS) {
LOG(ERROR) << "Unable to shut down vm before upgrade";
weak_this->OnUpgrade(result);
return;
}
CrostiniManager::GetForProfile(weak_this->profile_)
->UpgradeContainer(
weak_this->container_id_, ContainerVersion::STRETCH,
ContainerVersion::BUSTER,
base::BindOnce(&CrostiniUpgrader::OnUpgrade, weak_this));
},
weak_ptr_factory_.GetWeakPtr()));
}
void CrostiniUpgrader::OnUpgrade(CrostiniResult result) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment