create vm: introduce --{os,arch,runtime} command-line arguments (#422)

* create vm: introduce --{os,arch,runtime} command-line arguments

* v1.VM: prevent unsupported fields for "vetu" runtime
This commit is contained in:
Nikolay Edigaryev
2026-03-17 19:46:00 +01:00
committed by GitHub
parent 143253083b
commit 3cfa244550
3 changed files with 68 additions and 2 deletions
+8
View File
@@ -73,6 +73,10 @@ func (controller *Controller) createVM(ctx *gin.Context) responder.Responder {
vm.Runtime = v1.RuntimeTart
}
if err := vm.Validate(); err != nil {
return responder.JSON(http.StatusPreconditionFailed, NewErrorResponse("%v", err))
}
// Softnet-specific logic: automatically enable Softnet when NetSoftnetAllow or NetSoftnetBlock are set
// and propagate deprecated and non-deprecated boolean fields into each other
if vm.NetSoftnetDeprecated || vm.NetSoftnet || len(vm.NetSoftnetAllow) != 0 || len(vm.NetSoftnetBlock) != 0 {
@@ -173,6 +177,10 @@ func (controller *Controller) updateVMSpec(ctx *gin.Context) responder.Responder
"and \"runtime\" fields cannot be modified"))
}
if err := userVM.Validate(); err != nil {
return responder.JSON(http.StatusPreconditionFailed, NewErrorResponse("%v", err))
}
// Softnet-specific logic: automatically enable Softnet when NetSoftnetAllow or NetSoftnetBlock are set
// and propagate deprecated and non-deprecated boolean fields into each other
if userVM.NetSoftnetDeprecated || userVM.NetSoftnet || len(userVM.NetSoftnetAllow) != 0 || len(userVM.NetSoftnetBlock) != 0 {