Skip to content

Commit a0bba90

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 a0bba90

File tree

1 file changed

+102
-24
lines changed

1 file changed

+102
-24
lines changed

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

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

71143
# Impact
72144

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

0 commit comments

Comments
 (0)