Skip to content

Commit

Permalink
Enable Kubevirt on ppc64le
Browse files Browse the repository at this point in the history
Enable Kubevirt on ppc64le arch.

Fixes:  kubevirt#2144

Signed-off-by: Nitesh Konkar [email protected]
  • Loading branch information
nitkon committed May 8, 2019
1 parent 4f68cb3 commit f1b9452
Show file tree
Hide file tree
Showing 17 changed files with 109 additions and 78 deletions.
14 changes: 6 additions & 8 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,13 @@ genrule(
name = "libvirt-shared-libs",
srcs = ["@libvirt_libs//file"],
outs = [
"libvirt.so.0.5000.0",
"libvirt-lxc.so.0.5000.0",
"libvirt-qemu.so.0.5000.0",
"libvirt.so.0.5001.0",
"libvirt-lxc.so.0.5001.0",
"libvirt-qemu.so.0.5001.0",
],
cmd = "\n".join([
"rpm2archive $(location @libvirt_libs//file)",
"tar -xzf $(location @libvirt_libs//file).tgz",
"cp -R usr/lib64/*.so.0.5000.0 $(@D)",
"rpm2cpio $(location @libvirt_libs//file) | cpio -idmv",
"cp -R usr/lib64/*.so.0.5001.0 $(@D)",
]),
)

Expand Down Expand Up @@ -107,8 +106,7 @@ genrule(
"libvirt/virterror.h",
],
cmd = "\n".join([
"rpm2archive $(location @libvirt_devel//file)",
"tar -xzf $(location @libvirt_devel//file).tgz",
"rpm2cpio $(location @libvirt_devel//file) | cpio -idmv",
"cp -R usr/include/libvirt $(@D)",
]),
)
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ bazel-generate:
SYNC_VENDOR=true hack/dockerized "./hack/bazel-generate.sh"

bazel-build:
hack/dockerized "hack/bazel-fmt.sh && hack/bazel-build.sh"
hack/dockerized "bazel build \
--platforms=@io_bazel_rules_go//go/toolchain:linux_ppc64le \
--workspace_status_command=./hack/print-workspace-status.sh \
//cmd/..."

bazel-build-images:
hack/dockerized "DOCKER_PREFIX=${DOCKER_PREFIX} DOCKER_TAG=${DOCKER_TAG} DOCKER_TAG_ALT=${DOCKER_TAG_ALT} ./hack/bazel-build-images.sh"
Expand Down
52 changes: 26 additions & 26 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -47,34 +47,34 @@ http_archive(
# Libvirt dependencies
http_file(
name = "libvirt_libs",
sha256 = "95d317fd645fb52745d642578263a9bcb0d796beadf00aeadebc0d692f5529ba",
sha256 = "0152d484d71abc50759775329fc9ee699fecfb9ff67154d6c6a5d91090f791a7",
urls = [
"https://libvirt.org/sources/libvirt-libs-5.0.0-1.fc28.x86_64.rpm",
"https://rpmfind.net/linux/fedora-secondary/development/rawhide/Everything/ppc64le/os/Packages/l/libvirt-libs-5.1.0-3.fc31.ppc64le.rpm",
],
)

http_file(
name = "libvirt_devel",
sha256 = "6573a047d777ed00f6858c2e75c780053b1f898ae1c3f7415e991c94c5ccdd70",
sha256 = "dfb3f3108300cc9e62da822b3073639d9712110880e3025f99fc231874433147",
urls = [
"https://libvirt.org/sources/libvirt-devel-5.0.0-1.fc28.x86_64.rpm",
"https://rpmfind.net/linux/fedora-secondary/development/rawhide/Everything/ppc64le/os/Packages/l/libvirt-devel-5.1.0-3.fc31.ppc64le.rpm",
],
)

# Disk images
http_file(
name = "alpine_image",
sha256 = "5a4b2588afd32e7024dd61d9558b77b03a4f3189cb4c9fc05e9e944fb780acdd",
sha256 = "d87d89958991d03ce158119ffa359ee0d9d0024dd46df7010c8c633a24f47be3",
urls = [
"http://dl-cdn.alpinelinux.org/alpine/v3.7/releases/x86_64/alpine-virt-3.7.0-x86_64.iso",
"http://dl-cdn.alpinelinux.org/alpine/v3.9/releases/ppc64le/alpine-standard-3.9.2-ppc64le.iso",
],
)

http_file(
name = "cirros_image",
sha256 = "a8dd75ecffd4cdd96072d60c2237b448e0c8b2bc94d57f10fdbc8c481d9005b8",
sha256 = "175063e409f4019acb760478eb1a94819628a1bec9376d26d3aa333449fe061d",
urls = [
"https://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img",
"https://download.cirros-cloud.net/0.4.0/cirros-0.4.0-ppc64le-disk.img",
],
)

Expand Down Expand Up @@ -145,18 +145,18 @@ container_repositories()
# Pull base image fedora28
container_pull(
name = "fedora",
digest = "sha256:57d86e03971841e79585379f8346289ceb5a3e8ee06933fbd5064b4f004659d1",
digest = "sha256:9b468a0c123715d5e1025876ee05aa5f2053aed4f9142937709b0145f7cd48cf",
registry = "index.docker.io",
repository = "library/fedora",
#tag = "28",
repository = "ppc64le/fedora",
# tag = "28",
)

# Pull base image libvirt
container_pull(
name = "libvirt",
digest = "sha256:081f113a73748775e5f37d8fb877a574f595df1551e39e48ebbe8e8afd501d3b",
digest = "sha256:a815b109a2942796dad95ca846ea019a7879c7607e529a546537d3985273ac7c",
registry = "index.docker.io",
repository = "kubevirt/libvirt",
repository = "niteshkonkar/libvirt",
#tag = "5.0.0",
)

Expand All @@ -165,7 +165,7 @@ container_pull(
name = "kubevirt-testing",
digest = "sha256:eb86f7388217bb18611c8c4e6169af3463c2a18f420314eb4d742b3d3669b16f",
registry = "index.docker.io",
repository = "kubevirtci/kubevirt-testing",
repository = "niteshkonkar/kubevirt-testing",
#tag = "28",
)

Expand All @@ -186,49 +186,49 @@ http_archive(
# Get container-disk-v1alpha RPM's
http_file(
name = "qemu-img",
sha256 = "611d6ff8e08eca0d543486f3e8b437f7ddbc362e4d281c7422677d712d017d61",
sha256 = "1e4c0171edb631d07f2e45af734d378ea7fe8f70c2a646d9bdb9c8c39696f4f2",
urls = [
"https://dl.fedoraproject.org/pub/fedora/linux/updates/28/Everything/x86_64/Packages/q/qemu-img-2.11.2-4.fc28.x86_64.rpm",
"https://rpmfind.net/linux/fedora-secondary/releases/28/Everything/ppc64le/os/Packages/q/qemu-img-2.11.1-2.fc28.ppc64le.rpm",
],
)

http_file(
name = "bzip2",
sha256 = "5248b7b85e58319c6c16e9b545dc04f1b25ba236e0507a7c923d74b00fe8741c",
sha256 = "e593e694a232829765969e7270cc355d2353436cd2f950029cfa4c0549125f7f",
urls = [
"https://dl.fedoraproject.org/pub/fedora/linux/releases/28/Everything/x86_64/os/Packages/b/bzip2-1.0.6-26.fc28.x86_64.rpm",
"https://rpmfind.net/linux/fedora-secondary/releases/28/Everything/ppc64le/os/Packages/b/bzip2-1.0.6-26.fc28.ppc64le.rpm",
],
)

http_file(
name = "capstone",
sha256 = "847ebb3a852f82cfe932230d1700cb8b90f602acbe9f9dcf5de7129a1d222c6b",
sha256 = "ed0a40f96a28330b39f33965f7945de7373c08806998a2a827eb5def95448d2f",
urls = [
"https://dl.fedoraproject.org/pub/fedora/linux/updates/28/Everything/x86_64/Packages/c/capstone-3.0.5-1.fc28.x86_64.rpm",
"https://rpmfind.net/linux/fedora-secondary/releases/28/Everything/ppc64le/os/Packages/c/capstone-3.0.4-14.fc28.ppc64le.rpm",
],
)

http_file(
name = "libaio",
sha256 = "da731218ec1a8e8f690c880d7a45d09722ea01090caba0ae25d9202e0d521404",
sha256 = "2bad2d833f2a572c41dc5e71f03029f697e42a05bf729d9957479e9bd9ee3342",
urls = [
"https://dl.fedoraproject.org/pub/fedora/linux/releases/28/Everything/x86_64/os/Packages/l/libaio-0.3.110-11.fc28.x86_64.rpm",
"https://rpmfind.net/linux/fedora-secondary/releases/28/Everything/ppc64le/os/Packages/l/libaio-0.3.110-11.fc28.ppc64le.rpm",
],
)

http_file(
name = "libstdc",
sha256 = "61743bc70033f02604fc18991f2a06efebd3b0f55abcbf5b1f7bd3e3cdca6293",
sha256 = "c7d739bf5e9ebe45aed803d3f39d01372f1c61e535cfe3adaf5fa28de9ec4992",
urls = [
"https://dl.fedoraproject.org/pub/fedora/linux/updates/28/Everything/x86_64/Packages/l/libstdc++-8.3.1-2.fc28.x86_64.rpm",
"https://rpmfind.net/linux/fedora-secondary/releases/28/Everything/ppc64le/os/Packages/l/libstdc++-8.0.1-0.20.fc28.ppc64le.rpm",
],
)

http_file(
name = "qemu-guest-agent",
sha256 = "1d76ae3e482017439412e9cc8e179afb8f47ab415a8a9a7ceaa9b4ee4f9c85e8",
sha256 = "7f9607d5eb5ff43877520fcb0fe0b7a385fb6b9e1ee3ebc2d7d9d07170f310b2",
urls = [
"https://dl.fedoraproject.org/pub/fedora/linux/updates/28/Everything/x86_64/Packages/q/qemu-guest-agent-2.11.2-4.fc28.x86_64.rpm",
"https://rpmfind.net/linux/fedora-secondary/releases/28/Everything/ppc64le/os/Packages/q/qemu-guest-agent-2.11.1-2.fc28.ppc64le.rpm",
],
)

Expand Down
6 changes: 3 additions & 3 deletions cluster/examples/vmi-ephemeral.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ spec:
- disk:
bus: virtio
name: containerdisk
machine:
type: ""
machine:
type: "pseries-3.1"
resources:
requests:
memory: 64M
terminationGracePeriodSeconds: 0
volumes:
- containerDisk:
image: registry:5000/kubevirt/cirros-container-disk-demo:devel
image: niteshkonkar/cirros-container-disk-demo:devel
name: containerdisk
12 changes: 10 additions & 2 deletions hack/bazel-build-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,17 @@ set -e
source hack/common.sh
source hack/config.sh

for tag in ${docker_tag} ${docker_tag_alt}; do
bazel build \
--sandbox_debug \
--platforms=@io_bazel_rules_go//go/toolchain:linux_ppc64le \
--workspace_status_command=./hack/print-workspace-status.sh \
--define container_prefix=${docker_prefix} \
--define container_tag=${docker_tag} \
//:build-images

if [ -n "$docker_tag_alt" ]; then
bazel build \
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 \
--platforms=@io_bazel_rules_go//go/toolchain:linux_ppc64le \
--workspace_status_command=./hack/print-workspace-status.sh \
--define container_prefix=${docker_prefix} \
--define container_tag=${tag} \
Expand Down
8 changes: 4 additions & 4 deletions hack/bazel-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ source hack/config.sh
rm -rf ${CMD_OUT_DIR}
mkdir -p ${CMD_OUT_DIR}/virtctl

# Build all binaries for amd64
# Build all binaries for ppc64le
bazel build \
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 \
--platforms=@io_bazel_rules_go//go/toolchain:linux_ppc64le \
--workspace_status_command=./hack/print-workspace-status.sh \
//cmd/...

Expand All @@ -40,9 +40,9 @@ bazel run \

# linux
bazel run \
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 \
--platforms=@io_bazel_rules_go//go/toolchain:linux_ppc64le \
--workspace_status_command=./hack/print-workspace-status.sh \
:build-virtctl -- ${CMD_OUT_DIR}/virtctl/virtctl-${KUBEVIRT_VERSION}-linux-amd64
:build-virtctl -- ${CMD_OUT_DIR}/virtctl/virtctl-${KUBEVIRT_VERSION}-linux-ppc64le

# darwin
bazel run \
Expand Down
6 changes: 3 additions & 3 deletions hack/bazel-fmt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ source hack/common.sh

shfmt -i 4 -w ${KUBEVIRT_DIR}/cluster/ ${KUBEVIRT_DIR}/hack/ ${KUBEVIRT_DIR}/images/
bazel run \
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 \
--platforms=@io_bazel_rules_go//go/toolchain:linux_ppc64le \
--workspace_status_command=./hack/print-workspace-status.sh \
//:gazelle -- pkg/ tools/ tests/ cmd/
bazel run \
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 \
--platforms=@io_bazel_rules_go//go/toolchain:linux_ppc64le \
--workspace_status_command=./hack/print-workspace-status.sh \
//:goimports
# allign BAZEL files to a single format
bazel run \
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 \
--platforms=@io_bazel_rules_go//go/toolchain:linux_ppc64le \
--workspace_status_command=./hack/print-workspace-status.sh \
//:buildifier
8 changes: 4 additions & 4 deletions hack/bazel-generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ rm -f vendor/github.com/libvirt/libvirt-go/BUILD.bazel

# generate BUILD files
bazel run \
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 \
--platforms=@io_bazel_rules_go//go/toolchain:linux_ppc64le \
--workspace_status_command=./hack/print-workspace-status.sh \
//:gazelle

# inject changes to libvirt BUILD file
bazel run \
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 \
--platforms=@io_bazel_rules_go//go/toolchain:linux_ppc64le \
--workspace_status_command=./hack/print-workspace-status.sh \
-- @com_github_bazelbuild_buildtools//buildozer 'add cdeps //:libvirt-libs //:libvirt-headers' //vendor/github.com/libvirt/libvirt-go:go_default_library
bazel run \
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 \
--platforms=@io_bazel_rules_go//go/toolchain:linux_ppc64le \
--workspace_status_command=./hack/print-workspace-status.sh \
-- @com_github_bazelbuild_buildtools//buildozer 'add copts -Ibazel-out/k8-fastbuild/genfiles' //vendor/github.com/libvirt/libvirt-go:go_default_library
# allign BAZEL files to a single format
bazel run \
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 \
--platforms=@io_bazel_rules_go//go/toolchain:linux_ppc64le \
--workspace_status_command=./hack/print-workspace-status.sh \
//:buildifier
11 changes: 9 additions & 2 deletions hack/bazel-push-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,16 @@ set -e
source hack/common.sh
source hack/config.sh

for tag in ${docker_tag} ${docker_tag_alt}; do
bazel run \
--platforms=@io_bazel_rules_go//go/toolchain:linux_ppc64le \
--workspace_status_command=./hack/print-workspace-status.sh \
--define container_prefix=${docker_prefix} \
--define container_tag=${docker_tag} \
//:push-images

if [ -n "$docker_tag_alt" ]; then
bazel run \
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 \
--platforms=@io_bazel_rules_go//go/toolchain:linux_ppc64le \
--workspace_status_command=./hack/print-workspace-status.sh \
--define container_prefix=${docker_prefix} \
--define container_tag=${tag} \
Expand Down
2 changes: 1 addition & 1 deletion hack/build-go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ for arg in $args; do

# always build and link the linux/amd64 binary
LINUX_NAME=${ARCH_BASENAME}-linux-amd64
GOOS=linux GOARCH=amd64 go build -i -o ${CMD_OUT_DIR}/${BIN_NAME}/${LINUX_NAME} -ldflags "$(kubevirt::version::ldflags)" $(pkg_dir linux amd64)
GOOS=linux GOARCH=ppc64le go build -i -o ${CMD_OUT_DIR}/${BIN_NAME}/${LINUX_NAME} -ldflags "$(kubevirt::version::ldflags)" $(pkg_dir linux amd64)
(cd ${CMD_OUT_DIR}/${BIN_NAME} && ln -sf ${LINUX_NAME} ${BIN_NAME})

kubevirt::version::get_version_vars
Expand Down
31 changes: 27 additions & 4 deletions hack/builder/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,36 @@
FROM fedora:28
FROM ppc64le/fedora:28

ENV LIBVIRT_VERSION 5.1.0
#ENV LIBVIRT_VERSION 5.0.0

# Install packages

RUN dnf -y install \
java-1.8.0-openjdk \
java-1.8.0-openjdk-devel \
python \
zip \
unzip \
zlib-devel \
wget \
gcc \
gcc-c++ \
glibc-devel && \
dnf -y clean all

#RUN mkdir -p /home/baz && \
# cd /home/baz && \
# wget https://github.com/bazelbuild/bazel/releases/download/0.23.0/bazel-0.23.0-dist.zip && \
# unzip -qq bazel-0.23.0-dist.zip

#RUN cd /home/baz && env EXTRA_BAZEL_ARGS="--host_javabase=@local_jdk//:jdk" bash ./compile.sh
#RUN mv /home/baz/output/bazel /usr/local/bin/bazel
COPY bazel /usr/local/bin/bazel

RUN dnf install -y dnf-plugins-core && \
dnf copr enable -y @virtmaint-sig/virt-preview && \
dnf copr enable -y vbatts/bazel && \
dnf -y install \
libvirt-devel-${LIBVIRT_VERSION} \
bazel \
libvirt-devel \
cpio \
patch \
make \
Expand All @@ -29,6 +51,7 @@ RUN dnf install -y dnf-plugins-core && \
jq && \
dnf -y clean all


ENV GIMME_GO_VERSION=1.11.5

RUN mkdir -p /gimme && curl -sL https://raw.githubusercontent.com/travis-ci/gimme/master/gimme | HOME=/gimme bash >> /etc/profile.d/gimme.sh
Expand Down
4 changes: 3 additions & 1 deletion hack/kubevirt-builder/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM kubevirt/builder@sha256:08b4db91e5f6272004892c6174129172c1bef5c6906bde9f8414cb945a588e12
#FROM kubevirt/builder@sha256:cd662847df816a0c5cf1a99dcb905301d305befe93d50bee8d00fdd5c74beb19
FROM kubevirt/builder:28-5.0.0

ENV GIMME_GO_VERSION=1.11.5
ENV GOPATH="/go" GOBIN="/usr/bin"
Expand All @@ -18,3 +19,4 @@ RUN pip install j2cli && pip3 install operator-courier==1.3.0
COPY rsyncd.conf /etc/rsyncd.conf

ENTRYPOINT [ "/entrypoint.sh" ]
RUN mkdir -p /home/nitesh
2 changes: 1 addition & 1 deletion pkg/virt-config/virt-properties.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
func SupportedEmulatedMachines() []string {
config := os.Getenv(emulatedMachinesEnvVar)
if len(config) == 0 {
return []string{"q35*", "pc-q35*"}
return []string{"q35*", "pc-q35*", "pseries*"}
}

vals := strings.Split(config, ",")
Expand Down
Loading

0 comments on commit f1b9452

Please sign in to comment.