~ubuntu-branches/ubuntu/precise/xen/precise

« back to all changes in this revision

Viewing changes to .pc/upstream-23936:cdb34816a40a-rework/tools/ocaml/libs/xs/queueop.ml

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2011-12-22 04:53:35 UTC
  • mfrom: (0.4.1) (1.3.2) (15.1.5 sid)
  • Revision ID: package-import@ubuntu.com-20111222045335-k2jy47lo9124o7e3
Tags: 4.1.2-2ubuntu1
* Merge from Debian testing.  Remaining changes:
    - libxenstore3.0: Conflict and replaces libxen3.
    - libxen-dev: Conflict and replaces libxen3-dev.
    - xenstore-utils: Conflict and replaces libxen3.
    - xen-utils-4.1: Conflict and replaces libxen3, python-xen-3.3,
      and xen-utils-4.1.
    - Make sure the LDFLAGS value passed is suitable for use by ld
      rather than gcc.
    - Dropped:
      - debian/patches/upstream-23044:d4ca456c0c25
      - debian/patches/upstream-23104:1976adbf2b80
      - debian/patches/upstream-changeset-23146.patch
      - debian/patches/upstream-changeset-23147.patch
      - debian/patches/xen-pirq-resubmit-irq.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
(*
 
2
 * Copyright (C) 2006-2007 XenSource Ltd.
 
3
 * Copyright (C) 2008      Citrix Ltd.
 
4
 * Author Vincent Hanquez <vincent.hanquez@eu.citrix.com>
 
5
 *
 
6
 * This program is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU Lesser General Public License as published
 
8
 * by the Free Software Foundation; version 2.1 only. with the special
 
9
 * exception on linking described in file LICENSE.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU Lesser General Public License for more details.
 
15
 *)
 
16
 
 
17
let data_concat ls = (String.concat "\000" ls) ^ "\000"
 
18
let queue_path ty (tid: int) (path: string) con =
 
19
        let data = data_concat [ path; ] in
 
20
        Xb.queue con (Xb.Packet.create tid 0 ty data)
 
21
 
 
22
(* operations *)
 
23
let directory tid path con = queue_path Xb.Op.Directory tid path con
 
24
let read tid path con = queue_path Xb.Op.Read tid path con
 
25
 
 
26
let getperms tid path con = queue_path Xb.Op.Getperms tid path con
 
27
 
 
28
let debug commands con =
 
29
        Xb.queue con (Xb.Packet.create 0 0 Xb.Op.Debug (data_concat commands))
 
30
 
 
31
let watch path data con =
 
32
        let data = data_concat [ path; data; ] in
 
33
        Xb.queue con (Xb.Packet.create 0 0 Xb.Op.Watch data)
 
34
 
 
35
let unwatch path data con =
 
36
        let data = data_concat [ path; data; ] in
 
37
        Xb.queue con (Xb.Packet.create 0 0 Xb.Op.Unwatch data)
 
38
 
 
39
let transaction_start con =
 
40
        Xb.queue con (Xb.Packet.create 0 0 Xb.Op.Transaction_start (data_concat []))
 
41
 
 
42
let transaction_end tid commit con =
 
43
        let data = data_concat [ (if commit then "T" else "F"); ] in
 
44
        Xb.queue con (Xb.Packet.create tid 0 Xb.Op.Transaction_end data)
 
45
 
 
46
let introduce domid mfn port con =
 
47
        let data = data_concat [ Printf.sprintf "%u" domid;
 
48
                                 Printf.sprintf "%nu" mfn;
 
49
                                 string_of_int port; ] in
 
50
        Xb.queue con (Xb.Packet.create 0 0 Xb.Op.Introduce data)
 
51
 
 
52
let release domid con =
 
53
        let data = data_concat [ Printf.sprintf "%u" domid; ] in
 
54
        Xb.queue con (Xb.Packet.create 0 0 Xb.Op.Release data)
 
55
 
 
56
let resume domid con =
 
57
        let data = data_concat [ Printf.sprintf "%u" domid; ] in
 
58
        Xb.queue con (Xb.Packet.create 0 0 Xb.Op.Resume data)
 
59
 
 
60
let getdomainpath domid con =
 
61
        let data = data_concat [ Printf.sprintf "%u" domid; ] in
 
62
        Xb.queue con (Xb.Packet.create 0 0 Xb.Op.Getdomainpath data)
 
63
 
 
64
let write tid path value con =
 
65
        let data = path ^ "\000" ^ value (* no NULL at the end *) in
 
66
        Xb.queue con (Xb.Packet.create tid 0 Xb.Op.Write data)
 
67
 
 
68
let mkdir tid path con = queue_path Xb.Op.Mkdir tid path con
 
69
let rm tid path con = queue_path Xb.Op.Rm tid path con
 
70
 
 
71
let setperms tid path perms con =
 
72
        let data = data_concat [ path; perms ] in
 
73
        Xb.queue con (Xb.Packet.create tid 0 Xb.Op.Setperms data)