add all qemu-img convert disk formats

This commit is contained in:
Mikaël Cluseau
2025-06-13 11:43:56 +02:00
parent 84a0e286e7
commit 4b05458cec
2 changed files with 27 additions and 12 deletions

View File

@ -98,11 +98,10 @@ func buildBootImgQemuConvert(out io.Writer, ctx *renderContext, format string) (
io.Copy(out, img) io.Copy(out, img)
return return
} }
func buildBootQcow2(out io.Writer, ctx *renderContext) (err error) { func qemuImgBootImg(format string) func(out io.Writer, ctx *renderContext) (err error) {
return buildBootImgQemuConvert(out, ctx, "qcow2") return func(out io.Writer, ctx *renderContext) (err error) {
} return buildBootImgQemuConvert(out, ctx, format)
func buildBootVmdk(out io.Writer, ctx *renderContext) (err error) { }
return buildBootImgQemuConvert(out, ctx, "vmdk")
} }
var grubSupportVersion = flag.String("grub-support", "1.1.0", "GRUB support version") var grubSupportVersion = flag.String("grub-support", "1.1.0", "GRUB support version")

View File

@ -46,20 +46,30 @@ func (ws wsHost) register(rws *restful.WebService, alterRB func(*restful.RouteBu
Produces(mime.DISK). Produces(mime.DISK).
Doc("Get the " + ws.hostDoc + "'s boot disk image"), Doc("Get the " + ws.hostDoc + "'s boot disk image"),
// - raw + compressed
b("boot.img.gz"). b("boot.img.gz").
Produces(mime.DISK + "+gzip"). Produces(mime.DISK + "+gzip").
Doc("Get the " + ws.hostDoc + "'s boot disk image (gzip compressed)"), Doc("Get the " + ws.hostDoc + "'s boot disk image, gzip compressed"),
b("boot.img.lz4"). b("boot.img.lz4").
Produces(mime.DISK + "+lz4"). Produces(mime.DISK + "+lz4").
Doc("Get the " + ws.hostDoc + "'s boot disk image (lz4 compressed)"), Doc("Get the " + ws.hostDoc + "'s boot disk image, lz4 compressed"),
// - other formats
b("boot.qcow2"). b("boot.qcow2").
Produces(mime.DISK + "+qcow2"). Produces(mime.DISK + "+qcow2").
Doc("Get the " + ws.hostDoc + "'s boot disk image (qcow2)"), Doc("Get the " + ws.hostDoc + "'s boot disk image, QCOW2 (KVM, Xen)"),
b("boot.qed").
Produces(mime.DISK + "+qed").
Doc("Get the " + ws.hostDoc + "'s boot disk image, QED (KVM)"),
b("boot.vmdk").
Produces(mime.DISK + "+vdi").
Doc("Get the " + ws.hostDoc + "'s boot disk image, VDI (VirtualBox)"),
b("boot.qcow2").
Produces(mime.DISK + "+vpc").
Doc("Get the " + ws.hostDoc + "'s boot disk image, VHD (Hyper-V)"),
b("boot.vmdk"). b("boot.vmdk").
Produces(mime.DISK + "+vmdk"). Produces(mime.DISK + "+vmdk").
Doc("Get the " + ws.hostDoc + "'s boot disk image (VMDK)"), Doc("Get the " + ws.hostDoc + "'s boot disk image, VMDK (VMware)"),
// metal/local HDD upgrades // metal/local HDD upgrades
b("boot.tar"). b("boot.tar").
@ -194,9 +204,15 @@ func renderHost(w http.ResponseWriter, r *http.Request, what string, host *local
case "boot.img.lz4": case "boot.img.lz4":
err = renderCtx(w, r, ctx, what, buildBootImgLZ4) err = renderCtx(w, r, ctx, what, buildBootImgLZ4)
case "boot.qcow2": case "boot.qcow2":
err = renderCtx(w, r, ctx, what, buildBootQcow2) err = renderCtx(w, r, ctx, what, qemuImgBootImg("qcow2"))
case "boot.qed":
err = renderCtx(w, r, ctx, what, qemuImgBootImg("qed"))
case "boot.vdi":
err = renderCtx(w, r, ctx, what, qemuImgBootImg("vdi"))
case "boot.vmdk": case "boot.vmdk":
err = renderCtx(w, r, ctx, what, buildBootVmdk) err = renderCtx(w, r, ctx, what, qemuImgBootImg("vmdk"))
case "boot.vpc":
err = renderCtx(w, r, ctx, what, qemuImgBootImg("vpc"))
default: default:
http.NotFound(w, r) http.NotFound(w, r)