Skip to content

Commit f36034e

Browse files
committed
Design proposal for supported image formats (v3)
Add details on specifying image format for VDI and VM migration. In particular This revision explains how to choose the destination image format during VDI creation and migration, including VM migration scenarios. Also fixes minor typos in the document. Signed-off-by: Guillaume <guillaume.thouvenin@vates.tech>
1 parent 5ec5732 commit f36034e

File tree

1 file changed

+100
-24
lines changed

1 file changed

+100
-24
lines changed

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

Lines changed: 100 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,104 @@ 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"]`).
59+
60+
### Driver behavior without `supported_image_formats`
61+
62+
If a driver does not provide this information (as is currently the case with
63+
existing drivers), the default value will be an empty array (`[]`). This signifies
64+
that the driver determines which format to use when creating VDI. During a migration,
65+
the destination driver will choose the format of the VDI if none is explicitly
66+
specified. This ensures backward compatibility with both current and future drivers.
67+
68+
### Specifying image formats for VDIs creation
69+
70+
If the supported image format is exposed to the client, then, when creating new VDI,
71+
user can specify the desired format via the `sm_config` parameter `type=qcow2` (or
72+
any format that is supported). If no format is specified, the driver will use its
73+
preferred default format. If the specified format is not supported, an error will be
74+
generated indicating that the SR does not support it.
75+
76+
```bash
77+
# xe vdi-create \
78+
sr-uuid=cbe2851e-9f9b-f310-9bca-254c1cf3edd8 \
79+
name-label="A new VDI" \
80+
virtual-size=10240 \
81+
sm-config:type=vhd
82+
```
83+
84+
### Specifying image formats for VDIs migration
85+
86+
When migrating a VDI, an API client may need to specify the desired image format if
87+
the destination SR supports multiple storage formats.
88+
89+
#### VDI pool migrate
90+
91+
To support this, a new parameter, `destination_image_format`, is introduced to
92+
`VDI.pool_migrate`. This field accepts a string specifying the desired format (e.g., *qcow2*),
93+
ensuring that the VDI is migrated in the correct format.
94+
95+
If the specified format is not supported or cannot be used (e.g., due to size limitations),
96+
an error will be generated. Validation will be performed as early as possible to prevent
97+
disruptions during migration. These checks can be performed by examining the XAPI database
98+
to determine whether the SR provided as the destination has a corresponding SM object with
99+
the expected format. If this is not the case, a `format not found` error will be returned.
100+
If no format is specified by the client, the destination driver will determine the appropriate
101+
format.
102+
103+
```bash
104+
# xe vdi-pool-migrate \
105+
uuid=<VDI_UUID> \
106+
sr-uuid=<SR_UUID> \
107+
destination-image-format=qcow2
108+
```
109+
110+
#### VM migration to remote host
111+
112+
A VDI migration can also occur during a VM migration. In this case, we need to
113+
be able to specify the expected destination format as well. Unlike `VDI.pool_migrate`,
114+
which applies to a single VDI, VM migration may involve multiple VDIs.
115+
There is already a parameter that maps each source VDI to its destination SR
116+
(see `vdi:<source-vdi-uuid>=<dest-sr-uuid>`). We propose to add a new parameter
117+
that allows specifying the desired destination format for a given source VDI.
118+
Similar to the VDI-to-SR mapping, the format would be:
119+
`image_format:<source-vdi-uuid>=<destination-image-format>`.
120+
121+
```bash
122+
# xe vm-migrate \
123+
host-uuid=<HOST_UUID> \
124+
remote-master=<IP> \
125+
remote-password=<PASS> \
126+
remote-username=<USER> \
127+
vdi:<VDI1_UUID>=<SR1_DEST_UUID> \
128+
vdi:<VDI2_UUID>=<SR2_DEST_UUID> \
129+
image-format:<VDI1_UUID>=vhd \
130+
image-format:<VDI2_UUID>=qcow2 \
131+
uuid=<VM_UUID>
132+
```
133+
The destination image format would be a string such as *vhd*, *qcow2*, or another
134+
supported format. It is optional to specify a format — if omitted, the driver
135+
managing the destination SR will determine the appropriate format.
136+
As with VDI pool migration, if this parameter is not supported by the SM driver,
137+
a `format not found` error will be returned. The validation must happen before
138+
sending a creation message to the SM driver — ideally at the same time as checking
139+
whether all VDIs can be migrated.
70140

71141
# Impact
72142

73-
- **Data Model:** A new field (`supported-image-formats`) is added to the SM records.
143+
It should have no impact on existing storage repositories that do not provide any information
144+
about the supported image format.
145+
146+
This change impacts the SM data model, and as such, the XAPI database version will
147+
be incremented.
148+
149+
- **Data Model:** A new field (`supported_image_formats`) is added to the SM records.
74150
- **Client Awareness:** Clients like the `xe` CLI will now be able to query and display the supported image formats for a given SR.
75151
- **Database Versioning:** The XAPI database version will be updated to reflect this change.
76152

0 commit comments

Comments
 (0)