pci_power_mgmt: int option;
}
+type config_disk_crypt = {
+ disk_crypt_cipher: string;
+ disk_crypt_key_size: int;
+ disk_crypt_key_file: string;
+}
+
type config_disk = {
disk_physpath: string;
disk_physty: Device.Vbd.physty;
disk_mode: Device.Vbd.mode;
disk_devtype: Device.Vbd.devty;
disk_dynadded: bool;
+ disk_crypt: config_disk_crypt option;
}
type config_nic = {
(* physpath:phystype:virtpath:mode:devtype *)
let ls = String.split ':' s in
- let physpath = List.nth ls 0
- and phystype = Device.Vbd.physty_of_string (List.nth ls 1)
- and virtpath = List.nth ls 2
- and mode = Device.Vbd.mode_of_string (List.nth ls 3)
- and devtype = Device.Vbd.devty_of_string (List.nth ls 4) in
-
+ let (physpath, phystype, virtpath, mode, devtype, kvs) =
+ match ls with
+ | physpath :: physty_s :: virtpath :: mode_s :: devtype_s :: left ->
+ let kvs = List.fold_left (fun acc s ->
+ match String.split '=' s with
+ | [ k; v ] -> (k, v) :: acc
+ | _ -> acc
+ ) [] left in
+ (physpath, Device.Vbd.physty_of_string physty_s,
+ virtpath, Device.Vbd.mode_of_string mode_s,
+ Device.Vbd.devty_of_string devtype_s, kvs)
+ | _ ->
+ failwith "need at least 5 arguments for disk"
+ in
+ let crypt_cipher, crypt_key_size, crypt_key_file =
+ (try Some (List.assoc "cipher" kvs) with Not_found -> None),
+ (try Some (List.assoc "key-size" kvs) with Not_found -> None),
+ (try Some (List.assoc "key-file" kvs) with Not_found -> None)
+ in
+ let dc =
+ if crypt_cipher = None && crypt_key_size = None && crypt_key_file = None then
+ None
+ else
+ Some {
+ disk_crypt_cipher = (match crypt_cipher with None -> "aes-xts-plain" | Some c -> c);
+ disk_crypt_key_size = (match crypt_key_size with None -> 256 | Some i -> int_of_string i);
+ disk_crypt_key_file = "";
+ }
+ in
{
disk_physpath = physpath;
disk_physty = phystype;
disk_mode = mode;
disk_devtype = devtype;
disk_dynadded = false;
+ disk_crypt = dc;
}
let config_cpuid_of_string s =