Skip to content

Commit

Permalink
Merge branch 'xapi-project:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
LunfanZhang authored Dec 4, 2023
2 parents 8e3398c + 0a36c4a commit 12badf2
Show file tree
Hide file tree
Showing 362 changed files with 11,186 additions and 5,431 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/1.249-lcm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ jobs:
# invalidate cache every week, gets built using a scheduled job
key: ${{ steps.cache-key.outputs.date }}-1.249

- name: Update Ubuntu repositories
run: sudo apt-get update

- name: Use ocaml
uses: avsm/setup-ocaml@v1
with:
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
jobs:
ocaml:
name: Docs
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
env:
XAPI_VERSION: "v0.0.0-${{ github.sha }}"
STORAGE_DOCDIR: .gh-pages-xapi-storage
Expand All @@ -24,6 +24,9 @@ jobs:
id: dotenv
uses: falti/dotenv-action@v1

- name: Update Ubuntu repositories
run: sudo apt-get update

- name: Use ocaml
uses: ocaml/setup-ocaml@v2
with:
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
jobs:
ocaml-format:
name: Ocaml files
runs-on: ubuntu-20.04
runs-on: ubuntu-latest

steps:
- name: Checkout code
Expand All @@ -22,7 +22,10 @@ jobs:
- name: Load environment file
id: dotenv
uses: falti/[email protected]
uses: falti/[email protected]

- name: Update Ubuntu repositories
run: sudo apt-get update

- name: Use ocaml
uses: ocaml/setup-ocaml@v2
Expand All @@ -31,11 +34,10 @@ jobs:
opam-repositories: |
xs-opam: ${{ steps.dotenv.outputs.repository }}
dune-cache: true
opam-pin: false

- name: Install ocamlformat
run: |
opam update
opam install ocamlformat
run: opam install ocamlformat

- name: Check whether `make format` was run
run: opam exec -- dune build @fmt
37 changes: 37 additions & 0 deletions .github/workflows/hugo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Generate and upload Hugo docs

on:
push:
branches: master

jobs:
ocaml:
name: Docs
runs-on: ubuntu-22.04

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: '0.119.0'

- name: Build
run: |
cd doc
hugo --minify
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.ACTIONS_DOCS_DEPLOY_KEY }}
publish_dir: ./doc/public
user_name: 'Github action on xapi-project/xen-api'
user_email: 'github-actions-xapi-project-xen-api[bot]@users.noreply.github.com'
external_repository: xapi-project/xapi-project.github.io
publish_branch: master
destination_dir: new-docs # temporary staging branch
allow_empty_commit: false
enable_jekyll: true # do not create .nojekyll file
56 changes: 11 additions & 45 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
jobs:
python-test:
name: Python tests
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
Expand All @@ -36,67 +36,33 @@ jobs:
name: Ocaml tests
runs-on: ubuntu-20.04
env:
package: 'xapi-cli-protocol xapi-client xapi-consts xapi-datamodel xapi-types xapi
xe xen-api-sdk xen-api-client xen-api-client-lwt xen-api-client-async
xapi-rrdd xapi-rrdd-plugin xapi-rrd-transport xapi-rrd-transport-utils
rrd-transport rrdd-plugin rrdd-plugins rrddump gzip http-lib pciutil
safe-resources sexpr stunnel uuid xapi-compression xml-light2 zstd
vhd-tool xapi-networkd xapi-squeezed xapi-xenopsd xapi-xenopsd-cli
xapi-xenopsd-simulator xapi-xenopsd-xc message-switch
message-switch-async message-switch-cli message-switch-core
message-switch-lwt message-switch-unix xapi-idl forkexec xapi-forkexecd
xapi-storage xapi-storage-script xapi-storage-cli wsproxy xapi-nbd
varstored-guard xapi-log xapi-open-uri vhd-format vhd-format-lwt
xapi-tracing xapi-expiry-alerts ezxenstore'
XAPI_VERSION: "v0.0.0-${{ github.sha }}"
XAPI_VERSION: "v0.0.0"

steps:
- name: Checkout code
uses: actions/checkout@v3

# The checkout action performs a shallow, this triggers dune to set the
# version to <hash>-dirty. Work around this dune behaviour and tag the
# commit so a proper version is always picked up
- name: Tag current commit
run: |
git config user.name "Dune workaround"
git config user.email "<>"
git tag -am "workaround for dune" "$XAPI_VERSION"
- name: Pull configuration from xs-opam
run: |
curl --fail --silent https://raw.githubusercontent.com/xapi-project/xs-opam/master/tools/xs-opam-ci.env | cut -f2 -d " " > .env
- name: Load environment file
id: dotenv
uses: falti/[email protected].2
uses: falti/[email protected].4

- name: Retrieve date for cache key
id: cache-key
run: echo "date=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_OUTPUT
shell: bash

- name: Restore opam cache
id: opam-cache
uses: actions/cache@v3
with:
path: "~/.opam"
# invalidate cache daily, gets built daily using a scheduled job
key: ${{ steps.cache-key.outputs.date }}
- name: Update Ubuntu repositories
run: sudo apt-get update

- name: Use ocaml
uses: avsm/setup-ocaml@v1
uses: ocaml/setup-ocaml@v2
with:
ocaml-version: ${{ steps.dotenv.outputs.ocaml_version_full }}
opam-repository: ${{ steps.dotenv.outputs.repository }}
ocaml-compiler: ${{ steps.dotenv.outputs.ocaml_version_full }}
opam-repositories: |
xs-opam: ${{ steps.dotenv.outputs.repository }}
dune-cache: true

- name: Install dependencies
run: |
opam update
opam pin add . --no-action
opam depext -u ${{ env.package }}
opam upgrade
opam install ${{ env.package }} --deps-only --with-test -v
run: opam install . --deps-only --with-test -v

- name: Configure
run: opam exec -- ./configure --xapi_version="$XAPI_VERSION"
Expand Down
22 changes: 6 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ on:
- 'v*'

jobs:
build:
build-python:
runs-on: ubuntu-latest
env:
XAPI_VERSION: ${{ github.ref_name }}

steps:
- name: Checkout code
Expand All @@ -27,7 +25,7 @@ jobs:
- name: Generate python package for XenAPI
run: |
./configure --xapi-version=${{ github.ref_name }}
./configure --xapi_version=${{ github.ref_name }}
make python
- name: Store python distribution artifacts
Expand All @@ -39,28 +37,20 @@ jobs:

release:
runs-on: ubuntu-latest
needs: build
needs: build-python
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Retrieve python distribution artifacts
uses: actions/download-artifact@v3
with:
name: XenAPI
path: dist/

- name: Draft Release ${{ github.ref_name }}
run: gh release create ${{ github.ref_name }} --draft --generate-notes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload artifacts
run: gh release upload ${{ github.ref_name }} dist/*
- name: Create release ${{ github.ref_name }}
run: gh release create ${{ github.ref_name }} --repo ${{ github.repository }} --generate-notes dist/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publish:
publish-pypi:
runs-on: ubuntu-latest
needs: release
environment: pypi
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,8 @@ ocaml/xenopsd/scripts/xen-backend.rules
ocaml/xenopsd/xentoollog_flags

ocaml/idl/gen_lifecycle.exe

.hugo_build.lock
go.sum

.DS_Store
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ lint:

test:
dune runtest --profile=$(PROFILE) --error-reporting=twice -j $(JOBS)
ifneq ($(PY_TEST), NO)
dune build @runtest-python --profile=$(PROFILE)
endif

stresstest:
dune build @stresstest --profile=$(PROFILE) --no-buffer -j $(JOBS)
Expand Down Expand Up @@ -116,6 +118,8 @@ install: build doc sdk doc-json
scripts/install.sh 755 _build/install/default/bin/vncproxy $(DESTDIR)$(OPTDIR)/debug/vncproxy
# ocaml/perftest
scripts/install.sh 755 _build/install/default/bin/perftest $(DESTDIR)$(OPTDIR)/debug/perftest
# ocaml/suspend-image-viewer
scripts/install.sh 755 _build/install/default/bin/suspend-image-viewer $(DESTDIR)$(OPTDIR)/debug/suspend-image-viewer
# ocaml/mpathalert
scripts/install.sh 755 _build/install/default/bin/mpathalert $(DESTDIR)$(OPTDIR)/bin/mpathalert
# ocaml/license
Expand All @@ -135,10 +139,11 @@ install: build doc sdk doc-json
# ocaml/rrd2csv
scripts/install.sh 755 _build/install/default/bin/rrd2csv $(DESTDIR)$(OPTDIR)/bin/rrd2csv
scripts/install.sh 644 ocaml/rrd2csv/man/rrd2csv.1.man $(DESTDIR)$(OPTMANDIR)/rrd2csv.1
# ocaml/xs-trace
scripts/install.sh 755 _build/install/default/bin/xs-trace $(DESTDIR)/usr/bin/xs-trace
# xcp-rrdd
install -D _build/install/default/bin/xcp-rrdd $(DESTDIR)/usr/sbin/xcp-rrdd
install -D _build/install/default/bin/rrddump $(DESTDIR)/usr/bin/rrddump
install -D -m 644 ocaml/xcp-rrdd/scripts/rrdd/rrdd.py $(DESTDIR)/usr/lib/python2.7/site-packages
# rrd-cli
install -D _build/install/default/bin/rrd-cli $(DESTDIR)/usr/bin/rrd-cli
# rrd-transport
Expand Down Expand Up @@ -181,6 +186,7 @@ install: build doc sdk doc-json
install -D ./ocaml/xenopsd/scripts/igmp_query_injector.py $(DESTDIR)/$(XENOPSD_LIBEXECDIR)/igmp_query_injector.py
install -D ./ocaml/xenopsd/scripts/qemu-wrapper $(DESTDIR)/$(QEMU_WRAPPER_DIR)/qemu-wrapper
install -D ./ocaml/xenopsd/scripts/swtpm-wrapper $(DESTDIR)/$(QEMU_WRAPPER_DIR)/swtpm-wrapper
install -D ./ocaml/xenopsd/scripts/pygrub-wrapper $(DESTDIR)/$(QEMU_WRAPPER_DIR)/pygrub-wrapper
DESTDIR=$(DESTDIR) SBINDIR=$(SBINDIR) QEMU_WRAPPER_DIR=$(QEMU_WRAPPER_DIR) XENOPSD_LIBEXECDIR=$(XENOPSD_LIBEXECDIR) ETCDIR=$(ETCDIR) ./ocaml/xenopsd/scripts/make-custom-xenopsd.conf
# squeezed
install -D _build/install/default/bin/squeezed $(DESTDIR)/$(SBINDIR)/squeezed
Expand All @@ -198,8 +204,6 @@ install: build doc sdk doc-json
message-switch message-switch-async message-switch-cli message-switch-core message-switch-lwt \
message-switch-unix xapi-idl forkexec xapi-forkexecd xapi-storage xapi-storage-script xapi-storage-cli \
xapi-nbd varstored-guard xapi-log xapi-open-uri xapi-tracing xapi-expiry-alerts cohttp-posix
make -C _build/default/ocaml/xapi-storage/python
make -C _build/default/ocaml/xapi-storage/python install DESTDIR=$(DESTDIR)
# docs
mkdir -p $(DESTDIR)$(DOCDIR)
cp -r $(XAPIDOC)/jekyll $(DESTDIR)$(DOCDIR)
Expand Down
13 changes: 13 additions & 0 deletions doc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Quick start guide:

- Install Hugo; follow the guidance on https://gohugo.io/getting-started/installing.
You'll need Go as well: see https://go.dev/
- Run a local server: `hugo server`
- Open a browser at http://127.0.0.1:1313/
- Add some content.
- Documents are written in Markdown.
- Please wrap lines in paragraphs to make review and diffs easier to read.
- The menu hierarchy comes mostly from the directory structure in `content/`.
- A file called `_index.md` is needed in a directory to define a new level in the menu. Add a title to the frontmatter.
- For a page that has images or other stuff included, it is best to create a new directory. Put the contents in a `index.md` file (no `_`) and the related files next to it. See https://gohugo.io/content-management/organization/ for more information.
- Look at https://mcshelby.github.io/hugo-theme-relearn/ for more information about what the Relearn theme offers, including some handy "shortcodes".
5 changes: 5 additions & 0 deletions doc/archetypes/default.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
+++
title = '{{ replace .File.ContentBaseName "-" " " | title }}'
date = {{ .Date }}
draft = true
+++
20 changes: 20 additions & 0 deletions doc/content/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
+++
title = "XAPI Toolstack Developer Guide"
archetype = "home"
+++

The **XAPI Toolstack**:

- Forms the control plane of both [XenServer](http://xenserver.com) as well as
[xcp-ng](http://xcp-ng.org),
- manages clusters of Xen hosts with shared storage and networking,
- has a full-featured [API](http://xapi-project-github.io/xen-api), used by clients such as
[XenCenter](https://github.com/xenserver/xenadmin) and [Xen Orchestra](https://xen-orchestra.com).

The XAPI Toolstack is an open-source project developed by the [xapi
project](http://www.xenproject.org/developers/teams/xapi.html), a sub-project of the Linux
Foundation Xen Project.

The source code is available on [Github under the xapi-project](https://github.com/xapi-project/). the main repository is [xen-api](https://github.com/xapi-project/xen-api).

This developer guide documents the internals of the Toolstack to help developers understand the code, fix bugs and add new features. It is a work-in-progress, with new documents added when ready and updated whenever needed.
7 changes: 7 additions & 0 deletions doc/content/toolstack/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: The XAPI Toolstack
menuTitle: The Toolstack
weight: 10
---

{{% children depth="2" %}}
Binary file added doc/content/toolstack/features/DR/dr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions doc/content/toolstack/features/DR/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
+++
title = "Disaster Recovery"
+++

The [HA](../HA/HA.html) feature will restart VMs after hosts have failed, but what
happens if a whole site (e.g. datacenter) is lost? A disaster recovery
configuration is shown in the following diagram:

![Disaster recovery maintaining a secondary site](dr.png)

We rely on the storage array's built-in mirroring to replicate (synchronously
or asynchronously: the admin's choice) between the primary and the secondary
site. When DR is enabled the VM disk data and VM metadata are written to the
storage server and mirrored. The secondary site contains the other side
of the data mirror and a set of hosts, which may be powered off.

In normal operation, the DR feature allows a "dry-run" recovery where a host
on the secondary site checks that it can indeed see all the VM disk data
and metadata. This should be done regularly, so that admins are familiar with
the process.

After a disaster, the admin breaks the mirror on the secondary site and triggers
a remote power-on of the offline hosts (either using an out-of-band tool or
the built-in host power-on feature of xapi). The pool master on the secondary
site can connect to the storage and extract all the VM metadata. Finally the
VMs can all be restarted.

When the primary site is fully recovered, the mirror can be re-synchronised
and the VMs can be moved back.
11 changes: 11 additions & 0 deletions doc/content/toolstack/features/HA/HA.configure.msc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
participant slave1
Note over master: Host.enable_ha\nchoose an SR\nfind or create VDIs\nattach VDIs\nwrite xhad.conf\nha_set_pool_state init
master->slave1: Host.preconfigure_ha
Note over slave1: attach VDIs\nwrite xhad.conf\n
master->slave2: Host.preconfigure_ha
Note over slave2: attach VDIs\nwrite xhad.conf\n
master->slave1: Host.ha_join_liveset
master->slave2: Host.ha_join_liveset
Note over master: ha_propose_master
slave1-->master: wait for master
slave2-->master: wait for master
Loading

0 comments on commit 12badf2

Please sign in to comment.