Repository navigation
Merge master into feature/mig - #7346
Merged
GabrielBuica merged 121 commits intoOct 21, 2026
Merged
GabrielBuica merged 121 commits into
GabrielBuica merged 121 commits into
Conversation
Signed-off-by: Ming Lu <ming.lu@cloud.com>
Add an Lldp module that manages lldpd via lldpcli to advertise the LLDP information for individual physical NICs on a host. This is done by the networkd interface `Interface.make_config`. lldpd is a user space LLDP agent running in dom0. lldpcli is a client to configure/query LLDP TLVs to/from lldpd. Signed-off-by: Ming Lu <ming.lu@cloud.com>
One of the advertising LLDP TLV is management address(es) of the host. This data is shared by the NICs with LLDP feature enabled. However, the address(es) on management interface on a host may change. This change can be caught by network_monitor_thread. Consequently, a callback is carried out to update this specific LLDP TLV configuration. Signed-off-by: Ming Lu <ming.lu@cloud.com>
This is for the safety of using CNA or hardware iSCSI in which case the NIC and a storage function share the same hardware. Enabling LLDP on such NICs may fail the corresponding storage function. Users can enable it with PIF level configuration if it is confirmed no impact on the storage function. Signed-off-by: Ming Lu <ming.lu@cloud.com>
…ldpd
Some NICs run an LLDP agent in firmware, which would conflict with
lldpd. Before enabling LLDP on an interface, disable the firmware agent
on a best-effort basis via ethtool private flags ("disable-fw-lldp" and
"fw-lldp-agent").
The "best-effort" means that not all NICs support firmware LLDP; for the
supported ones, not all can be turned off from dom0. Users can turn off
the firmware LLDP from UEFI host settings.
Overall, the conflict is not supposed to impact other functions. So it's
a try on best-effort.
Signed-off-by: Ming Lu <ming.lu@cloud.com>
This is the first PR of LLDP feature. The overall design doc is https://github.com/xapi-project/xen-api/blob/master/doc/content/design/lldp.md The PR is for managing a LLDP agent (and one implementation `lldpd`) and configuring for individual NICs through LLDP client. Cache is used to avoid unnecessary calls of LLDP client as most of configurations are shared by NICs.
Add the XAPI database fields and enums for the LLDP feature: - pool.lldp_enabled (bool, DynamicRO): pool-wide LLDP toggle. Fresh-install default is true (set in create_pool_record); the datamodel default_value is false, which is the value applied on update/RPU from a release without LLDP. - pool.lldp_multicast_address (enum lldp_multicast_address, RW): the multicast MAC address group used for LLDP advertising. - PIF.lldp_mode (enum pif_lldp_mode, DynamicRO): per-PIF override of the pool-wide setting (default | enabled | disabled). All existing Db.PIF.create and Db.Pool.create call sites are updated to pass the new fields. Signed-off-by: Changlei Li <changlei.li@citrix.com>
Add the XenAPI messages and their implementations, forwarding and CLI: - pool.set_lldp_enabled (self, value, force): sets pool.lldp_enabled and, for every managed physical PIF, re-applies the LLDP configuration via PIF.plug, returning a map of PIFs that failed and their error message. When force is false and value already matches the current setting it is a no-op returning an empty map. - PIF.set_lldp_mode (self, value, force): sets PIF.lldp_mode on a managed physical PIF and re-applies via PIF.plug. Non-physical PIFs are rejected with PIF_IS_NOT_PHYSICAL. For bond members, applies lldp config via pluging their bond master PIF. CLI: 'xe pool-set-lldp-enabled', 'xe pif-set-lldp-mode', and read-only param-list fields lldp-enabled, lldp-multicast-address (settable via pool-param-set) and lldp-mode. Signed-off-by: Changlei Li <changlei.li@citrix.com>
When bringing up the NIC of a managed physical PIF, build the networkd LLDP record from the XAPI database and include it in the interface configuration passed to networkd, replacing the previous hard-coded 'lldp = None'. The effective state resolves the configuration matrix: PIF.lldp_mode of enabled/disabled overrides pool.lldp_enabled, and 'enabled' additionally sets 'force' so networkd overrides its NIC-driver blocklist. The chassis id, system name and description are taken from the host, and the multicast address from pool.lldp_multicast_address. Signed-off-by: Changlei Li <changlei.li@citrix.com>
Apply the LLDP change to networkd only for PIFs that are currently attached; an unplugged PIF has its DB value updated and picks up the setting the next time it is brought up. This avoids bringing up interfaces that were deliberately down as a side effect of a pure LLDP configuration change. PIF.set_lldp_mode re-plugs the target (self, or the bond master for a bond member) only if it is currently_attached; pool.set_lldp_enabled re-plugs only currently-attached standalone physical PIFs and bond masters. Signed-off-by: Changlei Li <changlei.li@citrix.com>
'default' is a reserved keyword in C#, which breaks the generated SDK. Rename the pif_lldp_mode enum value to 'inherited' (it means the PIF follows pool.lldp_enabled) and update the field default, descriptions, CLI help accordingly. Signed-off-by: Changlei Li <changlei.li@citrix.com>
Signed-off-by: Changlei Li <changlei.li@citrix.com>
Signed-off-by: Changlei Li <changlei.li@citrix.com>
Design doc: https://github.com/xapi-project/xen-api/blob/master/doc/content/design/lldp.md New fileds: pool.lldp_enabled pool.lldp_multicast_address (RW) pif.lldp_mode APIs: pool.set_lldp_enabled PIF.set_lldp_mode CLI: xe pool-set-lldp-enabled xe pif-set-lldp-mode
Add a DynamicRO map(string, string) field that exposes the effective LLDP state (enabled/disabled/blocked) and the received neighbour TLVs (system_name, port_id, port_description) of the physical NIC. Pass it at the PIF_metrics create sites, show it via the xe CLI, and document the field in the LLDP design doc. Signed-off-by: Changlei Li <changlei.li@citrix.com>
Add lldp_rx (LLDP state plus neighbour fields) to the shared network stats. networkd parses `lldpcli -f json0 show neighbors` for the neighbour and `show interfaces` for the state (rx-and-tx is Enabled, otherwise Blocked when the driver is in the blocklist, else Disabled), and records both in /dev/shm/network_stats. Signed-off-by: Changlei Li <changlei.li@citrix.com>
Cover Lldp.parse_neighbors, parse_enabled_interfaces and state_of. Signed-off-by: Changlei Li <changlei.li@citrix.com>
Monitor_dbcalls reads lldp_rx from the network stats and writes it to PIF_metrics.lldp_neighbor as a string map (state plus neighbour keys), with change detection to avoid redundant database writes. Signed-off-by: Changlei Li <changlei.li@citrix.com>
Signed-off-by: Changlei Li <changlei.li@citrix.com>
…t#7231) PIF_metrics.lldp_neighbor, Map (String, String), the received LLDP TLVs from the corresponding PIF Example: “state”: “enabled”, “system_name”: “EU1-ESWA04-7”, “port_id”: “ifname Eth1/8/3”, “port_description”: “genuk-37-13-nap/eth2_(nsec)”
Lldp settings lookup the management interface via Inventory.lookup. This method reads from inventory cache. Unlike xapi, the inventory cache is not maintained well in networkd. So Lldp may get a stale management interface when it sets management address tlv by the signal_networking_change. Now reread the inventory to refresh the inventory cache in networkd to get the right management interface. Signed-off-by: Changlei Li <changlei.li@citrix.com>
The lldpd service is only started when the first PIF enables LLDP. Until then, the periodic (30s) neighbour/interface queries and the disable commands still invoked lldpcli, which failed and logged errors - most noticeably when LLDP is disabled on all PIFs. Track whether networkd has started the service and short-circuit lldpcli calls with a Service_not_running error while it has not. A genuine outage after a successful start is still surfaced, since the flag is only set on success and reflects networkd's intent to run the service. This mechanism is wrapped in the public function call_cli, so can provide the consistent behavior when call cli. Signed-off-by: Changlei Li <changlei.li@citrix.com>
Change the map result to void and report failures as API errors instead, for better UI showing. An LLDP configuration failure is applied best-effort inside networkd and swallowed as a warning (it must not block PIF.plug), so it can never appear in such a map anyway. The re-plug itself can still genuinely fail: attempt every affected PIF, collect the ones whose re-plug fails, and if any did, raise LLDP_PIF_REPLUG_FAILED with the list so the user sees which PIFs certainly did not get the new LLDP setting. - datamodel: remove the ~result clause; add the LLDP_PIF_REPLUG_FAILED error - xapi: re-plug affected PIFs with List.filter_map, raising on failures; PIF.set_lldp_mode raises the same error when its re-plug fails - CLI: drop the failure table and just invoke the API Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Changlei Li <changlei.li@citrix.com>
PIF_metrics.lldp_neighbor strings originate from a neighbour's LLDP TLVs
via lldpcli, so they are untrusted. Sanitise each of the three values
(system_name, port_id, port_description) as it is parsed:
- verify UTF-8 encoding, discarding a value with any malformed byte
sequence rather than repairing it (Yojson passes raw bytes through);
- remove control characters (C0, DEL and C1);
- truncate to 256 bytes, stopping on a UTF-8 codepoint boundary so the
result stays valid UTF-8.
Adds a uutf dependency for the UTF-8 fold, with unit tests covering
truncation (codepoint boundary, exact-fit, no-split), malformed-UTF-8
rejection (per-field), and control-character stripping.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Changlei Li <changlei.li@citrix.com>
An API error is declared in two places: add_error in ocaml/xapi-consts/api_errors.ml makes it raisable, and the error function in ocaml/idl/datamodel_errors.ml declares its parameters and puts it in the generated SDK and the error reference. Nothing checked that both happened, so a code with only the first compiles, is raisable, and reaches a client as a string that appears in no reference. Add test_error_registration to the tests stanza under ocaml/idl. It folds the two lists against each other and names any code present in one and absent from the other. Both are read at run time rather than parsed out of the source, because api_errors.ml builds the AUTH_ENABLE_FAILED_* family by concatenation and those codes have no string literal for a textual lint to find. Thirteen codes are declared today with no datamodel entry. They are listed by name in the test, so each can be discharged on its own, and the number of codes missing an entry is checked against the size of that list. Registering a code and deleting its line keeps the two in step; a code declared in only one place widens the gap and fails. Three of the thirteen are raised: VDI_IO_ERROR, REVERT_ONLY_ALLOWED_ON_SNAPSHOT and CLIENT_ERROR. Registering those needs a parameter list and a doc string for each, which is a separate change. The test collects its checks as a list and derives the exit code from it rather than relying on assert. Every check is generated by iterating one of the two lists, so a list that comes back empty yields no checks rather than failing ones; the test exits 2 rather than 0 in that case. It was made to fail on purpose four ways before being relied on: a code declared and not registered, an entry registered as a bare string and not declared, a listed code that has since been registered, and a list that comes back empty. Delete ocaml/idl/errors.sh, which attempted the same comparison and was referenced by no dune file, makefile or script. It greps datamodel.ml rather than datamodel_errors.ml, matches the OCaml binding name rather than the error string, and exits zero whatever it finds. Signed-off-by: Gabriel Buica <danutgabriel.buica@citrix.com>
Signed-off-by: Ming Lu <ming.lu@cloud.com>
A missing piece in 4c1209e `v26.21.0` has been tagged. With this fix, `v26.21.1` will be tagged. Unfortunately, wildcard * doesn't work. So next time it may be missed again.
The HVM PIRQ feature is known to have compatibility issues with some AMD GPUs. It has been disabled by default in Xenlight version 024e7131be5c. Change the HVM PIRQ default setting to false on fresh boots. However, HVM PIRQ is needed for VMs using VGPU, so we need to keep the default as true on these VMs. To XenServer team: Would it be possible to test this PR further to find all other VM configurations that need HVM PIRQ to be enabled (like VGPU)?
Re raising xapi-project#7317 against master.
…pi-project#7314) These are the only non-oneshot units that aren't part of `toolstack.target`, so wouldn't be restarted on an update with `xe-toolstack-restart`. I'm pretty sure this was accidental for `xapi-nbd`, but I'm wondering if it was intentional for `xapi-ssh-monitor` for some reason?
Reading a small configuration file with the existing helpers, such as Unixext.string_of_file or Unixext.read_lines, blocks if the path is a FIFO with no writer, reads without limit from a device such as /dev/zero, and raises on errors. A daemon that reads such a file for every operation must not hang, grow or fail because of what is there. Add Unixext.read_small_regular_file, which never blocks, reads at most a given number of bytes, and never raises. It only opens the path if stat says it is a regular file, so that a FIFO or a device is not opened. It opens the file non-blocking, checks with fstat that what it opened is a regular file, and reads at most max_bytes + 1 bytes. A missing file gives Ok None, a regular file of at most max_bytes bytes gives Ok (Some content), and anything else gives Error with the reason. Also add a test covering small and oversized files, a missing file, symlinks, a directory, a device and a FIFO with no writer. Signed-off-by: Marcus Granado <marcus.granado@citrix.com>
… unset xenopsd uses kTLS for the migrations a host sends only when its xenopsd.conf sets migration-tls = "ktls"; an empty or absent option means stunnel. So `xe-enable-experimental-feature migration_ktls`, the way the plans in doc/content/design/migration-tls.md (R1.1.1) says a host should opt in, currently has no effect. The goal is that the migration_ktls experimental feature flag enables kTLS for the migrations a host sends, while an explicit migration-tls in xenopsd.conf still overrides the decision on that host. The transport is now chosen once per migration: - if migration-tls set to "ktls" or "stunnel": use that value. An unknown value means stunnel, and the flag does not override it. - if migration-tls unset (the default, now distinct from "stunnel"): kTLS if /etc/xenserver/features.d/migration_ktls is on, otherwise stunnel. The file is read with Unixext.read_small_regular_file and parsed as v6d parses it, so 1 and true are on. An unusable file or an unrecognised value means stunnel, with a warning. The choice is logged with what made it, and passed to the vm, mem and vgpu connections of the migration, so that a flag changed during a migration cannot mix transports. The flag is not licence-gated yet; a comment marks where a licence check would go in a future planned PR that will integrate the licensing decisions with experimental flags in the host. Also: the feature-flags-path option now sets the directory read here; a test covers the order of precedence and the flag parsing; the design document, the helper README, the sample xenopsd.conf and the helper's resource description are updated to match. Signed-off-by: Marcus Granado <marcus.granado@citrix.com>
The overall latency datasource for an SR comes from a different module than read_latency/write_latency and was left aggregating with max, so it reports the worst single VDI's mean rather than the SR's. Beside two datasources that are now request-weighted means it is comparable with neither, and can read below read_latency whenever writes are fast and numerous enough to pull each VDI's combined mean under the SR-wide read mean. The first-sample rule was missing here as well: with no reading from five seconds ago the delta was the whole lifetime counter, so a newly plugged VDI contributed a lifetime average and an avgqu_sz spike that max carried straight to the SR figure. The iostat fallback took await from the wrong column. Index 9 is r_await on sysstat 10 and svctm on sysstat 9; await is 8 in both layouts, as the existing avgqu-sz index confirms. It now also carries the request rate as its weight, so a fallback VDI counts for its share of an SR that also has blktap3 VDIs rather than for a single request. Per-VBD values are unchanged, except on the first sample after a VDI appears where the lifetime average is replaced by zero. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Mark Syms <mark.syms@citrix.com>
VM templates ship with sr="" by default. When installed via xe vm-install, this gets replaced by the default SR, but the API raises error UUID_INVALID because the empty string gets taken literally. Callers are supposed to fill this in themselves, but we see recurring issues when they don't. This commit makes the API match the CLI by falling back to the default SR when sr="" is specified on a template. Signed-off-by: Christian Pardillo Laursen <christian.pardillolaursen@citrix.com>
The debug log just above printed the correct versions:
debug [db_hiupgrade] Database schema version is (5, 800); binary schema version is (5, 799)
But the warn log printed the same string twice, confusingly:
warn [db_hiupgrade] Database schema version (5, 800) is more recent than binary (5, 800): downgrade is unsupported.
Fix the typo :)
Signed-off-by: Andrii Sultanov <andriy.sultanov@vates.tech>
Signed-off-by: Ming Lu <ming.lu@cloud.com>
The debug log just above printed the correct versions: debug [db_hiupgrade] Database schema version is (5, 800); binary schema version is (5, 799) But the warn log printed the same string twice, confusingly: warn [db_hiupgrade] Database schema version (5, 800) is more recent than binary (5, 800): downgrade is unsupported. Fix the typo :)
…erimental feature flag (xapi-project#7337) Currently, xenopsd only uses kTLS for the migrations that a host sends when its xenopsd.conf sets migration-tls = "ktls". `xe-enable-experimental-feature migration_ktls`, the way the plans in doc/content/design/migration-tls.md (R1.1.1) say a host should opt in, currently has no effect. This PR enables kTLS for the the migrations when that host's migration_ktls experimental feature is on, while an explicit migration-tls in xenopsd.conf still overrides the decision on that host. xenopsd now chooses the transport once per https migration: a) an explicit migration-tls in xenopsd.conf wins; b) otherwise kTLS is used if /etc/xenserver/features.d/migration_ktls is on (1 or true), else c) stunnel stays the default. An unusable file or an unrecognised value means stunnel, with a warning. The choice is logged with what made it and used for the vm, mem and vgpu connections of a migration. The flag is read with a new Unixext.read_small_regular_file, which never blocks on a FIFO or a device, reads a bounded amount and never raises; the design document, the sample xenopsd.conf and the helper's docs are updated. Tested with: * positive: with `xe-enable-experimental-feature migration_ktls` on both hosts, every migration logged "migration-tls: ktls (from /etc/xenserver/features.d/migration_ktls)" and used kTLS (2 kTLS sockets each, no fallback to stunnel): test job 4760693 (10-VM pool-master evacuation), and manual migrations in both directions, also tested with zstd compression on. * regression: BVT 252229, BST 252230 found no regressions. Every https migration sent by this build logged the expected line "migration-tls: stunnel (from /etc/xenserver/features.d/migration_ktls)", indicating no change of behaviour in the default case. XS8->XS9 migrations and the rolling upgrade from XS8 worked as expected.
VM templates ship with sr="" by default. When installed via xe vm-install, this gets replaced by the default SR, but the API raises error UUID_INVALID because the empty string gets taken literally. Callers are supposed to fill this in themselves, but we see recurring issues when they don't. This commit makes the API match the CLI by falling back to the default SR when sr="" is specified on a template.
If multiple hosts have installed a new SM plugin since the last toolstack restart and are restarting simultaneously, there's a race window between checking for registered plugins and registering a new one, which can lead to duplicate SM plugins being registered. I was not able to reproduce this myself, but we've seen this case in support: 12:00:00 hostA: dbsync (update_env) |xapi_sm] Xapi_sm.create_from_query_result Registering SM plugin linstor (version 1.0) 12:00:00 hostB: dbsync (update_env) |xapi_sm] Xapi_sm.create_from_query_result Registering SM plugin linstor (version 1.0) 12:00:00 hostA: dbsync (update_env) |storage_access] Storage_access.on_xapi_start: found duplicate SM plugins for the same type: type:linstor... Clean up these duplicate entries instead of just logging them. Sort the records by reference to get deterministic ordering from multiple hosts. Remove all but the first such duplicate record. Signed-off-by: Andrii Sultanov <andriy.sultanov@vates.tech>
Before this change, a newly created validation check in XenRT reported this. ``` [11:38:44 12/10] HOST(2687c73e-05df-4bcc-9754-69fc7f8207dc) RRD of AVERAGE read_latency_583db357: 59 comparable samples, worst aggregate/largest-member ratio 4.61 [11:38:44 12/10] t=1791804825 HOST(2687c73e-05df-4bcc-9754-69fc7f8207dc) RRD of AVERAGE read_latency_583db357=17768.0 exceeds largest member 6847.0 [11:38:44 12/10] t=1791804830 HOST(2687c73e-05df-4bcc-9754-69fc7f8207dc) RRD of AVERAGE read_latency_583db357=60023.0 exceeds largest member 25144.0 [11:38:44 12/10] t=1791804835 HOST(2687c73e-05df-4bcc-9754-69fc7f8207dc) RRD of AVERAGE read_latency_583db357=77610.0 exceeds largest member 21221.0 [11:38:44 12/10] t=1791804840 HOST(2687c73e-05df-4bcc-9754-69fc7f8207dc) RRD of AVERAGE read_latency_583db357=70145.0 exceeds largest member 22530.0 [11:38:44 12/10] t=1791804845 HOST(2687c73e-05df-4bcc-9754-69fc7f8207dc) RRD of AVERAGE read_latency_583db357=66606.0 exceeds largest member 27892.0 [11:38:44 12/10] t=1791804850 HOST(2687c73e-05df-4bcc-9754-69fc7f8207dc) RRD of AVERAGE read_latency_583db357=101371.0 exceeds largest member 42453.0 [11:38:44 12/10] t=1791804855 HOST(2687c73e-05df-4bcc-9754-69fc7f8207dc) RRD of AVERAGE read_latency_583db357=113430.0 exceeds largest member 30737.0 [11:38:44 12/10] t=1791804860 HOST(2687c73e-05df-4bcc-9754-69fc7f8207dc) RRD of AVERAGE read_latency_583db357=45043.0 exceeds largest member 23948.0 [11:38:44 12/10] t=1791804865 HOST(2687c73e-05df-4bcc-9754-69fc7f8207dc) RRD of AVERAGE read_latency_583db357=97787.0 exceeds largest member 26289.0 [11:38:44 12/10] t=1791804870 HOST(2687c73e-05df-4bcc-9754-69fc7f8207dc) RRD of AVERAGE read_latency_583db357=78488.0 exceeds largest member 34669.0 [11:38:44 12/10] t=1791804875 HOST(2687c73e-05df-4bcc-9754-69fc7f8207dc) RRD of AVERAGE read_latency_583db357=79010.0 exceeds largest member 27669.0 [11:38:44 12/10] t=1791804880 HOST(2687c73e-05df-4bcc-9754-69fc7f8207dc) RRD of AVERAGE read_latency_583db357=75286.0 exceeds largest member 28331.0 [11:38:44 12/10] t=1791804885 HOST(2687c73e-05df-4bcc-9754-69fc7f8207dc) RRD of AVERAGE read_latency_583db357=78877.0 exceeds largest member 34294.0 [11:38:44 12/10] t=1791804890 HOST(2687c73e-05df-4bcc-9754-69fc7f8207dc) RRD of AVERAGE read_latency_583db357=107517.0 exceeds largest member 37129.0 [11:38:44 12/10] t=1791804895 HOST(2687c73e-05df-4bcc-9754-69fc7f8207dc) RRD of AVERAGE read_latency_583db357=172680.0 exceeds largest member 37436.0 [11:38:44 12/10] t=1791804900 HOST(2687c73e-05df-4bcc-9754-69fc7f8207dc) RRD of AVERAGE read_latency_583db357=81336.0 exceeds largest member 29071.0 [11:38:44 12/10] t=1791804905 HOST(2687c73e-05df-4bcc-9754-69fc7f8207dc) RRD of AVERAGE read_latency_583db357=199452.0 exceeds largest member 124663.0 [11:38:44 12/10] t=1791804910 HOST(2687c73e-05df-4bcc-9754-69fc7f8207dc) RRD of AVERAGE read_latency_583db357=97007.0 exceeds largest member 31924.0 [11:38:44 12/10] t=1791804915 HOST(2687c73e-05df-4bcc-9754-69fc7f8207dc) RRD of AVERAGE read_latency_583db357=94462.0 exceeds largest member 37343.0 [11:38:44 12/10] t=1791804920 HOST(2687c73e-05df-4bcc-9754-69fc7f8207dc) RRD of AVERAGE read_latency_583db357=97979.0 exceeds largest member 26627.0 ``` After the fix the test case reports ``` [11:29:05 12/10] HOST(1ad3b2c1-b812-4d60-9174-83d0ffd81cc0) RRD of AVERAGE read_latency_9504dbb7: 60 comparable samples, worst aggregate/largest-member ratio 0.99 ``` This was reported to us by a large XenServer customer, who, rightly, didn't believe the latency data being presented.
…api-project#7319) ## The problem ```shell ./configure --xapi_version=v1912.6.23 # Turing's birth date make make install DESTDIR=/tmp/xapi /tmp/xapi/usr/sbin/xenopsd-xc --version ``` When `git describe` finds a tag, the last command prints its output instead of the configured version: ``` 26.20.0-29-g0af2b37-dirty ``` When it finds none, `git describe` returns a bare commit hash. `Xapi_version.parse_xapi_version` cannot parse it, and since this function is called when the `Xapi_version` module is initialised, xenopsd-xc aborts at startup, whatever its arguments: ``` Fatal error: exception Failure("Couldn't determine xapi version from string: '0af2b37-dirty'") ``` This happened in XCP-ng builds, for instance: xcp-ng-rpms/xapi#145 Eight other programs take their version from `git describe` in the same way, among them xcp-networkd, xcp-rrdd and squeezed. More generally, of the 19 installed programs that link `Xapi_version`, the module that holds the configured version, only one reports `1912.6.23` when invoked with `--version`. ## Its causes There are three causes, and they overlap: one cause can hide another. A program that aborts at startup because it gets its version from `git describe` (1) never gets a chance to show that it has no `--version` option (2), or that it reports a hard-coded version (3). Once they get the configured version instead, squeezed, varstored-guard and pvs-proxy-ovs-setup turn out to have no `--version` option (2), and sm-cli turns out to report a hard-coded version (3). 1. dune-build-info chooses the version it writes into a program as follows: - if the program belongs to a package that has a version, it writes that version, which here is the configured one; - otherwise, it writes the output of `git describe` when the program is installed, ignoring the version of the project. The nine programs mentioned above belong to no package: they are installed through an `(install)` stanza, and their `(executable)` stanza names none. 2. Many programs have no `--version` option: xapi, squeezed, varstored-guard, pvs-proxy-ovs-setup, mpathalert, event_listen, vncproxy, quicktestbin, gen_lifecycle, alert-certificate-check and daily-license-check. Some of them, xapi for instance, already use the configured version internally, but cannot show it. 3. Some programs report a hard-coded version: rrd2csv reports 0.1.3, and sm-cli, xapi-nbd, xenops-cli, vhd-tool, message-cli and qcow-stream-tool report 1.0.0. ## What this PR does This situation went unnoticed because nothing checked the version that installed programs report. The PR has two parts: it first adds the missing check, then removes the three causes described above. The first part (commits 1 to 3) sets up the check. The script check-versions.sh lists every installed program that links Xapi_version, together with what the program does when invoked with `--version`, and checks that it does exactly that. The CI runs it after `make install`. The check has three goals: 1. Document how each program behaves before any change. 2. Track the progress made by the fixes (commits 4 to 11). Since the causes overlap, fixing one of them sometimes changes how a program fails instead of making it succeed: once commit 4 removes the first cause, squeezed, varstored-guard and pvs-proxy-ovs-setup stop aborting and turn out not to recognise `--version`, and sm-cli turns out to report 1.0.0. The script makes such changes visible: a program that does not behave as listed makes the check fail, even when it does better, so each fix updates the script, and each commit message shows how the summary of check-versions.sh changes. 3. Keep the problem from coming back, as far as possible. An installed program that links Xapi_version but is not listed in the script makes the check fail. A program that does not link Xapi_version, however, goes unnoticed, although it may still need the configured version: the five programs fixed by commits 10 and 11 were such programs. For such programs, it is up to the programmer to use Xapi_version. Commit 3 changes the version the CI configures from 0.0.0 to 1912.6.23 (Alan Turing's birth date). 0.0.0 is the default of `Xapi_version.platform_version`, so a program could report it because it is a default, not because it was configured, and still pass the check. Nobody would type 1912.6.23 by accident: a program that reports it can only have got it from the configuration. The value is also easy to spot in a log. The check itself, however, does not depend on the configured version, which it reads from the configuration: it passes both before commit 3, with 0.0.0, and after, with 1912.6.23. The second part (commits 4 to 11) removes the causes one at a time. Commit 4 attaches the installed programs to their package, which removes cause (1). Commits 5, 6, 8 and 9 add a `--version` option where it was missing (2). Commits 6, 8, 10 and 11 replace hard-coded versions with the configured one (3). Commit 7 prepares commit 8: it makes sure quicktestbin does nothing before parsing its arguments. Commits 4 to 9 deal with programs that already link Xapi_version. Commits 10 and 11 deal with programs that did not link Xapi_version but reported a hard-coded 1.0.0: xapi-nbd and xenops-cli, then vhd-tool, message-cli and qcow-stream-tool. Commit 11 was added in response to @psafont's first review. Commit 4 attaches an executable to its package without installing it with `(public_name -)` and `(package ...)`. The documentation of the executable stanza is ambiguous about this combination, but it matches what it documents for the executables stanza, where `-` in `public_names` marks an executable that is not installed, and dune does attach the executable to the package. If that changed, check-versions.sh would detect it. Commits 12 and 13, also added in response to @psafont's review, change no version that programs report. When the version provided by dune-build-info cannot be parsed, programs that link Xapi_version still abort at startup, but commit 12 replaces the uncaught exception with a message that says how to configure a version. Commit 13 replaces `Xapi_version.compare_version`, which parsed both of its arguments, with `compare_to_local`, which compares a version with the one of the running program, already parsed when the module is initialised. The series is meant to be reviewed commit by commit. Each commit builds and passes the CI on its own. The message of commit 1 shows the summary of check-versions.sh before any fix, and the message of each commit that changes that summary says how. ## Visible changes - All 24 programs that now link `Xapi_version` report the configured version when invoked with `--version`. - rrd2csv used to print "rrd2csv version 0.1.3" followed by "(C) Citrix 2012" for both `--version` and `-v`. Both now print the configured version only. The copyright notice is no longer printed, but remains in the header of the source file. Is that acceptable? - quicktestbin no longer prints a qcheck seed, nor runs tput, before parsing its arguments. As a consequence, the message "tput: No value for $TERM", which appeared in the logs of the CI, is gone. - Eight opam packages now declare a dependency on xapi-consts, which provides Xapi_version. I will update xs-opam accordingly once this PR is merged. xapi-tools, xapi-storage-cli, varstored-guard, xapi-debug, xapi-nbd and vhd-tool already depended on it indirectly, so for them this changes nothing in what gets installed: the dependency is only made explicit. message-switch-cli and qcow-stream-tool, however, did not depend on xapi-consts before, even indirectly: installing them now also installs xapi-consts.
The two rules that run basic-rpc-test.sh, for the runtest and stresstest aliases, declared a dependency on ../cli/main.exe, which the script does not use. Signed-off-by: Seb Hinderer <sebastien.hinderer@vates.tech>
Fix a regression introduced by commit b69987e ("dune: attach installed executables to their package"): concur-rpc-test.sh stops the switch with message-cli, which that commit attached to the message-switch-cli package, so `dune runtest -p message-switch` failed with: Error: No rule found for ocaml/message-switch/cli/main.exe The tests now use a copy of message-cli, built from the same source and attached to message-switch without being installed. As message-cli uses Xapi_version, message-switch gets a test dependency on xapi-consts. Signed-off-by: Seb Hinderer <sebastien.hinderer@vates.tech>
…t alone (xapi-project#7343) Commit b69987e of PR xapi-project#7319 has introduced a regression: the tests of message-switch fail when the package is built and tested on its own, as happens when it is installed with its tests through opam (`opam install -t message-switch`): ``` ./configure dune build -p message-switch dune runtest -p message-switch ``` ``` Error: No rule found for ocaml/message-switch/cli/main.exe -> required by alias ocaml/message-switch/core_test/runtest in ocaml/message-switch/core_test/dune:32 ``` This was found by the CI of xs-opam. The CI of xen-api builds all packages together, so it could not see it. The first commit removes a dependency on message-cli that two test rules did not use. The second one makes the remaining test use a copy of message-cli attached to message-switch. message-switch now has a test dependency on xapi-consts. I will update xs-opam accordingly once this PR is merged. @last-genius: as xapi-project#7342 includes xapi-project#7319, it should include this PR too.
This is a continuation of xapi-project#6873 If multiple hosts have installed a new SM plugin since the last toolstack restart and are restarting simultaneously, there's a race window between checking for registered plugins and registering a new one, which can lead to duplicate SM plugins being registered. I was not able to reproduce this myself, but we've seen this case in support: 12:00:00 hostA: dbsync (update_env) |xapi_sm] Xapi_sm.create_from_query_result Registering SM plugin linstor (version 1.0) 12:00:00 hostB: dbsync (update_env) |xapi_sm] Xapi_sm.create_from_query_result Registering SM plugin linstor (version 1.0) 12:00:00 hostA: dbsync (update_env) |storage_access] Storage_access.on_xapi_start: found duplicate SM plugins for the same type: type:linstor... Clean up these duplicate entries instead of just logging them. Sort the records by reference to get deterministic ordering from multiple hosts. Remove all but the first such duplicate record.
Conflict in ocaml/idl/schematest.ml: last_known_schema_hash was recomputed for the merged datamodel (schema_minor_vsn 911 from master). Signed-off-by: Gabriel Buica <danutgabriel.buica@citrix.com>
cplaursen
approved these changes
Oct 21, 2026
mg12
approved these changes
Oct 21, 2026
mg12
added a commit
that referenced
this pull request
Nov 13, 2026
This updates feature/mig with the 75 commits that master has gained since the last merge, up to 0a1c669 (v26.24.0). One of them is #7386. It moves the "Static analyzer for OCaml C stubs" check to ubuntu-24.04, because CodeChecker uses apt-key, which ubuntu 26.04 no longer has. Without that change, the check fails on every pull request against feature/mig. Because feature/mig is protected, this is a merge commit, not a rebase. There was one conflict, in ocaml/idl/schematest.ml. last_known_schema_hash is recomputed for the merged datamodel, and schema_minor_vsn is master's 912. This is how #7346 handled the same conflict. Tested: built every directory under ocaml/, with the format checks of ocaml/idl, ocaml/xapi and ocaml/tests, and ran the ocaml/idl and ocaml/tests suites: all pass (2435 tests), including the schema test with the new hash.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.