New Upstream Snapshot - vagrant-libvirt
Ready changes
Summary
Merged new upstream version: 0.11.2+git20230207.1.8fa764f (was: 0.11.2).
Diff
diff --git a/.gitattributes b/.gitattributes
deleted file mode 100644
index 9d4f626..0000000
--- a/.gitattributes
+++ /dev/null
@@ -1 +0,0 @@
-lib/vagrant-libvirt/version.rb export-subst
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
deleted file mode 100644
index fe22e6e..0000000
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ /dev/null
@@ -1,62 +0,0 @@
----
-name: Bug report
-about: Create a report to help us improve
-title: ''
-labels: ''
-assignees: ''
-
----
-
-**Describe the bug**
-A clear and concise description of what the bug is.
-
-<!--
-To test if the issue exists in the latest code you can download a pre-built gem of what is on main from the GitHub
-rubygems package [repository](https://github.com/vagrant-libvirt/vagrant-libvirt/packages/1659776) under the
-asserts. Unfortunately it's not yet possible to make the rubygem repositories in GitHub public.
-
-To install provide the file directly to the install command:
-```
-vagrant plugin install ./vagrant-libvirt-<version>.gem
-```
-
-It is possible to install directly from the GitHub rubygems package repository, however this will embedded
-your GitHub token directly into the file `~/.vagrant.d/plugins.json`:
-```
-vagrant plugin install vagrant-libvirt \
- --plugin-source https://${USERNAME}:${GITHUB_TOKEN}@rubygems.pkg.github.com/vagrant-libvirt \
- --plugin-version "0.10.9.pre.62"
-```
-
-Provided this token is a classic token limited to `read:packages` only, this may be acceptable to you.
--->
-
-**To Reproduce**
-Steps to reproduce the behavior:
-1. Go to '...'
-2. Click on '....'
-3. Scroll down to '....'
-4. See error
-
-**Expected behavior**
-A clear and concise description of what you expected to happen.
-
-**Screenshots**
-If applicable, add screenshots to help explain your problem.
-
-**Versions (please complete the following information):**:
-- Libvirt version:
-- Vagrant version [output of `vagrant version`]:
-- Vagrant flavour [Upstream or Distro]:
-- Vagrant plugins versions (including vagrant-libvirt) [output of `vagrant plugin list`]:
-
-**Debug Log**
-Attach Output of `VAGRANT_LOG=debug vagrant ... --provider=libvirt >vagrant.log 2>&1`
-```
-Delete this text and drag and drop the log file for github to attach and add a link here
-```
-
-**A Vagrantfile to reproduce the issue:**
-```
-Insert Vagrantfile inside quotes here (remove sensitive data if needed)
-```
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
deleted file mode 100644
index bbcbbe7..0000000
--- a/.github/ISSUE_TEMPLATE/feature_request.md
+++ /dev/null
@@ -1,20 +0,0 @@
----
-name: Feature request
-about: Suggest an idea for this project
-title: ''
-labels: ''
-assignees: ''
-
----
-
-**Is your feature request related to a problem? Please describe.**
-A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
-
-**Describe the solution you'd like**
-A clear and concise description of what you want to happen.
-
-**Describe alternatives you've considered**
-A clear and concise description of any alternative solutions or features you've considered.
-
-**Additional context**
-Add any other context or screenshots about the feature request here.
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
deleted file mode 100644
index 4d48ceb..0000000
--- a/.github/dependabot.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-version: 2
-updates:
- - package-ecosystem: "bundler"
- directory: "/docs"
- schedule:
- interval: "weekly"
- - package-ecosystem: "github-actions"
- directory: "/"
- schedule:
- interval: "weekly"
diff --git a/.github/workflows/build-gem-package-notify.yml b/.github/workflows/build-gem-package-notify.yml
deleted file mode 100644
index 7fab117..0000000
--- a/.github/workflows/build-gem-package-notify.yml
+++ /dev/null
@@ -1,84 +0,0 @@
-name: add gem artifact links
-on:
- workflow_run:
- workflows: ['publish-gem']
- types:
- - completed
-
-jobs:
- artifacts-url-comments:
- if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
- name: Add artifact links to pull request
- runs-on: ubuntu-22.04
- steps:
- - name: 'Download artifact'
- uses: actions/github-script@v6
- with:
- script: |
- const artifacts = await github.paginate(
- github.rest.actions.listWorkflowRunArtifacts, {
- owner: context.repo.owner,
- repo: context.repo.repo,
- run_id: ${{github.event.workflow_run.id }},
- },
- );
- if (!artifacts.length) {
- return core.error(`No artifacts found`);
- }
- var matchArtifact = artifacts.find((artifact) => {
- return artifact.name == "pr"
- });
- if (matchArtifact === undefined) {
- return core.error(`No PR artifact found`);
- }
- var download = await github.rest.actions.downloadArtifact({
- owner: context.repo.owner,
- repo: context.repo.repo,
- artifact_id: matchArtifact.id,
- archive_format: 'zip',
- });
- var fs = require('fs');
- fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(download.data));
- - run: unzip pr.zip
- - uses: actions/github-script@v6
- with:
- # This snippet is public-domain, taken from
- # https://github.com/oprypin/nightly.link/blob/master/.github/workflows/pr-comment.yml
- script: |
- async function upsertComment(owner, repo, issue_number, purpose, body) {
- const {data: comments} = await github.rest.issues.listComments(
- {owner, repo, issue_number});
- const marker = `<!-- bot: ${purpose} -->`;
- body = marker + "\n" + body;
- const existing = comments.filter((c) => c.body.includes(marker));
- if (existing.length > 0) {
- const last = existing[existing.length - 1];
- core.info(`Updating comment ${last.id}`);
- await github.rest.issues.updateComment({
- owner, repo,
- body,
- comment_id: last.id,
- });
- } else {
- core.info(`Creating a comment in issue / PR #${issue_number}`);
- await github.rest.issues.createComment({issue_number, body, owner, repo});
- }
- }
- const {owner, repo} = context.repo;
- const run_id = ${{github.event.workflow_run.id}};
- const artifacts = await github.paginate(
- github.rest.actions.listWorkflowRunArtifacts, {owner, repo, run_id});
- if (!artifacts.length) {
- return core.error(`No artifacts found`);
- }
- var fs = require('fs');
- var issue_number = Number(fs.readFileSync('./NR'));
- let body = `Download the latest artifacts for this pull request here:\n`;
- for (const art of artifacts) {
- if (art.name == 'pr') {
- continue;
- }
- body += `\n* [${art.name}.zip](https://nightly.link/${owner}/${repo}/actions/artifacts/${art.id}.zip)`;
- }
- core.info("Review thread message body:", body);
- await upsertComment(owner, repo, issue_number, "nightly-link", body);
diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml
deleted file mode 100644
index f1e3b5d..0000000
--- a/.github/workflows/docker-image.yml
+++ /dev/null
@@ -1,184 +0,0 @@
-name: docker-image
-
-on:
- push:
- branches:
- - main
- tags:
- - '*.*.*'
- pull_request_target:
- types:
- - assigned
- - opened
- - synchronize
- - reopened
- # for delete
- - closed
-
-
-permissions:
- packages: write
- pull-requests: write
-
-jobs:
- build-image-with-buildah:
- if: ${{ ! (startsWith(github.event_name, 'pull_request') && github.event.action == 'closed' ) }}
- runs-on: ubuntu-22.04
- steps:
- -
- name: Checkout
- if: ${{ ! startsWith(github.event_name, 'pull_request') }}
- uses: actions/checkout@v3
- with:
- fetch-depth: 0
- -
- if: startsWith(github.event_name, 'pull_request')
- name: Checkout
- uses: actions/checkout@v3
- with:
- fetch-depth: 0
- ref: ${{ github.event.pull_request.head.sha }}
- -
- name: Build with buildah
- run: buildah bud .
-
- generate-docker-metadata:
- uses: vagrant-libvirt/vagrant-libvirt/.github/workflows/docker-meta.yml@main
- secrets: inherit
-
- generate-docker-metadata-slim:
- uses: vagrant-libvirt/vagrant-libvirt/.github/workflows/docker-meta.yml@main
- with:
- flavor: |
- suffix=-slim
- secrets: inherit
-
- build-docker-image:
- if: ${{ ! (startsWith(github.event_name, 'pull_request') && github.event.action == 'closed' ) }}
- runs-on: ubuntu-22.04
- needs:
- - generate-docker-metadata
- - generate-docker-metadata-slim
- steps:
- -
- name: Checkout
- if: ${{ ! startsWith(github.event_name, 'pull_request') }}
- uses: actions/checkout@v3
- with:
- fetch-depth: 0
- -
- if: startsWith(github.event_name, 'pull_request')
- name: Checkout
- uses: actions/checkout@v3
- with:
- fetch-depth: 0
- ref: ${{ github.event.pull_request.head.sha }}
- -
- name: Set up QEMU
- uses: docker/setup-qemu-action@v2
- -
- name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v2
- with:
- driver-opts: image=moby/buildkit:master
- -
- name: Cache Docker layers
- uses: actions/cache@v3
- with:
- path: /tmp/.buildx-cache
- key: ${{ runner.os }}-buildx-${{ github.sha }}
- restore-keys: |
- ${{ runner.os }}-buildx-
- -
- name: Login to GitHub Container Registry
- uses: docker/login-action@v2
- with:
- registry: ghcr.io
- username: ${{ github.repository_owner }}
- password: ${{ secrets.GITHUB_TOKEN }}
- -
- name: Login to DockerHub
- if: ${{ ! startsWith(github.event_name, 'pull_request') }}
- uses: docker/login-action@v2
- with:
- username: ${{ secrets.DOCKERHUB_USERNAME }}
- password: ${{ secrets.DOCKERHUB_TOKEN }}
- -
- name: Build and push main image
- id: docker_build
- uses: docker/build-push-action@v3
- with:
- context: .
- platforms: linux/amd64
- push: true
- tags: ${{ needs.generate-docker-metadata.outputs.tags }}
- target: final
- labels: ${{ needs.generate-docker-metadata.outputs.labels }}
- cache-from: type=local,src=/tmp/.buildx-cache
- cache-to: type=local,dest=/tmp/.buildx-cache,mode=max
- -
- name: Build and push slim image
- id: docker_build_slim
- uses: docker/build-push-action@v3
- with:
- context: .
- platforms: linux/amd64
- push: true
- tags: ${{ needs.generate-docker-metadata-slim.outputs.tags }}
- target: slim
- labels: ${{ needs.generate-docker-metadata-slim.outputs.labels }}
- cache-from: type=local,src=/tmp/.buildx-cache
- cache-to: type=local,dest=/tmp/.buildx-cache,mode=max
- -
- name: Image digest
- run: echo ${{ steps.docker_build.outputs.digest }}
- -
- name: Image digest Slim
- run: echo ${{ steps.docker_build_slim.outputs.digest }}
- -
- name: Comment on label required for docs preview deploy
- if: startsWith(github.event_name, 'pull_request')
- uses: marocchino/sticky-pull-request-comment@v2
- with:
- recreate: true
- header: docker-image-tag
- message: |-
- A docker image containing the code from this plugin to allow testing locally without installing
- can be pulled from: ${{ fromJSON(steps.docker_build_slim.outputs.metadata)['image.name'] }}
-
- If you need the image with the full dev toolchain, you can instead pull: ${{ fromJSON(steps.docker_build.outputs.metadata)['image.name'] }}
-
- generate-delete-docker-images-matrix:
- if: startsWith(github.event_name, 'pull_request') && github.event.action == 'closed'
- runs-on: ubuntu-22.04
- needs:
- - generate-docker-metadata
- - generate-docker-metadata-slim
- outputs:
- matrix: ${{ steps.matrix.outputs.tags }}
- steps:
- -
- name: Generate matrix
- id: matrix
- run: |
- TAGS="$(echo "${{ needs.generate-docker-metadata-slim.outputs.tags }},${{ needs.generate-docker-metadata.outputs.tags }}" | jq --raw-input -c '[split(",") | .[] / ":" |.[1]]')"
-
- echo "tags=${TAGS}" >> ${GITHUB_OUTPUT}
-
-# Currently delete requires a PAT, which is considered unsafe until it is possible to scope them to a specific org.
-# As this appears to be in beta, uncomment the following at some point in the future.
-#
-# delete-docker-images:
-# needs: generate-delete-docker-images-matrix
-# runs-on: ubuntu-22.04
-# strategy:
-# matrix:
-# tag: ${{ fromJSON(needs.generate-delete-docker-images-matrix.outputs.matrix) }}
-# steps:
-# - name: Delete image
-# uses: bots-house/ghcr-delete-image-action@v1.0.0
-# with:
-# owner: ${{ github.repository_owner }}
-# name: ${{ github.event.repository.name }}
-# token: ${{ secrets.GITHUB_TOKEN }}
-# tag: ${{ matrix.tag }}
diff --git a/.github/workflows/docker-meta.yml b/.github/workflows/docker-meta.yml
deleted file mode 100644
index 3ce1fdc..0000000
--- a/.github/workflows/docker-meta.yml
+++ /dev/null
@@ -1,62 +0,0 @@
-name: Docker Metadata
-
-on:
- workflow_call:
- inputs:
- flavor:
- required: false
- type: string
- secrets:
- DOCKERHUB_USERNAME:
- required: false
- DOCKERHUB_ORGANIZATION:
- required: false
- outputs:
- labels:
- value: ${{ jobs.generate-metadata.outputs.labels }}
- tags:
- value: ${{ jobs.generate-metadata.outputs.tags }}
-
-jobs:
- generate-metadata:
- name: Generate Metadata
- runs-on: ubuntu-22.04
- outputs:
- labels: ${{ steps.metadata.outputs.labels }}
- tags: ${{ steps.metadata.outputs.tags }}
- steps:
- -
- name: Generate docker image names for publishing
- id: docker_image_names
- run: |
- # suggestion from https://trstringer.com/github-actions-multiline-strings/ to handle
- # passing multi-line strings to subsequent action
- echo 'IMAGE_NAMES<<EOF' >> ${GITHUB_ENV}
- echo ghcr.io/${{ github.repository_owner }}/vagrant-libvirt >> ${GITHUB_ENV}
- if [[ -n "${{ secrets.DOCKERHUB_USERNAME }}" ]] && [[ ${{ github.event_name }} != pull_request* ]]
- then
- ORG_NAME=$(echo ${{ github.repository_owner }} | tr -d '-')
- echo ${ORG_NAME}/vagrant-libvirt >> ${GITHUB_ENV}
- fi
- echo 'EOF' >> ${GITHUB_ENV}
- -
- name: Setup publish tags and versions for image
- id: metadata
- uses: docker/metadata-action@v4
- with:
- images: |
- ${{ env.IMAGE_NAMES }}
- tags: |
- # nightly
- type=schedule
- # tag events
- type=pep440,pattern={{version}}
- type=pep440,pattern={{major}}
- type=pep440,pattern={{major}}.{{minor}}
- type=pep440,pattern={{version}},value=latest
- # push to master
- type=edge,branch=${{ github.event.repository.default_branch }}
- type=sha,enable={{is_default_branch}}
- # pull requests
- type=ref,event=pr
- flavor: ${{ inputs.flavor }}
diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml
deleted file mode 100644
index 26eb597..0000000
--- a/.github/workflows/integration-tests.yml
+++ /dev/null
@@ -1,140 +0,0 @@
-name: Integration Tests
-
-on:
- push:
- branches:
- - main
- pull_request:
-
-jobs:
- generate-matrix:
- runs-on: ubuntu-latest
- outputs:
- matrix: ${{ steps.generate-matrix.outputs.matrix }}
-
- env:
- NOKOGIRI_USE_SYSTEM_LIBRARIES: true
- VAGRANT_VERSION: v2.2.14
-
- steps:
- - uses: actions/checkout@v3
- with:
- fetch-depth: 0
- - name: Set up libvirt for test generation
- run: |
- sudo apt-get update
- sudo apt-get install -y \
- libvirt-dev \
- libz-dev \
- ;
- - uses: actions/cache@v3
- with:
- path: vendor/bundle
- key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
- restore-keys: |
- ${{ runner.os }}-gems-
- - name: Set up Ruby
- uses: ruby/setup-ruby@v1
- with:
- ruby-version: 2.6.6
- - name: Run bundler using cached path
- run: |
- bundle config path vendor/bundle
- bundle install --jobs 4 --retry 3
- - name: Generate matrix
- id: generate-matrix
- run: |
- bundle exec rspec --color --format json --fail-fast --dry-run --tag acceptance --out report.json
- tests="$(jq -c '[.examples[].full_description]' report.json)"
-
- echo "matrix=${tests}" >> ${GITHUB_OUTPUT}
-
- run-tests:
- needs: generate-matrix
-
- runs-on: ubuntu-22.04
- strategy:
- fail-fast: false
- matrix:
- test_name: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }}
-
- env:
- NOKOGIRI_USE_SYSTEM_LIBRARIES: true
- VAGRANT_VERSION: v2.2.14
-
- steps:
- - uses: actions/checkout@v3
- with:
- fetch-depth: 0
- - name: Set up libvirt
- run: |
- sudo apt-get update
- sudo apt-get install -y \
- bridge-utils \
- dnsmasq-base \
- ebtables \
- libarchive-tools \
- libguestfs-tools \
- libvirt-clients \
- libvirt-daemon \
- libvirt-daemon-system \
- qemu-kvm \
- qemu-utils \
- ;
- sudo apt-get install -y \
- libvirt-dev \
- libz-dev \
- ;
-
- # start daemon
- sudo systemctl start libvirtd
-
- # add user to group
- sudo usermod -a -G libvirt $USER
- - uses: actions/cache@v3
- with:
- path: vendor/bundle
- key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
- restore-keys: |
- ${{ runner.os }}-gems-
- - uses: actions/cache@v3
- with:
- path: ~/.vagrant.d/boxes
- key: ${{ runner.os }}-${{ env.VAGRANT_VERSION }}
- restore-keys: |
- ${{ runner.os }}-
- - name: Set up Ruby
- uses: ruby/setup-ruby@v1
- with:
- ruby-version: 2.6.6
- - name: Run bundler using cached path
- run: |
- bundle config path vendor/bundle
- bundle install --jobs 4 --retry 3
- - name: Run tests
- run: |
- mkdir -p $HOME/.vagrant.d/
- # use software emulation due to lack of nested emulation
- cat <<EOF > $HOME/.vagrant.d/Vagrantfile
- Vagrant.configure("2") do |config|
- config.vm.provider :libvirt do |libvirt|
- libvirt.driver = "qemu"
- end
- end
- EOF
-
- # tell integration tests to use boxes from the cached location
- # and also to load the above Vagrantfile. This is done because
- # sg will not inherit env vars, so it's necessary to set them
- # in a script that sg runs before calling bundle.
- cat <<EOF > script.bash
- #!/bin/bash
- #
- export VAGRANT_LIBVIRT_VAGRANT_HOME=$HOME/.vagrant.d
-
- bundle exec rspec --color --fail-fast --tag acceptance -e '${{ matrix.test_name }}'
- EOF
- chmod a+x script.bash
-
- # run script under libvirt group
- sg libvirt -c ./script.bash
diff --git a/.github/workflows/no-response.yml b/.github/workflows/no-response.yml
deleted file mode 100644
index bc1ede6..0000000
--- a/.github/workflows/no-response.yml
+++ /dev/null
@@ -1,20 +0,0 @@
-name: No Response
-
-# Both `issue_comment` and `scheduled` event types are required for this Action
-# to work properly.
-on:
- issue_comment:
- types: [created]
- schedule:
- # Schedule for five minutes after the hour, every hour
- - cron: '30 0,12 * * *'
-
-jobs:
- noResponse:
- runs-on: ubuntu-latest
- steps:
- - uses: lee-dohm/no-response@v0.5.0
- with:
- token: ${{ github.token }}
- daysUntilClose: 30
- responseRequiredLabel: needinfo
diff --git a/.github/workflows/publish-documentation-preview-notify.yml b/.github/workflows/publish-documentation-preview-notify.yml
deleted file mode 100644
index 242cfc2..0000000
--- a/.github/workflows/publish-documentation-preview-notify.yml
+++ /dev/null
@@ -1,25 +0,0 @@
-name: Deploy Docs Preview Requires Label
-on:
- pull_request_target:
- types:
- - opened
- - reopened
- - synchronize
- paths:
- - 'docs/**'
-
-permissions:
- pull-requests: write
-jobs:
- notify-label-required:
- if: ${{ !contains(github.event.pull_request.labels.*.name, 'preview-docs') }}
- runs-on: ubuntu-latest
- steps:
- - name: Comment on label required for docs preview deploy
- uses: marocchino/sticky-pull-request-comment@v2
- with:
- recreate: true
- header: notify-label-required
- message: |-
- Maintainers: This PR updates the documentation, please review and apply
- the label 'preview-docs' if satisfied it is safe to publish.
diff --git a/.github/workflows/publish-documentation-preview.yml b/.github/workflows/publish-documentation-preview.yml
deleted file mode 100644
index 0277da8..0000000
--- a/.github/workflows/publish-documentation-preview.yml
+++ /dev/null
@@ -1,76 +0,0 @@
-name: Deploy Docs Preview
-on:
- pull_request_target:
- types:
- - closed
- - labeled
- paths:
- - 'docs/**'
-
-permissions:
- contents: write
- pull-requests: write
-jobs:
- build-and-deploy:
- if: ${{ github.event.action == 'closed' || (github.event.action == 'labeled' && github.event.label.name == 'preview-docs') }}
- concurrency: publish-gh-pages
- runs-on: ubuntu-latest
- steps:
- - name: Checkout ποΈ
- uses: actions/checkout@v3
- with:
- ref: ${{ github.event.pull_request.head.sha }}
- - name: Set up Ruby
- if: ${{ github.event.action == 'labeled' }}
- uses: ruby/setup-ruby@v1
- with:
- ruby-version: 2.6
- - name: Install and Build π§
- # don't allow a close to execute anything from the source code
- if: ${{ github.event.action == 'labeled' }}
- run: |
- PR_NUMBER=$(jq -r ".number" "$GITHUB_EVENT_PATH")
- REPO_NAME=$(jq -r ".repository.name" "$GITHUB_EVENT_PATH")
-
- # TODO find a way for jekyll to perform this automatically
- convert docs/_assets/images/logo.png -define icon:auto-resize=256,64,48,32,16 docs/favicon.ico
-
- # avoid look up of API as it doesn't work from within actions without exposing the GITHUB_TOKEN here which is a security risk
- cat <<EOF >> docs/_config.yml
- repository_nwo: vagrant-libvirt/vagrant-libvirt
- plugin_script_base_path: /${REPO_NAME}/pr-preview/pr-${PR_NUMBER}
- EOF
-
- BUNDLE_GEMFILE=./docs/Gemfile bundle install
- BUNDLE_GEMFILE=./docs/Gemfile bundle exec jekyll build --source docs/ --baseurl="/${REPO_NAME}/pr-preview/pr-${PR_NUMBER}" --destination build
- - name: Set action
- run: |
- event_type=$(jq -r ".action" "$GITHUB_EVENT_PATH")
- echo "event_type is $event_type"
-
- case $event_type in
- "labeled")
- echo "action set to deploy"
- echo "action=deploy" >> "$GITHUB_ENV"
- ;;
- "closed")
- echo "action set to remove"
- echo "action=remove" >> "$GITHUB_ENV"
- ;;
- *)
- echo "unknown event type $event_type; no action to take"
- echo "action=none" >> "$GITHUB_ENV"
- ;;
- esac
- - name: Deploy preview
- uses: rossjrw/pr-preview-action@v1
- with:
- action: ${{ env.action }}
- source-dir: ./build/
- preview-branch: gh-pages
- umbrella-dir: pr-preview
- - name: Remove label
- uses: actions-ecosystem/action-remove-labels@v1
- if: ${{ always() }}
- with:
- labels: preview-docs
diff --git a/.github/workflows/publish-documentation-release.yml b/.github/workflows/publish-documentation-release.yml
deleted file mode 100644
index f0e2009..0000000
--- a/.github/workflows/publish-documentation-release.yml
+++ /dev/null
@@ -1,46 +0,0 @@
-name: Deploy Docs Release
-on:
- push:
- tags:
- - '*.*.*'
-
-permissions:
- contents: write
-
-jobs:
- build-and-deploy:
- concurrency: ci-${{ github.ref }}
- runs-on: ubuntu-latest
- steps:
- - name: Checkout ποΈ
- uses: actions/checkout@v3
- - name: Set up Ruby
- uses: ruby/setup-ruby@v1
- with:
- ruby-version: 2.6
- - name: Install and Build π§
- run: |
- VERSION=${{ github.ref_name }}
- REPO_NAME=$(jq -r ".repository.name" "$GITHUB_EVENT_PATH")
-
- # TODO find a way for jekyll to perform this automatically
- convert docs/_assets/images/logo.png -define icon:auto-resize=256,64,48,32,16 docs/favicon.ico
-
- # avoid look up of API as it doesn't work from within actions without exposing the GITHUB_TOKEN here which is a security risk
- cat <<EOF >> docs/_config.yml
- repository_nwo: vagrant-libvirt/vagrant-libvirt
- EOF
-
- BUNDLE_GEMFILE=./docs/Gemfile bundle install
- BUNDLE_GEMFILE=./docs/Gemfile bundle exec jekyll build --source docs/ --baseurl="/${REPO_NAME}/version/${VERSION}" --destination build
- - name: Deploy π
- uses: JamesIves/github-pages-deploy-action@v4.4.1
- with:
- branch: gh-pages
- folder: build
- clean: true
- force: false
- target-folder: version/${{ github.ref_name }}
- clean-exclude: |
- pr-preview/
- version/
diff --git a/.github/workflows/publish-documentation.yml b/.github/workflows/publish-documentation.yml
deleted file mode 100644
index d9c7cbb..0000000
--- a/.github/workflows/publish-documentation.yml
+++ /dev/null
@@ -1,43 +0,0 @@
-name: Deploy Docs
-on:
- push:
- branches:
- - main
- paths:
- - 'docs/**'
-
-permissions:
- contents: write
-
-jobs:
- build-and-deploy:
- concurrency: ci-${{ github.ref }}
- runs-on: ubuntu-latest
- steps:
- - name: Checkout ποΈ
- uses: actions/checkout@v3
- - name: Set up Ruby
- uses: ruby/setup-ruby@v1
- with:
- ruby-version: 2.6
- - name: Install and Build π§
- run: |
- # TODO find a way for jekyll to perform this automatically
- convert docs/_assets/images/logo.png -define icon:auto-resize=256,64,48,32,16 docs/favicon.ico
-
- # avoid look up of API as it doesn't work from within actions without exposing the GITHUB_TOKEN here which is a security risk
- cat <<EOF >> docs/_config.yml
- repository_nwo: vagrant-libvirt/vagrant-libvirt
- EOF
-
- BUNDLE_GEMFILE=./docs/Gemfile bundle install
- BUNDLE_GEMFILE=./docs/Gemfile bundle exec jekyll build --source docs/ --destination build
- - name: Deploy π
- uses: JamesIves/github-pages-deploy-action@v4.4.1
- with:
- branch: gh-pages
- folder: build
- clean: true
- clean-exclude: |
- pr-preview/
- version/
diff --git a/.github/workflows/publish-gem-package.yml b/.github/workflows/publish-gem-package.yml
deleted file mode 100644
index 99a1c1b..0000000
--- a/.github/workflows/publish-gem-package.yml
+++ /dev/null
@@ -1,76 +0,0 @@
-name: publish-gem
-
-on:
- push:
- branches:
- - main
- pull_request:
-
-permissions:
- packages: write
-
-jobs:
- build-package:
- runs-on: ubuntu-22.04
- outputs:
- artifact_name: ${{ steps.artifact_name.outputs.artifact_name }}
- steps:
- - uses: actions/checkout@v3
- with:
- fetch-depth: 0
- - name: Install rake & ruby
- run: |
- sudo apt-get install -y \
- rake \
- ruby \
- ;
- - name: Build gem
- run: |
- rake build
- - name: Generate artifact name
- id: artifact_name
- run: |
- cd pkg/
- GEM_PKG=$(ls -1 *.gem)
- echo "artifact_name=${GEM_PKG}" >> ${GITHUB_OUTPUT}
- - uses: actions/upload-artifact@v3
- with:
- name: ${{ steps.artifact_name.outputs.artifact_name }}
- path: pkg/**.gem
- # workflow_run doesn't receive a list of the pull requests triggering if it's
- # from a fork, so use this to save the PR number for use in the notify job
- - name: Save PR number
- if: github.ref != 'refs/heads/main'
- run: |
- mkdir -p ./pr
- echo ${{ github.event.number }} > ./pr/NR
- - uses: actions/upload-artifact@v2
- if: github.ref != 'refs/heads/main'
- with:
- name: pr
- path: pr/
-
- publish-package:
- needs: build-package
- runs-on: ubuntu-22.04
- if: github.ref == 'refs/heads/main'
- steps:
- - uses: actions/download-artifact@v3
- with:
- name: ${{ needs.build-package.outputs.artifact_name }}
- - name: setup credentials
- run: |
- mkdir ~/.gem
- cat <<EOF > ~/.gem/credentials
- ---
- :github: Bearer ${GITHUB_TOKEN}
- EOF
- chmod 0600 ~/.gem/credentials
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- - name: publish package
- run: |
- gem push --key github \
- --host https://rubygems.pkg.github.com/${GITHUB_REPOSITORY_OWNER} \
- *.gem
-
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
deleted file mode 100644
index 43d408c..0000000
--- a/.github/workflows/release.yml
+++ /dev/null
@@ -1,22 +0,0 @@
-name: release
-
-on:
- push:
- tags:
- - '*.*.*'
-
-jobs:
- publish-release:
- name: Create Release
- runs-on: ubuntu-latest
- steps:
- -
- name: Create Release
- uses: softprops/action-gh-release@v1
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- with:
- name: Release ${{ github.ref_name }}
- target_commitish: ${{ github.event.repository.default_branch }}
- generate_release_notes: true
- tag_name: ${{ github.ref_name }}
diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml
deleted file mode 100644
index 84aca8b..0000000
--- a/.github/workflows/unit-tests.yml
+++ /dev/null
@@ -1,125 +0,0 @@
-# This workflow uses actions that are not certified by GitHub.
-# They are provided by a third-party and are governed by
-# separate terms of service, privacy policy, and support
-# documentation.
-# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
-# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
-
-name: CI
-
-on:
- push:
- branches:
- - main
- pull_request:
-
-jobs:
- test:
-
- runs-on: ubuntu-latest
- env:
- VAGRANT_LIBVIRT_REQUIRE_SIMPLECOV: "true"
- continue-on-error: ${{ matrix.allow_fail }}
- strategy:
- fail-fast: false
- matrix:
- # need to define one entry with a single entry for each of the options
- # to allow include to expand the matrix correctly.
- ruby: [3.1]
- vagrant: [main]
- allow_fail: [true]
- include:
- - ruby: 2.2.10
- vagrant: v2.0.4
- allow_fail: false
- - ruby: 2.3.5
- vagrant: v2.1.5
- allow_fail: false
- - ruby: 2.4.10
- vagrant: v2.2.4
- allow_fail: false
- - ruby: 2.6.6
- vagrant: v2.2.14
- allow_fail: false
- - ruby: 2.7.2
- vagrant: v2.2.10
- allow_fail: false
- # above block is to ensure compatible with Ubuntu 20.04 vagrant package
- # although it uses 2.2.10 it is the earliest version that will install on
- # ruby 2.7 without patching
- - ruby: 3.1
- vagrant:
- allow_fail: false
-
- steps:
- - uses: actions/checkout@v3
- with:
- fetch-depth: 0
- - name: Clone ruby-libvirt for ruby 3.1 support
- if: ${{ startsWith(matrix.ruby, '3.1') }}
- uses: actions/checkout@v3
- with:
- repository: libvirt/libvirt-ruby
- path: .deps/libvirt-ruby
- ref: 43444be184e4d877c5ce110ee5475c952d7590f7
- - name: Set up libvirt
- run: |
- sudo apt-get update
- sudo apt-get install libvirt-dev
- - uses: actions/cache@v3
- with:
- path: vendor/bundle
- key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
- restore-keys: |
- ${{ runner.os }}-gems-
- - name: Set up Ruby
- uses: ruby/setup-ruby@v1
- with:
- ruby-version: ${{ matrix.ruby }}
- - name: Set up rubygems
- run: |
- gem update --system --conservative || (gem i "rubygems-update:~>2.7" --no-document && update_rubygems)
- gem update bundler --conservative
- - name: Ensure bundle uses https instead of insecure git
- run: |
- git config --global url."https://github.com/".insteadOf git://github.com/
- - name: Handle additional ruby 3.1 setup
- if: ${{ startsWith(matrix.ruby, '3.1') }}
- run: |
- # build gem of latest bindings that contain fix for ruby include path
- pushd .deps/libvirt-ruby
- rake gem
- popd
-
- mkdir -p vendor/bundle/ruby/3.0.0/cache/
- cp .deps/libvirt-ruby/pkg/ruby-libvirt-*.gem vendor/bundle/ruby/3.0.0/cache/
- # need the following to allow the local provided gem to be used instead of the
- # one from rubygems
- bundle config set --local disable_checksum_validation true
- - name: Run bundler using cached path
- run: |
- bundle config path vendor/bundle
- bundle install --jobs 4 --retry 3
- env:
- VAGRANT_VERSION: ${{ matrix.vagrant }}
- - name: Run tests
- run: |
- bundle exec rspec --color --format documentation
- env:
- VAGRANT_VERSION: ${{ matrix.vagrant }}
- - name: Coveralls Parallel
- uses: coverallsapp/github-action@master
- with:
- github-token: ${{ secrets.github_token }}
- parallel: true
- path-to-lcov: ./coverage/lcov.info
-
- finish:
- needs: test
- runs-on: ubuntu-latest
- steps:
- - name: Coveralls Finished
- uses: coverallsapp/github-action@master
- with:
- github-token: ${{ secrets.github_token }}
- parallel-finished: true
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index 28a19c4..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,26 +0,0 @@
-*.gem
-*.rbc
-.bundle
-.config
-.yardoc
-Gemfile.lock
-InstalledFiles
-_yardoc
-bin/
-coverage
-doc/
-lib/bundler/man
-pkg
-rdoc
-spec/reports
-test/tmp
-test/version_tmp
-tmp
-/Vagrantfile
-.vagrant
-*.swp
-.deps
-docs/favicon.ico
-
-# don't commit the generated version
-lib/vagrant-libvirt/version
diff --git a/debian/changelog b/debian/changelog
index 3de91b0..13836ed 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+vagrant-libvirt (0.11.2+git20230207.1.8fa764f-1) UNRELEASED; urgency=low
+
+ * New upstream snapshot.
+
+ -- Debian Janitor <janitor@jelmer.uk> Wed, 08 Feb 2023 14:01:09 -0000
+
vagrant-libvirt (0.11.2-1) unstable; urgency=medium
* New upstream version 0.11.2
diff --git a/docs/Gemfile b/docs/Gemfile
index f0c5cf9..b08516b 100644
--- a/docs/Gemfile
+++ b/docs/Gemfile
@@ -7,7 +7,7 @@ source "https://rubygems.org"
#
# This will help ensure the proper Jekyll version is running.
# Happy Jekylling!
-gem "github-pages", "~> 227", group: :jekyll_plugins
+gem "github-pages", "~> 228", group: :jekyll_plugins
# If you want to use GitHub Pages, remove the "gem "jekyll"" above and
# uncomment the line below. To upgrade, run `bundle update github-pages`.
# gem "github-pages", group: :jekyll_plugins
diff --git a/docs/Gemfile.lock b/docs/Gemfile.lock
index 16ce331..33b5d11 100644
--- a/docs/Gemfile.lock
+++ b/docs/Gemfile.lock
@@ -6,40 +6,40 @@ GEM
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
- addressable (2.8.0)
- public_suffix (>= 2.0.2, < 5.0)
+ addressable (2.8.1)
+ public_suffix (>= 2.0.2, < 6.0)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.11.1)
colorator (1.1.0)
- commonmarker (0.23.6)
- concurrent-ruby (1.1.10)
+ commonmarker (0.23.8)
+ concurrent-ruby (1.2.0)
dnsruby (1.61.9)
simpleidn (~> 0.1)
em-websocket (0.5.3)
eventmachine (>= 0.12.9)
http_parser.rb (~> 0)
- ethon (0.15.0)
+ ethon (0.16.0)
ffi (>= 1.15.0)
eventmachine (1.2.7)
execjs (2.8.1)
extras (0.3.0)
forwardable-extended (~> 2.5)
- faraday (2.3.0)
- faraday-net_http (~> 2.0)
+ faraday (2.7.4)
+ faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
- faraday-net_http (2.0.3)
+ faraday-net_http (3.0.2)
fastimage (2.2.6)
ffi (1.15.5)
forwardable-extended (2.6.0)
gemoji (3.0.1)
- github-pages (227)
+ github-pages (228)
github-pages-health-check (= 1.17.9)
- jekyll (= 3.9.2)
+ jekyll (= 3.9.3)
jekyll-avatar (= 0.7.0)
jekyll-coffeescript (= 1.1.1)
- jekyll-commonmark-ghpages (= 0.2.0)
+ jekyll-commonmark-ghpages (= 0.4.0)
jekyll-default-layout (= 0.1.4)
jekyll-feed (= 0.15.1)
jekyll-gist (= 1.5.0)
@@ -73,7 +73,7 @@ GEM
jemoji (= 0.12.0)
kramdown (= 2.3.2)
kramdown-parser-gfm (= 1.1.0)
- liquid (= 4.0.3)
+ liquid (= 4.0.4)
mercenary (~> 0.3)
minima (= 2.5.1)
nokogiri (>= 1.13.6, < 2.0)
@@ -85,17 +85,17 @@ GEM
octokit (~> 4.0)
public_suffix (>= 3.0, < 5.0)
typhoeus (~> 1.3)
- html-pipeline (2.14.2)
+ html-pipeline (2.14.3)
activesupport (>= 2)
nokogiri (>= 1.4)
http_parser.rb (0.8.0)
- i18n (0.9.5)
+ i18n (1.12.0)
concurrent-ruby (~> 1.0)
- jekyll (3.9.2)
+ jekyll (3.9.3)
addressable (~> 2.4)
colorator (~> 1.0)
em-websocket (~> 0.5)
- i18n (~> 0.7)
+ i18n (>= 0.7, < 2)
jekyll-sass-converter (~> 1.0)
jekyll-watch (~> 2.0)
kramdown (>= 1.17, < 3)
@@ -122,11 +122,11 @@ GEM
coffee-script-source (~> 1.11.1)
jekyll-commonmark (1.4.0)
commonmarker (~> 0.22)
- jekyll-commonmark-ghpages (0.2.0)
- commonmarker (~> 0.23.4)
+ jekyll-commonmark-ghpages (0.4.0)
+ commonmarker (~> 0.23.7)
jekyll (~> 3.9.0)
jekyll-commonmark (~> 1.4.0)
- rouge (>= 2.0, < 4.0)
+ rouge (>= 2.0, < 5.0)
jekyll-default-layout (0.1.4)
jekyll (~> 3.0)
jekyll-feed (0.15.1)
@@ -207,9 +207,9 @@ GEM
jekyll-seo-tag (~> 2.0)
jekyll-titles-from-headings (0.5.3)
jekyll (>= 3.3, < 5.0)
- jekyll-toc (0.17.1)
+ jekyll-toc (0.18.0)
jekyll (>= 3.9)
- nokogiri (~> 1.11)
+ nokogiri (~> 1.12)
jekyll-watch (2.2.1)
listen (~> 3.0)
jemoji (0.12.0)
@@ -220,21 +220,21 @@ GEM
rexml
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
- liquid (4.0.3)
+ liquid (4.0.4)
liquid-tag-parser (1.9.0)
extras (~> 0.3)
liquid (>= 3.0, < 5.0)
- listen (3.7.1)
+ listen (3.8.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
mercenary (0.3.6)
- mini_portile2 (2.8.0)
+ mini_portile2 (2.8.1)
minima (2.5.1)
jekyll (>= 3.5, < 5.0)
jekyll-feed (~> 0.9)
jekyll-seo-tag (~> 2.1)
- minitest (5.16.2)
- nokogiri (1.13.9)
+ minitest (5.17.0)
+ nokogiri (1.14.1)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
octokit (4.25.1)
@@ -243,9 +243,9 @@ GEM
pathutil (0.16.2)
forwardable-extended (~> 2.6)
public_suffix (4.0.7)
- racc (1.6.0)
- rack (2.2.4)
- rb-fsevent (0.11.1)
+ racc (1.6.2)
+ rack (2.2.6.2)
+ rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
rexml (3.2.5)
@@ -271,7 +271,7 @@ GEM
thread_safe (0.3.6)
typhoeus (1.4.0)
ethon (>= 0.9.0)
- tzinfo (1.2.10)
+ tzinfo (1.2.11)
thread_safe (~> 0.1)
unf (0.1.4)
unf_ext
@@ -282,7 +282,7 @@ PLATFORMS
ruby
DEPENDENCIES
- github-pages (~> 227)
+ github-pages (~> 228)
http_parser.rb (~> 0.6.0)
jekyll-assets (~> 3.0.12)
jekyll-feed (~> 0.12)
@@ -293,4 +293,4 @@ DEPENDENCIES
wdm (~> 0.1.1)
BUNDLED WITH
- 1.17.3
+ 2.3.26
diff --git a/docs/configuration.markdown b/docs/configuration.markdown
index 366303d..163863a 100644
--- a/docs/configuration.markdown
+++ b/docs/configuration.markdown
@@ -494,9 +494,11 @@ starts with `libvirt__` string. Here is a list of those options:
for for more information. *Note: takes either 'yes' or 'no' for value*
* `:libvirt__ipv6_address` - Define ipv6 address, require also prefix.
* `:libvirt__ipv6_prefix` - Define ipv6 prefix. generate string `<ip family="ipv6" address="address" prefix="prefix" >`
-* `:libvirt__iface_name` - Define a name for the private network interface.
- With this feature one can [simulate physical link
- failures](https://github.com/vagrant-libvirt/vagrant-libvirt/pull/498)
+* `:libvirt__iface_name` - Define a name for the corresponding network interface
+ created on the host. With this feature one can [simulate physical link
+ failures](https://github.com/vagrant-libvirt/vagrant-libvirt/pull/498). Note
+ that you cannot use names reserved for libvirt's usage based on [documentation](
+ https://libvirt.org/formatdomain.html#overriding-the-target-element).
* `:mac` - MAC address for the interface. *Note: specify this in lowercase
since Vagrant network scripts assume it will be!*
* `:libvirt__mtu` - MTU size for the Libvirt network, if not defined, the
@@ -542,6 +544,14 @@ virtual network.
* `:trust_guest_rx_filters` - Support trustGuestRxFilters attribute. Details
are listed [here](http://www.libvirt.org/formatdomain.html#elementsNICSDirect).
Default is 'false'.
+* `:libvirt__iface_name` - Define a name for the corresponding network interface
+ that is created on the host connected to the bridge dev. This can be used to
+ help attach VLAN tags to specific VMs by adjusting the pattern to match. Note
+ that you cannot use names reserved for libvirt's usage based on [documentation](
+ https://libvirt.org/formatdomain.html#overriding-the-target-element).
+* `:libvirt__mtu` - MTU size for the Libvirt interface, if not defined, the
+ created network will use the Libvirt default (1500). VMs still need to configure
+ their internal interface MTUs.
Additionally for public networks, to facilitate validating if the device provided
can be used, vagrant-libvirt will check both the host interfaces visible to libvirt
@@ -582,6 +592,7 @@ used by this network are configurable at the provider level.
the Libvirt default (1500) will be used.
* `management_network_keep` - Starting from version *0.7.0*, *always_destroy* is set to *true* by default for any network.
This option allows to change this behaviour for the management network.
+* `management_network_model_type` - Model of the network adapter to use for the management interface. Default is 'virtio'.
You may wonder how vagrant-libvirt knows the IP address a VM received. Libvirt
doesn't provide a standard way to find out the IP address of a running domain.
@@ -1035,9 +1046,18 @@ end
## Clock
-Clock offset can be specified via `libvirt.clock_offset`. (Default is utc)
+The clock can be configured using one of the following methods:
-Additionally timers can be specified via `libvirt.clock_timer`.
+* Set nothing, and the clock will default to UTC.
+* Set `libvirt.clock_offset` to 'utc' or 'localtime' by assigning the respective values.
+* To set the clock to a different timezone, assign the timezone name to `libvirt.clock_timezone`.
+* To set the clock to the same absolute time whenever the VM starts, set `libvirt.clock_absolute`.
+ The value format is that of an epoch timestamp.
+* To set the clock at an arbitrary offset to realtime, use `libvirt.clock_adjustment`.
+ Specify the offset adjustment in seconds. By default, the clock offset is relative to UTC,
+ but this can be changed by setting `libvirt.clock_basis` to 'localtime'.
+
+In addition to the above, timers can be specified via `libvirt.clock_timer`.
Available options for timers are: name, track, tickpolicy, frequency, mode, present
```ruby
diff --git a/lib/vagrant-libvirt/action/create_domain.rb b/lib/vagrant-libvirt/action/create_domain.rb
index 35be527..96026f2 100644
--- a/lib/vagrant-libvirt/action/create_domain.rb
+++ b/lib/vagrant-libvirt/action/create_domain.rb
@@ -36,7 +36,11 @@ module VagrantPlugins
@nodeset = config.nodeset
@features = config.features
@features_hyperv = config.features_hyperv
+ @clock_absolute = config.clock_absolute
+ @clock_adjustment = config.clock_adjustment
+ @clock_basis = config.clock_basis
@clock_offset = config.clock_offset
+ @clock_timezone = config.clock_timezone
@clock_timers = config.clock_timers
@launchsecurity_data = config.launchsecurity_data
@shares = config.shares
@@ -198,6 +202,8 @@ module VagrantPlugins
dir = File.dirname(serial[:source][:path])
begin
FileUtils.mkdir_p(dir)
+ FileUtils.touch(serial[:source][:path])
+ File.truncate(serial[:source][:path], 0) unless serial[:source].fetch(:append, false)
rescue ::Errno::EACCES
raise Errors::SerialCannotCreatePathError,
path: dir
@@ -234,7 +240,15 @@ module VagrantPlugins
env[:ui].info(" -- Feature (HyperV): name=#{feature[:name]}, state=#{feature[:state]}")
end
end
- env[:ui].info(" -- Clock offset: #{@clock_offset}")
+ if not @clock_absolute.nil?
+ env[:ui].info(" -- Clock absolute: #{@clock_absolute}")
+ elsif not @clock_adjustment.nil?
+ env[:ui].info(" -- Clock adjustment: #{@clock_adjustment}")
+ elsif not @clock_timezone.nil?
+ env[:ui].info(" -- Clock timezone: #{@clock_timezone}")
+ else
+ env[:ui].info(" -- Clock offset: #{@clock_offset}")
+ end
@clock_timers.each do |timer|
env[:ui].info(" -- Clock timer: #{timer.map { |k,v| "#{k}=#{v}"}.join(', ')}")
end
diff --git a/lib/vagrant-libvirt/action/create_network_interfaces.rb b/lib/vagrant-libvirt/action/create_network_interfaces.rb
index f134755..f01bcbb 100644
--- a/lib/vagrant-libvirt/action/create_network_interfaces.rb
+++ b/lib/vagrant-libvirt/action/create_network_interfaces.rb
@@ -4,6 +4,9 @@ require 'log4r'
require 'vagrant/util/network_ip'
require 'vagrant/util/scoped_hash_override'
+require 'vagrant-libvirt/util/erb_template'
+require 'vagrant-libvirt/util/network_util'
+
module VagrantPlugins
module ProviderLibvirt
module Action
@@ -40,7 +43,7 @@ module VagrantPlugins
# Vagrant gives you adapter 0 by default
# Assign interfaces to slots.
- configured_networks(env, @logger).each do |options|
+ configured_networks(env[:machine], @logger).each do |options|
# don't need to create interface for this type
next if options[:iface_type] == :forwarded_port
@@ -96,6 +99,7 @@ module VagrantPlugins
@driver_iommu = iface_configuration.fetch(:driver_iommu, false )
@driver_name = iface_configuration.fetch(:driver_name, false)
@driver_queues = iface_configuration.fetch(:driver_queues, false)
+ @device_name = iface_configuration.fetch(:iface_name, nil)
@portgroup = iface_configuration.fetch(:portgroup, nil)
@network_name = iface_configuration.fetch(:network_name, @network_name)
template_name = 'public_interface'
@@ -146,7 +150,7 @@ module VagrantPlugins
# FIXME: all options for network driver should be hash from Vagrantfile
driver_options = {}
driver_options[:name] = @driver_name if @driver_name
- driver_options[:iommu] = @driver_iommu ? "on" : "off" if @nic_model_type == 'virtio'
+ driver_options[:iommu] = @driver_iommu ? "on" : "off" if @model_type == 'virtio'
driver_options[:queues] = @driver_queues if @driver_queues
@udp_tunnel ||= {}
@@ -169,7 +173,7 @@ module VagrantPlugins
@logger.debug {
"Attaching Network Device with XML:\n#{xml}"
}
- domain.attach_device(xml)
+ env[:machine].provider.driver.attach_device(xml)
rescue => e
raise Errors::AttachDeviceError,
error_message: e.message
diff --git a/lib/vagrant-libvirt/action/create_networks.rb b/lib/vagrant-libvirt/action/create_networks.rb
index 775aba5..b0aa0de 100644
--- a/lib/vagrant-libvirt/action/create_networks.rb
+++ b/lib/vagrant-libvirt/action/create_networks.rb
@@ -47,7 +47,7 @@ module VagrantPlugins
@@lock.synchronize do
# Iterate over networks If some network is not
# available, create it if possible. Otherwise raise an error.
- configured_networks(env, @logger).each do |options|
+ configured_networks(env[:machine], @logger).each do |options|
# Only need to create private networks
next if options[:iface_type] != :private_network ||
options.fetch(:tunnel_type, nil)
diff --git a/lib/vagrant-libvirt/action/forward_ports.rb b/lib/vagrant-libvirt/action/forward_ports.rb
index 89f641b..8f16a1e 100644
--- a/lib/vagrant-libvirt/action/forward_ports.rb
+++ b/lib/vagrant-libvirt/action/forward_ports.rb
@@ -93,7 +93,7 @@ module VagrantPlugins
-N
#{ssh_info[:host]}
)
- params += '-g' if gateway_ports
+ params <<= '-g' if gateway_ports
options = (%W(
User=#{ssh_info[:username]}
diff --git a/lib/vagrant-libvirt/action/start_domain.rb b/lib/vagrant-libvirt/action/start_domain.rb
index 9956834..d2dad83 100644
--- a/lib/vagrant-libvirt/action/start_domain.rb
+++ b/lib/vagrant-libvirt/action/start_domain.rb
@@ -166,12 +166,29 @@ module VagrantPlugins
xml_descr.delete_element('/domain/cpu')
end
- # Clock
+ # Clock - can change in complicated ways, so just build a new clock and compare
+ newclock = REXML::Element.new('newclock')
+ if not config.clock_absolute.nil?
+ newclock.add_attribute('offset', 'absolute')
+ newclock.add_attribute('start', config.clock_absolute)
+ elsif not config.clock_adjustment.nil?
+ newclock.add_attribute('offset', 'variable')
+ newclock.add_attribute('basis', config.clock_basis)
+ newclock.add_attribute('adjustment', config.clock_adjustment)
+ elsif not config.clock_timezone.nil?
+ newclock.add_attribute('offset', 'timezone')
+ newclock.add_attribute('timezone', config.clock_timezone)
+ else
+ newclock.add_attribute('offset', config.clock_offset)
+ end
clock = REXML::XPath.first(xml_descr, '/domain/clock')
- if clock.attributes['offset'] != config.clock_offset
- @logger.debug "clock offset changed"
+ if clock.attributes != newclock.attributes
+ @logger.debug "clock definition changed"
descr_changed = true
- clock.attributes['offset'] = config.clock_offset
+ clock.attributes.clear
+ newclock.attributes.each do |attr, value|
+ clock.add_attribute(attr, value)
+ end
end
# clock timers - because timers can be added/removed, just rebuild and then compare
@@ -272,13 +289,25 @@ module VagrantPlugins
graphics.attributes['listen'] = config.graphics_ip
graphics.delete_element('//listen')
end
- if graphics.attributes['autoport'] != config.graphics_autoport
- descr_changed = true
- graphics.attributes['autoport'] = config.graphics_autoport
- if config.graphics_autoport == 'no'
- graphics.attributes.delete('autoport')
+ unless config.graphics_port.nil? or config.graphics_port == -1
+ if graphics.attributes['autoport'] != 'no'
+ descr_changed = true
+ graphics.attributes['autoport'] = 'no'
+ end
+ if graphics.attributes['port'] != config.graphics_port
+ descr_changed = true
graphics.attributes['port'] = config.graphics_port
end
+ else
+ if graphics.attributes['autoport'] != config.graphics_autoport
+ descr_changed = true
+ graphics.attributes['autoport'] = config.graphics_autoport
+ if config.graphics_autoport == 'no'
+ graphics.attributes['port'] = config.graphics_port
+ else
+ graphics.attributes['port'] = '-1'
+ end
+ end
end
if graphics.attributes['websocket'] != config.graphics_websocket.to_s
descr_changed = true
diff --git a/lib/vagrant-libvirt/config.rb b/lib/vagrant-libvirt/config.rb
index d4763be..ea5fdce 100644
--- a/lib/vagrant-libvirt/config.rb
+++ b/lib/vagrant-libvirt/config.rb
@@ -7,11 +7,13 @@ require 'vagrant/action/builtin/mixin_synced_folders'
require 'vagrant-libvirt/errors'
require 'vagrant-libvirt/util/resolvers'
+require 'vagrant-libvirt/util/network_util'
module VagrantPlugins
module ProviderLibvirt
class Config < Vagrant.plugin('2', :config)
include Vagrant::Action::Builtin::MixinSyncedFolders
+ include VagrantPlugins::ProviderLibvirt::Util::NetworkUtil
# manually specify URI
# will supersede most other options if provided
@@ -68,6 +70,7 @@ module VagrantPlugins
attr_accessor :management_network_mtu
attr_accessor :management_network_keep
attr_accessor :management_network_driver_iommu
+ attr_accessor :management_network_model_type
# System connection information
attr_accessor :system_uri
@@ -95,7 +98,11 @@ module VagrantPlugins
attr_accessor :shares
attr_accessor :features
attr_accessor :features_hyperv
+ attr_accessor :clock_absolute
+ attr_accessor :clock_adjustment
+ attr_accessor :clock_basis
attr_accessor :clock_offset
+ attr_accessor :clock_timezone
attr_accessor :clock_timers
attr_accessor :launchsecurity_data
attr_accessor :numa_nodes
@@ -222,6 +229,8 @@ module VagrantPlugins
]
def initialize
+ @logger = Log4r::Logger.new("vagrant_libvirt::config")
+
@uri = UNSET_VALUE
@driver = UNSET_VALUE
@host = UNSET_VALUE
@@ -249,6 +258,7 @@ module VagrantPlugins
@management_network_mtu = UNSET_VALUE
@management_network_keep = UNSET_VALUE
@management_network_driver_iommu = UNSET_VALUE
+ @management_network_model_type = UNSET_VALUE
# System connection information
@system_uri = UNSET_VALUE
@@ -272,7 +282,11 @@ module VagrantPlugins
@shares = UNSET_VALUE
@features = UNSET_VALUE
@features_hyperv = UNSET_VALUE
+ @clock_absolute = UNSET_VALUE
+ @clock_adjustment = UNSET_VALUE
+ @clock_basis = UNSET_VALUE
@clock_offset = UNSET_VALUE
+ @clock_timezone = UNSET_VALUE
@clock_timers = []
@launchsecurity_data = UNSET_VALUE
@numa_nodes = UNSET_VALUE
@@ -959,6 +973,7 @@ module VagrantPlugins
@management_network_mtu = nil if @management_network_mtu == UNSET_VALUE
@management_network_keep = false if @management_network_keep == UNSET_VALUE
@management_network_driver_iommu = false if @management_network_driver_iommu == UNSET_VALUE
+ @management_network_model_type = 'virtio' if @management_network_model_type == UNSET_VALUE
# Domain specific settings.
@title = '' if @title == UNSET_VALUE
@@ -995,7 +1010,11 @@ module VagrantPlugins
@shares = nil if @shares == UNSET_VALUE
@features = ['acpi','apic','pae'] if @features == UNSET_VALUE
@features_hyperv = [] if @features_hyperv == UNSET_VALUE
+ @clock_absolute = nil if @clock_absolute == UNSET_VALUE
+ @clock_adjustment = nil if @clock_adjustment == UNSET_VALUE
+ @clock_basis = 'utc' if @clock_basis == UNSET_VALUE
@clock_offset = 'utc' if @clock_offset == UNSET_VALUE
+ @clock_timezone = nil if @clock_timezone == UNSET_VALUE
@clock_timers = [] if @clock_timers == UNSET_VALUE
@launchsecurity_data = nil if @launchsecurity_data == UNSET_VALUE
@numa_nodes = @numa_nodes == UNSET_VALUE ? nil : _generate_numa
@@ -1206,27 +1225,7 @@ module VagrantPlugins
errors << "#{e}"
end
- machine.config.vm.networks.each_with_index do |network, index|
- type, opts = network
-
- if opts[:mac]
- if opts[:mac] =~ /\A([0-9a-fA-F]{12})\z/
- opts[:mac] = opts[:mac].scan(/../).join(':')
- end
- unless opts[:mac] =~ /\A([0-9a-fA-F]{2}:){5}([0-9a-fA-F]{2})\z/
- errors << "Configured NIC MAC '#{opts[:mac]}' is not in 'xx:xx:xx:xx:xx:xx' or 'xxxxxxxxxxxx' format"
- end
- end
-
- # only interested in public networks where portgroup is nil, as then source will be a host device
- if type == :public_network && opts[:portgroup] == nil
- devices = host_devices(machine)
- hostdev = opts.fetch(:dev, 'eth0')
- if !devices.include?(hostdev)
- errors << "network configuration #{index} for machine #{machine.name} is a public_network referencing host device '#{hostdev}' which does not exist, consider adding ':dev => ....' referencing one of #{devices.join(", ")}"
- end
- end
- end
+ errors = validate_networks(machine, errors)
if !machine.provider_config.volume_cache.nil? and machine.provider_config.volume_cache != UNSET_VALUE
machine.ui.warn("Libvirt Provider: volume_cache is deprecated. Use disk_driver :cache => '#{machine.provider_config.volume_cache}' instead.")
@@ -1250,6 +1249,10 @@ module VagrantPlugins
end
end
+ if [@clock_absolute, @clock_adjustment, @clock_timezone].count {|clock| !clock.nil?} > 1
+ errors << "At most, only one of [clock_absolute, clock_adjustment, clock_timezone] may be set."
+ end
+
errors = validate_sysinfo(machine, errors)
{ 'Libvirt Provider' => errors }
@@ -1320,8 +1323,8 @@ module VagrantPlugins
end
end
- # Extract host values from uri if provided, otherwise nil
- @host = uri.host
+ # Extract host values from uri if provided, otherwise set empty string
+ @host = uri.host || ""
@port = uri.port
# only override username if there is a value provided
@username = nil if @username == UNSET_VALUE
@@ -1389,11 +1392,55 @@ module VagrantPlugins
end
end
- def host_devices(machine)
- machine.provider.driver.host_devices.select do |dev|
- next if dev.empty?
- dev != "lo" && !@host_device_exclude_prefixes.any? { |exclude| dev.start_with?(exclude) }
+ def validate_networks(machine, errors)
+ begin
+ networks = configured_networks(machine, @logger)
+ rescue Errors::VagrantLibvirtError => e
+ errors << "#{e}"
+
+ return
end
+
+ return if networks.empty?
+
+ networks.each_with_index do |network, index|
+ if network[:mac]
+ if network[:mac] =~ /\A([0-9a-fA-F]{12})\z/
+ network[:mac] = network[:mac].scan(/../).join(':')
+ end
+ unless network[:mac] =~ /\A([0-9a-fA-F]{2}:){5}([0-9a-fA-F]{2})\z/
+ errors << "Configured NIC MAC '#{network[:mac]}' is not in 'xx:xx:xx:xx:xx:xx' or 'xxxxxxxxxxxx' format"
+ end
+ end
+
+ # only interested in public networks where portgroup is nil, as then source will be a host device
+ if network[:iface_type] == :public_network && network[:portgroup] == nil
+ exclude_prefixes = @host_device_exclude_prefixes
+ # for qemu sessions the management network injected will be a public_network trying to use a libvirt managed device
+ if index == 0 and machine.provider_config.mgmt_attach and machine.provider_config.qemu_use_session == true
+ exclude_prefixes.delete('virbr')
+ end
+
+ devices = machine.provider.driver.host_devices.select do |dev|
+ next if dev.empty?
+ dev != "lo" && !exclude_prefixes.any? { |exclude| dev.start_with?(exclude) }
+ end
+ hostdev = network.fetch(:dev, 'eth0')
+
+ if !devices.include?(hostdev)
+ errors << "network configuration #{index} for machine #{machine.name} is a public_network referencing host device '#{hostdev}' which does not exist, consider adding ':dev => ....' referencing one of #{devices.join(", ")}"
+ end
+ end
+
+ unless network[:iface_name].nil?
+ restricted_devnames = ['vnet', 'vif', 'macvtap', 'macvlan']
+ if restricted_devnames.any? { |restricted| network[:iface_name].start_with?(restricted) }
+ errors << "network configuration for machine #{machine.name} with setting :libvirt__iface_name => '#{network[:iface_name]}' starts with a restricted prefix according to libvirt docs https://libvirt.org/formatdomain.html#overriding-the-target-element, please use a device name that does not start with one of #{restricted_devnames.join(", ")}"
+ end
+ end
+ end
+
+ errors
end
def validate_sysinfo(machine, errors)
diff --git a/lib/vagrant-libvirt/templates/domain.xml.erb b/lib/vagrant-libvirt/templates/domain.xml.erb
index 862de52..0419665 100644
--- a/lib/vagrant-libvirt/templates/domain.xml.erb
+++ b/lib/vagrant-libvirt/templates/domain.xml.erb
@@ -132,7 +132,15 @@
</hyperv>
<%- end -%>
</features>
+<%- if not @clock_absolute.nil? -%>
+ <clock offset='absolute' start='<%= @clock_absolute %>'>
+<%- elsif not @clock_adjustment.nil? -%>
+ <clock offset='variable' basis='<%= @clock_basis %>' adjustment='<%= @clock_adjustment %>'>
+<%- elsif not @clock_timezone.nil? -%>
+ <clock offset='timezone' timezone='<%= @clock_timezone %>'>
+<%- else -%>
<clock offset='<%= @clock_offset %>'>
+<%- end -%>
<%- @clock_timers.each do |clock_timer| -%>
<timer<% clock_timer.each do |attr, value| %> <%= attr %>='<%= value %>'<% end %>/>
<%- end -%>
@@ -208,9 +216,12 @@
<%- end -%>
<%- @serials.each_with_index do |serial, port| -%>
<serial type='<%= serial[:type] %>'>
- <%- unless serial[:source].nil? -%>
- <source path='<%= serial[:source][:path] %>'/>
- <%- end -%>
+ <%- unless serial[:source].nil?
+ source = serial[:source]
+ seclabel = serial[:source][:seclabel]
+-%>
+ <source path='<%= source[:path] %>' append='<%= source.fetch(:append, 'on') %>'/>
+ <%- end -%>
<target port='<%= port %>'/>
</serial>
<%- end -%>
diff --git a/lib/vagrant-libvirt/templates/public_interface.xml.erb b/lib/vagrant-libvirt/templates/public_interface.xml.erb
index cf98a09..d1c28ea 100644
--- a/lib/vagrant-libvirt/templates/public_interface.xml.erb
+++ b/lib/vagrant-libvirt/templates/public_interface.xml.erb
@@ -1,34 +1,39 @@
<interface type='<%= @type %>'<% if @trust_guest_rx_filters %> trustGuestRxFilters='yes'<% end %>>
<alias name='ua-net-<%= @iface_number %>'/>
- <% if @mac %>
+ <%- if @mac %>
<mac address='<%= @mac %>'/>
- <% end %>
- <%if @type == 'direct'%>
+ <%- end %>
+ <%- if @type == 'direct'%>
<source dev='<%= @device %>' mode='<%= @mode %>'/>
- <% elsif !@portgroup.nil? %>
+ <%- elsif !@portgroup.nil? %>
<source network='<%=@network_name%>' portgroup='<%=@portgroup%>'/>
- <% else %>
+ <%- else %>
<source bridge='<%=@device%>'/>
- <% end %>
+ <%- end %>
+ <%- unless @device_name.nil? %>
+ <target dev='<%= @device_name %>'/>
+ <%- end %>
<model type='<%=@model_type%>'/>
- <% if @driver_name and @driver_queues %>
+ <%- if @driver_name and @driver_queues %>
<driver <% if @driver_iommu %> iommu="on" <% end %> name='<%=@driver_name%>' queues='<%=@driver_queues%>'/>
- <% elsif @driver_queues %>
+ <%- elsif @driver_queues %>
<driver <% if @driver_iommu %> iommu="on" <% end %> queues='<%=@driver_queues%>'/>
- <% elsif @driver_name %>
+ <%- elsif @driver_name %>
<driver <% if @driver_iommu %> iommu="on" <% end %> name='<%=@driver_name%>'/>
- <% elsif @driver_iommu %>
+ <%- elsif @driver_iommu %>
<driver iommu='on' />
+ <%- end %>
+ <% if @mtu %>
+ <mtu size="<%= @mtu %>" />
<% end %>
-
- <% if @ovs %>
+ <%- if @ovs %>
<virtualport type='openvswitch'>
- <% if @ovs_interfaceid %>
+ <%- if @ovs_interfaceid %>
<parameters interfaceid='<%=@ovs_interfaceid%>'/>
- <% end %>
+ <%- end %>
</virtualport>
- <% end %>
- <% if @pci_bus and @pci_slot %>
+ <%- end %>
+ <%- if @pci_bus and @pci_slot %>
<address type='pci' bus='<%=@pci_bus%>' slot='<%=@pci_slot%>' />
- <% end %>
+ <%- end %>
</interface>
diff --git a/lib/vagrant-libvirt/util/network_util.rb b/lib/vagrant-libvirt/util/network_util.rb
index b29182e..937e2bc 100644
--- a/lib/vagrant-libvirt/util/network_util.rb
+++ b/lib/vagrant-libvirt/util/network_util.rb
@@ -18,22 +18,23 @@ module VagrantPlugins
module NetworkUtil
include Vagrant::Util::NetworkIP
- def configured_networks(env, logger)
- qemu_use_session = env[:machine].provider_config.qemu_use_session
- qemu_use_agent = env[:machine].provider_config.qemu_use_agent
- management_network_device = env[:machine].provider_config.management_network_device
- management_network_name = env[:machine].provider_config.management_network_name
- management_network_address = env[:machine].provider_config.management_network_address
- management_network_mode = env[:machine].provider_config.management_network_mode
- management_network_mac = env[:machine].provider_config.management_network_mac
- management_network_guest_ipv6 = env[:machine].provider_config.management_network_guest_ipv6
- management_network_autostart = env[:machine].provider_config.management_network_autostart
- management_network_pci_bus = env[:machine].provider_config.management_network_pci_bus
- management_network_pci_slot = env[:machine].provider_config.management_network_pci_slot
- management_network_domain = env[:machine].provider_config.management_network_domain
- management_network_mtu = env[:machine].provider_config.management_network_mtu
- management_network_keep = env[:machine].provider_config.management_network_keep
- management_network_driver_iommu = env[:machine].provider_config.management_network_driver_iommu
+ def configured_networks(machine, logger)
+ qemu_use_session = machine.provider_config.qemu_use_session
+ qemu_use_agent = machine.provider_config.qemu_use_agent
+ management_network_device = machine.provider_config.management_network_device
+ management_network_name = machine.provider_config.management_network_name
+ management_network_address = machine.provider_config.management_network_address
+ management_network_mode = machine.provider_config.management_network_mode
+ management_network_mac = machine.provider_config.management_network_mac
+ management_network_guest_ipv6 = machine.provider_config.management_network_guest_ipv6
+ management_network_autostart = machine.provider_config.management_network_autostart
+ management_network_pci_bus = machine.provider_config.management_network_pci_bus
+ management_network_pci_slot = machine.provider_config.management_network_pci_slot
+ management_network_domain = machine.provider_config.management_network_domain
+ management_network_mtu = machine.provider_config.management_network_mtu
+ management_network_keep = machine.provider_config.management_network_keep
+ management_network_driver_iommu = machine.provider_config.management_network_driver_iommu
+ management_network_model_type = machine.provider_config.management_network_model_type
logger.info "Using #{management_network_name} at #{management_network_address} as the management network #{management_network_mode} is the mode"
begin
@@ -54,6 +55,7 @@ module VagrantPlugins
if qemu_use_session
management_network_options = {
iface_type: :public_network,
+ model_type: management_network_model_type,
dev: management_network_device,
mode: 'bridge',
type: 'bridge',
@@ -63,6 +65,7 @@ module VagrantPlugins
else
management_network_options = {
iface_type: :private_network,
+ model_type: management_network_model_type,
network_name: management_network_name,
ip: Regexp.last_match(1),
netmask: Regexp.last_match(2),
@@ -101,23 +104,23 @@ module VagrantPlugins
# if there is a box and management network is disabled
# need qemu agent enabled and at least one network that can be accessed
if (
- env[:machine].config.vm.box &&
- !env[:machine].provider_config.mgmt_attach &&
- !env[:machine].provider_config.qemu_use_agent &&
- !env[:machine].config.vm.networks.any? { |type, _| ["private_network", "public_network"].include?(type.to_s) }
+ machine.config.vm.box &&
+ !machine.provider_config.mgmt_attach &&
+ !machine.provider_config.qemu_use_agent &&
+ !machine.config.vm.networks.any? { |type, _| ["private_network", "public_network"].include?(type.to_s) }
)
raise Errors::ManagementNetworkRequired
end
# add management network to list of networks to check
# unless mgmt_attach set to false
- networks = if env[:machine].provider_config.mgmt_attach
+ networks = if machine.provider_config.mgmt_attach
[management_network_options]
else
[]
end
- env[:machine].config.vm.networks.each do |type, original_options|
+ machine.config.vm.networks.each do |type, original_options|
logger.debug "In config found network type #{type} options #{original_options}"
# Options can be specified in Vagrantfile in short format (:ip => ...),
# or provider format # (:libvirt__network_name => ...).
diff --git a/lib/vagrant-libvirt/version.rb b/lib/vagrant-libvirt/version.rb
index 97fa48d..32b850e 100644
--- a/lib/vagrant-libvirt/version.rb
+++ b/lib/vagrant-libvirt/version.rb
@@ -7,7 +7,7 @@ module VagrantPlugins
module ProviderLibvirt
VERSION_FILE = File.dirname(__FILE__) + "/version"
- GIT_ARCHIVE_VERSION = "e0b17b34f5d651c35fd848a2083fe9d91f0506ca tag: 0.11.2"
+ GIT_ARCHIVE_VERSION = "$Format:%H %D$"
HOMEPAGE = 'https://github.com/vagrant-libvirt/vagrant-libvirt'
diff --git a/spec/support/libvirt_acceptance_context.rb b/spec/support/libvirt_acceptance_context.rb
index 7628224..8e0f533 100644
--- a/spec/support/libvirt_acceptance_context.rb
+++ b/spec/support/libvirt_acceptance_context.rb
@@ -71,7 +71,7 @@ shared_context 'libvirt_acceptance' do
# allows for a helper Vagrantfile to force specific provider options if testing
# environment needs them
vagrantfile = File.join(vagrant_home, 'Vagrantfile')
- if File.exists?(vagrantfile) and !File.exists?(File.join(target_env.homedir, 'Vagrantfile'))
+ if File.exist?(vagrantfile) and !File.exist?(File.join(target_env.homedir, 'Vagrantfile'))
FileUtils.cp(vagrantfile, target_env.homedir)
end
end
diff --git a/spec/support/matchers/have_file_content.rb b/spec/support/matchers/have_file_content.rb
index 9970f6b..2021518 100644
--- a/spec/support/matchers/have_file_content.rb
+++ b/spec/support/matchers/have_file_content.rb
@@ -45,7 +45,7 @@ require "rspec/expectations/version"
# end
RSpec::Matchers.define :have_file_content do |expected|
match do |actual|
- next false unless File.exists?(actual)
+ next false unless File.exist?(actual)
@actual = File.read(actual).chomp
@expected = if expected.is_a? String
diff --git a/spec/support/unit_context.rb b/spec/support/unit_context.rb
index bb87f19..4c4126d 100644
--- a/spec/support/unit_context.rb
+++ b/spec/support/unit_context.rb
@@ -29,12 +29,9 @@ shared_context 'unit' do
# Mock the communicator to prevent SSH commands for being executed.
let(:communicator) { double('communicator') }
- # Mock the guest operating system.
- let(:guest) { double('guest') }
let(:app) { ->(env) {} }
before (:each) do
- allow(machine).to receive(:guest).and_return(guest)
allow(machine).to receive(:communicate).and_return(communicator)
allow(machine).to receive(:ui).and_return(ui)
end
diff --git a/spec/unit/action/clean_machine_folder_spec.rb b/spec/unit/action/clean_machine_folder_spec.rb
index faad98c..b8ed8ac 100644
--- a/spec/unit/action/clean_machine_folder_spec.rb
+++ b/spec/unit/action/clean_machine_folder_spec.rb
@@ -20,7 +20,7 @@ describe VagrantPlugins::ProviderLibvirt::Action::CleanMachineFolder do
expect(subject.call(env)).to be_nil
- expect(File.exists?(machine.data_dir)).to eq(true)
+ expect(File.exist?(machine.data_dir)).to eq(true)
expect(Dir.entries(machine.data_dir)).to match_array([".", ".."])
end
end
@@ -38,7 +38,7 @@ describe VagrantPlugins::ProviderLibvirt::Action::CleanMachineFolder do
expect(subject.call(env)).to be_nil
- expect(File.exists?(machine.data_dir)).to eq(true)
+ expect(File.exist?(machine.data_dir)).to eq(true)
expect(Dir.entries(machine.data_dir)).to match_array([".", ".."])
end
end
@@ -51,7 +51,7 @@ describe VagrantPlugins::ProviderLibvirt::Action::CleanMachineFolder do
expect(subject.call(env)).to be_nil
- expect(File.exists?(machine.data_dir)).to eq(true)
+ expect(File.exist?(machine.data_dir)).to eq(true)
expect(Dir.entries(machine.data_dir)).to match_array([".", ".."])
end
end
diff --git a/spec/unit/action/create_network_interfaces.rb b/spec/unit/action/create_network_interfaces.rb
new file mode 100644
index 0000000..dfcf08e
--- /dev/null
+++ b/spec/unit/action/create_network_interfaces.rb
@@ -0,0 +1,305 @@
+# frozen_string_literal: true
+
+require_relative '../../spec_helper'
+
+require 'vagrant-libvirt/errors'
+require 'vagrant-libvirt/action/create_network_interfaces'
+require 'vagrant-libvirt/util/unindent'
+
+describe VagrantPlugins::ProviderLibvirt::Action::CreateNetworkInterfaces do
+ subject { described_class.new(app, env) }
+
+ include_context 'unit'
+ include_context 'libvirt'
+
+ let(:networks) { [
+ instance_double(::Libvirt::Network),
+ instance_double(::Libvirt::Network),
+ ] }
+ let(:default_network_xml) {
+ <<-EOF
+ <network>
+ <name>default</name>
+ <uuid>e5f871eb-2899-48b2-83df-78aa43efa360</uuid>
+ <forward mode='nat'>
+ <nat>
+ <port start='1024' end='65535'/>
+ </nat>
+ </forward>
+ <bridge name='virbr0' stp='on' delay='0'/>
+ <mac address='52:54:00:71:ce:a6'/>
+ <ip address='192.168.122.1' netmask='255.255.255.0'>
+ <dhcp>
+ <range start='192.168.122.2' end='192.168.122.254'/>
+ </dhcp>
+ </ip>
+ </network>
+ EOF
+ }
+ let(:management_network_xml) {
+ <<-EOF
+ <network ipv6='yes'>
+ <name>vagrant-libvirt</name>
+ <uuid>46360938-0607-4168-a182-1352fac4a4f9</uuid>
+ <forward mode='nat'/>
+ <bridge name='virbr1' stp='on' delay='0'/>
+ <mac address='52:54:00:c2:d5:a5'/>
+ <ip address='192.168.121.1' netmask='255.255.255.0'>
+ <dhcp>
+ <range start='192.168.121.1' end='192.168.121.254'/>
+ </dhcp>
+ </ip>
+ </network>
+ EOF
+ }
+ let(:default_management_nic_xml) {
+ <<-EOF.unindent
+ <interface type="network">
+ <alias name="ua-net-0"></alias>
+ <source network="vagrant-libvirt"></source>
+ <target dev="vnet0"></target>
+ <model type="virtio"></model>
+ <driver iommu="off"></driver>
+ </interface>
+ EOF
+ }
+
+ before do
+ allow(app).to receive(:call)
+ allow(libvirt_client).to receive(:lookup_domain_by_uuid).and_return(libvirt_domain)
+
+ allow(driver).to receive(:list_all_networks).and_return(networks)
+
+ allow(networks[0]).to receive(:xml_desc).and_return(default_network_xml)
+ allow(networks[0]).to receive(:name).and_return('default')
+ allow(networks[0]).to receive(:bridge_name).and_return('virbr0')
+ allow(networks[0]).to receive(:active?).and_return(true)
+ allow(networks[0]).to receive(:autostart?).and_return(true)
+ allow(networks[1]).to receive(:xml_desc).and_return(management_network_xml)
+ allow(networks[1]).to receive(:name).and_return('vagrant-libvirt')
+ allow(networks[1]).to receive(:bridge_name).and_return('virbr1')
+ allow(networks[1]).to receive(:active?).and_return(true)
+ allow(networks[1]).to receive(:autostart?).and_return(false)
+
+ allow(logger).to receive(:info)
+ allow(logger).to receive(:debug)
+ end
+
+ describe '#call' do
+ it 'should inject the management network definition' do
+ expect(driver).to receive(:attach_device).with(default_management_nic_xml)
+
+ expect(subject.call(env)).to be_nil
+ end
+
+ context 'private network' do
+ let(:vagrantfile) do
+ <<-EOF
+ Vagrant.configure('2') do |config|
+ config.vm.box = "vagrant-libvirt/test"
+ config.vm.define :test
+ config.vm.provider :libvirt do |libvirt|
+ #{vagrantfile_providerconfig}
+ end
+
+ config.vm.network :private_network, :ip => "10.20.30.40"
+ end
+ EOF
+ end
+ let(:private_network) { instance_double(::Libvirt::Network) }
+ let(:private_network_xml) {
+ <<-EOF
+ <network ipv6='yes'>
+ <name>test1</name>
+ <uuid>46360938-0607-4168-a182-1352fac4a4f9</uuid>
+ <forward mode='nat'/>
+ <bridge name='virbr2' stp='on' delay='0'/>
+ <mac address='52:54:00:c2:d5:a5'/>
+ <ip address='10.20.30.1' netmask='255.255.255.0'>
+ <dhcp>
+ <range start='10.20.30.1' end='10.20.30.254'/>
+ </dhcp>
+ </ip>
+ </network>
+ EOF
+ }
+ let(:private_nic_xml) {
+ <<-EOF.unindent
+ <interface type="network">
+ <alias name="ua-net-1"></alias>
+ <source network="test1"></source>
+ <target dev="vnet1"></target>
+ <model type="virtio"></model>
+ <driver iommu="off"></driver>
+ </interface>
+ EOF
+ }
+
+ before do
+ allow(private_network).to receive(:xml_desc).and_return(private_network_xml)
+ allow(private_network).to receive(:name).and_return('test1')
+ allow(private_network).to receive(:bridge_name).and_return('virbr2')
+ allow(private_network).to receive(:active?).and_return(true)
+ allow(private_network).to receive(:autostart?).and_return(false)
+ end
+
+ it 'should attach for two networks' do
+ expect(driver).to receive(:list_all_networks).and_return(networks + [private_network])
+ expect(driver).to receive(:attach_device).with(default_management_nic_xml)
+ expect(driver).to receive(:attach_device).with(private_nic_xml)
+ expect(guest).to receive(:capability).with(:configure_networks, any_args)
+
+ expect(subject.call(env)).to be_nil
+ end
+
+ context 'when iface name is set' do
+ let(:private_nic_xml) {
+ <<-EOF.unindent
+ <interface type="network">
+ <alias name="ua-net-1"></alias>
+ <source network="test1"></source>
+ <target dev="myvnet0"></target>
+ <model type="virtio"></model>
+ <driver iommu="off"></driver>
+ </interface>
+ EOF
+ }
+
+ before do
+ machine.config.vm.networks[0][1][:libvirt__iface_name] = "myvnet0"
+ end
+
+ it 'should set target appropriately' do
+ expect(driver).to receive(:list_all_networks).and_return(networks + [private_network])
+ expect(driver).to receive(:attach_device).with(default_management_nic_xml)
+ expect(driver).to receive(:attach_device).with(private_nic_xml)
+ expect(guest).to receive(:capability).with(:configure_networks, any_args)
+
+ expect(subject.call(env)).to be_nil
+ end
+ end
+
+ it 'should skip configuring networks in guest without box' do
+ machine.config.vm.box = nil
+
+ expect(driver).to receive(:list_all_networks).and_return(networks + [private_network])
+ expect(driver).to receive(:attach_device).with(default_management_nic_xml)
+ expect(driver).to receive(:attach_device).with(private_nic_xml)
+ expect(guest).to_not receive(:capability).with(:configure_networks, any_args)
+
+ expect(subject.call(env)).to be_nil
+ end
+ end
+
+ context 'public network' do
+ let(:vagrantfile) do
+ <<-EOF
+ Vagrant.configure('2') do |config|
+ config.vm.box = "vagrant-libvirt/test"
+ config.vm.define :test
+ config.vm.provider :libvirt do |libvirt|
+ #{vagrantfile_providerconfig}
+ end
+
+ config.vm.network :public_network, :dev => "virbr1", :mode => "bridge", :type => "bridge"
+ end
+ EOF
+ end
+ let(:public_network) { instance_double(::Libvirt::Network) }
+ let(:public_network_xml) {
+ <<-EOF
+ <network ipv6='yes'>
+ <name>test1</name>
+ <uuid>46360938-0607-4168-a182-1352fac4a4f9</uuid>
+ <forward mode='nat'/>
+ <bridge name='virbr2' stp='on' delay='0'/>
+ <mac address='52:54:00:c2:d5:a5'/>
+ <ip address='10.20.30.1' netmask='255.255.255.0'>
+ <dhcp>
+ <range start='10.20.30.1' end='10.20.30.254'/>
+ </dhcp>
+ </ip>
+ </network>
+ EOF
+ }
+ let(:public_nic_xml) {
+ <<-EOF.unindent
+ <interface type='bridge'>
+ <alias name='ua-net-1'/>
+ <source bridge='virbr1'/>
+ <model type='virtio'/>
+ </interface>
+ EOF
+ }
+ let(:domain_xml) {
+ # don't need full domain here, just enough for the network element to work
+ <<-EOF.unindent
+ <domain type='qemu'>
+ <devices>
+ <interface type='network'>
+ <alias name='ua-net-0'/>
+ <mac address='52:54:00:7d:14:0e'/>
+ <source network='vagrant-libvirt'/>
+ <model type='virtio'/>
+ <driver iommu='off'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
+ </interface>
+ <interface type='network'>
+ <alias name='ua-net-1'/>
+ <mac address='52:54:00:7d:14:0f'/>
+ <source bridge='virbr1'/>
+ <model type='virtio'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
+ </interface>
+ </devices>
+ </domain>
+ EOF
+ }
+
+ before do
+ allow(public_network).to receive(:xml_desc).and_return(public_network_xml)
+ allow(public_network).to receive(:name).and_return('test1')
+ allow(public_network).to receive(:bridge_name).and_return('virbr2')
+ allow(public_network).to receive(:active?).and_return(true)
+ allow(public_network).to receive(:autostart?).and_return(false)
+
+ allow(libvirt_domain).to receive(:xml_desc).and_return(domain_xml)
+ end
+
+ it 'should attach for two networks' do
+ expect(driver).to receive(:list_all_networks).and_return(networks + [public_network])
+ expect(driver).to receive(:attach_device).with(default_management_nic_xml)
+ expect(driver).to receive(:attach_device).with(public_nic_xml)
+ expect(guest).to receive(:capability).with(:configure_networks, any_args)
+
+ expect(subject.call(env)).to be_nil
+ end
+
+ context 'when iface name is set' do
+ let(:public_nic_xml) {
+ <<-EOF.unindent
+ <interface type='bridge'>
+ <alias name='ua-net-1'/>
+ <source bridge='virbr1'/>
+ <target dev='myvnet0'/>
+ <model type='virtio'/>
+ </interface>
+ EOF
+ }
+
+ before do
+ machine.config.vm.networks[0][1][:libvirt__iface_name] = "myvnet0"
+ end
+
+ it 'should set target appropriately' do
+ expect(driver).to receive(:list_all_networks).and_return(networks + [public_network])
+ expect(driver).to receive(:attach_device).with(default_management_nic_xml)
+ expect(driver).to receive(:attach_device).with(public_nic_xml)
+ expect(guest).to receive(:capability).with(:configure_networks, any_args)
+
+ expect(subject.call(env)).to be_nil
+ end
+ end
+ end
+ end
+end
diff --git a/spec/unit/action/start_domain_spec.rb b/spec/unit/action/start_domain_spec.rb
index 07927ad..a8826ef 100644
--- a/spec/unit/action/start_domain_spec.rb
+++ b/spec/unit/action/start_domain_spec.rb
@@ -349,6 +349,48 @@ describe VagrantPlugins::ProviderLibvirt::Action::StartDomain do
expect(subject.call(env)).to be_nil
end
end
+
+ [
+ [
+ 'when port explicitly set, should set autoport=no',
+ proc { |config|
+ config.graphics_port = 5901
+ },
+ "<graphics autoport='yes' keymap='en-us' listen='127.0.0.1' port='-1' type='vnc' websocket='-1'/>",
+ "<graphics autoport='no' keymap='en-us' listen='127.0.0.1' port='5901' type='vnc' websocket='-1'/>",
+ ],
+ [
+ 'when port updated, should set autoport=no and update port',
+ proc { |config|
+ config.graphics_port = 5902
+ },
+ "<graphics autoport='no' keymap='en-us' listen='127.0.0.1' port='5901' type='vnc' websocket='-1'/>",
+ "<graphics autoport='no' keymap='en-us' listen='127.0.0.1' port='5902' type='vnc' websocket='-1'/>",
+ ],
+ [
+ 'when autoport set and no port, should set autoport=yes and update port to -1',
+ proc { |config|
+ config.graphics_autoport = 'yes'
+ },
+ "<graphics autoport='no' keymap='en-us' listen='127.0.0.1' port='5901' type='vnc' websocket='-1'/>",
+ "<graphics autoport='yes' keymap='en-us' listen='127.0.0.1' port='-1' type='vnc' websocket='-1'/>",
+ ],
+ ].each do |description, config_proc, graphics_xml_start, graphics_xml_output|
+ it "#{description}" do
+ config_proc.call(machine.provider_config)
+
+ initial_domain_xml = domain_xml.gsub(/<graphics .*\/>/, graphics_xml_start)
+ updated_domain_xml = domain_xml.gsub(/<graphics .*\/>/, graphics_xml_output)
+
+ expect(ui).to_not receive(:warn)
+ expect(connection).to receive(:define_domain).with(match(graphics_xml_output)).and_return(libvirt_domain)
+ expect(libvirt_domain).to receive(:xml_desc).and_return(initial_domain_xml, updated_domain_xml, updated_domain_xml)
+ expect(libvirt_domain).to receive(:autostart=)
+ expect(domain).to receive(:start)
+
+ expect(subject.call(env)).to be_nil
+ end
+ end
end
context 'nvram' do
diff --git a/spec/unit/cap/mount_9p_spec.rb b/spec/unit/cap/mount_9p_spec.rb
index e8957a9..add5253 100644
--- a/spec/unit/cap/mount_9p_spec.rb
+++ b/spec/unit/cap/mount_9p_spec.rb
@@ -15,6 +15,9 @@ describe 'VagrantPlugins::ProviderLibvirt::Cap::Mount9P' do
end
let(:options) { {} }
+ # Mock the guest operating system.
+ let(:guest) { double('guest') }
+
describe '#mount_9p_shared_folder' do
let(:synced_folders) { {
"/vagrant" => {
@@ -26,6 +29,7 @@ describe 'VagrantPlugins::ProviderLibvirt::Cap::Mount9P' do
} }
before do
+ allow(machine).to receive(:guest).and_return(guest)
allow(guest).to receive(:capability).and_return('/home/vagrant/vagant')
allow(communicator).to receive(:sudo).with('mkdir -p /home/vagrant/vagant')
end
diff --git a/spec/unit/config_spec.rb b/spec/unit/config_spec.rb
index d205214..f43de4d 100644
--- a/spec/unit/config_spec.rb
+++ b/spec/unit/config_spec.rb
@@ -86,7 +86,7 @@ describe VagrantPlugins::ProviderLibvirt::Config do
],
[ # connect explicit to unix socket
{:uri => "qemu+unix:///system"},
- {:uri => "qemu+unix:///system", :connect_via_ssh => false, :host => nil, :username => nil},
+ {:uri => "qemu+unix:///system", :connect_via_ssh => false, :host => "", :username => nil},
],
[ # via libssh2 should enable ssh as well
{:uri => "qemu+libssh2://user@remote/system?known_hosts=/home/user/.ssh/known_hosts"},
@@ -139,7 +139,7 @@ describe VagrantPlugins::ProviderLibvirt::Config do
],
[ # with session and using ssh infer connect by ssh and ignore host as not provided
{},
- {:uri => "qemu+ssh:///session", :qemu_use_session => true, :connect_via_ssh => true, :host => nil},
+ {:uri => "qemu+ssh:///session", :qemu_use_session => true, :connect_via_ssh => true, :host => ""},
{
:env => {'LIBVIRT_DEFAULT_URI' => "qemu+ssh:///session"},
}
@@ -768,8 +768,11 @@ describe VagrantPlugins::ProviderLibvirt::Config do
context 'with mac defined' do
let (:vm) { double('vm') }
+ let(:box) { instance_double(::Vagrant::Box) }
+
before do
machine.config.instance_variable_get("@keys")[:vm] = vm
+ allow(vm).to receive(:box).and_return(box)
end
it 'is valid with valid mac' do
@@ -781,7 +784,7 @@ describe VagrantPlugins::ProviderLibvirt::Config do
network = [:public, { mac: 'aabbccddeeff' }]
expect(vm).to receive(:networks).and_return([network])
assert_valid
- expect(network[1][:mac]).to eql('aa:bb:cc:dd:ee:ff')
+ expect(network[1][:mac]).to eql('aabbccddeeff')
end
it 'should be invalid if MAC not formatted correctly' do
@@ -798,8 +801,9 @@ describe VagrantPlugins::ProviderLibvirt::Config do
'virbr0',
] }
let(:driver) { instance_double(::VagrantPlugins::ProviderLibvirt::Driver) }
+ let(:device_name) { 'eth0' }
before do
- machine.config.vm.network :public_network, dev: 'eth0', ip: "192.168.2.157"
+ machine.config.vm.network :public_network, dev: device_name, ip: "192.168.2.157"
allow(machine.provider).to receive(:driver).and_return(driver)
expect(driver).to receive(:host_devices).and_return(host_devices).at_least(:once).times
end
@@ -809,9 +813,7 @@ describe VagrantPlugins::ProviderLibvirt::Config do
end
context 'when default device not on host' do
- before do
- machine.config.vm.network :public_network, dev: 'eno1', ip: "192.168.2.157"
- end
+ let(:device_name) { 'eno1' }
it 'should be invalid' do
assert_invalid
@@ -819,9 +821,7 @@ describe VagrantPlugins::ProviderLibvirt::Config do
end
context 'when using excluded host device' do
- before do
- machine.config.vm.network :public_network, dev: 'virbr0', ip: "192.168.2.157"
- end
+ let(:device_name) { 'virbr0' }
it 'should be invalid' do
assert_invalid
@@ -837,6 +837,27 @@ describe VagrantPlugins::ProviderLibvirt::Config do
end
end
end
+
+ context 'when setting iface_name' do
+ let(:iface_name) { 'myvnet1' }
+
+ before do
+ machine.config.vm.network :public_network, libvirt__iface_name: iface_name, ip: "192.168.2.157"
+ end
+
+ it 'should valididate' do
+ assert_valid
+ end
+
+ context 'when set to reserved value' do
+ let(:iface_name) { 'vnet1' }
+
+ it 'should be invalid' do
+ errors = assert_invalid
+ expect(errors).to include(match(/network configuration for machine test with setting :libvirt__iface_name => '#{iface_name}' starts/))
+ end
+ end
+ end
end
context 'with nvram defined' do
@@ -996,10 +1017,16 @@ describe VagrantPlugins::ProviderLibvirt::Config do
EOF
end
let(:driver) { instance_double(::VagrantPlugins::ProviderLibvirt::Driver) }
+ let(:host_devices) { [
+ 'lo',
+ 'eth0',
+ 'virbr0',
+ ] }
before do
allow(machine.provider).to receive(:driver).and_return(driver)
allow(driver).to receive_message_chain('connection.client.libversion').and_return(6_002_000)
+ allow(driver).to receive(:host_devices).and_return(host_devices)
end
context 'when type is 9p' do
diff --git a/spec/unit/driver_spec.rb b/spec/unit/driver_spec.rb
index c01b823..6cf0f0a 100644
--- a/spec/unit/driver_spec.rb
+++ b/spec/unit/driver_spec.rb
@@ -42,40 +42,51 @@ describe VagrantPlugins::ProviderLibvirt::Driver do
# need to override the default package iso_env as using a different
# name for the test machines above.
let(:machine) { iso_env.machine(:test1, :libvirt) }
- let(:machine2) { iso_env.machine(:test2, :libvirt) }
- let(:connection1) { double("connection 1") }
- let(:connection2) { double("connection 2") }
- let(:system_connection1) { double("system connection 1") }
- let(:system_connection2) { double("system connection 2") }
+ let(:connection) { double("connection 1") }
+ let(:system_connection) { double("system connection 1") }
# make it easier for distros that want to switch the default value for
# qemu_use_session to true by ensuring it is explicitly false for tests.
before do
allow(machine.provider).to receive('driver').and_call_original
- allow(machine2.provider).to receive('driver').and_call_original
end
describe '#connection' do
+ let(:machine2) { iso_env.machine(:test2, :libvirt) }
+ let(:connection2) { double("connection 2") }
+
+ before do
+ allow(machine2.provider).to receive('driver').and_call_original
+ end
+
it 'should configure a separate connection per machine' do
expect(Fog::Compute).to receive(:new).with(
- hash_including({:libvirt_uri => 'qemu+ssh://user@remote1/system'})).and_return(connection1)
+ hash_including({:libvirt_uri => 'qemu+ssh://user@remote1/system'})).and_return(connection)
expect(Fog::Compute).to receive(:new).with(
hash_including({:libvirt_uri => 'qemu+ssh://vms@remote2/system'})).and_return(connection2)
- expect(machine.provider.driver.connection).to eq(connection1)
+ expect(machine.provider.driver.connection).to eq(connection)
expect(machine2.provider.driver.connection).to eq(connection2)
end
it 'should configure the connection once' do
- expect(Fog::Compute).to receive(:new).once().and_return(connection1)
+ expect(Fog::Compute).to receive(:new).once().and_return(connection)
- expect(machine.provider.driver.connection).to eq(connection1)
- expect(machine.provider.driver.connection).to eq(connection1)
- expect(machine.provider.driver.connection).to eq(connection1)
+ expect(machine.provider.driver.connection).to eq(connection)
+ expect(machine.provider.driver.connection).to eq(connection)
+ expect(machine.provider.driver.connection).to eq(connection)
end
end
describe '#system_connection' do
+ let(:machine2) { iso_env.machine(:test2, :libvirt) }
+ let(:connection2) { double("connection 2") }
+ let(:system_connection2) { double("system connection 2") }
+
+ before do
+ allow(machine2.provider).to receive('driver').and_call_original
+ end
+
# note that the urls for the two tests are currently
# incorrect here as they should be the following:
# qemu+ssh://user@remote1/system
@@ -87,19 +98,19 @@ describe VagrantPlugins::ProviderLibvirt::Driver do
# system_uri should be 'qemu+ssh://user@remote1/system'
# and not 'qemu:///system'.
it 'should configure a separate connection per machine' do
- expect(Libvirt).to receive(:open_read_only).with('qemu+ssh://user@remote1/system').and_return(system_connection1)
+ expect(Libvirt).to receive(:open_read_only).with('qemu+ssh://user@remote1/system').and_return(system_connection)
expect(Libvirt).to receive(:open_read_only).with('qemu+ssh://vms@remote2/system').and_return(system_connection2)
- expect(machine.provider.driver.system_connection).to eq(system_connection1)
+ expect(machine.provider.driver.system_connection).to eq(system_connection)
expect(machine2.provider.driver.system_connection).to eq(system_connection2)
end
it 'should configure the connection once' do
- expect(Libvirt).to receive(:open_read_only).with('qemu+ssh://user@remote1/system').and_return(system_connection1)
+ expect(Libvirt).to receive(:open_read_only).with('qemu+ssh://user@remote1/system').and_return(system_connection)
- expect(machine.provider.driver.system_connection).to eq(system_connection1)
- expect(machine.provider.driver.system_connection).to eq(system_connection1)
- expect(machine.provider.driver.system_connection).to eq(system_connection1)
+ expect(machine.provider.driver.system_connection).to eq(system_connection)
+ expect(machine.provider.driver.system_connection).to eq(system_connection)
+ expect(machine.provider.driver.system_connection).to eq(system_connection)
end
end
end
diff --git a/spec/unit/templates/domain_all_settings.xml b/spec/unit/templates/domain_all_settings.xml
index d14df4b..3dce82d 100644
--- a/spec/unit/templates/domain_all_settings.xml
+++ b/spec/unit/templates/domain_all_settings.xml
@@ -47,7 +47,7 @@
<spinlocks state='on' retries='4096' />
</hyperv>
</features>
- <clock offset='variable'>
+ <clock offset='variable' basis='localtime' adjustment='-31536000'>
<timer name='t1'/>
<timer name='t2' track='b' tickpolicy='c' frequency='d' mode='e' present='yes'/>
</clock>
@@ -105,7 +105,7 @@
<target dev='fda' bus='fdc'/>
</disk>
<serial type='file'>
- <source path='/var/log/vm_consoles/machine.log'/>
+ <source path='/var/log/vm_consoles/machine.log' append='on'/>
<target port='0'/>
</serial>
<console type='file'>
diff --git a/spec/unit/templates/domain_spec.rb b/spec/unit/templates/domain_spec.rb
index d1b8495..d228759 100644
--- a/spec/unit/templates/domain_spec.rb
+++ b/spec/unit/templates/domain_spec.rb
@@ -62,7 +62,8 @@ describe 'templates/domain' do
domain.cpu_mode = 'custom'
domain.cpu_feature(name: 'AAA', policy: 'required')
domain.hyperv_feature(name: 'BBB', state: 'on')
- domain.clock_offset = 'variable'
+ domain.clock_adjustment = -(365 * 24 * 60 * 60)
+ domain.clock_basis = 'localtime'
domain.clock_timer(name: 't1')
domain.clock_timer(name: 't2', track: 'b', tickpolicy: 'c', frequency: 'd', mode: 'e', present: 'yes')
domain.hyperv_feature(name: 'spinlocks', state: 'on', retries: '4096')
More details
Historical runs
- failed: /usr/lib/ruby/vendor_ruby/gem2deb/metadata.rb:135:in `load_gemspec': E: cannot load gemspec vagrant-libvirt.gemspec (RuntimeError)
- nothing-to-do: Last upstream version 0.8.0 already imported.
- command-failed: Command 'SCHROOT=unstable-amd64-sbuild PYTHONPATH=/:/code:/code/breezy:/code/dulwich:/code/lintian-brush:/code/ognibuild:/code/silver-platter:/code/buildlog-consultant:/code/upstream-ontologist:/code/debmutate:/code/python-debian/lib:/usr/lib/python39.zip:/usr/lib/python3.9:/usr/lib/python3.9/lib-dynload:/usr/local/lib/python3.9/dist-packages:/usr/lib/python3/dist-packages /usr/bin/python3 -m janitor.dist --packaging=/tmp/janitorutmd8gc8/vagrant-libvirt/debian' returned non-zero exit status 1.