Skip to content

fix(hypervisors): fix SupportsSharedfs for CloudHypervisor and add unit tests - #1045

Draft
Norway-02 wants to merge 1 commit into
urunc-dev:mainfrom
Norway-02:fix/cloud-hypervisor-virtiofs
Draft

fix(hypervisors): fix SupportsSharedfs for CloudHypervisor and add unit tests#1045
Norway-02 wants to merge 1 commit into
urunc-dev:mainfrom
Norway-02:fix/cloud-hypervisor-virtiofs

Conversation

@Norway-02

Copy link
Copy Markdown

Sure — here is the entire GitHub PR description in one copy-paste box:

## Description

`CloudHypervisor.SupportsSharedfs()` incorrectly rejected `virtiofs` as a supported shared filesystem type.

The existing implementation only checked for `"virtio"`:

```go
// SupportsSharedfs returns true as Cloud Hypervisor supports virtiofs
func (ch *CloudHypervisor) SupportsSharedfs(fsType string) bool {
	switch fsType {
	case "virtio":
		return true
	default:
		return false
	}
}

However, throughout urunc, the shared filesystem type may be specified as either "virtio" or "virtiofs" (for example, in BuildExecCmd, shared_fs.go, and OCI annotations).

As a result:

ch.SupportsSharedfs("virtiofs")

incorrectly returned false, causing valid virtiofs shared filesystem configurations to be rejected.

Changes

This PR:

  • Updates SupportsSharedfs to support both "virtio" and "virtiofs".

  • Adds cloud_hypervisor_test.go with unit tests covering:

    • SupportsSharedfs

    • BuildExecCmd

      • memory
      • CPUs
      • seccomp
      • network
      • block devices
      • initrd
      • virtiofs
      • vsock
    • UsesKVM

    • Path

    • Ok

    • PreExec

Updated Implementation

// SupportsSharedfs returns true as Cloud Hypervisor supports virtiofs
func (ch *CloudHypervisor) SupportsSharedfs(fsType string) bool {
	switch fsType {
	case "virtio", "virtiofs":
		return true
	default:
		return false
	}
}

Testing

Unit Tests

Ran:

go test -v -cover ./pkg/unikontainers/hypervisors/...

All tests in pkg/unikontainers/hypervisors passed successfully, including:

  • TestCloudHypervisorSupportsSharedfs
  • TestCloudHypervisorBuildExecCmd

The test suite completed with 100% success.

Formatting

gofmt -s -w pkg/unikontainers/hypervisors/*.go

Static Analysis

go vet ./pkg/unikontainers/hypervisors/...

go vet completed successfully.

Related Issues

Fixes #NONE

LLM Usage

None.

Checklist

  • I have read the contribution guide.
  • The linter passes locally (make lint).
  • The e2e tests of at least one tool pass locally (make test_ctr, make test_nerdctl, make test_docker, or make test_crictl).
  • If LLMs were used: I have read the LLM policy.

Release Note

fix(hypervisors): fix SupportsSharedfs for CloudHypervisor to handle virtiofs parameter and add unit tests

…it tests

Signed-off-by: Norway-02 <anshulkhetade02@gmail.com>
@netlify

netlify Bot commented Sep 12, 2026

Copy link
Copy Markdown

Deploy Preview for urunc canceled.

Name Link
🔨 Latest commit 0047521
🔍 Latest deploy log https://app.netlify.com/projects/urunc/deploys/6aa57c953d9e950008fbcd1a

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.

1 participant