From 5adc2f0a8a69f86e8ff9a90e30f2343846d2a0ca Mon Sep 17 00:00:00 2001 From: Hannes Mehnert Date: Sun, 5 Jul 2020 20:53:57 +0200 Subject: [PATCH] vmm_asn: instead of potentially losing information, be honest and fail if requested to encode older versions of unikernel configuration --- src/vmm_asn.ml | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/vmm_asn.ml b/src/vmm_asn.ml index c9d70d3..48ec44f 100644 --- a/src/vmm_asn.ml +++ b/src/vmm_asn.ml @@ -356,13 +356,7 @@ let v0_unikernel_config = and fail_behaviour = `Quit (* TODO maybe set to restart by default :) *) in { typ ; compressed ; image ; fail_behaviour ; cpuid ; memory ; block_devices ; bridges ; argv } - and g vm = - let network_interfaces = match vm.bridges with [] -> None | xs -> Some (List.map fst xs) - and block_device = match vm.block_devices with [] -> None | x::_ -> Some x - and typ = if vm.compressed then `Hvt_amd64_compressed else `Hvt_amd64 - in - let image = typ, vm.image in - (vm.cpuid, vm.memory, block_device, network_interfaces, image, vm.argv) + and g _vm = failwith "cannot encode v0 unikernel configs" in Asn.S.map f g @@ Asn.S.(sequence6 @@ -383,11 +377,7 @@ let v1_unikernel_config = and block_devices = match blocks with None -> [] | Some xs -> xs in { typ ; compressed ; image ; fail_behaviour ; cpuid ; memory ; block_devices ; bridges ; argv } - and g vm = - let bridges = match vm.bridges with [] -> None | xs -> Some (List.map fst xs) - and blocks = match vm.block_devices with [] -> None | xs -> Some xs - in - (vm.typ, (vm.compressed, (vm.image, (vm.fail_behaviour, (vm.cpuid, (vm.memory, (blocks, (bridges, vm.argv)))))))) + and g _vm = failwith "cannot encode v1 unikernel configs" in Asn.S.(map f g @@ sequence @@ (required ~label:"typ" typ)