]> xenbits.xensource.com Git - xcp/xen-api.git/commitdiff
blktap2: Map Tap type devices to blkback backends.
authorDaniel Stodden <daniel.stodden@citrix.com>
Thu, 8 Jul 2010 11:59:56 +0000 (12:59 +0100)
committerDaniel Stodden <daniel.stodden@citrix.com>
Thu, 8 Jul 2010 11:59:56 +0000 (12:59 +0100)
Make the agent map all Vbd backend types to blkback instances. We keep
the kind=Tap on backend types. But the distinction remains significant
only so VHD snapshotting can pause VBDs where necessary.

Signed-off-by: Daniel Stodden <daniel.stodden@citrix.com>
ocaml/xapi/xen_helpers.ml
ocaml/xenops/device.ml
ocaml/xenops/xenops.ml

index 6d9b6e87ecb151950912b2c2309454d86f931d31..b67d356c90e129f8a89c4200ef00af9393597860 100644 (file)
@@ -41,11 +41,9 @@ let vbd_of_devid ~__context ~vm devid =
 let device_of_vbd ~__context ~self = 
   let vm = Db.VBD.get_VM ~__context ~self in
   let domid = Int64.to_int (Db.VM.get_domid ~__context ~self:vm) in
-  let vdi = Db.VBD.get_VDI ~__context ~self in
-  let kind = kind_of_vdi ~__context ~self:vdi in
   let devid = devid_of_vbd ~__context ~self in
   let backend = { Device_common.domid = 0; 
-                 kind = kind;
+                 kind = Device_common.Vbd;
                  devid = devid } in
   Device_common.device_of_backend backend domid 
 
index f5584dbbf1c4b46e681cf69dcf9f7950775fac2f..3094a993eedbbd348270f1ddcac20a6acf387f84 100644 (file)
@@ -252,9 +252,7 @@ type physty = File | Phys | Qcow | Vhd | Aio
 let backendty_of_physty = function
        | File -> "file"
        | Phys -> "phy"
-       | Qcow -> "tap"
-       | Vhd  -> "tap"
-       | Aio  -> "tap"
+       | Qcow | Vhd | Aio -> "phy"
 
 let string_of_physty = function
        | Qcow -> "qcow"
@@ -485,14 +483,9 @@ let add ~xs ~hvm ~mode ~virtpath ~phystype ~physpath ~dev_type ~unpluggable
         ?(protocol=Protocol_Native) ?extra_backend_keys ?(extra_private_keys=[]) ?(backend_domid=0) domid  =
        let back_tbl = Hashtbl.create 16 and front_tbl = Hashtbl.create 16 in
        let devid = device_number virtpath in
-
-       let backend_tap ty physpath =
-               Hashtbl.add back_tbl "params" (ty ^ ":" ^ physpath);
-               "tap", { domid = backend_domid; kind = Tap; devid = devid }
-               in
-       let backend_blk ty physpath =
-               Hashtbl.add back_tbl "params" physpath;
-               "vbd", { domid = backend_domid; kind = Vbd; devid = devid }
+       let device = 
+         let backend = { domid = backend_domid; kind = Vbd; devid = devid } 
+         in  device_of_backend backend domid
        in
 
        debug "Device.Vbd.add (virtpath=%s | physpath=%s | phystype=%s)"
@@ -512,30 +505,16 @@ let add ~xs ~hvm ~mode ~virtpath ~phystype ~physpath ~dev_type ~unpluggable
             List.iter (fun (k, v) -> Hashtbl.add back_tbl k v) keys
         | None -> ());
 
-       let frontend = { domid = domid; kind = Vbd; devid = devid } in
-
-       let backend_ty, backend = match phystype with
-       | File ->
-               (* Note: qemu access device images itself, so requires the path
-                  of the original file or block device. CDROM media change is achieved
-                  by changing the path in xenstore. Only PV guests need the loopback *)
-               let backend_ty, backend = backend_blk "file" physpath in
-               if not(hvm) then begin
-                 let device = { backend = backend; frontend = frontend } in
-                 let loopdev = Hotplug.mount_loopdev ~xs device physpath (mode = ReadOnly) in
-                 Hashtbl.add back_tbl "physical-device" (string_of_major_minor loopdev);
-                 Hashtbl.add back_tbl "loop-device" loopdev;
-               end;
-               backend_ty, backend
-       | Phys ->
-               Hashtbl.add back_tbl "physical-device" (string_of_major_minor physpath);
-               backend_blk "raw" physpath
-       | Qcow | Vhd | Aio ->
-               backend_tap (string_of_physty phystype) physpath
-               in
-
-       let device = { backend = backend; frontend = frontend } in
-       
+       begin match phystype with
+         | File ->
+             if not(hvm) then begin
+               let loopdev = Hotplug.mount_loopdev ~xs device physpath (mode = ReadOnly) in
+               Hashtbl.add back_tbl "physical-device" (string_of_major_minor loopdev);
+               Hashtbl.add back_tbl "loop-device" loopdev
+             end
+         | Phys | Qcow | Vhd | Aio ->
+             Hashtbl.add back_tbl "physical-device" (string_of_major_minor physpath)
+          end;
 
        Hashtbl.add_list front_tbl [
                "backend-id", string_of_int backend_domid;
@@ -554,6 +533,7 @@ let add ~xs ~hvm ~mode ~virtpath ~phystype ~physpath ~dev_type ~unpluggable
                "dev", (if domid = 0 && virtpath.[0] = 'x' then "/dev/" else "") ^ virtpath;
                "type", backendty_of_physty phystype;
                "mode", string_of_mode mode;
+               "params", physpath;
        ];
        if protocol <> Protocol_Native then
                Hashtbl.add front_tbl "protocol" (string_of_protocol protocol);
index 1acf52a66436743fc3168bbecc4ca9eb16127239..08148fb19be7c981beb9cda92b1eb6b015c4af7e 100644 (file)
@@ -233,11 +233,9 @@ let find_device ~xs (frontend: endpoint) (backend: endpoint) =
   | _ -> failwith "failed to find device"
 
 let del_vbd ~xs ~domid ~backend_domid ~virtpath ~phystype =
-       let physty = Device.Vbd.physty_of_string phystype in
-       let kind = Device.Vbd.kind_of_physty physty in
        let devid = Device.Vbd.device_number virtpath in
-       let frontend = { domid = domid; kind = kind; devid = devid } in
-       let backend = { domid = backend_domid; kind = kind; devid = devid } in
+       let frontend = { domid = domid; kind = Vbd; devid = devid } in
+       let backend = { domid = backend_domid; kind = Vbd; devid = devid } in
        let device = find_device ~xs frontend backend in
        Device.clean_shutdown ~xs device