for isofile in $isopath/Qubes-*x86_64.iso; do
  if [ -e "$isofile" ]; then
    regexp --set=isoname "$isopath/(.*)" "$isofile"
    submenu "$isoname ->" "$isofile" {
      iso_path="$2"
      loopback loop "$iso_path"
      probe --label --set=cd_label (loop)
      menuentry "Install Qubes" {
        bootoptions="iso-scan/filename=$iso_path inst.stage2=hd:LABEL=$cd_label i915.preliminary_hw_support=1 quiet rhgb"
        multiboot (loop)/isolinux/xen.gz
        module (loop)/isolinux/vmlinuz $bootoptions
        module (loop)/isolinux/initrd.img
      }
      menuentry "Test this media & install Qubes" {
        bootoptions="iso-scan/filename=$iso_path inst.stage2=hd:LABEL=$cd_label i915.preliminary_hw_support=1 quiet rhgb rd.live.check"
        multiboot (loop)/isolinux/xen.gz
        module (loop)/isolinux/vmlinuz $bootoptions
        module (loop)/isolinux/initrd.img
      }
      menuentry "Install Qubes in basic graphics mode" {
        bootoptions="iso-scan/filename=$iso_path inst.stage2=hd:LABEL=$cd_label xdriver=vesa nomodeset quiet"
        multiboot (loop)/isolinux/xen.gz
        module (loop)/isolinux/vmlinuz $bootoptions
        module (loop)/isolinux/initrd.img
      }
      menuentry "Rescue a Qubes system" {
        bootoptions="iso-scan/filename=$iso_path inst.stage2=hd:LABEL=$cd_label rescue quiet"
        multiboot (loop)/isolinux/xen.gz
        module (loop)/isolinux/vmlinuz $bootoptions
        module (loop)/isolinux/initrd.img
      }
    }
  fi
done
