XCP-ng
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    How to reliably determine VDI format (vhd, qcow2, raw) via XAPI across versions

    Scheduled Pinned Locked Moved Development
    3 Posts 3 Posters 31 Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • bvitnikB Online
      bvitnik
      last edited by bvitnik

      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_type is now image-format key in the sm-config parameter 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-config are 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 type when creating raw VDIs:

      xe vdi-create sr-uuid=sr-uuid type=user virtual-size=virtual-size \
              name-label=VDI name sm-config:type=raw
      

      In my testing this transparently gets renamed to image-format in 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_type and fallback to image-format if 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.

      poddingueP dthenotD 2 Replies Last reply Reply Quote 1
      • poddingueP Offline
        poddingue Vates 🪐 @bvitnik
        last edited by

        From what I can tell, the image-format key showed up alongside the QCOW2 work in 8.3, and vdi_type is 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 mentions image-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 reading vdi_type first and falling back to image-format sounds 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 whether image-format is the canonical key going forward and whether vdi_type is kept only for compatibility.

        1 Reply Last reply Reply Quote 0
        • dthenotD Online
          dthenot Vates 🪐 XCP-ng Team @bvitnik
          last edited by

          @bvitnik Hello,

          sm-config:vdi_type is the pre-existing one so we are still writing it for compatibility reasons.
          But you might notice that vdi_type is only written for LVM-based SRs.
          While image-format is always written in XCP-ng with the QCOW2 feature.

          So it might be safe to just look at image-format if it exist and if it's not, it's likely a VHD.
          On LVMSR, you can fallback on vdi_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.

          1 Reply Last reply Reply Quote 0

          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
          • First post
            Last post