@@ -424,36 +424,8 @@ func addHypervisorConfigOverrides(ocispec specs.Spec, config *vc.SandboxConfig,
424424 return err
425425 }
426426
427- if value , ok := ocispec .Annotations [vcAnnotations .HypervisorPath ]; ok {
428- if ! checkPathIsInGlobs (runtime .HypervisorConfig .HypervisorPathList , value ) {
429- return fmt .Errorf ("hypervisor %v required from annotation is not valid" , value )
430- }
431- config .HypervisorConfig .HypervisorPath = value
432- }
433-
434- if value , ok := ocispec .Annotations [vcAnnotations .JailerPath ]; ok {
435- if ! checkPathIsInGlobs (runtime .HypervisorConfig .JailerPathList , value ) {
436- return fmt .Errorf ("jailer %v required from annotation is not valid" , value )
437- }
438- config .HypervisorConfig .JailerPath = value
439- }
440-
441- if value , ok := ocispec .Annotations [vcAnnotations .CtlPath ]; ok {
442- if ! checkPathIsInGlobs (runtime .HypervisorConfig .HypervisorCtlPathList , value ) {
443- return fmt .Errorf ("hypervisor control %v required from annotation is not valid" , value )
444- }
445- config .HypervisorConfig .HypervisorCtlPath = value
446- }
447-
448- if value , ok := ocispec .Annotations [vcAnnotations .KernelParams ]; ok {
449- if value != "" {
450- params := vc .DeserializeParams (strings .Fields (value ))
451- for _ , param := range params {
452- if err := config .HypervisorConfig .AddKernelParam (param ); err != nil {
453- return fmt .Errorf ("Error adding kernel parameters in annotation kernel_params : %v" , err )
454- }
455- }
456- }
427+ if err := addHypervisorPathOverrides (ocispec , config , runtime ); err != nil {
428+ return err
457429 }
458430
459431 if value , ok := ocispec .Annotations [vcAnnotations .MachineType ]; ok {
@@ -540,6 +512,41 @@ func addHypervisorConfigOverrides(ocispec specs.Spec, config *vc.SandboxConfig,
540512 return nil
541513}
542514
515+ func addHypervisorPathOverrides (ocispec specs.Spec , config * vc.SandboxConfig , runtime RuntimeConfig ) error {
516+ if value , ok := ocispec .Annotations [vcAnnotations .HypervisorPath ]; ok {
517+ if ! checkPathIsInGlobs (runtime .HypervisorConfig .HypervisorPathList , value ) {
518+ return fmt .Errorf ("hypervisor %v required from annotation is not valid" , value )
519+ }
520+ config .HypervisorConfig .HypervisorPath = value
521+ }
522+
523+ if value , ok := ocispec .Annotations [vcAnnotations .JailerPath ]; ok {
524+ if ! checkPathIsInGlobs (runtime .HypervisorConfig .JailerPathList , value ) {
525+ return fmt .Errorf ("jailer %v required from annotation is not valid" , value )
526+ }
527+ config .HypervisorConfig .JailerPath = value
528+ }
529+
530+ if value , ok := ocispec .Annotations [vcAnnotations .CtlPath ]; ok {
531+ if ! checkPathIsInGlobs (runtime .HypervisorConfig .HypervisorCtlPathList , value ) {
532+ return fmt .Errorf ("hypervisor control %v required from annotation is not valid" , value )
533+ }
534+ config .HypervisorConfig .HypervisorCtlPath = value
535+ }
536+
537+ if value , ok := ocispec .Annotations [vcAnnotations .KernelParams ]; ok {
538+ if value != "" {
539+ params := vc .DeserializeParams (strings .Fields (value ))
540+ for _ , param := range params {
541+ if err := config .HypervisorConfig .AddKernelParam (param ); err != nil {
542+ return fmt .Errorf ("Error adding kernel parameters in annotation kernel_params : %v" , err )
543+ }
544+ }
545+ }
546+ }
547+ return nil
548+ }
549+
543550func addHypervisorMemoryOverrides (ocispec specs.Spec , sbConfig * vc.SandboxConfig , runtime RuntimeConfig ) error {
544551 if value , ok := ocispec .Annotations [vcAnnotations .DefaultMemory ]; ok {
545552 memorySz , err := strconv .ParseUint (value , 10 , 32 )
0 commit comments