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] stabilise order PCI devices are passed through to gues

To: xen-api@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-API] [PATCH] stabilise order PCI devices are passed through to guests
From: David Scott <dave.scott@xxxxxxxxxxxxx>
Date: Mon, 5 Apr 2010 20:51:03 +0100
Delivery-date: Mon, 05 Apr 2010 12:48:11 -0700
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
# HG changeset patch
# User David Scott <dave.scott@xxxxxxxxxxxxx>
# Date 1270497002 -3600
# Node ID 9d41a85de51298757c474717f2f948e3c6121e00
# Parent  4ee206f7ec1f68139abd3bc8d24537f879c8bf04
CA-39889: hotplug PCI devices into guests in the order specified in the 
(original) other-config key.

There were two problems:
1. xapi was accidentally reversing the list provided in the other_config key (a 
side-effect of a fold)
2. when listing the PCI devices present in xenstore, the Device.PCI.list 
function was passing the device order number back in the place reserved for 
"PCI bus ID". This caused the devices to be hotplugged in reverse over reboot.

Now the behaviour is:
1. devices are hotplugged in the order they are found in the other_config key
2. the hotplug ordering is stable across start/internal reboot/external reboot

Signed-off-by: David Scott <dave.scott@xxxxxxxxxxxxx>

diff -r 4ee206f7ec1f -r 9d41a85de512 ocaml/xapi/vmops.ml
--- a/ocaml/xapi/vmops.ml       Tue Mar 09 16:02:02 2010 +0000
+++ b/ocaml/xapi/vmops.ml       Mon Apr 05 20:50:02 2010 +0100
@@ -489,6 +489,8 @@
                                     (fun id a b c d -> (id, (a, b, c, d))) :: 
acc
                with _ -> acc
        ) [] devs in
+       (* Preserve the configured order *)
+       let devs = List.rev devs in
        if devs <> [] 
        then Rbac.assert_permission ~__context 
~permission:Rbac_static.permission_internal_vm_plug_pcidevs;
        devs
diff -r 4ee206f7ec1f -r 9d41a85de512 ocaml/xapi/xapi_vm.ml
--- a/ocaml/xapi/xapi_vm.ml     Tue Mar 09 16:02:02 2010 +0000
+++ b/ocaml/xapi/xapi_vm.ml     Mon Apr 05 20:50:02 2010 +0100
@@ -399,6 +399,7 @@
         
         (* Before we destroy the old domain we check which PCI devices were 
plugged in *)
         let pcidevs = with_xc_and_xs (fun xc xs -> Device.PCI.list xc xs 
domid) in
+        debug "Listed PCI devices: [ %s ]" (String.concat ", " (List.map (fun 
(x, dev) -> string_of_int x ^ "/" ^ (Device.PCI.to_string dev)) pcidevs));
 
         let localhost = Helpers.get_localhost ~__context in
          debug "%s phase 1/3: destroying old domain" api_call_name;
diff -r 4ee206f7ec1f -r 9d41a85de512 ocaml/xenops/device.ml
--- a/ocaml/xenops/device.ml    Tue Mar 09 16:02:02 2010 +0000
+++ b/ocaml/xenops/device.ml    Mon Apr 05 20:50:02 2010 +0100
@@ -1188,7 +1188,11 @@
   let device_number_of_string x =
     (* remove the silly prefix *)
     int_of_string (String.sub x (String.length prefix) (String.length x - 
(String.length prefix))) in
-  List.map (fun (x, y) -> device_number_of_string x, of_string y) pairs
+  let pairs' = List.map (fun (x, y) -> device_number_of_string x, of_string y) 
pairs in
+  (* Sort into the order the devices were plugged *)
+  let sorted = List.sort (fun a b -> compare (fst a) (fst b)) pairs' in
+  (* Assume the PCI bus ID is 0 *)
+  List.map (fun (_, y) -> 0, y) sorted
 
 
 let plug ~xc ~xs (domain, bus, dev, func) domid devid = 
3 files changed, 8 insertions(+), 1 deletion(-)
ocaml/xapi/vmops.ml    |    2 ++
ocaml/xapi/xapi_vm.ml  |    1 +
ocaml/xenops/device.ml |    6 +++++-


Attachment: xen-api.hg.patch
Description: Text Data

_______________________________________________
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] stabilise order PCI devices are passed through to guests, David Scott <=