How to reliably determine VDI format (vhd, qcow2, raw) via XAPI across versions
-
Hi,
It has come to my attention that in recent times there was some change in how VDI format is tracked in XAPI database, especially with arrival of QCOW2 support, first in XenServer (GFS2 SRs only) and then in XCP-ng 8.3 (other SR types).
Currently, I have access to XCP-ng 8.1 and 8.3 (with latest updates) and I'm seeing these differences:
XCP-ng 8.1:
$ xe vdi-param-list uuid=SOMEUUID ... sm-config (MRO): vdi_type: vhd ...XCP-ng 8.3:
$ xe vdi-param-list uuid=SOMEUUID ... sm-config (MRO): image-format: vhd ...So it seems what was earlier
vdi_typeis nowimage-formatkey in thesm-configparameter of a VDI.On the other hand, some people are reporting having both keys present in
sm-config, e.g.:... sm-config (MRO): image-format: vhd; vdi_type: vhd ...Neither are well documented and I can't find any official info on what keys in
sm-configare supported and what is their purpose. Maybe devs can shed some light on this?To add to the confusion, official XenServer documentation mentiones a key called just
typewhen creating raw VDIs:xe vdi-create sr-uuid=sr-uuid type=user virtual-size=virtual-size \ name-label=VDI name sm-config:type=rawIn my testing this transparently gets renamed to
image-formatin the latest version of XCP-ng.The reason this bothers me is that I was asked to implement reporting of VDI format in my Ansible modules for XCP-ng but now I'm not sure how to do it across all of the supported versions of XenServer and XCP-ng. Currently it looks like I should try to get
vdi_typeand fallback toimage-formatif the first one is not found but I'm not certain if these keys are interchangable and have the same purpose or they just happen to sometimes have the same value. Also, ISO image VDIs seems to be missing any format indication.Any info on this subject is well appreciated. Thanks.
-
From what I can tell, the
image-formatkey showed up alongside the QCOW2 work in 8.3, andvdi_typeis the older one.
The QCOW2 FAQ at https://docs.xcp-ng.org/storage/qcow2_faq#how-to-create-a-qcow2-vdi is the only place I've found that even mentionsimage-format, though it's about creating a VDI rather than detecting the format of one that already exists. I honestly don't know whether the two keys are guaranteed to stay in sync or just happen to agree, so your idea of readingvdi_typefirst and falling back toimage-formatsounds like the safest bet to me, but I wouldn't trust my own guess here.
The point about ISO VDIs having no format indicator is a good one, too. It might be worth a mention to @Team-Storage, since they'd know whetherimage-formatis the canonical key going forward and whethervdi_typeis kept only for compatibility. -
@bvitnik Hello,
sm-config:vdi_typeis the pre-existing one so we are still writing it for compatibility reasons.
But you might notice thatvdi_typeis only written for LVM-based SRs.
Whileimage-formatis always written in XCP-ng with the QCOW2 feature.So it might be safe to just look at
image-formatif it exist and if it's not, it's likely a VHD.
On LVMSR, you can fallback onvdi_type(and it should work for XS too).Indeed, ISO SRs do not advertise a VDI format. Technically, ISOs could be considered to be
raw.It should also be noted that our implementation of QCOW2 is very different from GFS2 QCOW2 of XenServer.
Our implementation uses the existing SR types to allow VHD and QCOW2 to co-exist. -
@dthenot Aaaaah, so it even depends on the SR type. That also explains the difference I'm seeing in my lab with 8.1 vs 8.3. The first one uses LVM backed SR and the other one uses file system (ext) backed SR.
I'll have to investigate this a little bit more.
Was
image-formatkey added by you (XCP-ng team) and is specific to XCP-ng or was it used at any point in XenServer also?
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login