Skip to content

Commit 85b82b5

Browse files
committed
xenops: extend Vif.t with defaults when needed
Signed-off-by: Rob Hoes <[email protected]>
1 parent 54c112a commit 85b82b5

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

xen/xenops_interface.ml

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ module Network = struct
9393
| Local of string (** name of a local switch *)
9494
| Remote of string * string (** vm.id * switch *)
9595
type ts = t list
96+
97+
let default_t = Local "xenbr0"
9698
end
9799

98100
module Pci = struct
@@ -437,20 +439,26 @@ module Vif = struct
437439
| Unspecified4
438440
| Static4 of string list * string option (* a list of CIDRs and optionally a gateway *)
439441

442+
let default_ipv4_configuration = Unspecified4
443+
440444
type ipv6_configuration =
441445
| Unspecified6
442446
| Static6 of string list * string option (* a list of CIDRs and optionally a gateway *)
443447

448+
let default_ipv6_configuration = Unspecified6
449+
444450
type locked_addresses = {
445-
ipv4: string list;
446-
ipv6: string list;
451+
ipv4: string list;
452+
ipv6: string list;
447453
}
448454

449-
type locking_mode =
450-
| Unlocked (* all traffic permitted *)
455+
type locking_mode =
456+
| Unlocked (* all traffic permitted *)
451457
| Disabled (* no traffic permitted *)
452458
| Locked of locked_addresses
453459

460+
let default_locking_mode = Unlocked
461+
454462
type t = {
455463
id: id;
456464
position: int;
@@ -466,6 +474,23 @@ module Vif = struct
466474
ipv6_configuration: ipv6_configuration;
467475
}
468476

477+
let default_t = {
478+
id = "", "";
479+
position = 0;
480+
mac = "fe:ff:ff:ff:ff:ff";
481+
carrier = true;
482+
mtu = 1500;
483+
rate = None;
484+
backend = Network.default_t;
485+
other_config = [];
486+
locking_mode = default_locking_mode;
487+
extra_private_keys = [];
488+
ipv4_configuration = default_ipv4_configuration;
489+
ipv6_configuration = default_ipv6_configuration;
490+
}
491+
492+
let t_of_rpc rpc = Rpc.struct_extend rpc (rpc_of_t default_t) |> t_of_rpc
493+
469494
type state = {
470495
active: bool;
471496
plugged: bool;

0 commit comments

Comments
 (0)