WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-api

[Xen-API] [PATCH] CA-37028: Netdev.vswitch: correct vsctl handling of em

To: xen-api@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-API] [PATCH] CA-37028: Netdev.vswitch: correct vsctl handling of empty response
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Mon, 25 Jan 2010 13:37:04 +0000
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Delivery-date: Mon, 25 Jan 2010 05:37:01 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-api-request@lists.xensource.com?subject=help>
List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>
List-post: <mailto:xen-api@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-api-bounces@xxxxxxxxxxxxxxxxxxx
The callers expect that if vsctl returns no output an empty list will
be returned. Instead a list containing the empty string was returned
due to the behaviour of Stringext.Strings.split when passed an empty
string. Explicitly check for an empty response from vsctl.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

diff -r b180a565573e -r 18f593937240 ocaml/netdev/netdev.ml
--- a/ocaml/netdev/netdev.ml    Mon Jan 25 10:30:12 2010 +0000
+++ b/ocaml/netdev/netdev.ml    Mon Jan 25 13:36:25 2010 +0000
@@ -219,7 +219,9 @@
   Unix.access vsctl_script [ Unix.X_OK ];
   let output, _ = Forkhelpers.execute_command_get_output vsctl_script args in
   let stripped = Stringext.String.strip (fun c -> c='\n') output in
-  Stringext.String.split '\n' stripped
+  match stripped with
+    | "" -> []
+    | s -> Stringext.String.split '\n' s
 
 let add name = ignore(vsctl ["add-br" ; name])
 let del name = ignore(vsctl ["del-br" ; name])

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-API] [PATCH] CA-37028: Netdev.vswitch: correct vsctl handling of empty response, Ian Campbell <=