Skip to content

Commit 64fda7a

Browse files
Sync feature limit vnc console with master (xapi-project#6819)
Sync feature branch with master. No code changed. ``` $ git show 27199eb commit 27199eb (HEAD -> private/stephenche/vnc_sync_260107, mygit/private/stephenche/vnc_sync_260107, bb/private/stephenche/vnc_sync_260107) Merge: 8c88947 19f2398 Author: Stephen Cheng <stephen.cheng@citrix.com> Date: Wed Jan 7 09:56:17 2026 +0800 Merge branch 'master' into private/stephenche/vnc_sync_260107 Signed-off-by: Stephen Cheng <stephen.cheng@citrix.com> diff --cc ocaml/idl/schematest.ml index 7dc03c9,e0658e78a..a90bf86 --- a/ocaml/idl/schematest.ml +++ b/ocaml/idl/schematest.ml @@@ -3,7 -3,7 +3,7 @@@ let hash x = Digest.string x |> Digest. (* BEWARE: if this changes, check that schema has been bumped accordingly in ocaml/idl/datamodel_common.ml, usually schema_minor_vsn *) - let last_known_schema_hash = "9e085767a7a70fb84747776c4d6cc663" -let last_known_schema_hash = "d8cb04ccddfd91ca3f0f9074dcf7c219" ++let last_known_schema_hash = "a01358e3ff5f42d5aee162e995d2ec05" let current_schema_hash : string = let open Datamodel_types in ```
2 parents 8c88947 + 74f91b5 commit 64fda7a

214 files changed

Lines changed: 5424 additions & 3400 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.git-blame-ignore-revs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ b12cf444edea15da6274975e1b2ca6a7fce2a090
3333
364c27f5d18ab9dd31825e67a93efabecad06823
3434
d8b4de9076531dd13bdffa20cc10c72290a52356
3535
bdf06bca7534fbc0c4fc3cee3408a51a22615226
36+
eefc649e17086fbc200e4da114ea673825e79864
3637

3738
# ocp-indent
3839
d018d26d6acd4707a23288b327b49e44f732725e

Makefile

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ build:
2121
check:
2222
dune build @check -j $(JOBS)
2323

24-
coverage:
25-
dune runtest --instrument-with bisect_ppx --force --profile=$(RELEASE) -j $(JOBS)
26-
bisect-ppx-report html
27-
bisect-ppx-report summary --per-file
28-
2924
clean:
3025
dune clean
3126

Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
---
2+
title: Host NTP and time config API
3+
layout: default
4+
design_doc: true
5+
revision: 1
6+
status: proposed
7+
---
8+
9+
# Host NTP and time
10+
11+
## Background
12+
13+
There are no APIs to config the NTP and timezone on the host. Previously, users
14+
had to login on the host via ssh and configure NTP and time manually. The goal
15+
of this feature is to introduce new APIs in XAPI to support NTP and time
16+
configuration, especially in the scenario that users disable ssh service on the
17+
host. XAPI can also store the NTP and timezone configuration in XAPI DB to provide
18+
cache for the getter APIs.
19+
20+
## Use cases
21+
22+
- User can set time zone of the host via XenAPI
23+
- User can get valid time zones list to set via XenAPI
24+
- User can get the current time zone of the host via XenAPI
25+
- User can set custom NTP servers via XenAPI
26+
- User can get the current custom NTP servers via XenAPI
27+
- User can enable/disable NTP service via XenAPI
28+
- User can get the current NTP service enabled or disabled via XenAPI
29+
- User can set NTP to use DHCP assigned servers via XenAPI
30+
- User can set NTP to use custom servers via XenAPI
31+
- User can set NTP to use default NTP servers via XenAPI
32+
- User can get the DHCP assigned NTP servers via XenAPI
33+
- User can get status of current NTP servers via XenAPI
34+
- User can get NTP sync status via XenAPI
35+
- User can set host’s time when NTP is disabled via XenAPI
36+
37+
## NTP configuration on the host
38+
39+
New fields:
40+
`host.ntp_mode`, enum host_ntp_mode(DHCP, Custom, Factory, Disabled)
41+
`host.ntp_custom_servers`, string set
42+
43+
New APIs: `host.set_ntp_mode`, `host.set_ntp_custom_servers`, `host.get_ntp_mode`,
44+
`host.get_ntp_custom_servers`, `host.get_ntp_servers_status`
45+
46+
Abstract the NTP configuration to 4 modes.
47+
- DHCP: set NTP to use DHCP assigned NTP servers
48+
- Custom: set NTP to use custom NTP servers
49+
- Factory: set NTP to use factory NTP servers
50+
- Disabled: disable NTP service
51+
52+
### DHCP mode
53+
54+
In this mode, NTP uses the DHCP assigned NTP servers as sources.
55+
56+
How the NTP and DHCP interaction?
57+
58+
On the host, dhclient executes `/etc/dhcp/dhclient.d/chrony.sh` to update the
59+
ntp servers when network event happens.
60+
- `chrony.sh` writes ntp servers to `/run/chrony-dhcp/$interface.sources`
61+
- Chonryd include the dir `/run/chrony-dhcp` by `sourcedir /run/chrony-dhcp` in
62+
the conf file
63+
- `chrony.sh` runs `chronyc reload sources` to reload NTP sources
64+
65+
Then NTP sources can be updated automatically in the DHCP mode
66+
67+
How to switch DHCP mode?
68+
69+
Dhclient stores dhcp lease in `/var/lib/xcp/dhclient-$interface.leases`, see
70+
module Dhclient in `/ocaml/networkd/lib/network_utils.ml`.
71+
72+
When switch the NTP mode to DHCP, XAPI
73+
- check ntp server item in the lease and fills it in chrony-dhcp files
74+
- Add the exec permission of `chrony.sh`
75+
- Remove all the NTP source items(Custom or Factory) in chronyd conf
76+
- Restart chronyd
77+
78+
When switch ntp mode from dhcp to others, XAPI
79+
- Remove the chrony-dhcp files
80+
- Remove the exec permission of chrony.sh
81+
- Add NTP source items(Custom or Factory) in chronyd conf
82+
- Restart chronyd
83+
84+
### Custom mode
85+
86+
In this mode, NTP uses `host.ntp_custom_servers` as sources.
87+
88+
When switch the NTP mode to Custom, XAPI
89+
- Remove NTP source items in chronyd conf
90+
- Add `host.ntp_custom_servers` as NTP source items in chronyd conf
91+
- Restart chronyd
92+
93+
When `host.ntp_custom_servers` changes and `host.ntp_mode` is Custom, set chronyd
94+
conf with new custom servers and restart chronyd.
95+
96+
### Factory mode
97+
98+
In this mode, ntp uses `factory-ntp-servers` in XAPI config file. Generally the
99+
factory-ntp-servers will be defined by the product.
100+
101+
### Disabled mode
102+
103+
This mode disables NTP service on the host.
104+
105+
### Others
106+
107+
`host.get_ntp_servers_status` calls `chronyc -c sources` to get ntp servers status.
108+
Output parse:
109+
```
110+
Source mode: '^' = server, '=' = peer, '#' = local clock.
111+
Source state: '*' = current synced, '+' = combined, '-' = not combined,
112+
'?' = unreachable, 'x' = time may be in error, '~' = time too variable
113+
```
114+
115+
## Timezone configuration on the host
116+
117+
New field: `host.timezone`, string
118+
119+
New APIs: `host.set_timezone`, `host.get_timezone`, `host.list_timezones`
120+
121+
The timezone is in IANA timezone database format. Timezone on the host can be
122+
get by `realpath /etc/localtime` which is linked to timezone file under
123+
`/usr/share/zoneinfo/`. It can set by link`/etc/localtime` to
124+
`/usr/share/zoneinfo/<timezone>`. All the valid timezones are actually the files
125+
under `/usr/share/zoneinfo/`.
126+
127+
Comparing to using a fixed UTC offset, the benefit is:
128+
- User-friendly: familiar region names and same with most system facilities.
129+
- Handles daylight saving time (DST) automatically
130+
131+
They are equivalent to the `timedatectl` commands
132+
```
133+
timedatectl set-timezone
134+
timedatectl status | grep "Time zone"
135+
timedatectl list-timezones
136+
```
137+
138+
## Time on the host
139+
140+
New API: `host.get_ntp_synchronized`, `host.set_servertime`
141+
142+
`host.get_ntp_synchronized` shows if the system time is synchronized with NTP
143+
source.
144+
145+
`host.set_servertime` offers an API to set the server time when NTP disabled.
146+
it accepts a RFC3339 datetime format timestamp with timezone, i.e. ends with 'Z'
147+
to represent the UTC or explicit UTC offset like '+05:00'.
148+
149+
## Dbsync and restriction
150+
151+
For the new fields in this doc, on XAPI start, dbsync will get the real host
152+
status and sync to XAPI DB to make the real host status and XAPI DB consistent.
153+
Upgrade case can also be benefited from the dbsync.
154+
155+
If the user changes the config behind XAPI, like modify the chronyd conf directly
156+
via ssh, the real status on the host and XAPI DB come to inconsistent and may
157+
lead to unpredicted result, unless restart XAPI.
158+
159+
## Usage examples
160+
161+
Set NTP DHCP mode and get the status
162+
```python
163+
session.xenapi.host.set_timezone(host_ref, 'UTC')
164+
session.xenapi.host.set_ntp_mode(host_ref, 'DHCP')
165+
session.xenapi.host.get_ntp_synchronized(host_ref)
166+
session.xenapi.host.get_ntp_servers_status(host_ref)
167+
```
168+
169+
Set NTP Custom mode and get the status
170+
```python
171+
session.xenapi.host.set_timezone(host_ref, 'Europe/London')
172+
servers = ['time.server1.com', 'time.server2.com', 'time.server3.com']
173+
session.xenapi.host.set_ntp_custom_servers(host_ref, servers)
174+
session.xenapi.host.set_ntp_mode(host_ref, 'Custom')
175+
session.xenapi.host.get_ntp_synchronized(host_ref)
176+
session.xenapi.host.get_ntp_servers_status(host_ref)
177+
```
178+
179+
Set NTP default mode and get the status
180+
```python
181+
session.xenapi.host.set_ntp_mode(host_ref, 'Factory')
182+
session.xenapi.host.get_ntp_synchronized(host_ref)
183+
session.xenapi.host.get_ntp_servers_status(host_ref)
184+
```
185+
186+
Disable NTP and set server time
187+
```python
188+
session.xenapi.host.set_timezone(host_ref, 'Europe/London')
189+
session.xenapi.host.set_ntp_mode(host_ref, 'Disabled')
190+
session.xenapi.host.set_servertime(host_ref, "20251105T16:11:55Z")
191+
```
192+
193+
## APIs summary
194+
195+
```
196+
host.ntp_mode
197+
host.ntp_custom_servers
198+
host.timezone
199+
200+
host.set_timezone
201+
host.list_timezones
202+
host.get_timezone
203+
host.get_ntp_synchronized
204+
host.set_ntp_mode
205+
host.get_ntp_mode
206+
host.set_ntp_custom_servers
207+
host.get_ntp_custom_servers
208+
host.get_ntp_servers_status
209+
host.set_servertime
210+
```

doc/content/design/numa.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
+++ title = "NUMA" +++
1+
---
2+
title: NUMA
3+
layout: default
4+
design_doc: true
5+
revision: 1
6+
status: proposed
7+
---
28

39
# NUMA
410

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
---
2+
title: Trusted certificates for identity validation in TLS connections
3+
layout: default
4+
design_doc: true
5+
revision: 1
6+
status: draft
7+
---
8+
9+
# Overview
10+
11+
In various use cases, TLS connections are established on the host on which XAPI runs.
12+
When establishing a TLS connection, the peer identity needs to be validated.
13+
This is done using either a root CA certificate to perform certificate chain validation, or a known peer certificate for validation with certificate pinning.
14+
The root CA certificates and peer certificates involved in this process are referred to as trusted certificates.
15+
When a trusted certificate is installed, the local endpoint can validate the peer identity during TLS connection establishment.
16+
Certificate chain validation is a general-purpose, standards-based approach but requires additional steps, such as getting the peer's certificate signed by a CA.
17+
In contrast, certificate pinning offers a quicker way to set up trust in some cases without the overhead of CA signing.
18+
For example, when establishing a TLS connection, the peer endpoint presenting a self-signed server certificate, the local endpoint, after explicit user confirmation, can set up the trust by pinning the server certificate for this peer.
19+
For subsequent connections, the local endpoint validates the peer against the pinned certificate.
20+
This allows the use case to start in quicker and easier way without prior CA signing and without compromising security.
21+
22+
As the unified API for the whole system, XAPI also exposes interfaces for users to install and manage trusted certificates that are used by system components for different purposes.
23+
24+
The base design described in [pool-certificates.md](https://github.com/minglumlu/xen-api/blob/5d1ea1520825d502c57a90a02db476cd7d6a9132/doc/content/design/pool-certificates.md) defines the database, API, and trust store in the filesystem for managing trusted certificates.
25+
This document introduces the following enhancements to that design:
26+
27+
* Explicit separation of root CA certificates and peer certificates:
28+
In the base design, both certificate types share the same database schema, APIs, and are stored together in a single bundle file.
29+
This makes it difficult to determine the appropriate validation approach based on the certificate type.
30+
The improvement introduces a type value to separate root CA certificates and peer certificates explicitly.
31+
32+
* Add a "purpose" attribute for trusted certificates:
33+
According to the base design, only certificates used for internal TLS connections among XAPI processes within a pool are stored separately.
34+
All other trusted certificates are grouped in a single bundle, which may include certificates for multiple purposes.
35+
By introducing a "purpose" attribute, certificates can be organized by their intended use, improving clarity and reducing ambiguity.
36+
37+
# Use Cases
38+
* An XAPI client establishes a TLS connection to an XAPI service.
39+
This case is outside the scope of trusted certificates managed by XAPI and is included here only for completeness.
40+
* An XAPI process on one host initiates a TLS connection to an XAPI process on another host within the same pool.
41+
This case is covered in the base design and is listed here for completeness.
42+
* An XAPI process initiates a TLS connection to an external service, such as an appliance.
43+
This case benefits from the improvements introduced in this design.
44+
* A non-XAPI process (like licensing agent) running on a host managed by XAPI initiates a TLS connection to an external service, such as a License Server.
45+
This case benefits from the improvements introduced in this design as well.
46+
47+
48+
# Changes
49+
## Database schema
50+
The *Certificate* class in database is defined to represent general certificates, including trusted certificates.
51+
One existing class field "type" supports the following enumeration values:
52+
* "ca": trusted certificates including both root CA and peer.
53+
* "host": identity certificate of a host for communication with entities outside the pool.
54+
* "host_internal": identity certificate of a host for communication with other pool members.
55+
56+
Two improvements in this design:
57+
* A new value "peer" is introduced in this design so that the existing "ca" now represents trusted root CA only.
58+
The new "peer" will represent trusted peer certificates.
59+
60+
* A new enumeration type "purpose" is introduced to indicate the intended usage of a trusted certificate.
61+
A new *Certificate* class field "purpose" (a set of values of enumeration type "purpose") will be added to represent all applicable purposes of a trusted certificate.
62+
By default, this set is empty which corresponds to the existing "ca" certificates for general purpose.
63+
64+
## API
65+
66+
### pool.install_ca_certificate
67+
68+
This is an existing API to install a trusted certificate into the pool with its arguments being defined as:
69+
* session (ref session_id): reference to a valid session;
70+
* name (string): the name of the certificate;
71+
* cert (string): the certificate in PEM format.
72+
73+
Prior to this design, the API's name parameter represents the certificate file name as persisted on the dom0 file system.
74+
In this design, this API will be deprecated because it exposes implementation details that should remain internal and hidden from users.
75+
The new "pool.install_trusted_certificate" should be used instead.
76+
For the same reason, "pool.uninstall_ca_certificate" will also be deprecated.
77+
78+
### pool.install_trusted_certificate
79+
This is a new API introduced in this design with its arguments being defined as:
80+
* session (ref session_id): reference to a valid session;
81+
* self (ref Pool): reference to the pool;
82+
* ca (boolean): the trusted certificate is a root CA certificate used to verify a chain (true), or a peer certificate used for certificate pinning (false);
83+
* cert (string): the trusted certificate in PEM format;
84+
* purpose (string list): the purposes of the trusted certificate.
85+
86+
This new API is used to install trusted certificate.
87+
When *purpose* is an empty set, it stands for a root CA certificate for general purpose.
88+
The *purpose* can not be an empty set when the *ca* is false, because each peer certificate is specific to a single server and therefore unsuitable for a shared trusted certificate for general purpose.
89+
90+
It returns *void* when succeed. Otherwise, return corresponding API error.
91+
92+
### pool.uninstall_trusted_certificate
93+
This is a new API introduced in this design to uninstall a trusted certificate with its arguments being defined as:
94+
* session (ref session_id): reference to a valid session;
95+
* certificate (ref Certificate): reference to the trusted certificate;
96+
* force (bool): remove the database entry even if the file doesn't exist.
97+
98+
It returns *void* when succeed. Otherwise, return corresponding API error.
99+
100+
### pool.join
101+
Prior to this design, trusted certificates are exchanged between the pool and the joining host during the pre‑join phase.
102+
This design preserves that behavior to ensure the joiner works correctly both before and after joining the pool.
103+
104+
### pool.eject
105+
The trusted certificates will be removed from any host which is being eject from the pool.
106+
107+
### Other APIs of managing trusted certificates
108+
The install/uninstall APIs above are not the only ways of managing the trusted certificates.
109+
A particular API, e.g. "pool.set_wlb_url", may also install the trusted certificate used to validate the WLB server on subsequent TLS connections.
110+
However, regardless of the entry point, all trusted certificates must be represented by a *Certificate* database object and stored in the same way described below as if installed by the install APIs.
111+
112+
## Trust store
113+
The trusted certificates are stored in individual hosts' filesystems.
114+
The existing stores defined in the base design are:
115+
| Name | Filesystem location | User-configurable | Used for |
116+
| ---- | ------------------- | ----------------- | -------- |
117+
| Trusted Default | /etc/stunnel/certs/ | yes (using API) | Certificates that users can install for trusting appliances
118+
| Trusted Pool | /etc/stunnel/certs-pool/ | no | Certificates that are managed by the pool for host-to-host communications
119+
| Default Bundle | /etc/stunnel/xapi-stunnel-ca-bundle.pem | no | Bundle of certificates that hosts use to verify appliances (in particular WLB), this is kept in sync with "Trusted Default"
120+
| Pool Bundle | /etc/stunnel/xapi-pool-ca-bundle.pem | no | Bundle of certificates that hosts use to verify other hosts on pool communications, this is kept in sync with "Trusted Pool"
121+
122+
Regarding the "User-configurable", when it is "yes", it means a user can only install and remove the file with "name" parameter of "pool.install_ca_certificate" ; when it is "no", it means the user can't install or remove it even via APIs. In any cases, a user can't change the certificate files directly.
123+
124+
When a trusted certificate is being installed via "pool.install_ca_certificate", the trusted certificate will be stored in the "Trusted Default" and "Default Bundle".
125+
This design doesn't change this for backwards compatibility. But the API "pool.install_ca_certificate" will be marked as *deprecated*.
126+
127+
The pool "Trusted Pool" and "Pool Bundle" are for host-to-host TLS communications within a pool. This design doesn't change them.
128+
129+
The stores for the certificates installed via "pool.install_trusted_certificate" are defined as:
130+
| Name | Filesystem location | Used for |
131+
| ---- | ------------------- | -------- |
132+
| Trusted General CA | /etc/trusted-certs/ca-general/ | Trusted root CA certificates that users can install to validate a peer’s identity when establishing a TLS connection for general purpose.
133+
| Trusted Peer | /etc/trusted-certs/peer-\<PURPOSE\>/ | Trusted peer certificates that users can install to validate a peer’s identity when establishing a TLS connection for \<PURPOSE\>.
134+
| Trusted CA | /etc/trusted-certs/ca-\<PURPOSE\>/ | Trusted root CA certificates that users can install to validate a peer’s identity when establishing a TLS connection for \<PURPOSE\>.
135+
| General Bundle | /etc/trusted-certs/ca-bundle-general.pem | Bundle of trusted root CA certificates under /etc/trusted-certs/ca-general/ to verify a peer's identity when establishing a TLS connection for general purpose.
136+
| Peer Bundle | /etc/trusted-certs/peer-bundle-\<PURPOSE\>.pem | Bundle of trusted peer certificates under /etc/trusted-certs/peer-\<PURPOSE\>/ to verify a peer's identity when establishing a TLS connection for \<PURPOSE\>.
137+
| CA Bundle | /etc/trusted-certs/ca-bundle-\<PURPOSE\>.pem | Bundle of trusted root CA certificates under /etc/trusted-certs/ca-\<PURPOSE\>/ to verify a peer's identity when establishing a TLS connection for \<PURPOSE\>.
138+
139+
The filesystem location is derived from the \<PURPOSE\>. Each \<PURPOSE\> string corresponds to a predefined value of the "purpose" type in the database, implemented as predefined constants.
140+
The certificate file names under filesystem locations of "Trusted General CA", "Trusted Peer" and "Trusted CA" will be the UUIDs of the *Certificate* objects.
141+
142+
## Precedence order of choosing trust stores
143+
The "Peer Bundle", "CA Bundle", and "Default Bundle" can be directly used when establishing TLS connections.
144+
The endpoint to validate the peer's identity must unambiguously choose only one non-empty bundle from them with the following precedence order:
145+
1. "Peer Bundle"
146+
2. "CA Bundle"
147+
3. "General Bundle"
148+
149+
No more attempts on remaining bundles when validation with the selected one fails (the server certificate is not trusted by the selected bundle).
150+
151+
For example, if "Peer Bundle" doesn't exist and the "CA Bundle" (if not empty) is selected to do the validation, the endpoint should not try with "General Bundle" even when the validation with "CA Bundle" failed.

0 commit comments

Comments
 (0)