]> xenbits.xensource.com Git - xcp/xen-api-libs.git/commitdiff
Add biosdevname call to Netdev
authorRob Hoes <rob.hoes@citrix.com>
Fri, 18 Jun 2010 13:32:23 +0000 (14:32 +0100)
committerRob Hoes <rob.hoes@citrix.com>
Fri, 18 Jun 2010 13:32:23 +0000 (14:32 +0100)
biosdevname is a tool used to find out the "real" device name of a network interface, according to the BIOS. This name is not affected by manual device renaming or changes in the Linux kernel.

Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
diff -r 96761a1835c1 netdev/netdev.ml--- a/netdev/netdev.ml
+++ b/netdev/netdev.ml
@@ -397,6 +397,13 @@
  not(List.mem "xen-backend" (String.split '/' link))
   with _ -> false

+let get_bios_name name =
+ try
+ let output, _ = Forkhelpers.execute_command_get_output "/sbin/biosdevname" ["-i"; name] in
+ let output = String.strip String.isspace output in
+ output
+ with _ -> name
+
 (* Dispatch network backend operations. *)

 let network_config_file = "/etc/xensource/network.conf"

netdev/netdev.mli

index 07ce7198a963003b7799f4fa45571e568ebe4ba5..822d50831352cf48f481cfe7df1d6a6f9a892f4f 100644 (file)
@@ -131,8 +131,13 @@ val get_carrier : string -> bool
 (** Returns PCI vendor and device ID for network device. *)
 val get_ids : string -> string * string
 
-(** Indicates whether the given interface is a physical interface *)
+(** Indicates whether the given interface is a physical interface. *)
 val is_physical : string -> bool
 
-(** Dispatch operation to correct backend device *)
+(** Returns the device name of the given interface according to [biosdevname]. This is a name
+ *  that is based on the BIOS name and should not be affected by changes in the Linux kernel or
+ *  manual device renaming. *)
+val get_bios_name : string -> string
+
+(** Dispatch operation to correct backend device. *)
 val network : network_ops