Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update bindings to libvirt 8 #212

Merged
merged 7 commits into from
Feb 29, 2024

Conversation

mpontillo
Copy link
Contributor

@mpontillo mpontillo commented Feb 27, 2024

Now that our upstream changes have landed in c-for-go, go-libvirt's libvirt bindings can be updated to support libvirt v8.0.0.

Note that we are roughly following the Ubuntu LTS release cycle with regard to the libvirt version supported; I plan to update to test with v10.0.0 next.

Te current c-for-go project needs enhancement in order to accomodate
generating bindings from the latest libvirt source.

This situation can be addressed by using a private fork (at least, until
any required changes can be merged upstream). This commit streamlines
the build process for c-for-go to allow building a private version to
the bin/ directory. This allows go-libvirt to operate without
contaminating the GOPATH with a different version.
This is useful in case it is desirable to validate the output generated
by c-for-go.

Use .gitignore file instead to ensure it does not get committed.
Copy link
Member

@trapgate trapgate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the gen-consts script can be simplified somewhat, and install-c-for-go.sh can then be dropped.

Here's my suggested version of gen-consts.sh:

#!/bin/bash
#
# This runs the first code generator used by go-libvirt: c-for-go. This script
# is run from the 'go generate ./...' command, and only needs to be run when
# changing to a different version of libvirt.

# Set TOP to the root of this repo, and SCRIPTS to the absolute path to the 
# scripts/ directory.
TOP="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
SCRIPTS="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

if [ -z "${LIBVIRT_SOURCE}" ]; then
    echo "Set LIBVIRT_SOURCE to the root of the libvirt sources you want to use first."
    exit 1
fi
if [ -z "$GOBIN" ]; then
    export GOBIN=$TOP/bin
fi

# Make sure c-for-go is installed
echo "Attempting to install c-for-go..."
if ! go install github.com/xlab/[email protected] ; then
    echo "failed to install c-for-go."
    exit 1
fi

# Make sure goyacc is installed (needed for the lvgen/ generator)
echo "Attempting to install goyacc..."
if ! go install golang.org/x/tools/cmd/[email protected]; then
    echo "failed to install goyacc. Please install it manually from https://golang.org/x/tools/cmd/goyacc"
    exit 1
fi

# Ensure fresh output is in libvirt/
rm -rf libvirt/

# Temporarily symlink the libvirt sources to a subdirectory because c-for-go
# lacks a mechanism for us to pass it a search path for header files.
LVDIR=lv_source
ln -sF ${LIBVIRT_SOURCE} ${LVDIR}
if ! c-for-go -nostamp -nocgo -ccincl libvirt.yml; then
    echo "c-for-go failed"
    exit 1
fi
mv libvirt/const.go ${SCRIPTS}/../const.gen.go
rm ${LVDIR}

@trapgate
Copy link
Member

You can drop the install-c-for-go.sh script now, I think.

* add GOBIN to the PATH to ensure the expected tools are used
* remove obsolete scripts/install-c-for-go.sh
* selectively remove unused generated files
* fix shellcheck warnings
@trapgate trapgate merged commit 83343b9 into digitalocean:master Feb 29, 2024
3 checks passed
@mpontillo mpontillo deleted the libvirt-8-updates branch February 29, 2024 22:44
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.

3 participants