Files
ubicloud/rhizome/host/lib/vhost_block_backend.rb
Hadi Moshayedi 805cc9bfee Rhizome: Support Ubiblk v0.1‑7
Ubiblk v0.1‑7 upgrades its dependencies to the most recent versions,
which consequently fixes a startup race condition.

The observable symptom of the race condition was that CH sometimes
failed to boot with Ubiblk disks. The sequence was:

1. CH sent `VHOST_USER_SET_VRING_ENABLE` to enable the vring, but didn’t
require an acknowledgement that it had been processed by Ubiblk.
2. The first IO request was placed into the vring, and the kick EventFd
was signalled to notify Ubiblk that there was IO to process.

The `vhost` crate used by Ubiblk ignores notifications before the vring
is enabled, so sometimes step 2 occurred before the enable message was
processed, causing Ubiblk to miss the IO request.

In vhost 0.14.0, the crate was updated to set the `REPLY_ACK` protocol
feature. When Ubiblk advertises this feature to CH, CH will wait for the
acknowledgement in step 1 before proceeding, eliminating the race
condition.
2025-07-10 09:36:44 -07:00

48 lines
1.1 KiB
Ruby

# frozen_string_literal: true
require "fileutils"
require_relative "../../common/lib/arch"
class VhostBlockBackend
def initialize(version)
@version = version
end
def sha256
if @version == "v0.1-7" && Arch.x64?
"114119bc78609db3795bcd426a386eb97a623ba78e9177de6b375b9616927ca6"
elsif @version == "v0.1-7" && Arch.arm64?
"aa92b91130de6e086332c4ad8dcb76e233624055532d5494db0a987883adee0f"
else
fail "Unsupported version: #{@version}, #{Arch.sym}"
end
end
def url
"https://github.com/ubicloud/ubiblk/releases/download/#{@version}/vhost-backend-#{Arch.sym}.tar.gz"
end
def dir
"/opt/vhost-block-backend/#{@version}"
end
def bin_path
"#{dir}/vhost-backend"
end
def init_metadata_path
"#{dir}/init-metadata"
end
def download
temp_tarball = "/tmp/vhost-backend-#{@version}.tar.gz"
puts "Downloading ubiblk package from #{url}"
r "curl -L3 --connect-timeout 5 --max-time 30 -o #{temp_tarball} #{url}"
FileUtils.mkdir_p(dir)
FileUtils.cd dir do
r "tar -xzf #{temp_tarball}"
end
FileUtils.rm_f temp_tarball
end
end