Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/dev_module_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ jobs:
find . \
-path ./images/cdi-cloner/cloner-startup -prune -o \
-path ./images/dvcr-artifact -prune -o \
-path ./images/virtualization-dra -prune -o \
-path ./test/performance/shatal -prune -o \
-type f -name '.golangci.yaml' -printf '%h\0' | \
xargs -0 -n1 | sort -u
Expand Down Expand Up @@ -279,6 +280,33 @@ jobs:
exit 1
fi

lint_go-virtualization-dra:
runs-on: ubuntu-22.04
name: Run go linter virtualization-dra
steps:
- name: Set up Go 1.25
uses: actions/setup-go@v5
with:
go-version: "1.25"

- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}

- name: Install golangci-lint
run: |
echo "Installing golangci-lint..."
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.8.0
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
echo "golangci-lint v2.8.0 installed successfully!"

- name: Lint virtualization-dra directory with golangci-lint
shell: bash
working-directory: ./images/virtualization-dra
run: |
set -e
golangci-lint run

lint_yaml:
runs-on: ubuntu-latest
name: Run yaml linter
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/translate-changelog.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2026 Flant JSC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Translate Changelog and Create PR

on:
Expand Down
18 changes: 9 additions & 9 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -283,19 +283,19 @@ tasks:
kubectl -n d8-virtualization port-forward deploy/virt-api 2345:2345
EOF

dlv:virtualization-dra-plugin:build:
desc: "Build image virtualization-dra-plugin with dlv"
dlv:virtualization-dra-usb:build:
desc: "Build image virtualization-dra-usb with dlv"
cmds:
- docker build --build-arg BRANCH=$BRANCH -f ./images/virtualization-dra-plugin/debug/dlv.Dockerfile -t "{{ .DLV_IMAGE }}" --platform linux/amd64 .
- docker build --build-arg BRANCH=$BRANCH -f ./images/virtualization-dra-usb/debug/dlv.Dockerfile -t "{{ .DLV_IMAGE }}" --platform linux/amd64 .

dlv:virtualization-dra-plugin:build-push:
desc: "Build and Push image virtualization-dra-plugin with dlv"
dlv:virtualization-dra-usb:build-push:
desc: "Build and Push image virtualization-dra-usb with dlv"
cmds:
- task: dlv:virtualization-dra-plugin:build
- task: dlv:virtualization-dra-usb:build
- docker push "{{ .DLV_IMAGE }}"
- task: dlv:virtualization-dra-plugin:print
- task: dlv:virtualization-dra-usb:print

dlv:virtualization-dra-plugin:print:
dlv:virtualization-dra-usb:print:
desc: "Print commands for debug"
env:
IMAGE: "{{ .DLV_IMAGE }}"
Expand All @@ -314,5 +314,5 @@ tasks:
}
}
}'
kubectl -n d8-virtualization port-forward deploy/virtualization-dra 2345:2345
kubectl -n d8-virtualization port-forward pod/<virtualization-dra-pod> 2345:2345
EOF
4 changes: 2 additions & 2 deletions images/hooks/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ require (
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.33.3 // indirect
k8s.io/apiextensions-apiserver v0.34.2 // indirect
k8s.io/apiserver v0.33.3 // indirect
k8s.io/client-go v0.34.2 // indirect
k8s.io/component-base v0.33.3 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b // indirect
kubevirt.io/api v1.6.2 // indirect
kubevirt.io/containerized-data-importer-api v1.60.3 // indirect
kubevirt.io/containerized-data-importer-api v1.63.1 // indirect
kubevirt.io/controller-lifecycle-operator-sdk/api v0.0.0-20220329064328-f3cc58c6ed90 // indirect
sigs.k8s.io/controller-runtime v0.21.0 // indirect
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
Expand Down
7 changes: 4 additions & 3 deletions images/hooks/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,9 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/sylabs/oci-tools v0.7.0 h1:SIisUvcEL+Vpa9/kmQDy1W3AwV2XVGad83sgZmXLlb0=
github.com/sylabs/oci-tools v0.7.0/go.mod h1:Ry6ngChflh20WPq6mLvCKSw2OTd9iDB5aR8OQzeq4hM=
github.com/sylabs/sif/v2 v2.15.0 h1:Nv0tzksFnoQiQ2eUwpAis9nVqEu4c3RcNSxX8P3Cecw=
Expand Down Expand Up @@ -658,8 +659,8 @@ k8s.io/utils v0.0.0-20240711033017-18e509b52bc8/go.mod h1:OLgZIPagt7ERELqWJFomSt
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
k8s.io/utils v0.0.0-20250604170112-4c0f3b243397 h1:hwvWFiBzdWw1FhfY1FooPn3kzWuJ8tmbZBHi4zVsl1Y=
k8s.io/utils v0.0.0-20250604170112-4c0f3b243397/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
kubevirt.io/containerized-data-importer-api v1.60.3 h1:kQEXi7scpzUa0RPf3/3MKk1Kmem0ZlqqiuK3kDF5L2I=
kubevirt.io/containerized-data-importer-api v1.60.3/go.mod h1:8mwrkZIdy8j/LmCyKt2wFXbiMavLUIqDaegaIF67CZs=
kubevirt.io/containerized-data-importer-api v1.63.1 h1:g2I9za0QEscRsQjOOK/MM0feywp1x9Gl8IyT6Egtg0g=
kubevirt.io/containerized-data-importer-api v1.63.1/go.mod h1:VGp35wxpLXU18b7cnEpmcThI3AjcZUSfg/Zfql44U4o=
kubevirt.io/controller-lifecycle-operator-sdk/api v0.0.0-20220329064328-f3cc58c6ed90 h1:QMrd0nKP0BGbnxTqakhDZAUhGKxPiPiN5gSDqKUmGGc=
kubevirt.io/controller-lifecycle-operator-sdk/api v0.0.0-20220329064328-f3cc58c6ed90/go.mod h1:018lASpFYBsYN6XwmA2TIrPCx6e0gviTd/ZNtSitKgc=
sigs.k8s.io/controller-runtime v0.21.0 h1:CYfjpEuicjUecRk+KAeyYh+ouUBn4llGyDYytIGcJS8=
Expand Down
12 changes: 12 additions & 0 deletions images/usb-modules/Makefile.standalone
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# SPDX-License-Identifier: GPL-2.0
# Out-of-tree build: no kernel .config needed.
# Use: make -C /lib/modules/$(uname -r)/build M=$(pwd) modules

obj-m += usbip-core.o
usbip-core-y := usbip_common.o usbip_event.o

obj-m += vhci-hcd.o
vhci-hcd-y := vhci_sysfs.o vhci_tx.o vhci_rx.o vhci_hcd.o

obj-m += usbip-host.o
usbip-host-y := stub_dev.o stub_main.o stub_rx.o stub_tx.o
75 changes: 75 additions & 0 deletions images/usb-modules/build-usbip-modules.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/usr/bin/env bash

# Copyright 2026 Flant JSC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Build usbip-core, usbip-host, vhci-hcd for the running kernel and put .ko into a tmp dir.
# Needs: kernel headers (e.g. linux-headers-$(uname -r)), make, gcc. No full kernel source.
#
# Usage:
# ./build-usbip-modules.sh [OUTPUT_DIR]
# OUTPUT_DIR defaults to /tmp/usbip-modules-$(uname -r)
# USBIP_SRC defaults to the directory where this script lives (driver source).
#
# Env:
# KVER - kernel version to build for (default: uname -r)
# USBIP_SRC - path to driver source (must contain .c and Makefile.standalone)
# OUTPUT_DIR - output directory (overrides optional argument)
#
# Minimal deps: bash, make, gcc, kernel headers package (e.g. linux-headers-${KVER}).

set -e

KVER="${KVER:-$(uname -r)}"
for base in /lib/modules /usr/lib/modules; do
[[ -d "${base}/${KVER}/build" || -L "${base}/${KVER}/build" ]] || continue
KBUILD="${base}/${KVER}/build"
break
done
KBUILD="${KBUILD:-/lib/modules/${KVER}/build}"
USBIP_SRC="${USBIP_SRC:-$(cd "$(dirname "$0")" && pwd)}"
OUTPUT_DIR="${OUTPUT_DIR:-${1:-/tmp/usbip-modules-${KVER}}}"

if [[ ! -d "$KBUILD" && ! -L "$KBUILD" ]]; then
echo "build-usbip-modules: kernel build dir not found for ${KVER}" >&2
echo "Install kernel headers (kernel-devel or linux-headers-${KVER}) on the host." >&2
exit 1
fi

# Resolve symlink so make sees the real path (must be visible in container)
if [[ -L "$KBUILD" ]]; then
KBUILD=$(readlink -f "$KBUILD")
fi
if [[ ! -d "$KBUILD" ]]; then
echo "build-usbip-modules: build is a symlink but its target is not visible in the container." >&2
echo " resolved path: $KBUILD" >&2
echo "Mount the kernel build tree from the host, e.g.:" >&2
echo " -v /usr/src/kernels:/usr/src/kernels:ro" >&2
exit 1
fi

if [[ ! -f "$USBIP_SRC/Makefile.standalone" ]]; then
echo "build-usbip-modules: $USBIP_SRC/Makefile.standalone not found" >&2
exit 1
fi

# Use standalone Makefile so we don't depend on kernel .config
cp -f "$USBIP_SRC/Makefile.standalone" "$USBIP_SRC/Makefile"

make -C "$KBUILD" M="$USBIP_SRC" CC="${CC:-gcc}" modules

mkdir -p "$OUTPUT_DIR"
cp -f "$USBIP_SRC"/usbip-core.ko "$USBIP_SRC"/usbip-host.ko "$USBIP_SRC"/vhci-hcd.ko "$OUTPUT_DIR/"

echo "Built for ${KVER}; modules in: ${OUTPUT_DIR}"
ls -la "$OUTPUT_DIR"/*.ko
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--- a/drivers/usb/usbip/usbip_common.h
+++ b/drivers/usb/usbip/usbip_common.h
@@ -20,6 +20,7 @@
#include <linux/wait.h>
#include <linux/sched/task.h>
#include <linux/kcov.h>
#include <uapi/linux/usbip.h>
+#include "usbip_compat.h"

#undef pr_fmt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/drivers/usb/usbip/vhci.h
+++ b/drivers/usb/usbip/vhci.h
@@ -76,7 +76,7 @@
#ifdef CONFIG_USBIP_VHCI_HC_PORTS
#define VHCI_HC_PORTS CONFIG_USBIP_VHCI_HC_PORTS
#else
-#define VHCI_HC_PORTS 8
+#define VHCI_HC_PORTS 32
#endif

/* Each VHCI has 2 hubs (USB2 and USB3), each has VHCI_HC_PORTS ports */
30 changes: 30 additions & 0 deletions images/usb-modules/patches/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Patches

This directory contains patches used to build the following out-of-tree kernel modules:

- `usbip-core`
- `usbip-host`
- `vhci-hcd`

---

## 001-usbip-add-compat-header-include.patch

Adds a compatibility header `usbip_compat.h` to ensure successful builds across different Linux kernel versions.

Some kernels may not provide the following helpers:

- `kmalloc_obj`
- `kmalloc_objs`
- `kzalloc_obj`
- `kzalloc_objs`

This patch provides fallback macro definitions based on `kmalloc` and `kzalloc`, improving portability and compatibility with older or differently configured kernel headers.

---

## 002-vhci-increase-default-ports-to-32.patch

Increases the default number of ports for the `vhci-hcd` virtual USB controller to **32**.

This allows more USB devices to be attached simultaneously via USB/IP
28 changes: 28 additions & 0 deletions images/usb-modules/usbip_compat.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Out-of-tree compat: kmalloc_obj() may be missing in older or
* differently configured kernel headers.
*/
#ifndef __USBIP_COMPAT_H
#define __USBIP_COMPAT_H

#include <linux/slab.h>

#ifndef kmalloc_obj
#define kmalloc_obj(type, flags) kmalloc(sizeof(type), flags)
#endif

#ifndef kmalloc_objs
#define kmalloc_objs(type, count) kmalloc((count) * sizeof(type), GFP_KERNEL)
#endif

#ifndef kzalloc_obj
/* One arg: kzalloc_obj(type); two args: kzalloc_obj(type, flags) */
#define kzalloc_obj(type, ...) kzalloc(sizeof(type), (0, ##__VA_ARGS__, GFP_KERNEL))
#endif

#ifndef kzalloc_objs
#define kzalloc_objs(type, count) kzalloc((count) * sizeof(type), GFP_KERNEL)
#endif

#endif /* __USBIP_COMPAT_H */
45 changes: 45 additions & 0 deletions images/usb-modules/werf.inc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
{{- $linuxTag := "v6.8" }}
{{- $linuxRepo := "https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git" }}

image: {{ .ModuleNamePrefix }}{{ .ImageName }}
# Need GCC 14+ for -fmin-function-alignment (used by Fedora kernel build)
fromImage: {{ "builder/debian-trixie-slim" }}
git:
- add: {{ .ModuleDir }}/images/{{ .ImageName }}
to: /src/images/usb-modules
stageDependencies:
setup:
- "**/usbip_compat.h"
- "**/Makefile.standalone"
- "**/build-usbip-modules.sh"
- "**/patches/*"
shell:
install:
- |
apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
git \
make \
gcc \
libc-dev \
libelf-dev \
&& rm -rf /var/lib/apt/lists/*

- |
git clone --depth 1 --filter=blob:none --sparse --branch {{ $linuxTag }} {{ $linuxRepo }} /src/linux \
&& cd /src/linux \
&& git sparse-checkout set drivers/usb/usbip

setup:
- cd /src/linux/drivers/usb/usbip
- cp /src/images/usb-modules/Makefile.standalone ./
- cp /src/images/usb-modules/build-usbip-modules.sh ./
- cp /src/images/usb-modules/usbip_compat.h ./
- chmod +x build-usbip-modules.sh

imageSpec:
config:
user: 64535
workingDir: "/src/linux/drivers/usb/usbip"
entrypoint: ["./build-usbip-modules.sh", "/out"]
1 change: 1 addition & 0 deletions images/virt-artifact/werf.inc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
image: {{ .ModuleNamePrefix }}{{ .ImageName }}-src-artifact
final: false
fromImage: builder/src
fromCacheVersion: "hotplug-42" # TODO: remove this
secrets:
- id: SOURCE_REPO
value: {{ $.SOURCE_REPO }}
Expand Down
4 changes: 2 additions & 2 deletions images/virt-controller/debug/dlv.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ RUN go install github.com/go-delve/delve/cmd/dlv@latest

ARG BRANCH="v1.6.2-virtualization"
ENV VERSION="1.6.2"
ENV GOVERSION="1.23.0"
ENV GOVERSION="1.24.0"

# Copy the git commits for rebuilding the image if the branch changes
ADD "https://api.github.com/repos/deckhouse/3p-kubevirt/commits/$BRANCH" /.git-commit-hash.tmp
Expand All @@ -26,7 +26,7 @@ ENV GOOS=linux
ENV CGO_ENABLED=0
ENV GOARCH=amd64

RUN go build -o /kubevirt-binaries/virt-controller ./cmd/virt-controller/
RUN go build -gcflags="all=-N -l" -o /kubevirt-binaries/virt-controller ./cmd/virt-controller/

FROM busybox

Expand Down
Loading
Loading