Skip to content

Commit c368857

Browse files
authored
Sync master to feature/configure-ssh-phase3 (#6598)
Merge master to feature branch and resolve the following conflicts: ```ocaml $ git show db5ad7d commit db5ad7d (HEAD -> private/luzhan/sync-master-to-feature, mygithub/private/luzhan/sync-master-to-feature) Merge: d34d581 c185101 Author: Lunfan Zhang[Lunfan.Zhang] <[email protected]> Date: Mon Jul 21 08:50:26 2025 +0000 Merge master to feature branch diff --cc ocaml/idl/schematest.ml index d3914f4,7bd70cb3a..963231d --- 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 = "a030fa0233a69a33200b628af0f030c7" -let last_known_schema_hash = "9cd32d98d092440c36617546a3d995bd" ++let last_known_schema_hash = "7586cb039918e573594fc358e90b0f04" let current_schema_hash : string = let open Datamodel_types in diff --cc ocaml/xapi/xapi_globs.ml index 14459e1,7bdd07079..ba08ad1 --- a/ocaml/xapi/xapi_globs.ml +++ b/ocaml/xapi/xapi_globs.ml @@@ -1757,12 -1758,16 +1762,22 @@@ let other_options , (fun () -> string_of_bool !validate_reusable_pool_session) , "Enable validation of reusable pool sessions before use" ) + ; ( "ssh-auto-mode" + , Arg.Bool (fun b -> ssh_auto_mode_default := b) + , (fun () -> string_of_bool !ssh_auto_mode_default) + , "Defaults to true; overridden to false via \ + /etc/xapi.conf.d/ssh-auto-mode.conf(e.g., in XenServer 8)" + ) + ; ( "vm-sysprep-enabled" + , Arg.Set vm_sysprep_enabled + , (fun () -> string_of_bool !vm_sysprep_enabled) + , "Enable VM.sysprep API" + ) + ; ( "vm-sysprep-wait" + , Arg.Set_float vm_sysprep_wait + , (fun () -> string_of_float !vm_sysprep_wait) + , "Time in seconds to wait for VM to recognise inserted CD" + ) ] (* The options can be set with the variable xapiflags in /etc/sysconfig/xapi ```
2 parents d34d581 + db5ad7d commit c368857

File tree

118 files changed

+4430
-2544
lines changed

Some content is hidden

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

118 files changed

+4430
-2544
lines changed

Makefile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ install-extra:
147147
DESTDIR=$(DESTDIR) SBINDIR=$(SBINDIR) QEMU_WRAPPER_DIR=$(QEMU_WRAPPER_DIR) XENOPSD_LIBEXECDIR=$(XENOPSD_LIBEXECDIR) ETCDIR=$(ETCDIR) ./ocaml/xenopsd/scripts/make-custom-xenopsd.conf
148148

149149
# common flags and packages for 'dune install' and 'dune uninstall'
150-
DUNE_IU_PACKAGES1=-j $(JOBS) --destdir=$(DESTDIR) --prefix=$(PREFIX) --libdir=$(LIBDIR) --mandir=$(MANDIR)
150+
DUNE_IU_COMMON=-j $(JOBS) --destdir=$(DESTDIR) --libdir=$(LIBDIR) --mandir=$(MANDIR)
151+
DUNE_IU_PACKAGES1=$(DUNE_IU_COMMON) --prefix=$(PREFIX)
151152
DUNE_IU_PACKAGES1+=--libexecdir=$(XENOPSD_LIBEXECDIR) --datadir=$(SDKDIR)
152153
DUNE_IU_PACKAGES1+=xapi-client xapi-schema xapi-consts xapi-cli-protocol xapi-datamodel xapi-types
153154
DUNE_IU_PACKAGES1+=xen-api-client xen-api-client-lwt rrdd-plugin rrd-transport
@@ -163,17 +164,17 @@ install-dune1:
163164
# dune can install libraries and several other files into the right locations
164165
dune install $(DUNE_IU_PACKAGES1)
165166

166-
DUNE_IU_PACKAGES2=-j $(JOBS) --destdir=$(DESTDIR) --prefix=$(OPTDIR) --libdir=$(LIBDIR) --mandir=$(MANDIR) --libexecdir=$(OPTDIR)/libexec --datadir=$(DOCDIR) xapi xe
167+
DUNE_IU_PACKAGES2=$(DUNE_IU_COMMON) --prefix=$(OPTDIR) --libexecdir=$(OPTDIR)/libexec --datadir=$(DOCDIR) xapi xe
167168

168169
install-dune2:
169170
dune install $(DUNE_IU_PACKAGES2)
170171

171-
DUNE_IU_PACKAGES3=-j $(JOBS) --destdir=$(DESTDIR) --prefix=$(OPTDIR) --libdir=$(LIBDIR) --mandir=$(MANDIR) --libexecdir=$(OPTDIR)/libexec --bindir=$(OPTDIR)/debug --datadir=$(OPTDIR)/debug xapi-debug
172+
DUNE_IU_PACKAGES3=$(DUNE_IU_COMMON) --prefix=$(OPTDIR) --libexecdir=$(OPTDIR)/libexec --bindir=$(OPTDIR)/debug --datadir=$(OPTDIR)/debug xapi-debug
172173

173174
install-dune3:
174175
dune install $(DUNE_IU_PACKAGES3)
175176

176-
DUNE_IU_PACKAGES4=-j $(JOBS) --destdir=$(DESTDIR) --prefix=$(PREFIX) --libdir=$(LIBDIR) --libexecdir=/usr/libexec --mandir=$(MANDIR) vhd-tool forkexec
177+
DUNE_IU_PACKAGES4=$(DUNE_IU_COMMON) --prefix=$(PREFIX) --libexecdir=/usr/libexec vhd-tool forkexec qcow-stream-tool
177178

178179
install-dune4:
179180
dune install $(DUNE_IU_PACKAGES4)
@@ -186,7 +187,7 @@ install:
186187
chmod +x $(DESTDIR)$(DOCDIR)/doc-convert.sh
187188
# backward compat with existing specfile, to be removed after it is updated
188189
find $(DESTDIR) -name '*.cmxs' -delete
189-
for pkg in xapi-debug xapi xe xapi-tools xapi-sdk vhd-tool; do for f in CHANGELOG LICENSE README.markdown; do rm $(DESTDIR)$(OPTDIR)/doc/$$pkg/$$f $(DESTDIR)$(PREFIX)/doc/$$pkg/$$f -f; done; for f in META dune-package opam; do rm $(DESTDIR)$(LIBDIR)/$$pkg/$$f -f; done; done;
190+
for pkg in xapi-debug xapi xe xapi-tools xapi-sdk vhd-tool qcow-stream-tool; do for f in CHANGELOG LICENSE README.markdown; do rm $(DESTDIR)$(OPTDIR)/doc/$$pkg/$$f $(DESTDIR)$(PREFIX)/doc/$$pkg/$$f -f; done; for f in META dune-package opam; do rm $(DESTDIR)$(LIBDIR)/$$pkg/$$f -f; done; done;
190191

191192

192193
uninstall:

doc/content/design/sm-supported-image-formats.md

Lines changed: 114 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Add supported image formats in sm-list
33
layout: default
44
design_doc: true
5-
revision: 2
5+
revision: 3
66
status: proposed
77
---
88

@@ -22,32 +22,16 @@ available formats.
2222
# Design Proposal
2323

2424
To expose the available image formats to clients (e.g., XenCenter, XenOrchestra, etc.),
25-
we propose adding a new field called `supported-image-formats` to the Storage Manager (SM)
26-
module. This field will be included in the output of the `SM.get_all_records` call.
25+
we propose adding a new field called `supported_image_formats` to the Storage Manager
26+
(SM) module. This field will be included in the output of the `SM.get_all_records` call.
2727

28-
The `supported-image-formats` field will be populated by retrieving information
29-
from the SMAPI drivers. Specifically, each driver will update its `DRIVER_INFO`
30-
dictionary with a new key, `supported_image_formats`, which will contain a list
31-
of strings representing the supported image formats
32-
(for example: `["vhd", "raw", "qcow2"]`).
33-
34-
The list designates the driver's preferred VDI format as its first entry. That
35-
means that when migrating a VDI, the destination storage repository will
36-
attempt to create a VDI in this preferred format. If the default format cannot
37-
be used (e.g., due to size limitations), an error will be generated.
38-
39-
If a driver does not provide this information (as is currently the case with existing
40-
drivers), the default value will be an empty array. This signifies that it is the
41-
driver that decides which format it will use. This ensures that the modification
42-
remains compatible with both current and future drivers.
43-
44-
With this new information, listing all parameters of the SM object will return:
28+
- With this new information, listing all parameters of the SM object will return:
4529

4630
```bash
4731
# xe sm-list params=all
4832
```
4933

50-
will output something like:
34+
Output of the command will look like (notice that CLI uses hyphens):
5135

5236
```
5337
uuid ( RO) : c6ae9a43-fff6-e482-42a9-8c3f8c533e36
@@ -65,12 +49,118 @@ required-cluster-stack ( RO) :
6549
supported-image-formats ( RO) : vhd, raw, qcow2
6650
```
6751

68-
This change impacts the SM data model, and as such, the XAPI database version will
69-
be incremented.
52+
## Implementation details
53+
54+
The `supported_image_formats` field will be populated by retrieving information
55+
from the SMAPI drivers. Specifically, each driver will update its `DRIVER_INFO`
56+
dictionary with a new key, `supported_image_formats`, which will contain a list
57+
of strings representing the supported image formats
58+
(for example: `["vhd", "raw", "qcow2"]`). Although the formats are listed as a
59+
list of strings, they are treated as a set-specifying the same format multiple
60+
times has no effect.
61+
62+
### Driver behavior without `supported_image_formats`
63+
64+
If a driver does not provide this information (as is currently the case with
65+
existing drivers), the default value will be an empty list. This signifies
66+
that the driver determines which format to use when creating VDI. During a migration,
67+
the destination driver will choose the format of the VDI if none is explicitly
68+
specified. This ensures backward compatibility with both current and future drivers.
69+
70+
### Specifying image formats for VDIs creation
71+
72+
If the supported image format is exposed to the client, then, when creating new VDI,
73+
user can specify the desired format via the `sm_config` parameter `image-format=qcow2` (or
74+
any format that is supported). If no format is specified, the driver will use its
75+
preferred default format. If the specified format is not supported, an error will be
76+
generated indicating that the SR does not support it. Here is how it can be achieved
77+
using the XE CLI:
78+
79+
```bash
80+
# xe vdi-create \
81+
sr-uuid=cbe2851e-9f9b-f310-9bca-254c1cf3edd8 \
82+
name-label="A new VDI" \
83+
virtual-size=10240 \
84+
sm-config:image-format=vhd
85+
```
86+
87+
### Specifying image formats for VDIs migration
88+
89+
When migrating a VDI, an API client may need to specify the desired image format if
90+
the destination SR supports multiple storage formats.
91+
92+
#### VDI pool migrate
93+
94+
To support this, a new parameter, `dest_img_format`, is introduced to
95+
`VDI.pool_migrate`. This field accepts a string specifying the desired format (e.g., *qcow2*),
96+
ensuring that the VDI is migrated in the correct format. The new signature of
97+
`VDI.pool_migrate` will be
98+
`VDI ref pool_migrate (session ref, VDI ref, SR ref, string, (string -> string) map)`.
99+
100+
If the specified format is not supported or cannot be used (e.g., due to size limitations),
101+
an error will be generated. Validation will be performed as early as possible to prevent
102+
disruptions during migration. These checks can be performed by examining the XAPI database
103+
to determine whether the SR provided as the destination has a corresponding SM object with
104+
the expected format. If this is not the case, a `format not found` error will be returned.
105+
If no format is specified by the client, the destination driver will determine the appropriate
106+
format.
107+
108+
```bash
109+
# xe vdi-pool-migrate \
110+
uuid=<VDI_UUID> \
111+
sr-uuid=<SR_UUID> \
112+
dest-img-format=qcow2
113+
```
114+
115+
#### VM migration to remote host
116+
117+
A VDI migration can also occur during a VM migration. In this case, we need to
118+
be able to specify the expected destination format as well. Unlike `VDI.pool_migrate`,
119+
which applies to a single VDI, VM migration may involve multiple VDIs.
120+
The current signature of `VM.migrate_send` is `(session ref, VM ref, (string -> string) map,
121+
bool, (VDI ref -> SR ref) map, (VIF ref -> network ref) map, (string -> string) map,
122+
(VGPU ref -> GPU_group ref) map)`. Thus there is already a parameter that maps each source
123+
VDI to its destination SR. We propose to add a new parameter that allows specifying the
124+
desired destination format for a given source VDI: `(VDI ref -> string)`. It is
125+
similar to the VDI-to-SR mapping. We will update the XE cli to support this new format.
126+
It would be `image_format:<source-vdi-uuid>=<destination-image-format>`:
127+
128+
```bash
129+
# xe vm-migrate \
130+
host-uuid=<HOST_UUID> \
131+
remote-master=<IP> \
132+
remote-password=<PASS> \
133+
remote-username=<USER> \
134+
vdi:<VDI1_UUID>=<SR1_DEST_UUID> \
135+
vdi:<VDI2_UUID>=<SR2_DEST_UUID> \
136+
image-format:<VDI1_UUID>=vhd \
137+
image-format:<VDI2_UUID>=qcow2 \
138+
uuid=<VM_UUID>
139+
```
140+
The destination image format would be a string such as *vhd*, *qcow2*, or another
141+
supported format. It is optional to specify a format. If omitted, the driver
142+
managing the destination SR will determine the appropriate format.
143+
As with VDI pool migration, if this parameter is not supported by the SM driver,
144+
a `format not found` error will be returned. The validation must happen before
145+
sending a creation message to the SM driver, ideally at the same time as checking
146+
whether all VDIs can be migrated.
147+
148+
To be able to check the format, we will need to modify `VM.assert_can_migrate` and
149+
add the mapping from VDI references to their image formats, as is done in `VM.migrate_send`.
70150

71151
# Impact
72152

73-
- **Data Model:** A new field (`supported-image-formats`) is added to the SM records.
153+
It should have no impact on existing storage repositories that do not provide any information
154+
about the supported image format.
155+
156+
This change impacts the SM data model, and as such, the XAPI database version will
157+
be incremented. It also impacts the API.
158+
159+
- **Data Model:**
160+
- A new field (`supported_image_formats`) is added to the SM records.
161+
- A new parameter is added to `VM.migrate_send`: `(VDI ref -> string) map`
162+
- A new parameter is added to `VM.assert_can_migrate`: `(VDI ref -> string) map`
163+
- A new parameter is added to `VDI.pool_migrate`: `string`
74164
- **Client Awareness:** Clients like the `xe` CLI will now be able to query and display the supported image formats for a given SR.
75165
- **Database Versioning:** The XAPI database version will be updated to reflect this change.
76166

dune-project

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,15 @@
577577
:with-test
578578
(>= "2.4.0")))))
579579

580+
(package
581+
(name qcow-stream-tool)
582+
(synopsis "Minimal CLI wrapper for qcow-stream")
583+
(depends
584+
qcow-stream
585+
cmdliner
586+
)
587+
)
588+
580589
(package
581590
(name varstored-guard))
582591

ocaml/idl/datamodel_errors.ml

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ let _ =
6868
"The license-server connection details (address or port) were missing or \
6969
incomplete."
7070
() ;
71-
error Api_errors.license_checkout_error ["reason"]
71+
error Api_errors.license_checkout_error ["code"; "message"]
7272
~doc:"The license for the edition you requested is not available." () ;
7373
error Api_errors.license_file_deprecated []
7474
~doc:
@@ -532,31 +532,14 @@ let _ =
532532
"You attempted an operation on a VM which requires a more recent version \
533533
of the PV drivers. Please upgrade your PV drivers."
534534
() ;
535-
error Api_errors.vm_lacks_feature_shutdown ["vm"]
536-
~doc:
537-
"You attempted an operation which needs the cooperative shutdown feature \
538-
on a VM which lacks it."
539-
() ;
540-
error Api_errors.vm_lacks_feature_vcpu_hotplug ["vm"]
541-
~doc:
542-
"You attempted an operation which needs the VM hotplug-vcpu feature on a \
543-
VM which lacks it."
544-
() ;
545-
error Api_errors.vm_lacks_feature_suspend ["vm"]
546-
~doc:
547-
"You attempted an operation which needs the VM cooperative suspend \
548-
feature on a VM which lacks it."
549-
() ;
550-
error Api_errors.vm_lacks_feature_static_ip_setting ["vm"]
551-
~doc:
552-
"You attempted an operation which needs the VM static-ip-setting feature \
553-
on a VM which lacks it."
554-
() ;
555535
error Api_errors.vm_lacks_feature ["vm"]
556536
~doc:"You attempted an operation on a VM which lacks the feature." () ;
537+
error Api_errors.vm_non_suspendable ["vm"; "reason"]
538+
~doc:"You attempted an operation on a VM which is not suspendable." () ;
557539
error Api_errors.vm_is_template ["vm"]
558540
~doc:"The operation attempted is not valid for a template VM" () ;
559-
error Api_errors.other_operation_in_progress ["class"; "object"]
541+
error Api_errors.other_operation_in_progress
542+
["class"; "object"; "operation_type"; "operation_ref"]
560543
~doc:"Another operation involving the object is currently in progress" () ;
561544
error Api_errors.vbd_not_removable_media ["vbd"]
562545
~doc:"Media could not be ejected because it is not removable" () ;
@@ -2071,6 +2054,9 @@ let _ =
20712054
enable it in XC or run xe pool-enable-tls-verification instead."
20722055
() ;
20732056

2057+
error Api_errors.sysprep ["vm"; "message"]
2058+
~doc:"VM.sysprep error with details in the message" () ;
2059+
20742060
message
20752061
(fst Api_messages.ha_pool_overcommitted)
20762062
~doc:

ocaml/idl/datamodel_lifecycle.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,8 @@ let prototyped_of_message = function
239239
Some "25.2.0"
240240
| "host", "set_numa_affinity_policy" ->
241241
Some "24.0.0"
242+
| "VM", "sysprep" ->
243+
Some "25.24.0"
242244
| "VM", "get_secureboot_readiness" ->
243245
Some "24.17.0"
244246
| "VM", "set_uefi_mode" ->

ocaml/idl/datamodel_vm.ml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2211,6 +2211,7 @@ let operations =
22112211
; ("reverting", "Reverting the VM to a previous snapshotted state")
22122212
; ("destroy", "refers to the act of uninstalling the VM")
22132213
; ("create_vtpm", "Creating and adding a VTPM to this VM")
2214+
; ("sysprep", "Performing a Windows sysprep on this VM")
22142215
]
22152216
)
22162217

@@ -2369,6 +2370,19 @@ let restart_device_models =
23692370
~allowed_roles:(_R_VM_POWER_ADMIN ++ _R_CLIENT_CERT)
23702371
()
23712372

2373+
let sysprep =
2374+
call ~name:"sysprep" ~lifecycle:[]
2375+
~params:
2376+
[
2377+
(Ref _vm, "self", "The VM")
2378+
; (String, "unattend", "XML content passed to sysprep")
2379+
; (Float, "timeout", "timeout in seconds for expected reboot")
2380+
]
2381+
~doc:
2382+
"Pass unattend.xml to Windows sysprep and wait for the VM to shut down \
2383+
as part of a reboot."
2384+
~allowed_roles:_R_VM_ADMIN ()
2385+
23722386
let vm_uefi_mode =
23732387
Enum
23742388
( "vm_uefi_mode"
@@ -2571,6 +2585,7 @@ let t =
25712585
; set_blocked_operations
25722586
; add_to_blocked_operations
25732587
; remove_from_blocked_operations
2588+
; sysprep
25742589
]
25752590
~contents:
25762591
([

ocaml/idl/schematest.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ let hash x = Digest.string x |> Digest.to_hex
33
(* BEWARE: if this changes, check that schema has been bumped accordingly in
44
ocaml/idl/datamodel_common.ml, usually schema_minor_vsn *)
55

6-
let last_known_schema_hash = "a030fa0233a69a33200b628af0f030c7"
6+
let last_known_schema_hash = "7586cb039918e573594fc358e90b0f04"
77

88
let current_schema_hash : string =
99
let open Datamodel_types in

0 commit comments

Comments
 (0)