Skip to content

Commit

Permalink
Implement VDI.attach by parsing the Volume.get_xml_desc output
Browse files Browse the repository at this point in the history
  • Loading branch information
David Scott committed Feb 27, 2013
1 parent aca6730 commit 2e3ef60
Showing 1 changed file with 40 additions and 7 deletions.
47 changes: 40 additions & 7 deletions server.ml
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,43 @@ module Implementation = struct
let set_content_id = set_content_id
let get_by_name = get_by_name

let vdi_path_of sr vdi = "XXX"
let example_volume_xml = "
<volume>
<name>myvol</name>
<key>rbd/myvol</key>
<source>
</source>
<capacity unit='bytes'>53687091200</capacity>
<allocation unit='bytes'>53687091200</allocation>
<target>
<path>rbd:rbd/myvol</path>
<format type='unknown'/>
<permissions>
<mode>00</mode>
<owner>0</owner>
<group>0</group>
</permissions>
</target>
</volume>
"

let read_xml_path path' xml =
let input = Xmlm.make_input (`String (0, xml)) in
let rec search path = match Xmlm.input input with
| `Dtd _ -> search path
| `El_start ((_, x), _) -> search (x :: path)
| `El_end -> search (List.tl path)
| `Data x when path = path' -> x
| `Data _ -> search path in
search []

let volume_target_path = [ "path"; "target"; "volume" ]

let vdi_path_of key =
let c = get_connection () in
let v = V.lookup_by_key c key in
let xml = V.get_xml_desc (V.const v) in
read_xml_path volume_target_path xml

let vdi_info_of_name pool name =
try
Expand Down Expand Up @@ -266,23 +302,20 @@ module Implementation = struct
failwith "Failed to find volume in storage pool: create silently failed?"

let destroy ctx ~dbg ~sr ~vdi =
let sr = Attached_srs.get sr in
let c = get_connection () in
let v = V.lookup_by_key c vdi in
(* BUG: libvir: Storage error : invalid argument: virStorageBackendFileSystemVolDelete: unsupported flags (0xfacae8) *)
V.delete (Obj.magic v)

let stat ctx ~dbg ~sr ~vdi = assert false
let attach ctx ~dbg ~dp ~sr ~vdi ~read_write =
let sr = Attached_srs.get sr in
let path = vdi_path_of sr vdi in
let path = vdi_path_of vdi in
{
params = "XXX";
params = path;
xenstore_data = []
}
let detach ctx ~dbg ~dp ~sr ~vdi =
let sr = Attached_srs.get sr in
let path = vdi_path_of sr vdi in
let _ = vdi_path_of vdi in
()
let activate ctx ~dbg ~dp ~sr ~vdi = ()
let deactivate ctx ~dbg ~dp ~sr ~vdi = ()
Expand Down

0 comments on commit 2e3ef60

Please sign in to comment.