ia64/xen-unstable

changeset 12117:c75716820107

Import libxen-src-0.4.3-2.tar.bz2.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author ewan@linford.intra
date Sat Oct 07 18:22:09 2006 +0100 (2006-10-07)
parents 9e0b024a1696
children 2ea55aa1dd46
files tools/libxen/COPYING tools/libxen/Makefile tools/libxen/README tools/libxen/include/xen_boot_type.h tools/libxen/include/xen_boot_type_internal.h tools/libxen/include/xen_common.h tools/libxen/include/xen_cpu_feature.h tools/libxen/include/xen_cpu_feature_internal.h tools/libxen/include/xen_driver_type.h tools/libxen/include/xen_driver_type_internal.h tools/libxen/include/xen_host.h tools/libxen/include/xen_host_cpu.h tools/libxen/include/xen_host_cpu_decl.h tools/libxen/include/xen_host_decl.h tools/libxen/include/xen_int_float_map.h tools/libxen/include/xen_internal.h tools/libxen/include/xen_network.h tools/libxen/include/xen_network_decl.h tools/libxen/include/xen_on_crash_behaviour.h tools/libxen/include/xen_on_crash_behaviour_internal.h tools/libxen/include/xen_on_normal_exit.h tools/libxen/include/xen_on_normal_exit_internal.h tools/libxen/include/xen_sr.h tools/libxen/include/xen_sr_decl.h tools/libxen/include/xen_string_string_map.h tools/libxen/include/xen_user.h tools/libxen/include/xen_user_decl.h tools/libxen/include/xen_vbd.h tools/libxen/include/xen_vbd_decl.h tools/libxen/include/xen_vbd_mode.h tools/libxen/include/xen_vbd_mode_internal.h tools/libxen/include/xen_vdi.h tools/libxen/include/xen_vdi_decl.h tools/libxen/include/xen_vdi_type.h tools/libxen/include/xen_vdi_type_internal.h tools/libxen/include/xen_vif.h tools/libxen/include/xen_vif_decl.h tools/libxen/include/xen_vm.h tools/libxen/include/xen_vm_decl.h tools/libxen/include/xen_vm_power_state.h tools/libxen/include/xen_vm_power_state_internal.h tools/libxen/src/xen_boot_type.c tools/libxen/src/xen_common.c tools/libxen/src/xen_cpu_feature.c tools/libxen/src/xen_driver_type.c tools/libxen/src/xen_host.c tools/libxen/src/xen_host_cpu.c tools/libxen/src/xen_int_float_map.c tools/libxen/src/xen_network.c tools/libxen/src/xen_on_crash_behaviour.c tools/libxen/src/xen_on_normal_exit.c tools/libxen/src/xen_sr.c tools/libxen/src/xen_string_string_map.c tools/libxen/src/xen_user.c tools/libxen/src/xen_vbd.c tools/libxen/src/xen_vbd_mode.c tools/libxen/src/xen_vdi.c tools/libxen/src/xen_vdi_type.c tools/libxen/src/xen_vif.c tools/libxen/src/xen_vm.c tools/libxen/src/xen_vm_power_state.c tools/libxen/test/test_bindings.c
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/tools/libxen/COPYING	Sat Oct 07 18:22:09 2006 +0100
     1.3 @@ -0,0 +1,510 @@
     1.4 +
     1.5 +                  GNU LESSER GENERAL PUBLIC LICENSE
     1.6 +                       Version 2.1, February 1999
     1.7 +
     1.8 + Copyright (C) 1991, 1999 Free Software Foundation, Inc.
     1.9 +     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    1.10 + Everyone is permitted to copy and distribute verbatim copies
    1.11 + of this license document, but changing it is not allowed.
    1.12 +
    1.13 +[This is the first released version of the Lesser GPL.  It also counts
    1.14 + as the successor of the GNU Library Public License, version 2, hence
    1.15 + the version number 2.1.]
    1.16 +
    1.17 +                            Preamble
    1.18 +
    1.19 +  The licenses for most software are designed to take away your
    1.20 +freedom to share and change it.  By contrast, the GNU General Public
    1.21 +Licenses are intended to guarantee your freedom to share and change
    1.22 +free software--to make sure the software is free for all its users.
    1.23 +
    1.24 +  This license, the Lesser General Public License, applies to some
    1.25 +specially designated software packages--typically libraries--of the
    1.26 +Free Software Foundation and other authors who decide to use it.  You
    1.27 +can use it too, but we suggest you first think carefully about whether
    1.28 +this license or the ordinary General Public License is the better
    1.29 +strategy to use in any particular case, based on the explanations
    1.30 +below.
    1.31 +
    1.32 +  When we speak of free software, we are referring to freedom of use,
    1.33 +not price.  Our General Public Licenses are designed to make sure that
    1.34 +you have the freedom to distribute copies of free software (and charge
    1.35 +for this service if you wish); that you receive source code or can get
    1.36 +it if you want it; that you can change the software and use pieces of
    1.37 +it in new free programs; and that you are informed that you can do
    1.38 +these things.
    1.39 +
    1.40 +  To protect your rights, we need to make restrictions that forbid
    1.41 +distributors to deny you these rights or to ask you to surrender these
    1.42 +rights.  These restrictions translate to certain responsibilities for
    1.43 +you if you distribute copies of the library or if you modify it.
    1.44 +
    1.45 +  For example, if you distribute copies of the library, whether gratis
    1.46 +or for a fee, you must give the recipients all the rights that we gave
    1.47 +you.  You must make sure that they, too, receive or can get the source
    1.48 +code.  If you link other code with the library, you must provide
    1.49 +complete object files to the recipients, so that they can relink them
    1.50 +with the library after making changes to the library and recompiling
    1.51 +it.  And you must show them these terms so they know their rights.
    1.52 +
    1.53 +  We protect your rights with a two-step method: (1) we copyright the
    1.54 +library, and (2) we offer you this license, which gives you legal
    1.55 +permission to copy, distribute and/or modify the library.
    1.56 +
    1.57 +  To protect each distributor, we want to make it very clear that
    1.58 +there is no warranty for the free library.  Also, if the library is
    1.59 +modified by someone else and passed on, the recipients should know
    1.60 +that what they have is not the original version, so that the original
    1.61 +author's reputation will not be affected by problems that might be
    1.62 +introduced by others.
    1.63 +
    1.64 +  Finally, software patents pose a constant threat to the existence of
    1.65 +any free program.  We wish to make sure that a company cannot
    1.66 +effectively restrict the users of a free program by obtaining a
    1.67 +restrictive license from a patent holder.  Therefore, we insist that
    1.68 +any patent license obtained for a version of the library must be
    1.69 +consistent with the full freedom of use specified in this license.
    1.70 +
    1.71 +  Most GNU software, including some libraries, is covered by the
    1.72 +ordinary GNU General Public License.  This license, the GNU Lesser
    1.73 +General Public License, applies to certain designated libraries, and
    1.74 +is quite different from the ordinary General Public License.  We use
    1.75 +this license for certain libraries in order to permit linking those
    1.76 +libraries into non-free programs.
    1.77 +
    1.78 +  When a program is linked with a library, whether statically or using
    1.79 +a shared library, the combination of the two is legally speaking a
    1.80 +combined work, a derivative of the original library.  The ordinary
    1.81 +General Public License therefore permits such linking only if the
    1.82 +entire combination fits its criteria of freedom.  The Lesser General
    1.83 +Public License permits more lax criteria for linking other code with
    1.84 +the library.
    1.85 +
    1.86 +  We call this license the "Lesser" General Public License because it
    1.87 +does Less to protect the user's freedom than the ordinary General
    1.88 +Public License.  It also provides other free software developers Less
    1.89 +of an advantage over competing non-free programs.  These disadvantages
    1.90 +are the reason we use the ordinary General Public License for many
    1.91 +libraries.  However, the Lesser license provides advantages in certain
    1.92 +special circumstances.
    1.93 +
    1.94 +  For example, on rare occasions, there may be a special need to
    1.95 +encourage the widest possible use of a certain library, so that it
    1.96 +becomes a de-facto standard.  To achieve this, non-free programs must
    1.97 +be allowed to use the library.  A more frequent case is that a free
    1.98 +library does the same job as widely used non-free libraries.  In this
    1.99 +case, there is little to gain by limiting the free library to free
   1.100 +software only, so we use the Lesser General Public License.
   1.101 +
   1.102 +  In other cases, permission to use a particular library in non-free
   1.103 +programs enables a greater number of people to use a large body of
   1.104 +free software.  For example, permission to use the GNU C Library in
   1.105 +non-free programs enables many more people to use the whole GNU
   1.106 +operating system, as well as its variant, the GNU/Linux operating
   1.107 +system.
   1.108 +
   1.109 +  Although the Lesser General Public License is Less protective of the
   1.110 +users' freedom, it does ensure that the user of a program that is
   1.111 +linked with the Library has the freedom and the wherewithal to run
   1.112 +that program using a modified version of the Library.
   1.113 +
   1.114 +  The precise terms and conditions for copying, distribution and
   1.115 +modification follow.  Pay close attention to the difference between a
   1.116 +"work based on the library" and a "work that uses the library".  The
   1.117 +former contains code derived from the library, whereas the latter must
   1.118 +be combined with the library in order to run.
   1.119 +
   1.120 +                  GNU LESSER GENERAL PUBLIC LICENSE
   1.121 +   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
   1.122 +
   1.123 +  0. This License Agreement applies to any software library or other
   1.124 +program which contains a notice placed by the copyright holder or
   1.125 +other authorized party saying it may be distributed under the terms of
   1.126 +this Lesser General Public License (also called "this License").
   1.127 +Each licensee is addressed as "you".
   1.128 +
   1.129 +  A "library" means a collection of software functions and/or data
   1.130 +prepared so as to be conveniently linked with application programs
   1.131 +(which use some of those functions and data) to form executables.
   1.132 +
   1.133 +  The "Library", below, refers to any such software library or work
   1.134 +which has been distributed under these terms.  A "work based on the
   1.135 +Library" means either the Library or any derivative work under
   1.136 +copyright law: that is to say, a work containing the Library or a
   1.137 +portion of it, either verbatim or with modifications and/or translated
   1.138 +straightforwardly into another language.  (Hereinafter, translation is
   1.139 +included without limitation in the term "modification".)
   1.140 +
   1.141 +  "Source code" for a work means the preferred form of the work for
   1.142 +making modifications to it.  For a library, complete source code means
   1.143 +all the source code for all modules it contains, plus any associated
   1.144 +interface definition files, plus the scripts used to control
   1.145 +compilation and installation of the library.
   1.146 +
   1.147 +  Activities other than copying, distribution and modification are not
   1.148 +covered by this License; they are outside its scope.  The act of
   1.149 +running a program using the Library is not restricted, and output from
   1.150 +such a program is covered only if its contents constitute a work based
   1.151 +on the Library (independent of the use of the Library in a tool for
   1.152 +writing it).  Whether that is true depends on what the Library does
   1.153 +and what the program that uses the Library does.
   1.154 +
   1.155 +  1. You may copy and distribute verbatim copies of the Library's
   1.156 +complete source code as you receive it, in any medium, provided that
   1.157 +you conspicuously and appropriately publish on each copy an
   1.158 +appropriate copyright notice and disclaimer of warranty; keep intact
   1.159 +all the notices that refer to this License and to the absence of any
   1.160 +warranty; and distribute a copy of this License along with the
   1.161 +Library.
   1.162 +
   1.163 +  You may charge a fee for the physical act of transferring a copy,
   1.164 +and you may at your option offer warranty protection in exchange for a
   1.165 +fee.
   1.166 +
   1.167 +  2. You may modify your copy or copies of the Library or any portion
   1.168 +of it, thus forming a work based on the Library, and copy and
   1.169 +distribute such modifications or work under the terms of Section 1
   1.170 +above, provided that you also meet all of these conditions:
   1.171 +
   1.172 +    a) The modified work must itself be a software library.
   1.173 +
   1.174 +    b) You must cause the files modified to carry prominent notices
   1.175 +    stating that you changed the files and the date of any change.
   1.176 +
   1.177 +    c) You must cause the whole of the work to be licensed at no
   1.178 +    charge to all third parties under the terms of this License.
   1.179 +
   1.180 +    d) If a facility in the modified Library refers to a function or a
   1.181 +    table of data to be supplied by an application program that uses
   1.182 +    the facility, other than as an argument passed when the facility
   1.183 +    is invoked, then you must make a good faith effort to ensure that,
   1.184 +    in the event an application does not supply such function or
   1.185 +    table, the facility still operates, and performs whatever part of
   1.186 +    its purpose remains meaningful.
   1.187 +
   1.188 +    (For example, a function in a library to compute square roots has
   1.189 +    a purpose that is entirely well-defined independent of the
   1.190 +    application.  Therefore, Subsection 2d requires that any
   1.191 +    application-supplied function or table used by this function must
   1.192 +    be optional: if the application does not supply it, the square
   1.193 +    root function must still compute square roots.)
   1.194 +
   1.195 +These requirements apply to the modified work as a whole.  If
   1.196 +identifiable sections of that work are not derived from the Library,
   1.197 +and can be reasonably considered independent and separate works in
   1.198 +themselves, then this License, and its terms, do not apply to those
   1.199 +sections when you distribute them as separate works.  But when you
   1.200 +distribute the same sections as part of a whole which is a work based
   1.201 +on the Library, the distribution of the whole must be on the terms of
   1.202 +this License, whose permissions for other licensees extend to the
   1.203 +entire whole, and thus to each and every part regardless of who wrote
   1.204 +it.
   1.205 +
   1.206 +Thus, it is not the intent of this section to claim rights or contest
   1.207 +your rights to work written entirely by you; rather, the intent is to
   1.208 +exercise the right to control the distribution of derivative or
   1.209 +collective works based on the Library.
   1.210 +
   1.211 +In addition, mere aggregation of another work not based on the Library
   1.212 +with the Library (or with a work based on the Library) on a volume of
   1.213 +a storage or distribution medium does not bring the other work under
   1.214 +the scope of this License.
   1.215 +
   1.216 +  3. You may opt to apply the terms of the ordinary GNU General Public
   1.217 +License instead of this License to a given copy of the Library.  To do
   1.218 +this, you must alter all the notices that refer to this License, so
   1.219 +that they refer to the ordinary GNU General Public License, version 2,
   1.220 +instead of to this License.  (If a newer version than version 2 of the
   1.221 +ordinary GNU General Public License has appeared, then you can specify
   1.222 +that version instead if you wish.)  Do not make any other change in
   1.223 +these notices.
   1.224 +
   1.225 +  Once this change is made in a given copy, it is irreversible for
   1.226 +that copy, so the ordinary GNU General Public License applies to all
   1.227 +subsequent copies and derivative works made from that copy.
   1.228 +
   1.229 +  This option is useful when you wish to copy part of the code of
   1.230 +the Library into a program that is not a library.
   1.231 +
   1.232 +  4. You may copy and distribute the Library (or a portion or
   1.233 +derivative of it, under Section 2) in object code or executable form
   1.234 +under the terms of Sections 1 and 2 above provided that you accompany
   1.235 +it with the complete corresponding machine-readable source code, which
   1.236 +must be distributed under the terms of Sections 1 and 2 above on a
   1.237 +medium customarily used for software interchange.
   1.238 +
   1.239 +  If distribution of object code is made by offering access to copy
   1.240 +from a designated place, then offering equivalent access to copy the
   1.241 +source code from the same place satisfies the requirement to
   1.242 +distribute the source code, even though third parties are not
   1.243 +compelled to copy the source along with the object code.
   1.244 +
   1.245 +  5. A program that contains no derivative of any portion of the
   1.246 +Library, but is designed to work with the Library by being compiled or
   1.247 +linked with it, is called a "work that uses the Library".  Such a
   1.248 +work, in isolation, is not a derivative work of the Library, and
   1.249 +therefore falls outside the scope of this License.
   1.250 +
   1.251 +  However, linking a "work that uses the Library" with the Library
   1.252 +creates an executable that is a derivative of the Library (because it
   1.253 +contains portions of the Library), rather than a "work that uses the
   1.254 +library".  The executable is therefore covered by this License.
   1.255 +Section 6 states terms for distribution of such executables.
   1.256 +
   1.257 +  When a "work that uses the Library" uses material from a header file
   1.258 +that is part of the Library, the object code for the work may be a
   1.259 +derivative work of the Library even though the source code is not.
   1.260 +Whether this is true is especially significant if the work can be
   1.261 +linked without the Library, or if the work is itself a library.  The
   1.262 +threshold for this to be true is not precisely defined by law.
   1.263 +
   1.264 +  If such an object file uses only numerical parameters, data
   1.265 +structure layouts and accessors, and small macros and small inline
   1.266 +functions (ten lines or less in length), then the use of the object
   1.267 +file is unrestricted, regardless of whether it is legally a derivative
   1.268 +work.  (Executables containing this object code plus portions of the
   1.269 +Library will still fall under Section 6.)
   1.270 +
   1.271 +  Otherwise, if the work is a derivative of the Library, you may
   1.272 +distribute the object code for the work under the terms of Section 6.
   1.273 +Any executables containing that work also fall under Section 6,
   1.274 +whether or not they are linked directly with the Library itself.
   1.275 +
   1.276 +  6. As an exception to the Sections above, you may also combine or
   1.277 +link a "work that uses the Library" with the Library to produce a
   1.278 +work containing portions of the Library, and distribute that work
   1.279 +under terms of your choice, provided that the terms permit
   1.280 +modification of the work for the customer's own use and reverse
   1.281 +engineering for debugging such modifications.
   1.282 +
   1.283 +  You must give prominent notice with each copy of the work that the
   1.284 +Library is used in it and that the Library and its use are covered by
   1.285 +this License.  You must supply a copy of this License.  If the work
   1.286 +during execution displays copyright notices, you must include the
   1.287 +copyright notice for the Library among them, as well as a reference
   1.288 +directing the user to the copy of this License.  Also, you must do one
   1.289 +of these things:
   1.290 +
   1.291 +    a) Accompany the work with the complete corresponding
   1.292 +    machine-readable source code for the Library including whatever
   1.293 +    changes were used in the work (which must be distributed under
   1.294 +    Sections 1 and 2 above); and, if the work is an executable linked
   1.295 +    with the Library, with the complete machine-readable "work that
   1.296 +    uses the Library", as object code and/or source code, so that the
   1.297 +    user can modify the Library and then relink to produce a modified
   1.298 +    executable containing the modified Library.  (It is understood
   1.299 +    that the user who changes the contents of definitions files in the
   1.300 +    Library will not necessarily be able to recompile the application
   1.301 +    to use the modified definitions.)
   1.302 +
   1.303 +    b) Use a suitable shared library mechanism for linking with the
   1.304 +    Library.  A suitable mechanism is one that (1) uses at run time a
   1.305 +    copy of the library already present on the user's computer system,
   1.306 +    rather than copying library functions into the executable, and (2)
   1.307 +    will operate properly with a modified version of the library, if
   1.308 +    the user installs one, as long as the modified version is
   1.309 +    interface-compatible with the version that the work was made with.
   1.310 +
   1.311 +    c) Accompany the work with a written offer, valid for at least
   1.312 +    three years, to give the same user the materials specified in
   1.313 +    Subsection 6a, above, for a charge no more than the cost of
   1.314 +    performing this distribution.
   1.315 +
   1.316 +    d) If distribution of the work is made by offering access to copy
   1.317 +    from a designated place, offer equivalent access to copy the above
   1.318 +    specified materials from the same place.
   1.319 +
   1.320 +    e) Verify that the user has already received a copy of these
   1.321 +    materials or that you have already sent this user a copy.
   1.322 +
   1.323 +  For an executable, the required form of the "work that uses the
   1.324 +Library" must include any data and utility programs needed for
   1.325 +reproducing the executable from it.  However, as a special exception,
   1.326 +the materials to be distributed need not include anything that is
   1.327 +normally distributed (in either source or binary form) with the major
   1.328 +components (compiler, kernel, and so on) of the operating system on
   1.329 +which the executable runs, unless that component itself accompanies
   1.330 +the executable.
   1.331 +
   1.332 +  It may happen that this requirement contradicts the license
   1.333 +restrictions of other proprietary libraries that do not normally
   1.334 +accompany the operating system.  Such a contradiction means you cannot
   1.335 +use both them and the Library together in an executable that you
   1.336 +distribute.
   1.337 +
   1.338 +  7. You may place library facilities that are a work based on the
   1.339 +Library side-by-side in a single library together with other library
   1.340 +facilities not covered by this License, and distribute such a combined
   1.341 +library, provided that the separate distribution of the work based on
   1.342 +the Library and of the other library facilities is otherwise
   1.343 +permitted, and provided that you do these two things:
   1.344 +
   1.345 +    a) Accompany the combined library with a copy of the same work
   1.346 +    based on the Library, uncombined with any other library
   1.347 +    facilities.  This must be distributed under the terms of the
   1.348 +    Sections above.
   1.349 +
   1.350 +    b) Give prominent notice with the combined library of the fact
   1.351 +    that part of it is a work based on the Library, and explaining
   1.352 +    where to find the accompanying uncombined form of the same work.
   1.353 +
   1.354 +  8. You may not copy, modify, sublicense, link with, or distribute
   1.355 +the Library except as expressly provided under this License.  Any
   1.356 +attempt otherwise to copy, modify, sublicense, link with, or
   1.357 +distribute the Library is void, and will automatically terminate your
   1.358 +rights under this License.  However, parties who have received copies,
   1.359 +or rights, from you under this License will not have their licenses
   1.360 +terminated so long as such parties remain in full compliance.
   1.361 +
   1.362 +  9. You are not required to accept this License, since you have not
   1.363 +signed it.  However, nothing else grants you permission to modify or
   1.364 +distribute the Library or its derivative works.  These actions are
   1.365 +prohibited by law if you do not accept this License.  Therefore, by
   1.366 +modifying or distributing the Library (or any work based on the
   1.367 +Library), you indicate your acceptance of this License to do so, and
   1.368 +all its terms and conditions for copying, distributing or modifying
   1.369 +the Library or works based on it.
   1.370 +
   1.371 +  10. Each time you redistribute the Library (or any work based on the
   1.372 +Library), the recipient automatically receives a license from the
   1.373 +original licensor to copy, distribute, link with or modify the Library
   1.374 +subject to these terms and conditions.  You may not impose any further
   1.375 +restrictions on the recipients' exercise of the rights granted herein.
   1.376 +You are not responsible for enforcing compliance by third parties with
   1.377 +this License.
   1.378 +
   1.379 +  11. If, as a consequence of a court judgment or allegation of patent
   1.380 +infringement or for any other reason (not limited to patent issues),
   1.381 +conditions are imposed on you (whether by court order, agreement or
   1.382 +otherwise) that contradict the conditions of this License, they do not
   1.383 +excuse you from the conditions of this License.  If you cannot
   1.384 +distribute so as to satisfy simultaneously your obligations under this
   1.385 +License and any other pertinent obligations, then as a consequence you
   1.386 +may not distribute the Library at all.  For example, if a patent
   1.387 +license would not permit royalty-free redistribution of the Library by
   1.388 +all those who receive copies directly or indirectly through you, then
   1.389 +the only way you could satisfy both it and this License would be to
   1.390 +refrain entirely from distribution of the Library.
   1.391 +
   1.392 +If any portion of this section is held invalid or unenforceable under
   1.393 +any particular circumstance, the balance of the section is intended to
   1.394 +apply, and the section as a whole is intended to apply in other
   1.395 +circumstances.
   1.396 +
   1.397 +It is not the purpose of this section to induce you to infringe any
   1.398 +patents or other property right claims or to contest validity of any
   1.399 +such claims; this section has the sole purpose of protecting the
   1.400 +integrity of the free software distribution system which is
   1.401 +implemented by public license practices.  Many people have made
   1.402 +generous contributions to the wide range of software distributed
   1.403 +through that system in reliance on consistent application of that
   1.404 +system; it is up to the author/donor to decide if he or she is willing
   1.405 +to distribute software through any other system and a licensee cannot
   1.406 +impose that choice.
   1.407 +
   1.408 +This section is intended to make thoroughly clear what is believed to
   1.409 +be a consequence of the rest of this License.
   1.410 +
   1.411 +  12. If the distribution and/or use of the Library is restricted in
   1.412 +certain countries either by patents or by copyrighted interfaces, the
   1.413 +original copyright holder who places the Library under this License
   1.414 +may add an explicit geographical distribution limitation excluding those
   1.415 +countries, so that distribution is permitted only in or among
   1.416 +countries not thus excluded.  In such case, this License incorporates
   1.417 +the limitation as if written in the body of this License.
   1.418 +
   1.419 +  13. The Free Software Foundation may publish revised and/or new
   1.420 +versions of the Lesser General Public License from time to time.
   1.421 +Such new versions will be similar in spirit to the present version,
   1.422 +but may differ in detail to address new problems or concerns.
   1.423 +
   1.424 +Each version is given a distinguishing version number.  If the Library
   1.425 +specifies a version number of this License which applies to it and
   1.426 +"any later version", you have the option of following the terms and
   1.427 +conditions either of that version or of any later version published by
   1.428 +the Free Software Foundation.  If the Library does not specify a
   1.429 +license version number, you may choose any version ever published by
   1.430 +the Free Software Foundation.
   1.431 +
   1.432 +  14. If you wish to incorporate parts of the Library into other free
   1.433 +programs whose distribution conditions are incompatible with these,
   1.434 +write to the author to ask for permission.  For software which is
   1.435 +copyrighted by the Free Software Foundation, write to the Free
   1.436 +Software Foundation; we sometimes make exceptions for this.  Our
   1.437 +decision will be guided by the two goals of preserving the free status
   1.438 +of all derivatives of our free software and of promoting the sharing
   1.439 +and reuse of software generally.
   1.440 +
   1.441 +                            NO WARRANTY
   1.442 +
   1.443 +  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
   1.444 +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
   1.445 +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
   1.446 +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
   1.447 +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
   1.448 +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   1.449 +PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
   1.450 +LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
   1.451 +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
   1.452 +
   1.453 +  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
   1.454 +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
   1.455 +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
   1.456 +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
   1.457 +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
   1.458 +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
   1.459 +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
   1.460 +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
   1.461 +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
   1.462 +DAMAGES.
   1.463 +
   1.464 +                     END OF TERMS AND CONDITIONS
   1.465 +
   1.466 +           How to Apply These Terms to Your New Libraries
   1.467 +
   1.468 +  If you develop a new library, and you want it to be of the greatest
   1.469 +possible use to the public, we recommend making it free software that
   1.470 +everyone can redistribute and change.  You can do so by permitting
   1.471 +redistribution under these terms (or, alternatively, under the terms
   1.472 +of the ordinary General Public License).
   1.473 +
   1.474 +  To apply these terms, attach the following notices to the library.
   1.475 +It is safest to attach them to the start of each source file to most
   1.476 +effectively convey the exclusion of warranty; and each file should
   1.477 +have at least the "copyright" line and a pointer to where the full
   1.478 +notice is found.
   1.479 +
   1.480 +
   1.481 +    <one line to give the library's name and a brief idea of what it does.>
   1.482 +    Copyright (C) <year>  <name of author>
   1.483 +
   1.484 +    This library is free software; you can redistribute it and/or
   1.485 +    modify it under the terms of the GNU Lesser General Public
   1.486 +    License as published by the Free Software Foundation; either
   1.487 +    version 2.1 of the License, or (at your option) any later version.
   1.488 +
   1.489 +    This library is distributed in the hope that it will be useful,
   1.490 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   1.491 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   1.492 +    Lesser General Public License for more details.
   1.493 +
   1.494 +    You should have received a copy of the GNU Lesser General Public
   1.495 +    License along with this library; if not, write to the Free Software
   1.496 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   1.497 +
   1.498 +Also add information on how to contact you by electronic and paper mail.
   1.499 +
   1.500 +You should also get your employer (if you work as a programmer) or
   1.501 +your school, if any, to sign a "copyright disclaimer" for the library,
   1.502 +if necessary.  Here is a sample; alter the names:
   1.503 +
   1.504 +  Yoyodyne, Inc., hereby disclaims all copyright interest in the
   1.505 +  library `Frob' (a library for tweaking knobs) written by James
   1.506 +  Random Hacker.
   1.507 +
   1.508 +  <signature of Ty Coon>, 1 April 1990
   1.509 +  Ty Coon, President of Vice
   1.510 +
   1.511 +That's all there is to it!
   1.512 +
   1.513 +
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/tools/libxen/Makefile	Sat Oct 07 18:22:09 2006 +0100
     2.3 @@ -0,0 +1,37 @@
     2.4 +#
     2.5 +# Copyright (c) 2006, XenSource Inc.
     2.6 +#
     2.7 +# This library is free software; you can redistribute it and/or
     2.8 +# modify it under the terms of the GNU Lesser General Public
     2.9 +# License as published by the Free Software Foundation; either
    2.10 +# version 2.1 of the License, or (at your option) any later version.
    2.11 +#
    2.12 +# This library is distributed in the hope that it will be useful,
    2.13 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
    2.14 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    2.15 +# Lesser General Public License for more details.
    2.16 +#
    2.17 +# You should have received a copy of the GNU Lesser General Public
    2.18 +# License along with this library; if not, write to the Free Software
    2.19 +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
    2.20 +#
    2.21 +
    2.22 +CFLAGS = -Iinclude                     \
    2.23 +         $(shell xml2-config --cflags) \
    2.24 +         $(shell curl-config --cflags) \
    2.25 +         -W -Wall -Werror -std=c99 -O2 -fPIC
    2.26 +
    2.27 +LDFLAGS = $(shell xml2-config --libs) \
    2.28 +          $(shell curl-config --libs)
    2.29 +
    2.30 +test/test_bindings: test/test_bindings.o src/libxen.so
    2.31 +	$(CC) $(LDFLAGS) -o $@ $< -L src -lxen
    2.32 +
    2.33 +src/libxen.so: $(patsubst %.c, %.o, $(wildcard src/*.c))
    2.34 +	$(CC) -shared -o $@ $^
    2.35 +
    2.36 +.PHONY: clean
    2.37 +clean:
    2.38 +	rm -f `find -name *.o`
    2.39 +	rm -f src/libxen.so
    2.40 +	rm -f test/test_bindings
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/tools/libxen/README	Sat Oct 07 18:22:09 2006 +0100
     3.3 @@ -0,0 +1,54 @@
     3.4 +Xen API C Bindings
     3.5 +==================
     3.6 +
     3.7 +This distribution is the source code to the proposed Xen API C bindings.
     3.8 +
     3.9 +The Xen API project will define an XML-RPC protocol for remote and local
    3.10 +management of Xen-based systems, and a set of bindings for these XML-RPC calls
    3.11 +into a number of languages (this package contains those to the C language).
    3.12 +
    3.13 +The intention is to standardise these XML-RPC calls, and then the Xen project
    3.14 +will guarantee that that wire protocol will be supported for the long term.
    3.15 +The bindings will also be supported in the Xen tree, giving a stable
    3.16 +foundation for Xen management tools and middlewares, in particular the Xen CIM
    3.17 +providers and libvirt.
    3.18 +
    3.19 +THIS IS A WORK IN PROGRESS.  The API and bindings are under active design and
    3.20 +development, and this is a snapshot release for developers only.  Both the API
    3.21 +and the C bindings are scheduled to be stabilised by the Xen 3.0.4 release
    3.22 +i.e. October 2006 at the earliest.
    3.23 +
    3.24 +These bindings are open-source (LGPL), and will be committed as libraries to
    3.25 +the Xen trees for all to use after the Xen 3.0.3 release.
    3.26 +
    3.27 +We welcome any discussion about this library and the API in general.  Please
    3.28 +join the Xen-API mailing list if you are interested in this project. I (Ewan
    3.29 +Mellor) will collate all the feedback from that list and push out new versions
    3.30 +of the document and the bindings as and when.
    3.31 +
    3.32 +
    3.33 +URLs
    3.34 +----
    3.35 +
    3.36 +Xen-API wiki page:
    3.37 +http://wiki.xensource.com/xenwiki/XenApi
    3.38 +
    3.39 +Xen-API mailing list:
    3.40 +  http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-api
    3.41 +
    3.42 +
    3.43 +Usage
    3.44 +-----
    3.45 +
    3.46 +The bindings depend upon libxml2, the XML toolkit from the GNOME project; the
    3.47 +test program depends upon libcurl3 also.  On Debian, you need the packages
    3.48 +libxml2-dev and libcurl3-dev.
    3.49 +
    3.50 +To compile, type make.
    3.51 +
    3.52 +To run the test, do
    3.53 +
    3.54 +LD_LIBRARY_PATH=src ./test/test_bindings <url> <username> <password>
    3.55 +
    3.56 +where <url> is the fragment of the server URL that follows the http://, for
    3.57 +example "localhost:8005/RPC2".
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/tools/libxen/include/xen_boot_type.h	Sat Oct 07 18:22:09 2006 +0100
     4.3 @@ -0,0 +1,87 @@
     4.4 +/*
     4.5 + * Copyright (c) 2006, XenSource Inc.
     4.6 + *
     4.7 + * This library is free software; you can redistribute it and/or
     4.8 + * modify it under the terms of the GNU Lesser General Public
     4.9 + * License as published by the Free Software Foundation; either
    4.10 + * version 2.1 of the License, or (at your option) any later version.
    4.11 + *
    4.12 + * This library is distributed in the hope that it will be useful,
    4.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    4.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    4.15 + * Lesser General Public License for more details.
    4.16 + *
    4.17 + * You should have received a copy of the GNU Lesser General Public
    4.18 + * License along with this library; if not, write to the Free Software
    4.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
    4.20 + */
    4.21 +
    4.22 +#ifndef XEN_BOOT_TYPE_H
    4.23 +#define XEN_BOOT_TYPE_H
    4.24 +
    4.25 +
    4.26 +#include "xen_common.h"
    4.27 +
    4.28 +
    4.29 +enum xen_boot_type
    4.30 +{
    4.31 +    /**
    4.32 +     * boot an HVM guest using an emulated BIOS
    4.33 +     */
    4.34 +    XEN_BOOT_TYPE_BIOS,
    4.35 +
    4.36 +    /**
    4.37 +     * boot from inside the machine using grub
    4.38 +     */
    4.39 +    XEN_BOOT_TYPE_GRUB,
    4.40 +
    4.41 +    /**
    4.42 +     * boot from an external kernel
    4.43 +     */
    4.44 +    XEN_BOOT_TYPE_KERNEL_EXTERNAL,
    4.45 +
    4.46 +    /**
    4.47 +     * boot from a kernel inside the guest filesystem
    4.48 +     */
    4.49 +    XEN_BOOT_TYPE_KERNEL_INTERNAL
    4.50 +};
    4.51 +
    4.52 +
    4.53 +typedef struct xen_boot_type_set
    4.54 +{
    4.55 +    size_t size;
    4.56 +    enum xen_boot_type contents[];
    4.57 +} xen_boot_type_set;
    4.58 +
    4.59 +/**
    4.60 + * Allocate a xen_boot_type_set of the given size.
    4.61 + */
    4.62 +extern xen_boot_type_set *
    4.63 +xen_boot_type_set_alloc(size_t size);
    4.64 +
    4.65 +/**
    4.66 + * Free the given xen_boot_type_set.  The given set must have been
    4.67 + * allocated by this library.
    4.68 + */
    4.69 +extern void
    4.70 +xen_boot_type_set_free(xen_boot_type_set *set);
    4.71 +
    4.72 +
    4.73 +/**
    4.74 + * Return the name corresponding to the given code.  This string must
    4.75 + * not be modified or freed.
    4.76 + */
    4.77 +extern const char *
    4.78 +xen_boot_type_to_string(enum xen_boot_type val);
    4.79 +
    4.80 +
    4.81 +/**
    4.82 + * Return the correct code for the given string, or set the session
    4.83 + * object to failure and return an undefined value if the given string does
    4.84 + * not match a known code.
    4.85 + */
    4.86 +extern enum xen_boot_type
    4.87 +xen_boot_type_from_string(xen_session *session, const char *str);
    4.88 +
    4.89 +
    4.90 +#endif
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/tools/libxen/include/xen_boot_type_internal.h	Sat Oct 07 18:22:09 2006 +0100
     5.3 @@ -0,0 +1,37 @@
     5.4 +/*
     5.5 + * Copyright (c) 2006, XenSource Inc.
     5.6 + *
     5.7 + * This library is free software; you can redistribute it and/or
     5.8 + * modify it under the terms of the GNU Lesser General Public
     5.9 + * License as published by the Free Software Foundation; either
    5.10 + * version 2.1 of the License, or (at your option) any later version.
    5.11 + *
    5.12 + * This library is distributed in the hope that it will be useful,
    5.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    5.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    5.15 + * Lesser General Public License for more details.
    5.16 + *
    5.17 + * You should have received a copy of the GNU Lesser General Public
    5.18 + * License along with this library; if not, write to the Free Software
    5.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
    5.20 + */
    5.21 +
    5.22 +
    5.23 +/*
    5.24 + * Declarations of the abstract types used during demarshalling of enum
    5.25 + * xen_boot_type.  Internal to this library -- do not use from outside.
    5.26 + */
    5.27 +
    5.28 +
    5.29 +#ifndef XEN_BOOT_TYPE_INTERNAL_H
    5.30 +#define XEN_BOOT_TYPE_INTERNAL_H
    5.31 +
    5.32 +
    5.33 +#include "xen_internal.h"
    5.34 +
    5.35 +
    5.36 +extern const abstract_type xen_boot_type_abstract_type_;
    5.37 +extern const abstract_type xen_boot_type_set_abstract_type_;
    5.38 +
    5.39 +
    5.40 +#endif
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/tools/libxen/include/xen_common.h	Sat Oct 07 18:22:09 2006 +0100
     6.3 @@ -0,0 +1,145 @@
     6.4 +/*
     6.5 +  Copyright (c) 2006 XenSource, Inc.
     6.6 + *
     6.7 + * This library is free software; you can redistribute it and/or
     6.8 + * modify it under the terms of the GNU Lesser General Public
     6.9 + * License as published by the Free Software Foundation; either
    6.10 + * version 2.1 of the License, or (at your option) any later version.
    6.11 + *
    6.12 + * This library is distributed in the hope that it will be useful,
    6.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    6.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    6.15 + * Lesser General Public License for more details.
    6.16 + *
    6.17 + * You should have received a copy of the GNU Lesser General Public
    6.18 + * License along with this library; if not, write to the Free Software
    6.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
    6.20 +*/
    6.21 +
    6.22 +#ifndef XEN_COMMON_H
    6.23 +#define XEN_COMMON_H
    6.24 +
    6.25 +
    6.26 +#include <stdbool.h>
    6.27 +#include <stddef.h>
    6.28 +#include <stdint.h>
    6.29 +#include <time.h>
    6.30 +
    6.31 +#include "xen_host_decl.h"
    6.32 +
    6.33 +
    6.34 +typedef bool (*xen_result_func)(const void *data, size_t len,
    6.35 +                                void *result_handle);
    6.36 +
    6.37 +
    6.38 +/**
    6.39 + * len does not include a terminating \0.
    6.40 + */
    6.41 +typedef int (*xen_call_func)(const void *, size_t len, void *user_handle,
    6.42 +                             void *result_handle,
    6.43 +                             xen_result_func result_func);
    6.44 +
    6.45 +
    6.46 +typedef struct
    6.47 +{
    6.48 +    xen_call_func call_func;
    6.49 +    void *handle;
    6.50 +    const char *session_id;
    6.51 +    bool ok;
    6.52 +    char **error_description;
    6.53 +    int error_description_count;
    6.54 +} xen_session;
    6.55 +
    6.56 +
    6.57 +struct xen_task_;
    6.58 +typedef struct xen_task_ * xen_task_id;
    6.59 +
    6.60 +
    6.61 +typedef struct
    6.62 +{
    6.63 +    int progress;
    6.64 +    long eta;
    6.65 +    /* !!! RESULT */
    6.66 +}  xen_task_status;
    6.67 +
    6.68 +
    6.69 +typedef struct
    6.70 +{
    6.71 +    int major;
    6.72 +    int minor;
    6.73 +    int patch;
    6.74 +    char *extraversion;
    6.75 +} xen_version;
    6.76 +
    6.77 +
    6.78 +/**
    6.79 + * Free the given xen_version, and all referenced values.
    6.80 + */
    6.81 +extern void xen_version_free(xen_version *version);
    6.82 +
    6.83 +
    6.84 +/**
    6.85 + * Return the version of this client-side library.  This will be the major,
    6.86 + * minor, and extraversion of the Xen release with which it was released,
    6.87 + * plus the library's own version as the patch.
    6.88 + */
    6.89 +extern xen_version *xen_get_client_side_version();
    6.90 +
    6.91 +
    6.92 +extern bool
    6.93 +xen_uuid_string_to_bytes(char *uuid, char **bytes);
    6.94 +
    6.95 +
    6.96 +extern bool
    6.97 +xen_uuid_bytes_to_string(char *bytes, char **uuid);
    6.98 +
    6.99 +
   6.100 +extern void
   6.101 +xen_uuid_free(char *uuid);
   6.102 +
   6.103 +
   6.104 +extern void
   6.105 +xen_uuid_bytes_free(char *bytes);
   6.106 +
   6.107 +
   6.108 +/**
   6.109 + * Initialise this library.  Call this before starting to use this library.
   6.110 + * Note that since this library depends upon libxml2, you should also call
   6.111 + * xmlInitParser as appropriate for your program.
   6.112 + */
   6.113 +extern
   6.114 +void xen_init(void);
   6.115 +
   6.116 +
   6.117 +/**
   6.118 + * Clear up this library.  Call when you have finished using this library.
   6.119 + * Note that since this library depends upon libxml2, you should also call
   6.120 + * xmlCleanupParser as appropriate for your program.
   6.121 + */
   6.122 +extern
   6.123 +void xen_fini(void);
   6.124 +
   6.125 +
   6.126 +/**
   6.127 + * Log in at the server, and allocate a xen_session to represent this session.
   6.128 + */
   6.129 +extern xen_session *
   6.130 +xen_session_login_with_password(xen_call_func call_func, void *handle,
   6.131 +                                const char *uname, const char *pwd);
   6.132 +
   6.133 +
   6.134 +/**
   6.135 + * Log out at the server, and free the xen_session.
   6.136 + */
   6.137 +extern void
   6.138 +xen_session_logout(xen_session *session);
   6.139 +
   6.140 +
   6.141 +/**
   6.142 + * Set *result to be a handle to the host to which this session is connected.
   6.143 + */
   6.144 +extern int
   6.145 +xen_session_get_this_host(xen_session *session, xen_host *result);
   6.146 +
   6.147 +
   6.148 +#endif
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/tools/libxen/include/xen_cpu_feature.h	Sat Oct 07 18:22:09 2006 +0100
     7.3 @@ -0,0 +1,382 @@
     7.4 +/*
     7.5 + * Copyright (c) 2006, XenSource Inc.
     7.6 + *
     7.7 + * This library is free software; you can redistribute it and/or
     7.8 + * modify it under the terms of the GNU Lesser General Public
     7.9 + * License as published by the Free Software Foundation; either
    7.10 + * version 2.1 of the License, or (at your option) any later version.
    7.11 + *
    7.12 + * This library is distributed in the hope that it will be useful,
    7.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    7.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    7.15 + * Lesser General Public License for more details.
    7.16 + *
    7.17 + * You should have received a copy of the GNU Lesser General Public
    7.18 + * License along with this library; if not, write to the Free Software
    7.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
    7.20 + */
    7.21 +
    7.22 +#ifndef XEN_CPU_FEATURE_H
    7.23 +#define XEN_CPU_FEATURE_H
    7.24 +
    7.25 +
    7.26 +#include "xen_common.h"
    7.27 +
    7.28 +
    7.29 +enum xen_cpu_feature
    7.30 +{
    7.31 +    /**
    7.32 +     *  Onboard FPU
    7.33 +     */
    7.34 +    XEN_CPU_FEATURE_FPU,
    7.35 +
    7.36 +    /**
    7.37 +     *  Virtual Mode Extensions
    7.38 +     */
    7.39 +    XEN_CPU_FEATURE_VME,
    7.40 +
    7.41 +    /**
    7.42 +     *  Debugging Extensions
    7.43 +     */
    7.44 +    XEN_CPU_FEATURE_DE,
    7.45 +
    7.46 +    /**
    7.47 +     *  Page Size Extensions
    7.48 +     */
    7.49 +    XEN_CPU_FEATURE_PSE,
    7.50 +
    7.51 +    /**
    7.52 +     *  Time Stamp Counter
    7.53 +     */
    7.54 +    XEN_CPU_FEATURE_TSC,
    7.55 +
    7.56 +    /**
    7.57 +     *  Model-Specific Registers, RDMSR, WRMSR
    7.58 +     */
    7.59 +    XEN_CPU_FEATURE_MSR,
    7.60 +
    7.61 +    /**
    7.62 +     *  Physical Address Extensions
    7.63 +     */
    7.64 +    XEN_CPU_FEATURE_PAE,
    7.65 +
    7.66 +    /**
    7.67 +     *  Machine Check Architecture
    7.68 +     */
    7.69 +    XEN_CPU_FEATURE_MCE,
    7.70 +
    7.71 +    /**
    7.72 +     *  CMPXCHG8 instruction
    7.73 +     */
    7.74 +    XEN_CPU_FEATURE_CX8,
    7.75 +
    7.76 +    /**
    7.77 +     *  Onboard APIC
    7.78 +     */
    7.79 +    XEN_CPU_FEATURE_APIC,
    7.80 +
    7.81 +    /**
    7.82 +     *  SYSENTER/SYSEXIT
    7.83 +     */
    7.84 +    XEN_CPU_FEATURE_SEP,
    7.85 +
    7.86 +    /**
    7.87 +     *  Memory Type Range Registers
    7.88 +     */
    7.89 +    XEN_CPU_FEATURE_MTRR,
    7.90 +
    7.91 +    /**
    7.92 +     *  Page Global Enable
    7.93 +     */
    7.94 +    XEN_CPU_FEATURE_PGE,
    7.95 +
    7.96 +    /**
    7.97 +     *  Machine Check Architecture
    7.98 +     */
    7.99 +    XEN_CPU_FEATURE_MCA,
   7.100 +
   7.101 +    /**
   7.102 +     *  CMOV instruction (FCMOVCC and FCOMI too if FPU present)
   7.103 +     */
   7.104 +    XEN_CPU_FEATURE_CMOV,
   7.105 +
   7.106 +    /**
   7.107 +     *  Page Attribute Table
   7.108 +     */
   7.109 +    XEN_CPU_FEATURE_PAT,
   7.110 +
   7.111 +    /**
   7.112 +     *  36-bit PSEs
   7.113 +     */
   7.114 +    XEN_CPU_FEATURE_PSE36,
   7.115 +
   7.116 +    /**
   7.117 +     *  Processor serial number
   7.118 +     */
   7.119 +    XEN_CPU_FEATURE_PN,
   7.120 +
   7.121 +    /**
   7.122 +     *  Supports the CLFLUSH instruction
   7.123 +     */
   7.124 +    XEN_CPU_FEATURE_CLFLSH,
   7.125 +
   7.126 +    /**
   7.127 +     *  Debug Trace Store
   7.128 +     */
   7.129 +    XEN_CPU_FEATURE_DTES,
   7.130 +
   7.131 +    /**
   7.132 +     *  ACPI via MSR
   7.133 +     */
   7.134 +    XEN_CPU_FEATURE_ACPI,
   7.135 +
   7.136 +    /**
   7.137 +     *  Multimedia Extensions
   7.138 +     */
   7.139 +    XEN_CPU_FEATURE_MMX,
   7.140 +
   7.141 +    /**
   7.142 +     *  FXSAVE and FXRSTOR instructions (fast save and restore
   7.143 +     */
   7.144 +    XEN_CPU_FEATURE_FXSR,
   7.145 +
   7.146 +    /**
   7.147 +     *  Streaming SIMD Extensions
   7.148 +     */
   7.149 +    XEN_CPU_FEATURE_XMM,
   7.150 +
   7.151 +    /**
   7.152 +     *  Streaming SIMD Extensions-2
   7.153 +     */
   7.154 +    XEN_CPU_FEATURE_XMM2,
   7.155 +
   7.156 +    /**
   7.157 +     *  CPU self snoop
   7.158 +     */
   7.159 +    XEN_CPU_FEATURE_SELFSNOOP,
   7.160 +
   7.161 +    /**
   7.162 +     *  Hyper-Threading
   7.163 +     */
   7.164 +    XEN_CPU_FEATURE_HT,
   7.165 +
   7.166 +    /**
   7.167 +     *  Automatic clock control
   7.168 +     */
   7.169 +    XEN_CPU_FEATURE_ACC,
   7.170 +
   7.171 +    /**
   7.172 +     *  IA-64 processor
   7.173 +     */
   7.174 +    XEN_CPU_FEATURE_IA64,
   7.175 +
   7.176 +    /**
   7.177 +     *  SYSCALL/SYSRET
   7.178 +     */
   7.179 +    XEN_CPU_FEATURE_SYSCALL,
   7.180 +
   7.181 +    /**
   7.182 +     *  MP Capable.
   7.183 +     */
   7.184 +    XEN_CPU_FEATURE_MP,
   7.185 +
   7.186 +    /**
   7.187 +     *  Execute Disable
   7.188 +     */
   7.189 +    XEN_CPU_FEATURE_NX,
   7.190 +
   7.191 +    /**
   7.192 +     *  AMD MMX extensions
   7.193 +     */
   7.194 +    XEN_CPU_FEATURE_MMXEXT,
   7.195 +
   7.196 +    /**
   7.197 +     *  Long Mode (x86-64)
   7.198 +     */
   7.199 +    XEN_CPU_FEATURE_LM,
   7.200 +
   7.201 +    /**
   7.202 +     *  AMD 3DNow! extensions
   7.203 +     */
   7.204 +    XEN_CPU_FEATURE_3DNOWEXT,
   7.205 +
   7.206 +    /**
   7.207 +     *  3DNow!
   7.208 +     */
   7.209 +    XEN_CPU_FEATURE_3DNOW,
   7.210 +
   7.211 +    /**
   7.212 +     *  CPU in recovery mode
   7.213 +     */
   7.214 +    XEN_CPU_FEATURE_RECOVERY,
   7.215 +
   7.216 +    /**
   7.217 +     *  Longrun power control
   7.218 +     */
   7.219 +    XEN_CPU_FEATURE_LONGRUN,
   7.220 +
   7.221 +    /**
   7.222 +     *  LongRun table interface
   7.223 +     */
   7.224 +    XEN_CPU_FEATURE_LRTI,
   7.225 +
   7.226 +    /**
   7.227 +     *  Cyrix MMX extensions
   7.228 +     */
   7.229 +    XEN_CPU_FEATURE_CXMMX,
   7.230 +
   7.231 +    /**
   7.232 +     *  AMD K6 nonstandard MTRRs
   7.233 +     */
   7.234 +    XEN_CPU_FEATURE_K6_MTRR,
   7.235 +
   7.236 +    /**
   7.237 +     *  Cyrix ARRs (= MTRRs)
   7.238 +     */
   7.239 +    XEN_CPU_FEATURE_CYRIX_ARR,
   7.240 +
   7.241 +    /**
   7.242 +     *  Centaur MCRs (= MTRRs)
   7.243 +     */
   7.244 +    XEN_CPU_FEATURE_CENTAUR_MCR,
   7.245 +
   7.246 +    /**
   7.247 +     *  Opteron, Athlon64
   7.248 +     */
   7.249 +    XEN_CPU_FEATURE_K8,
   7.250 +
   7.251 +    /**
   7.252 +     *  Athlon
   7.253 +     */
   7.254 +    XEN_CPU_FEATURE_K7,
   7.255 +
   7.256 +    /**
   7.257 +     *  P3
   7.258 +     */
   7.259 +    XEN_CPU_FEATURE_P3,
   7.260 +
   7.261 +    /**
   7.262 +     *  P4
   7.263 +     */
   7.264 +    XEN_CPU_FEATURE_P4,
   7.265 +
   7.266 +    /**
   7.267 +     *  TSC ticks at a constant rate
   7.268 +     */
   7.269 +    XEN_CPU_FEATURE_CONSTANT_TSC,
   7.270 +
   7.271 +    /**
   7.272 +     *  FXSAVE leaks FOP/FIP/FOP
   7.273 +     */
   7.274 +    XEN_CPU_FEATURE_FXSAVE_LEAK,
   7.275 +
   7.276 +    /**
   7.277 +     *  Streaming SIMD Extensions-3
   7.278 +     */
   7.279 +    XEN_CPU_FEATURE_XMM3,
   7.280 +
   7.281 +    /**
   7.282 +     *  Monitor/Mwait support
   7.283 +     */
   7.284 +    XEN_CPU_FEATURE_MWAIT,
   7.285 +
   7.286 +    /**
   7.287 +     *  CPL Qualified Debug Store
   7.288 +     */
   7.289 +    XEN_CPU_FEATURE_DSCPL,
   7.290 +
   7.291 +    /**
   7.292 +     *  Enhanced SpeedStep
   7.293 +     */
   7.294 +    XEN_CPU_FEATURE_EST,
   7.295 +
   7.296 +    /**
   7.297 +     *  Thermal Monitor 2
   7.298 +     */
   7.299 +    XEN_CPU_FEATURE_TM2,
   7.300 +
   7.301 +    /**
   7.302 +     *  Context ID
   7.303 +     */
   7.304 +    XEN_CPU_FEATURE_CID,
   7.305 +
   7.306 +    /**
   7.307 +     *  CMPXCHG16B
   7.308 +     */
   7.309 +    XEN_CPU_FEATURE_CX16,
   7.310 +
   7.311 +    /**
   7.312 +     *  Send Task Priority Messages
   7.313 +     */
   7.314 +    XEN_CPU_FEATURE_XTPR,
   7.315 +
   7.316 +    /**
   7.317 +     *  on-CPU RNG present (xstore insn)
   7.318 +     */
   7.319 +    XEN_CPU_FEATURE_XSTORE,
   7.320 +
   7.321 +    /**
   7.322 +     *  on-CPU RNG enabled
   7.323 +     */
   7.324 +    XEN_CPU_FEATURE_XSTORE_EN,
   7.325 +
   7.326 +    /**
   7.327 +     *  on-CPU crypto (xcrypt insn)
   7.328 +     */
   7.329 +    XEN_CPU_FEATURE_XCRYPT,
   7.330 +
   7.331 +    /**
   7.332 +     *  on-CPU crypto enabled
   7.333 +     */
   7.334 +    XEN_CPU_FEATURE_XCRYPT_EN,
   7.335 +
   7.336 +    /**
   7.337 +     *  LAHF/SAHF in long mode
   7.338 +     */
   7.339 +    XEN_CPU_FEATURE_LAHF_LM,
   7.340 +
   7.341 +    /**
   7.342 +     *  If yes HyperThreading not valid
   7.343 +     */
   7.344 +    XEN_CPU_FEATURE_CMP_LEGACY
   7.345 +};
   7.346 +
   7.347 +
   7.348 +typedef struct xen_cpu_feature_set
   7.349 +{
   7.350 +    size_t size;
   7.351 +    enum xen_cpu_feature contents[];
   7.352 +} xen_cpu_feature_set;
   7.353 +
   7.354 +/**
   7.355 + * Allocate a xen_cpu_feature_set of the given size.
   7.356 + */
   7.357 +extern xen_cpu_feature_set *
   7.358 +xen_cpu_feature_set_alloc(size_t size);
   7.359 +
   7.360 +/**
   7.361 + * Free the given xen_cpu_feature_set.  The given set must have been
   7.362 + * allocated by this library.
   7.363 + */
   7.364 +extern void
   7.365 +xen_cpu_feature_set_free(xen_cpu_feature_set *set);
   7.366 +
   7.367 +
   7.368 +/**
   7.369 + * Return the name corresponding to the given code.  This string must
   7.370 + * not be modified or freed.
   7.371 + */
   7.372 +extern const char *
   7.373 +xen_cpu_feature_to_string(enum xen_cpu_feature val);
   7.374 +
   7.375 +
   7.376 +/**
   7.377 + * Return the correct code for the given string, or set the session
   7.378 + * object to failure and return an undefined value if the given string does
   7.379 + * not match a known code.
   7.380 + */
   7.381 +extern enum xen_cpu_feature
   7.382 +xen_cpu_feature_from_string(xen_session *session, const char *str);
   7.383 +
   7.384 +
   7.385 +#endif
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/tools/libxen/include/xen_cpu_feature_internal.h	Sat Oct 07 18:22:09 2006 +0100
     8.3 @@ -0,0 +1,37 @@
     8.4 +/*
     8.5 + * Copyright (c) 2006, XenSource Inc.
     8.6 + *
     8.7 + * This library is free software; you can redistribute it and/or
     8.8 + * modify it under the terms of the GNU Lesser General Public
     8.9 + * License as published by the Free Software Foundation; either
    8.10 + * version 2.1 of the License, or (at your option) any later version.
    8.11 + *
    8.12 + * This library is distributed in the hope that it will be useful,
    8.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    8.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    8.15 + * Lesser General Public License for more details.
    8.16 + *
    8.17 + * You should have received a copy of the GNU Lesser General Public
    8.18 + * License along with this library; if not, write to the Free Software
    8.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
    8.20 + */
    8.21 +
    8.22 +
    8.23 +/*
    8.24 + * Declarations of the abstract types used during demarshalling of enum
    8.25 + * xen_cpu_feature.  Internal to this library -- do not use from outside.
    8.26 + */
    8.27 +
    8.28 +
    8.29 +#ifndef XEN_CPU_FEATURE_INTERNAL_H
    8.30 +#define XEN_CPU_FEATURE_INTERNAL_H
    8.31 +
    8.32 +
    8.33 +#include "xen_internal.h"
    8.34 +
    8.35 +
    8.36 +extern const abstract_type xen_cpu_feature_abstract_type_;
    8.37 +extern const abstract_type xen_cpu_feature_set_abstract_type_;
    8.38 +
    8.39 +
    8.40 +#endif
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/tools/libxen/include/xen_driver_type.h	Sat Oct 07 18:22:09 2006 +0100
     9.3 @@ -0,0 +1,77 @@
     9.4 +/*
     9.5 + * Copyright (c) 2006, XenSource Inc.
     9.6 + *
     9.7 + * This library is free software; you can redistribute it and/or
     9.8 + * modify it under the terms of the GNU Lesser General Public
     9.9 + * License as published by the Free Software Foundation; either
    9.10 + * version 2.1 of the License, or (at your option) any later version.
    9.11 + *
    9.12 + * This library is distributed in the hope that it will be useful,
    9.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    9.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    9.15 + * Lesser General Public License for more details.
    9.16 + *
    9.17 + * You should have received a copy of the GNU Lesser General Public
    9.18 + * License along with this library; if not, write to the Free Software
    9.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
    9.20 + */
    9.21 +
    9.22 +#ifndef XEN_DRIVER_TYPE_H
    9.23 +#define XEN_DRIVER_TYPE_H
    9.24 +
    9.25 +
    9.26 +#include "xen_common.h"
    9.27 +
    9.28 +
    9.29 +enum xen_driver_type
    9.30 +{
    9.31 +    /**
    9.32 +     * use hardware emulation
    9.33 +     */
    9.34 +    XEN_DRIVER_TYPE_IOEMU,
    9.35 +
    9.36 +    /**
    9.37 +     * use paravirtualised driver
    9.38 +     */
    9.39 +    XEN_DRIVER_TYPE_PARAVIRTUALISED
    9.40 +};
    9.41 +
    9.42 +
    9.43 +typedef struct xen_driver_type_set
    9.44 +{
    9.45 +    size_t size;
    9.46 +    enum xen_driver_type contents[];
    9.47 +} xen_driver_type_set;
    9.48 +
    9.49 +/**
    9.50 + * Allocate a xen_driver_type_set of the given size.
    9.51 + */
    9.52 +extern xen_driver_type_set *
    9.53 +xen_driver_type_set_alloc(size_t size);
    9.54 +
    9.55 +/**
    9.56 + * Free the given xen_driver_type_set.  The given set must have been
    9.57 + * allocated by this library.
    9.58 + */
    9.59 +extern void
    9.60 +xen_driver_type_set_free(xen_driver_type_set *set);
    9.61 +
    9.62 +
    9.63 +/**
    9.64 + * Return the name corresponding to the given code.  This string must
    9.65 + * not be modified or freed.
    9.66 + */
    9.67 +extern const char *
    9.68 +xen_driver_type_to_string(enum xen_driver_type val);
    9.69 +
    9.70 +
    9.71 +/**
    9.72 + * Return the correct code for the given string, or set the session
    9.73 + * object to failure and return an undefined value if the given string does
    9.74 + * not match a known code.
    9.75 + */
    9.76 +extern enum xen_driver_type
    9.77 +xen_driver_type_from_string(xen_session *session, const char *str);
    9.78 +
    9.79 +
    9.80 +#endif
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/tools/libxen/include/xen_driver_type_internal.h	Sat Oct 07 18:22:09 2006 +0100
    10.3 @@ -0,0 +1,37 @@
    10.4 +/*
    10.5 + * Copyright (c) 2006, XenSource Inc.
    10.6 + *
    10.7 + * This library is free software; you can redistribute it and/or
    10.8 + * modify it under the terms of the GNU Lesser General Public
    10.9 + * License as published by the Free Software Foundation; either
   10.10 + * version 2.1 of the License, or (at your option) any later version.
   10.11 + *
   10.12 + * This library is distributed in the hope that it will be useful,
   10.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   10.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   10.15 + * Lesser General Public License for more details.
   10.16 + *
   10.17 + * You should have received a copy of the GNU Lesser General Public
   10.18 + * License along with this library; if not, write to the Free Software
   10.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   10.20 + */
   10.21 +
   10.22 +
   10.23 +/*
   10.24 + * Declarations of the abstract types used during demarshalling of enum
   10.25 + * xen_driver_type.  Internal to this library -- do not use from outside.
   10.26 + */
   10.27 +
   10.28 +
   10.29 +#ifndef XEN_DRIVER_TYPE_INTERNAL_H
   10.30 +#define XEN_DRIVER_TYPE_INTERNAL_H
   10.31 +
   10.32 +
   10.33 +#include "xen_internal.h"
   10.34 +
   10.35 +
   10.36 +extern const abstract_type xen_driver_type_abstract_type_;
   10.37 +extern const abstract_type xen_driver_type_set_abstract_type_;
   10.38 +
   10.39 +
   10.40 +#endif
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/tools/libxen/include/xen_host.h	Sat Oct 07 18:22:09 2006 +0100
    11.3 @@ -0,0 +1,276 @@
    11.4 +/*
    11.5 + * Copyright (c) 2006, XenSource Inc.
    11.6 + *
    11.7 + * This library is free software; you can redistribute it and/or
    11.8 + * modify it under the terms of the GNU Lesser General Public
    11.9 + * License as published by the Free Software Foundation; either
   11.10 + * version 2.1 of the License, or (at your option) any later version.
   11.11 + *
   11.12 + * This library is distributed in the hope that it will be useful,
   11.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   11.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   11.15 + * Lesser General Public License for more details.
   11.16 + *
   11.17 + * You should have received a copy of the GNU Lesser General Public
   11.18 + * License along with this library; if not, write to the Free Software
   11.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   11.20 + */
   11.21 +
   11.22 +#ifndef XEN_HOST_H
   11.23 +#define XEN_HOST_H
   11.24 +
   11.25 +#include "xen_common.h"
   11.26 +#include "xen_host_cpu_decl.h"
   11.27 +#include "xen_host_decl.h"
   11.28 +#include "xen_string_string_map.h"
   11.29 +#include "xen_vm_decl.h"
   11.30 +
   11.31 +
   11.32 +/*
   11.33 + * The host class. 
   11.34 + *  
   11.35 + * A physical host.
   11.36 + */
   11.37 +
   11.38 +
   11.39 +/**
   11.40 + * Free the given xen_host.  The given handle must have been allocated
   11.41 + * by this library.
   11.42 + */
   11.43 +extern void
   11.44 +xen_host_free(xen_host host);
   11.45 +
   11.46 +
   11.47 +typedef struct xen_host_set
   11.48 +{
   11.49 +    size_t size;
   11.50 +    xen_host *contents[];
   11.51 +} xen_host_set;
   11.52 +
   11.53 +/**
   11.54 + * Allocate a xen_host_set of the given size.
   11.55 + */
   11.56 +extern xen_host_set *
   11.57 +xen_host_set_alloc(size_t size);
   11.58 +
   11.59 +/**
   11.60 + * Free the given xen_host_set.  The given set must have been allocated
   11.61 + * by this library.
   11.62 + */
   11.63 +extern void
   11.64 +xen_host_set_free(xen_host_set *set);
   11.65 +
   11.66 +
   11.67 +typedef struct xen_host_record
   11.68 +{
   11.69 +    xen_host handle;
   11.70 +    char *uuid;
   11.71 +    char *name_label;
   11.72 +    char *name_description;
   11.73 +    xen_string_string_map *software_version;
   11.74 +    struct xen_vm_record_opt_set *resident_vms;
   11.75 +    struct xen_host_cpu_record_opt_set *host_cpus;
   11.76 +} xen_host_record;
   11.77 +
   11.78 +/**
   11.79 + * Allocate a xen_host_record.
   11.80 + */
   11.81 +extern xen_host_record *
   11.82 +xen_host_record_alloc(void);
   11.83 +
   11.84 +/**
   11.85 + * Free the given xen_host_record, and all referenced values.  The
   11.86 + * given record must have been allocated by this library.
   11.87 + */
   11.88 +extern void
   11.89 +xen_host_record_free(xen_host_record *record);
   11.90 +
   11.91 +
   11.92 +typedef struct xen_host_record_opt
   11.93 +{
   11.94 +    bool is_record;
   11.95 +    union
   11.96 +    {
   11.97 +        xen_host handle;
   11.98 +        xen_host_record *record;
   11.99 +    } u;
  11.100 +} xen_host_record_opt;
  11.101 +
  11.102 +/**
  11.103 + * Allocate a xen_host_record_opt.
  11.104 + */
  11.105 +extern xen_host_record_opt *
  11.106 +xen_host_record_opt_alloc(void);
  11.107 +
  11.108 +/**
  11.109 + * Free the given xen_host_record_opt, and all referenced values.  The
  11.110 + * given record_opt must have been allocated by this library.
  11.111 + */
  11.112 +extern void
  11.113 +xen_host_record_opt_free(xen_host_record_opt *record_opt);
  11.114 +
  11.115 +
  11.116 +typedef struct xen_host_record_set
  11.117 +{
  11.118 +    size_t size;
  11.119 +    xen_host_record *contents[];
  11.120 +} xen_host_record_set;
  11.121 +
  11.122 +/**
  11.123 + * Allocate a xen_host_record_set of the given size.
  11.124 + */
  11.125 +extern xen_host_record_set *
  11.126 +xen_host_record_set_alloc(size_t size);
  11.127 +
  11.128 +/**
  11.129 + * Free the given xen_host_record_set, and all referenced values.  The
  11.130 + * given set must have been allocated by this library.
  11.131 + */
  11.132 +extern void
  11.133 +xen_host_record_set_free(xen_host_record_set *set);
  11.134 +
  11.135 +
  11.136 +
  11.137 +typedef struct xen_host_record_opt_set
  11.138 +{
  11.139 +    size_t size;
  11.140 +    xen_host_record_opt *contents[];
  11.141 +} xen_host_record_opt_set;
  11.142 +
  11.143 +/**
  11.144 + * Allocate a xen_host_record_opt_set of the given size.
  11.145 + */
  11.146 +extern xen_host_record_opt_set *
  11.147 +xen_host_record_opt_set_alloc(size_t size);
  11.148 +
  11.149 +/**
  11.150 + * Free the given xen_host_record_opt_set, and all referenced values. 
  11.151 + * The given set must have been allocated by this library.
  11.152 + */
  11.153 +extern void
  11.154 +xen_host_record_opt_set_free(xen_host_record_opt_set *set);
  11.155 +
  11.156 +
  11.157 +/**
  11.158 + * Get the current state of the given host.  !!!
  11.159 + */
  11.160 +extern bool
  11.161 +xen_host_get_record(xen_session *session, xen_host_record **result, xen_host host);
  11.162 +
  11.163 +
  11.164 +/**
  11.165 + * Get a reference to the object with the specified UUID.  !!!
  11.166 + */
  11.167 +extern bool
  11.168 +xen_host_get_by_uuid(xen_session *session, xen_host *result, char *uuid);
  11.169 +
  11.170 +
  11.171 +/**
  11.172 + * Create a new host instance, and return its handle.
  11.173 + */
  11.174 +extern bool
  11.175 +xen_host_create(xen_session *session, xen_host *result, xen_host_record *record);
  11.176 +
  11.177 +
  11.178 +/**
  11.179 + * Get a reference to the object with the specified label.
  11.180 + */
  11.181 +extern bool
  11.182 +xen_host_get_by_name_label(xen_session *session, xen_host *result, char *label);
  11.183 +
  11.184 +
  11.185 +/**
  11.186 + * Get the uuid field of the given host.
  11.187 + */
  11.188 +extern bool
  11.189 +xen_host_get_uuid(xen_session *session, char **result, xen_host host);
  11.190 +
  11.191 +
  11.192 +/**
  11.193 + * Get the name/label field of the given host.
  11.194 + */
  11.195 +extern bool
  11.196 +xen_host_get_name_label(xen_session *session, char **result, xen_host host);
  11.197 +
  11.198 +
  11.199 +/**
  11.200 + * Get the name/description field of the given host.
  11.201 + */
  11.202 +extern bool
  11.203 +xen_host_get_name_description(xen_session *session, char **result, xen_host host);
  11.204 +
  11.205 +
  11.206 +/**
  11.207 + * Get the software_version field of the given host.
  11.208 + */
  11.209 +extern bool
  11.210 +xen_host_get_software_version(xen_session *session, xen_string_string_map **result, xen_host host);
  11.211 +
  11.212 +
  11.213 +/**
  11.214 + * Get the resident_VMs field of the given host.
  11.215 + */
  11.216 +extern bool
  11.217 +xen_host_get_resident_vms(xen_session *session, xen_vm *result, xen_host host);
  11.218 +
  11.219 +
  11.220 +/**
  11.221 + * Get the host_CPUs field of the given host.
  11.222 + */
  11.223 +extern bool
  11.224 +xen_host_get_host_cpus(xen_session *session, xen_host_cpu *result, xen_host host);
  11.225 +
  11.226 +
  11.227 +/**
  11.228 + * Set the name/label field of the given host.
  11.229 + */
  11.230 +extern bool
  11.231 +xen_host_set_name_label(xen_session *session, xen_host xen_host, char *label);
  11.232 +
  11.233 +
  11.234 +/**
  11.235 + * Set the name/description field of the given host.
  11.236 + */
  11.237 +extern bool
  11.238 +xen_host_set_name_description(xen_session *session, xen_host xen_host, char *description);
  11.239 +
  11.240 +
  11.241 +/**
  11.242 + * Puts the host into a state in which no new VMs can be started.
  11.243 + * Currently active VMs on the host continue to execute.
  11.244 + */
  11.245 +extern bool
  11.246 +xen_host_disable(xen_session *session, xen_host host);
  11.247 +
  11.248 +
  11.249 +/**
  11.250 + * Puts the host into a state in which new VMs can be started.
  11.251 + */
  11.252 +extern bool
  11.253 +xen_host_enable(xen_session *session, xen_host host);
  11.254 +
  11.255 +
  11.256 +/**
  11.257 + * Shutdown the host. (This function can only be called if there are no
  11.258 + * currently running VMs on the host and it is disabled.)
  11.259 + */
  11.260 +extern bool
  11.261 +xen_host_shutdown(xen_session *session, xen_host host);
  11.262 +
  11.263 +
  11.264 +/**
  11.265 + * Reboot the host. (This function can only be called if there are no
  11.266 + * currently running VMs on the host and it is disabled.)
  11.267 + */
  11.268 +extern bool
  11.269 +xen_host_reboot(xen_session *session, xen_host host);
  11.270 +
  11.271 +
  11.272 +/**
  11.273 + * Return a list of all the hosts known to the system
  11.274 + */
  11.275 +extern bool
  11.276 +xen_host_get_all(xen_session *session, xen_host *result);
  11.277 +
  11.278 +
  11.279 +#endif
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/tools/libxen/include/xen_host_cpu.h	Sat Oct 07 18:22:09 2006 +0100
    12.3 @@ -0,0 +1,208 @@
    12.4 +/*
    12.5 + * Copyright (c) 2006, XenSource Inc.
    12.6 + *
    12.7 + * This library is free software; you can redistribute it and/or
    12.8 + * modify it under the terms of the GNU Lesser General Public
    12.9 + * License as published by the Free Software Foundation; either
   12.10 + * version 2.1 of the License, or (at your option) any later version.
   12.11 + *
   12.12 + * This library is distributed in the hope that it will be useful,
   12.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   12.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   12.15 + * Lesser General Public License for more details.
   12.16 + *
   12.17 + * You should have received a copy of the GNU Lesser General Public
   12.18 + * License along with this library; if not, write to the Free Software
   12.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   12.20 + */
   12.21 +
   12.22 +#ifndef XEN_HOST_CPU_H
   12.23 +#define XEN_HOST_CPU_H
   12.24 +
   12.25 +#include "xen_common.h"
   12.26 +#include "xen_cpu_feature.h"
   12.27 +#include "xen_host_cpu_decl.h"
   12.28 +#include "xen_host_decl.h"
   12.29 +
   12.30 +
   12.31 +/*
   12.32 + * The host_cpu class. 
   12.33 + *  
   12.34 + * A physical CPU.
   12.35 + */
   12.36 +
   12.37 +
   12.38 +/**
   12.39 + * Free the given xen_host_cpu.  The given handle must have been
   12.40 + * allocated by this library.
   12.41 + */
   12.42 +extern void
   12.43 +xen_host_cpu_free(xen_host_cpu host_cpu);
   12.44 +
   12.45 +
   12.46 +typedef struct xen_host_cpu_set
   12.47 +{
   12.48 +    size_t size;
   12.49 +    xen_host_cpu *contents[];
   12.50 +} xen_host_cpu_set;
   12.51 +
   12.52 +/**
   12.53 + * Allocate a xen_host_cpu_set of the given size.
   12.54 + */
   12.55 +extern xen_host_cpu_set *
   12.56 +xen_host_cpu_set_alloc(size_t size);
   12.57 +
   12.58 +/**
   12.59 + * Free the given xen_host_cpu_set.  The given set must have been
   12.60 + * allocated by this library.
   12.61 + */
   12.62 +extern void
   12.63 +xen_host_cpu_set_free(xen_host_cpu_set *set);
   12.64 +
   12.65 +
   12.66 +typedef struct xen_host_cpu_record
   12.67 +{
   12.68 +    xen_host_cpu handle;
   12.69 +    char *uuid;
   12.70 +    struct xen_host_record_opt *host;
   12.71 +    uint64_t number;
   12.72 +    struct xen_cpu_feature_set *features;
   12.73 +    double utilisation;
   12.74 +} xen_host_cpu_record;
   12.75 +
   12.76 +/**
   12.77 + * Allocate a xen_host_cpu_record.
   12.78 + */
   12.79 +extern xen_host_cpu_record *
   12.80 +xen_host_cpu_record_alloc(void);
   12.81 +
   12.82 +/**
   12.83 + * Free the given xen_host_cpu_record, and all referenced values.  The
   12.84 + * given record must have been allocated by this library.
   12.85 + */
   12.86 +extern void
   12.87 +xen_host_cpu_record_free(xen_host_cpu_record *record);
   12.88 +
   12.89 +
   12.90 +typedef struct xen_host_cpu_record_opt
   12.91 +{
   12.92 +    bool is_record;
   12.93 +    union
   12.94 +    {
   12.95 +        xen_host_cpu handle;
   12.96 +        xen_host_cpu_record *record;
   12.97 +    } u;
   12.98 +} xen_host_cpu_record_opt;
   12.99 +
  12.100 +/**
  12.101 + * Allocate a xen_host_cpu_record_opt.
  12.102 + */
  12.103 +extern xen_host_cpu_record_opt *
  12.104 +xen_host_cpu_record_opt_alloc(void);
  12.105 +
  12.106 +/**
  12.107 + * Free the given xen_host_cpu_record_opt, and all referenced values. 
  12.108 + * The given record_opt must have been allocated by this library.
  12.109 + */
  12.110 +extern void
  12.111 +xen_host_cpu_record_opt_free(xen_host_cpu_record_opt *record_opt);
  12.112 +
  12.113 +
  12.114 +typedef struct xen_host_cpu_record_set
  12.115 +{
  12.116 +    size_t size;
  12.117 +    xen_host_cpu_record *contents[];
  12.118 +} xen_host_cpu_record_set;
  12.119 +
  12.120 +/**
  12.121 + * Allocate a xen_host_cpu_record_set of the given size.
  12.122 + */
  12.123 +extern xen_host_cpu_record_set *
  12.124 +xen_host_cpu_record_set_alloc(size_t size);
  12.125 +
  12.126 +/**
  12.127 + * Free the given xen_host_cpu_record_set, and all referenced values. 
  12.128 + * The given set must have been allocated by this library.
  12.129 + */
  12.130 +extern void
  12.131 +xen_host_cpu_record_set_free(xen_host_cpu_record_set *set);
  12.132 +
  12.133 +
  12.134 +
  12.135 +typedef struct xen_host_cpu_record_opt_set
  12.136 +{
  12.137 +    size_t size;
  12.138 +    xen_host_cpu_record_opt *contents[];
  12.139 +} xen_host_cpu_record_opt_set;
  12.140 +
  12.141 +/**
  12.142 + * Allocate a xen_host_cpu_record_opt_set of the given size.
  12.143 + */
  12.144 +extern xen_host_cpu_record_opt_set *
  12.145 +xen_host_cpu_record_opt_set_alloc(size_t size);
  12.146 +
  12.147 +/**
  12.148 + * Free the given xen_host_cpu_record_opt_set, and all referenced
  12.149 + * values.  The given set must have been allocated by this library.
  12.150 + */
  12.151 +extern void
  12.152 +xen_host_cpu_record_opt_set_free(xen_host_cpu_record_opt_set *set);
  12.153 +
  12.154 +
  12.155 +/**
  12.156 + * Get the current state of the given host_cpu.  !!!
  12.157 + */
  12.158 +extern bool
  12.159 +xen_host_cpu_get_record(xen_session *session, xen_host_cpu_record **result, xen_host_cpu host_cpu);
  12.160 +
  12.161 +
  12.162 +/**
  12.163 + * Get a reference to the object with the specified UUID.  !!!
  12.164 + */
  12.165 +extern bool
  12.166 +xen_host_cpu_get_by_uuid(xen_session *session, xen_host_cpu *result, char *uuid);
  12.167 +
  12.168 +
  12.169 +/**
  12.170 + * Create a new host_cpu instance, and return its handle.
  12.171 + */
  12.172 +extern bool
  12.173 +xen_host_cpu_create(xen_session *session, xen_host_cpu *result, xen_host_cpu_record *record);
  12.174 +
  12.175 +
  12.176 +/**
  12.177 + * Get the uuid field of the given host_cpu.
  12.178 + */
  12.179 +extern bool
  12.180 +xen_host_cpu_get_uuid(xen_session *session, char **result, xen_host_cpu host_cpu);
  12.181 +
  12.182 +
  12.183 +/**
  12.184 + * Get the host field of the given host_cpu.
  12.185 + */
  12.186 +extern bool
  12.187 +xen_host_cpu_get_host(xen_session *session, xen_host *result, xen_host_cpu host_cpu);
  12.188 +
  12.189 +
  12.190 +/**
  12.191 + * Get the number field of the given host_cpu.
  12.192 + */
  12.193 +extern bool
  12.194 +xen_host_cpu_get_number(xen_session *session, uint64_t *result, xen_host_cpu host_cpu);
  12.195 +
  12.196 +
  12.197 +/**
  12.198 + * Get the features field of the given host_cpu.
  12.199 + */
  12.200 +extern bool
  12.201 +xen_host_cpu_get_features(xen_session *session, struct xen_cpu_feature_set **result, xen_host_cpu host_cpu);
  12.202 +
  12.203 +
  12.204 +/**
  12.205 + * Get the utilisation field of the given host_cpu.
  12.206 + */
  12.207 +extern bool
  12.208 +xen_host_cpu_get_utilisation(xen_session *session, double *result, xen_host_cpu host_cpu);
  12.209 +
  12.210 +
  12.211 +#endif
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/tools/libxen/include/xen_host_cpu_decl.h	Sat Oct 07 18:22:09 2006 +0100
    13.3 @@ -0,0 +1,30 @@
    13.4 +/*
    13.5 + * Copyright (c) 2006, XenSource Inc.
    13.6 + *
    13.7 + * This library is free software; you can redistribute it and/or
    13.8 + * modify it under the terms of the GNU Lesser General Public
    13.9 + * License as published by the Free Software Foundation; either
   13.10 + * version 2.1 of the License, or (at your option) any later version.
   13.11 + *
   13.12 + * This library is distributed in the hope that it will be useful,
   13.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   13.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   13.15 + * Lesser General Public License for more details.
   13.16 + *
   13.17 + * You should have received a copy of the GNU Lesser General Public
   13.18 + * License along with this library; if not, write to the Free Software
   13.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   13.20 + */
   13.21 +
   13.22 +#ifndef XEN_HOST_CPU_DECL_H
   13.23 +#define XEN_HOST_CPU_DECL_H
   13.24 +
   13.25 +typedef void *xen_host_cpu;
   13.26 +
   13.27 +struct xen_host_cpu_set;
   13.28 +struct xen_host_cpu_record;
   13.29 +struct xen_host_cpu_record_set;
   13.30 +struct xen_host_cpu_record_opt;
   13.31 +struct xen_host_cpu_record_opt_set;
   13.32 +
   13.33 +#endif
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/tools/libxen/include/xen_host_decl.h	Sat Oct 07 18:22:09 2006 +0100
    14.3 @@ -0,0 +1,30 @@
    14.4 +/*
    14.5 + * Copyright (c) 2006, XenSource Inc.
    14.6 + *
    14.7 + * This library is free software; you can redistribute it and/or
    14.8 + * modify it under the terms of the GNU Lesser General Public
    14.9 + * License as published by the Free Software Foundation; either
   14.10 + * version 2.1 of the License, or (at your option) any later version.
   14.11 + *
   14.12 + * This library is distributed in the hope that it will be useful,
   14.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   14.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   14.15 + * Lesser General Public License for more details.
   14.16 + *
   14.17 + * You should have received a copy of the GNU Lesser General Public
   14.18 + * License along with this library; if not, write to the Free Software
   14.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   14.20 + */
   14.21 +
   14.22 +#ifndef XEN_HOST_DECL_H
   14.23 +#define XEN_HOST_DECL_H
   14.24 +
   14.25 +typedef void *xen_host;
   14.26 +
   14.27 +struct xen_host_set;
   14.28 +struct xen_host_record;
   14.29 +struct xen_host_record_set;
   14.30 +struct xen_host_record_opt;
   14.31 +struct xen_host_record_opt_set;
   14.32 +
   14.33 +#endif
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/tools/libxen/include/xen_int_float_map.h	Sat Oct 07 18:22:09 2006 +0100
    15.3 @@ -0,0 +1,53 @@
    15.4 +/*
    15.5 + * Copyright (c) 2006, XenSource Inc.
    15.6 + *
    15.7 + * This library is free software; you can redistribute it and/or
    15.8 + * modify it under the terms of the GNU Lesser General Public
    15.9 + * License as published by the Free Software Foundation; either
   15.10 + * version 2.1 of the License, or (at your option) any later version.
   15.11 + *
   15.12 + * This library is distributed in the hope that it will be useful,
   15.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   15.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   15.15 + * Lesser General Public License for more details.
   15.16 + *
   15.17 + * You should have received a copy of the GNU Lesser General Public
   15.18 + * License along with this library; if not, write to the Free Software
   15.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   15.20 + */
   15.21 +
   15.22 +#ifndef XEN_INT_FLOAT_MAP_H
   15.23 +#define XEN_INT_FLOAT_MAP_H
   15.24 +
   15.25 +
   15.26 +#include "xen_common.h"
   15.27 +
   15.28 +
   15.29 +typedef struct xen_int_float_map_contents
   15.30 +{
   15.31 +  uint64_t key;
   15.32 +  double val;
   15.33 +} xen_int_float_map_contents;
   15.34 +
   15.35 +
   15.36 +typedef struct xen_int_float_map
   15.37 +{
   15.38 +    size_t size;
   15.39 +    xen_int_float_map_contents contents[];
   15.40 +} xen_int_float_map;
   15.41 +
   15.42 +/**
   15.43 + * Allocate a xen_int_float_map of the given size.
   15.44 + */
   15.45 +extern xen_int_float_map *
   15.46 +xen_int_float_map_alloc(size_t size);
   15.47 +
   15.48 +/**
   15.49 + * Free the given xen_int_float_map, and all referenced values.  The
   15.50 + * given map must have been allocated by this library.
   15.51 + */
   15.52 +extern void
   15.53 +xen_int_float_map_free(xen_int_float_map *map);
   15.54 +
   15.55 +
   15.56 +#endif
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/tools/libxen/include/xen_internal.h	Sat Oct 07 18:22:09 2006 +0100
    16.3 @@ -0,0 +1,192 @@
    16.4 +/*
    16.5 +  Copyright (c) 2006 XenSource, Inc.
    16.6 + *
    16.7 + * This library is free software; you can redistribute it and/or
    16.8 + * modify it under the terms of the GNU Lesser General Public
    16.9 + * License as published by the Free Software Foundation; either
   16.10 + * version 2.1 of the License, or (at your option) any later version.
   16.11 + *
   16.12 + * This library is distributed in the hope that it will be useful,
   16.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   16.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   16.15 + * Lesser General Public License for more details.
   16.16 + *
   16.17 + * You should have received a copy of the GNU Lesser General Public
   16.18 + * License along with this library; if not, write to the Free Software
   16.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   16.20 +*/
   16.21 +
   16.22 +#ifndef XEN_INTERNAL_H
   16.23 +#define XEN_INTERNAL_H
   16.24 +
   16.25 +
   16.26 +#include <inttypes.h>
   16.27 +#include <stdbool.h>
   16.28 +#include <stdlib.h>
   16.29 +
   16.30 +#include "xen_common.h"
   16.31 +
   16.32 +
   16.33 +enum abstract_typename
   16.34 +{
   16.35 +  VOID,
   16.36 +  STRING,
   16.37 +  INT,
   16.38 +  FLOAT,
   16.39 +  BOOL,
   16.40 +  DATETIME,
   16.41 +  SET,
   16.42 +  MAP,
   16.43 +  STRUCT,
   16.44 +  REF,
   16.45 +  ENUM,
   16.46 +  ENUMSET
   16.47 +};
   16.48 +
   16.49 +
   16.50 +typedef struct
   16.51 +{
   16.52 +    size_t size;
   16.53 +    void *contents[];
   16.54 +} arbitrary_set;
   16.55 +
   16.56 +
   16.57 +typedef struct struct_member struct_member;
   16.58 +
   16.59 +
   16.60 +typedef struct abstract_type
   16.61 +{
   16.62 +    enum abstract_typename typename;
   16.63 +    const struct abstract_type *child;
   16.64 +    const char * (*enum_marshaller)(int);
   16.65 +    int (*enum_demarshaller)(xen_session *, const char *);
   16.66 +    size_t struct_size;
   16.67 +    size_t member_count;
   16.68 +    const struct_member *members;
   16.69 +} abstract_type;
   16.70 +
   16.71 +
   16.72 +struct struct_member
   16.73 +{
   16.74 +    const char *key;
   16.75 +    const struct abstract_type *type;
   16.76 +    int offset;
   16.77 +};
   16.78 +
   16.79 +
   16.80 +extern const abstract_type abstract_type_string;
   16.81 +extern const abstract_type abstract_type_int;
   16.82 +extern const abstract_type abstract_type_float;
   16.83 +extern const abstract_type abstract_type_bool;
   16.84 +extern const abstract_type abstract_type_datetime;
   16.85 +extern const abstract_type abstract_type_ref;
   16.86 +
   16.87 +extern const abstract_type abstract_type_string_set;
   16.88 +extern const abstract_type abstract_type_ref_set;
   16.89 +
   16.90 +extern const abstract_type abstract_type_string_string_map;
   16.91 +extern const abstract_type abstract_type_int_float_map;
   16.92 +
   16.93 +
   16.94 +typedef struct abstract_value
   16.95 +{
   16.96 +    const abstract_type *type;
   16.97 +    union
   16.98 +    {
   16.99 +        const char *string_val;
  16.100 +        uint64_t int_val;
  16.101 +        int enum_val;
  16.102 +        double double_val;
  16.103 +        bool bool_val;
  16.104 +        arbitrary_set *set_val;
  16.105 +        void *struct_val;
  16.106 +    } u;
  16.107 +} abstract_value;
  16.108 +
  16.109 +
  16.110 +extern void
  16.111 +xen_call_(xen_session *s, const char *method_name, abstract_value params[],
  16.112 +          int param_count, const abstract_type *result_type, void *value);
  16.113 +
  16.114 +
  16.115 +#define XEN_CALL_(method_name__)                                \
  16.116 +    xen_call_(session, method_name__, param_values,             \
  16.117 +              sizeof(param_values) / sizeof(param_values[0]),   \
  16.118 +              &result_type, result)                             \
  16.119 +
  16.120 +
  16.121 +extern char *
  16.122 +xen_strdup_(const char *in);
  16.123 +
  16.124 +
  16.125 +extern int
  16.126 +xen_enum_lookup_(xen_session *session, const char *str,
  16.127 +                 const char **lookup_table, int n);
  16.128 +
  16.129 +#define ENUM_LOOKUP(session__, str__, lookup_table__)   \
  16.130 +    xen_enum_lookup_(session__, str__, lookup_table__,  \
  16.131 +                     sizeof(lookup_table__) /           \
  16.132 +                     sizeof(lookup_table__[0]))         \
  16.133 +                                                        \
  16.134 +
  16.135 +#define XEN_ALLOC(type__)                       \
  16.136 +type__ *                                        \
  16.137 +type__ ## _alloc()                              \
  16.138 +{                                               \
  16.139 +    return calloc(1, sizeof(type__));           \
  16.140 +}                                               \
  16.141 +
  16.142 +
  16.143 +#define XEN_FREE(type__)                        \
  16.144 +void                                            \
  16.145 +type__ ## _free(type__ handle)                  \
  16.146 +{                                               \
  16.147 +    free(handle);                               \
  16.148 +}                                               \
  16.149 +
  16.150 +
  16.151 +#define XEN_SET_ALLOC_FREE(type__)                                      \
  16.152 +type__ ## _set *                                                        \
  16.153 +type__ ## _set_alloc(size_t size)                                       \
  16.154 +{                                                                       \
  16.155 +    return calloc(1, sizeof(type__ ## _set) + size * sizeof(type__));   \
  16.156 +}                                                                       \
  16.157 +                                                                        \
  16.158 +void                                                                    \
  16.159 +type__ ## _set_free(type__ ## _set *set)                                \
  16.160 +{                                                                       \
  16.161 +    if (set == NULL)                                                    \
  16.162 +    {                                                                   \
  16.163 +        return;                                                         \
  16.164 +    }                                                                   \
  16.165 +    size_t n = set->size;                                               \
  16.166 +    for (size_t i = 0; i < n; i++)                                      \
  16.167 +    {                                                                   \
  16.168 +       type__ ## _free(set->contents[i]);                               \
  16.169 +    }                                                                   \
  16.170 +                                                                        \
  16.171 +    free(set);                                                          \
  16.172 +}                                                                       \
  16.173 +
  16.174 +
  16.175 +#define XEN_RECORD_OPT_FREE(type__)                     \
  16.176 +void                                                    \
  16.177 +type__ ## _record_opt_free(type__ ## _record_opt *opt)  \
  16.178 +{                                                       \
  16.179 +    if (opt == NULL)                                    \
  16.180 +    {                                                   \
  16.181 +        return;                                         \
  16.182 +    }                                                   \
  16.183 +    if (opt->is_record)                                 \
  16.184 +    {                                                   \
  16.185 +        type__ ## _record_free(opt->u.record);          \
  16.186 +    }                                                   \
  16.187 +    else                                                \
  16.188 +    {                                                   \
  16.189 +        type__ ## _free(opt->u.handle);                 \
  16.190 +    }                                                   \
  16.191 +    free(opt);                                          \
  16.192 +}                                                       \
  16.193 +
  16.194 +
  16.195 +#endif
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/tools/libxen/include/xen_network.h	Sat Oct 07 18:22:09 2006 +0100
    17.3 @@ -0,0 +1,287 @@
    17.4 +/*
    17.5 + * Copyright (c) 2006, XenSource Inc.
    17.6 + *
    17.7 + * This library is free software; you can redistribute it and/or
    17.8 + * modify it under the terms of the GNU Lesser General Public
    17.9 + * License as published by the Free Software Foundation; either
   17.10 + * version 2.1 of the License, or (at your option) any later version.
   17.11 + *
   17.12 + * This library is distributed in the hope that it will be useful,
   17.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   17.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   17.15 + * Lesser General Public License for more details.
   17.16 + *
   17.17 + * You should have received a copy of the GNU Lesser General Public
   17.18 + * License along with this library; if not, write to the Free Software
   17.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   17.20 + */
   17.21 +
   17.22 +#ifndef XEN_NETWORK_H
   17.23 +#define XEN_NETWORK_H
   17.24 +
   17.25 +#include "xen_common.h"
   17.26 +#include "xen_network_decl.h"
   17.27 +#include "xen_vif_decl.h"
   17.28 +
   17.29 +
   17.30 +/*
   17.31 + * The network class. 
   17.32 + *  
   17.33 + * A virtual network.
   17.34 + */
   17.35 +
   17.36 +
   17.37 +/**
   17.38 + * Free the given xen_network.  The given handle must have been
   17.39 + * allocated by this library.
   17.40 + */
   17.41 +extern void
   17.42 +xen_network_free(xen_network network);
   17.43 +
   17.44 +
   17.45 +typedef struct xen_network_set
   17.46 +{
   17.47 +    size_t size;
   17.48 +    xen_network *contents[];
   17.49 +} xen_network_set;
   17.50 +
   17.51 +/**
   17.52 + * Allocate a xen_network_set of the given size.
   17.53 + */
   17.54 +extern xen_network_set *
   17.55 +xen_network_set_alloc(size_t size);
   17.56 +
   17.57 +/**
   17.58 + * Free the given xen_network_set.  The given set must have been
   17.59 + * allocated by this library.
   17.60 + */
   17.61 +extern void
   17.62 +xen_network_set_free(xen_network_set *set);
   17.63 +
   17.64 +
   17.65 +typedef struct xen_network_record
   17.66 +{
   17.67 +    xen_network handle;
   17.68 +    char *uuid;
   17.69 +    char *name_label;
   17.70 +    char *name_description;
   17.71 +    struct xen_vif_record_opt_set *vifs;
   17.72 +    char *nic;
   17.73 +    char *vlan;
   17.74 +    char *default_gateway;
   17.75 +    char *default_netmask;
   17.76 +} xen_network_record;
   17.77 +
   17.78 +/**
   17.79 + * Allocate a xen_network_record.
   17.80 + */
   17.81 +extern xen_network_record *
   17.82 +xen_network_record_alloc(void);
   17.83 +
   17.84 +/**
   17.85 + * Free the given xen_network_record, and all referenced values.  The
   17.86 + * given record must have been allocated by this library.
   17.87 + */
   17.88 +extern void
   17.89 +xen_network_record_free(xen_network_record *record);
   17.90 +
   17.91 +
   17.92 +typedef struct xen_network_record_opt
   17.93 +{
   17.94 +    bool is_record;
   17.95 +    union
   17.96 +    {
   17.97 +        xen_network handle;
   17.98 +        xen_network_record *record;
   17.99 +    } u;
  17.100 +} xen_network_record_opt;
  17.101 +
  17.102 +/**
  17.103 + * Allocate a xen_network_record_opt.
  17.104 + */
  17.105 +extern xen_network_record_opt *
  17.106 +xen_network_record_opt_alloc(void);
  17.107 +
  17.108 +/**
  17.109 + * Free the given xen_network_record_opt, and all referenced values. 
  17.110 + * The given record_opt must have been allocated by this library.
  17.111 + */
  17.112 +extern void
  17.113 +xen_network_record_opt_free(xen_network_record_opt *record_opt);
  17.114 +
  17.115 +
  17.116 +typedef struct xen_network_record_set
  17.117 +{
  17.118 +    size_t size;
  17.119 +    xen_network_record *contents[];
  17.120 +} xen_network_record_set;
  17.121 +
  17.122 +/**
  17.123 + * Allocate a xen_network_record_set of the given size.
  17.124 + */
  17.125 +extern xen_network_record_set *
  17.126 +xen_network_record_set_alloc(size_t size);
  17.127 +
  17.128 +/**
  17.129 + * Free the given xen_network_record_set, and all referenced values. 
  17.130 + * The given set must have been allocated by this library.
  17.131 + */
  17.132 +extern void
  17.133 +xen_network_record_set_free(xen_network_record_set *set);
  17.134 +
  17.135 +
  17.136 +
  17.137 +typedef struct xen_network_record_opt_set
  17.138 +{
  17.139 +    size_t size;
  17.140 +    xen_network_record_opt *contents[];
  17.141 +} xen_network_record_opt_set;
  17.142 +
  17.143 +/**
  17.144 + * Allocate a xen_network_record_opt_set of the given size.
  17.145 + */
  17.146 +extern xen_network_record_opt_set *
  17.147 +xen_network_record_opt_set_alloc(size_t size);
  17.148 +
  17.149 +/**
  17.150 + * Free the given xen_network_record_opt_set, and all referenced
  17.151 + * values.  The given set must have been allocated by this library.
  17.152 + */
  17.153 +extern void
  17.154 +xen_network_record_opt_set_free(xen_network_record_opt_set *set);
  17.155 +
  17.156 +
  17.157 +/**
  17.158 + * Get the current state of the given network.  !!!
  17.159 + */
  17.160 +extern bool
  17.161 +xen_network_get_record(xen_session *session, xen_network_record **result, xen_network network);
  17.162 +
  17.163 +
  17.164 +/**
  17.165 + * Get a reference to the object with the specified UUID.  !!!
  17.166 + */
  17.167 +extern bool
  17.168 +xen_network_get_by_uuid(xen_session *session, xen_network *result, char *uuid);
  17.169 +
  17.170 +
  17.171 +/**
  17.172 + * Create a new network instance, and return its handle.
  17.173 + */
  17.174 +extern bool
  17.175 +xen_network_create(xen_session *session, xen_network *result, xen_network_record *record);
  17.176 +
  17.177 +
  17.178 +/**
  17.179 + * Get a reference to the object with the specified label.
  17.180 + */
  17.181 +extern bool
  17.182 +xen_network_get_by_name_label(xen_session *session, xen_network *result, char *label);
  17.183 +
  17.184 +
  17.185 +/**
  17.186 + * Get the uuid field of the given network.
  17.187 + */
  17.188 +extern bool
  17.189 +xen_network_get_uuid(xen_session *session, char **result, xen_network network);
  17.190 +
  17.191 +
  17.192 +/**
  17.193 + * Get the name/label field of the given network.
  17.194 + */
  17.195 +extern bool
  17.196 +xen_network_get_name_label(xen_session *session, char **result, xen_network network);
  17.197 +
  17.198 +
  17.199 +/**
  17.200 + * Get the name/description field of the given network.
  17.201 + */
  17.202 +extern bool
  17.203 +xen_network_get_name_description(xen_session *session, char **result, xen_network network);
  17.204 +
  17.205 +
  17.206 +/**
  17.207 + * Get the VIFs field of the given network.
  17.208 + */
  17.209 +extern bool
  17.210 +xen_network_get_vifs(xen_session *session, xen_vif *result, xen_network network);
  17.211 +
  17.212 +
  17.213 +/**
  17.214 + * Get the NIC field of the given network.
  17.215 + */
  17.216 +extern bool
  17.217 +xen_network_get_nic(xen_session *session, char **result, xen_network network);
  17.218 +
  17.219 +
  17.220 +/**
  17.221 + * Get the VLAN field of the given network.
  17.222 + */
  17.223 +extern bool
  17.224 +xen_network_get_vlan(xen_session *session, char **result, xen_network network);
  17.225 +
  17.226 +
  17.227 +/**
  17.228 + * Get the default_gateway field of the given network.
  17.229 + */
  17.230 +extern bool
  17.231 +xen_network_get_default_gateway(xen_session *session, char **result, xen_network network);
  17.232 +
  17.233 +
  17.234 +/**
  17.235 + * Get the default_netmask field of the given network.
  17.236 + */
  17.237 +extern bool
  17.238 +xen_network_get_default_netmask(xen_session *session, char **result, xen_network network);
  17.239 +
  17.240 +
  17.241 +/**
  17.242 + * Set the name/label field of the given network.
  17.243 + */
  17.244 +extern bool
  17.245 +xen_network_set_name_label(xen_session *session, xen_network xen_network, char *label);
  17.246 +
  17.247 +
  17.248 +/**
  17.249 + * Set the name/description field of the given network.
  17.250 + */
  17.251 +extern bool
  17.252 +xen_network_set_name_description(xen_session *session, xen_network xen_network, char *description);
  17.253 +
  17.254 +
  17.255 +/**
  17.256 + * Set the NIC field of the given network.
  17.257 + */
  17.258 +extern bool
  17.259 +xen_network_set_nic(xen_session *session, xen_network xen_network, char *nic);
  17.260 +
  17.261 +
  17.262 +/**
  17.263 + * Set the VLAN field of the given network.
  17.264 + */
  17.265 +extern bool
  17.266 +xen_network_set_vlan(xen_session *session, xen_network xen_network, char *vlan);
  17.267 +
  17.268 +
  17.269 +/**
  17.270 + * Set the default_gateway field of the given network.
  17.271 + */
  17.272 +extern bool
  17.273 +xen_network_set_default_gateway(xen_session *session, xen_network xen_network, char *default_gateway);
  17.274 +
  17.275 +
  17.276 +/**
  17.277 + * Set the default_netmask field of the given network.
  17.278 + */
  17.279 +extern bool
  17.280 +xen_network_set_default_netmask(xen_session *session, xen_network xen_network, char *default_netmask);
  17.281 +
  17.282 +
  17.283 +/**
  17.284 + * Return a list of all the networks known to the system
  17.285 + */
  17.286 +extern bool
  17.287 +xen_network_get_all(xen_session *session, xen_network *result);
  17.288 +
  17.289 +
  17.290 +#endif
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/tools/libxen/include/xen_network_decl.h	Sat Oct 07 18:22:09 2006 +0100
    18.3 @@ -0,0 +1,30 @@
    18.4 +/*
    18.5 + * Copyright (c) 2006, XenSource Inc.
    18.6 + *
    18.7 + * This library is free software; you can redistribute it and/or
    18.8 + * modify it under the terms of the GNU Lesser General Public
    18.9 + * License as published by the Free Software Foundation; either
   18.10 + * version 2.1 of the License, or (at your option) any later version.
   18.11 + *
   18.12 + * This library is distributed in the hope that it will be useful,
   18.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   18.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   18.15 + * Lesser General Public License for more details.
   18.16 + *
   18.17 + * You should have received a copy of the GNU Lesser General Public
   18.18 + * License along with this library; if not, write to the Free Software
   18.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   18.20 + */
   18.21 +
   18.22 +#ifndef XEN_NETWORK_DECL_H
   18.23 +#define XEN_NETWORK_DECL_H
   18.24 +
   18.25 +typedef void *xen_network;
   18.26 +
   18.27 +struct xen_network_set;
   18.28 +struct xen_network_record;
   18.29 +struct xen_network_record_set;
   18.30 +struct xen_network_record_opt;
   18.31 +struct xen_network_record_opt_set;
   18.32 +
   18.33 +#endif
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/tools/libxen/include/xen_on_crash_behaviour.h	Sat Oct 07 18:22:09 2006 +0100
    19.3 @@ -0,0 +1,97 @@
    19.4 +/*
    19.5 + * Copyright (c) 2006, XenSource Inc.
    19.6 + *
    19.7 + * This library is free software; you can redistribute it and/or
    19.8 + * modify it under the terms of the GNU Lesser General Public
    19.9 + * License as published by the Free Software Foundation; either
   19.10 + * version 2.1 of the License, or (at your option) any later version.
   19.11 + *
   19.12 + * This library is distributed in the hope that it will be useful,
   19.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   19.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   19.15 + * Lesser General Public License for more details.
   19.16 + *
   19.17 + * You should have received a copy of the GNU Lesser General Public
   19.18 + * License along with this library; if not, write to the Free Software
   19.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   19.20 + */
   19.21 +
   19.22 +#ifndef XEN_ON_CRASH_BEHAVIOUR_H
   19.23 +#define XEN_ON_CRASH_BEHAVIOUR_H
   19.24 +
   19.25 +
   19.26 +#include "xen_common.h"
   19.27 +
   19.28 +
   19.29 +enum xen_on_crash_behaviour
   19.30 +{
   19.31 +    /**
   19.32 +     * destroy the VM state
   19.33 +     */
   19.34 +    XEN_ON_CRASH_BEHAVIOUR_DESTROY,
   19.35 +
   19.36 +    /**
   19.37 +     * record a coredump and then destroy the VM state
   19.38 +     */
   19.39 +    XEN_ON_CRASH_BEHAVIOUR_COREDUMP_AND_DESTROY,
   19.40 +
   19.41 +    /**
   19.42 +     * restart the VM
   19.43 +     */
   19.44 +    XEN_ON_CRASH_BEHAVIOUR_RESTART,
   19.45 +
   19.46 +    /**
   19.47 +     * record a coredump and then restart the VM
   19.48 +     */
   19.49 +    XEN_ON_CRASH_BEHAVIOUR_COREDUMP_AND_RESTART,
   19.50 +
   19.51 +    /**
   19.52 +     * leave the crashed VM as-is
   19.53 +     */
   19.54 +    XEN_ON_CRASH_BEHAVIOUR_PRESERVE,
   19.55 +
   19.56 +    /**
   19.57 +     * rename the crashed VM and start a new copy
   19.58 +     */
   19.59 +    XEN_ON_CRASH_BEHAVIOUR_RENAME_RESTART
   19.60 +};
   19.61 +
   19.62 +
   19.63 +typedef struct xen_on_crash_behaviour_set
   19.64 +{
   19.65 +    size_t size;
   19.66 +    enum xen_on_crash_behaviour contents[];
   19.67 +} xen_on_crash_behaviour_set;
   19.68 +
   19.69 +/**
   19.70 + * Allocate a xen_on_crash_behaviour_set of the given size.
   19.71 + */
   19.72 +extern xen_on_crash_behaviour_set *
   19.73 +xen_on_crash_behaviour_set_alloc(size_t size);
   19.74 +
   19.75 +/**
   19.76 + * Free the given xen_on_crash_behaviour_set.  The given set must have
   19.77 + * been allocated by this library.
   19.78 + */
   19.79 +extern void
   19.80 +xen_on_crash_behaviour_set_free(xen_on_crash_behaviour_set *set);
   19.81 +
   19.82 +
   19.83 +/**
   19.84 + * Return the name corresponding to the given code.  This string must
   19.85 + * not be modified or freed.
   19.86 + */
   19.87 +extern const char *
   19.88 +xen_on_crash_behaviour_to_string(enum xen_on_crash_behaviour val);
   19.89 +
   19.90 +
   19.91 +/**
   19.92 + * Return the correct code for the given string, or set the session
   19.93 + * object to failure and return an undefined value if the given string does
   19.94 + * not match a known code.
   19.95 + */
   19.96 +extern enum xen_on_crash_behaviour
   19.97 +xen_on_crash_behaviour_from_string(xen_session *session, const char *str);
   19.98 +
   19.99 +
  19.100 +#endif
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/tools/libxen/include/xen_on_crash_behaviour_internal.h	Sat Oct 07 18:22:09 2006 +0100
    20.3 @@ -0,0 +1,38 @@
    20.4 +/*
    20.5 + * Copyright (c) 2006, XenSource Inc.
    20.6 + *
    20.7 + * This library is free software; you can redistribute it and/or
    20.8 + * modify it under the terms of the GNU Lesser General Public
    20.9 + * License as published by the Free Software Foundation; either
   20.10 + * version 2.1 of the License, or (at your option) any later version.
   20.11 + *
   20.12 + * This library is distributed in the hope that it will be useful,
   20.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   20.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   20.15 + * Lesser General Public License for more details.
   20.16 + *
   20.17 + * You should have received a copy of the GNU Lesser General Public
   20.18 + * License along with this library; if not, write to the Free Software
   20.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   20.20 + */
   20.21 +
   20.22 +
   20.23 +/*
   20.24 + * Declarations of the abstract types used during demarshalling of enum
   20.25 + * xen_on_crash_behaviour.  Internal to this library -- do not use from
   20.26 + * outside.
   20.27 + */
   20.28 +
   20.29 +
   20.30 +#ifndef XEN_ON_CRASH_BEHAVIOUR_INTERNAL_H
   20.31 +#define XEN_ON_CRASH_BEHAVIOUR_INTERNAL_H
   20.32 +
   20.33 +
   20.34 +#include "xen_internal.h"
   20.35 +
   20.36 +
   20.37 +extern const abstract_type xen_on_crash_behaviour_abstract_type_;
   20.38 +extern const abstract_type xen_on_crash_behaviour_set_abstract_type_;
   20.39 +
   20.40 +
   20.41 +#endif
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/tools/libxen/include/xen_on_normal_exit.h	Sat Oct 07 18:22:09 2006 +0100
    21.3 @@ -0,0 +1,77 @@
    21.4 +/*
    21.5 + * Copyright (c) 2006, XenSource Inc.
    21.6 + *
    21.7 + * This library is free software; you can redistribute it and/or
    21.8 + * modify it under the terms of the GNU Lesser General Public
    21.9 + * License as published by the Free Software Foundation; either
   21.10 + * version 2.1 of the License, or (at your option) any later version.
   21.11 + *
   21.12 + * This library is distributed in the hope that it will be useful,
   21.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   21.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   21.15 + * Lesser General Public License for more details.
   21.16 + *
   21.17 + * You should have received a copy of the GNU Lesser General Public
   21.18 + * License along with this library; if not, write to the Free Software
   21.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   21.20 + */
   21.21 +
   21.22 +#ifndef XEN_ON_NORMAL_EXIT_H
   21.23 +#define XEN_ON_NORMAL_EXIT_H
   21.24 +
   21.25 +
   21.26 +#include "xen_common.h"
   21.27 +
   21.28 +
   21.29 +enum xen_on_normal_exit
   21.30 +{
   21.31 +    /**
   21.32 +     * destroy the VM state
   21.33 +     */
   21.34 +    XEN_ON_NORMAL_EXIT_DESTROY,
   21.35 +
   21.36 +    /**
   21.37 +     * restart the VM
   21.38 +     */
   21.39 +    XEN_ON_NORMAL_EXIT_RESTART
   21.40 +};
   21.41 +
   21.42 +
   21.43 +typedef struct xen_on_normal_exit_set
   21.44 +{
   21.45 +    size_t size;
   21.46 +    enum xen_on_normal_exit contents[];
   21.47 +} xen_on_normal_exit_set;
   21.48 +
   21.49 +/**
   21.50 + * Allocate a xen_on_normal_exit_set of the given size.
   21.51 + */
   21.52 +extern xen_on_normal_exit_set *
   21.53 +xen_on_normal_exit_set_alloc(size_t size);
   21.54 +
   21.55 +/**
   21.56 + * Free the given xen_on_normal_exit_set.  The given set must have been
   21.57 + * allocated by this library.
   21.58 + */
   21.59 +extern void
   21.60 +xen_on_normal_exit_set_free(xen_on_normal_exit_set *set);
   21.61 +
   21.62 +
   21.63 +/**
   21.64 + * Return the name corresponding to the given code.  This string must
   21.65 + * not be modified or freed.
   21.66 + */
   21.67 +extern const char *
   21.68 +xen_on_normal_exit_to_string(enum xen_on_normal_exit val);
   21.69 +
   21.70 +
   21.71 +/**
   21.72 + * Return the correct code for the given string, or set the session
   21.73 + * object to failure and return an undefined value if the given string does
   21.74 + * not match a known code.
   21.75 + */
   21.76 +extern enum xen_on_normal_exit
   21.77 +xen_on_normal_exit_from_string(xen_session *session, const char *str);
   21.78 +
   21.79 +
   21.80 +#endif
    22.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.2 +++ b/tools/libxen/include/xen_on_normal_exit_internal.h	Sat Oct 07 18:22:09 2006 +0100
    22.3 @@ -0,0 +1,37 @@
    22.4 +/*
    22.5 + * Copyright (c) 2006, XenSource Inc.
    22.6 + *
    22.7 + * This library is free software; you can redistribute it and/or
    22.8 + * modify it under the terms of the GNU Lesser General Public
    22.9 + * License as published by the Free Software Foundation; either
   22.10 + * version 2.1 of the License, or (at your option) any later version.
   22.11 + *
   22.12 + * This library is distributed in the hope that it will be useful,
   22.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   22.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   22.15 + * Lesser General Public License for more details.
   22.16 + *
   22.17 + * You should have received a copy of the GNU Lesser General Public
   22.18 + * License along with this library; if not, write to the Free Software
   22.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   22.20 + */
   22.21 +
   22.22 +
   22.23 +/*
   22.24 + * Declarations of the abstract types used during demarshalling of enum
   22.25 + * xen_on_normal_exit.  Internal to this library -- do not use from outside.
   22.26 + */
   22.27 +
   22.28 +
   22.29 +#ifndef XEN_ON_NORMAL_EXIT_INTERNAL_H
   22.30 +#define XEN_ON_NORMAL_EXIT_INTERNAL_H
   22.31 +
   22.32 +
   22.33 +#include "xen_internal.h"
   22.34 +
   22.35 +
   22.36 +extern const abstract_type xen_on_normal_exit_abstract_type_;
   22.37 +extern const abstract_type xen_on_normal_exit_set_abstract_type_;
   22.38 +
   22.39 +
   22.40 +#endif
    23.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.2 +++ b/tools/libxen/include/xen_sr.h	Sat Oct 07 18:22:09 2006 +0100
    23.3 @@ -0,0 +1,275 @@
    23.4 +/*
    23.5 + * Copyright (c) 2006, XenSource Inc.
    23.6 + *
    23.7 + * This library is free software; you can redistribute it and/or
    23.8 + * modify it under the terms of the GNU Lesser General Public
    23.9 + * License as published by the Free Software Foundation; either
   23.10 + * version 2.1 of the License, or (at your option) any later version.
   23.11 + *
   23.12 + * This library is distributed in the hope that it will be useful,
   23.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   23.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   23.15 + * Lesser General Public License for more details.
   23.16 + *
   23.17 + * You should have received a copy of the GNU Lesser General Public
   23.18 + * License along with this library; if not, write to the Free Software
   23.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   23.20 + */
   23.21 +
   23.22 +#ifndef XEN_SR_H
   23.23 +#define XEN_SR_H
   23.24 +
   23.25 +#include "xen_common.h"
   23.26 +#include "xen_sr_decl.h"
   23.27 +#include "xen_vdi_decl.h"
   23.28 +
   23.29 +
   23.30 +/*
   23.31 + * The SR class. 
   23.32 + *  
   23.33 + * A storage repository.
   23.34 + */
   23.35 +
   23.36 +
   23.37 +/**
   23.38 + * Free the given xen_sr.  The given handle must have been allocated by
   23.39 + * this library.
   23.40 + */
   23.41 +extern void
   23.42 +xen_sr_free(xen_sr sr);
   23.43 +
   23.44 +
   23.45 +typedef struct xen_sr_set
   23.46 +{
   23.47 +    size_t size;
   23.48 +    xen_sr *contents[];
   23.49 +} xen_sr_set;
   23.50 +
   23.51 +/**
   23.52 + * Allocate a xen_sr_set of the given size.
   23.53 + */
   23.54 +extern xen_sr_set *
   23.55 +xen_sr_set_alloc(size_t size);
   23.56 +
   23.57 +/**
   23.58 + * Free the given xen_sr_set.  The given set must have been allocated
   23.59 + * by this library.
   23.60 + */
   23.61 +extern void
   23.62 +xen_sr_set_free(xen_sr_set *set);
   23.63 +
   23.64 +
   23.65 +typedef struct xen_sr_record
   23.66 +{
   23.67 +    xen_sr handle;
   23.68 +    char *uuid;
   23.69 +    char *name_label;
   23.70 +    char *name_description;
   23.71 +    struct xen_vdi_record_opt_set *vdis;
   23.72 +    uint64_t virtual_allocation;
   23.73 +    uint64_t physical_utilisation;
   23.74 +    uint64_t physical_size;
   23.75 +    char *type;
   23.76 +    char *location;
   23.77 +} xen_sr_record;
   23.78 +
   23.79 +/**
   23.80 + * Allocate a xen_sr_record.
   23.81 + */
   23.82 +extern xen_sr_record *
   23.83 +xen_sr_record_alloc(void);
   23.84 +
   23.85 +/**
   23.86 + * Free the given xen_sr_record, and all referenced values.  The given
   23.87 + * record must have been allocated by this library.
   23.88 + */
   23.89 +extern void
   23.90 +xen_sr_record_free(xen_sr_record *record);
   23.91 +
   23.92 +
   23.93 +typedef struct xen_sr_record_opt
   23.94 +{
   23.95 +    bool is_record;
   23.96 +    union
   23.97 +    {
   23.98 +        xen_sr handle;
   23.99 +        xen_sr_record *record;
  23.100 +    } u;
  23.101 +} xen_sr_record_opt;
  23.102 +
  23.103 +/**
  23.104 + * Allocate a xen_sr_record_opt.
  23.105 + */
  23.106 +extern xen_sr_record_opt *
  23.107 +xen_sr_record_opt_alloc(void);
  23.108 +
  23.109 +/**
  23.110 + * Free the given xen_sr_record_opt, and all referenced values.  The
  23.111 + * given record_opt must have been allocated by this library.
  23.112 + */
  23.113 +extern void
  23.114 +xen_sr_record_opt_free(xen_sr_record_opt *record_opt);
  23.115 +
  23.116 +
  23.117 +typedef struct xen_sr_record_set
  23.118 +{
  23.119 +    size_t size;
  23.120 +    xen_sr_record *contents[];
  23.121 +} xen_sr_record_set;
  23.122 +
  23.123 +/**
  23.124 + * Allocate a xen_sr_record_set of the given size.
  23.125 + */
  23.126 +extern xen_sr_record_set *
  23.127 +xen_sr_record_set_alloc(size_t size);
  23.128 +
  23.129 +/**
  23.130 + * Free the given xen_sr_record_set, and all referenced values.  The
  23.131 + * given set must have been allocated by this library.
  23.132 + */
  23.133 +extern void
  23.134 +xen_sr_record_set_free(xen_sr_record_set *set);
  23.135 +
  23.136 +
  23.137 +
  23.138 +typedef struct xen_sr_record_opt_set
  23.139 +{
  23.140 +    size_t size;
  23.141 +    xen_sr_record_opt *contents[];
  23.142 +} xen_sr_record_opt_set;
  23.143 +
  23.144 +/**
  23.145 + * Allocate a xen_sr_record_opt_set of the given size.
  23.146 + */
  23.147 +extern xen_sr_record_opt_set *
  23.148 +xen_sr_record_opt_set_alloc(size_t size);
  23.149 +
  23.150 +/**
  23.151 + * Free the given xen_sr_record_opt_set, and all referenced values. 
  23.152 + * The given set must have been allocated by this library.
  23.153 + */
  23.154 +extern void
  23.155 +xen_sr_record_opt_set_free(xen_sr_record_opt_set *set);
  23.156 +
  23.157 +
  23.158 +/**
  23.159 + * Get the current state of the given SR.  !!!
  23.160 + */
  23.161 +extern bool
  23.162 +xen_sr_get_record(xen_session *session, xen_sr_record **result, xen_sr sr);
  23.163 +
  23.164 +
  23.165 +/**
  23.166 + * Get a reference to the object with the specified UUID.  !!!
  23.167 + */
  23.168 +extern bool
  23.169 +xen_sr_get_by_uuid(xen_session *session, xen_sr *result, char *uuid);
  23.170 +
  23.171 +
  23.172 +/**
  23.173 + * Create a new SR instance, and return its handle.
  23.174 + */
  23.175 +extern bool
  23.176 +xen_sr_create(xen_session *session, xen_sr *result, xen_sr_record *record);
  23.177 +
  23.178 +
  23.179 +/**
  23.180 + * Get a reference to the object with the specified label.
  23.181 + */
  23.182 +extern bool
  23.183 +xen_sr_get_by_name_label(xen_session *session, xen_sr *result, char *label);
  23.184 +
  23.185 +
  23.186 +/**
  23.187 + * Get the uuid field of the given SR.
  23.188 + */
  23.189 +extern bool
  23.190 +xen_sr_get_uuid(xen_session *session, char **result, xen_sr sr);
  23.191 +
  23.192 +
  23.193 +/**
  23.194 + * Get the name/label field of the given SR.
  23.195 + */
  23.196 +extern bool
  23.197 +xen_sr_get_name_label(xen_session *session, char **result, xen_sr sr);
  23.198 +
  23.199 +
  23.200 +/**
  23.201 + * Get the name/description field of the given SR.
  23.202 + */
  23.203 +extern bool
  23.204 +xen_sr_get_name_description(xen_session *session, char **result, xen_sr sr);
  23.205 +
  23.206 +
  23.207 +/**
  23.208 + * Get the VDIs field of the given SR.
  23.209 + */
  23.210 +extern bool
  23.211 +xen_sr_get_vdis(xen_session *session, xen_vdi *result, xen_sr sr);
  23.212 +
  23.213 +
  23.214 +/**
  23.215 + * Get the virtual_allocation field of the given SR.
  23.216 + */
  23.217 +extern bool
  23.218 +xen_sr_get_virtual_allocation(xen_session *session, uint64_t *result, xen_sr sr);
  23.219 +
  23.220 +
  23.221 +/**
  23.222 + * Get the physical_utilisation field of the given SR.
  23.223 + */
  23.224 +extern bool
  23.225 +xen_sr_get_physical_utilisation(xen_session *session, uint64_t *result, xen_sr sr);
  23.226 +
  23.227 +
  23.228 +/**
  23.229 + * Get the physical_size field of the given SR.
  23.230 + */
  23.231 +extern bool
  23.232 +xen_sr_get_physical_size(xen_session *session, uint64_t *result, xen_sr sr);
  23.233 +
  23.234 +
  23.235 +/**
  23.236 + * Get the type field of the given SR.
  23.237 + */
  23.238 +extern bool
  23.239 +xen_sr_get_type(xen_session *session, char **result, xen_sr sr);
  23.240 +
  23.241 +
  23.242 +/**
  23.243 + * Get the location field of the given SR.
  23.244 + */
  23.245 +extern bool
  23.246 +xen_sr_get_location(xen_session *session, char **result, xen_sr sr);
  23.247 +
  23.248 +
  23.249 +/**
  23.250 + * Set the name/label field of the given SR.
  23.251 + */
  23.252 +extern bool
  23.253 +xen_sr_set_name_label(xen_session *session, xen_sr xen_sr, char *label);
  23.254 +
  23.255 +
  23.256 +/**
  23.257 + * Set the name/description field of the given SR.
  23.258 + */
  23.259 +extern bool
  23.260 +xen_sr_set_name_description(xen_session *session, xen_sr xen_sr, char *description);
  23.261 +
  23.262 +
  23.263 +/**
  23.264 + * Take an exact copy of the Storage Repository; 
  23.265 + *         the cloned storage repository has the same type as its parent
  23.266 + */
  23.267 +extern bool
  23.268 +xen_sr_clone(xen_session *session, xen_sr *result, xen_sr sr, char *loc, char *name);
  23.269 +
  23.270 +
  23.271 +/**
  23.272 + * Return a list of all the Storage Repositories known to the system
  23.273 + */
  23.274 +extern bool
  23.275 +xen_sr_get_all(xen_session *session, xen_sr *result);
  23.276 +
  23.277 +
  23.278 +#endif
    24.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.2 +++ b/tools/libxen/include/xen_sr_decl.h	Sat Oct 07 18:22:09 2006 +0100
    24.3 @@ -0,0 +1,30 @@
    24.4 +/*
    24.5 + * Copyright (c) 2006, XenSource Inc.
    24.6 + *
    24.7 + * This library is free software; you can redistribute it and/or
    24.8 + * modify it under the terms of the GNU Lesser General Public
    24.9 + * License as published by the Free Software Foundation; either
   24.10 + * version 2.1 of the License, or (at your option) any later version.
   24.11 + *
   24.12 + * This library is distributed in the hope that it will be useful,
   24.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   24.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   24.15 + * Lesser General Public License for more details.
   24.16 + *
   24.17 + * You should have received a copy of the GNU Lesser General Public
   24.18 + * License along with this library; if not, write to the Free Software
   24.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   24.20 + */
   24.21 +
   24.22 +#ifndef XEN_SR_DECL_H
   24.23 +#define XEN_SR_DECL_H
   24.24 +
   24.25 +typedef void *xen_sr;
   24.26 +
   24.27 +struct xen_sr_set;
   24.28 +struct xen_sr_record;
   24.29 +struct xen_sr_record_set;
   24.30 +struct xen_sr_record_opt;
   24.31 +struct xen_sr_record_opt_set;
   24.32 +
   24.33 +#endif
    25.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.2 +++ b/tools/libxen/include/xen_string_string_map.h	Sat Oct 07 18:22:09 2006 +0100
    25.3 @@ -0,0 +1,53 @@
    25.4 +/*
    25.5 + * Copyright (c) 2006, XenSource Inc.
    25.6 + *
    25.7 + * This library is free software; you can redistribute it and/or
    25.8 + * modify it under the terms of the GNU Lesser General Public
    25.9 + * License as published by the Free Software Foundation; either
   25.10 + * version 2.1 of the License, or (at your option) any later version.
   25.11 + *
   25.12 + * This library is distributed in the hope that it will be useful,
   25.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   25.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   25.15 + * Lesser General Public License for more details.
   25.16 + *
   25.17 + * You should have received a copy of the GNU Lesser General Public
   25.18 + * License along with this library; if not, write to the Free Software
   25.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   25.20 + */
   25.21 +
   25.22 +#ifndef XEN_STRING_STRING_MAP_H
   25.23 +#define XEN_STRING_STRING_MAP_H
   25.24 +
   25.25 +
   25.26 +#include "xen_common.h"
   25.27 +
   25.28 +
   25.29 +typedef struct xen_string_string_map_contents
   25.30 +{
   25.31 +  char *key;
   25.32 +  char *val;
   25.33 +} xen_string_string_map_contents;
   25.34 +
   25.35 +
   25.36 +typedef struct xen_string_string_map
   25.37 +{
   25.38 +    size_t size;
   25.39 +    xen_string_string_map_contents contents[];
   25.40 +} xen_string_string_map;
   25.41 +
   25.42 +/**
   25.43 + * Allocate a xen_string_string_map of the given size.
   25.44 + */
   25.45 +extern xen_string_string_map *
   25.46 +xen_string_string_map_alloc(size_t size);
   25.47 +
   25.48 +/**
   25.49 + * Free the given xen_string_string_map, and all referenced values. 
   25.50 + * The given map must have been allocated by this library.
   25.51 + */
   25.52 +extern void
   25.53 +xen_string_string_map_free(xen_string_string_map *map);
   25.54 +
   25.55 +
   25.56 +#endif
    26.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.2 +++ b/tools/libxen/include/xen_user.h	Sat Oct 07 18:22:09 2006 +0100
    26.3 @@ -0,0 +1,197 @@
    26.4 +/*
    26.5 + * Copyright (c) 2006, XenSource Inc.
    26.6 + *
    26.7 + * This library is free software; you can redistribute it and/or
    26.8 + * modify it under the terms of the GNU Lesser General Public
    26.9 + * License as published by the Free Software Foundation; either
   26.10 + * version 2.1 of the License, or (at your option) any later version.
   26.11 + *
   26.12 + * This library is distributed in the hope that it will be useful,
   26.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   26.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   26.15 + * Lesser General Public License for more details.
   26.16 + *
   26.17 + * You should have received a copy of the GNU Lesser General Public
   26.18 + * License along with this library; if not, write to the Free Software
   26.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   26.20 + */
   26.21 +
   26.22 +#ifndef XEN_USER_H
   26.23 +#define XEN_USER_H
   26.24 +
   26.25 +#include "xen_common.h"
   26.26 +#include "xen_user_decl.h"
   26.27 +
   26.28 +
   26.29 +/*
   26.30 + * The user class. 
   26.31 + *  
   26.32 + * A user of the system.
   26.33 + */
   26.34 +
   26.35 +
   26.36 +/**
   26.37 + * Free the given xen_user.  The given handle must have been allocated
   26.38 + * by this library.
   26.39 + */
   26.40 +extern void
   26.41 +xen_user_free(xen_user user);
   26.42 +
   26.43 +
   26.44 +typedef struct xen_user_set
   26.45 +{
   26.46 +    size_t size;
   26.47 +    xen_user *contents[];
   26.48 +} xen_user_set;
   26.49 +
   26.50 +/**
   26.51 + * Allocate a xen_user_set of the given size.
   26.52 + */
   26.53 +extern xen_user_set *
   26.54 +xen_user_set_alloc(size_t size);
   26.55 +
   26.56 +/**
   26.57 + * Free the given xen_user_set.  The given set must have been allocated
   26.58 + * by this library.
   26.59 + */
   26.60 +extern void
   26.61 +xen_user_set_free(xen_user_set *set);
   26.62 +
   26.63 +
   26.64 +typedef struct xen_user_record
   26.65 +{
   26.66 +    xen_user handle;
   26.67 +    char *uuid;
   26.68 +    char *short_name;
   26.69 +    char *fullname;
   26.70 +} xen_user_record;
   26.71 +
   26.72 +/**
   26.73 + * Allocate a xen_user_record.
   26.74 + */
   26.75 +extern xen_user_record *
   26.76 +xen_user_record_alloc(void);
   26.77 +
   26.78 +/**
   26.79 + * Free the given xen_user_record, and all referenced values.  The
   26.80 + * given record must have been allocated by this library.
   26.81 + */
   26.82 +extern void
   26.83 +xen_user_record_free(xen_user_record *record);
   26.84 +
   26.85 +
   26.86 +typedef struct xen_user_record_opt
   26.87 +{
   26.88 +    bool is_record;
   26.89 +    union
   26.90 +    {
   26.91 +        xen_user handle;
   26.92 +        xen_user_record *record;
   26.93 +    } u;
   26.94 +} xen_user_record_opt;
   26.95 +
   26.96 +/**
   26.97 + * Allocate a xen_user_record_opt.
   26.98 + */
   26.99 +extern xen_user_record_opt *
  26.100 +xen_user_record_opt_alloc(void);
  26.101 +
  26.102 +/**
  26.103 + * Free the given xen_user_record_opt, and all referenced values.  The
  26.104 + * given record_opt must have been allocated by this library.
  26.105 + */
  26.106 +extern void
  26.107 +xen_user_record_opt_free(xen_user_record_opt *record_opt);
  26.108 +
  26.109 +
  26.110 +typedef struct xen_user_record_set
  26.111 +{
  26.112 +    size_t size;
  26.113 +    xen_user_record *contents[];
  26.114 +} xen_user_record_set;
  26.115 +
  26.116 +/**
  26.117 + * Allocate a xen_user_record_set of the given size.
  26.118 + */
  26.119 +extern xen_user_record_set *
  26.120 +xen_user_record_set_alloc(size_t size);
  26.121 +
  26.122 +/**
  26.123 + * Free the given xen_user_record_set, and all referenced values.  The
  26.124 + * given set must have been allocated by this library.
  26.125 + */
  26.126 +extern void
  26.127 +xen_user_record_set_free(xen_user_record_set *set);
  26.128 +
  26.129 +
  26.130 +
  26.131 +typedef struct xen_user_record_opt_set
  26.132 +{
  26.133 +    size_t size;
  26.134 +    xen_user_record_opt *contents[];
  26.135 +} xen_user_record_opt_set;
  26.136 +
  26.137 +/**
  26.138 + * Allocate a xen_user_record_opt_set of the given size.
  26.139 + */
  26.140 +extern xen_user_record_opt_set *
  26.141 +xen_user_record_opt_set_alloc(size_t size);
  26.142 +
  26.143 +/**
  26.144 + * Free the given xen_user_record_opt_set, and all referenced values. 
  26.145 + * The given set must have been allocated by this library.
  26.146 + */
  26.147 +extern void
  26.148 +xen_user_record_opt_set_free(xen_user_record_opt_set *set);
  26.149 +
  26.150 +
  26.151 +/**
  26.152 + * Get the current state of the given user.  !!!
  26.153 + */
  26.154 +extern bool
  26.155 +xen_user_get_record(xen_session *session, xen_user_record **result, xen_user user);
  26.156 +
  26.157 +
  26.158 +/**
  26.159 + * Get a reference to the object with the specified UUID.  !!!
  26.160 + */
  26.161 +extern bool
  26.162 +xen_user_get_by_uuid(xen_session *session, xen_user *result, char *uuid);
  26.163 +
  26.164 +
  26.165 +/**
  26.166 + * Create a new user instance, and return its handle.
  26.167 + */
  26.168 +extern bool
  26.169 +xen_user_create(xen_session *session, xen_user *result, xen_user_record *record);
  26.170 +
  26.171 +
  26.172 +/**
  26.173 + * Get the uuid field of the given user.
  26.174 + */
  26.175 +extern bool
  26.176 +xen_user_get_uuid(xen_session *session, char **result, xen_user user);
  26.177 +
  26.178 +
  26.179 +/**
  26.180 + * Get the short_name field of the given user.
  26.181 + */
  26.182 +extern bool
  26.183 +xen_user_get_short_name(xen_session *session, char **result, xen_user user);
  26.184 +
  26.185 +
  26.186 +/**
  26.187 + * Get the fullname field of the given user.
  26.188 + */
  26.189 +extern bool
  26.190 +xen_user_get_fullname(xen_session *session, char **result, xen_user user);
  26.191 +
  26.192 +
  26.193 +/**
  26.194 + * Set the fullname field of the given user.
  26.195 + */
  26.196 +extern bool
  26.197 +xen_user_set_fullname(xen_session *session, xen_user xen_user, char *fullname);
  26.198 +
  26.199 +
  26.200 +#endif
    27.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.2 +++ b/tools/libxen/include/xen_user_decl.h	Sat Oct 07 18:22:09 2006 +0100
    27.3 @@ -0,0 +1,30 @@
    27.4 +/*
    27.5 + * Copyright (c) 2006, XenSource Inc.
    27.6 + *
    27.7 + * This library is free software; you can redistribute it and/or
    27.8 + * modify it under the terms of the GNU Lesser General Public
    27.9 + * License as published by the Free Software Foundation; either
   27.10 + * version 2.1 of the License, or (at your option) any later version.
   27.11 + *
   27.12 + * This library is distributed in the hope that it will be useful,
   27.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   27.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   27.15 + * Lesser General Public License for more details.
   27.16 + *
   27.17 + * You should have received a copy of the GNU Lesser General Public
   27.18 + * License along with this library; if not, write to the Free Software
   27.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   27.20 + */
   27.21 +
   27.22 +#ifndef XEN_USER_DECL_H
   27.23 +#define XEN_USER_DECL_H
   27.24 +
   27.25 +typedef void *xen_user;
   27.26 +
   27.27 +struct xen_user_set;
   27.28 +struct xen_user_record;
   27.29 +struct xen_user_record_set;
   27.30 +struct xen_user_record_opt;
   27.31 +struct xen_user_record_opt_set;
   27.32 +
   27.33 +#endif
    28.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.2 +++ b/tools/libxen/include/xen_vbd.h	Sat Oct 07 18:22:09 2006 +0100
    28.3 @@ -0,0 +1,269 @@
    28.4 +/*
    28.5 + * Copyright (c) 2006, XenSource Inc.
    28.6 + *
    28.7 + * This library is free software; you can redistribute it and/or
    28.8 + * modify it under the terms of the GNU Lesser General Public
    28.9 + * License as published by the Free Software Foundation; either
   28.10 + * version 2.1 of the License, or (at your option) any later version.
   28.11 + *
   28.12 + * This library is distributed in the hope that it will be useful,
   28.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   28.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   28.15 + * Lesser General Public License for more details.
   28.16 + *
   28.17 + * You should have received a copy of the GNU Lesser General Public
   28.18 + * License along with this library; if not, write to the Free Software
   28.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   28.20 + */
   28.21 +
   28.22 +#ifndef XEN_VBD_H
   28.23 +#define XEN_VBD_H
   28.24 +
   28.25 +#include "xen_common.h"
   28.26 +#include "xen_driver_type.h"
   28.27 +#include "xen_vbd_decl.h"
   28.28 +#include "xen_vbd_mode.h"
   28.29 +#include "xen_vdi_decl.h"
   28.30 +#include "xen_vm_decl.h"
   28.31 +
   28.32 +
   28.33 +/*
   28.34 + * The VBD class. 
   28.35 + *  
   28.36 + * A virtual block device.
   28.37 + */
   28.38 +
   28.39 +
   28.40 +/**
   28.41 + * Free the given xen_vbd.  The given handle must have been allocated
   28.42 + * by this library.
   28.43 + */
   28.44 +extern void
   28.45 +xen_vbd_free(xen_vbd vbd);
   28.46 +
   28.47 +
   28.48 +typedef struct xen_vbd_set
   28.49 +{
   28.50 +    size_t size;
   28.51 +    xen_vbd *contents[];
   28.52 +} xen_vbd_set;
   28.53 +
   28.54 +/**
   28.55 + * Allocate a xen_vbd_set of the given size.
   28.56 + */
   28.57 +extern xen_vbd_set *
   28.58 +xen_vbd_set_alloc(size_t size);
   28.59 +
   28.60 +/**
   28.61 + * Free the given xen_vbd_set.  The given set must have been allocated
   28.62 + * by this library.
   28.63 + */
   28.64 +extern void
   28.65 +xen_vbd_set_free(xen_vbd_set *set);
   28.66 +
   28.67 +
   28.68 +typedef struct xen_vbd_record
   28.69 +{
   28.70 +    xen_vbd handle;
   28.71 +    char *uuid;
   28.72 +    struct xen_vm_record_opt *vm;
   28.73 +    struct xen_vdi_record_opt *vdi;
   28.74 +    char *device;
   28.75 +    enum xen_vbd_mode mode;
   28.76 +    enum xen_driver_type driver;
   28.77 +    double io_bandwidth_incoming_kbs;
   28.78 +    double io_bandwidth_outgoing_kbs;
   28.79 +} xen_vbd_record;
   28.80 +
   28.81 +/**
   28.82 + * Allocate a xen_vbd_record.
   28.83 + */
   28.84 +extern xen_vbd_record *
   28.85 +xen_vbd_record_alloc(void);
   28.86 +
   28.87 +/**
   28.88 + * Free the given xen_vbd_record, and all referenced values.  The given
   28.89 + * record must have been allocated by this library.
   28.90 + */
   28.91 +extern void
   28.92 +xen_vbd_record_free(xen_vbd_record *record);
   28.93 +
   28.94 +
   28.95 +typedef struct xen_vbd_record_opt
   28.96 +{
   28.97 +    bool is_record;
   28.98 +    union
   28.99 +    {
  28.100 +        xen_vbd handle;
  28.101 +        xen_vbd_record *record;
  28.102 +    } u;
  28.103 +} xen_vbd_record_opt;
  28.104 +
  28.105 +/**
  28.106 + * Allocate a xen_vbd_record_opt.
  28.107 + */
  28.108 +extern xen_vbd_record_opt *
  28.109 +xen_vbd_record_opt_alloc(void);
  28.110 +
  28.111 +/**
  28.112 + * Free the given xen_vbd_record_opt, and all referenced values.  The
  28.113 + * given record_opt must have been allocated by this library.
  28.114 + */
  28.115 +extern void
  28.116 +xen_vbd_record_opt_free(xen_vbd_record_opt *record_opt);
  28.117 +
  28.118 +
  28.119 +typedef struct xen_vbd_record_set
  28.120 +{
  28.121 +    size_t size;
  28.122 +    xen_vbd_record *contents[];
  28.123 +} xen_vbd_record_set;
  28.124 +
  28.125 +/**
  28.126 + * Allocate a xen_vbd_record_set of the given size.
  28.127 + */
  28.128 +extern xen_vbd_record_set *
  28.129 +xen_vbd_record_set_alloc(size_t size);
  28.130 +
  28.131 +/**
  28.132 + * Free the given xen_vbd_record_set, and all referenced values.  The
  28.133 + * given set must have been allocated by this library.
  28.134 + */
  28.135 +extern void
  28.136 +xen_vbd_record_set_free(xen_vbd_record_set *set);
  28.137 +
  28.138 +
  28.139 +
  28.140 +typedef struct xen_vbd_record_opt_set
  28.141 +{
  28.142 +    size_t size;
  28.143 +    xen_vbd_record_opt *contents[];
  28.144 +} xen_vbd_record_opt_set;
  28.145 +
  28.146 +/**
  28.147 + * Allocate a xen_vbd_record_opt_set of the given size.
  28.148 + */
  28.149 +extern xen_vbd_record_opt_set *
  28.150 +xen_vbd_record_opt_set_alloc(size_t size);
  28.151 +
  28.152 +/**
  28.153 + * Free the given xen_vbd_record_opt_set, and all referenced values. 
  28.154 + * The given set must have been allocated by this library.
  28.155 + */
  28.156 +extern void
  28.157 +xen_vbd_record_opt_set_free(xen_vbd_record_opt_set *set);
  28.158 +
  28.159 +
  28.160 +/**
  28.161 + * Get the current state of the given VBD.  !!!
  28.162 + */
  28.163 +extern bool
  28.164 +xen_vbd_get_record(xen_session *session, xen_vbd_record **result, xen_vbd vbd);
  28.165 +
  28.166 +
  28.167 +/**
  28.168 + * Get a reference to the object with the specified UUID.  !!!
  28.169 + */
  28.170 +extern bool
  28.171 +xen_vbd_get_by_uuid(xen_session *session, xen_vbd *result, char *uuid);
  28.172 +
  28.173 +
  28.174 +/**
  28.175 + * Create a new VBD instance, and return its handle.
  28.176 + */
  28.177 +extern bool
  28.178 +xen_vbd_create(xen_session *session, xen_vbd *result, xen_vbd_record *record);
  28.179 +
  28.180 +
  28.181 +/**
  28.182 + * Get the uuid field of the given VBD.
  28.183 + */
  28.184 +extern bool
  28.185 +xen_vbd_get_uuid(xen_session *session, char **result, xen_vbd vbd);
  28.186 +
  28.187 +
  28.188 +/**
  28.189 + * Get the VM field of the given VBD.
  28.190 + */
  28.191 +extern bool
  28.192 +xen_vbd_get_vm(xen_session *session, xen_vm *result, xen_vbd vbd);
  28.193 +
  28.194 +
  28.195 +/**
  28.196 + * Get the VDI field of the given VBD.
  28.197 + */
  28.198 +extern bool
  28.199 +xen_vbd_get_vdi(xen_session *session, xen_vdi *result, xen_vbd vbd);
  28.200 +
  28.201 +
  28.202 +/**
  28.203 + * Get the device field of the given VBD.
  28.204 + */
  28.205 +extern bool
  28.206 +xen_vbd_get_device(xen_session *session, char **result, xen_vbd vbd);
  28.207 +
  28.208 +
  28.209 +/**
  28.210 + * Get the mode field of the given VBD.
  28.211 + */
  28.212 +extern bool
  28.213 +xen_vbd_get_mode(xen_session *session, enum xen_vbd_mode *result, xen_vbd vbd);
  28.214 +
  28.215 +
  28.216 +/**
  28.217 + * Get the driver field of the given VBD.
  28.218 + */
  28.219 +extern bool
  28.220 +xen_vbd_get_driver(xen_session *session, enum xen_driver_type *result, xen_vbd vbd);
  28.221 +
  28.222 +
  28.223 +/**
  28.224 + * Get the IO_bandwidth/incoming_kbs field of the given VBD.
  28.225 + */
  28.226 +extern bool
  28.227 +xen_vbd_get_io_bandwidth_incoming_kbs(xen_session *session, double *result, xen_vbd vbd);
  28.228 +
  28.229 +
  28.230 +/**
  28.231 + * Get the IO_bandwidth/outgoing_kbs field of the given VBD.
  28.232 + */
  28.233 +extern bool
  28.234 +xen_vbd_get_io_bandwidth_outgoing_kbs(xen_session *session, double *result, xen_vbd vbd);
  28.235 +
  28.236 +
  28.237 +/**
  28.238 + * Set the VM field of the given VBD.
  28.239 + */
  28.240 +extern bool
  28.241 +xen_vbd_set_vm(xen_session *session, xen_vbd xen_vbd, xen_vm vm);
  28.242 +
  28.243 +
  28.244 +/**
  28.245 + * Set the VDI field of the given VBD.
  28.246 + */
  28.247 +extern bool
  28.248 +xen_vbd_set_vdi(xen_session *session, xen_vbd xen_vbd, xen_vdi vdi);
  28.249 +
  28.250 +
  28.251 +/**
  28.252 + * Set the device field of the given VBD.
  28.253 + */
  28.254 +extern bool
  28.255 +xen_vbd_set_device(xen_session *session, xen_vbd xen_vbd, char *device);
  28.256 +
  28.257 +
  28.258 +/**
  28.259 + * Set the mode field of the given VBD.
  28.260 + */
  28.261 +extern bool
  28.262 +xen_vbd_set_mode(xen_session *session, xen_vbd xen_vbd, enum xen_vbd_mode mode);
  28.263 +
  28.264 +
  28.265 +/**
  28.266 + * Set the driver field of the given VBD.
  28.267 + */
  28.268 +extern bool
  28.269 +xen_vbd_set_driver(xen_session *session, xen_vbd xen_vbd, enum xen_driver_type driver);
  28.270 +
  28.271 +
  28.272 +#endif
    29.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.2 +++ b/tools/libxen/include/xen_vbd_decl.h	Sat Oct 07 18:22:09 2006 +0100
    29.3 @@ -0,0 +1,30 @@
    29.4 +/*
    29.5 + * Copyright (c) 2006, XenSource Inc.
    29.6 + *
    29.7 + * This library is free software; you can redistribute it and/or
    29.8 + * modify it under the terms of the GNU Lesser General Public
    29.9 + * License as published by the Free Software Foundation; either
   29.10 + * version 2.1 of the License, or (at your option) any later version.
   29.11 + *
   29.12 + * This library is distributed in the hope that it will be useful,
   29.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   29.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   29.15 + * Lesser General Public License for more details.
   29.16 + *
   29.17 + * You should have received a copy of the GNU Lesser General Public
   29.18 + * License along with this library; if not, write to the Free Software
   29.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   29.20 + */
   29.21 +
   29.22 +#ifndef XEN_VBD_DECL_H
   29.23 +#define XEN_VBD_DECL_H
   29.24 +
   29.25 +typedef void *xen_vbd;
   29.26 +
   29.27 +struct xen_vbd_set;
   29.28 +struct xen_vbd_record;
   29.29 +struct xen_vbd_record_set;
   29.30 +struct xen_vbd_record_opt;
   29.31 +struct xen_vbd_record_opt_set;
   29.32 +
   29.33 +#endif
    30.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.2 +++ b/tools/libxen/include/xen_vbd_mode.h	Sat Oct 07 18:22:09 2006 +0100
    30.3 @@ -0,0 +1,77 @@
    30.4 +/*
    30.5 + * Copyright (c) 2006, XenSource Inc.
    30.6 + *
    30.7 + * This library is free software; you can redistribute it and/or
    30.8 + * modify it under the terms of the GNU Lesser General Public
    30.9 + * License as published by the Free Software Foundation; either
   30.10 + * version 2.1 of the License, or (at your option) any later version.
   30.11 + *
   30.12 + * This library is distributed in the hope that it will be useful,
   30.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   30.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   30.15 + * Lesser General Public License for more details.
   30.16 + *
   30.17 + * You should have received a copy of the GNU Lesser General Public
   30.18 + * License along with this library; if not, write to the Free Software
   30.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   30.20 + */
   30.21 +
   30.22 +#ifndef XEN_VBD_MODE_H
   30.23 +#define XEN_VBD_MODE_H
   30.24 +
   30.25 +
   30.26 +#include "xen_common.h"
   30.27 +
   30.28 +
   30.29 +enum xen_vbd_mode
   30.30 +{
   30.31 +    /**
   30.32 +     * disk is mounted read-only
   30.33 +     */
   30.34 +    XEN_VBD_MODE_RO,
   30.35 +
   30.36 +    /**
   30.37 +     * disk is mounted read-write
   30.38 +     */
   30.39 +    XEN_VBD_MODE_RW
   30.40 +};
   30.41 +
   30.42 +
   30.43 +typedef struct xen_vbd_mode_set
   30.44 +{
   30.45 +    size_t size;
   30.46 +    enum xen_vbd_mode contents[];
   30.47 +} xen_vbd_mode_set;
   30.48 +
   30.49 +/**
   30.50 + * Allocate a xen_vbd_mode_set of the given size.
   30.51 + */
   30.52 +extern xen_vbd_mode_set *
   30.53 +xen_vbd_mode_set_alloc(size_t size);
   30.54 +
   30.55 +/**
   30.56 + * Free the given xen_vbd_mode_set.  The given set must have been
   30.57 + * allocated by this library.
   30.58 + */
   30.59 +extern void
   30.60 +xen_vbd_mode_set_free(xen_vbd_mode_set *set);
   30.61 +
   30.62 +
   30.63 +/**
   30.64 + * Return the name corresponding to the given code.  This string must
   30.65 + * not be modified or freed.
   30.66 + */
   30.67 +extern const char *
   30.68 +xen_vbd_mode_to_string(enum xen_vbd_mode val);
   30.69 +
   30.70 +
   30.71 +/**
   30.72 + * Return the correct code for the given string, or set the session
   30.73 + * object to failure and return an undefined value if the given string does
   30.74 + * not match a known code.
   30.75 + */
   30.76 +extern enum xen_vbd_mode
   30.77 +xen_vbd_mode_from_string(xen_session *session, const char *str);
   30.78 +
   30.79 +
   30.80 +#endif
    31.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.2 +++ b/tools/libxen/include/xen_vbd_mode_internal.h	Sat Oct 07 18:22:09 2006 +0100
    31.3 @@ -0,0 +1,37 @@
    31.4 +/*
    31.5 + * Copyright (c) 2006, XenSource Inc.
    31.6 + *
    31.7 + * This library is free software; you can redistribute it and/or
    31.8 + * modify it under the terms of the GNU Lesser General Public
    31.9 + * License as published by the Free Software Foundation; either
   31.10 + * version 2.1 of the License, or (at your option) any later version.
   31.11 + *
   31.12 + * This library is distributed in the hope that it will be useful,
   31.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   31.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   31.15 + * Lesser General Public License for more details.
   31.16 + *
   31.17 + * You should have received a copy of the GNU Lesser General Public
   31.18 + * License along with this library; if not, write to the Free Software
   31.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   31.20 + */
   31.21 +
   31.22 +
   31.23 +/*
   31.24 + * Declarations of the abstract types used during demarshalling of enum
   31.25 + * xen_vbd_mode.  Internal to this library -- do not use from outside.
   31.26 + */
   31.27 +
   31.28 +
   31.29 +#ifndef XEN_VBD_MODE_INTERNAL_H
   31.30 +#define XEN_VBD_MODE_INTERNAL_H
   31.31 +
   31.32 +
   31.33 +#include "xen_internal.h"
   31.34 +
   31.35 +
   31.36 +extern const abstract_type xen_vbd_mode_abstract_type_;
   31.37 +extern const abstract_type xen_vbd_mode_set_abstract_type_;
   31.38 +
   31.39 +
   31.40 +#endif
    32.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    32.2 +++ b/tools/libxen/include/xen_vdi.h	Sat Oct 07 18:22:09 2006 +0100
    32.3 @@ -0,0 +1,330 @@
    32.4 +/*
    32.5 + * Copyright (c) 2006, XenSource Inc.
    32.6 + *
    32.7 + * This library is free software; you can redistribute it and/or
    32.8 + * modify it under the terms of the GNU Lesser General Public
    32.9 + * License as published by the Free Software Foundation; either
   32.10 + * version 2.1 of the License, or (at your option) any later version.
   32.11 + *
   32.12 + * This library is distributed in the hope that it will be useful,
   32.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   32.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   32.15 + * Lesser General Public License for more details.
   32.16 + *
   32.17 + * You should have received a copy of the GNU Lesser General Public
   32.18 + * License along with this library; if not, write to the Free Software
   32.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   32.20 + */
   32.21 +
   32.22 +#ifndef XEN_VDI_H
   32.23 +#define XEN_VDI_H
   32.24 +
   32.25 +#include "xen_common.h"
   32.26 +#include "xen_sr_decl.h"
   32.27 +#include "xen_vbd_decl.h"
   32.28 +#include "xen_vdi_decl.h"
   32.29 +#include "xen_vdi_type.h"
   32.30 +
   32.31 +
   32.32 +/*
   32.33 + * The VDI class. 
   32.34 + *  
   32.35 + * A virtual disk image.
   32.36 + */
   32.37 +
   32.38 +
   32.39 +/**
   32.40 + * Free the given xen_vdi.  The given handle must have been allocated
   32.41 + * by this library.
   32.42 + */
   32.43 +extern void
   32.44 +xen_vdi_free(xen_vdi vdi);
   32.45 +
   32.46 +
   32.47 +typedef struct xen_vdi_set
   32.48 +{
   32.49 +    size_t size;
   32.50 +    xen_vdi *contents[];
   32.51 +} xen_vdi_set;
   32.52 +
   32.53 +/**
   32.54 + * Allocate a xen_vdi_set of the given size.
   32.55 + */
   32.56 +extern xen_vdi_set *
   32.57 +xen_vdi_set_alloc(size_t size);
   32.58 +
   32.59 +/**
   32.60 + * Free the given xen_vdi_set.  The given set must have been allocated
   32.61 + * by this library.
   32.62 + */
   32.63 +extern void
   32.64 +xen_vdi_set_free(xen_vdi_set *set);
   32.65 +
   32.66 +
   32.67 +typedef struct xen_vdi_record
   32.68 +{
   32.69 +    xen_vdi handle;
   32.70 +    char *uuid;
   32.71 +    char *name_label;
   32.72 +    char *name_description;
   32.73 +    struct xen_sr_record_opt *sr;
   32.74 +    struct xen_vbd_record_opt_set *vbds;
   32.75 +    uint64_t virtual_size;
   32.76 +    uint64_t physical_utilisation;
   32.77 +    uint64_t sector_size;
   32.78 +    enum xen_vdi_type type;
   32.79 +    struct xen_vdi_record_opt *parent;
   32.80 +    struct xen_vdi_record_opt_set *children;
   32.81 +    bool sharable;
   32.82 +    bool read_only;
   32.83 +} xen_vdi_record;
   32.84 +
   32.85 +/**
   32.86 + * Allocate a xen_vdi_record.
   32.87 + */
   32.88 +extern xen_vdi_record *
   32.89 +xen_vdi_record_alloc(void);
   32.90 +
   32.91 +/**
   32.92 + * Free the given xen_vdi_record, and all referenced values.  The given
   32.93 + * record must have been allocated by this library.
   32.94 + */
   32.95 +extern void
   32.96 +xen_vdi_record_free(xen_vdi_record *record);
   32.97 +
   32.98 +
   32.99 +typedef struct xen_vdi_record_opt
  32.100 +{
  32.101 +    bool is_record;
  32.102 +    union
  32.103 +    {
  32.104 +        xen_vdi handle;
  32.105 +        xen_vdi_record *record;
  32.106 +    } u;
  32.107 +} xen_vdi_record_opt;
  32.108 +
  32.109 +/**
  32.110 + * Allocate a xen_vdi_record_opt.
  32.111 + */
  32.112 +extern xen_vdi_record_opt *
  32.113 +xen_vdi_record_opt_alloc(void);
  32.114 +
  32.115 +/**
  32.116 + * Free the given xen_vdi_record_opt, and all referenced values.  The
  32.117 + * given record_opt must have been allocated by this library.
  32.118 + */
  32.119 +extern void
  32.120 +xen_vdi_record_opt_free(xen_vdi_record_opt *record_opt);
  32.121 +
  32.122 +
  32.123 +typedef struct xen_vdi_record_set
  32.124 +{
  32.125 +    size_t size;
  32.126 +    xen_vdi_record *contents[];
  32.127 +} xen_vdi_record_set;
  32.128 +
  32.129 +/**
  32.130 + * Allocate a xen_vdi_record_set of the given size.
  32.131 + */
  32.132 +extern xen_vdi_record_set *
  32.133 +xen_vdi_record_set_alloc(size_t size);
  32.134 +
  32.135 +/**
  32.136 + * Free the given xen_vdi_record_set, and all referenced values.  The
  32.137 + * given set must have been allocated by this library.
  32.138 + */
  32.139 +extern void
  32.140 +xen_vdi_record_set_free(xen_vdi_record_set *set);
  32.141 +
  32.142 +
  32.143 +
  32.144 +typedef struct xen_vdi_record_opt_set
  32.145 +{
  32.146 +    size_t size;
  32.147 +    xen_vdi_record_opt *contents[];
  32.148 +} xen_vdi_record_opt_set;
  32.149 +
  32.150 +/**
  32.151 + * Allocate a xen_vdi_record_opt_set of the given size.
  32.152 + */
  32.153 +extern xen_vdi_record_opt_set *
  32.154 +xen_vdi_record_opt_set_alloc(size_t size);
  32.155 +
  32.156 +/**
  32.157 + * Free the given xen_vdi_record_opt_set, and all referenced values. 
  32.158 + * The given set must have been allocated by this library.
  32.159 + */
  32.160 +extern void
  32.161 +xen_vdi_record_opt_set_free(xen_vdi_record_opt_set *set);
  32.162 +
  32.163 +
  32.164 +/**
  32.165 + * Get the current state of the given VDI.  !!!
  32.166 + */
  32.167 +extern bool
  32.168 +xen_vdi_get_record(xen_session *session, xen_vdi_record **result, xen_vdi vdi);
  32.169 +
  32.170 +
  32.171 +/**
  32.172 + * Get a reference to the object with the specified UUID.  !!!
  32.173 + */
  32.174 +extern bool
  32.175 +xen_vdi_get_by_uuid(xen_session *session, xen_vdi *result, char *uuid);
  32.176 +
  32.177 +
  32.178 +/**
  32.179 + * Create a new VDI instance, and return its handle.
  32.180 + */
  32.181 +extern bool
  32.182 +xen_vdi_create(xen_session *session, xen_vdi *result, xen_vdi_record *record);
  32.183 +
  32.184 +
  32.185 +/**
  32.186 + * Get a reference to the object with the specified label.
  32.187 + */
  32.188 +extern bool
  32.189 +xen_vdi_get_by_name_label(xen_session *session, xen_vdi *result, char *label);
  32.190 +
  32.191 +
  32.192 +/**
  32.193 + * Get the uuid field of the given VDI.
  32.194 + */
  32.195 +extern bool
  32.196 +xen_vdi_get_uuid(xen_session *session, char **result, xen_vdi vdi);
  32.197 +
  32.198 +
  32.199 +/**
  32.200 + * Get the name/label field of the given VDI.
  32.201 + */
  32.202 +extern bool
  32.203 +xen_vdi_get_name_label(xen_session *session, char **result, xen_vdi vdi);
  32.204 +
  32.205 +
  32.206 +/**
  32.207 + * Get the name/description field of the given VDI.
  32.208 + */
  32.209 +extern bool
  32.210 +xen_vdi_get_name_description(xen_session *session, char **result, xen_vdi vdi);
  32.211 +
  32.212 +
  32.213 +/**
  32.214 + * Get the SR field of the given VDI.
  32.215 + */
  32.216 +extern bool
  32.217 +xen_vdi_get_sr(xen_session *session, xen_sr *result, xen_vdi vdi);
  32.218 +
  32.219 +
  32.220 +/**
  32.221 + * Get the VBDs field of the given VDI.
  32.222 + */
  32.223 +extern bool
  32.224 +xen_vdi_get_vbds(xen_session *session, xen_vbd *result, xen_vdi vdi);
  32.225 +
  32.226 +
  32.227 +/**
  32.228 + * Get the virtual_size field of the given VDI.
  32.229 + */
  32.230 +extern bool
  32.231 +xen_vdi_get_virtual_size(xen_session *session, uint64_t *result, xen_vdi vdi);
  32.232 +
  32.233 +
  32.234 +/**
  32.235 + * Get the physical_utilisation field of the given VDI.
  32.236 + */
  32.237 +extern bool
  32.238 +xen_vdi_get_physical_utilisation(xen_session *session, uint64_t *result, xen_vdi vdi);
  32.239 +
  32.240 +
  32.241 +/**
  32.242 + * Get the sector_size field of the given VDI.
  32.243 + */
  32.244 +extern bool
  32.245 +xen_vdi_get_sector_size(xen_session *session, uint64_t *result, xen_vdi vdi);
  32.246 +
  32.247 +
  32.248 +/**
  32.249 + * Get the type field of the given VDI.
  32.250 + */
  32.251 +extern bool
  32.252 +xen_vdi_get_type(xen_session *session, enum xen_vdi_type *result, xen_vdi vdi);
  32.253 +
  32.254 +
  32.255 +/**
  32.256 + * Get the parent field of the given VDI.
  32.257 + */
  32.258 +extern bool
  32.259 +xen_vdi_get_parent(xen_session *session, xen_vdi *result, xen_vdi vdi);
  32.260 +
  32.261 +
  32.262 +/**
  32.263 + * Get the children field of the given VDI.
  32.264 + */
  32.265 +extern bool
  32.266 +xen_vdi_get_children(xen_session *session, xen_vdi *result, xen_vdi vdi);
  32.267 +
  32.268 +
  32.269 +/**
  32.270 + * Get the sharable field of the given VDI.
  32.271 + */
  32.272 +extern bool
  32.273 +xen_vdi_get_sharable(xen_session *session, bool *result, xen_vdi vdi);
  32.274 +
  32.275 +
  32.276 +/**
  32.277 + * Get the read_only field of the given VDI.
  32.278 + */
  32.279 +extern bool
  32.280 +xen_vdi_get_read_only(xen_session *session, bool *result, xen_vdi vdi);
  32.281 +
  32.282 +
  32.283 +/**
  32.284 + * Set the name/label field of the given VDI.
  32.285 + */
  32.286 +extern bool
  32.287 +xen_vdi_set_name_label(xen_session *session, xen_vdi xen_vdi, char *label);
  32.288 +
  32.289 +
  32.290 +/**
  32.291 + * Set the name/description field of the given VDI.
  32.292 + */
  32.293 +extern bool
  32.294 +xen_vdi_set_name_description(xen_session *session, xen_vdi xen_vdi, char *description);
  32.295 +
  32.296 +
  32.297 +/**
  32.298 + * Set the SR field of the given VDI.
  32.299 + */
  32.300 +extern bool
  32.301 +xen_vdi_set_sr(xen_session *session, xen_vdi xen_vdi, xen_sr sr);
  32.302 +
  32.303 +
  32.304 +/**
  32.305 + * Set the virtual_size field of the given VDI.
  32.306 + */
  32.307 +extern bool
  32.308 +xen_vdi_set_virtual_size(xen_session *session, xen_vdi xen_vdi, uint64_t virtual_size);
  32.309 +
  32.310 +
  32.311 +/**
  32.312 + * Set the sharable field of the given VDI.
  32.313 + */
  32.314 +extern bool
  32.315 +xen_vdi_set_sharable(xen_session *session, xen_vdi xen_vdi, bool sharable);
  32.316 +
  32.317 +
  32.318 +/**
  32.319 + * Set the read_only field of the given VDI.
  32.320 + */
  32.321 +extern bool
  32.322 +xen_vdi_set_read_only(xen_session *session, xen_vdi xen_vdi, bool read_only);
  32.323 +
  32.324 +
  32.325 +/**
  32.326 + * Take an exact copy of the VDI; the snapshot lives in the same
  32.327 + * Storage Repository as its parent.
  32.328 + */
  32.329 +extern bool
  32.330 +xen_vdi_snapshot(xen_session *session, xen_vdi *result, xen_vdi vdi);
  32.331 +
  32.332 +
  32.333 +#endif
    33.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    33.2 +++ b/tools/libxen/include/xen_vdi_decl.h	Sat Oct 07 18:22:09 2006 +0100
    33.3 @@ -0,0 +1,30 @@
    33.4 +/*
    33.5 + * Copyright (c) 2006, XenSource Inc.
    33.6 + *
    33.7 + * This library is free software; you can redistribute it and/or
    33.8 + * modify it under the terms of the GNU Lesser General Public
    33.9 + * License as published by the Free Software Foundation; either
   33.10 + * version 2.1 of the License, or (at your option) any later version.
   33.11 + *
   33.12 + * This library is distributed in the hope that it will be useful,
   33.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   33.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   33.15 + * Lesser General Public License for more details.
   33.16 + *
   33.17 + * You should have received a copy of the GNU Lesser General Public
   33.18 + * License along with this library; if not, write to the Free Software
   33.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   33.20 + */
   33.21 +
   33.22 +#ifndef XEN_VDI_DECL_H
   33.23 +#define XEN_VDI_DECL_H
   33.24 +
   33.25 +typedef void *xen_vdi;
   33.26 +
   33.27 +struct xen_vdi_set;
   33.28 +struct xen_vdi_record;
   33.29 +struct xen_vdi_record_set;
   33.30 +struct xen_vdi_record_opt;
   33.31 +struct xen_vdi_record_opt_set;
   33.32 +
   33.33 +#endif
    34.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    34.2 +++ b/tools/libxen/include/xen_vdi_type.h	Sat Oct 07 18:22:09 2006 +0100
    34.3 @@ -0,0 +1,82 @@
    34.4 +/*
    34.5 + * Copyright (c) 2006, XenSource Inc.
    34.6 + *
    34.7 + * This library is free software; you can redistribute it and/or
    34.8 + * modify it under the terms of the GNU Lesser General Public
    34.9 + * License as published by the Free Software Foundation; either
   34.10 + * version 2.1 of the License, or (at your option) any later version.
   34.11 + *
   34.12 + * This library is distributed in the hope that it will be useful,
   34.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   34.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   34.15 + * Lesser General Public License for more details.
   34.16 + *
   34.17 + * You should have received a copy of the GNU Lesser General Public
   34.18 + * License along with this library; if not, write to the Free Software
   34.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   34.20 + */
   34.21 +
   34.22 +#ifndef XEN_VDI_TYPE_H
   34.23 +#define XEN_VDI_TYPE_H
   34.24 +
   34.25 +
   34.26 +#include "xen_common.h"
   34.27 +
   34.28 +
   34.29 +enum xen_vdi_type
   34.30 +{
   34.31 +    /**
   34.32 +     * a disk that may be replaced on upgrade
   34.33 +     */
   34.34 +    XEN_VDI_TYPE_SYSTEM,
   34.35 +
   34.36 +    /**
   34.37 +     * a disk that is always preserved on upgrade
   34.38 +     */
   34.39 +    XEN_VDI_TYPE_USER,
   34.40 +
   34.41 +    /**
   34.42 +     * a disk that may be reformatted on upgrade
   34.43 +     */
   34.44 +    XEN_VDI_TYPE_EPHEMERAL
   34.45 +};
   34.46 +
   34.47 +
   34.48 +typedef struct xen_vdi_type_set
   34.49 +{
   34.50 +    size_t size;
   34.51 +    enum xen_vdi_type contents[];
   34.52 +} xen_vdi_type_set;
   34.53 +
   34.54 +/**
   34.55 + * Allocate a xen_vdi_type_set of the given size.
   34.56 + */
   34.57 +extern xen_vdi_type_set *
   34.58 +xen_vdi_type_set_alloc(size_t size);
   34.59 +
   34.60 +/**
   34.61 + * Free the given xen_vdi_type_set.  The given set must have been
   34.62 + * allocated by this library.
   34.63 + */
   34.64 +extern void
   34.65 +xen_vdi_type_set_free(xen_vdi_type_set *set);
   34.66 +
   34.67 +
   34.68 +/**
   34.69 + * Return the name corresponding to the given code.  This string must
   34.70 + * not be modified or freed.
   34.71 + */
   34.72 +extern const char *
   34.73 +xen_vdi_type_to_string(enum xen_vdi_type val);
   34.74 +
   34.75 +
   34.76 +/**
   34.77 + * Return the correct code for the given string, or set the session
   34.78 + * object to failure and return an undefined value if the given string does
   34.79 + * not match a known code.
   34.80 + */
   34.81 +extern enum xen_vdi_type
   34.82 +xen_vdi_type_from_string(xen_session *session, const char *str);
   34.83 +
   34.84 +
   34.85 +#endif
    35.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    35.2 +++ b/tools/libxen/include/xen_vdi_type_internal.h	Sat Oct 07 18:22:09 2006 +0100
    35.3 @@ -0,0 +1,37 @@
    35.4 +/*
    35.5 + * Copyright (c) 2006, XenSource Inc.
    35.6 + *
    35.7 + * This library is free software; you can redistribute it and/or
    35.8 + * modify it under the terms of the GNU Lesser General Public
    35.9 + * License as published by the Free Software Foundation; either
   35.10 + * version 2.1 of the License, or (at your option) any later version.
   35.11 + *
   35.12 + * This library is distributed in the hope that it will be useful,
   35.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   35.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   35.15 + * Lesser General Public License for more details.
   35.16 + *
   35.17 + * You should have received a copy of the GNU Lesser General Public
   35.18 + * License along with this library; if not, write to the Free Software
   35.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   35.20 + */
   35.21 +
   35.22 +
   35.23 +/*
   35.24 + * Declarations of the abstract types used during demarshalling of enum
   35.25 + * xen_vdi_type.  Internal to this library -- do not use from outside.
   35.26 + */
   35.27 +
   35.28 +
   35.29 +#ifndef XEN_VDI_TYPE_INTERNAL_H
   35.30 +#define XEN_VDI_TYPE_INTERNAL_H
   35.31 +
   35.32 +
   35.33 +#include "xen_internal.h"
   35.34 +
   35.35 +
   35.36 +extern const abstract_type xen_vdi_type_abstract_type_;
   35.37 +extern const abstract_type xen_vdi_type_set_abstract_type_;
   35.38 +
   35.39 +
   35.40 +#endif
    36.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    36.2 +++ b/tools/libxen/include/xen_vif.h	Sat Oct 07 18:22:09 2006 +0100
    36.3 @@ -0,0 +1,314 @@
    36.4 +/*
    36.5 + * Copyright (c) 2006, XenSource Inc.
    36.6 + *
    36.7 + * This library is free software; you can redistribute it and/or
    36.8 + * modify it under the terms of the GNU Lesser General Public
    36.9 + * License as published by the Free Software Foundation; either
   36.10 + * version 2.1 of the License, or (at your option) any later version.
   36.11 + *
   36.12 + * This library is distributed in the hope that it will be useful,
   36.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   36.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   36.15 + * Lesser General Public License for more details.
   36.16 + *
   36.17 + * You should have received a copy of the GNU Lesser General Public
   36.18 + * License along with this library; if not, write to the Free Software
   36.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   36.20 + */
   36.21 +
   36.22 +#ifndef XEN_VIF_H
   36.23 +#define XEN_VIF_H
   36.24 +
   36.25 +#include "xen_common.h"
   36.26 +#include "xen_driver_type.h"
   36.27 +#include "xen_network_decl.h"
   36.28 +#include "xen_vif_decl.h"
   36.29 +#include "xen_vm_decl.h"
   36.30 +
   36.31 +
   36.32 +/*
   36.33 + * The VIF class. 
   36.34 + *  
   36.35 + * A virtual network interface.
   36.36 + */
   36.37 +
   36.38 +
   36.39 +/**
   36.40 + * Free the given xen_vif.  The given handle must have been allocated
   36.41 + * by this library.
   36.42 + */
   36.43 +extern void
   36.44 +xen_vif_free(xen_vif vif);
   36.45 +
   36.46 +
   36.47 +typedef struct xen_vif_set
   36.48 +{
   36.49 +    size_t size;
   36.50 +    xen_vif *contents[];
   36.51 +} xen_vif_set;
   36.52 +
   36.53 +/**
   36.54 + * Allocate a xen_vif_set of the given size.
   36.55 + */
   36.56 +extern xen_vif_set *
   36.57 +xen_vif_set_alloc(size_t size);
   36.58 +
   36.59 +/**
   36.60 + * Free the given xen_vif_set.  The given set must have been allocated
   36.61 + * by this library.
   36.62 + */
   36.63 +extern void
   36.64 +xen_vif_set_free(xen_vif_set *set);
   36.65 +
   36.66 +
   36.67 +typedef struct xen_vif_record
   36.68 +{
   36.69 +    xen_vif handle;
   36.70 +    char *uuid;
   36.71 +    char *name;
   36.72 +    enum xen_driver_type type;
   36.73 +    char *device;
   36.74 +    struct xen_network_record_opt *network;
   36.75 +    struct xen_vm_record_opt *vm;
   36.76 +    char *mac;
   36.77 +    uint64_t mtu;
   36.78 +    double network_read_kbs;
   36.79 +    double network_write_kbs;
   36.80 +    double io_bandwidth_incoming_kbs;
   36.81 +    double io_bandwidth_outgoing_kbs;
   36.82 +} xen_vif_record;
   36.83 +
   36.84 +/**
   36.85 + * Allocate a xen_vif_record.
   36.86 + */
   36.87 +extern xen_vif_record *
   36.88 +xen_vif_record_alloc(void);
   36.89 +
   36.90 +/**
   36.91 + * Free the given xen_vif_record, and all referenced values.  The given
   36.92 + * record must have been allocated by this library.
   36.93 + */
   36.94 +extern void
   36.95 +xen_vif_record_free(xen_vif_record *record);
   36.96 +
   36.97 +
   36.98 +typedef struct xen_vif_record_opt
   36.99 +{
  36.100 +    bool is_record;
  36.101 +    union
  36.102 +    {
  36.103 +        xen_vif handle;
  36.104 +        xen_vif_record *record;
  36.105 +    } u;
  36.106 +} xen_vif_record_opt;
  36.107 +
  36.108 +/**
  36.109 + * Allocate a xen_vif_record_opt.
  36.110 + */
  36.111 +extern xen_vif_record_opt *
  36.112 +xen_vif_record_opt_alloc(void);
  36.113 +
  36.114 +/**
  36.115 + * Free the given xen_vif_record_opt, and all referenced values.  The
  36.116 + * given record_opt must have been allocated by this library.
  36.117 + */
  36.118 +extern void
  36.119 +xen_vif_record_opt_free(xen_vif_record_opt *record_opt);
  36.120 +
  36.121 +
  36.122 +typedef struct xen_vif_record_set
  36.123 +{
  36.124 +    size_t size;
  36.125 +    xen_vif_record *contents[];
  36.126 +} xen_vif_record_set;
  36.127 +
  36.128 +/**
  36.129 + * Allocate a xen_vif_record_set of the given size.
  36.130 + */
  36.131 +extern xen_vif_record_set *
  36.132 +xen_vif_record_set_alloc(size_t size);
  36.133 +
  36.134 +/**
  36.135 + * Free the given xen_vif_record_set, and all referenced values.  The
  36.136 + * given set must have been allocated by this library.
  36.137 + */
  36.138 +extern void
  36.139 +xen_vif_record_set_free(xen_vif_record_set *set);
  36.140 +
  36.141 +
  36.142 +
  36.143 +typedef struct xen_vif_record_opt_set
  36.144 +{
  36.145 +    size_t size;
  36.146 +    xen_vif_record_opt *contents[];
  36.147 +} xen_vif_record_opt_set;
  36.148 +
  36.149 +/**
  36.150 + * Allocate a xen_vif_record_opt_set of the given size.
  36.151 + */
  36.152 +extern xen_vif_record_opt_set *
  36.153 +xen_vif_record_opt_set_alloc(size_t size);
  36.154 +
  36.155 +/**
  36.156 + * Free the given xen_vif_record_opt_set, and all referenced values. 
  36.157 + * The given set must have been allocated by this library.
  36.158 + */
  36.159 +extern void
  36.160 +xen_vif_record_opt_set_free(xen_vif_record_opt_set *set);
  36.161 +
  36.162 +
  36.163 +/**
  36.164 + * Get the current state of the given VIF.  !!!
  36.165 + */
  36.166 +extern bool
  36.167 +xen_vif_get_record(xen_session *session, xen_vif_record **result, xen_vif vif);
  36.168 +
  36.169 +
  36.170 +/**
  36.171 + * Get a reference to the object with the specified UUID.  !!!
  36.172 + */
  36.173 +extern bool
  36.174 +xen_vif_get_by_uuid(xen_session *session, xen_vif *result, char *uuid);
  36.175 +
  36.176 +
  36.177 +/**
  36.178 + * Create a new VIF instance, and return its handle.
  36.179 + */
  36.180 +extern bool
  36.181 +xen_vif_create(xen_session *session, xen_vif *result, xen_vif_record *record);
  36.182 +
  36.183 +
  36.184 +/**
  36.185 + * Get the uuid field of the given VIF.
  36.186 + */
  36.187 +extern bool
  36.188 +xen_vif_get_uuid(xen_session *session, char **result, xen_vif vif);
  36.189 +
  36.190 +
  36.191 +/**
  36.192 + * Get the name field of the given VIF.
  36.193 + */
  36.194 +extern bool
  36.195 +xen_vif_get_name(xen_session *session, char **result, xen_vif vif);
  36.196 +
  36.197 +
  36.198 +/**
  36.199 + * Get the type field of the given VIF.
  36.200 + */
  36.201 +extern bool
  36.202 +xen_vif_get_type(xen_session *session, enum xen_driver_type *result, xen_vif vif);
  36.203 +
  36.204 +
  36.205 +/**
  36.206 + * Get the device field of the given VIF.
  36.207 + */
  36.208 +extern bool
  36.209 +xen_vif_get_device(xen_session *session, char **result, xen_vif vif);
  36.210 +
  36.211 +
  36.212 +/**
  36.213 + * Get the network field of the given VIF.
  36.214 + */
  36.215 +extern bool
  36.216 +xen_vif_get_network(xen_session *session, xen_network *result, xen_vif vif);
  36.217 +
  36.218 +
  36.219 +/**
  36.220 + * Get the VM field of the given VIF.
  36.221 + */
  36.222 +extern bool
  36.223 +xen_vif_get_vm(xen_session *session, xen_vm *result, xen_vif vif);
  36.224 +
  36.225 +
  36.226 +/**
  36.227 + * Get the MAC field of the given VIF.
  36.228 + */
  36.229 +extern bool
  36.230 +xen_vif_get_mac(xen_session *session, char **result, xen_vif vif);
  36.231 +
  36.232 +
  36.233 +/**
  36.234 + * Get the MTU field of the given VIF.
  36.235 + */
  36.236 +extern bool
  36.237 +xen_vif_get_mtu(xen_session *session, uint64_t *result, xen_vif vif);
  36.238 +
  36.239 +
  36.240 +/**
  36.241 + * Get the network_read_kbs field of the given VIF.
  36.242 + */
  36.243 +extern bool
  36.244 +xen_vif_get_network_read_kbs(xen_session *session, double *result, xen_vif vif);
  36.245 +
  36.246 +
  36.247 +/**
  36.248 + * Get the network_write_kbs field of the given VIF.
  36.249 + */
  36.250 +extern bool
  36.251 +xen_vif_get_network_write_kbs(xen_session *session, double *result, xen_vif vif);
  36.252 +
  36.253 +
  36.254 +/**
  36.255 + * Get the IO_bandwidth/incoming_kbs field of the given VIF.
  36.256 + */
  36.257 +extern bool
  36.258 +xen_vif_get_io_bandwidth_incoming_kbs(xen_session *session, double *result, xen_vif vif);
  36.259 +
  36.260 +
  36.261 +/**
  36.262 + * Get the IO_bandwidth/outgoing_kbs field of the given VIF.
  36.263 + */
  36.264 +extern bool
  36.265 +xen_vif_get_io_bandwidth_outgoing_kbs(xen_session *session, double *result, xen_vif vif);
  36.266 +
  36.267 +
  36.268 +/**
  36.269 + * Set the name field of the given VIF.
  36.270 + */
  36.271 +extern bool
  36.272 +xen_vif_set_name(xen_session *session, xen_vif xen_vif, char *name);
  36.273 +
  36.274 +
  36.275 +/**
  36.276 + * Set the type field of the given VIF.
  36.277 + */
  36.278 +extern bool
  36.279 +xen_vif_set_type(xen_session *session, xen_vif xen_vif, enum xen_driver_type type);
  36.280 +
  36.281 +
  36.282 +/**
  36.283 + * Set the device field of the given VIF.
  36.284 + */
  36.285 +extern bool
  36.286 +xen_vif_set_device(xen_session *session, xen_vif xen_vif, char *device);
  36.287 +
  36.288 +
  36.289 +/**
  36.290 + * Set the network field of the given VIF.
  36.291 + */
  36.292 +extern bool
  36.293 +xen_vif_set_network(xen_session *session, xen_vif xen_vif, xen_network network);
  36.294 +
  36.295 +
  36.296 +/**
  36.297 + * Set the VM field of the given VIF.
  36.298 + */
  36.299 +extern bool
  36.300 +xen_vif_set_vm(xen_session *session, xen_vif xen_vif, xen_vm vm);
  36.301 +
  36.302 +
  36.303 +/**
  36.304 + * Set the MAC field of the given VIF.
  36.305 + */
  36.306 +extern bool
  36.307 +xen_vif_set_mac(xen_session *session, xen_vif xen_vif, char *mac);
  36.308 +
  36.309 +
  36.310 +/**
  36.311 + * Set the MTU field of the given VIF.
  36.312 + */
  36.313 +extern bool
  36.314 +xen_vif_set_mtu(xen_session *session, xen_vif xen_vif, uint64_t mtu);
  36.315 +
  36.316 +
  36.317 +#endif
    37.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    37.2 +++ b/tools/libxen/include/xen_vif_decl.h	Sat Oct 07 18:22:09 2006 +0100
    37.3 @@ -0,0 +1,30 @@
    37.4 +/*
    37.5 + * Copyright (c) 2006, XenSource Inc.
    37.6 + *
    37.7 + * This library is free software; you can redistribute it and/or
    37.8 + * modify it under the terms of the GNU Lesser General Public
    37.9 + * License as published by the Free Software Foundation; either
   37.10 + * version 2.1 of the License, or (at your option) any later version.
   37.11 + *
   37.12 + * This library is distributed in the hope that it will be useful,
   37.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   37.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   37.15 + * Lesser General Public License for more details.
   37.16 + *
   37.17 + * You should have received a copy of the GNU Lesser General Public
   37.18 + * License along with this library; if not, write to the Free Software
   37.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   37.20 + */
   37.21 +
   37.22 +#ifndef XEN_VIF_DECL_H
   37.23 +#define XEN_VIF_DECL_H
   37.24 +
   37.25 +typedef void *xen_vif;
   37.26 +
   37.27 +struct xen_vif_set;
   37.28 +struct xen_vif_record;
   37.29 +struct xen_vif_record_set;
   37.30 +struct xen_vif_record_opt;
   37.31 +struct xen_vif_record_opt_set;
   37.32 +
   37.33 +#endif
    38.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    38.2 +++ b/tools/libxen/include/xen_vm.h	Sat Oct 07 18:22:09 2006 +0100
    38.3 @@ -0,0 +1,809 @@
    38.4 +/*
    38.5 + * Copyright (c) 2006, XenSource Inc.
    38.6 + *
    38.7 + * This library is free software; you can redistribute it and/or
    38.8 + * modify it under the terms of the GNU Lesser General Public
    38.9 + * License as published by the Free Software Foundation; either
   38.10 + * version 2.1 of the License, or (at your option) any later version.
   38.11 + *
   38.12 + * This library is distributed in the hope that it will be useful,
   38.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   38.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   38.15 + * Lesser General Public License for more details.
   38.16 + *
   38.17 + * You should have received a copy of the GNU Lesser General Public
   38.18 + * License along with this library; if not, write to the Free Software
   38.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   38.20 + */
   38.21 +
   38.22 +#ifndef XEN_VM_H
   38.23 +#define XEN_VM_H
   38.24 +
   38.25 +#include "xen_boot_type.h"
   38.26 +#include "xen_common.h"
   38.27 +#include "xen_cpu_feature.h"
   38.28 +#include "xen_host_decl.h"
   38.29 +#include "xen_int_float_map.h"
   38.30 +#include "xen_on_crash_behaviour.h"
   38.31 +#include "xen_on_normal_exit.h"
   38.32 +#include "xen_string_string_map.h"
   38.33 +#include "xen_vbd_decl.h"
   38.34 +#include "xen_vif_decl.h"
   38.35 +#include "xen_vm_decl.h"
   38.36 +#include "xen_vm_power_state.h"
   38.37 +
   38.38 +
   38.39 +/*
   38.40 + * The VM class. 
   38.41 + *  
   38.42 + * A virtual machine (or 'guest').
   38.43 + */
   38.44 +
   38.45 +
   38.46 +/**
   38.47 + * Free the given xen_vm.  The given handle must have been allocated by
   38.48 + * this library.
   38.49 + */
   38.50 +extern void
   38.51 +xen_vm_free(xen_vm vm);
   38.52 +
   38.53 +
   38.54 +typedef struct xen_vm_set
   38.55 +{
   38.56 +    size_t size;
   38.57 +    xen_vm *contents[];
   38.58 +} xen_vm_set;
   38.59 +
   38.60 +/**
   38.61 + * Allocate a xen_vm_set of the given size.
   38.62 + */
   38.63 +extern xen_vm_set *
   38.64 +xen_vm_set_alloc(size_t size);
   38.65 +
   38.66 +/**
   38.67 + * Free the given xen_vm_set.  The given set must have been allocated
   38.68 + * by this library.
   38.69 + */
   38.70 +extern void
   38.71 +xen_vm_set_free(xen_vm_set *set);
   38.72 +
   38.73 +
   38.74 +typedef struct xen_vm_record
   38.75 +{
   38.76 +    xen_vm handle;
   38.77 +    char *uuid;
   38.78 +    enum xen_vm_power_state power_state;
   38.79 +    char *name_label;
   38.80 +    char *name_description;
   38.81 +    uint64_t user_version;
   38.82 +    bool is_a_template;
   38.83 +    struct xen_host_record_opt *resident_on;
   38.84 +    uint64_t memory_static_max;
   38.85 +    uint64_t memory_dynamic_max;
   38.86 +    uint64_t memory_actual;
   38.87 +    uint64_t memory_dynamic_min;
   38.88 +    uint64_t memory_static_min;
   38.89 +    char *vcpus_policy;
   38.90 +    char *vcpus_params;
   38.91 +    uint64_t vcpus_number;
   38.92 +    xen_int_float_map *vcpus_utilisation;
   38.93 +    struct xen_cpu_feature_set *vcpus_features_required;
   38.94 +    struct xen_cpu_feature_set *vcpus_features_can_use;
   38.95 +    struct xen_cpu_feature_set *vcpus_features_force_on;
   38.96 +    struct xen_cpu_feature_set *vcpus_features_force_off;
   38.97 +    enum xen_on_normal_exit actions_after_shutdown;
   38.98 +    enum xen_on_normal_exit actions_after_reboot;
   38.99 +    enum xen_on_normal_exit actions_after_suspend;
  38.100 +    enum xen_on_crash_behaviour actions_after_crash;
  38.101 +    struct xen_vif_record_opt_set *vifs;
  38.102 +    struct xen_vbd_record_opt_set *vbds;
  38.103 +    uint64_t tpm_instance;
  38.104 +    uint64_t tpm_backend;
  38.105 +    char *bios_boot;
  38.106 +    bool platform_std_vga;
  38.107 +    char *platform_serial;
  38.108 +    bool platform_localtime;
  38.109 +    bool platform_clock_offset;
  38.110 +    bool platform_enable_audio;
  38.111 +    char *builder;
  38.112 +    enum xen_boot_type boot_method;
  38.113 +    char *kernel_kernel;
  38.114 +    char *kernel_initrd;
  38.115 +    char *kernel_args;
  38.116 +    char *grub_cmdline;
  38.117 +    char *pci_bus;
  38.118 +    xen_string_string_map *tools_version;
  38.119 +    xen_string_string_map *otherconfig;
  38.120 +} xen_vm_record;
  38.121 +
  38.122 +/**
  38.123 + * Allocate a xen_vm_record.
  38.124 + */
  38.125 +extern xen_vm_record *
  38.126 +xen_vm_record_alloc(void);
  38.127 +
  38.128 +/**
  38.129 + * Free the given xen_vm_record, and all referenced values.  The given
  38.130 + * record must have been allocated by this library.
  38.131 + */
  38.132 +extern void
  38.133 +xen_vm_record_free(xen_vm_record *record);
  38.134 +
  38.135 +
  38.136 +typedef struct xen_vm_record_opt
  38.137 +{
  38.138 +    bool is_record;
  38.139 +    union
  38.140 +    {
  38.141 +        xen_vm handle;
  38.142 +        xen_vm_record *record;
  38.143 +    } u;
  38.144 +} xen_vm_record_opt;
  38.145 +
  38.146 +/**
  38.147 + * Allocate a xen_vm_record_opt.
  38.148 + */
  38.149 +extern xen_vm_record_opt *
  38.150 +xen_vm_record_opt_alloc(void);
  38.151 +
  38.152 +/**
  38.153 + * Free the given xen_vm_record_opt, and all referenced values.  The
  38.154 + * given record_opt must have been allocated by this library.
  38.155 + */
  38.156 +extern void
  38.157 +xen_vm_record_opt_free(xen_vm_record_opt *record_opt);
  38.158 +
  38.159 +
  38.160 +typedef struct xen_vm_record_set
  38.161 +{
  38.162 +    size_t size;
  38.163 +    xen_vm_record *contents[];
  38.164 +} xen_vm_record_set;
  38.165 +
  38.166 +/**
  38.167 + * Allocate a xen_vm_record_set of the given size.
  38.168 + */
  38.169 +extern xen_vm_record_set *
  38.170 +xen_vm_record_set_alloc(size_t size);
  38.171 +
  38.172 +/**
  38.173 + * Free the given xen_vm_record_set, and all referenced values.  The
  38.174 + * given set must have been allocated by this library.
  38.175 + */
  38.176 +extern void
  38.177 +xen_vm_record_set_free(xen_vm_record_set *set);
  38.178 +
  38.179 +
  38.180 +
  38.181 +typedef struct xen_vm_record_opt_set
  38.182 +{
  38.183 +    size_t size;
  38.184 +    xen_vm_record_opt *contents[];
  38.185 +} xen_vm_record_opt_set;
  38.186 +
  38.187 +/**
  38.188 + * Allocate a xen_vm_record_opt_set of the given size.
  38.189 + */
  38.190 +extern xen_vm_record_opt_set *
  38.191 +xen_vm_record_opt_set_alloc(size_t size);
  38.192 +
  38.193 +/**
  38.194 + * Free the given xen_vm_record_opt_set, and all referenced values. 
  38.195 + * The given set must have been allocated by this library.
  38.196 + */
  38.197 +extern void
  38.198 +xen_vm_record_opt_set_free(xen_vm_record_opt_set *set);
  38.199 +
  38.200 +
  38.201 +/**
  38.202 + * Get the current state of the given VM.  !!!
  38.203 + */
  38.204 +extern bool
  38.205 +xen_vm_get_record(xen_session *session, xen_vm_record **result, xen_vm vm);
  38.206 +
  38.207 +
  38.208 +/**
  38.209 + * Get a reference to the object with the specified UUID.  !!!
  38.210 + */
  38.211 +extern bool
  38.212 +xen_vm_get_by_uuid(xen_session *session, xen_vm *result, char *uuid);
  38.213 +
  38.214 +
  38.215 +/**
  38.216 + * Create a new VM instance, and return its handle.
  38.217 + */
  38.218 +extern bool
  38.219 +xen_vm_create(xen_session *session, xen_vm *result, xen_vm_record *record);
  38.220 +
  38.221 +
  38.222 +/**
  38.223 + * Get a reference to the object with the specified label.
  38.224 + */
  38.225 +extern bool
  38.226 +xen_vm_get_by_name_label(xen_session *session, xen_vm *result, char *label);
  38.227 +
  38.228 +
  38.229 +/**
  38.230 + * Get the uuid field of the given VM.
  38.231 + */
  38.232 +extern bool
  38.233 +xen_vm_get_uuid(xen_session *session, char **result, xen_vm vm);
  38.234 +
  38.235 +
  38.236 +/**
  38.237 + * Get the power_state field of the given VM.
  38.238 + */
  38.239 +extern bool
  38.240 +xen_vm_get_power_state(xen_session *session, enum xen_vm_power_state *result, xen_vm vm);
  38.241 +
  38.242 +
  38.243 +/**
  38.244 + * Get the name/label field of the given VM.
  38.245 + */
  38.246 +extern bool
  38.247 +xen_vm_get_name_label(xen_session *session, char **result, xen_vm vm);
  38.248 +
  38.249 +
  38.250 +/**
  38.251 + * Get the name/description field of the given VM.
  38.252 + */
  38.253 +extern bool
  38.254 +xen_vm_get_name_description(xen_session *session, char **result, xen_vm vm);
  38.255 +
  38.256 +
  38.257 +/**
  38.258 + * Get the user_version field of the given VM.
  38.259 + */
  38.260 +extern bool
  38.261 +xen_vm_get_user_version(xen_session *session, uint64_t *result, xen_vm vm);
  38.262 +
  38.263 +
  38.264 +/**
  38.265 + * Get the is_a_template field of the given VM.
  38.266 + */
  38.267 +extern bool
  38.268 +xen_vm_get_is_a_template(xen_session *session, bool *result, xen_vm vm);
  38.269 +
  38.270 +
  38.271 +/**
  38.272 + * Get the resident_on field of the given VM.
  38.273 + */
  38.274 +extern bool
  38.275 +xen_vm_get_resident_on(xen_session *session, xen_host *result, xen_vm vm);
  38.276 +
  38.277 +
  38.278 +/**
  38.279 + * Get the memory/static_max field of the given VM.
  38.280 + */
  38.281 +extern bool
  38.282 +xen_vm_get_memory_static_max(xen_session *session, uint64_t *result, xen_vm vm);
  38.283 +
  38.284 +
  38.285 +/**
  38.286 + * Get the memory/dynamic_max field of the given VM.
  38.287 + */
  38.288 +extern bool
  38.289 +xen_vm_get_memory_dynamic_max(xen_session *session, uint64_t *result, xen_vm vm);
  38.290 +
  38.291 +
  38.292 +/**
  38.293 + * Get the memory/actual field of the given VM.
  38.294 + */
  38.295 +extern bool
  38.296 +xen_vm_get_memory_actual(xen_session *session, uint64_t *result, xen_vm vm);
  38.297 +
  38.298 +
  38.299 +/**
  38.300 + * Get the memory/dynamic_min field of the given VM.
  38.301 + */
  38.302 +extern bool
  38.303 +xen_vm_get_memory_dynamic_min(xen_session *session, uint64_t *result, xen_vm vm);
  38.304 +
  38.305 +
  38.306 +/**
  38.307 + * Get the memory/static_min field of the given VM.
  38.308 + */
  38.309 +extern bool
  38.310 +xen_vm_get_memory_static_min(xen_session *session, uint64_t *result, xen_vm vm);
  38.311 +
  38.312 +
  38.313 +/**
  38.314 + * Get the VCPUs/policy field of the given VM.
  38.315 + */
  38.316 +extern bool
  38.317 +xen_vm_get_vcpus_policy(xen_session *session, char **result, xen_vm vm);
  38.318 +
  38.319 +
  38.320 +/**
  38.321 + * Get the VCPUs/params field of the given VM.
  38.322 + */
  38.323 +extern bool
  38.324 +xen_vm_get_vcpus_params(xen_session *session, char **result, xen_vm vm);
  38.325 +
  38.326 +
  38.327 +/**
  38.328 + * Get the VCPUs/number field of the given VM.
  38.329 + */
  38.330 +extern bool
  38.331 +xen_vm_get_vcpus_number(xen_session *session, uint64_t *result, xen_vm vm);
  38.332 +
  38.333 +
  38.334 +/**
  38.335 + * Get the VCPUs/utilisation field of the given VM.
  38.336 + */
  38.337 +extern bool
  38.338 +xen_vm_get_vcpus_utilisation(xen_session *session, xen_int_float_map **result, xen_vm vm);
  38.339 +
  38.340 +
  38.341 +/**
  38.342 + * Get the VCPUs/features/required field of the given VM.
  38.343 + */
  38.344 +extern bool
  38.345 +xen_vm_get_vcpus_features_required(xen_session *session, struct xen_cpu_feature_set **result, xen_vm vm);
  38.346 +
  38.347 +
  38.348 +/**
  38.349 + * Get the VCPUs/features/can_use field of the given VM.
  38.350 + */
  38.351 +extern bool
  38.352 +xen_vm_get_vcpus_features_can_use(xen_session *session, struct xen_cpu_feature_set **result, xen_vm vm);
  38.353 +
  38.354 +
  38.355 +/**
  38.356 + * Get the VCPUs/features/force_on field of the given VM.
  38.357 + */
  38.358 +extern bool
  38.359 +xen_vm_get_vcpus_features_force_on(xen_session *session, struct xen_cpu_feature_set **result, xen_vm vm);
  38.360 +
  38.361 +
  38.362 +/**
  38.363 + * Get the VCPUs/features/force_off field of the given VM.
  38.364 + */
  38.365 +extern bool
  38.366 +xen_vm_get_vcpus_features_force_off(xen_session *session, struct xen_cpu_feature_set **result, xen_vm vm);
  38.367 +
  38.368 +
  38.369 +/**
  38.370 + * Get the actions/after_shutdown field of the given VM.
  38.371 + */
  38.372 +extern bool
  38.373 +xen_vm_get_actions_after_shutdown(xen_session *session, enum xen_on_normal_exit *result, xen_vm vm);
  38.374 +
  38.375 +
  38.376 +/**
  38.377 + * Get the actions/after_reboot field of the given VM.
  38.378 + */
  38.379 +extern bool
  38.380 +xen_vm_get_actions_after_reboot(xen_session *session, enum xen_on_normal_exit *result, xen_vm vm);
  38.381 +
  38.382 +
  38.383 +/**
  38.384 + * Get the actions/after_suspend field of the given VM.
  38.385 + */
  38.386 +extern bool
  38.387 +xen_vm_get_actions_after_suspend(xen_session *session, enum xen_on_normal_exit *result, xen_vm vm);
  38.388 +
  38.389 +
  38.390 +/**
  38.391 + * Get the actions/after_crash field of the given VM.
  38.392 + */
  38.393 +extern bool
  38.394 +xen_vm_get_actions_after_crash(xen_session *session, enum xen_on_crash_behaviour *result, xen_vm vm);
  38.395 +
  38.396 +
  38.397 +/**
  38.398 + * Get the VIFs field of the given VM.
  38.399 + */
  38.400 +extern bool
  38.401 +xen_vm_get_vifs(xen_session *session, xen_vif *result, xen_vm vm);
  38.402 +
  38.403 +
  38.404 +/**
  38.405 + * Get the VBDs field of the given VM.
  38.406 + */
  38.407 +extern bool
  38.408 +xen_vm_get_vbds(xen_session *session, xen_vbd *result, xen_vm vm);
  38.409 +
  38.410 +
  38.411 +/**
  38.412 + * Get the TPM/instance field of the given VM.
  38.413 + */
  38.414 +extern bool
  38.415 +xen_vm_get_tpm_instance(xen_session *session, uint64_t *result, xen_vm vm);
  38.416 +
  38.417 +
  38.418 +/**
  38.419 + * Get the TPM/backend field of the given VM.
  38.420 + */
  38.421 +extern bool
  38.422 +xen_vm_get_tpm_backend(xen_session *session, uint64_t *result, xen_vm vm);
  38.423 +
  38.424 +
  38.425 +/**
  38.426 + * Get the bios/boot field of the given VM.
  38.427 + */
  38.428 +extern bool
  38.429 +xen_vm_get_bios_boot(xen_session *session, char **result, xen_vm vm);
  38.430 +
  38.431 +
  38.432 +/**
  38.433 + * Get the platform/std_VGA field of the given VM.
  38.434 + */
  38.435 +extern bool
  38.436 +xen_vm_get_platform_std_vga(xen_session *session, bool *result, xen_vm vm);
  38.437 +
  38.438 +
  38.439 +/**
  38.440 + * Get the platform/serial field of the given VM.
  38.441 + */
  38.442 +extern bool
  38.443 +xen_vm_get_platform_serial(xen_session *session, char **result, xen_vm vm);
  38.444 +
  38.445 +
  38.446 +/**
  38.447 + * Get the platform/localtime field of the given VM.
  38.448 + */
  38.449 +extern bool
  38.450 +xen_vm_get_platform_localtime(xen_session *session, bool *result, xen_vm vm);
  38.451 +
  38.452 +
  38.453 +/**
  38.454 + * Get the platform/clock_offset field of the given VM.
  38.455 + */
  38.456 +extern bool
  38.457 +xen_vm_get_platform_clock_offset(xen_session *session, bool *result, xen_vm vm);
  38.458 +
  38.459 +
  38.460 +/**
  38.461 + * Get the platform/enable_audio field of the given VM.
  38.462 + */
  38.463 +extern bool
  38.464 +xen_vm_get_platform_enable_audio(xen_session *session, bool *result, xen_vm vm);
  38.465 +
  38.466 +
  38.467 +/**
  38.468 + * Get the builder field of the given VM.
  38.469 + */
  38.470 +extern bool
  38.471 +xen_vm_get_builder(xen_session *session, char **result, xen_vm vm);
  38.472 +
  38.473 +
  38.474 +/**
  38.475 + * Get the boot_method field of the given VM.
  38.476 + */
  38.477 +extern bool
  38.478 +xen_vm_get_boot_method(xen_session *session, enum xen_boot_type *result, xen_vm vm);
  38.479 +
  38.480 +
  38.481 +/**
  38.482 + * Get the kernel/kernel field of the given VM.
  38.483 + */
  38.484 +extern bool
  38.485 +xen_vm_get_kernel_kernel(xen_session *session, char **result, xen_vm vm);
  38.486 +
  38.487 +
  38.488 +/**
  38.489 + * Get the kernel/initrd field of the given VM.
  38.490 + */
  38.491 +extern bool
  38.492 +xen_vm_get_kernel_initrd(xen_session *session, char **result, xen_vm vm);
  38.493 +
  38.494 +
  38.495 +/**
  38.496 + * Get the kernel/args field of the given VM.
  38.497 + */
  38.498 +extern bool
  38.499 +xen_vm_get_kernel_args(xen_session *session, char **result, xen_vm vm);
  38.500 +
  38.501 +
  38.502 +/**
  38.503 + * Get the grub/cmdline field of the given VM.
  38.504 + */
  38.505 +extern bool
  38.506 +xen_vm_get_grub_cmdline(xen_session *session, char **result, xen_vm vm);
  38.507 +
  38.508 +
  38.509 +/**
  38.510 + * Get the PCI_bus field of the given VM.
  38.511 + */
  38.512 +extern bool
  38.513 +xen_vm_get_pci_bus(xen_session *session, char **result, xen_vm vm);
  38.514 +
  38.515 +
  38.516 +/**
  38.517 + * Get the tools_version field of the given VM.
  38.518 + */
  38.519 +extern bool
  38.520 +xen_vm_get_tools_version(xen_session *session, xen_string_string_map **result, xen_vm vm);
  38.521 +
  38.522 +
  38.523 +/**
  38.524 + * Get the otherConfig field of the given VM.
  38.525 + */
  38.526 +extern bool
  38.527 +xen_vm_get_otherconfig(xen_session *session, xen_string_string_map **result, xen_vm vm);
  38.528 +
  38.529 +
  38.530 +/**
  38.531 + * Set the name/label field of the given VM.
  38.532 + */
  38.533 +extern bool
  38.534 +xen_vm_set_name_label(xen_session *session, xen_vm xen_vm, char *label);
  38.535 +
  38.536 +
  38.537 +/**
  38.538 + * Set the name/description field of the given VM.
  38.539 + */
  38.540 +extern bool
  38.541 +xen_vm_set_name_description(xen_session *session, xen_vm xen_vm, char *description);
  38.542 +
  38.543 +
  38.544 +/**
  38.545 + * Set the user_version field of the given VM.
  38.546 + */
  38.547 +extern bool
  38.548 +xen_vm_set_user_version(xen_session *session, xen_vm xen_vm, uint64_t user_version);
  38.549 +
  38.550 +
  38.551 +/**
  38.552 + * Set the is_a_template field of the given VM.
  38.553 + */
  38.554 +extern bool
  38.555 +xen_vm_set_is_a_template(xen_session *session, xen_vm xen_vm, bool is_a_template);
  38.556 +
  38.557 +
  38.558 +/**
  38.559 + * Set the memory/dynamic_max field of the given VM.
  38.560 + */
  38.561 +extern bool
  38.562 +xen_vm_set_memory_dynamic_max(xen_session *session, xen_vm xen_vm, uint64_t dynamic_max);
  38.563 +
  38.564 +
  38.565 +/**
  38.566 + * Set the memory/dynamic_min field of the given VM.
  38.567 + */
  38.568 +extern bool
  38.569 +xen_vm_set_memory_dynamic_min(xen_session *session, xen_vm xen_vm, uint64_t dynamic_min);
  38.570 +
  38.571 +
  38.572 +/**
  38.573 + * Set the VCPUs/policy field of the given VM.
  38.574 + */
  38.575 +extern bool
  38.576 +xen_vm_set_vcpus_policy(xen_session *session, xen_vm xen_vm, char *policy);
  38.577 +
  38.578 +
  38.579 +/**
  38.580 + * Set the VCPUs/params field of the given VM.
  38.581 + */
  38.582 +extern bool
  38.583 +xen_vm_set_vcpus_params(xen_session *session, xen_vm xen_vm, char *params);
  38.584 +
  38.585 +
  38.586 +/**
  38.587 + * Set the VCPUs/features/force_on field of the given VM.
  38.588 + */
  38.589 +extern bool
  38.590 +xen_vm_set_vcpus_features_force_on(xen_session *session, xen_vm xen_vm, struct xen_cpu_feature_set *force_on);
  38.591 +
  38.592 +
  38.593 +/**
  38.594 + * Set the VCPUs/features/force_off field of the given VM.
  38.595 + */
  38.596 +extern bool
  38.597 +xen_vm_set_vcpus_features_force_off(xen_session *session, xen_vm xen_vm, struct xen_cpu_feature_set *force_off);
  38.598 +
  38.599 +
  38.600 +/**
  38.601 + * Set the actions/after_shutdown field of the given VM.
  38.602 + */
  38.603 +extern bool
  38.604 +xen_vm_set_actions_after_shutdown(xen_session *session, xen_vm xen_vm, enum xen_on_normal_exit after_shutdown);
  38.605 +
  38.606 +
  38.607 +/**
  38.608 + * Set the actions/after_reboot field of the given VM.
  38.609 + */
  38.610 +extern bool
  38.611 +xen_vm_set_actions_after_reboot(xen_session *session, xen_vm xen_vm, enum xen_on_normal_exit after_reboot);
  38.612 +
  38.613 +
  38.614 +/**
  38.615 + * Set the actions/after_suspend field of the given VM.
  38.616 + */
  38.617 +extern bool
  38.618 +xen_vm_set_actions_after_suspend(xen_session *session, xen_vm xen_vm, enum xen_on_normal_exit after_suspend);
  38.619 +
  38.620 +
  38.621 +/**
  38.622 + * Set the actions/after_crash field of the given VM.
  38.623 + */
  38.624 +extern bool
  38.625 +xen_vm_set_actions_after_crash(xen_session *session, xen_vm xen_vm, enum xen_on_crash_behaviour after_crash);
  38.626 +
  38.627 +
  38.628 +/**
  38.629 + * Set the bios/boot field of the given VM.
  38.630 + */
  38.631 +extern bool
  38.632 +xen_vm_set_bios_boot(xen_session *session, xen_vm xen_vm, char *boot);
  38.633 +
  38.634 +
  38.635 +/**
  38.636 + * Set the platform/std_VGA field of the given VM.
  38.637 + */
  38.638 +extern bool
  38.639 +xen_vm_set_platform_std_vga(xen_session *session, xen_vm xen_vm, bool std_vga);
  38.640 +
  38.641 +
  38.642 +/**
  38.643 + * Set the platform/serial field of the given VM.
  38.644 + */
  38.645 +extern bool
  38.646 +xen_vm_set_platform_serial(xen_session *session, xen_vm xen_vm, char *serial);
  38.647 +
  38.648 +
  38.649 +/**
  38.650 + * Set the platform/localtime field of the given VM.
  38.651 + */
  38.652 +extern bool
  38.653 +xen_vm_set_platform_localtime(xen_session *session, xen_vm xen_vm, bool localtime);
  38.654 +
  38.655 +
  38.656 +/**
  38.657 + * Set the platform/clock_offset field of the given VM.
  38.658 + */
  38.659 +extern bool
  38.660 +xen_vm_set_platform_clock_offset(xen_session *session, xen_vm xen_vm, bool clock_offset);
  38.661 +
  38.662 +
  38.663 +/**
  38.664 + * Set the platform/enable_audio field of the given VM.
  38.665 + */
  38.666 +extern bool
  38.667 +xen_vm_set_platform_enable_audio(xen_session *session, xen_vm xen_vm, bool enable_audio);
  38.668 +
  38.669 +
  38.670 +/**
  38.671 + * Set the builder field of the given VM.
  38.672 + */
  38.673 +extern bool
  38.674 +xen_vm_set_builder(xen_session *session, xen_vm xen_vm, char *builder);
  38.675 +
  38.676 +
  38.677 +/**
  38.678 + * Set the boot_method field of the given VM.
  38.679 + */
  38.680 +extern bool
  38.681 +xen_vm_set_boot_method(xen_session *session, xen_vm xen_vm, enum xen_boot_type boot_method);
  38.682 +
  38.683 +
  38.684 +/**
  38.685 + * Set the kernel/kernel field of the given VM.
  38.686 + */
  38.687 +extern bool
  38.688 +xen_vm_set_kernel_kernel(xen_session *session, xen_vm xen_vm, char *kernel);
  38.689 +
  38.690 +
  38.691 +/**
  38.692 + * Set the kernel/initrd field of the given VM.
  38.693 + */
  38.694 +extern bool
  38.695 +xen_vm_set_kernel_initrd(xen_session *session, xen_vm xen_vm, char *initrd);
  38.696 +
  38.697 +
  38.698 +/**
  38.699 + * Set the kernel/args field of the given VM.
  38.700 + */
  38.701 +extern bool
  38.702 +xen_vm_set_kernel_args(xen_session *session, xen_vm xen_vm, char *args);
  38.703 +
  38.704 +
  38.705 +/**
  38.706 + * Set the grub/cmdline field of the given VM.
  38.707 + */
  38.708 +extern bool
  38.709 +xen_vm_set_grub_cmdline(xen_session *session, xen_vm xen_vm, char *cmdline);
  38.710 +
  38.711 +
  38.712 +/**
  38.713 + * Set the otherConfig field of the given VM.
  38.714 + */
  38.715 +extern bool
  38.716 +xen_vm_set_otherconfig(xen_session *session, xen_vm xen_vm, xen_string_string_map *otherconfig);
  38.717 +
  38.718 +
  38.719 +/**
  38.720 + * Clones the specified VM, making a new VM. Clone automatically
  38.721 + * exploits the capabilities of the underlying storage repository in which the
  38.722 + * VM's disk images are stored (e.g. Copy on Write).   This function can only
  38.723 + * be called when the VM is in the Halted State.
  38.724 + */
  38.725 +extern bool
  38.726 +xen_vm_clone(xen_session *session, xen_vm *result, xen_vm vm, char *new_name);
  38.727 +
  38.728 +
  38.729 +/**
  38.730 + * Start the specified VM.  This function can only be called with the
  38.731 + * VM is in the Halted State.
  38.732 + */
  38.733 +extern bool
  38.734 +xen_vm_start(xen_session *session, xen_vm vm, bool start_paused);
  38.735 +
  38.736 +
  38.737 +/**
  38.738 + * Pause the specified VM. This can only be called when the specified
  38.739 + * VM is in the Running state.
  38.740 + */
  38.741 +extern bool
  38.742 +xen_vm_pause(xen_session *session, xen_vm vm);
  38.743 +
  38.744 +
  38.745 +/**
  38.746 + * Resume the specified VM. This can only be called when the specified
  38.747 + * VM is in the Paused state.
  38.748 + */
  38.749 +extern bool
  38.750 +xen_vm_unpause(xen_session *session, xen_vm vm);
  38.751 +
  38.752 +
  38.753 +/**
  38.754 + * Attempt to cleanly shutdown the specified VM. (Note: this may not be
  38.755 + * supported---e.g. if a guest agent is not installed). 
  38.756 + *  
  38.757 + * Once shutdown has been completed perform poweroff action specified in guest
  38.758 + * configuration.
  38.759 + */
  38.760 +extern bool
  38.761 +xen_vm_clean_shutdown(xen_session *session, xen_vm vm);
  38.762 +
  38.763 +
  38.764 +/**
  38.765 + * Attempt to cleanly shutdown the specified VM (Note: this may not be
  38.766 + * supported---e.g. if a guest agent is not installed). 
  38.767 + *  
  38.768 + * Once shutdown has been completed perform reboot action specified in guest
  38.769 + * configuration.
  38.770 + */
  38.771 +extern bool
  38.772 +xen_vm_clean_reboot(xen_session *session, xen_vm vm);
  38.773 +
  38.774 +
  38.775 +/**
  38.776 + * Stop executing the specified VM without attempting a clean shutdown.
  38.777 + * Then perform poweroff action specified in VM configuration.
  38.778 + */
  38.779 +extern bool
  38.780 +xen_vm_hard_shutdown(xen_session *session, xen_vm vm);
  38.781 +
  38.782 +
  38.783 +/**
  38.784 + * Stop executing the specified VM without attempting a clean shutdown.
  38.785 + * Then perform reboot action specified in VM configuration
  38.786 + */
  38.787 +extern bool
  38.788 +xen_vm_hard_reboot(xen_session *session, xen_vm vm);
  38.789 +
  38.790 +
  38.791 +/**
  38.792 + * Suspend the specified VM to disk.
  38.793 + */
  38.794 +extern bool
  38.795 +xen_vm_suspend(xen_session *session, xen_vm vm);
  38.796 +
  38.797 +
  38.798 +/**
  38.799 + * Awaken the specified VM and resume it.
  38.800 + */
  38.801 +extern bool
  38.802 +xen_vm_resume(xen_session *session, xen_vm vm, bool start_paused);
  38.803 +
  38.804 +
  38.805 +/**
  38.806 + * Return a list of all the VMs known to the system.
  38.807 + */
  38.808 +extern bool
  38.809 +xen_vm_get_all(xen_session *session, xen_vm *result);
  38.810 +
  38.811 +
  38.812 +#endif
    39.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    39.2 +++ b/tools/libxen/include/xen_vm_decl.h	Sat Oct 07 18:22:09 2006 +0100
    39.3 @@ -0,0 +1,30 @@
    39.4 +/*
    39.5 + * Copyright (c) 2006, XenSource Inc.
    39.6 + *
    39.7 + * This library is free software; you can redistribute it and/or
    39.8 + * modify it under the terms of the GNU Lesser General Public
    39.9 + * License as published by the Free Software Foundation; either
   39.10 + * version 2.1 of the License, or (at your option) any later version.
   39.11 + *
   39.12 + * This library is distributed in the hope that it will be useful,
   39.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   39.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   39.15 + * Lesser General Public License for more details.
   39.16 + *
   39.17 + * You should have received a copy of the GNU Lesser General Public
   39.18 + * License along with this library; if not, write to the Free Software
   39.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   39.20 + */
   39.21 +
   39.22 +#ifndef XEN_VM_DECL_H
   39.23 +#define XEN_VM_DECL_H
   39.24 +
   39.25 +typedef void *xen_vm;
   39.26 +
   39.27 +struct xen_vm_set;
   39.28 +struct xen_vm_record;
   39.29 +struct xen_vm_record_set;
   39.30 +struct xen_vm_record_opt;
   39.31 +struct xen_vm_record_opt_set;
   39.32 +
   39.33 +#endif
    40.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    40.2 +++ b/tools/libxen/include/xen_vm_power_state.h	Sat Oct 07 18:22:09 2006 +0100
    40.3 @@ -0,0 +1,97 @@
    40.4 +/*
    40.5 + * Copyright (c) 2006, XenSource Inc.
    40.6 + *
    40.7 + * This library is free software; you can redistribute it and/or
    40.8 + * modify it under the terms of the GNU Lesser General Public
    40.9 + * License as published by the Free Software Foundation; either
   40.10 + * version 2.1 of the License, or (at your option) any later version.
   40.11 + *
   40.12 + * This library is distributed in the hope that it will be useful,
   40.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   40.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   40.15 + * Lesser General Public License for more details.
   40.16 + *
   40.17 + * You should have received a copy of the GNU Lesser General Public
   40.18 + * License along with this library; if not, write to the Free Software
   40.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   40.20 + */
   40.21 +
   40.22 +#ifndef XEN_VM_POWER_STATE_H
   40.23 +#define XEN_VM_POWER_STATE_H
   40.24 +
   40.25 +
   40.26 +#include "xen_common.h"
   40.27 +
   40.28 +
   40.29 +enum xen_vm_power_state
   40.30 +{
   40.31 +    /**
   40.32 +     * Halted
   40.33 +     */
   40.34 +    XEN_VM_POWER_STATE_HALTED,
   40.35 +
   40.36 +    /**
   40.37 +     * Paused
   40.38 +     */
   40.39 +    XEN_VM_POWER_STATE_PAUSED,
   40.40 +
   40.41 +    /**
   40.42 +     * Running
   40.43 +     */
   40.44 +    XEN_VM_POWER_STATE_RUNNING,
   40.45 +
   40.46 +    /**
   40.47 +     * Suspended
   40.48 +     */
   40.49 +    XEN_VM_POWER_STATE_SUSPENDED,
   40.50 +
   40.51 +    /**
   40.52 +     * Shutting Down
   40.53 +     */
   40.54 +    XEN_VM_POWER_STATE_SHUTTINGDOWN,
   40.55 +
   40.56 +    /**
   40.57 +     * Some other unknown state
   40.58 +     */
   40.59 +    XEN_VM_POWER_STATE_UNKNOWN
   40.60 +};
   40.61 +
   40.62 +
   40.63 +typedef struct xen_vm_power_state_set
   40.64 +{
   40.65 +    size_t size;
   40.66 +    enum xen_vm_power_state contents[];
   40.67 +} xen_vm_power_state_set;
   40.68 +
   40.69 +/**
   40.70 + * Allocate a xen_vm_power_state_set of the given size.
   40.71 + */
   40.72 +extern xen_vm_power_state_set *
   40.73 +xen_vm_power_state_set_alloc(size_t size);
   40.74 +
   40.75 +/**
   40.76 + * Free the given xen_vm_power_state_set.  The given set must have been
   40.77 + * allocated by this library.
   40.78 + */
   40.79 +extern void
   40.80 +xen_vm_power_state_set_free(xen_vm_power_state_set *set);
   40.81 +
   40.82 +
   40.83 +/**
   40.84 + * Return the name corresponding to the given code.  This string must
   40.85 + * not be modified or freed.
   40.86 + */
   40.87 +extern const char *
   40.88 +xen_vm_power_state_to_string(enum xen_vm_power_state val);
   40.89 +
   40.90 +
   40.91 +/**
   40.92 + * Return the correct code for the given string, or set the session
   40.93 + * object to failure and return an undefined value if the given string does
   40.94 + * not match a known code.
   40.95 + */
   40.96 +extern enum xen_vm_power_state
   40.97 +xen_vm_power_state_from_string(xen_session *session, const char *str);
   40.98 +
   40.99 +
  40.100 +#endif
    41.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    41.2 +++ b/tools/libxen/include/xen_vm_power_state_internal.h	Sat Oct 07 18:22:09 2006 +0100
    41.3 @@ -0,0 +1,37 @@
    41.4 +/*
    41.5 + * Copyright (c) 2006, XenSource Inc.
    41.6 + *
    41.7 + * This library is free software; you can redistribute it and/or
    41.8 + * modify it under the terms of the GNU Lesser General Public
    41.9 + * License as published by the Free Software Foundation; either
   41.10 + * version 2.1 of the License, or (at your option) any later version.
   41.11 + *
   41.12 + * This library is distributed in the hope that it will be useful,
   41.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   41.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   41.15 + * Lesser General Public License for more details.
   41.16 + *
   41.17 + * You should have received a copy of the GNU Lesser General Public
   41.18 + * License along with this library; if not, write to the Free Software
   41.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   41.20 + */
   41.21 +
   41.22 +
   41.23 +/*
   41.24 + * Declarations of the abstract types used during demarshalling of enum
   41.25 + * xen_vm_power_state.  Internal to this library -- do not use from outside.
   41.26 + */
   41.27 +
   41.28 +
   41.29 +#ifndef XEN_VM_POWER_STATE_INTERNAL_H
   41.30 +#define XEN_VM_POWER_STATE_INTERNAL_H
   41.31 +
   41.32 +
   41.33 +#include "xen_internal.h"
   41.34 +
   41.35 +
   41.36 +extern const abstract_type xen_vm_power_state_abstract_type_;
   41.37 +extern const abstract_type xen_vm_power_state_set_abstract_type_;
   41.38 +
   41.39 +
   41.40 +#endif
    42.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    42.2 +++ b/tools/libxen/src/xen_boot_type.c	Sat Oct 07 18:22:09 2006 +0100
    42.3 @@ -0,0 +1,83 @@
    42.4 +/*
    42.5 + * Copyright (c) 2006, XenSource Inc.
    42.6 + *
    42.7 + * This library is free software; you can redistribute it and/or
    42.8 + * modify it under the terms of the GNU Lesser General Public
    42.9 + * License as published by the Free Software Foundation; either
   42.10 + * version 2.1 of the License, or (at your option) any later version.
   42.11 + *
   42.12 + * This library is distributed in the hope that it will be useful,
   42.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   42.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   42.15 + * Lesser General Public License for more details.
   42.16 + *
   42.17 + * You should have received a copy of the GNU Lesser General Public
   42.18 + * License along with this library; if not, write to the Free Software
   42.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   42.20 + */
   42.21 +
   42.22 +#include <string.h>
   42.23 +
   42.24 +#include "xen_internal.h"
   42.25 +#include "xen_boot_type.h"
   42.26 +#include "xen_boot_type_internal.h"
   42.27 +
   42.28 +
   42.29 +/*
   42.30 + * Maintain this in the same order as the enum declaration!
   42.31 + */
   42.32 +static const char *lookup_table[] =
   42.33 +{
   42.34 +    "bios",
   42.35 +    "grub",
   42.36 +    "kernel_external",
   42.37 +    "kernel_internal"
   42.38 +};
   42.39 +
   42.40 +
   42.41 +extern xen_boot_type_set *
   42.42 +xen_boot_type_set_alloc(size_t size)
   42.43 +{
   42.44 +    return calloc(1, sizeof(xen_boot_type_set) +
   42.45 +                  size * sizeof(enum xen_boot_type));
   42.46 +}
   42.47 +
   42.48 +
   42.49 +extern void
   42.50 +xen_boot_type_set_free(xen_boot_type_set *set)
   42.51 +{
   42.52 +    free(set);
   42.53 +}
   42.54 +
   42.55 +
   42.56 +const char *
   42.57 +xen_boot_type_to_string(enum xen_boot_type val)
   42.58 +{
   42.59 +    return lookup_table[val];
   42.60 +}
   42.61 +
   42.62 +
   42.63 +extern enum xen_boot_type
   42.64 +xen_boot_type_from_string(xen_session *session, const char *str)
   42.65 +{
   42.66 +    return ENUM_LOOKUP(session, str, lookup_table);
   42.67 +}
   42.68 +
   42.69 +
   42.70 +const abstract_type xen_boot_type_abstract_type_ =
   42.71 +    {
   42.72 +        .typename = ENUM,
   42.73 +        .enum_marshaller =
   42.74 +             (const char *(*)(int))&xen_boot_type_to_string,
   42.75 +        .enum_demarshaller =
   42.76 +             (int (*)(xen_session *, const char *))&xen_boot_type_from_string
   42.77 +    };
   42.78 +
   42.79 +
   42.80 +const abstract_type xen_boot_type_set_abstract_type_ =
   42.81 +    {
   42.82 +        .typename = SET,
   42.83 +        .child = &xen_boot_type_abstract_type_
   42.84 +    };
   42.85 +
   42.86 +
    43.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    43.2 +++ b/tools/libxen/src/xen_common.c	Sat Oct 07 18:22:09 2006 +0100
    43.3 @@ -0,0 +1,1329 @@
    43.4 +/*
    43.5 +  Copyright (c) 2006 XenSource, Inc.
    43.6 + *
    43.7 + * This library is free software; you can redistribute it and/or
    43.8 + * modify it under the terms of the GNU Lesser General Public
    43.9 + * License as published by the Free Software Foundation; either
   43.10 + * version 2.1 of the License, or (at your option) any later version.
   43.11 + *
   43.12 + * This library is distributed in the hope that it will be useful,
   43.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   43.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   43.15 + * Lesser General Public License for more details.
   43.16 + *
   43.17 + * You should have received a copy of the GNU Lesser General Public
   43.18 + * License along with this library; if not, write to the Free Software
   43.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   43.20 +*/
   43.21 +
   43.22 +#include <assert.h>
   43.23 +#include <stdarg.h>
   43.24 +#include <stddef.h>
   43.25 +#include <stdio.h>
   43.26 +#include <stdlib.h>
   43.27 +#include <string.h>
   43.28 +
   43.29 +#include <libxml/parser.h>
   43.30 +#include <libxml/tree.h>
   43.31 +#include <libxml/xmlsave.h>
   43.32 +#include <libxml/xmlstring.h>
   43.33 +#include <libxml/xpath.h>
   43.34 +
   43.35 +#include "xen_common.h"
   43.36 +#include "xen_internal.h"
   43.37 +#include "xen_int_float_map.h"
   43.38 +#include "xen_string_string_map.h"
   43.39 +
   43.40 +
   43.41 +static xmlXPathCompExprPtr responsePath = NULL;
   43.42 +static xmlXPathCompExprPtr faultPath = NULL;
   43.43 +
   43.44 +
   43.45 +typedef struct
   43.46 +{
   43.47 +    size_t size;
   43.48 +    void *contents[];
   43.49 +} arbitrary_map;
   43.50 +
   43.51 +
   43.52 +typedef struct
   43.53 +{
   43.54 +    bool is_record;
   43.55 +    union
   43.56 +    {
   43.57 +        char *handle;
   43.58 +        void *record;
   43.59 +    } u;
   43.60 +} arbitrary_record_opt;
   43.61 +
   43.62 +
   43.63 +static char *
   43.64 +make_body(const char *, abstract_value [], int);
   43.65 +
   43.66 +static void
   43.67 +parse_result(xen_session *, const char *, const abstract_type *, void *);
   43.68 +
   43.69 +static void
   43.70 +add_value(xmlNode *, const char *, const char *);
   43.71 +static void
   43.72 +add_param(xmlNode *, const char *, const char *);
   43.73 +
   43.74 +static xmlNode *
   43.75 +add_param_struct(xmlNode *);
   43.76 +static xmlNode *
   43.77 +add_struct_array(xmlNode *, const char *);
   43.78 +static void
   43.79 +add_struct_member(xmlNode *, const char *, const char *, const char *);
   43.80 +static void
   43.81 +add_unnamed_value(xmlNode *, const char *, const char *, const char *);
   43.82 +
   43.83 +static void
   43.84 +add_struct_value(const struct abstract_type *, void *,
   43.85 +                 void (*)(xmlNode *, const char *, const char *,
   43.86 +                          const char *),
   43.87 +                 const char *, xmlNode *);
   43.88 +
   43.89 +static void
   43.90 +call_raw(xen_session *, const char *, abstract_value [], int,
   43.91 +         const abstract_type *, void *);
   43.92 +
   43.93 +static void
   43.94 +parse_structmap_value(xen_session *, xmlNode *, const abstract_type *,
   43.95 +                      void *);
   43.96 +
   43.97 +static size_t size_of_member(const abstract_type *);
   43.98 +
   43.99 +
  43.100 +void
  43.101 +xen_init(void)
  43.102 +{
  43.103 +    responsePath =
  43.104 +        xmlXPathCompile(
  43.105 +            BAD_CAST(
  43.106 +                "/methodResponse/params/param/value/struct/member/value"));
  43.107 +    faultPath =
  43.108 +        xmlXPathCompile(
  43.109 +            BAD_CAST("/methodResponse/fault/value/struct/member/value"));
  43.110 +}
  43.111 +
  43.112 +
  43.113 +void
  43.114 +xen_fini(void)
  43.115 +{
  43.116 +    xmlXPathFreeCompExpr(responsePath);
  43.117 +    xmlXPathFreeCompExpr(faultPath);
  43.118 +    responsePath = NULL;
  43.119 +    faultPath = NULL;
  43.120 +}
  43.121 +
  43.122 +
  43.123 +xen_session *
  43.124 +xen_session_login_with_password(xen_call_func call_func, void *handle,
  43.125 +                                const char *uname, const char *pwd)
  43.126 +{
  43.127 +    abstract_value params[] =
  43.128 +        {
  43.129 +            { .type = &abstract_type_string,
  43.130 +              .u.string_val = uname },
  43.131 +            { .type = &abstract_type_string,
  43.132 +              .u.string_val = pwd }
  43.133 +        };
  43.134 +
  43.135 +    xen_session *session = malloc(sizeof(xen_session));
  43.136 +    session->call_func = call_func;
  43.137 +    session->handle = handle;
  43.138 +    session->session_id = NULL;
  43.139 +    session->ok = true;
  43.140 +    session->error_description = NULL;
  43.141 +    session->error_description_count = 0;
  43.142 +
  43.143 +    call_raw(session, "Session.login_with_password", params, 2,
  43.144 +             &abstract_type_string, &session->session_id);
  43.145 +
  43.146 +    return session;
  43.147 +}
  43.148 +
  43.149 +
  43.150 +void
  43.151 +xen_session_logout(xen_session *session)
  43.152 +{
  43.153 +    abstract_value params[] =
  43.154 +        {
  43.155 +        };
  43.156 +    xen_call_(session, "Session.logout", params, 0, NULL, NULL);
  43.157 +
  43.158 +    if (session->error_description != NULL)
  43.159 +    {
  43.160 +        for (int i = 0; i < session->error_description_count; i++)
  43.161 +        {
  43.162 +            free(session->error_description[i]);
  43.163 +        }
  43.164 +        free(session->error_description);
  43.165 +    }
  43.166 +
  43.167 +    free((char *)session->session_id);
  43.168 +    free(session);
  43.169 +}
  43.170 +
  43.171 +
  43.172 +int
  43.173 +xen_session_get_this_host(xen_session *session, xen_host *result)
  43.174 +{
  43.175 +    abstract_value params[] =
  43.176 +        {
  43.177 +        };
  43.178 +
  43.179 +    xen_call_(session, "Session.get_this_host", params, 0,
  43.180 +              &abstract_type_string, result);
  43.181 +    return session->ok;
  43.182 +}
  43.183 +
  43.184 +
  43.185 +#define X "%02x"
  43.186 +#define UUID_FORMAT X X X X "-" X X "-" X X "-" X X "-" X X X X X X
  43.187 +
  43.188 +
  43.189 +bool
  43.190 +xen_uuid_string_to_bytes(char *uuid, char **bytes)
  43.191 +{
  43.192 +    unsigned int buf[16];
  43.193 +
  43.194 +    *bytes = NULL;
  43.195 +    
  43.196 +    if (strlen(uuid) != 36)
  43.197 +        return false;
  43.198 +
  43.199 +    if (16 != sscanf(uuid, UUID_FORMAT,
  43.200 +                     buf + 0, buf + 1, buf + 2, buf + 3,
  43.201 +                     buf + 4, buf + 5,
  43.202 +                     buf + 6, buf + 7,
  43.203 +                     buf + 8, buf + 9,
  43.204 +                     buf + 10, buf + 11, buf + 12, buf + 13, buf + 14,
  43.205 +                       buf + 15))
  43.206 +    {
  43.207 +        return false;
  43.208 +    }
  43.209 +
  43.210 +    *bytes = malloc(16);
  43.211 +    if (*bytes == NULL)
  43.212 +        return false;
  43.213 +
  43.214 +    for (int i = 0; i < 16; i++) {
  43.215 +        (*bytes)[i] = (char)buf[i];
  43.216 +    }
  43.217 +
  43.218 +    return true;
  43.219 +}
  43.220 +
  43.221 +
  43.222 +bool
  43.223 +xen_uuid_bytes_to_string(char *bytes, char **uuid)
  43.224 +{
  43.225 +    *uuid = malloc(37);
  43.226 +    if (*uuid == NULL)
  43.227 +        return false;
  43.228 +
  43.229 +    sprintf(*uuid, UUID_FORMAT,
  43.230 +            bytes[0], bytes[1], bytes[2], bytes[3],
  43.231 +            bytes[4], bytes[5],
  43.232 +            bytes[6], bytes[7],
  43.233 +            bytes[8], bytes[9],
  43.234 +            bytes[10], bytes[11], bytes[12], bytes[13], bytes[14], bytes[15]);
  43.235 +
  43.236 +    return true;
  43.237 +}
  43.238 +
  43.239 +
  43.240 +#undef UUID_FORMAT
  43.241 +#undef X
  43.242 +
  43.243 +
  43.244 +void
  43.245 +xen_uuid_free(char *uuid)
  43.246 +{
  43.247 +    free(uuid);
  43.248 +}
  43.249 +
  43.250 +
  43.251 +void
  43.252 +xen_uuid_bytes_free(char *bytes)
  43.253 +{
  43.254 +    free(bytes);
  43.255 +}
  43.256 +
  43.257 +
  43.258 +/**
  43.259 + * @param value A pointer to the correct location as per the given
  43.260 + * result_type.  Will be populated if the call succeeds.  In that case, and if
  43.261 + * value is a char **, the char * itself must be freed by the caller.
  43.262 + */
  43.263 +void
  43.264 +xen_call_(xen_session *s, const char *method_name,
  43.265 +          abstract_value params[], int param_count,
  43.266 +          const abstract_type *result_type, void *value)
  43.267 +{
  43.268 +    if (!s->ok)
  43.269 +    {
  43.270 +        return;
  43.271 +    }
  43.272 +
  43.273 +    abstract_value *full_params =
  43.274 +        malloc(sizeof(abstract_value) * (param_count + 1));
  43.275 +
  43.276 +    full_params[0].type = &abstract_type_string;
  43.277 +    full_params[0].u.string_val = s->session_id;
  43.278 +
  43.279 +    memcpy(full_params + 1, params, param_count * sizeof(abstract_value));
  43.280 +
  43.281 +    call_raw(s, method_name, full_params, param_count + 1, result_type,
  43.282 +             value);
  43.283 +
  43.284 +    free(full_params);
  43.285 +}
  43.286 +
  43.287 +
  43.288 +static bool
  43.289 +bufferAdd(const void *data, size_t len, void *buffer)
  43.290 +{
  43.291 +    return 0 == xmlBufferAdd((xmlBufferPtr)buffer, data, len);
  43.292 +}
  43.293 +
  43.294 +
  43.295 +static void
  43.296 +call_raw(xen_session *s, const char *method_name,
  43.297 +         abstract_value params[], int param_count,
  43.298 +         const abstract_type *result_type, void *value)
  43.299 +{
  43.300 +    xmlBufferPtr buffer = xmlBufferCreate();
  43.301 +    char *body = make_body(method_name, params, param_count);
  43.302 +    int error_code =
  43.303 +        s->call_func(body, strlen(body), s->handle, buffer, &bufferAdd);
  43.304 +    free(body);
  43.305 +    if (error_code)
  43.306 +    {
  43.307 +        char **strings = malloc(2 * sizeof(char *));
  43.308 +
  43.309 +        strings[0] = xen_strdup_("TRANSPORT_FAULT");
  43.310 +        strings[1] = malloc(20);
  43.311 +        snprintf(strings[1], 20, "%d", error_code);
  43.312 +
  43.313 +        s->ok = false;
  43.314 +        s->error_description = strings;
  43.315 +        s->error_description_count = 2;
  43.316 +    }
  43.317 +    else
  43.318 +    {
  43.319 +        parse_result(s, (char *)xmlBufferContent(buffer), result_type, value);
  43.320 +    }
  43.321 +    xmlBufferFree(buffer);
  43.322 +}
  43.323 +
  43.324 +
  43.325 +static void server_error(xen_session *session, const char *error_string)
  43.326 +{
  43.327 +    if (!session->ok)
  43.328 +    {
  43.329 +        /* Don't wipe out the earlier error message with this one. */
  43.330 +        return;
  43.331 +    }
  43.332 +
  43.333 +    char **strings = malloc(2 * sizeof(char *));
  43.334 +
  43.335 +    strings[0] = xen_strdup_("SERVER_FAULT");
  43.336 +    strings[1] = xen_strdup_(error_string);
  43.337 +
  43.338 +    session->ok = false;
  43.339 +    session->error_description = strings;
  43.340 +    session->error_description_count = 2;
  43.341 +}
  43.342 +
  43.343 +
  43.344 +static void server_error_2(xen_session *session, const char *error_string,
  43.345 +                           const char *param)
  43.346 +{
  43.347 +    if (!session->ok)
  43.348 +    {
  43.349 +        /* Don't wipe out the earlier error message with this one. */
  43.350 +        return;
  43.351 +    }
  43.352 +
  43.353 +    char **strings = malloc(3 * sizeof(char *));
  43.354 +
  43.355 +    strings[0] = xen_strdup_("SERVER_FAULT_2");
  43.356 +    strings[1] = xen_strdup_(error_string);
  43.357 +    strings[2] = xen_strdup_(param);
  43.358 +
  43.359 +    session->ok = false;
  43.360 +    session->error_description = strings;
  43.361 +    session->error_description_count = 3;
  43.362 +}
  43.363 +
  43.364 +
  43.365 +static bool is_container_node(xmlNode *n, char *type)
  43.366 +{
  43.367 +    return
  43.368 +        n->type == XML_ELEMENT_NODE &&
  43.369 +        0 == strcmp((char *)n->name, type) &&
  43.370 +        n->children != NULL &&
  43.371 +        n->children == n->last &&
  43.372 +        n->children->type == XML_ELEMENT_NODE;
  43.373 +}
  43.374 +
  43.375 +
  43.376 +/**
  43.377 + * @return The contents of the given value, or NULL if this is not a node with
  43.378 + * the given type.  If not NULL, the result must be freed with xmlFree().
  43.379 + */
  43.380 +static xmlChar *string_from_value(xmlNode *n, char *type)
  43.381 +{
  43.382 +    return
  43.383 +        is_container_node(n, "value") &&
  43.384 +        0 == strcmp((char *)n->children->name, type) ?
  43.385 +          (n->children->children == NULL ?
  43.386 +             xmlStrdup(BAD_CAST("")) :
  43.387 +             xmlNodeGetContent(n->children->children)) :
  43.388 +          NULL;
  43.389 +}
  43.390 +
  43.391 +
  43.392 +/**
  43.393 + * Find the name node that is a child of the given one, and return its
  43.394 + * contents, or NULL if this has no such node.  If not NULL, the result must
  43.395 + * be freed with xmlFree().
  43.396 + */
  43.397 +static xmlChar *string_from_name(xmlNode *n)
  43.398 +{
  43.399 +    xmlNode *cur = n->children;
  43.400 +
  43.401 +    while (cur != NULL)
  43.402 +    {
  43.403 +        if (0 == strcmp((char *)cur->name, "name"))
  43.404 +        {
  43.405 +            return xmlNodeGetContent(cur);
  43.406 +        }
  43.407 +        cur = cur->next;
  43.408 +    }
  43.409 +
  43.410 +    return NULL;
  43.411 +}
  43.412 +
  43.413 +
  43.414 +static int count_children(xmlNode *n, const char *name)
  43.415 +{
  43.416 +    int result = 0;
  43.417 +    xmlNode *cur = n->children;
  43.418 +
  43.419 +    while (cur != NULL)
  43.420 +    {
  43.421 +        if (0 == strcmp((char *)cur->name, name))
  43.422 +        {
  43.423 +            result++;
  43.424 +        }
  43.425 +        cur = cur->next;
  43.426 +    }
  43.427 +
  43.428 +    return result;
  43.429 +}
  43.430 +
  43.431 +
  43.432 +static void destring(xen_session *s, xmlChar *name, const abstract_type *type,
  43.433 +                     void *value)
  43.434 +{
  43.435 +    switch (type->typename)
  43.436 +    {
  43.437 +    case STRING:
  43.438 +        *((char **)value) = xen_strdup_((const char *)name);
  43.439 +        break;
  43.440 +
  43.441 +    case INT:
  43.442 +        *((uint64_t *)value) = atoll((const char *)name);
  43.443 +        break;
  43.444 +
  43.445 +    case FLOAT:
  43.446 +        *((double *)value) = atof((const char *)name);
  43.447 +        break;
  43.448 +
  43.449 +    default:
  43.450 +        server_error(s, "Invalid Map key type");
  43.451 +    }
  43.452 +}
  43.453 +
  43.454 +
  43.455 +static void parse_into(xen_session *s, xmlNode *value_node,
  43.456 +                       const abstract_type *result_type, void *value,
  43.457 +                       int slot)
  43.458 +{
  43.459 +    if (result_type == NULL)
  43.460 +    {
  43.461 +        xmlChar *string = string_from_value(value_node, "string");
  43.462 +        if (string == NULL || strcmp((char *)string, ""))
  43.463 +        {
  43.464 +            server_error(s,
  43.465 +                         "Expected Void from the server, but didn't get it");
  43.466 +        }
  43.467 +        else
  43.468 +        {
  43.469 +            free(string);
  43.470 +        }
  43.471 +
  43.472 +        return;
  43.473 +    }
  43.474 +
  43.475 +    switch (result_type->typename)
  43.476 +    {
  43.477 +    case STRING:
  43.478 +    {
  43.479 +        xmlChar *string = string_from_value(value_node, "string");
  43.480 +        if (string == NULL)
  43.481 +        {
  43.482 +            server_error(
  43.483 +                s, "Expected a String from the server, but didn't get one");
  43.484 +        }
  43.485 +        else
  43.486 +        {
  43.487 +            ((char **)value)[slot] = xen_strdup_((const char *)string);
  43.488 +            free(string);
  43.489 +        }
  43.490 +    }
  43.491 +    break;
  43.492 +
  43.493 +    case ENUM:
  43.494 +    {
  43.495 +        xmlChar *string = string_from_value(value_node, "string");
  43.496 +        if (string == NULL)
  43.497 +        {
  43.498 +            server_error(
  43.499 +                s, "Expected an Enum from the server, but didn't get one");
  43.500 +        }
  43.501 +        else
  43.502 +        {
  43.503 +            ((int *)value)[slot] =
  43.504 +                result_type->enum_demarshaller(s, (const char *)string);
  43.505 +            free(string);
  43.506 +        }
  43.507 +    }
  43.508 +    break;
  43.509 +
  43.510 +    case INT:
  43.511 +    {
  43.512 +        xmlChar *string = string_from_value(value_node, "string");
  43.513 +        if (string == NULL)
  43.514 +        {
  43.515 +            server_error(
  43.516 +                s, "Expected an Int from the server, but didn't get one");
  43.517 +        }
  43.518 +        else
  43.519 +        {
  43.520 +            ((uint64_t *)value)[slot] = (uint64_t)atoll((char *)string);
  43.521 +            free(string);
  43.522 +        }
  43.523 +    }
  43.524 +    break;
  43.525 +
  43.526 +    case FLOAT:
  43.527 +    {
  43.528 +        xmlChar *string = string_from_value(value_node, "double");
  43.529 +        if (string == NULL)
  43.530 +        {
  43.531 +            server_error(
  43.532 +                s, "Expected a Float from the server, but didn't get one");
  43.533 +        }
  43.534 +        else
  43.535 +        {
  43.536 +            ((double *)value)[slot] = atof((char *)string);
  43.537 +            free(string);
  43.538 +        }
  43.539 +    }
  43.540 +    break;
  43.541 +
  43.542 +    case BOOL:
  43.543 +    {
  43.544 +        xmlChar *string = string_from_value(value_node, "boolean");
  43.545 +        if (string == NULL)
  43.546 +        {
  43.547 +            server_error(
  43.548 +                s, "Expected a Bool from the server, but didn't get one");
  43.549 +        }
  43.550 +        else
  43.551 +        {
  43.552 +            ((bool *)value)[slot] = (0 == strcmp((char *)string, "1"));
  43.553 +            free(string);
  43.554 +        }
  43.555 +    }
  43.556 +    break;
  43.557 +
  43.558 +    case SET:
  43.559 +    {
  43.560 +        if (!is_container_node(value_node, "value") ||
  43.561 +            !is_container_node(value_node->children, "array"))
  43.562 +        {
  43.563 +            server_error(s,
  43.564 +                         "Expected Set from the server, but didn't get it");
  43.565 +        }
  43.566 +        else
  43.567 +        {
  43.568 +            xmlNode *data_node = value_node->children->children;
  43.569 +            int n = count_children(data_node, "value");
  43.570 +
  43.571 +            const abstract_type *member_type = result_type->child;
  43.572 +            size_t member_size = size_of_member(member_type);
  43.573 +
  43.574 +            arbitrary_set *set =
  43.575 +                calloc(1, sizeof(arbitrary_set) + member_size * n);
  43.576 +            set->size = n;
  43.577 +            int i = 0;
  43.578 +            xmlNode *cur = data_node->children;
  43.579 +
  43.580 +            while (cur != NULL)
  43.581 +            {
  43.582 +                if (0 == strcmp((char *)cur->name, "value"))
  43.583 +                {
  43.584 +                    parse_into(s, cur, member_type, set->contents, i);
  43.585 +                    i++;
  43.586 +                }
  43.587 +                cur = cur->next;
  43.588 +            }
  43.589 +
  43.590 +            ((arbitrary_set **)value)[slot] = set;
  43.591 +        }
  43.592 +    }
  43.593 +    break;
  43.594 +
  43.595 +    case MAP:
  43.596 +    {
  43.597 +        if (!is_container_node(value_node, "value") ||
  43.598 +            value_node->children->type != XML_ELEMENT_NODE ||
  43.599 +            0 != strcmp((char *)value_node->children->name, "struct") ||
  43.600 +            value_node->children->children == NULL)
  43.601 +        {
  43.602 +            server_error(s,
  43.603 +                         "Expected Map from the server, but didn't get it");
  43.604 +        }
  43.605 +        else
  43.606 +        {
  43.607 +            xmlNode *struct_node = value_node->children;
  43.608 +            int n = count_children(struct_node, "member");
  43.609 +
  43.610 +            size_t struct_size = result_type->struct_size;
  43.611 +
  43.612 +            const struct struct_member *key_member = result_type->members;
  43.613 +            const struct struct_member *val_member = result_type->members + 1;
  43.614 +
  43.615 +            arbitrary_map *map =
  43.616 +                calloc(1, sizeof(arbitrary_map) + struct_size * n);
  43.617 +            map->size = n;
  43.618 +            int i = 0;
  43.619 +            xmlNode *cur = struct_node->children;
  43.620 +
  43.621 +            while (cur != NULL)
  43.622 +            {
  43.623 +                if (0 == strcmp((char *)cur->name, "member"))
  43.624 +                {
  43.625 +                    if (cur->children == NULL || cur->last == cur->children)
  43.626 +                    {
  43.627 +                        server_error(s, "Malformed Map");
  43.628 +                        free(map);
  43.629 +                        return;
  43.630 +                    }
  43.631 +
  43.632 +                    xmlChar *name = string_from_name(cur);
  43.633 +                    if (name == NULL)
  43.634 +                    {
  43.635 +                        server_error(s, "Malformed Map");
  43.636 +                        free(map);
  43.637 +                        return;
  43.638 +                    }
  43.639 +
  43.640 +                    destring(s, name, key_member->type,
  43.641 +                             ((void *)(map + 1)) +
  43.642 +                             (i * struct_size) +
  43.643 +                             key_member->offset);
  43.644 +                    xmlFree(name);
  43.645 +                    if (!s->ok)
  43.646 +                    {
  43.647 +                        free(map);
  43.648 +                        return;
  43.649 +                    }
  43.650 +
  43.651 +                    parse_structmap_value(s, cur, val_member->type,
  43.652 +                                          ((void *)(map + 1)) +
  43.653 +                                          (i * struct_size) +
  43.654 +                                          val_member->offset);
  43.655 +                    if (!s->ok)
  43.656 +                    {
  43.657 +                        free(map);
  43.658 +                        return;
  43.659 +                    }
  43.660 +                    i++;
  43.661 +                }
  43.662 +                cur = cur->next;
  43.663 +            }
  43.664 +
  43.665 +            ((arbitrary_map **)value)[slot] = map;
  43.666 +        }
  43.667 +    }
  43.668 +    break;
  43.669 +
  43.670 +    case STRUCT:
  43.671 +    {
  43.672 +        if (!is_container_node(value_node, "value") ||
  43.673 +            value_node->children->type != XML_ELEMENT_NODE ||
  43.674 +            0 != strcmp((char *)value_node->children->name, "struct") ||
  43.675 +            value_node->children->children == NULL)
  43.676 +        {
  43.677 +            server_error(s,
  43.678 +                         "Expected Map from the server, but didn't get it");
  43.679 +        }
  43.680 +        else
  43.681 +        {
  43.682 +            xmlNode *struct_node = value_node->children;
  43.683 +
  43.684 +            void *result = calloc(1, result_type->struct_size);
  43.685 +            xmlNode *cur = struct_node->children;
  43.686 +
  43.687 +            size_t member_count = result_type->member_count;
  43.688 +
  43.689 +            const struct_member **checklist =
  43.690 +                malloc(sizeof(const struct_member *) * member_count);
  43.691 +            int seen_count = 0;
  43.692 +
  43.693 +            while (cur != NULL)
  43.694 +            {
  43.695 +                if (0 == strcmp((char *)cur->name, "member"))
  43.696 +                {
  43.697 +                    if (cur->children == NULL || cur->last == cur->children)
  43.698 +                    {
  43.699 +                        server_error(s, "Malformed Struct");
  43.700 +                        free(result);
  43.701 +                        free(checklist);
  43.702 +                        return;
  43.703 +                    }
  43.704 +
  43.705 +                    xmlChar *name = string_from_name(cur);
  43.706 +                    if (name == NULL)
  43.707 +                    {
  43.708 +                        server_error(s, "Malformed Struct");
  43.709 +                        free(result);
  43.710 +                        free(checklist);
  43.711 +                        return;
  43.712 +                    }
  43.713 +
  43.714 +                    for (size_t i = 0; i < member_count; i++)
  43.715 +                    {
  43.716 +                        const struct_member *mem = result_type->members + i;
  43.717 +
  43.718 +                        if (0 == strcmp((char *)name, mem->key))
  43.719 +                        {
  43.720 +                            parse_structmap_value(s, cur, mem->type,
  43.721 +                                                  result + mem->offset);
  43.722 +                            checklist[seen_count] = mem;
  43.723 +                            seen_count++;
  43.724 +                            break;
  43.725 +                        }
  43.726 +                    }
  43.727 +
  43.728 +                    /* Note that we're skipping unknown fields implicitly.
  43.729 +                       This means that we'll be forward compatible with
  43.730 +                       new servers. */
  43.731 +
  43.732 +                    xmlFree(name);
  43.733 +
  43.734 +                    if (!s->ok)
  43.735 +                    {
  43.736 +                        free(result);
  43.737 +                        free(checklist);
  43.738 +                        return;
  43.739 +                    }
  43.740 +                }
  43.741 +                cur = cur->next;
  43.742 +            }
  43.743 +
  43.744 +            /* Check that we've filled all fields. */
  43.745 +            for (size_t i = 0; i < member_count; i++)
  43.746 +            {
  43.747 +                const struct_member *mem = result_type->members + i;
  43.748 +                int j;
  43.749 +
  43.750 +                for (j = 0; j < seen_count; j++)
  43.751 +                {
  43.752 +                    if (checklist[j] == mem)
  43.753 +                    {
  43.754 +                        break;
  43.755 +                    }
  43.756 +                }
  43.757 +
  43.758 +                if (j == seen_count)
  43.759 +                {
  43.760 +                    server_error_2(s,
  43.761 +                                   "Struct did not contain expected field",
  43.762 +                                   mem->key);
  43.763 +                    free(result);
  43.764 +                    free(checklist);
  43.765 +                    return;
  43.766 +                }
  43.767 +            }
  43.768 +
  43.769 +            free(checklist);
  43.770 +            ((void **)value)[slot] = result;
  43.771 +        }
  43.772 +    }
  43.773 +    break;
  43.774 +
  43.775 +    case REF:
  43.776 +    {
  43.777 +        arbitrary_record_opt *record_opt =
  43.778 +            calloc(1, sizeof(arbitrary_record_opt));
  43.779 +
  43.780 +        record_opt->is_record = false;
  43.781 +        parse_into(s, value_node, &abstract_type_string,
  43.782 +                   &(record_opt->u.handle), 0);
  43.783 +
  43.784 +        ((arbitrary_record_opt **)value)[slot] = record_opt;
  43.785 +    }
  43.786 +    break;
  43.787 +
  43.788 +    default:
  43.789 +        assert(false);
  43.790 +    }
  43.791 +}
  43.792 +
  43.793 +
  43.794 +static size_t size_of_member(const abstract_type *type)
  43.795 +{
  43.796 +    switch (type->typename)
  43.797 +    {
  43.798 +    case STRING:
  43.799 +        return sizeof(char *);
  43.800 +
  43.801 +/*
  43.802 +    case INT:
  43.803 +        return sizeof(uint64_t);
  43.804 +
  43.805 +    case FLOAT:
  43.806 +        return sizeof(double);
  43.807 +
  43.808 +    case BOOL:
  43.809 +        return sizeof(bool);
  43.810 +*/
  43.811 +    case ENUM:
  43.812 +        return sizeof(int);
  43.813 +
  43.814 +    case REF:
  43.815 +        return sizeof(arbitrary_record_opt);
  43.816 +
  43.817 +    default:
  43.818 +        assert(false);
  43.819 +    }
  43.820 +}
  43.821 +
  43.822 +
  43.823 +static void parse_structmap_value(xen_session *s, xmlNode *n,
  43.824 +                                  const abstract_type *type, void *value)
  43.825 +{
  43.826 +    xmlNode *cur = n->children;
  43.827 +
  43.828 +    while (cur != NULL)
  43.829 +    {
  43.830 +        if (0 == strcmp((char *)cur->name, "value"))
  43.831 +        {
  43.832 +            parse_into(s, cur, type, value, 0);
  43.833 +            return;
  43.834 +        }
  43.835 +        cur = cur->next;
  43.836 +    }
  43.837 +
  43.838 +    server_error(s, "Missing value in Map/Struct");
  43.839 +}
  43.840 +
  43.841 +
  43.842 +static void parse_fault(xen_session *session, xmlXPathContextPtr xpathCtx)
  43.843 +{
  43.844 +    xmlXPathObjectPtr xpathObj = xmlXPathCompiledEval(faultPath, xpathCtx);
  43.845 +    if (xpathObj == NULL)
  43.846 +    {
  43.847 +        server_error(session, "Method response is neither result nor fault");
  43.848 +        return;
  43.849 +    }
  43.850 +
  43.851 +    if (xpathObj->type != XPATH_NODESET ||
  43.852 +        xpathObj->nodesetval->nodeNr != 2)
  43.853 +    {
  43.854 +        xmlXPathFreeObject(xpathObj);
  43.855 +        server_error(session, "Method response is neither result nor fault");
  43.856 +        return;
  43.857 +    }
  43.858 +
  43.859 +    xmlNode *fault_node0 = xpathObj->nodesetval->nodeTab[0];
  43.860 +    xmlNode *fault_node1 = xpathObj->nodesetval->nodeTab[1];
  43.861 +
  43.862 +    xmlChar *fault_code_str = string_from_value(fault_node0, "int");
  43.863 +    if (fault_code_str == NULL)
  43.864 +    {
  43.865 +        fault_code_str = string_from_value(fault_node0, "i4");
  43.866 +    }
  43.867 +    if (fault_code_str == NULL)
  43.868 +    {
  43.869 +        xmlXPathFreeObject(xpathObj);
  43.870 +        server_error(session, "Fault code is malformed");
  43.871 +        return;
  43.872 +    }
  43.873 +
  43.874 +    xmlChar *fault_string_str = string_from_value(fault_node1, "string");
  43.875 +    if (fault_string_str == NULL)
  43.876 +    {
  43.877 +        xmlFree(fault_code_str);
  43.878 +        xmlXPathFreeObject(xpathObj);
  43.879 +        server_error(session, "Fault string is malformed");
  43.880 +        return;
  43.881 +    }
  43.882 +
  43.883 +    char **strings = malloc(3 * sizeof(char *));
  43.884 +
  43.885 +    strings[0] = xen_strdup_("FAULT");
  43.886 +    strings[1] = xen_strdup_((char *)fault_code_str);
  43.887 +    strings[2] = xen_strdup_((char *)fault_string_str);
  43.888 +
  43.889 +    session->ok = false;
  43.890 +    session->error_description = strings;
  43.891 +    session->error_description_count = 3;
  43.892 +
  43.893 +    xmlFree(fault_code_str);
  43.894 +    xmlFree(fault_string_str);
  43.895 +    xmlXPathFreeObject(xpathObj);
  43.896 +}
  43.897 +
  43.898 +
  43.899 +static void parse_failure(xen_session *session, xmlNode *node)
  43.900 +{
  43.901 +    abstract_type error_description_type =
  43.902 +        { .typename = SET,
  43.903 +          .child = &abstract_type_string };
  43.904 +    arbitrary_set *error_descriptions;
  43.905 +
  43.906 +    parse_into(session, node, &error_description_type, &error_descriptions,
  43.907 +               0);
  43.908 +
  43.909 +    if (session->ok)
  43.910 +    {
  43.911 +        session->ok = false;
  43.912 +
  43.913 +        char **c = (char **)error_descriptions->contents;
  43.914 +        int n = error_descriptions->size;
  43.915 +
  43.916 +        char **strings = malloc(3 * sizeof(char *));
  43.917 +        for (int i = 0; i < n; i++)
  43.918 +        {
  43.919 +            strings[i] = xen_strdup_(c[i]);
  43.920 +        }
  43.921 +
  43.922 +        session->error_description_count = n;
  43.923 +        session->error_description = strings;
  43.924 +    }
  43.925 +
  43.926 +    free(error_descriptions);
  43.927 +}
  43.928 +
  43.929 +
  43.930 +/**
  43.931 + * Parameters as for xen_call_() above.
  43.932 + */
  43.933 +static void parse_result(xen_session *session, const char *result,
  43.934 +                         const abstract_type *result_type, void *value)
  43.935 +{
  43.936 +    xmlDocPtr doc =
  43.937 +        xmlReadMemory(result, strlen(result), "", NULL, XML_PARSE_NONET);
  43.938 +
  43.939 +    if (doc == NULL)
  43.940 +    {
  43.941 +        server_error(session, "Couldn't parse the server response");
  43.942 +        return;
  43.943 +    }
  43.944 +
  43.945 +    xmlXPathContextPtr xpathCtx = xmlXPathNewContext(doc);
  43.946 +    if (xpathCtx == NULL)
  43.947 +    {
  43.948 +        xmlFreeDoc(doc);
  43.949 +        server_error(session, "Couldn't create XPath context");
  43.950 +        return;
  43.951 +    }
  43.952 +
  43.953 +    xmlXPathObjectPtr xpathObj =
  43.954 +        xmlXPathCompiledEval(responsePath, xpathCtx);
  43.955 +    if (xpathObj == NULL)
  43.956 +    {
  43.957 +        parse_fault(session, xpathCtx);
  43.958 +
  43.959 +        xmlXPathFreeContext(xpathCtx); 
  43.960 +        xmlFreeDoc(doc);
  43.961 +        return;
  43.962 +    }
  43.963 +
  43.964 +    if  (xpathObj->type != XPATH_NODESET ||
  43.965 +         xpathObj->nodesetval->nodeNr != 2)
  43.966 +    {
  43.967 +        parse_fault(session, xpathCtx);
  43.968 +
  43.969 +        xmlXPathFreeObject(xpathObj);
  43.970 +        xmlXPathFreeContext(xpathCtx); 
  43.971 +        xmlFreeDoc(doc);
  43.972 +        return;
  43.973 +    }
  43.974 +
  43.975 +    xmlNode *node0 = xpathObj->nodesetval->nodeTab[0];
  43.976 +    xmlNode *node1 = xpathObj->nodesetval->nodeTab[1];
  43.977 +
  43.978 +    xmlChar *status_code = string_from_value(node0, "string");
  43.979 +    if (status_code == NULL)
  43.980 +    {
  43.981 +        xmlXPathFreeObject(xpathObj);
  43.982 +        xmlXPathFreeContext(xpathCtx); 
  43.983 +        xmlFreeDoc(doc);
  43.984 +        server_error(session, "Server response does not have a Status");
  43.985 +        return;
  43.986 +    }
  43.987 +
  43.988 +    if (strcmp((char *)status_code, "Success"))
  43.989 +    {
  43.990 +        parse_failure(session, node1);
  43.991 +
  43.992 +        xmlFree(status_code);
  43.993 +        xmlXPathFreeObject(xpathObj);
  43.994 +        xmlXPathFreeContext(xpathCtx); 
  43.995 +        xmlFreeDoc(doc); 
  43.996 +        return;
  43.997 +    }
  43.998 +
  43.999 +    parse_into(session, node1, result_type, value, 0);
 43.1000 +
 43.1001 +    xmlFree(status_code);
 43.1002 +    xmlXPathFreeObject(xpathObj);
 43.1003 +    xmlXPathFreeContext(xpathCtx);
 43.1004 +    xmlFreeDoc(doc);
 43.1005 +}
 43.1006 +
 43.1007 +
 43.1008 +static char *
 43.1009 +make_body(const char *method_name, abstract_value params[], int param_count)
 43.1010 +{
 43.1011 +    char buf[20];
 43.1012 +
 43.1013 +    xmlDocPtr doc = xmlNewDoc(BAD_CAST "1.0");
 43.1014 +    xmlNode *methodCall = xmlNewNode(NULL, BAD_CAST "methodCall");
 43.1015 +    xmlDocSetRootElement(doc, methodCall);
 43.1016 +
 43.1017 +    xmlNewChild(methodCall, NULL, BAD_CAST "methodName",
 43.1018 +                BAD_CAST method_name);
 43.1019 +
 43.1020 +    xmlNode *params_node =
 43.1021 +        xmlNewChild(methodCall, NULL, BAD_CAST "params", NULL);
 43.1022 +
 43.1023 +    for (int p = 0; p < param_count; p++)
 43.1024 +    {
 43.1025 +        abstract_value *v = params + p;
 43.1026 +        switch (v->type->typename)
 43.1027 +        {
 43.1028 +        case STRING:
 43.1029 +            add_param(params_node, "string", v->u.string_val);
 43.1030 +            break;
 43.1031 +
 43.1032 +        case INT:
 43.1033 +            snprintf(buf, sizeof(buf), "%"PRId64, v->u.int_val);
 43.1034 +            add_param(params_node, "string", buf);
 43.1035 +            break;
 43.1036 +
 43.1037 +        case FLOAT:
 43.1038 +            snprintf(buf, sizeof(buf), "%lf", v->u.double_val);
 43.1039 +            add_param(params_node, "double", buf);
 43.1040 +            break;
 43.1041 +
 43.1042 +        case BOOL:
 43.1043 +            add_param(params_node, "boolean", v->u.bool_val ? "1" : "0");
 43.1044 +            break;
 43.1045 +            
 43.1046 +        case VOID:
 43.1047 +            add_param(params_node, "string", "");
 43.1048 +            break;
 43.1049 +
 43.1050 +        case ENUM:
 43.1051 +            add_param(params_node, "string",
 43.1052 +                      v->type->enum_marshaller(v->u.enum_val));
 43.1053 +            break;
 43.1054 +
 43.1055 +        case STRUCT:
 43.1056 +        {
 43.1057 +            size_t member_count = v->type->member_count;
 43.1058 +
 43.1059 +            xmlNode *struct_node = add_param_struct(params_node);
 43.1060 +
 43.1061 +            for (size_t i = 0; i < member_count; i++)
 43.1062 +            {
 43.1063 +                const struct struct_member *mem = v->type->members + i;
 43.1064 +                const char *key = mem->key;
 43.1065 +                void *struct_value = v->u.struct_val;
 43.1066 +
 43.1067 +                add_struct_value(mem->type, struct_value + mem->offset,
 43.1068 +                                 add_struct_member, key, struct_node);
 43.1069 +            }
 43.1070 +        }
 43.1071 +        break;
 43.1072 +
 43.1073 +        default:
 43.1074 +            assert(false);
 43.1075 +        }
 43.1076 +    }
 43.1077 +
 43.1078 +    xmlBufferPtr buffer = xmlBufferCreate();
 43.1079 +    xmlSaveCtxtPtr save_ctxt =
 43.1080 +        xmlSaveToBuffer(buffer, NULL, XML_SAVE_NO_XHTML);
 43.1081 +
 43.1082 +    if (xmlSaveDoc(save_ctxt, doc) == -1)
 43.1083 +    {
 43.1084 +        return NULL;
 43.1085 +    }
 43.1086 +
 43.1087 +    xmlFreeDoc(doc);
 43.1088 +    xmlSaveClose(save_ctxt);
 43.1089 +    xmlChar *content = xmlStrdup(xmlBufferContent(buffer));
 43.1090 +    xmlBufferFree(buffer);
 43.1091 +    return (char *)content;
 43.1092 +}
 43.1093 +
 43.1094 +
 43.1095 +static void
 43.1096 +add_struct_value(const struct abstract_type *type, void *value,
 43.1097 +                 void (*adder)(xmlNode *node, const char *key,
 43.1098 +                               const char *type, const char *val),
 43.1099 +                 const char *key, xmlNode *node)
 43.1100 +{
 43.1101 +    char buf[20];
 43.1102 +
 43.1103 +    switch (type->typename)
 43.1104 +    {
 43.1105 +    case REF:
 43.1106 +    case STRING:
 43.1107 +    {
 43.1108 +        char *val = *(char **)value;
 43.1109 +        if (val != NULL)
 43.1110 +        {
 43.1111 +            adder(node, key, "string", val);
 43.1112 +        }
 43.1113 +    }
 43.1114 +    break;
 43.1115 +
 43.1116 +    case INT:
 43.1117 +    {
 43.1118 +        uint64_t val = *(uint64_t *)value;
 43.1119 +        snprintf(buf, sizeof(buf), "%"PRId64, val);
 43.1120 +        adder(node, key, "string", buf);
 43.1121 +    }
 43.1122 +    break;
 43.1123 +
 43.1124 +    case FLOAT:
 43.1125 +    {
 43.1126 +        double val = *(double *)value;
 43.1127 +        snprintf(buf, sizeof(buf), "%lf", val);
 43.1128 +        adder(node, key, "double", buf);
 43.1129 +    }
 43.1130 +    break;
 43.1131 +
 43.1132 +    case BOOL:
 43.1133 +    {
 43.1134 +        bool val = *(bool *)value;
 43.1135 +        adder(node, key, "boolean", val ? "1" : "0");
 43.1136 +    }
 43.1137 +    break;
 43.1138 +
 43.1139 +    case ENUM:
 43.1140 +    {
 43.1141 +        int val = *(int *)value;
 43.1142 +        adder(node, key, "string", type->enum_marshaller(val));
 43.1143 +    }
 43.1144 +    break;
 43.1145 +
 43.1146 +    case SET:
 43.1147 +    {
 43.1148 +        const struct abstract_type *member_type = type->child;
 43.1149 +        size_t member_size = size_of_member(member_type);
 43.1150 +        arbitrary_set *set_val = *(arbitrary_set **)value;
 43.1151 +
 43.1152 +        if (set_val != NULL)
 43.1153 +        {
 43.1154 +            xmlNode *data_node = add_struct_array(node, key);
 43.1155 +
 43.1156 +            for (size_t i = 0; i < set_val->size; i++)
 43.1157 +            {
 43.1158 +                void *member_value = set_val->contents + (i * member_size);
 43.1159 +                add_struct_value(member_type, member_value,
 43.1160 +                                 add_unnamed_value, NULL, data_node);
 43.1161 +            }
 43.1162 +        }
 43.1163 +    }
 43.1164 +    break;
 43.1165 +
 43.1166 +    case STRUCT:
 43.1167 +    case MAP:
 43.1168 +    {
 43.1169 +        /* XXX Nested structures aren't supported yet, but
 43.1170 +           fortunately we don't need them, because we don't have
 43.1171 +           any "deep create" calls.  This will need to be
 43.1172 +           fixed.  We don't need maps either. */
 43.1173 +    }
 43.1174 +    break;
 43.1175 +
 43.1176 +    default:
 43.1177 +        assert(false);
 43.1178 +    }
 43.1179 +}
 43.1180 +
 43.1181 +
 43.1182 +static xmlNode *
 43.1183 +add_container(xmlNode *parent, const char *name)
 43.1184 +{
 43.1185 +    return xmlNewChild(parent, NULL, BAD_CAST name, NULL);
 43.1186 +}
 43.1187 +
 43.1188 +
 43.1189 +static void
 43.1190 +add_param(xmlNode *params_node, const char *type, const char *value)
 43.1191 +{
 43.1192 +    xmlNode *param_node = add_container(params_node, "param");
 43.1193 +    add_value(param_node, type, value);
 43.1194 +}
 43.1195 +
 43.1196 +
 43.1197 +static void
 43.1198 +add_value(xmlNode *parent, const char *type, const char *value)
 43.1199 +{
 43.1200 +    xmlNode *value_node = add_container(parent, "value");
 43.1201 +    xmlNewChild(value_node, NULL, BAD_CAST type, BAD_CAST value);
 43.1202 +}
 43.1203 +
 43.1204 +
 43.1205 +static void
 43.1206 +add_unnamed_value(xmlNode *parent, const char *name, const char *type,
 43.1207 +                  const char *value)
 43.1208 +{
 43.1209 +    (void)name;
 43.1210 +    add_value(parent, type, value);
 43.1211 +}
 43.1212 +
 43.1213 +
 43.1214 +static xmlNode *
 43.1215 +add_param_struct(xmlNode *params_node)
 43.1216 +{
 43.1217 +    xmlNode *param_node = add_container(params_node, "param");
 43.1218 +    xmlNode *value_node = add_container(param_node,  "value");
 43.1219 +
 43.1220 +    return xmlNewChild(value_node, NULL, BAD_CAST "struct", NULL);
 43.1221 +}
 43.1222 +
 43.1223 +
 43.1224 +static void
 43.1225 +add_struct_member(xmlNode *struct_node, const char *name, const char *type,
 43.1226 +                  const char *value)
 43.1227 +{
 43.1228 +    xmlNode *member_node = add_container(struct_node, "member");
 43.1229 +
 43.1230 +    xmlNewChild(member_node, NULL, BAD_CAST "name", BAD_CAST name);
 43.1231 +
 43.1232 +    add_value(member_node, type, value);
 43.1233 +}
 43.1234 +
 43.1235 +
 43.1236 +static xmlNode *
 43.1237 +add_struct_array(xmlNode *struct_node, const char *name)
 43.1238 +{
 43.1239 +    xmlNode *member_node = add_container(struct_node, "member");
 43.1240 +
 43.1241 +    xmlNewChild(member_node, NULL, BAD_CAST "name", BAD_CAST name);
 43.1242 +
 43.1243 +    xmlNode *value_node = add_container(member_node, "value");
 43.1244 +    xmlNode *array_node = add_container(value_node,  "array");
 43.1245 +
 43.1246 +    return add_container(array_node,  "data");
 43.1247 +
 43.1248 +}
 43.1249 +
 43.1250 +
 43.1251 +int xen_enum_lookup_(xen_session *session, const char *str,
 43.1252 +                     const char **lookup_table, int n)
 43.1253 +{
 43.1254 +    if (str != NULL)
 43.1255 +    {
 43.1256 +        for (int i = 0; i < n; i++)
 43.1257 +        {
 43.1258 +            if (0 == strcmp(str, lookup_table[i]))
 43.1259 +            {
 43.1260 +                return i;
 43.1261 +            }
 43.1262 +        }
 43.1263 +    }
 43.1264 +
 43.1265 +    server_error_2(session, "Bad enum string", str);
 43.1266 +    return 0;
 43.1267 +}
 43.1268 +
 43.1269 +
 43.1270 +char *
 43.1271 +xen_strdup_(const char *in)
 43.1272 +{
 43.1273 +    char *result = malloc(strlen(in) + 1);
 43.1274 +    strcpy(result, in);
 43.1275 +    return result;
 43.1276 +}
 43.1277 +
 43.1278 +
 43.1279 +const abstract_type abstract_type_string = { .typename = STRING };
 43.1280 +const abstract_type abstract_type_int = { .typename = INT };
 43.1281 +const abstract_type abstract_type_float = { .typename = FLOAT };
 43.1282 +const abstract_type abstract_type_bool = { .typename = BOOL };
 43.1283 +const abstract_type abstract_type_datetime = { .typename = DATETIME };
 43.1284 +const abstract_type abstract_type_ref = { .typename = REF };
 43.1285 +
 43.1286 +const abstract_type abstract_type_string_set =
 43.1287 +    {
 43.1288 +        .typename = SET,
 43.1289 +        .child = &abstract_type_string
 43.1290 +    };
 43.1291 +
 43.1292 +const abstract_type abstract_type_ref_set =
 43.1293 +    {
 43.1294 +        .typename = SET,
 43.1295 +        .child = &abstract_type_ref
 43.1296 +    };
 43.1297 +
 43.1298 +static const struct struct_member string_string_members[] =
 43.1299 +{
 43.1300 +    {
 43.1301 +        .type = &abstract_type_string,
 43.1302 +        .offset = offsetof(xen_string_string_map_contents, key)
 43.1303 +    },
 43.1304 +    {
 43.1305 +        .type = &abstract_type_string,
 43.1306 +        .offset = offsetof(xen_string_string_map_contents, val)
 43.1307 +    }
 43.1308 +};
 43.1309 +const abstract_type abstract_type_string_string_map =
 43.1310 +    {
 43.1311 +        .typename = MAP,
 43.1312 +        .struct_size = sizeof(xen_string_string_map_contents),
 43.1313 +        .members = string_string_members
 43.1314 +    };
 43.1315 +
 43.1316 +static struct struct_member int_float_members[] =
 43.1317 +{
 43.1318 +    {
 43.1319 +        .type = &abstract_type_int,
 43.1320 +        .offset = offsetof(xen_int_float_map_contents, key)
 43.1321 +    },
 43.1322 +    {
 43.1323 +        .type = &abstract_type_float,
 43.1324 +        .offset = offsetof(xen_int_float_map_contents, val)
 43.1325 +    }
 43.1326 +};
 43.1327 +const abstract_type abstract_type_int_float_map =
 43.1328 +    {
 43.1329 +        .typename = MAP,
 43.1330 +        .struct_size = sizeof(xen_int_float_map_contents),
 43.1331 +        .members = int_float_members
 43.1332 +    };
    44.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    44.2 +++ b/tools/libxen/src/xen_cpu_feature.c	Sat Oct 07 18:22:09 2006 +0100
    44.3 @@ -0,0 +1,142 @@
    44.4 +/*
    44.5 + * Copyright (c) 2006, XenSource Inc.
    44.6 + *
    44.7 + * This library is free software; you can redistribute it and/or
    44.8 + * modify it under the terms of the GNU Lesser General Public
    44.9 + * License as published by the Free Software Foundation; either
   44.10 + * version 2.1 of the License, or (at your option) any later version.
   44.11 + *
   44.12 + * This library is distributed in the hope that it will be useful,
   44.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   44.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   44.15 + * Lesser General Public License for more details.
   44.16 + *
   44.17 + * You should have received a copy of the GNU Lesser General Public
   44.18 + * License along with this library; if not, write to the Free Software
   44.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   44.20 + */
   44.21 +
   44.22 +#include <string.h>
   44.23 +
   44.24 +#include "xen_internal.h"
   44.25 +#include "xen_cpu_feature.h"
   44.26 +#include "xen_cpu_feature_internal.h"
   44.27 +
   44.28 +
   44.29 +/*
   44.30 + * Maintain this in the same order as the enum declaration!
   44.31 + */
   44.32 +static const char *lookup_table[] =
   44.33 +{
   44.34 +    "FPU",
   44.35 +    "VME",
   44.36 +    "DE",
   44.37 +    "PSE",
   44.38 +    "TSC",
   44.39 +    "MSR",
   44.40 +    "PAE",
   44.41 +    "MCE",
   44.42 +    "CX8",
   44.43 +    "APIC",
   44.44 +    "SEP",
   44.45 +    "MTRR",
   44.46 +    "PGE",
   44.47 +    "MCA",
   44.48 +    "CMOV",
   44.49 +    "PAT",
   44.50 +    "PSE36",
   44.51 +    "PN",
   44.52 +    "CLFLSH",
   44.53 +    "DTES",
   44.54 +    "ACPI",
   44.55 +    "MMX",
   44.56 +    "FXSR",
   44.57 +    "XMM",
   44.58 +    "XMM2",
   44.59 +    "SELFSNOOP",
   44.60 +    "HT",
   44.61 +    "ACC",
   44.62 +    "IA64",
   44.63 +    "SYSCALL",
   44.64 +    "MP",
   44.65 +    "NX",
   44.66 +    "MMXEXT",
   44.67 +    "LM",
   44.68 +    "3DNOWEXT",
   44.69 +    "3DNOW",
   44.70 +    "RECOVERY",
   44.71 +    "LONGRUN",
   44.72 +    "LRTI",
   44.73 +    "CXMMX",
   44.74 +    "K6_MTRR",
   44.75 +    "CYRIX_ARR",
   44.76 +    "CENTAUR_MCR",
   44.77 +    "K8",
   44.78 +    "K7",
   44.79 +    "P3",
   44.80 +    "P4",
   44.81 +    "CONSTANT_TSC",
   44.82 +    "FXSAVE_LEAK",
   44.83 +    "XMM3",
   44.84 +    "MWAIT",
   44.85 +    "DSCPL",
   44.86 +    "EST",
   44.87 +    "TM2",
   44.88 +    "CID",
   44.89 +    "CX16",
   44.90 +    "XTPR",
   44.91 +    "XSTORE",
   44.92 +    "XSTORE_EN",
   44.93 +    "XCRYPT",
   44.94 +    "XCRYPT_EN",
   44.95 +    "LAHF_LM",
   44.96 +    "CMP_LEGACY"
   44.97 +};
   44.98 +
   44.99 +
  44.100 +extern xen_cpu_feature_set *
  44.101 +xen_cpu_feature_set_alloc(size_t size)
  44.102 +{
  44.103 +    return calloc(1, sizeof(xen_cpu_feature_set) +
  44.104 +                  size * sizeof(enum xen_cpu_feature));
  44.105 +}
  44.106 +
  44.107 +
  44.108 +extern void
  44.109 +xen_cpu_feature_set_free(xen_cpu_feature_set *set)
  44.110 +{
  44.111 +    free(set);
  44.112 +}
  44.113 +
  44.114 +
  44.115 +const char *
  44.116 +xen_cpu_feature_to_string(enum xen_cpu_feature val)
  44.117 +{
  44.118 +    return lookup_table[val];
  44.119 +}
  44.120 +
  44.121 +
  44.122 +extern enum xen_cpu_feature
  44.123 +xen_cpu_feature_from_string(xen_session *session, const char *str)
  44.124 +{
  44.125 +    return ENUM_LOOKUP(session, str, lookup_table);
  44.126 +}
  44.127 +
  44.128 +
  44.129 +const abstract_type xen_cpu_feature_abstract_type_ =
  44.130 +    {
  44.131 +        .typename = ENUM,
  44.132 +        .enum_marshaller =
  44.133 +             (const char *(*)(int))&xen_cpu_feature_to_string,
  44.134 +        .enum_demarshaller =
  44.135 +             (int (*)(xen_session *, const char *))&xen_cpu_feature_from_string
  44.136 +    };
  44.137 +
  44.138 +
  44.139 +const abstract_type xen_cpu_feature_set_abstract_type_ =
  44.140 +    {
  44.141 +        .typename = SET,
  44.142 +        .child = &xen_cpu_feature_abstract_type_
  44.143 +    };
  44.144 +
  44.145 +
    45.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    45.2 +++ b/tools/libxen/src/xen_driver_type.c	Sat Oct 07 18:22:09 2006 +0100
    45.3 @@ -0,0 +1,81 @@
    45.4 +/*
    45.5 + * Copyright (c) 2006, XenSource Inc.
    45.6 + *
    45.7 + * This library is free software; you can redistribute it and/or
    45.8 + * modify it under the terms of the GNU Lesser General Public
    45.9 + * License as published by the Free Software Foundation; either
   45.10 + * version 2.1 of the License, or (at your option) any later version.
   45.11 + *
   45.12 + * This library is distributed in the hope that it will be useful,
   45.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   45.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   45.15 + * Lesser General Public License for more details.
   45.16 + *
   45.17 + * You should have received a copy of the GNU Lesser General Public
   45.18 + * License along with this library; if not, write to the Free Software
   45.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   45.20 + */
   45.21 +
   45.22 +#include <string.h>
   45.23 +
   45.24 +#include "xen_internal.h"
   45.25 +#include "xen_driver_type.h"
   45.26 +#include "xen_driver_type_internal.h"
   45.27 +
   45.28 +
   45.29 +/*
   45.30 + * Maintain this in the same order as the enum declaration!
   45.31 + */
   45.32 +static const char *lookup_table[] =
   45.33 +{
   45.34 +    "ioemu",
   45.35 +    "paravirtualised"
   45.36 +};
   45.37 +
   45.38 +
   45.39 +extern xen_driver_type_set *
   45.40 +xen_driver_type_set_alloc(size_t size)
   45.41 +{
   45.42 +    return calloc(1, sizeof(xen_driver_type_set) +
   45.43 +                  size * sizeof(enum xen_driver_type));
   45.44 +}
   45.45 +
   45.46 +
   45.47 +extern void
   45.48 +xen_driver_type_set_free(xen_driver_type_set *set)
   45.49 +{
   45.50 +    free(set);
   45.51 +}
   45.52 +
   45.53 +
   45.54 +const char *
   45.55 +xen_driver_type_to_string(enum xen_driver_type val)
   45.56 +{
   45.57 +    return lookup_table[val];
   45.58 +}
   45.59 +
   45.60 +
   45.61 +extern enum xen_driver_type
   45.62 +xen_driver_type_from_string(xen_session *session, const char *str)
   45.63 +{
   45.64 +    return ENUM_LOOKUP(session, str, lookup_table);
   45.65 +}
   45.66 +
   45.67 +
   45.68 +const abstract_type xen_driver_type_abstract_type_ =
   45.69 +    {
   45.70 +        .typename = ENUM,
   45.71 +        .enum_marshaller =
   45.72 +             (const char *(*)(int))&xen_driver_type_to_string,
   45.73 +        .enum_demarshaller =
   45.74 +             (int (*)(xen_session *, const char *))&xen_driver_type_from_string
   45.75 +    };
   45.76 +
   45.77 +
   45.78 +const abstract_type xen_driver_type_set_abstract_type_ =
   45.79 +    {
   45.80 +        .typename = SET,
   45.81 +        .child = &xen_driver_type_abstract_type_
   45.82 +    };
   45.83 +
   45.84 +
    46.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    46.2 +++ b/tools/libxen/src/xen_host.c	Sat Oct 07 18:22:09 2006 +0100
    46.3 @@ -0,0 +1,350 @@
    46.4 +/*
    46.5 + * Copyright (c) 2006, XenSource Inc.
    46.6 + *
    46.7 + * This library is free software; you can redistribute it and/or
    46.8 + * modify it under the terms of the GNU Lesser General Public
    46.9 + * License as published by the Free Software Foundation; either
   46.10 + * version 2.1 of the License, or (at your option) any later version.
   46.11 + *
   46.12 + * This library is distributed in the hope that it will be useful,
   46.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   46.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   46.15 + * Lesser General Public License for more details.
   46.16 + *
   46.17 + * You should have received a copy of the GNU Lesser General Public
   46.18 + * License along with this library; if not, write to the Free Software
   46.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   46.20 + */
   46.21 +
   46.22 +
   46.23 +#include <stddef.h>
   46.24 +#include <stdlib.h>
   46.25 +
   46.26 +#include "xen_common.h"
   46.27 +#include "xen_host.h"
   46.28 +#include "xen_host_cpu.h"
   46.29 +#include "xen_internal.h"
   46.30 +#include "xen_string_string_map.h"
   46.31 +#include "xen_vm.h"
   46.32 +
   46.33 +
   46.34 +XEN_FREE(xen_host)
   46.35 +XEN_SET_ALLOC_FREE(xen_host)
   46.36 +XEN_ALLOC(xen_host_record)
   46.37 +XEN_SET_ALLOC_FREE(xen_host_record)
   46.38 +XEN_ALLOC(xen_host_record_opt)
   46.39 +XEN_RECORD_OPT_FREE(xen_host)
   46.40 +XEN_SET_ALLOC_FREE(xen_host_record_opt)
   46.41 +
   46.42 +
   46.43 +static const struct_member xen_host_record_struct_members[] =
   46.44 +    {
   46.45 +        { .key = "uuid",
   46.46 +          .type = &abstract_type_string,
   46.47 +          .offset = offsetof(xen_host_record, uuid) },
   46.48 +        { .key = "name_label",
   46.49 +          .type = &abstract_type_string,
   46.50 +          .offset = offsetof(xen_host_record, name_label) },
   46.51 +        { .key = "name_description",
   46.52 +          .type = &abstract_type_string,
   46.53 +          .offset = offsetof(xen_host_record, name_description) },
   46.54 +        { .key = "software_version",
   46.55 +          .type = &abstract_type_string_string_map,
   46.56 +          .offset = offsetof(xen_host_record, software_version) },
   46.57 +        { .key = "resident_vms",
   46.58 +          .type = &abstract_type_ref_set,
   46.59 +          .offset = offsetof(xen_host_record, resident_vms) },
   46.60 +        { .key = "host_cpus",
   46.61 +          .type = &abstract_type_ref_set,
   46.62 +          .offset = offsetof(xen_host_record, host_cpus) }
   46.63 +    };
   46.64 +
   46.65 +const abstract_type xen_host_record_abstract_type_ =
   46.66 +    {
   46.67 +       .typename = STRUCT,
   46.68 +       .struct_size = sizeof(xen_host_record),
   46.69 +       .member_count =
   46.70 +           sizeof(xen_host_record_struct_members) / sizeof(struct_member),
   46.71 +       .members = xen_host_record_struct_members
   46.72 +    };
   46.73 +
   46.74 +
   46.75 +void
   46.76 +xen_host_record_free(xen_host_record *record)
   46.77 +{
   46.78 +    free(record->handle);
   46.79 +    free(record->uuid);
   46.80 +    free(record->name_label);
   46.81 +    free(record->name_description);
   46.82 +    xen_string_string_map_free(record->software_version);
   46.83 +    xen_vm_record_opt_set_free(record->resident_vms);
   46.84 +    xen_host_cpu_record_opt_set_free(record->host_cpus);
   46.85 +    free(record);
   46.86 +}
   46.87 +
   46.88 +
   46.89 +bool
   46.90 +xen_host_get_record(xen_session *session, xen_host_record **result, xen_host host)
   46.91 +{
   46.92 +    abstract_value param_values[] =
   46.93 +        {
   46.94 +            { .type = &abstract_type_string,
   46.95 +              .u.string_val = host }
   46.96 +        };
   46.97 +
   46.98 +    abstract_type result_type = xen_host_record_abstract_type_;
   46.99 +
  46.100 +    *result = NULL;
  46.101 +    XEN_CALL_("host.get_record");
  46.102 +
  46.103 +    if (session->ok)
  46.104 +    {
  46.105 +       (*result)->handle = xen_strdup_((*result)->uuid);
  46.106 +    }
  46.107 +
  46.108 +    return session->ok;
  46.109 +}
  46.110 +
  46.111 +
  46.112 +bool
  46.113 +xen_host_get_by_uuid(xen_session *session, xen_host *result, char *uuid)
  46.114 +{
  46.115 +    abstract_value param_values[] =
  46.116 +        {
  46.117 +            { .type = &abstract_type_string,
  46.118 +              .u.string_val = uuid }
  46.119 +        };
  46.120 +
  46.121 +    abstract_type result_type = abstract_type_string;
  46.122 +
  46.123 +    *result = NULL;
  46.124 +    XEN_CALL_("host.get_by_uuid");
  46.125 +    return session->ok;
  46.126 +}
  46.127 +
  46.128 +
  46.129 +bool
  46.130 +xen_host_create(xen_session *session, xen_host *result, xen_host_record *record)
  46.131 +{
  46.132 +    abstract_value param_values[] =
  46.133 +        {
  46.134 +            { .type = &xen_host_record_abstract_type_,
  46.135 +              .u.struct_val = record }
  46.136 +        };
  46.137 +
  46.138 +    abstract_type result_type = abstract_type_string;
  46.139 +
  46.140 +    *result = NULL;
  46.141 +    XEN_CALL_("host.create");
  46.142 +    return session->ok;
  46.143 +}
  46.144 +
  46.145 +
  46.146 +bool
  46.147 +xen_host_get_by_name_label(xen_session *session, xen_host *result, char *label)
  46.148 +{
  46.149 +    abstract_value param_values[] =
  46.150 +        {
  46.151 +            { .type = &abstract_type_string,
  46.152 +              .u.string_val = label }
  46.153 +        };
  46.154 +
  46.155 +    abstract_type result_type = abstract_type_string;
  46.156 +
  46.157 +    *result = NULL;
  46.158 +    XEN_CALL_("host.get_by_name_label");
  46.159 +    return session->ok;
  46.160 +}
  46.161 +
  46.162 +
  46.163 +bool
  46.164 +xen_host_get_name_label(xen_session *session, char **result, xen_host host)
  46.165 +{
  46.166 +    abstract_value param_values[] =
  46.167 +        {
  46.168 +            { .type = &abstract_type_string,
  46.169 +              .u.string_val = host }
  46.170 +        };
  46.171 +
  46.172 +    abstract_type result_type = abstract_type_string;
  46.173 +
  46.174 +    *result = NULL;
  46.175 +    XEN_CALL_("host.get_name_label");
  46.176 +    return session->ok;
  46.177 +}
  46.178 +
  46.179 +
  46.180 +bool
  46.181 +xen_host_get_name_description(xen_session *session, char **result, xen_host host)
  46.182 +{
  46.183 +    abstract_value param_values[] =
  46.184 +        {
  46.185 +            { .type = &abstract_type_string,
  46.186 +              .u.string_val = host }
  46.187 +        };
  46.188 +
  46.189 +    abstract_type result_type = abstract_type_string;
  46.190 +
  46.191 +    *result = NULL;
  46.192 +    XEN_CALL_("host.get_name_description");
  46.193 +    return session->ok;
  46.194 +}
  46.195 +
  46.196 +
  46.197 +bool
  46.198 +xen_host_get_software_version(xen_session *session, xen_string_string_map **result, xen_host host)
  46.199 +{
  46.200 +    abstract_value param_values[] =
  46.201 +        {
  46.202 +            { .type = &abstract_type_string,
  46.203 +              .u.string_val = host }
  46.204 +        };
  46.205 +
  46.206 +    abstract_type result_type = abstract_type_string_string_map;
  46.207 +
  46.208 +    *result = NULL;
  46.209 +    XEN_CALL_("host.get_software_version");
  46.210 +    return session->ok;
  46.211 +}
  46.212 +
  46.213 +
  46.214 +bool
  46.215 +xen_host_get_resident_vms(xen_session *session, xen_vm *result, xen_host host)
  46.216 +{
  46.217 +    abstract_value param_values[] =
  46.218 +        {
  46.219 +            { .type = &abstract_type_string,
  46.220 +              .u.string_val = host }
  46.221 +        };
  46.222 +
  46.223 +    abstract_type result_type = abstract_type_string_set;
  46.224 +
  46.225 +    *result = NULL;
  46.226 +    XEN_CALL_("host.get_resident_vms");
  46.227 +    return session->ok;
  46.228 +}
  46.229 +
  46.230 +
  46.231 +bool
  46.232 +xen_host_get_host_cpus(xen_session *session, xen_host_cpu *result, xen_host host)
  46.233 +{
  46.234 +    abstract_value param_values[] =
  46.235 +        {
  46.236 +            { .type = &abstract_type_string,
  46.237 +              .u.string_val = host }
  46.238 +        };
  46.239 +
  46.240 +    abstract_type result_type = abstract_type_string_set;
  46.241 +
  46.242 +    *result = NULL;
  46.243 +    XEN_CALL_("host.get_host_cpus");
  46.244 +    return session->ok;
  46.245 +}
  46.246 +
  46.247 +
  46.248 +bool
  46.249 +xen_host_set_name_label(xen_session *session, xen_host xen_host, char *label)
  46.250 +{
  46.251 +    abstract_value param_values[] =
  46.252 +        {
  46.253 +            { .type = &abstract_type_string,
  46.254 +              .u.string_val = xen_host },
  46.255 +            { .type = &abstract_type_string,
  46.256 +              .u.string_val = label }
  46.257 +        };
  46.258 +
  46.259 +    xen_call_(session, "host.set_name_label", param_values, 2, NULL, NULL);
  46.260 +    return session->ok;
  46.261 +}
  46.262 +
  46.263 +
  46.264 +bool
  46.265 +xen_host_set_name_description(xen_session *session, xen_host xen_host, char *description)
  46.266 +{
  46.267 +    abstract_value param_values[] =
  46.268 +        {
  46.269 +            { .type = &abstract_type_string,
  46.270 +              .u.string_val = xen_host },
  46.271 +            { .type = &abstract_type_string,
  46.272 +              .u.string_val = description }
  46.273 +        };
  46.274 +
  46.275 +    xen_call_(session, "host.set_name_description", param_values, 2, NULL, NULL);
  46.276 +    return session->ok;
  46.277 +}
  46.278 +
  46.279 +
  46.280 +bool
  46.281 +xen_host_disable(xen_session *session, xen_host host)
  46.282 +{
  46.283 +    abstract_value param_values[] =
  46.284 +        {
  46.285 +            { .type = &abstract_type_string,
  46.286 +              .u.string_val = host }
  46.287 +        };
  46.288 +
  46.289 +    xen_call_(session, "host.disable", param_values, 1, NULL, NULL);
  46.290 +    return session->ok;
  46.291 +}
  46.292 +
  46.293 +
  46.294 +bool
  46.295 +xen_host_enable(xen_session *session, xen_host host)
  46.296 +{
  46.297 +    abstract_value param_values[] =
  46.298 +        {
  46.299 +            { .type = &abstract_type_string,
  46.300 +              .u.string_val = host }
  46.301 +        };
  46.302 +
  46.303 +    xen_call_(session, "host.enable", param_values, 1, NULL, NULL);
  46.304 +    return session->ok;
  46.305 +}
  46.306 +
  46.307 +
  46.308 +bool
  46.309 +xen_host_shutdown(xen_session *session, xen_host host)
  46.310 +{
  46.311 +    abstract_value param_values[] =
  46.312 +        {
  46.313 +            { .type = &abstract_type_string,
  46.314 +              .u.string_val = host }
  46.315 +        };
  46.316 +
  46.317 +    xen_call_(session, "host.shutdown", param_values, 1, NULL, NULL);
  46.318 +    return session->ok;
  46.319 +}
  46.320 +
  46.321 +
  46.322 +bool
  46.323 +xen_host_reboot(xen_session *session, xen_host host)
  46.324 +{
  46.325 +    abstract_value param_values[] =
  46.326 +        {
  46.327 +            { .type = &abstract_type_string,
  46.328 +              .u.string_val = host }
  46.329 +        };
  46.330 +
  46.331 +    xen_call_(session, "host.reboot", param_values, 1, NULL, NULL);
  46.332 +    return session->ok;
  46.333 +}
  46.334 +
  46.335 +
  46.336 +bool
  46.337 +xen_host_get_all(xen_session *session, xen_host *result)
  46.338 +{
  46.339 +
  46.340 +    abstract_type result_type = abstract_type_string_set;
  46.341 +
  46.342 +    *result = NULL;
  46.343 +    xen_call_(session, "host.get_all", NULL, 0, &result_type, result);
  46.344 +    return session->ok;
  46.345 +}
  46.346 +
  46.347 +
  46.348 +bool
  46.349 +xen_host_get_uuid(xen_session *session, char **result, xen_host host)
  46.350 +{
  46.351 +    *result = session->ok ? xen_strdup_((char *)host) : NULL;
  46.352 +    return session->ok;
  46.353 +}
    47.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    47.2 +++ b/tools/libxen/src/xen_host_cpu.c	Sat Oct 07 18:22:09 2006 +0100
    47.3 @@ -0,0 +1,208 @@
    47.4 +/*
    47.5 + * Copyright (c) 2006, XenSource Inc.
    47.6 + *
    47.7 + * This library is free software; you can redistribute it and/or
    47.8 + * modify it under the terms of the GNU Lesser General Public
    47.9 + * License as published by the Free Software Foundation; either
   47.10 + * version 2.1 of the License, or (at your option) any later version.
   47.11 + *
   47.12 + * This library is distributed in the hope that it will be useful,
   47.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   47.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   47.15 + * Lesser General Public License for more details.
   47.16 + *
   47.17 + * You should have received a copy of the GNU Lesser General Public
   47.18 + * License along with this library; if not, write to the Free Software
   47.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   47.20 + */
   47.21 +
   47.22 +
   47.23 +#include <stddef.h>
   47.24 +#include <stdlib.h>
   47.25 +
   47.26 +#include "xen_common.h"
   47.27 +#include "xen_cpu_feature.h"
   47.28 +#include "xen_cpu_feature_internal.h"
   47.29 +#include "xen_host.h"
   47.30 +#include "xen_host_cpu.h"
   47.31 +#include "xen_internal.h"
   47.32 +
   47.33 +
   47.34 +XEN_FREE(xen_host_cpu)
   47.35 +XEN_SET_ALLOC_FREE(xen_host_cpu)
   47.36 +XEN_ALLOC(xen_host_cpu_record)
   47.37 +XEN_SET_ALLOC_FREE(xen_host_cpu_record)
   47.38 +XEN_ALLOC(xen_host_cpu_record_opt)
   47.39 +XEN_RECORD_OPT_FREE(xen_host_cpu)
   47.40 +XEN_SET_ALLOC_FREE(xen_host_cpu_record_opt)
   47.41 +
   47.42 +
   47.43 +static const struct_member xen_host_cpu_record_struct_members[] =
   47.44 +    {
   47.45 +        { .key = "uuid",
   47.46 +          .type = &abstract_type_string,
   47.47 +          .offset = offsetof(xen_host_cpu_record, uuid) },
   47.48 +        { .key = "host",
   47.49 +          .type = &abstract_type_ref,
   47.50 +          .offset = offsetof(xen_host_cpu_record, host) },
   47.51 +        { .key = "number",
   47.52 +          .type = &abstract_type_int,
   47.53 +          .offset = offsetof(xen_host_cpu_record, number) },
   47.54 +        { .key = "features",
   47.55 +          .type = &xen_cpu_feature_set_abstract_type_,
   47.56 +          .offset = offsetof(xen_host_cpu_record, features) },
   47.57 +        { .key = "utilisation",
   47.58 +          .type = &abstract_type_float,
   47.59 +          .offset = offsetof(xen_host_cpu_record, utilisation) }
   47.60 +    };
   47.61 +
   47.62 +const abstract_type xen_host_cpu_record_abstract_type_ =
   47.63 +    {
   47.64 +       .typename = STRUCT,
   47.65 +       .struct_size = sizeof(xen_host_cpu_record),
   47.66 +       .member_count =
   47.67 +           sizeof(xen_host_cpu_record_struct_members) / sizeof(struct_member),
   47.68 +       .members = xen_host_cpu_record_struct_members
   47.69 +    };
   47.70 +
   47.71 +
   47.72 +void
   47.73 +xen_host_cpu_record_free(xen_host_cpu_record *record)
   47.74 +{
   47.75 +    free(record->handle);
   47.76 +    free(record->uuid);
   47.77 +    xen_host_record_opt_free(record->host);
   47.78 +    xen_cpu_feature_set_free(record->features);
   47.79 +    free(record);
   47.80 +}
   47.81 +
   47.82 +
   47.83 +bool
   47.84 +xen_host_cpu_get_record(xen_session *session, xen_host_cpu_record **result, xen_host_cpu host_cpu)
   47.85 +{
   47.86 +    abstract_value param_values[] =
   47.87 +        {
   47.88 +            { .type = &abstract_type_string,
   47.89 +              .u.string_val = host_cpu }
   47.90 +        };
   47.91 +
   47.92 +    abstract_type result_type = xen_host_cpu_record_abstract_type_;
   47.93 +
   47.94 +    *result = NULL;
   47.95 +    XEN_CALL_("host_cpu.get_record");
   47.96 +
   47.97 +    if (session->ok)
   47.98 +    {
   47.99 +       (*result)->handle = xen_strdup_((*result)->uuid);
  47.100 +    }
  47.101 +
  47.102 +    return session->ok;
  47.103 +}
  47.104 +
  47.105 +
  47.106 +bool
  47.107 +xen_host_cpu_get_by_uuid(xen_session *session, xen_host_cpu *result, char *uuid)
  47.108 +{
  47.109 +    abstract_value param_values[] =
  47.110 +        {
  47.111 +            { .type = &abstract_type_string,
  47.112 +              .u.string_val = uuid }
  47.113 +        };
  47.114 +
  47.115 +    abstract_type result_type = abstract_type_string;
  47.116 +
  47.117 +    *result = NULL;
  47.118 +    XEN_CALL_("host_cpu.get_by_uuid");
  47.119 +    return session->ok;
  47.120 +}
  47.121 +
  47.122 +
  47.123 +bool
  47.124 +xen_host_cpu_create(xen_session *session, xen_host_cpu *result, xen_host_cpu_record *record)
  47.125 +{
  47.126 +    abstract_value param_values[] =
  47.127 +        {
  47.128 +            { .type = &xen_host_cpu_record_abstract_type_,
  47.129 +              .u.struct_val = record }
  47.130 +        };
  47.131 +
  47.132 +    abstract_type result_type = abstract_type_string;
  47.133 +
  47.134 +    *result = NULL;
  47.135 +    XEN_CALL_("host_cpu.create");
  47.136 +    return session->ok;
  47.137 +}
  47.138 +
  47.139 +
  47.140 +bool
  47.141 +xen_host_cpu_get_host(xen_session *session, xen_host *result, xen_host_cpu host_cpu)
  47.142 +{
  47.143 +    abstract_value param_values[] =
  47.144 +        {
  47.145 +            { .type = &abstract_type_string,
  47.146 +              .u.string_val = host_cpu }
  47.147 +        };
  47.148 +
  47.149 +    abstract_type result_type = abstract_type_string;
  47.150 +
  47.151 +    *result = NULL;
  47.152 +    XEN_CALL_("host_cpu.get_host");
  47.153 +    return session->ok;
  47.154 +}
  47.155 +
  47.156 +
  47.157 +bool
  47.158 +xen_host_cpu_get_number(xen_session *session, uint64_t *result, xen_host_cpu host_cpu)
  47.159 +{
  47.160 +    abstract_value param_values[] =
  47.161 +        {
  47.162 +            { .type = &abstract_type_string,
  47.163 +              .u.string_val = host_cpu }
  47.164 +        };
  47.165 +
  47.166 +    abstract_type result_type = abstract_type_int;
  47.167 +
  47.168 +    XEN_CALL_("host_cpu.get_number");
  47.169 +    return session->ok;
  47.170 +}
  47.171 +
  47.172 +
  47.173 +bool
  47.174 +xen_host_cpu_get_features(xen_session *session, struct xen_cpu_feature_set **result, xen_host_cpu host_cpu)
  47.175 +{
  47.176 +    abstract_value param_values[] =
  47.177 +        {
  47.178 +            { .type = &abstract_type_string,
  47.179 +              .u.string_val = host_cpu }
  47.180 +        };
  47.181 +
  47.182 +    abstract_type result_type = xen_cpu_feature_set_abstract_type_;
  47.183 +
  47.184 +    *result = NULL;
  47.185 +    XEN_CALL_("host_cpu.get_features");
  47.186 +    return session->ok;
  47.187 +}
  47.188 +
  47.189 +
  47.190 +bool
  47.191 +xen_host_cpu_get_utilisation(xen_session *session, double *result, xen_host_cpu host_cpu)
  47.192 +{
  47.193 +    abstract_value param_values[] =
  47.194 +        {
  47.195 +            { .type = &abstract_type_string,
  47.196 +              .u.string_val = host_cpu }
  47.197 +        };
  47.198 +
  47.199 +    abstract_type result_type = abstract_type_float;
  47.200 +
  47.201 +    XEN_CALL_("host_cpu.get_utilisation");
  47.202 +    return session->ok;
  47.203 +}
  47.204 +
  47.205 +
  47.206 +bool
  47.207 +xen_host_cpu_get_uuid(xen_session *session, char **result, xen_host_cpu host_cpu)
  47.208 +{
  47.209 +    *result = session->ok ? xen_strdup_((char *)host_cpu) : NULL;
  47.210 +    return session->ok;
  47.211 +}
    48.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    48.2 +++ b/tools/libxen/src/xen_int_float_map.c	Sat Oct 07 18:22:09 2006 +0100
    48.3 @@ -0,0 +1,37 @@
    48.4 +/*
    48.5 + * Copyright (c) 2006, XenSource Inc.
    48.6 + *
    48.7 + * This library is free software; you can redistribute it and/or
    48.8 + * modify it under the terms of the GNU Lesser General Public
    48.9 + * License as published by the Free Software Foundation; either
   48.10 + * version 2.1 of the License, or (at your option) any later version.
   48.11 + *
   48.12 + * This library is distributed in the hope that it will be useful,
   48.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   48.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   48.15 + * Lesser General Public License for more details.
   48.16 + *
   48.17 + * You should have received a copy of the GNU Lesser General Public
   48.18 + * License along with this library; if not, write to the Free Software
   48.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   48.20 + */
   48.21 +
   48.22 +
   48.23 +#include "xen_common.h"
   48.24 +#include "xen_int_float_map.h"
   48.25 +#include "xen_internal.h"
   48.26 +
   48.27 +
   48.28 +xen_int_float_map *
   48.29 +xen_int_float_map_alloc(size_t size)
   48.30 +{
   48.31 +    return calloc(1, sizeof(xen_int_float_map) +
   48.32 +                  size * sizeof(struct xen_int_float_map_contents));
   48.33 +}
   48.34 +
   48.35 +
   48.36 +void
   48.37 +xen_int_float_map_free(xen_int_float_map *map)
   48.38 +{
   48.39 +    free(map);
   48.40 +}
    49.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    49.2 +++ b/tools/libxen/src/xen_network.c	Sat Oct 07 18:22:09 2006 +0100
    49.3 @@ -0,0 +1,398 @@
    49.4 +/*
    49.5 + * Copyright (c) 2006, XenSource Inc.
    49.6 + *
    49.7 + * This library is free software; you can redistribute it and/or
    49.8 + * modify it under the terms of the GNU Lesser General Public
    49.9 + * License as published by the Free Software Foundation; either
   49.10 + * version 2.1 of the License, or (at your option) any later version.
   49.11 + *
   49.12 + * This library is distributed in the hope that it will be useful,
   49.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   49.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   49.15 + * Lesser General Public License for more details.
   49.16 + *
   49.17 + * You should have received a copy of the GNU Lesser General Public
   49.18 + * License along with this library; if not, write to the Free Software
   49.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   49.20 + */
   49.21 +
   49.22 +
   49.23 +#include <stddef.h>
   49.24 +#include <stdlib.h>
   49.25 +
   49.26 +#include "xen_common.h"
   49.27 +#include "xen_internal.h"
   49.28 +#include "xen_network.h"
   49.29 +#include "xen_vif.h"
   49.30 +
   49.31 +
   49.32 +XEN_FREE(xen_network)
   49.33 +XEN_SET_ALLOC_FREE(xen_network)
   49.34 +XEN_ALLOC(xen_network_record)
   49.35 +XEN_SET_ALLOC_FREE(xen_network_record)
   49.36 +XEN_ALLOC(xen_network_record_opt)
   49.37 +XEN_RECORD_OPT_FREE(xen_network)
   49.38 +XEN_SET_ALLOC_FREE(xen_network_record_opt)
   49.39 +
   49.40 +
   49.41 +static const struct_member xen_network_record_struct_members[] =
   49.42 +    {
   49.43 +        { .key = "uuid",
   49.44 +          .type = &abstract_type_string,
   49.45 +          .offset = offsetof(xen_network_record, uuid) },
   49.46 +        { .key = "name_label",
   49.47 +          .type = &abstract_type_string,
   49.48 +          .offset = offsetof(xen_network_record, name_label) },
   49.49 +        { .key = "name_description",
   49.50 +          .type = &abstract_type_string,
   49.51 +          .offset = offsetof(xen_network_record, name_description) },
   49.52 +        { .key = "vifs",
   49.53 +          .type = &abstract_type_ref_set,
   49.54 +          .offset = offsetof(xen_network_record, vifs) },
   49.55 +        { .key = "nic",
   49.56 +          .type = &abstract_type_string,
   49.57 +          .offset = offsetof(xen_network_record, nic) },
   49.58 +        { .key = "vlan",
   49.59 +          .type = &abstract_type_string,
   49.60 +          .offset = offsetof(xen_network_record, vlan) },
   49.61 +        { .key = "default_gateway",
   49.62 +          .type = &abstract_type_string,
   49.63 +          .offset = offsetof(xen_network_record, default_gateway) },
   49.64 +        { .key = "default_netmask",
   49.65 +          .type = &abstract_type_string,
   49.66 +          .offset = offsetof(xen_network_record, default_netmask) }
   49.67 +    };
   49.68 +
   49.69 +const abstract_type xen_network_record_abstract_type_ =
   49.70 +    {
   49.71 +       .typename = STRUCT,
   49.72 +       .struct_size = sizeof(xen_network_record),
   49.73 +       .member_count =
   49.74 +           sizeof(xen_network_record_struct_members) / sizeof(struct_member),
   49.75 +       .members = xen_network_record_struct_members
   49.76 +    };
   49.77 +
   49.78 +
   49.79 +void
   49.80 +xen_network_record_free(xen_network_record *record)
   49.81 +{
   49.82 +    free(record->handle);
   49.83 +    free(record->uuid);
   49.84 +    free(record->name_label);
   49.85 +    free(record->name_description);
   49.86 +    xen_vif_record_opt_set_free(record->vifs);
   49.87 +    free(record->nic);
   49.88 +    free(record->vlan);
   49.89 +    free(record->default_gateway);
   49.90 +    free(record->default_netmask);
   49.91 +    free(record);
   49.92 +}
   49.93 +
   49.94 +
   49.95 +bool
   49.96 +xen_network_get_record(xen_session *session, xen_network_record **result, xen_network network)
   49.97 +{
   49.98 +    abstract_value param_values[] =
   49.99 +        {
  49.100 +            { .type = &abstract_type_string,
  49.101 +              .u.string_val = network }
  49.102 +        };
  49.103 +
  49.104 +    abstract_type result_type = xen_network_record_abstract_type_;
  49.105 +
  49.106 +    *result = NULL;
  49.107 +    XEN_CALL_("network.get_record");
  49.108 +
  49.109 +    if (session->ok)
  49.110 +    {
  49.111 +       (*result)->handle = xen_strdup_((*result)->uuid);
  49.112 +    }
  49.113 +
  49.114 +    return session->ok;
  49.115 +}
  49.116 +
  49.117 +
  49.118 +bool
  49.119 +xen_network_get_by_uuid(xen_session *session, xen_network *result, char *uuid)
  49.120 +{
  49.121 +    abstract_value param_values[] =
  49.122 +        {
  49.123 +            { .type = &abstract_type_string,
  49.124 +              .u.string_val = uuid }
  49.125 +        };
  49.126 +
  49.127 +    abstract_type result_type = abstract_type_string;
  49.128 +
  49.129 +    *result = NULL;
  49.130 +    XEN_CALL_("network.get_by_uuid");
  49.131 +    return session->ok;
  49.132 +}
  49.133 +
  49.134 +
  49.135 +bool
  49.136 +xen_network_create(xen_session *session, xen_network *result, xen_network_record *record)
  49.137 +{
  49.138 +    abstract_value param_values[] =
  49.139 +        {
  49.140 +            { .type = &xen_network_record_abstract_type_,
  49.141 +              .u.struct_val = record }
  49.142 +        };
  49.143 +
  49.144 +    abstract_type result_type = abstract_type_string;
  49.145 +
  49.146 +    *result = NULL;
  49.147 +    XEN_CALL_("network.create");
  49.148 +    return session->ok;
  49.149 +}
  49.150 +
  49.151 +
  49.152 +bool
  49.153 +xen_network_get_by_name_label(xen_session *session, xen_network *result, char *label)
  49.154 +{
  49.155 +    abstract_value param_values[] =
  49.156 +        {
  49.157 +            { .type = &abstract_type_string,
  49.158 +              .u.string_val = label }
  49.159 +        };
  49.160 +
  49.161 +    abstract_type result_type = abstract_type_string;
  49.162 +
  49.163 +    *result = NULL;
  49.164 +    XEN_CALL_("network.get_by_name_label");
  49.165 +    return session->ok;
  49.166 +}
  49.167 +
  49.168 +
  49.169 +bool
  49.170 +xen_network_get_name_label(xen_session *session, char **result, xen_network network)
  49.171 +{
  49.172 +    abstract_value param_values[] =
  49.173 +        {
  49.174 +            { .type = &abstract_type_string,
  49.175 +              .u.string_val = network }
  49.176 +        };
  49.177 +
  49.178 +    abstract_type result_type = abstract_type_string;
  49.179 +
  49.180 +    *result = NULL;
  49.181 +    XEN_CALL_("network.get_name_label");
  49.182 +    return session->ok;
  49.183 +}
  49.184 +
  49.185 +
  49.186 +bool
  49.187 +xen_network_get_name_description(xen_session *session, char **result, xen_network network)
  49.188 +{
  49.189 +    abstract_value param_values[] =
  49.190 +        {
  49.191 +            { .type = &abstract_type_string,
  49.192 +              .u.string_val = network }
  49.193 +        };
  49.194 +
  49.195 +    abstract_type result_type = abstract_type_string;
  49.196 +
  49.197 +    *result = NULL;
  49.198 +    XEN_CALL_("network.get_name_description");
  49.199 +    return session->ok;
  49.200 +}
  49.201 +
  49.202 +
  49.203 +bool
  49.204 +xen_network_get_vifs(xen_session *session, xen_vif *result, xen_network network)
  49.205 +{
  49.206 +    abstract_value param_values[] =
  49.207 +        {
  49.208 +            { .type = &abstract_type_string,
  49.209 +              .u.string_val = network }
  49.210 +        };
  49.211 +
  49.212 +    abstract_type result_type = abstract_type_string_set;
  49.213 +
  49.214 +    *result = NULL;
  49.215 +    XEN_CALL_("network.get_vifs");
  49.216 +    return session->ok;
  49.217 +}
  49.218 +
  49.219 +
  49.220 +bool
  49.221 +xen_network_get_nic(xen_session *session, char **result, xen_network network)
  49.222 +{
  49.223 +    abstract_value param_values[] =
  49.224 +        {
  49.225 +            { .type = &abstract_type_string,
  49.226 +              .u.string_val = network }
  49.227 +        };
  49.228 +
  49.229 +    abstract_type result_type = abstract_type_string;
  49.230 +
  49.231 +    *result = NULL;
  49.232 +    XEN_CALL_("network.get_nic");
  49.233 +    return session->ok;
  49.234 +}
  49.235 +
  49.236 +
  49.237 +bool
  49.238 +xen_network_get_vlan(xen_session *session, char **result, xen_network network)
  49.239 +{
  49.240 +    abstract_value param_values[] =
  49.241 +        {
  49.242 +            { .type = &abstract_type_string,
  49.243 +              .u.string_val = network }
  49.244 +        };
  49.245 +
  49.246 +    abstract_type result_type = abstract_type_string;
  49.247 +
  49.248 +    *result = NULL;
  49.249 +    XEN_CALL_("network.get_vlan");
  49.250 +    return session->ok;
  49.251 +}
  49.252 +
  49.253 +
  49.254 +bool
  49.255 +xen_network_get_default_gateway(xen_session *session, char **result, xen_network network)
  49.256 +{
  49.257 +    abstract_value param_values[] =
  49.258 +        {
  49.259 +            { .type = &abstract_type_string,
  49.260 +              .u.string_val = network }
  49.261 +        };
  49.262 +
  49.263 +    abstract_type result_type = abstract_type_string;
  49.264 +
  49.265 +    *result = NULL;
  49.266 +    XEN_CALL_("network.get_default_gateway");
  49.267 +    return session->ok;
  49.268 +}
  49.269 +
  49.270 +
  49.271 +bool
  49.272 +xen_network_get_default_netmask(xen_session *session, char **result, xen_network network)
  49.273 +{
  49.274 +    abstract_value param_values[] =
  49.275 +        {
  49.276 +            { .type = &abstract_type_string,
  49.277 +              .u.string_val = network }
  49.278 +        };
  49.279 +
  49.280 +    abstract_type result_type = abstract_type_string;
  49.281 +
  49.282 +    *result = NULL;
  49.283 +    XEN_CALL_("network.get_default_netmask");
  49.284 +    return session->ok;
  49.285 +}
  49.286 +
  49.287 +
  49.288 +bool
  49.289 +xen_network_set_name_label(xen_session *session, xen_network xen_network, char *label)
  49.290 +{
  49.291 +    abstract_value param_values[] =
  49.292 +        {
  49.293 +            { .type = &abstract_type_string,
  49.294 +              .u.string_val = xen_network },
  49.295 +            { .type = &abstract_type_string,
  49.296 +              .u.string_val = label }
  49.297 +        };
  49.298 +
  49.299 +    xen_call_(session, "network.set_name_label", param_values, 2, NULL, NULL);
  49.300 +    return session->ok;
  49.301 +}
  49.302 +
  49.303 +
  49.304 +bool
  49.305 +xen_network_set_name_description(xen_session *session, xen_network xen_network, char *description)
  49.306 +{
  49.307 +    abstract_value param_values[] =
  49.308 +        {
  49.309 +            { .type = &abstract_type_string,
  49.310 +              .u.string_val = xen_network },
  49.311 +            { .type = &abstract_type_string,
  49.312 +              .u.string_val = description }
  49.313 +        };
  49.314 +
  49.315 +    xen_call_(session, "network.set_name_description", param_values, 2, NULL, NULL);
  49.316 +    return session->ok;
  49.317 +}
  49.318 +
  49.319 +
  49.320 +bool
  49.321 +xen_network_set_nic(xen_session *session, xen_network xen_network, char *nic)
  49.322 +{
  49.323 +    abstract_value param_values[] =
  49.324 +        {
  49.325 +            { .type = &abstract_type_string,
  49.326 +              .u.string_val = xen_network },
  49.327 +            { .type = &abstract_type_string,
  49.328 +              .u.string_val = nic }
  49.329 +        };
  49.330 +
  49.331 +    xen_call_(session, "network.set_nic", param_values, 2, NULL, NULL);
  49.332 +    return session->ok;
  49.333 +}
  49.334 +
  49.335 +
  49.336 +bool
  49.337 +xen_network_set_vlan(xen_session *session, xen_network xen_network, char *vlan)
  49.338 +{
  49.339 +    abstract_value param_values[] =
  49.340 +        {
  49.341 +            { .type = &abstract_type_string,
  49.342 +              .u.string_val = xen_network },
  49.343 +            { .type = &abstract_type_string,
  49.344 +              .u.string_val = vlan }
  49.345 +        };
  49.346 +
  49.347 +    xen_call_(session, "network.set_vlan", param_values, 2, NULL, NULL);
  49.348 +    return session->ok;
  49.349 +}
  49.350 +
  49.351 +
  49.352 +bool
  49.353 +xen_network_set_default_gateway(xen_session *session, xen_network xen_network, char *default_gateway)
  49.354 +{
  49.355 +    abstract_value param_values[] =
  49.356 +        {
  49.357 +            { .type = &abstract_type_string,
  49.358 +              .u.string_val = xen_network },
  49.359 +            { .type = &abstract_type_string,
  49.360 +              .u.string_val = default_gateway }
  49.361 +        };
  49.362 +
  49.363 +    xen_call_(session, "network.set_default_gateway", param_values, 2, NULL, NULL);
  49.364 +    return session->ok;
  49.365 +}
  49.366 +
  49.367 +
  49.368 +bool
  49.369 +xen_network_set_default_netmask(xen_session *session, xen_network xen_network, char *default_netmask)
  49.370 +{
  49.371 +    abstract_value param_values[] =
  49.372 +        {
  49.373 +            { .type = &abstract_type_string,
  49.374 +              .u.string_val = xen_network },
  49.375 +            { .type = &abstract_type_string,
  49.376 +              .u.string_val = default_netmask }
  49.377 +        };
  49.378 +
  49.379 +    xen_call_(session, "network.set_default_netmask", param_values, 2, NULL, NULL);
  49.380 +    return session->ok;
  49.381 +}
  49.382 +
  49.383 +
  49.384 +bool
  49.385 +xen_network_get_all(xen_session *session, xen_network *result)
  49.386 +{
  49.387 +
  49.388 +    abstract_type result_type = abstract_type_string_set;
  49.389 +
  49.390 +    *result = NULL;
  49.391 +    xen_call_(session, "network.get_all", NULL, 0, &result_type, result);
  49.392 +    return session->ok;
  49.393 +}
  49.394 +
  49.395 +
  49.396 +bool
  49.397 +xen_network_get_uuid(xen_session *session, char **result, xen_network network)
  49.398 +{
  49.399 +    *result = session->ok ? xen_strdup_((char *)network) : NULL;
  49.400 +    return session->ok;
  49.401 +}
    50.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    50.2 +++ b/tools/libxen/src/xen_on_crash_behaviour.c	Sat Oct 07 18:22:09 2006 +0100
    50.3 @@ -0,0 +1,85 @@
    50.4 +/*
    50.5 + * Copyright (c) 2006, XenSource Inc.
    50.6 + *
    50.7 + * This library is free software; you can redistribute it and/or
    50.8 + * modify it under the terms of the GNU Lesser General Public
    50.9 + * License as published by the Free Software Foundation; either
   50.10 + * version 2.1 of the License, or (at your option) any later version.
   50.11 + *
   50.12 + * This library is distributed in the hope that it will be useful,
   50.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   50.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   50.15 + * Lesser General Public License for more details.
   50.16 + *
   50.17 + * You should have received a copy of the GNU Lesser General Public
   50.18 + * License along with this library; if not, write to the Free Software
   50.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   50.20 + */
   50.21 +
   50.22 +#include <string.h>
   50.23 +
   50.24 +#include "xen_internal.h"
   50.25 +#include "xen_on_crash_behaviour.h"
   50.26 +#include "xen_on_crash_behaviour_internal.h"
   50.27 +
   50.28 +
   50.29 +/*
   50.30 + * Maintain this in the same order as the enum declaration!
   50.31 + */
   50.32 +static const char *lookup_table[] =
   50.33 +{
   50.34 +    "destroy",
   50.35 +    "coredump_and_destroy",
   50.36 +    "restart",
   50.37 +    "coredump_and_restart",
   50.38 +    "preserve",
   50.39 +    "rename_restart"
   50.40 +};
   50.41 +
   50.42 +
   50.43 +extern xen_on_crash_behaviour_set *
   50.44 +xen_on_crash_behaviour_set_alloc(size_t size)
   50.45 +{
   50.46 +    return calloc(1, sizeof(xen_on_crash_behaviour_set) +
   50.47 +                  size * sizeof(enum xen_on_crash_behaviour));
   50.48 +}
   50.49 +
   50.50 +
   50.51 +extern void
   50.52 +xen_on_crash_behaviour_set_free(xen_on_crash_behaviour_set *set)
   50.53 +{
   50.54 +    free(set);
   50.55 +}
   50.56 +
   50.57 +
   50.58 +const char *
   50.59 +xen_on_crash_behaviour_to_string(enum xen_on_crash_behaviour val)
   50.60 +{
   50.61 +    return lookup_table[val];
   50.62 +}
   50.63 +
   50.64 +
   50.65 +extern enum xen_on_crash_behaviour
   50.66 +xen_on_crash_behaviour_from_string(xen_session *session, const char *str)
   50.67 +{
   50.68 +    return ENUM_LOOKUP(session, str, lookup_table);
   50.69 +}
   50.70 +
   50.71 +
   50.72 +const abstract_type xen_on_crash_behaviour_abstract_type_ =
   50.73 +    {
   50.74 +        .typename = ENUM,
   50.75 +        .enum_marshaller =
   50.76 +             (const char *(*)(int))&xen_on_crash_behaviour_to_string,
   50.77 +        .enum_demarshaller =
   50.78 +             (int (*)(xen_session *, const char *))&xen_on_crash_behaviour_from_string
   50.79 +    };
   50.80 +
   50.81 +
   50.82 +const abstract_type xen_on_crash_behaviour_set_abstract_type_ =
   50.83 +    {
   50.84 +        .typename = SET,
   50.85 +        .child = &xen_on_crash_behaviour_abstract_type_
   50.86 +    };
   50.87 +
   50.88 +
    51.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    51.2 +++ b/tools/libxen/src/xen_on_normal_exit.c	Sat Oct 07 18:22:09 2006 +0100
    51.3 @@ -0,0 +1,81 @@
    51.4 +/*
    51.5 + * Copyright (c) 2006, XenSource Inc.
    51.6 + *
    51.7 + * This library is free software; you can redistribute it and/or
    51.8 + * modify it under the terms of the GNU Lesser General Public
    51.9 + * License as published by the Free Software Foundation; either
   51.10 + * version 2.1 of the License, or (at your option) any later version.
   51.11 + *
   51.12 + * This library is distributed in the hope that it will be useful,
   51.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   51.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   51.15 + * Lesser General Public License for more details.
   51.16 + *
   51.17 + * You should have received a copy of the GNU Lesser General Public
   51.18 + * License along with this library; if not, write to the Free Software
   51.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   51.20 + */
   51.21 +
   51.22 +#include <string.h>
   51.23 +
   51.24 +#include "xen_internal.h"
   51.25 +#include "xen_on_normal_exit.h"
   51.26 +#include "xen_on_normal_exit_internal.h"
   51.27 +
   51.28 +
   51.29 +/*
   51.30 + * Maintain this in the same order as the enum declaration!
   51.31 + */
   51.32 +static const char *lookup_table[] =
   51.33 +{
   51.34 +    "destroy",
   51.35 +    "restart"
   51.36 +};
   51.37 +
   51.38 +
   51.39 +extern xen_on_normal_exit_set *
   51.40 +xen_on_normal_exit_set_alloc(size_t size)
   51.41 +{
   51.42 +    return calloc(1, sizeof(xen_on_normal_exit_set) +
   51.43 +                  size * sizeof(enum xen_on_normal_exit));
   51.44 +}
   51.45 +
   51.46 +
   51.47 +extern void
   51.48 +xen_on_normal_exit_set_free(xen_on_normal_exit_set *set)
   51.49 +{
   51.50 +    free(set);
   51.51 +}
   51.52 +
   51.53 +
   51.54 +const char *
   51.55 +xen_on_normal_exit_to_string(enum xen_on_normal_exit val)
   51.56 +{
   51.57 +    return lookup_table[val];
   51.58 +}
   51.59 +
   51.60 +
   51.61 +extern enum xen_on_normal_exit
   51.62 +xen_on_normal_exit_from_string(xen_session *session, const char *str)
   51.63 +{
   51.64 +    return ENUM_LOOKUP(session, str, lookup_table);
   51.65 +}
   51.66 +
   51.67 +
   51.68 +const abstract_type xen_on_normal_exit_abstract_type_ =
   51.69 +    {
   51.70 +        .typename = ENUM,
   51.71 +        .enum_marshaller =
   51.72 +             (const char *(*)(int))&xen_on_normal_exit_to_string,
   51.73 +        .enum_demarshaller =
   51.74 +             (int (*)(xen_session *, const char *))&xen_on_normal_exit_from_string
   51.75 +    };
   51.76 +
   51.77 +
   51.78 +const abstract_type xen_on_normal_exit_set_abstract_type_ =
   51.79 +    {
   51.80 +        .typename = SET,
   51.81 +        .child = &xen_on_normal_exit_abstract_type_
   51.82 +    };
   51.83 +
   51.84 +
    52.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    52.2 +++ b/tools/libxen/src/xen_sr.c	Sat Oct 07 18:22:09 2006 +0100
    52.3 @@ -0,0 +1,370 @@
    52.4 +/*
    52.5 + * Copyright (c) 2006, XenSource Inc.
    52.6 + *
    52.7 + * This library is free software; you can redistribute it and/or
    52.8 + * modify it under the terms of the GNU Lesser General Public
    52.9 + * License as published by the Free Software Foundation; either
   52.10 + * version 2.1 of the License, or (at your option) any later version.
   52.11 + *
   52.12 + * This library is distributed in the hope that it will be useful,
   52.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   52.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   52.15 + * Lesser General Public License for more details.
   52.16 + *
   52.17 + * You should have received a copy of the GNU Lesser General Public
   52.18 + * License along with this library; if not, write to the Free Software
   52.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   52.20 + */
   52.21 +
   52.22 +
   52.23 +#include <stddef.h>
   52.24 +#include <stdlib.h>
   52.25 +
   52.26 +#include "xen_common.h"
   52.27 +#include "xen_internal.h"
   52.28 +#include "xen_sr.h"
   52.29 +#include "xen_vdi.h"
   52.30 +
   52.31 +
   52.32 +XEN_FREE(xen_sr)
   52.33 +XEN_SET_ALLOC_FREE(xen_sr)
   52.34 +XEN_ALLOC(xen_sr_record)
   52.35 +XEN_SET_ALLOC_FREE(xen_sr_record)
   52.36 +XEN_ALLOC(xen_sr_record_opt)
   52.37 +XEN_RECORD_OPT_FREE(xen_sr)
   52.38 +XEN_SET_ALLOC_FREE(xen_sr_record_opt)
   52.39 +
   52.40 +
   52.41 +static const struct_member xen_sr_record_struct_members[] =
   52.42 +    {
   52.43 +        { .key = "uuid",
   52.44 +          .type = &abstract_type_string,
   52.45 +          .offset = offsetof(xen_sr_record, uuid) },
   52.46 +        { .key = "name_label",
   52.47 +          .type = &abstract_type_string,
   52.48 +          .offset = offsetof(xen_sr_record, name_label) },
   52.49 +        { .key = "name_description",
   52.50 +          .type = &abstract_type_string,
   52.51 +          .offset = offsetof(xen_sr_record, name_description) },
   52.52 +        { .key = "vdis",
   52.53 +          .type = &abstract_type_ref_set,
   52.54 +          .offset = offsetof(xen_sr_record, vdis) },
   52.55 +        { .key = "virtual_allocation",
   52.56 +          .type = &abstract_type_int,
   52.57 +          .offset = offsetof(xen_sr_record, virtual_allocation) },
   52.58 +        { .key = "physical_utilisation",
   52.59 +          .type = &abstract_type_int,
   52.60 +          .offset = offsetof(xen_sr_record, physical_utilisation) },
   52.61 +        { .key = "physical_size",
   52.62 +          .type = &abstract_type_int,
   52.63 +          .offset = offsetof(xen_sr_record, physical_size) },
   52.64 +        { .key = "type",
   52.65 +          .type = &abstract_type_string,
   52.66 +          .offset = offsetof(xen_sr_record, type) },
   52.67 +        { .key = "location",
   52.68 +          .type = &abstract_type_string,
   52.69 +          .offset = offsetof(xen_sr_record, location) }
   52.70 +    };
   52.71 +
   52.72 +const abstract_type xen_sr_record_abstract_type_ =
   52.73 +    {
   52.74 +       .typename = STRUCT,
   52.75 +       .struct_size = sizeof(xen_sr_record),
   52.76 +       .member_count =
   52.77 +           sizeof(xen_sr_record_struct_members) / sizeof(struct_member),
   52.78 +       .members = xen_sr_record_struct_members
   52.79 +    };
   52.80 +
   52.81 +
   52.82 +void
   52.83 +xen_sr_record_free(xen_sr_record *record)
   52.84 +{
   52.85 +    free(record->handle);
   52.86 +    free(record->uuid);
   52.87 +    free(record->name_label);
   52.88 +    free(record->name_description);
   52.89 +    xen_vdi_record_opt_set_free(record->vdis);
   52.90 +    free(record->type);
   52.91 +    free(record->location);
   52.92 +    free(record);
   52.93 +}
   52.94 +
   52.95 +
   52.96 +bool
   52.97 +xen_sr_get_record(xen_session *session, xen_sr_record **result, xen_sr sr)
   52.98 +{
   52.99 +    abstract_value param_values[] =
  52.100 +        {
  52.101 +            { .type = &abstract_type_string,
  52.102 +              .u.string_val = sr }
  52.103 +        };
  52.104 +
  52.105 +    abstract_type result_type = xen_sr_record_abstract_type_;
  52.106 +
  52.107 +    *result = NULL;
  52.108 +    XEN_CALL_("SR.get_record");
  52.109 +
  52.110 +    if (session->ok)
  52.111 +    {
  52.112 +       (*result)->handle = xen_strdup_((*result)->uuid);
  52.113 +    }
  52.114 +
  52.115 +    return session->ok;
  52.116 +}
  52.117 +
  52.118 +
  52.119 +bool
  52.120 +xen_sr_get_by_uuid(xen_session *session, xen_sr *result, char *uuid)
  52.121 +{
  52.122 +    abstract_value param_values[] =
  52.123 +        {
  52.124 +            { .type = &abstract_type_string,
  52.125 +              .u.string_val = uuid }
  52.126 +        };
  52.127 +
  52.128 +    abstract_type result_type = abstract_type_string;
  52.129 +
  52.130 +    *result = NULL;
  52.131 +    XEN_CALL_("SR.get_by_uuid");
  52.132 +    return session->ok;
  52.133 +}
  52.134 +
  52.135 +
  52.136 +bool
  52.137 +xen_sr_create(xen_session *session, xen_sr *result, xen_sr_record *record)
  52.138 +{
  52.139 +    abstract_value param_values[] =
  52.140 +        {
  52.141 +            { .type = &xen_sr_record_abstract_type_,
  52.142 +              .u.struct_val = record }
  52.143 +        };
  52.144 +
  52.145 +    abstract_type result_type = abstract_type_string;
  52.146 +
  52.147 +    *result = NULL;
  52.148 +    XEN_CALL_("SR.create");
  52.149 +    return session->ok;
  52.150 +}
  52.151 +
  52.152 +
  52.153 +bool
  52.154 +xen_sr_get_by_name_label(xen_session *session, xen_sr *result, char *label)
  52.155 +{
  52.156 +    abstract_value param_values[] =
  52.157 +        {
  52.158 +            { .type = &abstract_type_string,
  52.159 +              .u.string_val = label }
  52.160 +        };
  52.161 +
  52.162 +    abstract_type result_type = abstract_type_string;
  52.163 +
  52.164 +    *result = NULL;
  52.165 +    XEN_CALL_("SR.get_by_name_label");
  52.166 +    return session->ok;
  52.167 +}
  52.168 +
  52.169 +
  52.170 +bool
  52.171 +xen_sr_get_name_label(xen_session *session, char **result, xen_sr sr)
  52.172 +{
  52.173 +    abstract_value param_values[] =
  52.174 +        {
  52.175 +            { .type = &abstract_type_string,
  52.176 +              .u.string_val = sr }
  52.177 +        };
  52.178 +
  52.179 +    abstract_type result_type = abstract_type_string;
  52.180 +
  52.181 +    *result = NULL;
  52.182 +    XEN_CALL_("SR.get_name_label");
  52.183 +    return session->ok;
  52.184 +}
  52.185 +
  52.186 +
  52.187 +bool
  52.188 +xen_sr_get_name_description(xen_session *session, char **result, xen_sr sr)
  52.189 +{
  52.190 +    abstract_value param_values[] =
  52.191 +        {
  52.192 +            { .type = &abstract_type_string,
  52.193 +              .u.string_val = sr }
  52.194 +        };
  52.195 +
  52.196 +    abstract_type result_type = abstract_type_string;
  52.197 +
  52.198 +    *result = NULL;
  52.199 +    XEN_CALL_("SR.get_name_description");
  52.200 +    return session->ok;
  52.201 +}
  52.202 +
  52.203 +
  52.204 +bool
  52.205 +xen_sr_get_vdis(xen_session *session, xen_vdi *result, xen_sr sr)
  52.206 +{
  52.207 +    abstract_value param_values[] =
  52.208 +        {
  52.209 +            { .type = &abstract_type_string,
  52.210 +              .u.string_val = sr }
  52.211 +        };
  52.212 +
  52.213 +    abstract_type result_type = abstract_type_string_set;
  52.214 +
  52.215 +    *result = NULL;
  52.216 +    XEN_CALL_("SR.get_vdis");
  52.217 +    return session->ok;
  52.218 +}
  52.219 +
  52.220 +
  52.221 +bool
  52.222 +xen_sr_get_virtual_allocation(xen_session *session, uint64_t *result, xen_sr sr)
  52.223 +{
  52.224 +    abstract_value param_values[] =
  52.225 +        {
  52.226 +            { .type = &abstract_type_string,
  52.227 +              .u.string_val = sr }
  52.228 +        };
  52.229 +
  52.230 +    abstract_type result_type = abstract_type_int;
  52.231 +
  52.232 +    XEN_CALL_("SR.get_virtual_allocation");
  52.233 +    return session->ok;
  52.234 +}
  52.235 +
  52.236 +
  52.237 +bool
  52.238 +xen_sr_get_physical_utilisation(xen_session *session, uint64_t *result, xen_sr sr)
  52.239 +{
  52.240 +    abstract_value param_values[] =
  52.241 +        {
  52.242 +            { .type = &abstract_type_string,
  52.243 +              .u.string_val = sr }
  52.244 +        };
  52.245 +
  52.246 +    abstract_type result_type = abstract_type_int;
  52.247 +
  52.248 +    XEN_CALL_("SR.get_physical_utilisation");
  52.249 +    return session->ok;
  52.250 +}
  52.251 +
  52.252 +
  52.253 +bool
  52.254 +xen_sr_get_physical_size(xen_session *session, uint64_t *result, xen_sr sr)
  52.255 +{
  52.256 +    abstract_value param_values[] =
  52.257 +        {
  52.258 +            { .type = &abstract_type_string,
  52.259 +              .u.string_val = sr }
  52.260 +        };
  52.261 +
  52.262 +    abstract_type result_type = abstract_type_int;
  52.263 +
  52.264 +    XEN_CALL_("SR.get_physical_size");
  52.265 +    return session->ok;
  52.266 +}
  52.267 +
  52.268 +
  52.269 +bool
  52.270 +xen_sr_get_type(xen_session *session, char **result, xen_sr sr)
  52.271 +{
  52.272 +    abstract_value param_values[] =
  52.273 +        {
  52.274 +            { .type = &abstract_type_string,
  52.275 +              .u.string_val = sr }
  52.276 +        };
  52.277 +
  52.278 +    abstract_type result_type = abstract_type_string;
  52.279 +
  52.280 +    *result = NULL;
  52.281 +    XEN_CALL_("SR.get_type");
  52.282 +    return session->ok;
  52.283 +}
  52.284 +
  52.285 +
  52.286 +bool
  52.287 +xen_sr_get_location(xen_session *session, char **result, xen_sr sr)
  52.288 +{
  52.289 +    abstract_value param_values[] =
  52.290 +        {
  52.291 +            { .type = &abstract_type_string,
  52.292 +              .u.string_val = sr }
  52.293 +        };
  52.294 +
  52.295 +    abstract_type result_type = abstract_type_string;
  52.296 +
  52.297 +    *result = NULL;
  52.298 +    XEN_CALL_("SR.get_location");
  52.299 +    return session->ok;
  52.300 +}
  52.301 +
  52.302 +
  52.303 +bool
  52.304 +xen_sr_set_name_label(xen_session *session, xen_sr xen_sr, char *label)
  52.305 +{
  52.306 +    abstract_value param_values[] =
  52.307 +        {
  52.308 +            { .type = &abstract_type_string,
  52.309 +              .u.string_val = xen_sr },
  52.310 +            { .type = &abstract_type_string,
  52.311 +              .u.string_val = label }
  52.312 +        };
  52.313 +
  52.314 +    xen_call_(session, "SR.set_name_label", param_values, 2, NULL, NULL);
  52.315 +    return session->ok;
  52.316 +}
  52.317 +
  52.318 +
  52.319 +bool
  52.320 +xen_sr_set_name_description(xen_session *session, xen_sr xen_sr, char *description)
  52.321 +{
  52.322 +    abstract_value param_values[] =
  52.323 +        {
  52.324 +            { .type = &abstract_type_string,
  52.325 +              .u.string_val = xen_sr },
  52.326 +            { .type = &abstract_type_string,
  52.327 +              .u.string_val = description }
  52.328 +        };
  52.329 +
  52.330 +    xen_call_(session, "SR.set_name_description", param_values, 2, NULL, NULL);
  52.331 +    return session->ok;
  52.332 +}
  52.333 +
  52.334 +
  52.335 +bool
  52.336 +xen_sr_clone(xen_session *session, xen_sr *result, xen_sr sr, char *loc, char *name)
  52.337 +{
  52.338 +    abstract_value param_values[] =
  52.339 +        {
  52.340 +            { .type = &abstract_type_string,
  52.341 +              .u.string_val = sr },
  52.342 +            { .type = &abstract_type_string,
  52.343 +              .u.string_val = loc },
  52.344 +            { .type = &abstract_type_string,
  52.345 +              .u.string_val = name }
  52.346 +        };
  52.347 +
  52.348 +    abstract_type result_type = abstract_type_string;
  52.349 +
  52.350 +    *result = NULL;
  52.351 +    XEN_CALL_("SR.clone");
  52.352 +    return session->ok;
  52.353 +}
  52.354 +
  52.355 +
  52.356 +bool
  52.357 +xen_sr_get_all(xen_session *session, xen_sr *result)
  52.358 +{
  52.359 +
  52.360 +    abstract_type result_type = abstract_type_string_set;
  52.361 +
  52.362 +    *result = NULL;
  52.363 +    xen_call_(session, "SR.get_all", NULL, 0, &result_type, result);
  52.364 +    return session->ok;
  52.365 +}
  52.366 +
  52.367 +
  52.368 +bool
  52.369 +xen_sr_get_uuid(xen_session *session, char **result, xen_sr sr)
  52.370 +{
  52.371 +    *result = session->ok ? xen_strdup_((char *)sr) : NULL;
  52.372 +    return session->ok;
  52.373 +}
    53.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    53.2 +++ b/tools/libxen/src/xen_string_string_map.c	Sat Oct 07 18:22:09 2006 +0100
    53.3 @@ -0,0 +1,49 @@
    53.4 +/*
    53.5 + * Copyright (c) 2006, XenSource Inc.
    53.6 + *
    53.7 + * This library is free software; you can redistribute it and/or
    53.8 + * modify it under the terms of the GNU Lesser General Public
    53.9 + * License as published by the Free Software Foundation; either
   53.10 + * version 2.1 of the License, or (at your option) any later version.
   53.11 + *
   53.12 + * This library is distributed in the hope that it will be useful,
   53.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   53.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   53.15 + * Lesser General Public License for more details.
   53.16 + *
   53.17 + * You should have received a copy of the GNU Lesser General Public
   53.18 + * License along with this library; if not, write to the Free Software
   53.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   53.20 + */
   53.21 +
   53.22 +
   53.23 +#include "xen_common.h"
   53.24 +#include "xen_internal.h"
   53.25 +#include "xen_string_string_map.h"
   53.26 +
   53.27 +
   53.28 +xen_string_string_map *
   53.29 +xen_string_string_map_alloc(size_t size)
   53.30 +{
   53.31 +    return calloc(1, sizeof(xen_string_string_map) +
   53.32 +                  size * sizeof(struct xen_string_string_map_contents));
   53.33 +}
   53.34 +
   53.35 +
   53.36 +void
   53.37 +xen_string_string_map_free(xen_string_string_map *map)
   53.38 +{
   53.39 +    if (map == NULL)
   53.40 +    {
   53.41 +        return;
   53.42 +    }
   53.43 +
   53.44 +    size_t n = map->size;
   53.45 +    for (size_t i = 0; i < n; i++)
   53.46 +    {
   53.47 +        free(map->contents[i].key);
   53.48 +        free(map->contents[i].val);
   53.49 +    }
   53.50 +
   53.51 +    free(map);
   53.52 +}
    54.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    54.2 +++ b/tools/libxen/src/xen_user.c	Sat Oct 07 18:22:09 2006 +0100
    54.3 @@ -0,0 +1,183 @@
    54.4 +/*
    54.5 + * Copyright (c) 2006, XenSource Inc.
    54.6 + *
    54.7 + * This library is free software; you can redistribute it and/or
    54.8 + * modify it under the terms of the GNU Lesser General Public
    54.9 + * License as published by the Free Software Foundation; either
   54.10 + * version 2.1 of the License, or (at your option) any later version.
   54.11 + *
   54.12 + * This library is distributed in the hope that it will be useful,
   54.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   54.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   54.15 + * Lesser General Public License for more details.
   54.16 + *
   54.17 + * You should have received a copy of the GNU Lesser General Public
   54.18 + * License along with this library; if not, write to the Free Software
   54.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   54.20 + */
   54.21 +
   54.22 +
   54.23 +#include <stddef.h>
   54.24 +#include <stdlib.h>
   54.25 +
   54.26 +#include "xen_common.h"
   54.27 +#include "xen_internal.h"
   54.28 +#include "xen_user.h"
   54.29 +
   54.30 +
   54.31 +XEN_FREE(xen_user)
   54.32 +XEN_SET_ALLOC_FREE(xen_user)
   54.33 +XEN_ALLOC(xen_user_record)
   54.34 +XEN_SET_ALLOC_FREE(xen_user_record)
   54.35 +XEN_ALLOC(xen_user_record_opt)
   54.36 +XEN_RECORD_OPT_FREE(xen_user)
   54.37 +XEN_SET_ALLOC_FREE(xen_user_record_opt)
   54.38 +
   54.39 +
   54.40 +static const struct_member xen_user_record_struct_members[] =
   54.41 +    {
   54.42 +        { .key = "uuid",
   54.43 +          .type = &abstract_type_string,
   54.44 +          .offset = offsetof(xen_user_record, uuid) },
   54.45 +        { .key = "short_name",
   54.46 +          .type = &abstract_type_string,
   54.47 +          .offset = offsetof(xen_user_record, short_name) },
   54.48 +        { .key = "fullname",
   54.49 +          .type = &abstract_type_string,
   54.50 +          .offset = offsetof(xen_user_record, fullname) }
   54.51 +    };
   54.52 +
   54.53 +const abstract_type xen_user_record_abstract_type_ =
   54.54 +    {
   54.55 +       .typename = STRUCT,
   54.56 +       .struct_size = sizeof(xen_user_record),
   54.57 +       .member_count =
   54.58 +           sizeof(xen_user_record_struct_members) / sizeof(struct_member),
   54.59 +       .members = xen_user_record_struct_members
   54.60 +    };
   54.61 +
   54.62 +
   54.63 +void
   54.64 +xen_user_record_free(xen_user_record *record)
   54.65 +{
   54.66 +    free(record->handle);
   54.67 +    free(record->uuid);
   54.68 +    free(record->short_name);
   54.69 +    free(record->fullname);
   54.70 +    free(record);
   54.71 +}
   54.72 +
   54.73 +
   54.74 +bool
   54.75 +xen_user_get_record(xen_session *session, xen_user_record **result, xen_user user)
   54.76 +{
   54.77 +    abstract_value param_values[] =
   54.78 +        {
   54.79 +            { .type = &abstract_type_string,
   54.80 +              .u.string_val = user }
   54.81 +        };
   54.82 +
   54.83 +    abstract_type result_type = xen_user_record_abstract_type_;
   54.84 +
   54.85 +    *result = NULL;
   54.86 +    XEN_CALL_("user.get_record");
   54.87 +
   54.88 +    if (session->ok)
   54.89 +    {
   54.90 +       (*result)->handle = xen_strdup_((*result)->uuid);
   54.91 +    }
   54.92 +
   54.93 +    return session->ok;
   54.94 +}
   54.95 +
   54.96 +
   54.97 +bool
   54.98 +xen_user_get_by_uuid(xen_session *session, xen_user *result, char *uuid)
   54.99 +{
  54.100 +    abstract_value param_values[] =
  54.101 +        {
  54.102 +            { .type = &abstract_type_string,
  54.103 +              .u.string_val = uuid }
  54.104 +        };
  54.105 +
  54.106 +    abstract_type result_type = abstract_type_string;
  54.107 +
  54.108 +    *result = NULL;
  54.109 +    XEN_CALL_("user.get_by_uuid");
  54.110 +    return session->ok;
  54.111 +}
  54.112 +
  54.113 +
  54.114 +bool
  54.115 +xen_user_create(xen_session *session, xen_user *result, xen_user_record *record)
  54.116 +{
  54.117 +    abstract_value param_values[] =
  54.118 +        {
  54.119 +            { .type = &xen_user_record_abstract_type_,
  54.120 +              .u.struct_val = record }
  54.121 +        };
  54.122 +
  54.123 +    abstract_type result_type = abstract_type_string;
  54.124 +
  54.125 +    *result = NULL;
  54.126 +    XEN_CALL_("user.create");
  54.127 +    return session->ok;
  54.128 +}
  54.129 +
  54.130 +
  54.131 +bool
  54.132 +xen_user_get_short_name(xen_session *session, char **result, xen_user user)
  54.133 +{
  54.134 +    abstract_value param_values[] =
  54.135 +        {
  54.136 +            { .type = &abstract_type_string,
  54.137 +              .u.string_val = user }
  54.138 +        };
  54.139 +
  54.140 +    abstract_type result_type = abstract_type_string;
  54.141 +
  54.142 +    *result = NULL;
  54.143 +    XEN_CALL_("user.get_short_name");
  54.144 +    return session->ok;
  54.145 +}
  54.146 +
  54.147 +
  54.148 +bool
  54.149 +xen_user_get_fullname(xen_session *session, char **result, xen_user user)
  54.150 +{
  54.151 +    abstract_value param_values[] =
  54.152 +        {
  54.153 +            { .type = &abstract_type_string,
  54.154 +              .u.string_val = user }
  54.155 +        };
  54.156 +
  54.157 +    abstract_type result_type = abstract_type_string;
  54.158 +
  54.159 +    *result = NULL;
  54.160 +    XEN_CALL_("user.get_fullname");
  54.161 +    return session->ok;
  54.162 +}
  54.163 +
  54.164 +
  54.165 +bool
  54.166 +xen_user_set_fullname(xen_session *session, xen_user xen_user, char *fullname)
  54.167 +{
  54.168 +    abstract_value param_values[] =
  54.169 +        {
  54.170 +            { .type = &abstract_type_string,
  54.171 +              .u.string_val = xen_user },
  54.172 +            { .type = &abstract_type_string,
  54.173 +              .u.string_val = fullname }
  54.174 +        };
  54.175 +
  54.176 +    xen_call_(session, "user.set_fullname", param_values, 2, NULL, NULL);
  54.177 +    return session->ok;
  54.178 +}
  54.179 +
  54.180 +
  54.181 +bool
  54.182 +xen_user_get_uuid(xen_session *session, char **result, xen_user user)
  54.183 +{
  54.184 +    *result = session->ok ? xen_strdup_((char *)user) : NULL;
  54.185 +    return session->ok;
  54.186 +}
    55.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    55.2 +++ b/tools/libxen/src/xen_vbd.c	Sat Oct 07 18:22:09 2006 +0100
    55.3 @@ -0,0 +1,350 @@
    55.4 +/*
    55.5 + * Copyright (c) 2006, XenSource Inc.
    55.6 + *
    55.7 + * This library is free software; you can redistribute it and/or
    55.8 + * modify it under the terms of the GNU Lesser General Public
    55.9 + * License as published by the Free Software Foundation; either
   55.10 + * version 2.1 of the License, or (at your option) any later version.
   55.11 + *
   55.12 + * This library is distributed in the hope that it will be useful,
   55.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   55.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   55.15 + * Lesser General Public License for more details.
   55.16 + *
   55.17 + * You should have received a copy of the GNU Lesser General Public
   55.18 + * License along with this library; if not, write to the Free Software
   55.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   55.20 + */
   55.21 +
   55.22 +
   55.23 +#include <stddef.h>
   55.24 +#include <stdlib.h>
   55.25 +
   55.26 +#include "xen_common.h"
   55.27 +#include "xen_driver_type_internal.h"
   55.28 +#include "xen_internal.h"
   55.29 +#include "xen_vbd.h"
   55.30 +#include "xen_vbd_mode_internal.h"
   55.31 +#include "xen_vdi.h"
   55.32 +#include "xen_vm.h"
   55.33 +
   55.34 +
   55.35 +XEN_FREE(xen_vbd)
   55.36 +XEN_SET_ALLOC_FREE(xen_vbd)
   55.37 +XEN_ALLOC(xen_vbd_record)
   55.38 +XEN_SET_ALLOC_FREE(xen_vbd_record)
   55.39 +XEN_ALLOC(xen_vbd_record_opt)
   55.40 +XEN_RECORD_OPT_FREE(xen_vbd)
   55.41 +XEN_SET_ALLOC_FREE(xen_vbd_record_opt)
   55.42 +
   55.43 +
   55.44 +static const struct_member xen_vbd_record_struct_members[] =
   55.45 +    {
   55.46 +        { .key = "uuid",
   55.47 +          .type = &abstract_type_string,
   55.48 +          .offset = offsetof(xen_vbd_record, uuid) },
   55.49 +        { .key = "vm",
   55.50 +          .type = &abstract_type_ref,
   55.51 +          .offset = offsetof(xen_vbd_record, vm) },
   55.52 +        { .key = "vdi",
   55.53 +          .type = &abstract_type_ref,
   55.54 +          .offset = offsetof(xen_vbd_record, vdi) },
   55.55 +        { .key = "device",
   55.56 +          .type = &abstract_type_string,
   55.57 +          .offset = offsetof(xen_vbd_record, device) },
   55.58 +        { .key = "mode",
   55.59 +          .type = &xen_vbd_mode_abstract_type_,
   55.60 +          .offset = offsetof(xen_vbd_record, mode) },
   55.61 +        { .key = "driver",
   55.62 +          .type = &xen_driver_type_abstract_type_,
   55.63 +          .offset = offsetof(xen_vbd_record, driver) },
   55.64 +        { .key = "io_bandwidth_incoming_kbs",
   55.65 +          .type = &abstract_type_float,
   55.66 +          .offset = offsetof(xen_vbd_record, io_bandwidth_incoming_kbs) },
   55.67 +        { .key = "io_bandwidth_outgoing_kbs",
   55.68 +          .type = &abstract_type_float,
   55.69 +          .offset = offsetof(xen_vbd_record, io_bandwidth_outgoing_kbs) }
   55.70 +    };
   55.71 +
   55.72 +const abstract_type xen_vbd_record_abstract_type_ =
   55.73 +    {
   55.74 +       .typename = STRUCT,
   55.75 +       .struct_size = sizeof(xen_vbd_record),
   55.76 +       .member_count =
   55.77 +           sizeof(xen_vbd_record_struct_members) / sizeof(struct_member),
   55.78 +       .members = xen_vbd_record_struct_members
   55.79 +    };
   55.80 +
   55.81 +
   55.82 +void
   55.83 +xen_vbd_record_free(xen_vbd_record *record)
   55.84 +{
   55.85 +    free(record->handle);
   55.86 +    free(record->uuid);
   55.87 +    xen_vm_record_opt_free(record->vm);
   55.88 +    xen_vdi_record_opt_free(record->vdi);
   55.89 +    free(record->device);
   55.90 +    free(record);
   55.91 +}
   55.92 +
   55.93 +
   55.94 +bool
   55.95 +xen_vbd_get_record(xen_session *session, xen_vbd_record **result, xen_vbd vbd)
   55.96 +{
   55.97 +    abstract_value param_values[] =
   55.98 +        {
   55.99 +            { .type = &abstract_type_string,
  55.100 +              .u.string_val = vbd }
  55.101 +        };
  55.102 +
  55.103 +    abstract_type result_type = xen_vbd_record_abstract_type_;
  55.104 +
  55.105 +    *result = NULL;
  55.106 +    XEN_CALL_("VBD.get_record");
  55.107 +
  55.108 +    if (session->ok)
  55.109 +    {
  55.110 +       (*result)->handle = xen_strdup_((*result)->uuid);
  55.111 +    }
  55.112 +
  55.113 +    return session->ok;
  55.114 +}
  55.115 +
  55.116 +
  55.117 +bool
  55.118 +xen_vbd_get_by_uuid(xen_session *session, xen_vbd *result, char *uuid)
  55.119 +{
  55.120 +    abstract_value param_values[] =
  55.121 +        {
  55.122 +            { .type = &abstract_type_string,
  55.123 +              .u.string_val = uuid }
  55.124 +        };
  55.125 +
  55.126 +    abstract_type result_type = abstract_type_string;
  55.127 +
  55.128 +    *result = NULL;
  55.129 +    XEN_CALL_("VBD.get_by_uuid");
  55.130 +    return session->ok;
  55.131 +}
  55.132 +
  55.133 +
  55.134 +bool
  55.135 +xen_vbd_create(xen_session *session, xen_vbd *result, xen_vbd_record *record)
  55.136 +{
  55.137 +    abstract_value param_values[] =
  55.138 +        {
  55.139 +            { .type = &xen_vbd_record_abstract_type_,
  55.140 +              .u.struct_val = record }
  55.141 +        };
  55.142 +
  55.143 +    abstract_type result_type = abstract_type_string;
  55.144 +
  55.145 +    *result = NULL;
  55.146 +    XEN_CALL_("VBD.create");
  55.147 +    return session->ok;
  55.148 +}
  55.149 +
  55.150 +
  55.151 +bool
  55.152 +xen_vbd_get_vm(xen_session *session, xen_vm *result, xen_vbd vbd)
  55.153 +{
  55.154 +    abstract_value param_values[] =
  55.155 +        {
  55.156 +            { .type = &abstract_type_string,
  55.157 +              .u.string_val = vbd }
  55.158 +        };
  55.159 +
  55.160 +    abstract_type result_type = abstract_type_string;
  55.161 +
  55.162 +    *result = NULL;
  55.163 +    XEN_CALL_("VBD.get_vm");
  55.164 +    return session->ok;
  55.165 +}
  55.166 +
  55.167 +
  55.168 +bool
  55.169 +xen_vbd_get_vdi(xen_session *session, xen_vdi *result, xen_vbd vbd)
  55.170 +{
  55.171 +    abstract_value param_values[] =
  55.172 +        {
  55.173 +            { .type = &abstract_type_string,
  55.174 +              .u.string_val = vbd }
  55.175 +        };
  55.176 +
  55.177 +    abstract_type result_type = abstract_type_string;
  55.178 +
  55.179 +    *result = NULL;
  55.180 +    XEN_CALL_("VBD.get_vdi");
  55.181 +    return session->ok;
  55.182 +}
  55.183 +
  55.184 +
  55.185 +bool
  55.186 +xen_vbd_get_device(xen_session *session, char **result, xen_vbd vbd)
  55.187 +{
  55.188 +    abstract_value param_values[] =
  55.189 +        {
  55.190 +            { .type = &abstract_type_string,
  55.191 +              .u.string_val = vbd }
  55.192 +        };
  55.193 +
  55.194 +    abstract_type result_type = abstract_type_string;
  55.195 +
  55.196 +    *result = NULL;
  55.197 +    XEN_CALL_("VBD.get_device");
  55.198 +    return session->ok;
  55.199 +}
  55.200 +
  55.201 +
  55.202 +bool
  55.203 +xen_vbd_get_mode(xen_session *session, enum xen_vbd_mode *result, xen_vbd vbd)
  55.204 +{
  55.205 +    abstract_value param_values[] =
  55.206 +        {
  55.207 +            { .type = &abstract_type_string,
  55.208 +              .u.string_val = vbd }
  55.209 +        };
  55.210 +
  55.211 +    abstract_type result_type = xen_vbd_mode_abstract_type_;
  55.212 +    char *result_str = NULL;
  55.213 +    XEN_CALL_("VBD.get_mode");
  55.214 +    *result = xen_vbd_mode_from_string(session, result_str);
  55.215 +    return session->ok;
  55.216 +}
  55.217 +
  55.218 +
  55.219 +bool
  55.220 +xen_vbd_get_driver(xen_session *session, enum xen_driver_type *result, xen_vbd vbd)
  55.221 +{
  55.222 +    abstract_value param_values[] =
  55.223 +        {
  55.224 +            { .type = &abstract_type_string,
  55.225 +              .u.string_val = vbd }
  55.226 +        };
  55.227 +
  55.228 +    abstract_type result_type = xen_driver_type_abstract_type_;
  55.229 +    char *result_str = NULL;
  55.230 +    XEN_CALL_("VBD.get_driver");
  55.231 +    *result = xen_driver_type_from_string(session, result_str);
  55.232 +    return session->ok;
  55.233 +}
  55.234 +
  55.235 +
  55.236 +bool
  55.237 +xen_vbd_get_io_bandwidth_incoming_kbs(xen_session *session, double *result, xen_vbd vbd)
  55.238 +{
  55.239 +    abstract_value param_values[] =
  55.240 +        {
  55.241 +            { .type = &abstract_type_string,
  55.242 +              .u.string_val = vbd }
  55.243 +        };
  55.244 +
  55.245 +    abstract_type result_type = abstract_type_float;
  55.246 +
  55.247 +    XEN_CALL_("VBD.get_io_bandwidth_incoming_kbs");
  55.248 +    return session->ok;
  55.249 +}
  55.250 +
  55.251 +
  55.252 +bool
  55.253 +xen_vbd_get_io_bandwidth_outgoing_kbs(xen_session *session, double *result, xen_vbd vbd)
  55.254 +{
  55.255 +    abstract_value param_values[] =
  55.256 +        {
  55.257 +            { .type = &abstract_type_string,
  55.258 +              .u.string_val = vbd }
  55.259 +        };
  55.260 +
  55.261 +    abstract_type result_type = abstract_type_float;
  55.262 +
  55.263 +    XEN_CALL_("VBD.get_io_bandwidth_outgoing_kbs");
  55.264 +    return session->ok;
  55.265 +}
  55.266 +
  55.267 +
  55.268 +bool
  55.269 +xen_vbd_set_vm(xen_session *session, xen_vbd xen_vbd, xen_vm vm)
  55.270 +{
  55.271 +    abstract_value param_values[] =
  55.272 +        {
  55.273 +            { .type = &abstract_type_string,
  55.274 +              .u.string_val = xen_vbd },
  55.275 +            { .type = &abstract_type_string,
  55.276 +              .u.string_val = vm }
  55.277 +        };
  55.278 +
  55.279 +    xen_call_(session, "VBD.set_vm", param_values, 2, NULL, NULL);
  55.280 +    return session->ok;
  55.281 +}
  55.282 +
  55.283 +
  55.284 +bool
  55.285 +xen_vbd_set_vdi(xen_session *session, xen_vbd xen_vbd, xen_vdi vdi)
  55.286 +{
  55.287 +    abstract_value param_values[] =
  55.288 +        {
  55.289 +            { .type = &abstract_type_string,
  55.290 +              .u.string_val = xen_vbd },
  55.291 +            { .type = &abstract_type_string,
  55.292 +              .u.string_val = vdi }
  55.293 +        };
  55.294 +
  55.295 +    xen_call_(session, "VBD.set_vdi", param_values, 2, NULL, NULL);
  55.296 +    return session->ok;
  55.297 +}
  55.298 +
  55.299 +
  55.300 +bool
  55.301 +xen_vbd_set_device(xen_session *session, xen_vbd xen_vbd, char *device)
  55.302 +{
  55.303 +    abstract_value param_values[] =
  55.304 +        {
  55.305 +            { .type = &abstract_type_string,
  55.306 +              .u.string_val = xen_vbd },
  55.307 +            { .type = &abstract_type_string,
  55.308 +              .u.string_val = device }
  55.309 +        };
  55.310 +
  55.311 +    xen_call_(session, "VBD.set_device", param_values, 2, NULL, NULL);
  55.312 +    return session->ok;
  55.313 +}
  55.314 +
  55.315 +
  55.316 +bool
  55.317 +xen_vbd_set_mode(xen_session *session, xen_vbd xen_vbd, enum xen_vbd_mode mode)
  55.318 +{
  55.319 +    abstract_value param_values[] =
  55.320 +        {
  55.321 +            { .type = &abstract_type_string,
  55.322 +              .u.string_val = xen_vbd },
  55.323 +            { .type = &xen_vbd_mode_abstract_type_,
  55.324 +              .u.string_val = xen_vbd_mode_to_string(mode) }
  55.325 +        };
  55.326 +
  55.327 +    xen_call_(session, "VBD.set_mode", param_values, 2, NULL, NULL);
  55.328 +    return session->ok;
  55.329 +}
  55.330 +
  55.331 +
  55.332 +bool
  55.333 +xen_vbd_set_driver(xen_session *session, xen_vbd xen_vbd, enum xen_driver_type driver)
  55.334 +{
  55.335 +    abstract_value param_values[] =
  55.336 +        {
  55.337 +            { .type = &abstract_type_string,
  55.338 +              .u.string_val = xen_vbd },
  55.339 +            { .type = &xen_driver_type_abstract_type_,
  55.340 +              .u.string_val = xen_driver_type_to_string(driver) }
  55.341 +        };
  55.342 +
  55.343 +    xen_call_(session, "VBD.set_driver", param_values, 2, NULL, NULL);
  55.344 +    return session->ok;
  55.345 +}
  55.346 +
  55.347 +
  55.348 +bool
  55.349 +xen_vbd_get_uuid(xen_session *session, char **result, xen_vbd vbd)
  55.350 +{
  55.351 +    *result = session->ok ? xen_strdup_((char *)vbd) : NULL;
  55.352 +    return session->ok;
  55.353 +}
    56.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    56.2 +++ b/tools/libxen/src/xen_vbd_mode.c	Sat Oct 07 18:22:09 2006 +0100
    56.3 @@ -0,0 +1,81 @@
    56.4 +/*
    56.5 + * Copyright (c) 2006, XenSource Inc.
    56.6 + *
    56.7 + * This library is free software; you can redistribute it and/or
    56.8 + * modify it under the terms of the GNU Lesser General Public
    56.9 + * License as published by the Free Software Foundation; either
   56.10 + * version 2.1 of the License, or (at your option) any later version.
   56.11 + *
   56.12 + * This library is distributed in the hope that it will be useful,
   56.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   56.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   56.15 + * Lesser General Public License for more details.
   56.16 + *
   56.17 + * You should have received a copy of the GNU Lesser General Public
   56.18 + * License along with this library; if not, write to the Free Software
   56.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   56.20 + */
   56.21 +
   56.22 +#include <string.h>
   56.23 +
   56.24 +#include "xen_internal.h"
   56.25 +#include "xen_vbd_mode.h"
   56.26 +#include "xen_vbd_mode_internal.h"
   56.27 +
   56.28 +
   56.29 +/*
   56.30 + * Maintain this in the same order as the enum declaration!
   56.31 + */
   56.32 +static const char *lookup_table[] =
   56.33 +{
   56.34 +    "RO",
   56.35 +    "RW"
   56.36 +};
   56.37 +
   56.38 +
   56.39 +extern xen_vbd_mode_set *
   56.40 +xen_vbd_mode_set_alloc(size_t size)
   56.41 +{
   56.42 +    return calloc(1, sizeof(xen_vbd_mode_set) +
   56.43 +                  size * sizeof(enum xen_vbd_mode));
   56.44 +}
   56.45 +
   56.46 +
   56.47 +extern void
   56.48 +xen_vbd_mode_set_free(xen_vbd_mode_set *set)
   56.49 +{
   56.50 +    free(set);
   56.51 +}
   56.52 +
   56.53 +
   56.54 +const char *
   56.55 +xen_vbd_mode_to_string(enum xen_vbd_mode val)
   56.56 +{
   56.57 +    return lookup_table[val];
   56.58 +}
   56.59 +
   56.60 +
   56.61 +extern enum xen_vbd_mode
   56.62 +xen_vbd_mode_from_string(xen_session *session, const char *str)
   56.63 +{
   56.64 +    return ENUM_LOOKUP(session, str, lookup_table);
   56.65 +}
   56.66 +
   56.67 +
   56.68 +const abstract_type xen_vbd_mode_abstract_type_ =
   56.69 +    {
   56.70 +        .typename = ENUM,
   56.71 +        .enum_marshaller =
   56.72 +             (const char *(*)(int))&xen_vbd_mode_to_string,
   56.73 +        .enum_demarshaller =
   56.74 +             (int (*)(xen_session *, const char *))&xen_vbd_mode_from_string
   56.75 +    };
   56.76 +
   56.77 +
   56.78 +const abstract_type xen_vbd_mode_set_abstract_type_ =
   56.79 +    {
   56.80 +        .typename = SET,
   56.81 +        .child = &xen_vbd_mode_abstract_type_
   56.82 +    };
   56.83 +
   56.84 +
    57.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    57.2 +++ b/tools/libxen/src/xen_vdi.c	Sat Oct 07 18:22:09 2006 +0100
    57.3 @@ -0,0 +1,499 @@
    57.4 +/*
    57.5 + * Copyright (c) 2006, XenSource Inc.
    57.6 + *
    57.7 + * This library is free software; you can redistribute it and/or
    57.8 + * modify it under the terms of the GNU Lesser General Public
    57.9 + * License as published by the Free Software Foundation; either
   57.10 + * version 2.1 of the License, or (at your option) any later version.
   57.11 + *
   57.12 + * This library is distributed in the hope that it will be useful,
   57.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   57.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   57.15 + * Lesser General Public License for more details.
   57.16 + *
   57.17 + * You should have received a copy of the GNU Lesser General Public
   57.18 + * License along with this library; if not, write to the Free Software
   57.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   57.20 + */
   57.21 +
   57.22 +
   57.23 +#include <stddef.h>
   57.24 +#include <stdlib.h>
   57.25 +
   57.26 +#include "xen_common.h"
   57.27 +#include "xen_internal.h"
   57.28 +#include "xen_sr.h"
   57.29 +#include "xen_vbd.h"
   57.30 +#include "xen_vdi.h"
   57.31 +#include "xen_vdi_type_internal.h"
   57.32 +
   57.33 +
   57.34 +XEN_FREE(xen_vdi)
   57.35 +XEN_SET_ALLOC_FREE(xen_vdi)
   57.36 +XEN_ALLOC(xen_vdi_record)
   57.37 +XEN_SET_ALLOC_FREE(xen_vdi_record)
   57.38 +XEN_ALLOC(xen_vdi_record_opt)
   57.39 +XEN_RECORD_OPT_FREE(xen_vdi)
   57.40 +XEN_SET_ALLOC_FREE(xen_vdi_record_opt)
   57.41 +
   57.42 +
   57.43 +static const struct_member xen_vdi_record_struct_members[] =
   57.44 +    {
   57.45 +        { .key = "uuid",
   57.46 +          .type = &abstract_type_string,
   57.47 +          .offset = offsetof(xen_vdi_record, uuid) },
   57.48 +        { .key = "name_label",
   57.49 +          .type = &abstract_type_string,
   57.50 +          .offset = offsetof(xen_vdi_record, name_label) },
   57.51 +        { .key = "name_description",
   57.52 +          .type = &abstract_type_string,
   57.53 +          .offset = offsetof(xen_vdi_record, name_description) },
   57.54 +        { .key = "sr",
   57.55 +          .type = &abstract_type_ref,
   57.56 +          .offset = offsetof(xen_vdi_record, sr) },
   57.57 +        { .key = "vbds",
   57.58 +          .type = &abstract_type_ref_set,
   57.59 +          .offset = offsetof(xen_vdi_record, vbds) },
   57.60 +        { .key = "virtual_size",
   57.61 +          .type = &abstract_type_int,
   57.62 +          .offset = offsetof(xen_vdi_record, virtual_size) },
   57.63 +        { .key = "physical_utilisation",
   57.64 +          .type = &abstract_type_int,
   57.65 +          .offset = offsetof(xen_vdi_record, physical_utilisation) },
   57.66 +        { .key = "sector_size",
   57.67 +          .type = &abstract_type_int,
   57.68 +          .offset = offsetof(xen_vdi_record, sector_size) },
   57.69 +        { .key = "type",
   57.70 +          .type = &xen_vdi_type_abstract_type_,
   57.71 +          .offset = offsetof(xen_vdi_record, type) },
   57.72 +        { .key = "parent",
   57.73 +          .type = &abstract_type_ref,
   57.74 +          .offset = offsetof(xen_vdi_record, parent) },
   57.75 +        { .key = "children",
   57.76 +          .type = &abstract_type_ref_set,
   57.77 +          .offset = offsetof(xen_vdi_record, children) },
   57.78 +        { .key = "sharable",
   57.79 +          .type = &abstract_type_bool,
   57.80 +          .offset = offsetof(xen_vdi_record, sharable) },
   57.81 +        { .key = "read_only",
   57.82 +          .type = &abstract_type_bool,
   57.83 +          .offset = offsetof(xen_vdi_record, read_only) }
   57.84 +    };
   57.85 +
   57.86 +const abstract_type xen_vdi_record_abstract_type_ =
   57.87 +    {
   57.88 +       .typename = STRUCT,
   57.89 +       .struct_size = sizeof(xen_vdi_record),
   57.90 +       .member_count =
   57.91 +           sizeof(xen_vdi_record_struct_members) / sizeof(struct_member),
   57.92 +       .members = xen_vdi_record_struct_members
   57.93 +    };
   57.94 +
   57.95 +
   57.96 +void
   57.97 +xen_vdi_record_free(xen_vdi_record *record)
   57.98 +{
   57.99 +    free(record->handle);
  57.100 +    free(record->uuid);
  57.101 +    free(record->name_label);
  57.102 +    free(record->name_description);
  57.103 +    xen_sr_record_opt_free(record->sr);
  57.104 +    xen_vbd_record_opt_set_free(record->vbds);
  57.105 +    xen_vdi_record_opt_free(record->parent);
  57.106 +    xen_vdi_record_opt_set_free(record->children);
  57.107 +    free(record);
  57.108 +}
  57.109 +
  57.110 +
  57.111 +bool
  57.112 +xen_vdi_get_record(xen_session *session, xen_vdi_record **result, xen_vdi vdi)
  57.113 +{
  57.114 +    abstract_value param_values[] =
  57.115 +        {
  57.116 +            { .type = &abstract_type_string,
  57.117 +              .u.string_val = vdi }
  57.118 +        };
  57.119 +
  57.120 +    abstract_type result_type = xen_vdi_record_abstract_type_;
  57.121 +
  57.122 +    *result = NULL;
  57.123 +    XEN_CALL_("VDI.get_record");
  57.124 +
  57.125 +    if (session->ok)
  57.126 +    {
  57.127 +       (*result)->handle = xen_strdup_((*result)->uuid);
  57.128 +    }
  57.129 +
  57.130 +    return session->ok;
  57.131 +}
  57.132 +
  57.133 +
  57.134 +bool
  57.135 +xen_vdi_get_by_uuid(xen_session *session, xen_vdi *result, char *uuid)
  57.136 +{
  57.137 +    abstract_value param_values[] =
  57.138 +        {
  57.139 +            { .type = &abstract_type_string,
  57.140 +              .u.string_val = uuid }
  57.141 +        };
  57.142 +
  57.143 +    abstract_type result_type = abstract_type_string;
  57.144 +
  57.145 +    *result = NULL;
  57.146 +    XEN_CALL_("VDI.get_by_uuid");
  57.147 +    return session->ok;
  57.148 +}
  57.149 +
  57.150 +
  57.151 +bool
  57.152 +xen_vdi_create(xen_session *session, xen_vdi *result, xen_vdi_record *record)
  57.153 +{
  57.154 +    abstract_value param_values[] =
  57.155 +        {
  57.156 +            { .type = &xen_vdi_record_abstract_type_,
  57.157 +              .u.struct_val = record }
  57.158 +        };
  57.159 +
  57.160 +    abstract_type result_type = abstract_type_string;
  57.161 +
  57.162 +    *result = NULL;
  57.163 +    XEN_CALL_("VDI.create");
  57.164 +    return session->ok;
  57.165 +}
  57.166 +
  57.167 +
  57.168 +bool
  57.169 +xen_vdi_get_by_name_label(xen_session *session, xen_vdi *result, char *label)
  57.170 +{
  57.171 +    abstract_value param_values[] =
  57.172 +        {
  57.173 +            { .type = &abstract_type_string,
  57.174 +              .u.string_val = label }
  57.175 +        };
  57.176 +
  57.177 +    abstract_type result_type = abstract_type_string;
  57.178 +
  57.179 +    *result = NULL;
  57.180 +    XEN_CALL_("VDI.get_by_name_label");
  57.181 +    return session->ok;
  57.182 +}
  57.183 +
  57.184 +
  57.185 +bool
  57.186 +xen_vdi_get_name_label(xen_session *session, char **result, xen_vdi vdi)
  57.187 +{
  57.188 +    abstract_value param_values[] =
  57.189 +        {
  57.190 +            { .type = &abstract_type_string,
  57.191 +              .u.string_val = vdi }
  57.192 +        };
  57.193 +
  57.194 +    abstract_type result_type = abstract_type_string;
  57.195 +
  57.196 +    *result = NULL;
  57.197 +    XEN_CALL_("VDI.get_name_label");
  57.198 +    return session->ok;
  57.199 +}
  57.200 +
  57.201 +
  57.202 +bool
  57.203 +xen_vdi_get_name_description(xen_session *session, char **result, xen_vdi vdi)
  57.204 +{
  57.205 +    abstract_value param_values[] =
  57.206 +        {
  57.207 +            { .type = &abstract_type_string,
  57.208 +              .u.string_val = vdi }
  57.209 +        };
  57.210 +
  57.211 +    abstract_type result_type = abstract_type_string;
  57.212 +
  57.213 +    *result = NULL;
  57.214 +    XEN_CALL_("VDI.get_name_description");
  57.215 +    return session->ok;
  57.216 +}
  57.217 +
  57.218 +
  57.219 +bool
  57.220 +xen_vdi_get_sr(xen_session *session, xen_sr *result, xen_vdi vdi)
  57.221 +{
  57.222 +    abstract_value param_values[] =
  57.223 +        {
  57.224 +            { .type = &abstract_type_string,
  57.225 +              .u.string_val = vdi }
  57.226 +        };
  57.227 +
  57.228 +    abstract_type result_type = abstract_type_string;
  57.229 +
  57.230 +    *result = NULL;
  57.231 +    XEN_CALL_("VDI.get_sr");
  57.232 +    return session->ok;
  57.233 +}
  57.234 +
  57.235 +
  57.236 +bool
  57.237 +xen_vdi_get_vbds(xen_session *session, xen_vbd *result, xen_vdi vdi)
  57.238 +{
  57.239 +    abstract_value param_values[] =
  57.240 +        {
  57.241 +            { .type = &abstract_type_string,
  57.242 +              .u.string_val = vdi }
  57.243 +        };
  57.244 +
  57.245 +    abstract_type result_type = abstract_type_string_set;
  57.246 +
  57.247 +    *result = NULL;
  57.248 +    XEN_CALL_("VDI.get_vbds");
  57.249 +    return session->ok;
  57.250 +}
  57.251 +
  57.252 +
  57.253 +bool
  57.254 +xen_vdi_get_virtual_size(xen_session *session, uint64_t *result, xen_vdi vdi)
  57.255 +{
  57.256 +    abstract_value param_values[] =
  57.257 +        {
  57.258 +            { .type = &abstract_type_string,
  57.259 +              .u.string_val = vdi }
  57.260 +        };
  57.261 +
  57.262 +    abstract_type result_type = abstract_type_int;
  57.263 +
  57.264 +    XEN_CALL_("VDI.get_virtual_size");
  57.265 +    return session->ok;
  57.266 +}
  57.267 +
  57.268 +
  57.269 +bool
  57.270 +xen_vdi_get_physical_utilisation(xen_session *session, uint64_t *result, xen_vdi vdi)
  57.271 +{
  57.272 +    abstract_value param_values[] =
  57.273 +        {
  57.274 +            { .type = &abstract_type_string,
  57.275 +              .u.string_val = vdi }
  57.276 +        };
  57.277 +
  57.278 +    abstract_type result_type = abstract_type_int;
  57.279 +
  57.280 +    XEN_CALL_("VDI.get_physical_utilisation");
  57.281 +    return session->ok;
  57.282 +}
  57.283 +
  57.284 +
  57.285 +bool
  57.286 +xen_vdi_get_sector_size(xen_session *session, uint64_t *result, xen_vdi vdi)
  57.287 +{
  57.288 +    abstract_value param_values[] =
  57.289 +        {
  57.290 +            { .type = &abstract_type_string,
  57.291 +              .u.string_val = vdi }
  57.292 +        };
  57.293 +
  57.294 +    abstract_type result_type = abstract_type_int;
  57.295 +
  57.296 +    XEN_CALL_("VDI.get_sector_size");
  57.297 +    return session->ok;
  57.298 +}
  57.299 +
  57.300 +
  57.301 +bool
  57.302 +xen_vdi_get_type(xen_session *session, enum xen_vdi_type *result, xen_vdi vdi)
  57.303 +{
  57.304 +    abstract_value param_values[] =
  57.305 +        {
  57.306 +            { .type = &abstract_type_string,
  57.307 +              .u.string_val = vdi }
  57.308 +        };
  57.309 +
  57.310 +    abstract_type result_type = xen_vdi_type_abstract_type_;
  57.311 +    char *result_str = NULL;
  57.312 +    XEN_CALL_("VDI.get_type");
  57.313 +    *result = xen_vdi_type_from_string(session, result_str);
  57.314 +    return session->ok;
  57.315 +}
  57.316 +
  57.317 +
  57.318 +bool
  57.319 +xen_vdi_get_parent(xen_session *session, xen_vdi *result, xen_vdi vdi)
  57.320 +{
  57.321 +    abstract_value param_values[] =
  57.322 +        {
  57.323 +            { .type = &abstract_type_string,
  57.324 +              .u.string_val = vdi }
  57.325 +        };
  57.326 +
  57.327 +    abstract_type result_type = abstract_type_string;
  57.328 +
  57.329 +    *result = NULL;
  57.330 +    XEN_CALL_("VDI.get_parent");
  57.331 +    return session->ok;
  57.332 +}
  57.333 +
  57.334 +
  57.335 +bool
  57.336 +xen_vdi_get_children(xen_session *session, xen_vdi *result, xen_vdi vdi)
  57.337 +{
  57.338 +    abstract_value param_values[] =
  57.339 +        {
  57.340 +            { .type = &abstract_type_string,
  57.341 +              .u.string_val = vdi }
  57.342 +        };
  57.343 +
  57.344 +    abstract_type result_type = abstract_type_string_set;
  57.345 +
  57.346 +    *result = NULL;
  57.347 +    XEN_CALL_("VDI.get_children");
  57.348 +    return session->ok;
  57.349 +}
  57.350 +
  57.351 +
  57.352 +bool
  57.353 +xen_vdi_get_sharable(xen_session *session, bool *result, xen_vdi vdi)
  57.354 +{
  57.355 +    abstract_value param_values[] =
  57.356 +        {
  57.357 +            { .type = &abstract_type_string,
  57.358 +              .u.string_val = vdi }
  57.359 +        };
  57.360 +
  57.361 +    abstract_type result_type = abstract_type_bool;
  57.362 +
  57.363 +    XEN_CALL_("VDI.get_sharable");
  57.364 +    return session->ok;
  57.365 +}
  57.366 +
  57.367 +
  57.368 +bool
  57.369 +xen_vdi_get_read_only(xen_session *session, bool *result, xen_vdi vdi)
  57.370 +{
  57.371 +    abstract_value param_values[] =
  57.372 +        {
  57.373 +            { .type = &abstract_type_string,
  57.374 +              .u.string_val = vdi }
  57.375 +        };
  57.376 +
  57.377 +    abstract_type result_type = abstract_type_bool;
  57.378 +
  57.379 +    XEN_CALL_("VDI.get_read_only");
  57.380 +    return session->ok;
  57.381 +}
  57.382 +
  57.383 +
  57.384 +bool
  57.385 +xen_vdi_set_name_label(xen_session *session, xen_vdi xen_vdi, char *label)
  57.386 +{
  57.387 +    abstract_value param_values[] =
  57.388 +        {
  57.389 +            { .type = &abstract_type_string,
  57.390 +              .u.string_val = xen_vdi },
  57.391 +            { .type = &abstract_type_string,
  57.392 +              .u.string_val = label }
  57.393 +        };
  57.394 +
  57.395 +    xen_call_(session, "VDI.set_name_label", param_values, 2, NULL, NULL);
  57.396 +    return session->ok;
  57.397 +}
  57.398 +
  57.399 +
  57.400 +bool
  57.401 +xen_vdi_set_name_description(xen_session *session, xen_vdi xen_vdi, char *description)
  57.402 +{
  57.403 +    abstract_value param_values[] =
  57.404 +        {
  57.405 +            { .type = &abstract_type_string,
  57.406 +              .u.string_val = xen_vdi },
  57.407 +            { .type = &abstract_type_string,
  57.408 +              .u.string_val = description }
  57.409 +        };
  57.410 +
  57.411 +    xen_call_(session, "VDI.set_name_description", param_values, 2, NULL, NULL);
  57.412 +    return session->ok;
  57.413 +}
  57.414 +
  57.415 +
  57.416 +bool
  57.417 +xen_vdi_set_sr(xen_session *session, xen_vdi xen_vdi, xen_sr sr)
  57.418 +{
  57.419 +    abstract_value param_values[] =
  57.420 +        {
  57.421 +            { .type = &abstract_type_string,
  57.422 +              .u.string_val = xen_vdi },
  57.423 +            { .type = &abstract_type_string,
  57.424 +              .u.string_val = sr }
  57.425 +        };
  57.426 +
  57.427 +    xen_call_(session, "VDI.set_sr", param_values, 2, NULL, NULL);
  57.428 +    return session->ok;
  57.429 +}
  57.430 +
  57.431 +
  57.432 +bool
  57.433 +xen_vdi_set_virtual_size(xen_session *session, xen_vdi xen_vdi, uint64_t virtual_size)
  57.434 +{
  57.435 +    abstract_value param_values[] =
  57.436 +        {
  57.437 +            { .type = &abstract_type_string,
  57.438 +              .u.string_val = xen_vdi },
  57.439 +            { .type = &abstract_type_int,
  57.440 +              .u.int_val = virtual_size }
  57.441 +        };
  57.442 +
  57.443 +    xen_call_(session, "VDI.set_virtual_size", param_values, 2, NULL, NULL);
  57.444 +    return session->ok;
  57.445 +}
  57.446 +
  57.447 +
  57.448 +bool
  57.449 +xen_vdi_set_sharable(xen_session *session, xen_vdi xen_vdi, bool sharable)
  57.450 +{
  57.451 +    abstract_value param_values[] =
  57.452 +        {
  57.453 +            { .type = &abstract_type_string,
  57.454 +              .u.string_val = xen_vdi },
  57.455 +            { .type = &abstract_type_bool,
  57.456 +              .u.bool_val = sharable }
  57.457 +        };
  57.458 +
  57.459 +    xen_call_(session, "VDI.set_sharable", param_values, 2, NULL, NULL);
  57.460 +    return session->ok;
  57.461 +}
  57.462 +
  57.463 +
  57.464 +bool
  57.465 +xen_vdi_set_read_only(xen_session *session, xen_vdi xen_vdi, bool read_only)
  57.466 +{
  57.467 +    abstract_value param_values[] =
  57.468 +        {
  57.469 +            { .type = &abstract_type_string,
  57.470 +              .u.string_val = xen_vdi },
  57.471 +            { .type = &abstract_type_bool,
  57.472 +              .u.bool_val = read_only }
  57.473 +        };
  57.474 +
  57.475 +    xen_call_(session, "VDI.set_read_only", param_values, 2, NULL, NULL);
  57.476 +    return session->ok;
  57.477 +}
  57.478 +
  57.479 +
  57.480 +bool
  57.481 +xen_vdi_snapshot(xen_session *session, xen_vdi *result, xen_vdi vdi)
  57.482 +{
  57.483 +    abstract_value param_values[] =
  57.484 +        {
  57.485 +            { .type = &abstract_type_string,
  57.486 +              .u.string_val = vdi }
  57.487 +        };
  57.488 +
  57.489 +    abstract_type result_type = abstract_type_string;
  57.490 +
  57.491 +    *result = NULL;
  57.492 +    XEN_CALL_("VDI.snapshot");
  57.493 +    return session->ok;
  57.494 +}
  57.495 +
  57.496 +
  57.497 +bool
  57.498 +xen_vdi_get_uuid(xen_session *session, char **result, xen_vdi vdi)
  57.499 +{
  57.500 +    *result = session->ok ? xen_strdup_((char *)vdi) : NULL;
  57.501 +    return session->ok;
  57.502 +}
    58.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    58.2 +++ b/tools/libxen/src/xen_vdi_type.c	Sat Oct 07 18:22:09 2006 +0100
    58.3 @@ -0,0 +1,82 @@
    58.4 +/*
    58.5 + * Copyright (c) 2006, XenSource Inc.
    58.6 + *
    58.7 + * This library is free software; you can redistribute it and/or
    58.8 + * modify it under the terms of the GNU Lesser General Public
    58.9 + * License as published by the Free Software Foundation; either
   58.10 + * version 2.1 of the License, or (at your option) any later version.
   58.11 + *
   58.12 + * This library is distributed in the hope that it will be useful,
   58.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   58.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   58.15 + * Lesser General Public License for more details.
   58.16 + *
   58.17 + * You should have received a copy of the GNU Lesser General Public
   58.18 + * License along with this library; if not, write to the Free Software
   58.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   58.20 + */
   58.21 +
   58.22 +#include <string.h>
   58.23 +
   58.24 +#include "xen_internal.h"
   58.25 +#include "xen_vdi_type.h"
   58.26 +#include "xen_vdi_type_internal.h"
   58.27 +
   58.28 +
   58.29 +/*
   58.30 + * Maintain this in the same order as the enum declaration!
   58.31 + */
   58.32 +static const char *lookup_table[] =
   58.33 +{
   58.34 +    "system",
   58.35 +    "user",
   58.36 +    "ephemeral"
   58.37 +};
   58.38 +
   58.39 +
   58.40 +extern xen_vdi_type_set *
   58.41 +xen_vdi_type_set_alloc(size_t size)
   58.42 +{
   58.43 +    return calloc(1, sizeof(xen_vdi_type_set) +
   58.44 +                  size * sizeof(enum xen_vdi_type));
   58.45 +}
   58.46 +
   58.47 +
   58.48 +extern void
   58.49 +xen_vdi_type_set_free(xen_vdi_type_set *set)
   58.50 +{
   58.51 +    free(set);
   58.52 +}
   58.53 +
   58.54 +
   58.55 +const char *
   58.56 +xen_vdi_type_to_string(enum xen_vdi_type val)
   58.57 +{
   58.58 +    return lookup_table[val];
   58.59 +}
   58.60 +
   58.61 +
   58.62 +extern enum xen_vdi_type
   58.63 +xen_vdi_type_from_string(xen_session *session, const char *str)
   58.64 +{
   58.65 +    return ENUM_LOOKUP(session, str, lookup_table);
   58.66 +}
   58.67 +
   58.68 +
   58.69 +const abstract_type xen_vdi_type_abstract_type_ =
   58.70 +    {
   58.71 +        .typename = ENUM,
   58.72 +        .enum_marshaller =
   58.73 +             (const char *(*)(int))&xen_vdi_type_to_string,
   58.74 +        .enum_demarshaller =
   58.75 +             (int (*)(xen_session *, const char *))&xen_vdi_type_from_string
   58.76 +    };
   58.77 +
   58.78 +
   58.79 +const abstract_type xen_vdi_type_set_abstract_type_ =
   58.80 +    {
   58.81 +        .typename = SET,
   58.82 +        .child = &xen_vdi_type_abstract_type_
   58.83 +    };
   58.84 +
   58.85 +
    59.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    59.2 +++ b/tools/libxen/src/xen_vif.c	Sat Oct 07 18:22:09 2006 +0100
    59.3 @@ -0,0 +1,460 @@
    59.4 +/*
    59.5 + * Copyright (c) 2006, XenSource Inc.
    59.6 + *
    59.7 + * This library is free software; you can redistribute it and/or
    59.8 + * modify it under the terms of the GNU Lesser General Public
    59.9 + * License as published by the Free Software Foundation; either
   59.10 + * version 2.1 of the License, or (at your option) any later version.
   59.11 + *
   59.12 + * This library is distributed in the hope that it will be useful,
   59.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   59.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   59.15 + * Lesser General Public License for more details.
   59.16 + *
   59.17 + * You should have received a copy of the GNU Lesser General Public
   59.18 + * License along with this library; if not, write to the Free Software
   59.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   59.20 + */
   59.21 +
   59.22 +
   59.23 +#include <stddef.h>
</