# HG changeset patch
# User Daniel Stodden <daniel.stodden@xxxxxxxxxx>
# Date 1278590396 -3600
# Node ID a4a3b736895091f3897f7d85a3414e45fc82f83e
# Parent 49e02232b23af620fccceeac251dcb145ba0d8ef
blktap2: Map Tap type devices to blkback backends.
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@xxxxxxxxxx>
diff -r 49e02232b23a -r a4a3b7368950 ocaml/xapi/xen_helpers.ml
--- a/ocaml/xapi/xen_helpers.ml Thu Jul 08 12:59:55 2010 +0100
+++ b/ocaml/xapi/xen_helpers.ml Thu Jul 08 12:59:56 2010 +0100
@@ -41,11 +41,9 @@
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
diff -r 49e02232b23a -r a4a3b7368950 ocaml/xenops/device.ml
--- a/ocaml/xenops/device.ml Thu Jul 08 12:59:55 2010 +0100
+++ b/ocaml/xenops/device.ml Thu Jul 08 12:59:56 2010 +0100
@@ -252,9 +252,7 @@
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 @@
?(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 @@
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 @@
"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);
diff -r 49e02232b23a -r a4a3b7368950 ocaml/xenops/xenops.ml
--- a/ocaml/xenops/xenops.ml Thu Jul 08 12:59:55 2010 +0100
+++ b/ocaml/xenops/xenops.ml Thu Jul 08 12:59:56 2010 +0100
@@ -233,11 +233,9 @@
| _ -> 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
ocaml/xapi/xen_helpers.ml | 4 +--
ocaml/xenops/device.ml | 50 ++++++++++++++--------------------------------
ocaml/xenops/xenops.ml | 6 +---
3 files changed, 18 insertions(+), 42 deletions(-)
blktap2.diff
Description: Text Data
_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api
|