---
.gitignore | 5 +
AUTHORS | 1 +
COPYING | 510 ++++++++++++
COPYING.LIB | 510 ------------
Makefile.am | 19 -
README.in | 28 -
autogen.sh | 70 --
build.properties | 4 +
build.xml | 82 ++
config.h.in | 58 --
configure.in | 172 ----
doc/.cvsignore | 1 -
doc/Makefile.am | 29 -
libvirt-java.pc.in | 12 -
libvirt-java.spec.in | 57 +-
src/Makefile.am | 66 --
src/jni/.cvsignore | 8 -
src/jni/ConnectAuthCallbackBridge.c | 71 --
src/jni/ConnectAuthCallbackBridge.h | 9 -
src/jni/ErrorHandler.c | 119 ---
src/jni/ErrorHandler.h | 3 -
src/jni/Makefile.am | 54 --
src/jni/generic.h | 180 ----
src/jni/org_libvirt_Connect.c | 363 --------
src/jni/org_libvirt_Domain.c | 581 -------------
src/jni/org_libvirt_Network.c | 59 --
src/jni/org_libvirt_StoragePool.c | 117 ---
src/jni/org_libvirt_StorageVol.c | 65 --
src/main/java/org/libvirt/.cvsignore | 1 +
src/main/java/org/libvirt/Connect.java | 878 ++++++++++++++++++++
src/main/java/org/libvirt/ConnectAuth.java | 153 ++++
src/main/java/org/libvirt/ConnectAuthDefault.java | 59 ++
src/main/java/org/libvirt/Domain.java | 655 +++++++++++++++
src/main/java/org/libvirt/DomainBlockStats.java | 28 +
src/main/java/org/libvirt/DomainInfo.java | 89 ++
.../java/org/libvirt/DomainInterfaceStats.java | 36 +
src/main/java/org/libvirt/Error.java | 473 +++++++++++
src/main/java/org/libvirt/ErrorException.java | 15 +
src/main/java/org/libvirt/ErrorHandler.java | 32 +
src/main/java/org/libvirt/LibvirtException.java | 31 +
src/main/java/org/libvirt/Network.java | 217 +++++
src/main/java/org/libvirt/NodeInfo.java | 61 ++
.../java/org/libvirt/SchedBooleanParameter.java | 40 +
.../java/org/libvirt/SchedDoubleParameter.java | 35 +
src/main/java/org/libvirt/SchedIntParameter.java | 26 +
src/main/java/org/libvirt/SchedLongParameter.java | 36 +
src/main/java/org/libvirt/SchedParameter.java | 72 ++
src/main/java/org/libvirt/SchedUintParameter.java | 36 +
src/main/java/org/libvirt/SchedUlongParameter.java | 35 +
src/main/java/org/libvirt/StoragePool.java | 325 ++++++++
src/main/java/org/libvirt/StoragePoolInfo.java | 79 ++
src/main/java/org/libvirt/StorageVol.java | 183 ++++
src/main/java/org/libvirt/StorageVolInfo.java | 59 ++
src/main/java/org/libvirt/VcpuInfo.java | 26 +
.../java/org/libvirt/jna/ConnectionPointer.java | 7 +
src/main/java/org/libvirt/jna/DomainPointer.java | 7 +
src/main/java/org/libvirt/jna/Libvirt.java | 162 ++++
src/main/java/org/libvirt/jna/NetworkPointer.java | 7 +
.../java/org/libvirt/jna/StoragePoolPointer.java | 7 +
.../java/org/libvirt/jna/StorageVolPointer.java | 7 +
src/main/java/org/libvirt/jna/virConnectAuth.java | 11 +
.../java/org/libvirt/jna/virConnectCredential.java | 12 +
.../java/org/libvirt/jna/virDomainBlockStats.java | 12 +
src/main/java/org/libvirt/jna/virDomainInfo.java | 13 +
.../org/libvirt/jna/virDomainInterfaceStats.java | 16 +
src/main/java/org/libvirt/jna/virError.java | 20 +
src/main/java/org/libvirt/jna/virNodeInfo.java | 19 +
.../java/org/libvirt/jna/virSchedParameter.java | 11 +
.../org/libvirt/jna/virSchedParameterValue.java | 13 +
.../java/org/libvirt/jna/virStoragePoolInfo.java | 11 +
.../java/org/libvirt/jna/virStorageVolInfo.java | 11 +
src/main/java/org/libvirt/jna/virVcpuInfo.java | 12 +
src/org/libvirt/.cvsignore | 1 -
src/org/libvirt/Connect.java | 878 --------------------
src/org/libvirt/ConnectAuth.java | 153 ----
src/org/libvirt/ConnectAuthDefault.java | 59 --
src/org/libvirt/Domain.java | 655 ---------------
src/org/libvirt/DomainBlockStats.java | 28 -
src/org/libvirt/DomainInfo.java | 89 --
src/org/libvirt/DomainInterfaceStats.java | 36 -
src/org/libvirt/Error.java | 473 -----------
src/org/libvirt/ErrorException.java | 15 -
src/org/libvirt/ErrorHandler.java | 32 -
src/org/libvirt/LibvirtException.java | 31 -
src/org/libvirt/Network.java | 217 -----
src/org/libvirt/NodeInfo.java | 61 --
src/org/libvirt/SchedBooleanParameter.java | 40 -
src/org/libvirt/SchedDoubleParameter.java | 35 -
src/org/libvirt/SchedIntParameter.java | 26 -
src/org/libvirt/SchedLongParameter.java | 36 -
src/org/libvirt/SchedParameter.java | 72 --
src/org/libvirt/SchedUintParameter.java | 36 -
src/org/libvirt/SchedUlongParameter.java | 35 -
src/org/libvirt/StoragePool.java | 325 --------
src/org/libvirt/StoragePoolInfo.java | 79 --
src/org/libvirt/StorageVol.java | 183 ----
src/org/libvirt/StorageVolInfo.java | 59 --
src/org/libvirt/VcpuInfo.java | 26 -
src/org/libvirt/jna/ConnectionPointer.java | 7 -
src/org/libvirt/jna/DomainPointer.java | 7 -
src/org/libvirt/jna/Libvirt.java | 162 ----
src/org/libvirt/jna/NetworkPointer.java | 7 -
src/org/libvirt/jna/StoragePoolPointer.java | 7 -
src/org/libvirt/jna/StorageVolPointer.java | 7 -
src/org/libvirt/jna/virConnectAuth.java | 11 -
src/org/libvirt/jna/virConnectCredential.java | 12 -
src/org/libvirt/jna/virDomainBlockStats.java | 12 -
src/org/libvirt/jna/virDomainInfo.java | 13 -
src/org/libvirt/jna/virDomainInterfaceStats.java | 16 -
src/org/libvirt/jna/virError.java | 20 -
src/org/libvirt/jna/virNodeInfo.java | 19 -
src/org/libvirt/jna/virSchedParameter.java | 11 -
src/org/libvirt/jna/virSchedParameterValue.java | 13 -
src/org/libvirt/jna/virStoragePoolInfo.java | 11 -
src/org/libvirt/jna/virStorageVolInfo.java | 11 -
src/org/libvirt/jna/virVcpuInfo.java | 12 -
src/test.java | 269 ------
src/test/java/test.java | 269 ++++++
test.sh | 4 +
119 files changed, 4931 insertions(+), 6940 deletions(-)
create mode 100644 .gitignore
create mode 100644 COPYING
delete mode 100644 COPYING.LIB
delete mode 100644 Makefile.am
delete mode 100644 README.in
delete mode 100755 autogen.sh
create mode 100644 build.properties
create mode 100644 build.xml
delete mode 100644 config.h.in
delete mode 100644 configure.in
delete mode 100644 doc/.cvsignore
delete mode 100644 doc/Makefile.am
delete mode 100644 libvirt-java.pc.in
delete mode 100644 src/Makefile.am
delete mode 100644 src/jni/.cvsignore
delete mode 100644 src/jni/ConnectAuthCallbackBridge.c
delete mode 100644 src/jni/ConnectAuthCallbackBridge.h
delete mode 100644 src/jni/ErrorHandler.c
delete mode 100644 src/jni/ErrorHandler.h
delete mode 100644 src/jni/Makefile.am
delete mode 100644 src/jni/generic.h
delete mode 100644 src/jni/org_libvirt_Connect.c
delete mode 100644 src/jni/org_libvirt_Domain.c
delete mode 100644 src/jni/org_libvirt_Network.c
delete mode 100644 src/jni/org_libvirt_StoragePool.c
delete mode 100644 src/jni/org_libvirt_StorageVol.c
create mode 100644 src/main/java/org/libvirt/.cvsignore
create mode 100644 src/main/java/org/libvirt/Connect.java
create mode 100644 src/main/java/org/libvirt/ConnectAuth.java
create mode 100644 src/main/java/org/libvirt/ConnectAuthDefault.java
create mode 100644 src/main/java/org/libvirt/Domain.java
create mode 100644 src/main/java/org/libvirt/DomainBlockStats.java
create mode 100644 src/main/java/org/libvirt/DomainInfo.java
create mode 100644 src/main/java/org/libvirt/DomainInterfaceStats.java
create mode 100644 src/main/java/org/libvirt/Error.java
create mode 100644 src/main/java/org/libvirt/ErrorException.java
create mode 100644 src/main/java/org/libvirt/ErrorHandler.java
create mode 100644 src/main/java/org/libvirt/LibvirtException.java
create mode 100644 src/main/java/org/libvirt/Network.java
create mode 100644 src/main/java/org/libvirt/NodeInfo.java
create mode 100644 src/main/java/org/libvirt/SchedBooleanParameter.java
create mode 100644 src/main/java/org/libvirt/SchedDoubleParameter.java
create mode 100644 src/main/java/org/libvirt/SchedIntParameter.java
create mode 100644 src/main/java/org/libvirt/SchedLongParameter.java
create mode 100644 src/main/java/org/libvirt/SchedParameter.java
create mode 100644 src/main/java/org/libvirt/SchedUintParameter.java
create mode 100644 src/main/java/org/libvirt/SchedUlongParameter.java
create mode 100644 src/main/java/org/libvirt/StoragePool.java
create mode 100644 src/main/java/org/libvirt/StoragePoolInfo.java
create mode 100644 src/main/java/org/libvirt/StorageVol.java
create mode 100644 src/main/java/org/libvirt/StorageVolInfo.java
create mode 100644 src/main/java/org/libvirt/VcpuInfo.java
create mode 100644 src/main/java/org/libvirt/jna/ConnectionPointer.java
create mode 100644 src/main/java/org/libvirt/jna/DomainPointer.java
create mode 100644 src/main/java/org/libvirt/jna/Libvirt.java
create mode 100644 src/main/java/org/libvirt/jna/NetworkPointer.java
create mode 100644 src/main/java/org/libvirt/jna/StoragePoolPointer.java
create mode 100644 src/main/java/org/libvirt/jna/StorageVolPointer.java
create mode 100644 src/main/java/org/libvirt/jna/virConnectAuth.java
create mode 100644 src/main/java/org/libvirt/jna/virConnectCredential.java
create mode 100644 src/main/java/org/libvirt/jna/virDomainBlockStats.java
create mode 100644 src/main/java/org/libvirt/jna/virDomainInfo.java
create mode 100644 src/main/java/org/libvirt/jna/virDomainInterfaceStats.java
create mode 100644 src/main/java/org/libvirt/jna/virError.java
create mode 100644 src/main/java/org/libvirt/jna/virNodeInfo.java
create mode 100644 src/main/java/org/libvirt/jna/virSchedParameter.java
create mode 100644 src/main/java/org/libvirt/jna/virSchedParameterValue.java
create mode 100644 src/main/java/org/libvirt/jna/virStoragePoolInfo.java
create mode 100644 src/main/java/org/libvirt/jna/virStorageVolInfo.java
create mode 100644 src/main/java/org/libvirt/jna/virVcpuInfo.java
delete mode 100644 src/org/libvirt/.cvsignore
delete mode 100644 src/org/libvirt/Connect.java
delete mode 100644 src/org/libvirt/ConnectAuth.java
delete mode 100644 src/org/libvirt/ConnectAuthDefault.java
delete mode 100644 src/org/libvirt/Domain.java
delete mode 100644 src/org/libvirt/DomainBlockStats.java
delete mode 100644 src/org/libvirt/DomainInfo.java
delete mode 100644 src/org/libvirt/DomainInterfaceStats.java
delete mode 100644 src/org/libvirt/Error.java
delete mode 100644 src/org/libvirt/ErrorException.java
delete mode 100644 src/org/libvirt/ErrorHandler.java
delete mode 100644 src/org/libvirt/LibvirtException.java
delete mode 100644 src/org/libvirt/Network.java
delete mode 100644 src/org/libvirt/NodeInfo.java
delete mode 100644 src/org/libvirt/SchedBooleanParameter.java
delete mode 100644 src/org/libvirt/SchedDoubleParameter.java
delete mode 100644 src/org/libvirt/SchedIntParameter.java
delete mode 100644 src/org/libvirt/SchedLongParameter.java
delete mode 100644 src/org/libvirt/SchedParameter.java
delete mode 100644 src/org/libvirt/SchedUintParameter.java
delete mode 100644 src/org/libvirt/SchedUlongParameter.java
delete mode 100644 src/org/libvirt/StoragePool.java
delete mode 100644 src/org/libvirt/StoragePoolInfo.java
delete mode 100644 src/org/libvirt/StorageVol.java
delete mode 100644 src/org/libvirt/StorageVolInfo.java
delete mode 100644 src/org/libvirt/VcpuInfo.java
delete mode 100644 src/org/libvirt/jna/ConnectionPointer.java
delete mode 100644 src/org/libvirt/jna/DomainPointer.java
delete mode 100644 src/org/libvirt/jna/Libvirt.java
delete mode 100644 src/org/libvirt/jna/NetworkPointer.java
delete mode 100644 src/org/libvirt/jna/StoragePoolPointer.java
delete mode 100644 src/org/libvirt/jna/StorageVolPointer.java
delete mode 100644 src/org/libvirt/jna/virConnectAuth.java
delete mode 100644 src/org/libvirt/jna/virConnectCredential.java
delete mode 100644 src/org/libvirt/jna/virDomainBlockStats.java
delete mode 100644 src/org/libvirt/jna/virDomainInfo.java
delete mode 100644 src/org/libvirt/jna/virDomainInterfaceStats.java
delete mode 100644 src/org/libvirt/jna/virError.java
delete mode 100644 src/org/libvirt/jna/virNodeInfo.java
delete mode 100644 src/org/libvirt/jna/virSchedParameter.java
delete mode 100644 src/org/libvirt/jna/virSchedParameterValue.java
delete mode 100644 src/org/libvirt/jna/virStoragePoolInfo.java
delete mode 100644 src/org/libvirt/jna/virStorageVolInfo.java
delete mode 100644 src/org/libvirt/jna/virVcpuInfo.java
delete mode 100644 src/test.java
create mode 100644 src/test/java/test.java
create mode 100755 test.sh
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..9f0382d
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,5 @@
+.classpath
+.project
+.settings
+target
+
diff --git a/AUTHORS b/AUTHORS
index d5655d2..64a4ca4 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -6,3 +6,4 @@ Patches provided by:
Daniel Schwager <Daniel.Schwager(a)dtnet.de>
Thomas Fricke <libvirt(a)thomasfricke.de>
David Lively <dlively(a)virtualiron.com>
+Bryan Kearney <bkearney(a)redhat.com>
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..cf9b6b9
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,510 @@
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations
+below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+^L
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it
+becomes a de-facto standard. To achieve this, non-free programs must
+be allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+^L
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control
+compilation and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+^L
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+^L
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at least
+ three years, to give the same user the materials specified in
+ Subsection 6a, above, for a charge no more than the cost of
+ performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+^L
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+^L
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply, and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License
+may add an explicit geographical distribution limitation excluding those
+countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+^L
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+^L
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms
+of the ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library.
+It is safest to attach them to the start of each source file to most
+effectively convey the exclusion of warranty; and each file should
+have at least the "copyright" line and a pointer to where the full
+notice is found.
+
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or
+your school, if any, to sign a "copyright disclaimer" for the library,
+if necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James
+ Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+
diff --git a/COPYING.LIB b/COPYING.LIB
deleted file mode 100644
index cf9b6b9..0000000
--- a/COPYING.LIB
+++ /dev/null
@@ -1,510 +0,0 @@
-
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the Lesser GPL. It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.]
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
- This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it. You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations
-below.
-
- When we speak of free software, we are referring to freedom of use,
-not price. Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
- To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights. These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
- For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you. You must make sure that they, too, receive or can get the source
-code. If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it. And you must show them these terms so they know their rights.
-
- We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
- To protect each distributor, we want to make it very clear that
-there is no warranty for the free library. Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-^L
- Finally, software patents pose a constant threat to the existence of
-any free program. We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder. Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
- Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License. This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License. We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
- When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library. The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom. The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
- We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License. It also provides other free software developers Less
-of an advantage over competing non-free programs. These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries. However, the Lesser license provides advantages in certain
-special circumstances.
-
- For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it
-becomes a de-facto standard. To achieve this, non-free programs must
-be allowed to use the library. A more frequent case is that a free
-library does the same job as widely used non-free libraries. In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
- In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software. For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
- Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
- The precise terms and conditions for copying, distribution and
-modification follow. Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library". The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-^L
- GNU LESSER GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
- A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
- The "Library", below, refers to any such software library or work
-which has been distributed under these terms. A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language. (Hereinafter, translation is
-included without limitation in the term "modification".)
-
- "Source code" for a work means the preferred form of the work for
-making modifications to it. For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control
-compilation and installation of the library.
-
- Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it). Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
- 1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
- You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-
- 2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) The modified work must itself be a software library.
-
- b) You must cause the files modified to carry prominent notices
- stating that you changed the files and the date of any change.
-
- c) You must cause the whole of the work to be licensed at no
- charge to all third parties under the terms of this License.
-
- d) If a facility in the modified Library refers to a function or a
- table of data to be supplied by an application program that uses
- the facility, other than as an argument passed when the facility
- is invoked, then you must make a good faith effort to ensure that,
- in the event an application does not supply such function or
- table, the facility still operates, and performs whatever part of
- its purpose remains meaningful.
-
- (For example, a function in a library to compute square roots has
- a purpose that is entirely well-defined independent of the
- application. Therefore, Subsection 2d requires that any
- application-supplied function or table used by this function must
- be optional: if the application does not supply it, the square
- root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library. To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License. (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.) Do not make any other change in
-these notices.
-^L
- Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
- This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
- 4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
- If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library". Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
- However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library". The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
- When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library. The
-threshold for this to be true is not precisely defined by law.
-
- If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work. (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
- Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-^L
- 6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
- You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License. You must supply a copy of this License. If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License. Also, you must do one
-of these things:
-
- a) Accompany the work with the complete corresponding
- machine-readable source code for the Library including whatever
- changes were used in the work (which must be distributed under
- Sections 1 and 2 above); and, if the work is an executable linked
- with the Library, with the complete machine-readable "work that
- uses the Library", as object code and/or source code, so that the
- user can modify the Library and then relink to produce a modified
- executable containing the modified Library. (It is understood
- that the user who changes the contents of definitions files in the
- Library will not necessarily be able to recompile the application
- to use the modified definitions.)
-
- b) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (1) uses at run time a
- copy of the library already present on the user's computer system,
- rather than copying library functions into the executable, and (2)
- will operate properly with a modified version of the library, if
- the user installs one, as long as the modified version is
- interface-compatible with the version that the work was made with.
-
- c) Accompany the work with a written offer, valid for at least
- three years, to give the same user the materials specified in
- Subsection 6a, above, for a charge no more than the cost of
- performing this distribution.
-
- d) If distribution of the work is made by offering access to copy
- from a designated place, offer equivalent access to copy the above
- specified materials from the same place.
-
- e) Verify that the user has already received a copy of these
- materials or that you have already sent this user a copy.
-
- For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it. However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
- It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system. Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-^L
- 7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
- a) Accompany the combined library with a copy of the same work
- based on the Library, uncombined with any other library
- facilities. This must be distributed under the terms of the
- Sections above.
-
- b) Give prominent notice with the combined library of the fact
- that part of it is a work based on the Library, and explaining
- where to find the accompanying uncombined form of the same work.
-
- 8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License. Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License. However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
- 9. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Library or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
- 10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-^L
- 11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all. For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply, and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License
-may add an explicit geographical distribution limitation excluding those
-countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation. If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-^L
- 14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission. For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this. Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
- NO WARRANTY
-
- 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
- END OF TERMS AND CONDITIONS
-^L
- How to Apply These Terms to Your New Libraries
-
- If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change. You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms
-of the ordinary General Public License).
-
- To apply these terms, attach the following notices to the library.
-It is safest to attach them to the start of each source file to most
-effectively convey the exclusion of warranty; and each file should
-have at least the "copyright" line and a pointer to where the full
-notice is found.
-
-
- <one line to give the library's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or
-your school, if any, to sign a "copyright disclaimer" for the library,
-if necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the
- library `Frob' (a library for tweaking knobs) written by James
- Random Hacker.
-
- <signature of Ty Coon>, 1 April 1990
- Ty Coon, President of Vice
-
-That's all there is to it!
-
-
diff --git a/Makefile.am b/Makefile.am
deleted file mode 100644
index d8084a0..0000000
--- a/Makefile.am
+++ /dev/null
@@ -1,19 +0,0 @@
-SUBDIRS=src doc
-
-EXTRA_DIST = \
- libvirt-java.pc.in \
- libvirt-java.spec.in \
- libvirt-java.spec \
- autogen.sh \
- INSTALL \
- README.in \
- README
-
-pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = libvirt-java.pc
-
-cleantar:
- @(rm -f libxml*.tar.gz && rm -f COPYING && cp COPYING.LIB COPYING)
-
-rpm: clean cleantar
- @(unset CDPATH ; $(MAKE) dist && rpmbuild -ta $(distdir).tar.gz)
diff --git a/README.in b/README.in
deleted file mode 100644
index f2a2ea0..0000000
--- a/README.in
+++ /dev/null
@@ -1,28 +0,0 @@
- This is the java binding to the libvirt library.
-
-To use it, your program needs to access both the java library (.jar file),
-and the JNI library (.so file)
-
-1. You must have the libvirt.jar file in your classpath.
-By default the installs it to @prefix@/share/java/libvirt-@VERSION@.jar
-
-2. You must have the libvirt_jni.so accessible by the dynamic linker.
-By default the RPM installs it to /usr/lib or /usr/lib64, so the linker will
-find it automatically. If it's in a different location, you have to set
-the LD_LIBRARY_PATH variable to the directory containing the libvirt_jni.so
-file.
-
-There is a rudimentary functional test program that the libvirt-java-devel
-installs put it into @prefix@/share/doc/libvirt-java-devel-@VERSION(a)/test.java
-
-To run it, first copy the test.java file to writeable directory
-cp @prefix@/share/doc/libvirt-java-devel-@VERSION(a)/test.java ~
-
-Compile the java file to a class:
-javac -classpath @prefix@/share/java/libvirt-@VERSION@.jar test.java
-
-Then run the program:
-java -classpath .:@prefix@/share/java/libvirt-@VERSION@.jar test
-
-There is full javadoc for the API in @prefix@/share/javadoc/libvirt-java-@VERSION@/
-
diff --git a/autogen.sh b/autogen.sh
deleted file mode 100755
index cc8110e..0000000
--- a/autogen.sh
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/bin/sh
-# Run this to generate all the initial makefiles, etc.
-
-srcdir=`dirname $0`
-test -z "$srcdir" && srcdir=.
-
-THEDIR=`pwd`
-cd $srcdir
-DIE=0
-
-AUTOMAKE=automake
-if [ "`uname`" = "SunOs" ] ; then
- AUTOMAKE=automake-1.10
-fi
-
-(autoconf --version) < /dev/null > /dev/null 2>&1 || {
- echo
- echo "You must have autoconf installed to compile libvirt-java."
- echo "Download the appropriate package for your distribution,"
- echo "or see
http://www.gnu.org/software/autoconf"
- DIE=1
-}
-
-(libtool --version) < /dev/null > /dev/null 2>&1 || {
- echo
- echo "You must have libtool installed to compile libvirt-java."
- echo "Download the appropriate package for your distribution,"
- echo "or see
http://www.gnu.org/software/libtool"
- DIE=1
-}
-
-($AUTOMAKE --version) < /dev/null > /dev/null 2>&1 || {
- echo
- DIE=1
- echo "You must have automake installed to compile libvirt."
- echo "Download the appropriate package for your distribution,"
- echo "or see
http://www.gnu.org/software/automake"
-}
-
-if test "$DIE" -eq 1; then
- exit 1
-fi
-
-test -f src/jni/org_libvirt_Domain.c || {
- echo "You must run this script in the top-level libvirt directory"
- exit 1
-}
-
-if test -z "$*"; then
- echo "I am going to run ./configure with no arguments - if you wish "
- echo "to pass any to it, please specify them on the $0 command line."
-fi
-
-libtoolize --copy --force
-aclocal
-autoheader
-automake --add-missing
-autoconf
-
-cd $THEDIR
-
-if test x$OBJ_DIR != x; then
- mkdir -p "$OBJ_DIR"
- cd "$OBJ_DIR"
-fi
-
-$srcdir/configure "$@" && {
- echo
- echo "Now type 'make' to compile libvirt."
-}
diff --git a/build.properties b/build.properties
new file mode 100644
index 0000000..557a972
--- /dev/null
+++ b/build.properties
@@ -0,0 +1,4 @@
+version=0.3.0pre
+libvirt.required=0.4.1
+java.required=1:1.6.0
+rpm.topdir=/home/bkearney/rpmbuild
diff --git a/build.xml b/build.xml
new file mode 100644
index 0000000..e1ee51f
--- /dev/null
+++ b/build.xml
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="Libvirt Java Bindings" default="build">
+ <property file="build.properties"/>
+ <property name="jar" value="libvirt-${version}"/>
+ <property name="jar.file" value="target/${jar}.jar"/>
+ <property name="src" value="libvirt-java-${version}"/>
+ <property name="src.file" value="target/${src}.tar.gz"/>
+ <property name="spec" value="libvirt-java.spec"/>
+ <property name="spec.file" value="target/${spec}"/>
+
+ <path id="compile.classpath">
+ <fileset dir="/usr/share/java">
+ <include name="jna.jar"/>
+ </fileset>
+ </path>
+
+ <path id="test.classpath">
+ <fileset dir="/usr/share/java">
+ <include name="jna.jar"/>
+ </fileset>
+ <pathelement location="target/classes"/>
+ </path>
+
+ <target name="init">
+ <mkdir dir="target/classes"/>
+ <mkdir dir="target/testclasses"/>
+ </target>
+
+ <target name="clean">
+ <delete dir="target"/>
+ </target>
+
+ <target name="build" depends="init">
+ <javac srcdir="src/main/java"
+ includes="**/*.java"
+ classpathref="compile.classpath"
+ destdir="target/classes"/>
+ <javac srcdir="src/test/java"
+ includes="**/*.java"
+ classpathref="test.classpath"
+ destdir="target/testclasses"/>
+ <jar destfile="${jar.file}"
+ basedir="target/classes"/>
+ </target>
+
+ <target name="docs" depends="build">
+ <mkdir dir="target/javadoc"/>
+ <javadoc sourcepath="src"
+ classpathref="compile.classpath"
+ destdir="target/javadoc"/>
+ </target>
+
+ <target name="src" depends="init">
+ <mkdir dir="target/libvirt-java-${version}"/>
+ <copy todir="target/libvirt-java-${version}">
+ <fileset dir="."
excludes="target/**,.gitignore,.git/**,.*,.*/**"/>
+ </copy>
+ <tar basedir="target"
+ includes="libvirt-java-${version}/**"
+ compression="gzip"
+ destfile="${src.file}"/>
+ </target>
+
+ <target name="spec" depends="init">
+ <copy file="libvirt-java.spec.in"
+ tofile="${spec.file}"
+ overwrite="true"
+ filtering="true">
+ <filterset filtersfile="build.properties"/>
+ </copy>
+ </target>
+
+ <target name="package" depends="src,build,docs,spec">
+ <copy file="${src.file}" todir="${rpm.topdir}/SOURCES"/>
+ <copy file="${spec.file}" todir="${rpm.topdir}/SPECS"/>
+ <rpm specfile="${spec}"
+ command="-ba"
+ topdir="${rpm.topdir}"/>
+ </target>
+
+
+</project>
diff --git a/config.h.in b/config.h.in
deleted file mode 100644
index f2383b8..0000000
--- a/config.h.in
+++ /dev/null
@@ -1,58 +0,0 @@
-/* config.h.in. Generated from configure.in by autoheader. */
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#undef HAVE_DLFCN_H
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#undef HAVE_INTTYPES_H
-
-/* Define to 1 if you have the <memory.h> header file. */
-#undef HAVE_MEMORY_H
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#undef HAVE_STDINT_H
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#undef HAVE_STDLIB_H
-
-/* Define to 1 if you have the <strings.h> header file. */
-#undef HAVE_STRINGS_H
-
-/* Define to 1 if you have the <string.h> header file. */
-#undef HAVE_STRING_H
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#undef HAVE_SYS_STAT_H
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#undef HAVE_SYS_TYPES_H
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#undef HAVE_UNISTD_H
-
-/* Define to 1 if your C compiler doesn't accept -c and -o together. */
-#undef NO_MINUS_C_MINUS_O
-
-/* Name of package */
-#undef PACKAGE
-
-/* Define to the address where bug reports for this package should be sent. */
-#undef PACKAGE_BUGREPORT
-
-/* Define to the full name of this package. */
-#undef PACKAGE_NAME
-
-/* Define to the full name and version of this package. */
-#undef PACKAGE_STRING
-
-/* Define to the one symbol short name of this package. */
-#undef PACKAGE_TARNAME
-
-/* Define to the version of this package. */
-#undef PACKAGE_VERSION
-
-/* Define to 1 if you have the ANSI C header files. */
-#undef STDC_HEADERS
-
-/* Version number of package */
-#undef VERSION
diff --git a/configure.in b/configure.in
deleted file mode 100644
index 6edc1da..0000000
--- a/configure.in
+++ /dev/null
@@ -1,172 +0,0 @@
-dnl
-dnl configure file for libvirt java bindings
-dnl Process this file with autoconf to produce a configure script.
-dnl
-dnl Copyright (C) Red Hat, Inc.
-dnl
-dnl See COPYING.LIB for the License of this software
-dnl
-dnl Daniel Veillard <veillard(a)redhat.com>
-dnl
-AC_INIT([libvirt-java], [0.2.1])
-AC_CONFIG_SRCDIR([src/jni/org_libvirt_Domain.c])
-AC_CONFIG_AUX_DIR(.)
-AC_CONFIG_HEADER([config.h])
-AM_INIT_AUTOMAKE([-Wno-portability])
-AC_CANONICAL_HOST
-
-LIBVIRT_REQUIRED="0.4.1"
-
-JNI_MAJOR_VERSION=`echo $VERSION | awk -F. '{print $1}'`
-JNI_MINOR_VERSION=`echo $VERSION | awk -F. '{print $2}'`
-JNI_MICRO_VERSION=`echo $VERSION | awk -F. '{print $3}'`
-JNI_VERSION_INFO=`expr $JNI_MAJOR_VERSION +
$JNI_MINOR_VERSION`:$JNI_MICRO_VERSION:$JNI_MINOR_VERSION
-JNI_VERSION_NUMBER=`expr $JNI_MAJOR_VERSION \* 1000000 + $JNI_MINOR_VERSION \* 1000 +
$JNI_MICRO_VERSION`
-
-AC_SUBST([JNI_MAJOR_VERSION])
-AC_SUBST([JNI_MINOR_VERSION])
-AC_SUBST([JNI_MICRO_VERSION])
-AC_SUBST([JNI_VERSION])
-AC_SUBST([JNI_VERSION_INFO])
-AC_SUBST([JNI_VERSION_NUMBER])
-
-AC_SUBST([LIBVIRT_REQUIRED])
-
-AC_PROG_CC
-AC_PROG_INSTALL
-AM_PROG_CC_C_O
-
-AC_DISABLE_STATIC
-dnl Support building Win32 DLLs (must appear *before* AM_PROG_LIBTOOL)
-AC_LIBTOOL_WIN32_DLL
-AM_PROG_LIBTOOL
-
-INSTALLED_JAR_DIR=\${prefix}/share/java
-INSTALLED_JNI_DIR=\${prefix}/lib/
-AC_SUBST(INSTALLED_JAR_DIR)
-AC_SUBST(INSTALLED_JNI_DIR)
-
-PKG_CHECK_MODULES(LIBVIRT, libvirt >= $LIBVIRT_REQUIRED)
-AC_SUBST(LIBVIRT_CFLAGS)
-AC_SUBST(LIBVIRT_LIBS)
-
-dnl
-dnl allow the user to specify the version of java either with
-dnl --with-java-home or with JAVA_HOME env variable.
-dnl
-AC_ARG_WITH(java_home,
-[ --with-java-home=DIR path to the Java Development Kit
directory(/usr/lib/jvm/java)])
-
-if test x"$with_java_home" != x"no" -a x"$with_java_home"
!= x"yes" ; then
- if test -d $with_java_home ; then
- JAVA_HOME=$with_java_home
- else
- AC_MSG_ERROR([provided JAVA_HOME $with_java_home is not a directory])
- fi
-fi
-if test x"$JAVA_HOME" == x"" ; then
- JAVA_HOME=/usr/lib/jvm/java
-fi
-
-AC_MSG_CHECKING(for JDK in $JAVA_HOME)
-if test ! -d $JAVA_HOME ; then
- AC_MSG_ERROR([JAVA_HOME $JAVA_HOME is not a directory])
-fi
-
-if test ! -x $JAVA_HOME/bin/java ; then
- AC_MSG_ERROR([missing $JAVA_HOME/bin/java binary])
-else
- JAVA=$JAVA_HOME/bin/java
-fi
-if test ! -x $JAVA_HOME/bin/javac ; then
- AC_MSG_ERROR([missing $JAVA_HOME/bin/javac binary])
-else
- JAVAC=$JAVA_HOME/bin/javac
-fi
-if test ! -x $JAVA_HOME/bin/javah ; then
- AC_MSG_ERROR([missing $JAVA_HOME/bin/javah binary])
-else
- JAVAH=$JAVA_HOME/bin/javah
-fi
-if test ! -x $JAVA_HOME/bin/javadoc ; then
- AC_MSG_ERROR([missing $JAVA_HOME/bin/javadoc binary])
-else
- JAVADOC=$JAVA_HOME/bin/javadoc
-fi
-if test ! -x $JAVA_HOME/bin/jar ; then
- AC_MSG_ERROR([missing $JAVA_HOME/bin/jar binary])
-else
- JAR=$JAVA_HOME/bin/jar
-fi
-
-java_version=`java -version 2>&1 | grep version`
-AC_MSG_RESULT(found $java_version)
-
-AC_SUBST(JAVA_HOME)
-AC_SUBST(JAVA)
-AC_SUBST(JAVAH)
-AC_SUBST(JAVAC)
-AC_SUBST(JAVADOC)
-AC_SUBST(JAR)
-
-dnl
-dnl then find the jni.h include file usually in the include subdir
-dnl
-JNI_CFLAGS=
-
-if test -f $JAVA_HOME/include/jni.h ; then
- JNI_CFLAGS="-I$JAVA_HOME/include"
-else
-if test "`find $JAVA_HOME -name jni.h`" != "" ; then
- head=`find $JAVA_HOME -name jni.h | tail -1`
- dir=`dirname $head`
- JNI_CFLAGS="-I$dir"
-fi
-fi
-
-dnl
-dnl then one need to find jni_md.h too usually in a system specific subdir
-dnl
-case "$build_os" in
- *linux*)
- system="linux"
- ;;
- *SunOS*)
- system="solaris"
- ;;
- *cygwin*)
- system="win32"
- ;;
- *)
- system="$build_os"
- ;;
-esac
-
-if test -f $JAVA_HOME/include/$system/jni_md.h ; then
- JNI_CFLAGS="$JNI_CFLAGS -I$JAVA_HOME/include/$system"
-else
-if test "`find $JAVA_HOME -name jni_md.h`" != "" ; then
- head=`find $JAVA_HOME -name jni_md.h | tail -1`
- dir=`dirname $head`
- JNI_CFLAGS="$JNI_CFLAGS -I$dir"
-fi
-fi
-AC_SUBST(JNI_CFLAGS)
-
-dnl
-dnl Depending on the JAVAC version used one may need additional version flag
-dnl
-JAVAC_FLAGS=
-javac_version=`$JAVAC -version 2>&1`
-case "$javac_version" in
- *Eclipse*)
- JAVAC_FLAGS="-source 1.5"
- ;;
-esac
-AC_SUBST(JAVAC_FLAGS)
-
-# very annoying
-rm -f COPYING
-cp COPYING.LIB COPYING
-
-AC_OUTPUT(Makefile README src/Makefile src/jni/Makefile doc/Makefile libvirt-java.pc
libvirt-java.spec)
diff --git a/doc/.cvsignore b/doc/.cvsignore
deleted file mode 100644
index eedd89b..0000000
--- a/doc/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-api
diff --git a/doc/Makefile.am b/doc/Makefile.am
deleted file mode 100644
index 31d425b..0000000
--- a/doc/Makefile.am
+++ /dev/null
@@ -1,29 +0,0 @@
-
-docdir = $(datadir)/doc/libvirt-java-$(VERSION)
-javadocdir = $(datadir)/javadoc/libvirt-java-$(VERSION)
-
-doc_DATA = $(top_srcdir)/AUTHORS $(top_srcdir)/COPYING.LIB \
- $(top_srcdir)/NEWS $(top_srcdir)/README
-
-all-local: docs
-
-docs:
- @(cd ../src && $(MAKE) docs)
-
-all_dest_javadoc_html_files = $(shell (find api/ -type f | sed 's+api/++'))
-dest_javadoc_dirs = $(shell (find api -mindepth 1 -type d | sed 's+api/++'))
-
-install-data-hook:
- $(mkinstalldirs) $(DESTDIR)$(docdir)
- @for dir in $(dest_javadoc_dirs); do \
- $(mkinstalldirs) $(DESTDIR)$(javadocdir)/$${dir}; done
- @for file in $(all_dest_javadoc_html_files); do \
- $(INSTALL_DATA) api/$${file} $(DESTDIR)$(javadocdir)/$${file}; done
-
-CLEANFILES = \
- api/resources/inherit.gif \
- api/package-list \
- api/stylesheet.css \
- $(shell find api -name '*.html') \
- ../src/doc-stamps
-
diff --git a/libvirt-java.pc.in b/libvirt-java.pc.in
deleted file mode 100644
index fd29d35..0000000
--- a/libvirt-java.pc.in
+++ /dev/null
@@ -1,12 +0,0 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-
-Name: libvirt-java
-Description: Libvirt library Java bindings
-Version: @VERSION@
-classpath=@INSTALLED_CLASSPATH@
-jnilibs=-L@libdir@ -lvirt-jni
-Libs: -L@libdir@ -lvirt-java
-Cflags:
diff --git a/libvirt-java.spec.in b/libvirt-java.spec.in
index 4c16c94..bb9afec 100644
--- a/libvirt-java.spec.in
+++ b/libvirt-java.spec.in
@@ -1,18 +1,21 @@
Summary: Java bindings for the libvirt virtualization API
Name: libvirt-java
-Version: @VERSION@
+Version: @version@
+Prefix: libvirt
Release: 1%{?dist}
License: LGPLv2+
Group: Development/Libraries
-Source:
http://libvirt.org/sources/java/libvirt-java-%{version}.tar.gz
+Source:
http://libvirt.org/sources/java/%{name}-%{version}.tar.gz
URL:
http://libvirt.org/
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
-Requires: libvirt >= @LIBVIRT_REQUIRED@
-Requires: java >= 1.5.0
+Requires: jna
+Requires: libvirt >= @libvirt.required@
+Requires: java >= @java.required@
Requires: jpackage-utils
-BuildRequires: libvirt-devel >= @LIBVIRT_REQUIRED@
-BuildRequires: java-devel >= 1.5.0
+BuildRequires: ant
+BuildRequires: jna
+BuildRequires: java-devel >= @java.required@
BuildRequires: pkgconfig
BuildRequires: jpackage-utils
@@ -25,19 +28,8 @@ BuildRequires: jpackage-utils
%description
Libvirt-java is a base framework allowing to use libvirt, the virtualization
API though the Java programming language.
-It requires libvirt >= @LIBVIRT_REQUIRED@
+It requires libvirt >= @libvirt.required@
-%package devel
-Summary: Compressed Java source files for %{name}
-Group: Development/Libraries
-Requires: %{name} = %{version}-%{release}
-Requires: libvirt-devel >= @LIBVIRT_REQUIRED@
-Requires: pkgconfig
-
-%description devel
-Libvirt-java is a base framework allowing to use libvirt, the virtualization
-API though the Java programming language. This is the development part needed
-to build applications with Libvirt-java.
%package javadoc
Summary: Java documentation for %{name}
@@ -51,24 +43,17 @@ API documentation for %{name}.
%setup -q
%build
-%configure --with-java-home=%{java_home}
-# javac call is not parallelizable, as a result the same command is
-# run N times in parallel if %{?_smp_mflags} is set up
-make
-
-# fix up the modification date of generated documentation
-find doc -type f -newer ChangeLog | xargs touch -r ChangeLog
+ant build docs
%install
rm -fr %{buildroot}
+install -d -m0755 %{buildroot}%{_javadir}
+install -d -m0755 %{buildroot}%{_javadocdir}/%{name}-%{version}
+cp target/%{prefix}-%{version}.jar %{buildroot}%{_javadir}
+%{__ln_s} %{_javadir}/%{prefix}-{version}.jar %{buildroot}%{_javadir}/%{prefix}.jar
+cp -r target/javadoc %{buildroot}%{_javadocdir}/%{name}-%{version}
-make %{?_smp_mflags} DESTDIR=$RPM_BUILD_ROOT install
-
-rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
-rm -f $RPM_BUILD_ROOT%{_libdir}/*.a
-%post -p /sbin/ldconfig
-%postun -p /sbin/ldconfig
%clean
rm -rf %{buildroot}
@@ -76,18 +61,12 @@ rm -rf %{buildroot}
%files
%defattr(-,root,root)
%doc AUTHORS COPYING NEWS README INSTALL
-%{_libdir}/libvirt_jni*.so.*
-%{_datadir}/java/*.jar
+%{_javadir}/*.jar
-%files devel
-%defattr(-,root,root)
-%doc src/*.java
-%{_libdir}/libvirt_jni*.so
-%{_libdir}/pkgconfig/*.pc
%files javadoc
%defattr(-,root,root)
-/usr/share/javadoc/%{name}-%{version}
+%{_javadocdir}/%{name}-%{version}
%changelog
* Fri Jul 18 2008 Daniel Veillard <veillard(a)redhat.com> - 0.2.0-1
diff --git a/src/Makefile.am b/src/Makefile.am
deleted file mode 100644
index 5200c1d..0000000
--- a/src/Makefile.am
+++ /dev/null
@@ -1,66 +0,0 @@
-# Build must be done in org first
-SUBDIRS=. jni
-
-java_libvirt_source_files = \
- org/libvirt/LibvirtException.java \
- org/libvirt/Connect.java \
- org/libvirt/ConnectAuthDefault.java \
- org/libvirt/ConnectAuth.java \
- org/libvirt/DomainBlockStats.java \
- org/libvirt/DomainInfo.java \
- org/libvirt/DomainInterfaceStats.java \
- org/libvirt/Domain.java \
- org/libvirt/ErrorException.java \
- org/libvirt/Error.java \
- org/libvirt/Network.java \
- org/libvirt/NodeInfo.java \
- org/libvirt/SchedBooleanParameter.java \
- org/libvirt/SchedDoubleParameter.java \
- org/libvirt/SchedIntParameter.java \
- org/libvirt/SchedLongParameter.java \
- org/libvirt/SchedParameter.java \
- org/libvirt/SchedUintParameter.java \
- org/libvirt/SchedUlongParameter.java \
- org/libvirt/VcpuInfo.java \
- org/libvirt/StoragePool.java \
- org/libvirt/StoragePoolInfo.java \
- org/libvirt/StorageVol.java \
- org/libvirt/StorageVolInfo.java
-
-EXTRA_DIST= \
- test.java \
- $(java_libvirt_source_files)
-
-libvirt_jardir = $(INSTALLED_JAR_DIR)
-libvirt_jar_DATA = libvirt-${VERSION}.jar
-
-libvirt_jar_class_files = $(java_libvirt_source_files:.java=.class)
-$(libvirt_jar_class_files): %.class: %.java
- $(JAVAC) $(JAVAC_FLAGS) -classpath "org/libvirt" org/libvirt/*.java
-
-all_jar_class_files = $(shell find org/libvirt -name '*.class' | sed
's%\$$%\\$$%g')
-
-libvirt-${VERSION}.jar: $(libvirt_jar_class_files)
- $(JAR) cf $@ $(all_jar_class_files)
-
-# running the javadoc command is better done here since we have
-# the authoritative list of java files
-
-doc-stamps: $(java_libvirt_source_files)
- $(JAVADOC) $(JAVADOC_FLAGS) -d $(top_srcdir)/doc/api \
- -sourcepath $(srcdir) \
- -windowtitle "Libvirt java $(VERSION) API Reference" \
- -doctitle "Libvirt java $(VERSION) API Reference" \
- org.libvirt
- touch doc-stamps
-
-docs: doc-stamps
-
-install-data-hook:
-
-CLEANFILES = \
- org/libvirt/*.class \
- test.class \
- libvirt-*.jar \
- doc-stamps
-
diff --git a/src/jni/.cvsignore b/src/jni/.cvsignore
deleted file mode 100644
index 4cb969d..0000000
--- a/src/jni/.cvsignore
+++ /dev/null
@@ -1,8 +0,0 @@
-org_libvirt_VirConnect.h
-org_libvirt_VirDomain.h
-org_libvirt_VirNetwork.h
-org_libvirt_VirDomain_CreateFlags.h
-org_libvirt_VirDomain_MigrateFlags.h
-org_libvirt_VirDomain_XMLFlags.h
-
-
diff --git a/src/jni/ConnectAuthCallbackBridge.c b/src/jni/ConnectAuthCallbackBridge.c
deleted file mode 100644
index 91a98dc..0000000
--- a/src/jni/ConnectAuthCallbackBridge.c
+++ /dev/null
@@ -1,71 +0,0 @@
-#include <jni.h>
-#include <libvirt/libvirt.h>
-#include <string.h>
-#include "ConnectAuthCallbackBridge.h"
-#include <assert.h>
-
-
-int ConnectAuthCallbackBridge(virConnectCredentialPtr cred, unsigned int ncred, void *
cbdata){
-
- //cbdata contains the java object that contains tha callback, as well as the JNI
environment
- JNIEnv *env = ((CallBackStructType*)cbdata)->env;
-
- jobject j_auth = ((CallBackStructType*)cbdata)->auth;
- jclass j_auth_cls = (*env)->GetObjectClass(env, j_auth);
- jmethodID j_auth_cb_id=(*env)->GetMethodID(env, (*env)->GetObjectClass(env,
j_auth), "callback", "([Lorg/libvirt/ConnectAuth$Credential;)I");
-
- jclass j_cred_cls = (*env)->FindClass(env,
"org/libvirt/ConnectAuth$Credential");
- jmethodID j_cred_constructor = (*env)->GetMethodID(env, j_cred_cls,
"<init>",
"(Lorg/libvirt/ConnectAuth;ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
- jfieldID j_cred_result_id = (*env)->GetFieldID(env, j_cred_cls, "result",
"Ljava/lang/String;");
-
- jobjectArray j_credArray = (*env)->NewObjectArray(env, ncred, j_cred_cls, NULL);
-
- //copy the credentials array to the Java object.
- int c;
- jobject j_cred;
- for(c=0; c<ncred; c++){
- j_cred=(*env)->NewObject(env,
- j_cred_cls,
- j_cred_constructor,
- j_auth,
- cred[c].type,
- (*env)->NewStringUTF(env, cred[c].prompt),
- (*env)->NewStringUTF(env, cred[c].challenge),
- (*env)->NewStringUTF(env, cred[c].defresult));
- (*env)->SetObjectArrayElement(env, j_credArray, c, j_cred);
- }
-
- //Time to call the actual java callback function
- int retval = (*env)->CallNonvirtualIntMethod(env,
- j_auth,
- j_auth_cls,
- j_auth_cb_id,
- j_credArray);
-
- if(retval){
- //The java callback function has failed, so we fail as well.
- return -1;
- }
-
- //If we are still here, the java callback returned sucessfully, so copy the results
back.
- jstring j_cred_result;
- const char* result;
-
- for(c=0; c<ncred; c++){
- j_cred = (*env)->GetObjectArrayElement(env, j_credArray, c);
- j_cred_result = (*env)->GetObjectField(env, j_cred, j_cred_result_id);
- //If this assert triggers, then the user-supplied ConnectAuth.callback function is
broken
- assert(j_cred_result);
- result = (*env)->GetStringUTFChars(env,
- j_cred_result,
- NULL);
- cred[c].result = strdup(result);
- cred[c].resultlen = strlen(result);
- (*env)->ReleaseStringUTFChars(env, j_cred_result, result);
- }
-
- //All done, back to libvirt
- return 0;
-
-}
-
diff --git a/src/jni/ConnectAuthCallbackBridge.h b/src/jni/ConnectAuthCallbackBridge.h
deleted file mode 100644
index b765b24..0000000
--- a/src/jni/ConnectAuthCallbackBridge.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <jni.h>
-#include <libvirt/libvirt.h>
-
-typedef struct {
- JNIEnv *env;
- jobject auth;
-} CallBackStructType;
-
-int ConnectAuthCallbackBridge(virConnectCredentialPtr cred, unsigned int ncred, void *
cbdata);
\ No newline at end of file
diff --git a/src/jni/ErrorHandler.c b/src/jni/ErrorHandler.c
deleted file mode 100644
index 9c92094..0000000
--- a/src/jni/ErrorHandler.c
+++ /dev/null
@@ -1,119 +0,0 @@
-#include "ErrorHandler.h"
-#include <stdio.h>
-#include <libvirt/virterror.h>
-#include <jni.h>
-
-void virErrorHandler(void *userdata, virErrorPtr error){
- JNIEnv *env=userdata;
- jclass exception_cls= (*env)->FindClass(env,
"org/libvirt/LibvirtException");
- jclass error_cls= (*env)->FindClass(env, "org/libvirt/Error");
- jobject j_error = (*env)->NewObject(env, error_cls, (*env)->GetMethodID(env,
error_cls, "<init>", "()V"));
- jobject j_exception;
-
- //Get objects for the errorNumber
- jclass
number_class=(*env)->FindClass(env,"Lorg/libvirt/Error$ErrorNumber;");
- jmethodID number_values_id=(*env)->GetStaticMethodID(env, number_class,
"values", "()[Lorg/libvirt/Error$ErrorNumber;");
- jarray number_values=(*env)->CallStaticObjectMethod(env, number_class,
number_values_id);
-
- //Ditto for errorLevel
- jclass
level_class=(*env)->FindClass(env,"Lorg/libvirt/Error$ErrorLevel;");
- jmethodID level_values_id=(*env)->GetStaticMethodID(env, level_class,
"values", "()[Lorg/libvirt/Error$ErrorLevel;");
- jarray level_values=(*env)->CallStaticObjectMethod(env, level_class,
level_values_id);
-
- //Ditto for errorDomain
- jclass
domain_class=(*env)->FindClass(env,"Lorg/libvirt/Error$ErrorDomain;");
- jmethodID domain_values_id=(*env)->GetStaticMethodID(env, domain_class,
"values", "()[Lorg/libvirt/Error$ErrorDomain;");
- jarray domain_values=(*env)->CallStaticObjectMethod(env, domain_class,
domain_values_id);
-
- //Straight copy everything
- (*env)->SetObjectField(
- env,
- j_error,
- (*env)->GetFieldID(env, error_cls, "code",
"Lorg/libvirt/Error$ErrorNumber;"),
- (*env)->GetObjectArrayElement(env, number_values, error->code));
- (*env)->SetObjectField(
- env,
- j_error,
- (*env)->GetFieldID(env, error_cls, "domain",
"Lorg/libvirt/Error$ErrorDomain;"),
- (*env)->GetObjectArrayElement(env, domain_values, error->domain));
- (*env)->SetObjectField(
- env,
- j_error,
- (*env)->GetFieldID(env, error_cls, "level",
"Lorg/libvirt/Error$ErrorLevel;"),
- (*env)->GetObjectArrayElement(env, level_values, error->level));
- (*env)->SetObjectField(
- env,
- j_error,
- (*env)->GetFieldID(env, error_cls, "message",
"Ljava/lang/String;"),
- (*env)->NewStringUTF(env, error->message));
-#if 0
-/*
- * use of those fields got deprecated
- */
- (*env)->SetLongField(
- env,
- j_error,
- (*env)->GetFieldID(env, error_cls, "VCP", "J"),
- (long)error->conn);
- (*env)->SetLongField(
- env,
- j_error,
- (*env)->GetFieldID(env, error_cls, "VDP", "J"),
- (long)error->dom);
- (*env)->SetLongField(
- env,
- j_error,
- (*env)->GetFieldID(env, error_cls, "VNP", "J"),
- (long)error->net);
-#else
- (*env)->SetLongField(
- env,
- j_error,
- (*env)->GetFieldID(env, error_cls, "VCP", "J"),
- (long)0);
- (*env)->SetLongField(
- env,
- j_error,
- (*env)->GetFieldID(env, error_cls, "VDP", "J"),
- (long)0);
- (*env)->SetLongField(
- env,
- j_error,
- (*env)->GetFieldID(env, error_cls, "VNP", "J"),
- (long)0);
-#endif
- (*env)->SetObjectField(
- env,
- j_error,
- (*env)->GetFieldID(env, error_cls, "str1",
"Ljava/lang/String;"),
- (*env)->NewStringUTF(env, error->str1));
- (*env)->SetObjectField(
- env,
- j_error,
- (*env)->GetFieldID(env, error_cls, "str2",
"Ljava/lang/String;"),
- (*env)->NewStringUTF(env, error->str2));
- (*env)->SetObjectField(
- env,
- j_error,
- (*env)->GetFieldID(env, error_cls, "str3",
"Ljava/lang/String;"),
- (*env)->NewStringUTF(env, error->str3));
- (*env)->SetIntField(
- env,
- j_error,
- (*env)->GetFieldID(env, error_cls, "int1", "I"),
- error->int1);
- (*env)->SetIntField(
- env,
- j_error,
- (*env)->GetFieldID(env, error_cls, "int2", "I"),
- error->int2);
-
- //Now we have the Error object properly initialized
- j_exception = (*env)->NewObject(env, exception_cls,
- (*env)->GetMethodID(env, exception_cls, "<init>",
"(Lorg/libvirt/Error;)V"),
- j_error);
-
- (*env)->ExceptionDescribe(env);
-
- (*env)->Throw(env, j_exception);
-}
diff --git a/src/jni/ErrorHandler.h b/src/jni/ErrorHandler.h
deleted file mode 100644
index ad1d2b3..0000000
--- a/src/jni/ErrorHandler.h
+++ /dev/null
@@ -1,3 +0,0 @@
-#include <libvirt/virterror.h>
-
-void virErrorHandler(void *, virErrorPtr);
diff --git a/src/jni/Makefile.am b/src/jni/Makefile.am
deleted file mode 100644
index c894024..0000000
--- a/src/jni/Makefile.am
+++ /dev/null
@@ -1,54 +0,0 @@
-GENERATED = \
- org_libvirt_Connect.h \
- org_libvirt_Network.h \
- org_libvirt_Domain.h \
- org_libvirt_Domain_CreateFlags.h \
- org_libvirt_Domain_MigrateFlags.h \
- org_libvirt_Domain_XMLFlags.h \
- org_libvirt_StoragePool_BuildFlags.h \
- org_libvirt_StoragePool_DeleteFlags.h \
- org_libvirt_StoragePool.h \
- org_libvirt_StorageVol_Type.h \
- org_libvirt_StorageVol_DeleteFlags.h \
- org_libvirt_StorageVol.h
-
-BUILT_SOURCES = $(GENERATED)
-
-JAVA_CLASS_ROOT=$(top_srcdir)/src
-
-org_libvirt_Connect.h : $(JAVA_CLASS_ROOT)/org/libvirt/Connect.class
- $(JAVAH) -classpath $(JAVA_CLASS_ROOT) org.libvirt.Connect
-
-org_libvirt_Network.h: $(JAVA_CLASS_ROOT)/org/libvirt/Network.class
- $(JAVAH) -classpath $(JAVA_CLASS_ROOT) org.libvirt.Network
-
-org_libvirt_Domain.h org_libvirt_Domain_CreateFlags.h org_libvirt_Domain_MigrateFlags.h
org_libvirt_Domain_XMLFlags.h : $(JAVA_CLASS_ROOT)/org/libvirt/Domain.class
- $(JAVAH) -classpath $(JAVA_CLASS_ROOT) org.libvirt.Domain
-
-org_libvirt_StoragePool.h org_libvirt_StoragePool_BuildFlags.h
org_libvirt_StoragePool_DeleteFlags.h : $(JAVA_CLASS_ROOT)/org/libvirt/StoragePool.class
- $(JAVAH) -classpath $(JAVA_CLASS_ROOT) org.libvirt.StoragePool
-
-org_libvirt_StorageVol.h org_libvirt_StorageVol_Type.h
org_libvirt_StorageVol_DeleteFlags.h : $(JAVA_CLASS_ROOT)/org/libvirt/StorageVol.class
- $(JAVAH) -classpath $(JAVA_CLASS_ROOT) org.libvirt.StorageVol
-
-lib_LTLIBRARIES = libvirt_jni.la
-libvirt_jni_la_SOURCES = \
- org_libvirt_Network.c \
- org_libvirt_Connect.c \
- org_libvirt_Domain.c \
- org_libvirt_StoragePool.c \
- org_libvirt_StorageVol.c \
- generic.h \
- ErrorHandler.c \
- ErrorHandler.h \
- ConnectAuthCallbackBridge.c \
- ConnectAuthCallbackBridge.h
-
-nodist_libvirt_jni_la_SOURCES = $(GENERATED)
-libvirt_jni_la_LIBADD = $(LIBVIRT_LIBS)
-libvirt_jni_la_LDFLAGS = -version-info @JNI_VERSION_INFO@
-libvirt_jni_la_CFLAGS = $(LIBVIRT_CFLAGS) @JNI_CFLAGS@
-
-
-CLEANFILES = \
- $(GENERATED) $(GENERATED_SUB_1)
diff --git a/src/jni/generic.h b/src/jni/generic.h
deleted file mode 100644
index 347c076..0000000
--- a/src/jni/generic.h
+++ /dev/null
@@ -1,180 +0,0 @@
-#ifndef GENERIC_H_
-#define GENERIC_H_
-#include <jni.h>
-#include <libvirt/libvirt.h>
-#include <stdlib.h>
-
-/* The macros here only make sense if they are the only thing in a function.
- */
-
-/*
- * Generic macro with a VIROBJ ARGument returning an int
- * (for functions like virDomainFree)
- */
-#define GENERIC__VIROBJ__INT(ENV, OBJ, VIROBJ1, VIRFUNC1) \
- return (jint)VIRFUNC1(VIROBJ1);
-
-/*
- * Generic macro with a VIROBJ and an int arguments returning an int
- * (for functions like virStorageVolDelete)
- */
-#define GENERIC__VIROBJ_INT__INT(ENV, OBJ, VIROBJ1, ARG1, VIRFUNC1) \
- return (jint)VIRFUNC1(VIROBJ1, ARG1);
-
-/*
- * Generic macro with a VIROBJ arguments returning a constant String
- * (for functions like virNetworkGetBridgeName )
- */
-#define GENERIC__VIROBJ__CONSTSTRING(ENV, OBJ, VIROBJ1, VIRFUNC1) \
- jstring j_retstring=NULL; \
- const char *retstring; \
- if((retstring = VIRFUNC1(VIROBJ1))){ \
- j_retstring = (*ENV)->NewStringUTF(ENV, retstring); \
- } \
- return j_retstring;
-
-/*
- * Generic macro with a VIROBJ arguments returning a String to be freed by
- * the caller (for functions like virNetworkGetName)
- */
-#define GENERIC__VIROBJ__STRING(ENV, OBJ, VIROBJ1,VIRFUNC1) \
- jstring j_retstring=NULL; \
- char *retstring; \
- if((retstring = VIRFUNC1(VIROBJ1))){ \
- j_retstring = (*ENV)->NewStringUTF(ENV, retstring); \
- free(retstring); \
- } \
- return j_retstring;
-
-/*
- * Generic macro with a VIROBJ and an int argument returning a String to be freed by the
caller
- * (for functions like virStoragePoolGetXMLDesc)
- */
-#define GENERIC_VIROBJ_INT__STRING(ENV, OBJ, VIROBJ, ARG1, VIRFUNC1) \
- jstring j_retstring; \
- char* retstring = NULL; \
- if((retstring = VIRFUNC1(VIROBJ, ARG1))){ \
- j_retstring = (*ENV)->NewStringUTF(ENV, retstring); \
- free(retstring); \
- } \
- return j_retstring;
-
-/*
- * Generic macro with a VIROBJ and an String arguments returning an int
- * (for functions like virDomainDetachDevice )
- */
-#define GENERIC_VIROBJ_STRING__INT(ENV, OBJ, VIROBJ, J_XMLDESC, VIRFUNC1) \
- const char *xmlDesc=(*ENV)->GetStringUTFChars(ENV, J_XMLDESC, NULL); \
- jint retval = (jlong)VIRFUNC1(VIROBJ, xmlDesc); \
- (*ENV)->ReleaseStringUTFChars(ENV, J_XMLDESC, xmlDesc); \
- return retval;
-
-/*
- * Generic macro with a VIROBJ and an String arguments returning a virObject
- * (for functions like *CreateXML* that take no flags)
- */
-#define GENERIC_VIROBJ_STRING__VIROBJ(ENV, OBJ, VIROBJ, J_XMLDESC, VIRFUNC1) \
- const char *xmlDesc=(*ENV)->GetStringUTFChars(ENV, J_XMLDESC, NULL); \
- jlong retval = (jlong)VIRFUNC1(VIROBJ, xmlDesc); \
- (*ENV)->ReleaseStringUTFChars(ENV, J_XMLDESC, xmlDesc); \
- return retval;
-
-/*
- * Generic macro with a VIROBJ and String and int arguments returning a
- * virObject (for functions like *CreateXML* that take a flags)
- */
-#define GENERIC_VIROBJ_STRING_INT__VIROBJ(ENV, OBJ, VIROBJ, J_XMLDESC, FLAGS, VIRFUNC1)
\
- const char *xmlDesc=(*ENV)->GetStringUTFChars(ENV, J_XMLDESC, NULL); \
- jlong retval = (jlong)VIRFUNC1(VIROBJ, xmlDesc, FLAGS); \
- (*ENV)->ReleaseStringUTFChars(ENV, J_XMLDESC, xmlDesc); \
- return retval;
-
-
-/*
- * Generic macro for the *getAutoStart functions
- */
-#define GENERIC_GETAUTOSTART(ENV, OBJ, VIROBJ, VIRFUNC1) \
- int autostart=0; \
- VIRFUNC1(VIROBJ, &autostart); \
- return (jboolean)autostart;
-
-/*
- * Generic macro for the *getUUID functions
- */
-#define GENERIC_GETUUID(ENV, OBJ, VIROBJ1, VIRFUNC1) \
- unsigned char uuid[VIR_UUID_BUFLEN]; \
- jintArray j_uuid; \
- int c; \
- int uuidbyte; \
- if(VIRFUNC1((void*)VIROBJ1, uuid)<0) \
- return NULL; \
- j_uuid=(*ENV)->NewIntArray(ENV, VIR_UUID_BUFLEN); \
- for(c=0; c<VIR_UUID_BUFLEN; c++){ \
- uuidbyte=uuid[c]; \
- (*ENV)->SetIntArrayRegion(ENV, j_uuid, c, 1, &uuidbyte); \
- } \
- return j_uuid;
-
-/*
- * Generic macro for the *getUUIDString functions
- */
-#define GENERIC_GETUUIDSTRING(ENV, OBJ, VIROBJ, VIRFUNC1) \
- char uuidString[VIR_UUID_STRING_BUFLEN]; \
- VIRFUNC1(VIROBJ, uuidString); \
- return (*ENV)->NewStringUTF(ENV, uuidString);
-
-
-/*
- * Generic macro for the *List* functions that return an array of strings
- * VIRFUNC1 is the *List* function
- * VIRFUNC2 is the corresponding *NumOf* function
- */
-#define GENERIC_LIST_STRINGARRAY(ENV, OBJ, VIROBJ,VIRFUNC1, VIRFUNC2) \
- int maxnames; \
- char **names; \
- int c; \
- jobjectArray j_names=NULL; \
- if((maxnames = VIRFUNC2(VIROBJ))<0) \
- return NULL; \
- names= (char**)calloc(maxnames, sizeof(char*)); \
- if(VIRFUNC1(VIROBJ, names, maxnames)>=0){ \
- j_names= (jobjectArray)(*ENV)->NewObjectArray(ENV, maxnames, \
- (*ENV)->FindClass(ENV,"java/lang/String"), \
- (*ENV)->NewStringUTF(ENV,"")); \
- for(c=0; c<maxnames; c++){ \
- (*ENV)->SetObjectArrayElement(ENV, j_names, c, \
- (*ENV)->NewStringUTF(ENV, names[c])); \
- } \
- } \
- free(names); \
- return j_names;
-
-/*
- * Generic macro for the *LookupBy* functions that take a string and return a VirObject
- */
-#define GENERIC_LOOKUPBY_STRING(ENV, OBJ, VIROBJ, J_STRINGID, VIRFUNC1) \
- const char *stringid=(*ENV)->GetStringUTFChars(ENV, J_STRINGID, NULL); \
- jlong retval = (jlong)VIRFUNC1(VIROBJ, stringid); \
- (*ENV)->ReleaseStringUTFChars(ENV, J_STRINGID, stringid); \
- return retval;
-
-/*
- * Generic macro for the *LookupBy* functions that take no argument and return a
VirObject
- */
-#define GENERIC_LOOKUPBY_NONE(ENV, OBJ, VIROBJ, VIRFUNC1) \
-return (jlong)VIRFUNC1(VIROBJ);
-
-/*
- * Generic macro for the *LookupBy* functions that take a UUID and return a VirObject
- */
-#define GENERIC_LOOKUPBY_UUID(ENV, OBJ, VIROBJ, J_UUID, VIRFUNC1) \
- unsigned char uuid[VIR_UUID_BUFLEN]; \
- int c; \
- int *uuid_int = (*ENV)->GetIntArrayElements(ENV, J_UUID, NULL);\
- for(c=0; c < VIR_UUID_BUFLEN; c++) \
- uuid[c]=uuid_int[c]; \
- return (jlong)VIRFUNC1(VIROBJ, uuid);
-
-
-
-#endif /*GENERIC_H_*/
diff --git a/src/jni/org_libvirt_Connect.c b/src/jni/org_libvirt_Connect.c
deleted file mode 100644
index cbf437c..0000000
--- a/src/jni/org_libvirt_Connect.c
+++ /dev/null
@@ -1,363 +0,0 @@
-#include "org_libvirt_Connect.h"
-#include <libvirt/libvirt.h>
-#include <stdlib.h>
-#include "ErrorHandler.h"
-#include "ConnectAuthCallbackBridge.h"
-#include "generic.h"
-#include <assert.h>
-
-//TODO leak check for *ArrayElements
-
-JNIEXPORT jint JNICALL Java_org_libvirt_Connect__1virInitialize
- (JNIEnv *env, jclass cls){
- int result;
- result=virInitialize();
- //The connection-less errors go to the initializing thread as an exception.
- //Not ideal, but better than just dropping the errors.
- virSetErrorFunc(env, virErrorHandler);
- return result;
-}
-
-JNIEXPORT jint JNICALL Java_org_libvirt_Connect__1close
- (JNIEnv *env, jobject obj, jlong VCP){
- GENERIC__VIROBJ__INT(env, obj, (virConnectPtr)VCP, virConnectClose)
-}
-
-JNIEXPORT jstring JNICALL Java_org_libvirt_Connect__1getHostName
- (JNIEnv *env, jobject obj, jlong VCP){
- GENERIC__VIROBJ__STRING(env, obj, (virConnectPtr)VCP, virConnectGetHostname)
-};
-
-JNIEXPORT jstring JNICALL Java_org_libvirt_Connect__1getCapabilities
- (JNIEnv *env, jobject obj, jlong VCP){
- GENERIC__VIROBJ__STRING(env, obj, (virConnectPtr)VCP, virConnectGetCapabilities)
-}
-
-JNIEXPORT jint JNICALL Java_org_libvirt_Connect__1getMaxVcpus
- (JNIEnv *env, jobject obj, jlong VCP, jstring j_type){
- const char *type = (*env)->GetStringUTFChars(env, j_type, NULL);
- int retval = (jint)virConnectGetMaxVcpus((virConnectPtr)VCP, type);
- (*env)->ReleaseStringUTFChars(env, j_type, type);
- return retval;
-};
-
-JNIEXPORT jstring JNICALL Java_org_libvirt_Connect__1getType
- (JNIEnv *env, jobject obj, jlong VCP){
- GENERIC__VIROBJ__CONSTSTRING(env, obj, (virConnectPtr)VCP, virConnectGetType)
-};
-
-JNIEXPORT jstring JNICALL Java_org_libvirt_Connect__1getURI
- (JNIEnv *env, jobject obj, jlong VCP){
- jstring j_uri=NULL;
- char *uri;
- if((uri = virConnectGetURI((virConnectPtr)VCP))){
- j_uri = (*env)->NewStringUTF(env, uri);
- free(uri);
- }
- return j_uri;
-};
-
-JNIEXPORT jlong JNICALL Java_org_libvirt_Connect__1getVersion
- (JNIEnv *env, jobject obj, jlong VCP){
- unsigned long hvVer=0;
- virConnectGetVersion((virConnectPtr)VCP, &hvVer);
- return (jlong)(hvVer);
-};
-
-JNIEXPORT jobjectArray JNICALL Java_org_libvirt_Connect__1listDefinedNetworks
- (JNIEnv *env, jobject obj, jlong VCP){
- GENERIC_LIST_STRINGARRAY(env, obj, (virConnectPtr)VCP, virConnectListDefinedNetworks,
virConnectNumOfDefinedNetworks)
-}
-
-JNIEXPORT jobjectArray JNICALL Java_org_libvirt_Connect__1listNetworks
- (JNIEnv *env, jobject obj, jlong VCP){
- GENERIC_LIST_STRINGARRAY(env, obj, (virConnectPtr)VCP, virConnectListNetworks,
virConnectNumOfNetworks)
-}
-
-JNIEXPORT jint JNICALL Java_org_libvirt_Connect__1numOfDefinedDomains
- (JNIEnv *env, jobject obj, jlong VCP){
- GENERIC__VIROBJ__INT(env, obj, (virConnectPtr)VCP, virConnectNumOfDefinedDomains)
-};
-
-JNIEXPORT jint JNICALL Java_org_libvirt_Connect__1numOfDefinedNetworks
- (JNIEnv *env, jobject obj, jlong VCP){
- GENERIC__VIROBJ__INT(env, obj, (virConnectPtr)VCP, virConnectNumOfDefinedNetworks)
-};
-
-JNIEXPORT jint JNICALL Java_org_libvirt_Connect__1numOfDomains
- (JNIEnv *env, jobject obj, jlong VCP){
- GENERIC__VIROBJ__INT(env, obj, (virConnectPtr)VCP, virConnectNumOfDomains)
-};
-
-JNIEXPORT jint JNICALL Java_org_libvirt_Connect__1numOfNetworks
- (JNIEnv *env, jobject obj, jlong VCP){
- GENERIC__VIROBJ__INT(env, obj, (virConnectPtr)VCP, virConnectNumOfNetworks)
-};
-
-JNIEXPORT jlong JNICALL Java_org_libvirt_Connect__1open
- (JNIEnv *env, jobject obj, jstring j_uri){
-
- virConnectPtr vc;
- const char *uri=(*env)->GetStringUTFChars(env, j_uri, NULL);
-
- //Initialize the libvirt VirtConn Object
- vc=virConnectOpen(uri);
- (*env)->ReleaseStringUTFChars(env, j_uri, uri);
- if(vc==NULL){
- //We have a pending java exception, let's return
- assert((*env)->ExceptionOccurred(env));
- return (jlong)NULL;
- }
-
- //Initialize the error handler for this connection
- virConnSetErrorFunc(vc, env, virErrorHandler);
-
- return (jlong)vc;
-};
-
-JNIEXPORT jlong JNICALL Java_org_libvirt_Connect__1openReadOnly
- (JNIEnv *env, jobject obj, jstring j_uri){
-
- virConnectPtr vc;
- const char *uri=(*env)->GetStringUTFChars(env, j_uri, NULL);
-
- //Initialize the libvirt VirtConn Object
- vc=virConnectOpenReadOnly(uri);
- (*env)->ReleaseStringUTFChars(env, j_uri, uri);
- if(vc==NULL){
- //We have a pending java exception, let's return
- assert((*env)->ExceptionOccurred(env));
- return (jlong)NULL;
- }
-
- //Initialized the error handler for this connection
- virConnSetErrorFunc(vc, env, virErrorHandler);
-
- return (jlong)vc;
-};
-
-JNIEXPORT jlong JNICALL Java_org_libvirt_Connect__1openAuth
- (JNIEnv *env, jobject obj, jstring j_uri, jobject j_auth, jint flags){
-
- virConnectPtr vc;
- const char *uri=(*env)->GetStringUTFChars(env, j_uri, NULL);
-
- virConnectAuth *auth = malloc(sizeof(virConnectAuth));
-
- jobject j_credTypeElement;
- int c;
-
- //Prepare by computing the class and field IDs
- jfieldID credTypeArray_id = (*env)->GetFieldID(env,
- (*env)->FindClass(env, "org/libvirt/ConnectAuth"),
- "credType",
- "[Lorg/libvirt/ConnectAuth$CredentialType;");
- jmethodID credTypeMapToInt_id = (*env)->GetMethodID(env,
- (*env)->FindClass(env, "org/libvirt/ConnectAuth$CredentialType"),
- "mapToInt",
- "()I");
-
- //Copy the array of credtypes with the helper function
- jarray j_credTypeArray=(*env)->GetObjectField(env, j_auth, credTypeArray_id);
- auth->ncredtype = (*env)->GetArrayLength(env, j_credTypeArray);
-
- auth->credtype = calloc(auth->ncredtype, sizeof(int));
- for(c=0; c< auth->ncredtype; c++){
- j_credTypeElement = (*env)->GetObjectArrayElement(env, j_credTypeArray, c);
- auth->credtype[c]=(*env)->CallIntMethod(env, j_credTypeElement,
credTypeMapToInt_id);
- }
-
- //The callback function is always ConnectAuthCallbackBridge
- auth->cb = &ConnectAuthCallbackBridge;
- //We pass the ConnectAuth object and the JNI env in cdbata
- CallBackStructType* cb_wrapper;
- cb_wrapper = malloc(sizeof(CallBackStructType));
- cb_wrapper->env = env;
- cb_wrapper->auth = j_auth;
- auth->cbdata=cb_wrapper;
-
- vc=virConnectOpenAuth(uri, auth, flags);
- (*env)->ReleaseStringUTFChars(env, j_uri, uri);
- if (vc==NULL){
- //We have a pending java exception, let's return
- assert((*env)->ExceptionOccurred(env));
- return (jlong)NULL;
- }
-
- //Initialize the error handler for this connection
- virConnSetErrorFunc(vc, env, virErrorHandler);
-
- return (jlong)vc;
-}
-
-JNIEXPORT jlong JNICALL Java_org_libvirt_Connect__1virNetworkCreateXML
- (JNIEnv *env, jobject obj, jlong VCP, jstring j_xmlDesc){
- GENERIC_VIROBJ_STRING__VIROBJ(env, obj, (virConnectPtr)VCP, j_xmlDesc,
virNetworkCreateXML)
-}
-
-JNIEXPORT jlong JNICALL Java_org_libvirt_Connect__1virNetworkDefineXML
-(JNIEnv *env, jobject obj, jlong VCP, jstring j_xmlDesc){
- GENERIC_VIROBJ_STRING__VIROBJ(env, obj, (virConnectPtr)VCP, j_xmlDesc,
virNetworkDefineXML)
-}
-
-JNIEXPORT jlong JNICALL Java_org_libvirt_Connect__1virNetworkLookupByName
- (JNIEnv *env, jobject obj, jlong VCP, jstring j_name){
- GENERIC_LOOKUPBY_STRING(env, obj, (virConnectPtr)VCP, j_name, virNetworkLookupByName)
-}
-
-JNIEXPORT jlong JNICALL Java_org_libvirt_Connect__1virNetworkLookupByUUID
- (JNIEnv *env, jobject obj, jlong VCP, jintArray j_UUID){
- GENERIC_LOOKUPBY_UUID(env, obj, (virConnectPtr)VCP, j_UUID, virNetworkLookupByUUID)
-}
-
-
-JNIEXPORT jlong JNICALL Java_org_libvirt_Connect__1virNetworkLookupByUUIDString
- (JNIEnv *env, jobject obj, jlong VCP, jstring j_UUID){
- GENERIC_LOOKUPBY_STRING(env, obj, (virConnectPtr)VCP, j_UUID,
virNetworkLookupByUUIDString)
-}
-
-JNIEXPORT jobject JNICALL Java_org_libvirt_Connect__1virNodeInfo
- (JNIEnv *env, jobject obj, jlong VCP){
- virNodeInfo nodeInfo;
- jobject j_nodeInfo;
- jclass cls = (*env)->FindClass(env, "org/libvirt/NodeInfo");
-
- //Fill the c struct
- if(virNodeGetInfo((virConnectPtr)VCP, &nodeInfo)<0){
- return NULL;
- }
-
- //Allocate the VirInfo Object
- j_nodeInfo = (jobject)(*env)->AllocObject(env, cls);
-
- //Copy the fields
- (*env)->SetObjectField(env, j_nodeInfo, (*env)->GetFieldID(env, cls,
"model", "Ljava/lang/String;"), (*env)->NewStringUTF(env,
nodeInfo.model));
- (*env)->SetLongField(env, j_nodeInfo, (*env)->GetFieldID(env, cls,
"memory", "J"), nodeInfo.memory);
- (*env)->SetIntField(env, j_nodeInfo, (*env)->GetFieldID(env, cls,
"cpus", "I"), nodeInfo.cpus);
- (*env)->SetIntField(env, j_nodeInfo, (*env)->GetFieldID(env, cls, "mhz",
"I"), nodeInfo.mhz);
- (*env)->SetIntField(env, j_nodeInfo, (*env)->GetFieldID(env, cls,
"cpus", "I"), nodeInfo.cpus);
- (*env)->SetIntField(env, j_nodeInfo, (*env)->GetFieldID(env, cls,
"nodes", "I"), nodeInfo.nodes);
- (*env)->SetIntField(env, j_nodeInfo, (*env)->GetFieldID(env, cls,
"sockets", "I"), nodeInfo.sockets);
- (*env)->SetIntField(env, j_nodeInfo, (*env)->GetFieldID(env, cls,
"cores", "I"), nodeInfo.cores);
- (*env)->SetIntField(env, j_nodeInfo, (*env)->GetFieldID(env, cls,
"threads", "I"), nodeInfo.threads);
-
- return j_nodeInfo;
-}
-
-JNIEXPORT jobjectArray JNICALL Java_org_libvirt_Connect__1listDefinedDomains
- (JNIEnv *env, jobject obj, jlong VCP){
- GENERIC_LIST_STRINGARRAY(env, obj, (virConnectPtr)VCP, virConnectListDefinedDomains,
virConnectNumOfDefinedDomains)
-}
-
-JNIEXPORT jintArray JNICALL Java_org_libvirt_Connect__1listDomains
- (JNIEnv *env, jobject obj, jlong VCP){
- int maxids;
- int *ids;
- jintArray j_ids=NULL;
-
- if((maxids = virConnectNumOfDomains((virConnectPtr)VCP))<0)
- return NULL;
- ids= (int*)calloc(maxids, sizeof(int));
- if(virConnectListDomains((virConnectPtr)VCP, ids, maxids)>=0){
- j_ids= (jintArray)(*env)->NewIntArray(env, maxids);
- (*env)->SetIntArrayRegion(env, j_ids, 0, maxids, ids);
- }
- free(ids);
-
- return j_ids;
-}
-
-JNIEXPORT jlong JNICALL Java_org_libvirt_Connect__1virDomainLookupByID
- (JNIEnv *env, jobject obj, jlong VCP, jint id){
- return (jlong)virDomainLookupByID((virConnectPtr)VCP, id);
-}
-
-JNIEXPORT jlong JNICALL Java_org_libvirt_Connect__1virDomainLookupByName
- (JNIEnv *env, jobject obj, jlong VCP, jstring j_name){
- GENERIC_LOOKUPBY_STRING(env, obj, (virConnectPtr)VCP, j_name, virDomainLookupByName)
-}
-
-JNIEXPORT jlong JNICALL Java_org_libvirt_Connect__1virDomainLookupByUUID
- (JNIEnv *env, jobject obj, jlong VCP, jintArray j_UUID){
- GENERIC_LOOKUPBY_UUID(env, obj, (virConnectPtr)VCP, j_UUID, virDomainLookupByUUID)
-}
-
-JNIEXPORT jlong JNICALL Java_org_libvirt_Connect__1virDomainLookupByUUIDString
- (JNIEnv *env, jobject obj, jlong VCP, jstring j_UUID){
- GENERIC_LOOKUPBY_STRING(env, obj, (virConnectPtr)VCP, j_UUID,
virDomainLookupByUUIDString)
-}
-
-JNIEXPORT jlong JNICALL Java_org_libvirt_Connect__1virGetLibVirVersion
- (JNIEnv *env, jobject obj){
- return LIBVIR_VERSION_NUMBER;
-}
-
-JNIEXPORT jlong JNICALL Java_org_libvirt_Connect__1virGetHypervisorVersion
- (JNIEnv *env, jobject obj, jstring j_type){
- unsigned long libVer;
- const char *type;
- unsigned long typeVer;
-
- type = (*env)->GetStringUTFChars(env, j_type, NULL);
-
- virGetVersion(&libVer, type, &typeVer);
- (*env)->ReleaseStringUTFChars(env, j_type, type);
-
- return libVer;
-}
-
-JNIEXPORT jlong JNICALL Java_org_libvirt_Connect__1virDomainCreateLinux
- (JNIEnv *env, jobject obj, jlong VCP, jstring j_xmlDesc, jint flags){
- GENERIC_VIROBJ_STRING_INT__VIROBJ(env, obj, (virConnectPtr)VCP, j_xmlDesc, flags,
virDomainCreateLinux)
-}
-
-JNIEXPORT jlong JNICALL Java_org_libvirt_Connect__1virDomainDefineXML
- (JNIEnv *env, jobject obj, jlong VCP, jstring j_xmlDesc){
- GENERIC_VIROBJ_STRING__VIROBJ(env, obj, (virConnectPtr)VCP, j_xmlDesc,
virDomainDefineXML)
-}
-
-JNIEXPORT jint JNICALL Java_org_libvirt_Connect__1virDomainRestore
- (JNIEnv *env, jobject obj, jlong VCP, jstring j_from){
- GENERIC_VIROBJ_STRING__VIROBJ(env, obj, (virConnectPtr)VCP, j_from, virDomainRestore)
-}
-
-JNIEXPORT jint JNICALL Java_org_libvirt_Connect__1setDom0Memory
- (JNIEnv *env, jobject obj, jlong memory){
- return virDomainSetMemory(NULL, memory);
-}
-
-JNIEXPORT jint JNICALL Java_org_libvirt_Connect__1numOfDefinedStoragePools
- (JNIEnv *env, jobject obj, jlong VCP){
- GENERIC__VIROBJ__INT(env, obj, (virConnectPtr)VCP, virConnectNumOfDefinedStoragePools)
-}
-
-JNIEXPORT jint JNICALL Java_org_libvirt_Connect__1numOfStoragePools
- (JNIEnv *env, jobject obj, jlong VCP){
- GENERIC__VIROBJ__INT(env, obj, (virConnectPtr)VCP, virConnectNumOfStoragePools)
-}
-
-JNIEXPORT jobjectArray JNICALL Java_org_libvirt_Connect__1listDefinedStoragePools
-(JNIEnv *env, jobject obj, jlong VCP){
- GENERIC_LIST_STRINGARRAY(env, obj, (virConnectPtr)VCP,
virConnectListDefinedStoragePools, virConnectNumOfDefinedStoragePools)
-}
-
-JNIEXPORT jobjectArray JNICALL Java_org_libvirt_Connect__1listStoragePools
-(JNIEnv *env, jobject obj, jlong VCP){
- GENERIC_LIST_STRINGARRAY(env, obj, (virConnectPtr)VCP, virConnectListStoragePools,
virConnectNumOfStoragePools)
-}
-
-JNIEXPORT jlong JNICALL Java_org_libvirt_Connect__1virStoragePoolCreateXML
-(JNIEnv *env, jobject obj, jlong VCP, jstring j_xmlDesc, jint flags){
- GENERIC_VIROBJ_STRING_INT__VIROBJ(env, obj, (virConnectPtr)VCP, j_xmlDesc, flags,
virStoragePoolCreateXML)
-}
-
-JNIEXPORT jlong JNICALL Java_org_libvirt_Connect__1virStoragePoolDefineXML
-(JNIEnv *env, jobject obj, jlong VCP, jstring j_xmlDesc, jint flags){
- GENERIC_VIROBJ_STRING_INT__VIROBJ(env, obj, (virConnectPtr)VCP, j_xmlDesc, flags,
virStoragePoolDefineXML)
-}
-
-JNIEXPORT jlong JNICALL Java_org_libvirt_Connect__1virStoragePoolLookupByName
-(JNIEnv *env, jobject obj, jlong VCP, jstring j_name){
- GENERIC_LOOKUPBY_STRING(env, obj, (virConnectPtr)VCP, j_name,
virStoragePoolLookupByName)
-}
-
diff --git a/src/jni/org_libvirt_Domain.c b/src/jni/org_libvirt_Domain.c
deleted file mode 100644
index 91e87d3..0000000
--- a/src/jni/org_libvirt_Domain.c
+++ /dev/null
@@ -1,581 +0,0 @@
-#include "org_libvirt_Domain.h"
-#include <libvirt/libvirt.h>
-#include "generic.h"
-#include <string.h>
-
-//TODO We still leak UTFstrings in the more complex functions
-
-JNIEXPORT jstring JNICALL Java_org_libvirt_Domain__1getXMLDesc
- (JNIEnv *env, jobject obj, jlong VDP, jint flags){
- GENERIC_VIROBJ_INT__STRING(env, obj, (virDomainPtr)VDP, flags, virDomainGetXMLDesc)
-}
-
-JNIEXPORT jboolean JNICALL Java_org_libvirt_Domain__1getAutostart
- (JNIEnv *env, jobject obj, jlong VDP){
- GENERIC_GETAUTOSTART(env, obj, (virDomainPtr)VDP, virDomainGetAutostart)
-}
-
-JNIEXPORT jint JNICALL Java_org_libvirt_Domain__1setAutostart
- (JNIEnv *env, jobject obj, jlong VDP, jboolean autostart){
- GENERIC__VIROBJ_INT__INT(env, obj, (virDomainPtr)VDP, autostart, virDomainSetAutostart)
-}
-
-JNIEXPORT jint JNICALL Java_org_libvirt_Domain__1getID
- (JNIEnv *env, jobject obj, jlong VDP){
- GENERIC__VIROBJ__INT(env, obj, (virDomainPtr)VDP, virDomainGetID)
-}
-
-JNIEXPORT jlong JNICALL Java_org_libvirt_Domain__1getMaxMemory
-(JNIEnv *env, jobject obj, jlong VDP){
- return virDomainGetMaxMemory((virDomainPtr)VDP);
-}
-
-JNIEXPORT jlong JNICALL Java_org_libvirt_Domain__1setMaxMemory
- (JNIEnv *env, jobject obj, jlong VDP, jlong memory){
- return virDomainSetMaxMemory((virDomainPtr)VDP, memory);
-}
-
-JNIEXPORT jint JNICALL Java_org_libvirt_Domain__1getMaxVcpus
- (JNIEnv *env, jobject obj, jlong VDP){
- GENERIC__VIROBJ__INT(env, obj, (virDomainPtr)VDP, virDomainGetMaxVcpus)
-}
-
-JNIEXPORT jstring JNICALL Java_org_libvirt_Domain__1getName
- (JNIEnv *env, jobject obj, jlong VDP){
- GENERIC__VIROBJ__CONSTSTRING(env, obj, (virDomainPtr)VDP, virDomainGetName)
-}
-
-JNIEXPORT jstring JNICALL Java_org_libvirt_Domain__1getOSType
- (JNIEnv *env, jobject obj, jlong VDP){
- GENERIC__VIROBJ__STRING(env, obj, (virDomainPtr)VDP, virDomainGetOSType)
-}
-
-JNIEXPORT jobjectArray JNICALL Java_org_libvirt_Domain__1getSchedulerType
-(JNIEnv *env, jobject obj, jlong VDP){
- jstring j_schedulerType;
- char *schedulerType=NULL;
- int nparams;
-
- //We don't return nparams
- if((schedulerType = virDomainGetSchedulerType((virDomainPtr)VDP, &nparams))){
- j_schedulerType = (*env)->NewStringUTF(env, schedulerType);
- free(schedulerType);
- }
- return j_schedulerType;
-}
-
-JNIEXPORT jobjectArray JNICALL Java_org_libvirt_Domain__1getSchedulerParameters
- (JNIEnv *env, jobject obj, jlong VDP){
- //It's gonna be slightly^h^h^h^h^h^h^h^hvery painful
- int nparams;
- int c;
- char *schedulerType;
- virSchedParameterPtr params;
- jobjectArray j_params;
- jobject j_param;
- jobject j_field;
- jclass cls;
-
- //Get nparams
- if(!(schedulerType = virDomainGetSchedulerType((virDomainPtr)VDP, &nparams)))
- return NULL;
-
- free(schedulerType);
-
- //allocate space for params
- params=(virSchedParameterPtr)calloc((size_t)nparams,
(size_t)sizeof(virSchedParameter));
-
- //Fill it
- if(virDomainGetSchedulerParameters((virDomainPtr)VDP, params, &nparams)<0)
- return NULL;
-
- //We need a dummy element to initialize the array
- j_param = (*env)->NewObject(env,
- (*env)->FindClass(env,"org/libvirt/SchedIntParameter"),
- (*env)->GetMethodID(env,
(*env)->FindClass(env,"org/libvirt/SchedIntParameter"),
"<init>", "()V"));
-
- //Create the array
- j_params= (jobjectArray)(*env)->NewObjectArray(env, nparams,
- (*env)->FindClass(env,"org/libvirt/SchedParameter"),
- j_param);
-
- //Fill it
- for(c=0; c<nparams; c++){
- j_field = (*env)->NewStringUTF(env, params[c].field);
-
- switch(params[c].type){
- case VIR_DOMAIN_SCHED_FIELD_INT:
- cls = (*env)->FindClass(env,"org/libvirt/SchedIntParameter");
- //Do I really need to allocate a new one every time?
- j_param=(*env)->AllocObject(env, cls);
- (*env)->SetObjectField(env, j_param, (*env)->GetFieldID(env, cls,
"field", "Ljava/lang/String;"), j_field);
- (*env)->SetIntField(env, j_param, (*env)->GetFieldID(env, cls,
"value", "I"), params[c].value.i);
- break;
- case VIR_DOMAIN_SCHED_FIELD_UINT:
- cls = (*env)->FindClass(env,"org/libvirt/SchedUintParameter");
- j_param=(*env)->AllocObject(env, cls);
- (*env)->SetObjectField(env, j_param, (*env)->GetFieldID(env, cls,
"field", "Ljava/lang/String;"), j_field);
- (*env)->SetIntField(env, j_param, (*env)->GetFieldID(env, cls,
"value", "I"), params[c].value.ui);
- break;
- case VIR_DOMAIN_SCHED_FIELD_LLONG:
- cls = (*env)->FindClass(env,"org/libvirt/SchedLongParameter");
- j_param=(*env)->AllocObject(env, cls);
- (*env)->SetObjectField(env, j_param, (*env)->GetFieldID(env, cls,
"field", "Ljava/lang/String;"), j_field);
- (*env)->SetIntField(env, j_param, (*env)->GetFieldID(env, cls,
"value", "J"), params[c].value.l);
- break;
- case VIR_DOMAIN_SCHED_FIELD_ULLONG:
- cls = (*env)->FindClass(env,"org/libvirt/SchedUlongParameter");
- j_param=(*env)->AllocObject(env, cls);
- (*env)->SetObjectField(env, j_param, (*env)->GetFieldID(env, cls,
"field", "Ljava/lang/String;"), j_field);
- (*env)->SetIntField(env, j_param, (*env)->GetFieldID(env, cls,
"value", "J"), params[c].value.ul);
- break;
- case VIR_DOMAIN_SCHED_FIELD_DOUBLE:
- cls = (*env)->FindClass(env,"org/libvirt/SchedDoubleParameter");
- j_param=(*env)->AllocObject(env, cls);
- (*env)->SetObjectField(env, j_param, (*env)->GetFieldID(env, cls,
"field", "Ljava/lang/String;"), j_field);
- (*env)->SetIntField(env, j_param, (*env)->GetFieldID(env, cls,
"value", "D"), params[c].value.d);
- break;
- case VIR_DOMAIN_SCHED_FIELD_BOOLEAN:
- cls = (*env)->FindClass(env,"org/libvirt/SchedBooleanParameter");
- j_param=(*env)->AllocObject(env, cls);
- (*env)->SetObjectField(env, j_param, (*env)->GetFieldID(env, cls,
"field", "Ljava/lang/String;"), j_field);
- (*env)->SetIntField(env, j_param, (*env)->GetFieldID(env, cls,
"value", "Z"), params[c].value.b);
- }
- //Copy our shiny new object to the array
- (*env)->SetObjectArrayElement(env, j_params, c, j_param);
- }
- //free params;
- free(params);
-
- //Crash and burn
- return j_params;
-}
-
-JNIEXPORT jint JNICALL Java_org_libvirt_Domain__1setSchedulerParameters
- (JNIEnv *env, jobject obj, jlong VDP, jobjectArray j_params){
- int nparams=(*env)->GetArrayLength(env, j_params);
- virSchedParameterPtr params;
- jobject j_param;
-
- jfieldID field_id;
- jfieldID value_id;
- int c;
- int returnvalue;
-
- params = (virSchedParameterPtr)calloc(sizeof(virSchedParameter),c);
-
- for(c=0; c<nparams; c++){
- j_param= (*env)->GetObjectArrayElement(env, j_params, c);
- const char *field;
-
- if((*env)->IsInstanceOf(env, j_param, (*env)->FindClass(env,
"org/libvirt/SchedIntParameter")))
- {
- field_id= (*env)->GetFieldID(env, (*env)->GetObjectClass(env, j_param),
"field", "Ljava/lang/String;");
- value_id= (*env)->GetFieldID(env, (*env)->GetObjectClass(env, j_param),
"value", "I");
- field = (*env)->GetStringUTFChars(env, (*env)->GetObjectField(env, j_param,
field_id), NULL);
- strcpy(params[c].field, field);
- (*env)->ReleaseStringUTFChars(env, (*env)->GetObjectField(env, j_param,
field_id), field);
- params[c].value.i= (*env)->GetIntField(env, j_param, value_id);
- params[c].type= VIR_DOMAIN_SCHED_FIELD_INT;
- } else if((*env)->IsInstanceOf(env, j_param, (*env)->FindClass(env,
"org/libvirt/SchedUintParameter")))
- {
- field_id= (*env)->GetFieldID(env, (*env)->GetObjectClass(env, j_param),
"field", "Ljava/lang/String;");
- value_id= (*env)->GetFieldID(env, (*env)->GetObjectClass(env, j_param),
"value", "I");
- field = (*env)->GetStringUTFChars(env, (*env)->GetObjectField(env, j_param,
field_id), NULL);
- strcpy(params[c].field, field);
- (*env)->ReleaseStringUTFChars(env, (*env)->GetObjectField(env, j_param,
field_id), field);
- params[c].value.ui= (*env)->GetIntField(env, j_param, value_id);
- params[c].type= VIR_DOMAIN_SCHED_FIELD_UINT;
- } else if((*env)->IsInstanceOf(env, j_param, (*env)->FindClass(env,
"org/libvirt/SchedLongParameter")))
- {
- field_id= (*env)->GetFieldID(env, (*env)->GetObjectClass(env, j_param),
"field", "Ljava/lang/String;");
- value_id= (*env)->GetFieldID(env, (*env)->GetObjectClass(env, j_param),
"value", "J");
- field = (*env)->GetStringUTFChars(env, (*env)->GetObjectField(env, j_param,
field_id), NULL);
- strcpy(params[c].field, field);
- (*env)->ReleaseStringUTFChars(env, (*env)->GetObjectField(env, j_param,
field_id), field);
- params[c].value.l= (*env)->GetLongField(env, j_param, value_id);
- params[c].type= VIR_DOMAIN_SCHED_FIELD_LLONG;
- } else if((*env)->IsInstanceOf(env, j_param, (*env)->FindClass(env,
"org/libvirt/SchedUlongParameter")))
- {
- field_id= (*env)->GetFieldID(env, (*env)->GetObjectClass(env, j_param),
"field", "Ljava/lang/String;");
- value_id= (*env)->GetFieldID(env, (*env)->GetObjectClass(env, j_param),
"value", "J");
- field = (*env)->GetStringUTFChars(env, (*env)->GetObjectField(env, j_param,
field_id), NULL);
- strcpy(params[c].field, field);
- (*env)->ReleaseStringUTFChars(env, (*env)->GetObjectField(env, j_param,
field_id), field);
- params[c].value.ul= (*env)->GetLongField(env, j_param, value_id);
- params[c].type= VIR_DOMAIN_SCHED_FIELD_ULLONG;
- } else if((*env)->IsInstanceOf(env, j_param, (*env)->FindClass(env,
"org/libvirt/SchedDoubleParameter")))
- {
- field_id= (*env)->GetFieldID(env, (*env)->GetObjectClass(env, j_param),
"field", "Ljava/lang/String;");
- value_id= (*env)->GetFieldID(env, (*env)->GetObjectClass(env, j_param),
"value", "D");
- field = (*env)->GetStringUTFChars(env, (*env)->GetObjectField(env, j_param,
field_id), NULL);
- strcpy(params[c].field, field);
- (*env)->ReleaseStringUTFChars(env, (*env)->GetObjectField(env, j_param,
field_id), field);
- params[c].value.d= (*env)->GetDoubleField(env, j_param, value_id);
- params[c].type= VIR_DOMAIN_SCHED_FIELD_ULLONG;
- } else if((*env)->IsInstanceOf(env, j_param, (*env)->FindClass(env,
"org/libvirt/SchedBooleanParameter")))
- {
- field_id= (*env)->GetFieldID(env, (*env)->GetObjectClass(env, j_param),
"field", "Ljava/lang/String;");
- value_id= (*env)->GetFieldID(env, (*env)->GetObjectClass(env, j_param),
"value", "Z");
- field = (*env)->GetStringUTFChars(env, (*env)->GetObjectField(env, j_param,
field_id), NULL);
- strcpy(params[c].field, field);
- (*env)->ReleaseStringUTFChars(env, (*env)->GetObjectField(env, j_param,
field_id), field);
- params[c].value.b= (*env)->GetBooleanField(env, j_param, value_id);
- params[c].type= VIR_DOMAIN_SCHED_FIELD_BOOLEAN;
- }
- }
-
- returnvalue= virDomainSetSchedulerParameters((virDomainPtr)VDP, params, nparams);
- free(params);
-
- return returnvalue;
-}
-
-JNIEXPORT jintArray JNICALL Java_org_libvirt_Domain__1getUUID
- (JNIEnv *env, jobject obj, jlong VDP){
- GENERIC_GETUUID(env, obj, (virDomainPtr)VDP, virDomainGetUUID)
-}
-
-JNIEXPORT jstring JNICALL Java_org_libvirt_Domain__1getUUIDString
- (JNIEnv *env, jobject obj, jlong VDP){
- GENERIC_GETUUIDSTRING(env, obj, (virDomainPtr)VDP, virDomainGetUUIDString)
-}
-
-JNIEXPORT jobjectArray JNICALL Java_org_libvirt_Domain__1getVcpusInfo
- (JNIEnv *env, jobject obj, jlong VDP){
- //Please hurt me even more!
- int maxinfo;
- virVcpuInfoPtr info;
- int c;
-
- jobject j_info;
- jobjectArray j_infoArray=NULL;
-
- jfieldID number_id;
- jfieldID state_id;
- jfieldID cputime_id;
- jfieldID cpu_id;
-
- jmethodID state_values_id;
- jclass state_class;
- jclass vcpuinfo_class;
- jobjectArray state_values;
-
- //Check the number of vcpus
- if((maxinfo=virDomainGetMaxVcpus((virDomainPtr)VDP))<0)
- return NULL;
-
- info=(virVcpuInfoPtr)calloc(maxinfo, sizeof(virVcpuInfo));
-
- //Get the data
- if(virDomainGetVcpus((virDomainPtr)VDP, info, maxinfo, NULL, 0)>=0){
- //get the field Ids of info
- vcpuinfo_class = (*env)->FindClass(env,"org/libvirt/VcpuInfo");
- number_id = (*env)->GetFieldID(env, vcpuinfo_class, "number",
"I");
- state_id = (*env)->GetFieldID(env, vcpuinfo_class, "state",
"Lorg/libvirt/VcpuInfo$VcpuState;");
- cputime_id = (*env)->GetFieldID(env, vcpuinfo_class, "cputime",
"J");
- cpu_id = (*env)->GetFieldID(env, vcpuinfo_class, "cpu", "I");
-
- //Get objects for the states so that we can copy them into the info structure
- state_class=(*env)->FindClass(env,"org.libvirt.VcpuInfo$VcpuState");
- state_values_id=(*env)->GetStaticMethodID(env, state_class, "values",
"()[Lorg/libvirt/VcpuInfo$VcpuState");
- state_values=(*env)->CallStaticObjectMethod(env, state_class, state_values_id);
-
- //We need a dummy element to initialize the array
- j_info = (*env)->NewObject(env,
- (*env)->FindClass(env,"org/libvirt/VcpuInfo"),
- (*env)->GetMethodID(env,
(*env)->FindClass(env,"org/libvirt/VcpuInfo"), "<init>",
"()V"));
-
- //Create the info array
- j_infoArray= (jobjectArray)(*env)->NewObjectArray(env, maxinfo,
- (*env)->FindClass(env,"org/libvirt/VcpuInfo"),
- j_info);
-
- //Fill it
- for(c=0; c<maxinfo; c++){
- //Does SteObjectArrayElement copy or reference this? Do I really need to allocate the
objects? I think not
- j_info = (*env)->AllocObject(env, vcpuinfo_class);
- //Fill the fields
- (*env)->SetIntField(env, j_info, number_id, info[c].number);
- (*env)->SetObjectField(env, j_info, state_id,
- (*env)->GetObjectArrayElement(env, state_values, info[c].state));
- (*env)->SetLongField(env, j_info, cputime_id, info[c].cpuTime);
- (*env)->SetIntField(env, j_info, cpu_id, info[c].cpu);
- //Add to the array
- (*env)->SetObjectArrayElement(env, j_infoArray, c, j_info);
- }
- }
- free(info);
- return j_infoArray;
-}
-
-JNIEXPORT jintArray JNICALL Java_org_libvirt_Domain__1getVcpusCpuMaps
- (JNIEnv *env, jobject obj, jlong VDP){
- int maxinfo;
- int maplen;
- unsigned char *cpumaps;
- int *i_cpumaps;
- jintArray j_cpumaps;
- int c;
- virNodeInfoPtr nodeinfo;
- virVcpuInfoPtr info;
-
- //Check number of vcpus;
- if((maxinfo = virDomainGetMaxVcpus((virDomainPtr)VDP))<0)
- return NULL;
-
- //Get maplen
- if(virNodeGetInfo( virDomainGetConnect( (virDomainPtr)VDP), nodeinfo )<0)
- return NULL;
- maplen=VIR_CPU_MAPLEN( VIR_NODEINFO_MAXCPUS( *nodeinfo ) );
-
- info=(virVcpuInfoPtr)calloc(maxinfo, sizeof(virVcpuInfo));
- cpumaps=malloc(sizeof(int)*maxinfo*maplen);
-
- //Get the data
- if(virDomainGetVcpus((virDomainPtr)VDP, info, maxinfo, cpumaps, maplen)>0){
- //unpack cpumaps
- for(c=0; c<maxinfo*maplen; c++)
- i_cpumaps[c]=cpumaps[c];
-
- j_cpumaps=(*env)->NewIntArray(env, maxinfo*maplen);
- (*env)->SetIntArrayRegion(env, j_cpumaps, 0, maxinfo*maplen, i_cpumaps);
- }
- free(info);
- free(cpumaps);
-
- return(j_cpumaps);
-}
-
-JNIEXPORT jint JNICALL Java_org_libvirt_Domain__1pinVcpu
- (JNIEnv *env, jobject obj, jlong VDP, jint vcpu, jintArray j_cpumap){
- int maplen;
- unsigned char *cpumap;
- jint *i_cpumap;
- int c;
- int retval;
-
- //Get maplen
- maplen=(*env)->GetArrayLength(env, j_cpumap);
-
- i_cpumap=calloc(sizeof(int), maplen);
- cpumap=calloc(sizeof(unsigned char), maplen);
-
- i_cpumap=(*env)->GetIntArrayElements(env, j_cpumap, NULL);
-
- //pack cpumap
- for(c=0; c<maplen; c++)
- cpumap[c]=i_cpumap[c];
-
- //Call libvirt
- retval = virDomainPinVcpu((virDomainPtr)VDP, vcpu, cpumap, maplen);
-
- free(cpumap);
- free(i_cpumap);
- return retval;
-}
-
-JNIEXPORT jint JNICALL Java_org_libvirt_Domain__1setVcpus
- (JNIEnv *env, jobject obj, jlong VDP, jint nvcpus){
- GENERIC__VIROBJ_INT__INT(env, obj, (virDomainPtr)VDP, nvcpus, virDomainSetVcpus)
-}
-
-JNIEXPORT jint JNICALL Java_org_libvirt_Domain__1attachDevice
- (JNIEnv *env, jobject obj, jlong VDP, jstring j_xmlDesc){
- GENERIC_VIROBJ_STRING__INT(env, obj, (virDomainPtr)VDP, j_xmlDesc,
virDomainAttachDevice);
-}
-
-JNIEXPORT jint JNICALL Java_org_libvirt_Domain__1detachDevice
- (JNIEnv *env, jobject obj, jlong VDP, jstring j_xmlDesc){
- GENERIC_VIROBJ_STRING__INT(env, obj, (virDomainPtr)VDP, j_xmlDesc,
virDomainDetachDevice);
-}
-
-
-JNIEXPORT jobject JNICALL Java_org_libvirt_Domain__1blockStats
- (JNIEnv *env, jobject obj, jlong VDP, jstring j_path){
- struct _virDomainBlockStats stats;
- jobject j_stats;
- jclass stats_cls=(*env)->FindClass(env, "org/libvirt/DomainBlockStats");
- const char *path = (*env)->GetStringUTFChars(env, j_path, NULL);
-
- if(virDomainBlockStats((virDomainPtr)VDP, path, &stats, sizeof(struct
_virDomainBlockStats))<0){
- (*env)->ReleaseStringUTFChars(env, j_path, path);
- return NULL;
- }
- (*env)->ReleaseStringUTFChars(env, j_path, path);
-
- j_stats = (*env)->AllocObject(env, stats_cls);
-
- (*env)->SetLongField(env, j_stats, (*env)->GetFieldID(env, stats_cls,
"rd_req", "J"), stats.rd_req);
- (*env)->SetLongField(env, j_stats, (*env)->GetFieldID(env, stats_cls,
"rd_bytes", "J"), stats.rd_bytes);
- (*env)->SetLongField(env, j_stats, (*env)->GetFieldID(env, stats_cls,
"wr_req", "J"), stats.wr_req);
- (*env)->SetLongField(env, j_stats, (*env)->GetFieldID(env, stats_cls,
"wr_bytes", "J"), stats.wr_bytes);
- (*env)->SetLongField(env, j_stats, (*env)->GetFieldID(env, stats_cls,
"errs", "J"), stats.errs);
-
- return j_stats;
-}
-
-
-JNIEXPORT jobject JNICALL Java_org_libvirt_Domain__1interfaceStats
- (JNIEnv *env, jobject obj, jlong VDP, jstring j_path){
- struct _virDomainInterfaceStats stats;
- jobject j_stats;
- jclass stats_cls=(*env)->FindClass(env,
"org/libvirt/DomainInterfaceStats");
- const char *path = (*env)->GetStringUTFChars(env, j_path, NULL);
-
- if(virDomainInterfaceStats((virDomainPtr)VDP, (*env)->GetStringUTFChars(env, j_path,
NULL), &stats, sizeof(struct _virDomainInterfaceStats))<0){
- (*env)->ReleaseStringUTFChars(env, j_path, path);
- return NULL;
- }
- (*env)->ReleaseStringUTFChars(env, j_path, path);
-
- j_stats = (*env)->AllocObject(env, stats_cls);
-
-
-
- (*env)->SetLongField(env, j_stats, (*env)->GetFieldID(env, stats_cls,
"rx_bytes", "J"), stats.rx_bytes);
- (*env)->SetLongField(env, j_stats, (*env)->GetFieldID(env, stats_cls,
"rx_packets", "J"), stats.rx_packets);
- (*env)->SetLongField(env, j_stats, (*env)->GetFieldID(env, stats_cls,
"rx_errs", "J"), stats.rx_errs);
- (*env)->SetLongField(env, j_stats, (*env)->GetFieldID(env, stats_cls,
"rx_drop", "J"), stats.rx_drop);
- (*env)->SetLongField(env, j_stats, (*env)->GetFieldID(env, stats_cls,
"tx_bytes", "J"), stats.tx_bytes);
- (*env)->SetLongField(env, j_stats, (*env)->GetFieldID(env, stats_cls,
"tx_packets", "J"), stats.tx_packets);
- (*env)->SetLongField(env, j_stats, (*env)->GetFieldID(env, stats_cls,
"tx_errs", "J"), stats.tx_errs);
- (*env)->SetLongField(env, j_stats, (*env)->GetFieldID(env, stats_cls,
"tx_drop", "J"), stats.tx_drop);
-
- return j_stats;
-}
-
-JNIEXPORT jint JNICALL Java_org_libvirt_Domain__1coreDump
- (JNIEnv *env, jobject obj, jlong VDP, jstring j_to, jint flags){
- const char *to = (*env)->GetStringUTFChars(env, j_to, NULL);
- jint retval = virDomainCoreDump((virDomainPtr)VDP, to, flags);
- (*env)->ReleaseStringUTFChars(env, j_to, to);
- return retval;
-}
-
-JNIEXPORT jint JNICALL Java_org_libvirt_Domain__1create
- (JNIEnv *env, jobject obj, jlong VDP){
- GENERIC__VIROBJ__INT(env, obj, (virDomainPtr)VDP, virDomainCreate)
-}
-
-JNIEXPORT jint JNICALL Java_org_libvirt_Domain__1destroy
- (JNIEnv *env, jobject obj, jlong VDP){
- GENERIC__VIROBJ__INT(env, obj, (virDomainPtr)VDP, virDomainDestroy)
-}
-
-JNIEXPORT jint JNICALL Java_org_libvirt_Domain__1free
- (JNIEnv *env, jobject obj, jlong VDP){
- GENERIC__VIROBJ__INT(env, obj, (virDomainPtr)VDP, virDomainFree)
-}
-
-JNIEXPORT jobject JNICALL Java_org_libvirt_Domain__1getInfo
- (JNIEnv *env, jobject obj, jlong VDP){
- //Please hurt me even more!
- virDomainInfo domainInfo;
-
- jobject j_info;
-
- jfieldID state_id;
- jfieldID maxMem_id;
- jfieldID memory_id;
- jfieldID nrVirtCpu_id;
- jfieldID cpuTime_id;
-
- jmethodID state_values_id;
- jclass state_class;
- jclass domaininfo_class;
- jobjectArray state_values;
-
- //Get the data
- if(virDomainGetInfo((virDomainPtr)VDP, &domainInfo)<0)
- return NULL;
-
- //get the field Ids of info
- domaininfo_class = (*env)->FindClass(env,"org/libvirt/DomainInfo");
-
- state_id = (*env)->GetFieldID(env, domaininfo_class, "state",
"Lorg/libvirt/DomainInfo$DomainState;");
- maxMem_id = (*env)->GetFieldID(env, domaininfo_class, "maxMem",
"J");
- memory_id = (*env)->GetFieldID(env, domaininfo_class, "memory",
"J");
- nrVirtCpu_id = (*env)->GetFieldID(env, domaininfo_class, "nrVirtCpu",
"I");
- cpuTime_id = (*env)->GetFieldID(env, domaininfo_class, "cpuTime",
"J");
-
- //Get objects for the states so that we can copy them into the info structure
- state_class=(*env)->FindClass(env,"org/libvirt/DomainInfo$DomainState");
- state_values_id=(*env)->GetStaticMethodID(env, state_class, "values",
"()[Lorg/libvirt/DomainInfo$DomainState;");
- state_values=(*env)->CallStaticObjectMethod(env, state_class, state_values_id);
-
- //Create the return object
- j_info = (*env)->AllocObject(env, domaininfo_class);
-
- //Fill the fields
- (*env)->SetObjectField(env, j_info, state_id,
- (*env)->GetObjectArrayElement(env, state_values, domainInfo.state));
- (*env)->SetLongField(env, j_info, maxMem_id, domainInfo.maxMem);
- (*env)->SetLongField(env, j_info, memory_id, domainInfo.memory);
- (*env)->SetIntField(env, j_info, nrVirtCpu_id, domainInfo.nrVirtCpu);
- (*env)->SetLongField(env, j_info, cpuTime_id, domainInfo.cpuTime);
-
- return j_info;
-}
-
-JNIEXPORT jlong JNICALL Java_org_libvirt_Domain__1migrate
- (JNIEnv *env, jobject obj, jlong VDP, jobject dconn, jlong flags, jstring j_dname,
jstring j_uri, jlong bandwidth){
-
- virConnectPtr destVCP;
-
- const char *dname=NULL;
- const char *uri=NULL;
-
- //if String="", we pass NULL to the library
- if((*env)->GetStringLength(env, j_dname)>0)
- dname=(*env)->GetStringUTFChars(env, j_dname, NULL);
-
- //if String="", we pass NULL to the library
- if((*env)->GetStringLength(env, j_uri)>0)
- uri=(*env)->GetStringUTFChars(env, j_uri, NULL);
-
- //Extract the destination Conn Ptr
- destVCP=(virConnectPtr)(*env)->GetLongField(env, dconn,
- (*env)->GetFieldID(env, (*env)->GetObjectClass(env, dconn), "VCP",
"J"));
-
- jlong retval = (jlong)virDomainMigrate((virDomainPtr)VDP, destVCP, flags, dname, uri,
bandwidth);
- (*env)->ReleaseStringUTFChars(env, j_dname, dname);
- (*env)->ReleaseStringUTFChars(env, j_uri, uri);
- return retval;
-}
-
-JNIEXPORT jint JNICALL Java_org_libvirt_Domain__1reboot
- (JNIEnv *env, jobject obj, jlong VDP, jint flags){
- GENERIC__VIROBJ_INT__INT(env, obj, (virDomainPtr)VDP, flags, virDomainReboot)
-}
-
-JNIEXPORT jint JNICALL Java_org_libvirt_Domain__1suspend
-(JNIEnv *env, jobject obj, jlong VDP){
- GENERIC__VIROBJ__INT(env, obj, (virDomainPtr)VDP, virDomainSuspend)
-}
-
-JNIEXPORT jint JNICALL Java_org_libvirt_Domain__1resume
- (JNIEnv *env, jobject obj, jlong VDP){
- GENERIC__VIROBJ__INT(env, obj, (virDomainPtr)VDP, virDomainResume)
-}
-
-JNIEXPORT jint JNICALL Java_org_libvirt_Domain__1save
- (JNIEnv *env, jobject obj, jlong VDP, jstring j_to){
- GENERIC_VIROBJ_STRING__INT(env, obj, (virDomainPtr)VDP, j_to, virDomainSave)
-}
-
-JNIEXPORT jint JNICALL Java_org_libvirt_Domain__1shutdown
- (JNIEnv *env, jobject obj, jlong VDP){
- GENERIC__VIROBJ__INT(env, obj, (virDomainPtr)VDP, virDomainShutdown)
-}
-
-JNIEXPORT jint JNICALL Java_org_libvirt_Domain__1undefine
-(JNIEnv *env, jobject obj, jlong VDP){
- GENERIC__VIROBJ__INT(env, obj, (virDomainPtr)VDP, virDomainUndefine)
-}
-
-JNIEXPORT jint JNICALL Java_org_libvirt_Domain__1setMemory
- (JNIEnv *env, jobject obj, jlong VDP, jlong memory){
- return virDomainSetMemory((virDomainPtr)VDP, memory);
-}
-
diff --git a/src/jni/org_libvirt_Network.c b/src/jni/org_libvirt_Network.c
deleted file mode 100644
index 19f4294..0000000
--- a/src/jni/org_libvirt_Network.c
+++ /dev/null
@@ -1,59 +0,0 @@
-#include "org_libvirt_Network.h"
-#include <libvirt/libvirt.h>
-#include "generic.h"
-#include <stdlib.h>
-
-JNIEXPORT jstring JNICALL Java_org_libvirt_Network__1getXMLDesc
- (JNIEnv *env, jobject obj, jlong VNP, jint j_flags){
- GENERIC_VIROBJ_INT__STRING(env, obj, (virNetworkPtr)VNP, j_flags, virNetworkGetXMLDesc)
-};
-
-JNIEXPORT jint JNICALL Java_org_libvirt_Network__1create
- (JNIEnv *env, jobject obj, jlong VNP){
- GENERIC__VIROBJ__INT(env, obj, (virNetworkPtr)VNP, virNetworkCreate)
-}
-
-JNIEXPORT jint JNICALL Java_org_libvirt_Network__1destroy
-(JNIEnv *env, jobject obj, jlong VNP){
- GENERIC__VIROBJ__INT(env, obj, (virNetworkPtr)VNP, virNetworkDestroy)
-}
-
-JNIEXPORT jint JNICALL Java_org_libvirt_Network__1free
-(JNIEnv *env, jobject obj, jlong VNP){
- GENERIC__VIROBJ__INT(env, obj, (virNetworkPtr)VNP, virNetworkFree)
-}
-
-JNIEXPORT jboolean JNICALL Java_org_libvirt_Network__1getAutostart
- (JNIEnv *env, jobject obj, jlong VNP){
- GENERIC_GETAUTOSTART(env, obj, (virNetworkPtr)VNP, virNetworkGetAutostart)
-}
-
-JNIEXPORT jint JNICALL Java_org_libvirt_Network__1setAutostart
- (JNIEnv *env, jobject obj, jlong VNP, jboolean j_autostart){
- GENERIC__VIROBJ_INT__INT(env, obj, (virNetworkPtr)VNP, j_autostart,
virNetworkSetAutostart)
-}
-
-JNIEXPORT jstring JNICALL Java_org_libvirt_Network__1getBridgeName
- (JNIEnv *env, jobject obj, jlong VNP){
- GENERIC__VIROBJ__STRING(env, obj, (virNetworkPtr)VNP, virNetworkGetBridgeName)
-}
-
-JNIEXPORT jstring JNICALL Java_org_libvirt_Network__1getName
- (JNIEnv *env, jobject obj, jlong VNP){
- GENERIC__VIROBJ__CONSTSTRING(env, obj, (virNetworkPtr)VNP, virNetworkGetName)
-}
-
-JNIEXPORT jintArray JNICALL Java_org_libvirt_Network__1getUUID
- (JNIEnv *env, jobject obj, jlong VNP){
- GENERIC_GETUUID(env, obj, (virNetworkPtr)VNP, virNetworkGetUUID)
-}
-
-JNIEXPORT jstring JNICALL Java_org_libvirt_Network__1getUUIDString
-(JNIEnv *env, jobject obj, jlong VNP){
- GENERIC_GETUUIDSTRING(env, obj, (virNetworkPtr)VNP, virNetworkGetUUIDString)
-}
-
-JNIEXPORT jint JNICALL Java_org_libvirt_Network__1undefine
- (JNIEnv *env, jobject obj, jlong VNP){
- GENERIC__VIROBJ__INT(env, obj, (virNetworkPtr)VNP, virNetworkUndefine)
-}
diff --git a/src/jni/org_libvirt_StoragePool.c b/src/jni/org_libvirt_StoragePool.c
deleted file mode 100644
index 549a3c4..0000000
--- a/src/jni/org_libvirt_StoragePool.c
+++ /dev/null
@@ -1,117 +0,0 @@
-#include <libvirt/libvirt.h>
-#include "org_libvirt_StoragePool.h"
-#include "generic.h"
-
-
-JNIEXPORT jint JNICALL Java_org_libvirt_StoragePool__1build
- (JNIEnv *env, jobject obj, jlong VSPP, jint flags){
- GENERIC__VIROBJ_INT__INT(env, obj, (virStoragePoolPtr)VSPP, flags, virStoragePoolBuild)
-}
-
-JNIEXPORT jint JNICALL Java_org_libvirt_StoragePool__1create
- (JNIEnv *env, jobject obj, jlong VSPP, jint flags){
- GENERIC__VIROBJ_INT__INT(env, obj, (virStoragePoolPtr)VSPP, flags,
virStoragePoolCreate)
-}
-
-JNIEXPORT jint JNICALL Java_org_libvirt_StoragePool__1delete
- (JNIEnv *env, jobject obj, jlong VSPP, jint flags){
- GENERIC__VIROBJ_INT__INT(env, obj, (virStoragePoolPtr)VSPP, flags,
virStoragePoolDelete)
-}
-
-JNIEXPORT jint JNICALL Java_org_libvirt_StoragePool__1destroy
- (JNIEnv *env, jobject obj, jlong VSPP){
- GENERIC__VIROBJ__INT(env, obj, (virStoragePoolPtr)VSPP, virStoragePoolDestroy)
-}
-
-JNIEXPORT jint JNICALL Java_org_libvirt_StoragePool__1free
- (JNIEnv *env, jobject obj, jlong VSPP){
- GENERIC__VIROBJ__INT(env, obj, (virStoragePoolPtr)VSPP, virStoragePoolFree)
-}
-
-JNIEXPORT jboolean JNICALL Java_org_libvirt_StoragePool__1getAutostart
- (JNIEnv *env, jobject obj, jlong VSPP){
- GENERIC_GETAUTOSTART(env, obj, (virStoragePoolPtr)VSPP, virStoragePoolGetAutostart)
-}
-
-JNIEXPORT jobject JNICALL Java_org_libvirt_StoragePool__1getInfo
- (JNIEnv *env, jobject obj, jlong VSPP){
-
- virStoragePoolInfo storagePoolInfo;
-
- jobject j_info;
-
- //Get the data
- if(virStoragePoolGetInfo((virStoragePoolPtr)VSPP, &storagePoolInfo)<0)
- return NULL;
-
- //get the field Ids of info
- jclass j_storagePoolInfo_cls =
(*env)->FindClass(env,"org/libvirt/StoragePoolInfo");
- jmethodID j_storagePoolInfo_constructor = (*env)->GetMethodID(env,
j_storagePoolInfo_cls, "<init>", "(IJJJ)V");
-
- //Long live encapsulation
- j_info=(*env)->NewObject(env,
- j_storagePoolInfo_cls,
- j_storagePoolInfo_constructor,
- storagePoolInfo.state,
- storagePoolInfo.capacity,
- storagePoolInfo.allocation,
- storagePoolInfo.available);
-
- return j_info;
-}
-
-JNIEXPORT jstring JNICALL Java_org_libvirt_StoragePool__1getName
- (JNIEnv *env, jobject obj, jlong VSPP){
- GENERIC__VIROBJ__CONSTSTRING(env, obj, (virStoragePoolPtr)VSPP, virStoragePoolGetName)
-}
-
-JNIEXPORT jintArray JNICALL Java_org_libvirt_StoragePool__1getUUID
- (JNIEnv *env, jobject obj, jlong VSPP){
- GENERIC_GETUUID(env, obj, (virStoragePoolPtr)VSPP, virStoragePoolGetUUID)
-}
-
-JNIEXPORT jstring JNICALL Java_org_libvirt_StoragePool__1getUUIDString
- (JNIEnv *env, jobject obj, jlong VSPP){
- GENERIC_GETUUIDSTRING(env, obj, (virStoragePoolPtr)VSPP, virStoragePoolGetUUIDString)
-}
-
-JNIEXPORT jstring JNICALL Java_org_libvirt_StoragePool__1getXMLDesc
- (JNIEnv *env, jobject obj, jlong VSPP, jint flags){
- GENERIC_VIROBJ_INT__STRING(env, obj, (virStoragePoolPtr)VSPP, flags,
virStoragePoolGetXMLDesc)
-}
-
-JNIEXPORT jobjectArray JNICALL Java_org_libvirt_StoragePool__1listVolumes
- (JNIEnv *env, jobject obj, jlong VSPP){
- GENERIC_LIST_STRINGARRAY(env, obj, (virStoragePoolPtr)VSPP, virStoragePoolListVolumes,
virStoragePoolNumOfVolumes)
-}
-
-JNIEXPORT jint JNICALL Java_org_libvirt_StoragePool__1numOfVolumes
- (JNIEnv *env, jobject obj, jlong VSPP){
- GENERIC__VIROBJ__INT(env, obj, (virStoragePoolPtr)VSPP, virStoragePoolNumOfVolumes)
-}
-
-JNIEXPORT jint JNICALL Java_org_libvirt_StoragePool__1refresh
- (JNIEnv *env, jobject obj, jlong VSPP, jint flags){
- GENERIC__VIROBJ_INT__INT(env, obj, (virStoragePoolPtr)VSPP, flags,
virStoragePoolRefresh)
-}
-
-JNIEXPORT jint JNICALL Java_org_libvirt_StoragePool__1setAutostart
- (JNIEnv *env, jobject obj, jlong VSPP, jint flags){
- GENERIC__VIROBJ_INT__INT(env, obj, (virStoragePoolPtr)VSPP, flags,
virStoragePoolSetAutostart)
-}
-
-JNIEXPORT jint JNICALL Java_org_libvirt_StoragePool__1undefine
-(JNIEnv *env, jobject obj, jlong VSPP){
- GENERIC__VIROBJ__INT(env, obj, (virStoragePoolPtr)VSPP, virStoragePoolUndefine)
-}
-
-JNIEXPORT jlong JNICALL Java_org_libvirt_StoragePool__1storageVolLookupByName
- (JNIEnv *env, jobject obj, jlong VSPP, jstring name){
- GENERIC_LOOKUPBY_STRING(env, obj, (virStoragePoolPtr)VSPP, name,
virStorageVolLookupByName)
-}
-
-JNIEXPORT jlong JNICALL Java_org_libvirt_StoragePool__1storageVolCreateXML
- (JNIEnv *env, jobject obj, jlong VSPP, jstring j_xmlDesc, jint flags){
- GENERIC_VIROBJ_STRING_INT__VIROBJ(env, obj, (virStoragePoolPtr)VSPP, j_xmlDesc, flags,
virStorageVolCreateXML)
-}
-
diff --git a/src/jni/org_libvirt_StorageVol.c b/src/jni/org_libvirt_StorageVol.c
deleted file mode 100644
index 8c54b77..0000000
--- a/src/jni/org_libvirt_StorageVol.c
+++ /dev/null
@@ -1,65 +0,0 @@
-#include "org_libvirt_StorageVol.h"
-#include "generic.h"
-#include <libvirt/libvirt.h>
-
-JNIEXPORT jlong JNICALL Java_org_libvirt_StorageVol__1storagePoolLookupByVolume
- (JNIEnv *env, jobject obj, jlong VSVP){
- GENERIC_LOOKUPBY_NONE(env, obj, (virStorageVolPtr)VSVP, virStoragePoolLookupByVolume)
-}
-
-JNIEXPORT jint JNICALL Java_org_libvirt_StorageVol__1delete
- (JNIEnv *env, jobject obj, jlong VSVP, jint flags){
- GENERIC__VIROBJ_INT__INT(env, obj, (virStorageVolPtr)VSVP, flags, virStorageVolDelete)
-}
-
-JNIEXPORT jint JNICALL Java_org_libvirt_StorageVol__1free
- (JNIEnv *env, jobject obj, jlong VSVP){
- GENERIC__VIROBJ__INT(env, obj, (virStorageVolPtr)VSVP, virStorageVolFree)
-}
-
-JNIEXPORT jobject JNICALL Java_org_libvirt_StorageVol__1getInfo
-(JNIEnv *env, jobject obj, jlong VSVP){
-
- virStorageVolInfo storageVolInfo;
-
- jobject j_info;
-
- //Get the data
- if(virStorageVolGetInfo((virStorageVolPtr)VSVP, &storageVolInfo)<0)
- return NULL;
-
- //get the field Ids of info
- jclass j_storageVolInfo_cls =
(*env)->FindClass(env,"org/libvirt/StorageVolInfo");
- jmethodID j_storageVolInfo_constructor = (*env)->GetMethodID(env,
j_storageVolInfo_cls, "<init>", "(IJJ)V");
-
- //Long live encapsulation
- j_info=(*env)->NewObject(env,
- j_storageVolInfo_cls,
- j_storageVolInfo_constructor,
- storageVolInfo.type,
- storageVolInfo.capacity,
- storageVolInfo.allocation);
-
- return j_info;
-}
-
-JNIEXPORT jstring JNICALL Java_org_libvirt_StorageVol__1getKey
- (JNIEnv *env, jobject obj, jlong VSVP){
- GENERIC__VIROBJ__CONSTSTRING(env, obj, (virStorageVolPtr)VSVP, virStorageVolGetKey)
-}
-
-JNIEXPORT jstring JNICALL Java_org_libvirt_StorageVol__1getName
- (JNIEnv *env, jobject obj, jlong VSVP){
- GENERIC__VIROBJ__CONSTSTRING(env, obj, (virStorageVolPtr)VSVP, virStorageVolGetName)
-}
-
-JNIEXPORT jstring JNICALL Java_org_libvirt_StorageVol__1getPath
- (JNIEnv *env, jobject obj, jlong VSVP){
- GENERIC__VIROBJ__STRING(env, obj, (virStorageVolPtr)VSVP, virStorageVolGetPath)
-}
-
-JNIEXPORT jstring JNICALL Java_org_libvirt_StorageVol__1getXMLDesc
- (JNIEnv *env, jobject obj, jlong VSVP, jint flags){
- GENERIC_VIROBJ_INT__STRING(env, obj, (virStorageVolPtr)VSVP, flags,
virStorageVolGetXMLDesc)
-}
-
diff --git a/src/main/java/org/libvirt/.cvsignore b/src/main/java/org/libvirt/.cvsignore
new file mode 100644
index 0000000..6b468b6
--- /dev/null
+++ b/src/main/java/org/libvirt/.cvsignore
@@ -0,0 +1 @@
+*.class
diff --git a/src/main/java/org/libvirt/Connect.java
b/src/main/java/org/libvirt/Connect.java
new file mode 100644
index 0000000..5041611
--- /dev/null
+++ b/src/main/java/org/libvirt/Connect.java
@@ -0,0 +1,878 @@
+package org.libvirt;
+
+import java.util.Arrays;
+
+import org.libvirt.LibvirtException;
+import org.libvirt.StoragePool;
+import org.libvirt.StorageVol;
+import org.libvirt.jna.ConnectionPointer;
+import org.libvirt.jna.DomainPointer;
+import org.libvirt.jna.Libvirt;
+import org.libvirt.jna.NetworkPointer;
+import org.libvirt.jna.StoragePoolPointer;
+import org.libvirt.jna.StorageVolPointer;
+import org.libvirt.jna.virConnectAuth;
+import org.libvirt.jna.virError;
+import org.libvirt.jna.virNodeInfo;
+
+import com.sun.jna.Native;
+import com.sun.jna.NativeLong;
+import com.sun.jna.Pointer;
+import com.sun.jna.ptr.ByReference;
+import com.sun.jna.ptr.LongByReference;
+
+/**
+ * The Connect object represents a connection to a local or remote hypervisor/driver.
+ *
+ * @author stoty
+ *
+ */
+public class Connect {
+
+ // Load the native part
+ static {
+ Libvirt.INSTANCE.virInitialize() ;
+ try {
+ ErrorHandler.processError(Libvirt.INSTANCE) ;
+ }
+ catch (Exception e) {
+ e.printStackTrace() ;
+ }
+ }
+
+ /**
+ * the native virConnectPtr.
+ */
+ protected ConnectionPointer VCP;
+
+
+ /**
+ * The libvirt library
+ */
+ Libvirt libvirt = Libvirt.INSTANCE ;
+
+ /**
+ * Construct a Connect object from a known native virConnectPtr
+ * For use when native libvirt returns a virConnectPtr, i.e. error handling.
+ *
+ * @param VCP the virConnectPtr pointing to an existing native virConnect structure
+ */
+ @Deprecated
+ Connect(long VCP) {
+ throw new RuntimeException("No longer supported") ;
+ }
+
+ /**
+ * Constructs a Connect object from the supplied URI.
+ *
+ * @param uri The connection URI
+ * @param readOnly Whether the connection is read-only
+ * @throws LibvirtException
+ * @see <a
href="http://libvirt.org/uri.html">The URI
documentation</a>
+ */
+ public Connect(String uri, boolean readOnly) throws LibvirtException {
+ if (readOnly) {
+ VCP = libvirt.virConnectOpenReadOnly(uri) ;
+ } else {
+ VCP = libvirt.virConnectOpen(uri) ;
+ }
+ // Check for an error
+ processError() ;
+ ErrorHandler.processError(Libvirt.INSTANCE) ;
+ }
+
+ /**
+ * Constructs a Connect object from the supplied URI,
+ * using the supplied authentication callback
+ *
+ * @param uri The connection URI
+ * @param auth a ConnectAuth object
+ * @param flags
+ * @throws LibvirtException
+ * @see <a
href="http://libvirt.org/uri.html">The URI
documentation</a>
+ */
+ public Connect(String uri, ConnectAuth auth, int flags) throws LibvirtException {
+ virConnectAuth vAuth = new virConnectAuth() ;
+ vAuth.cb = auth ;
+ vAuth.cbdata = null ;
+ vAuth.ncredtype = auth.credType.length ;
+ vAuth.credtype = new int[vAuth.ncredtype] ;
+
+ for (int x = 0 ; x < vAuth.ncredtype ; x++) {
+ vAuth.credtype[x] = auth.credType[x].ordinal() ;
+ }
+
+ VCP = libvirt.virConnectOpenAuth(uri, vAuth, flags) ;
+ // Check for an error
+ processError() ;
+ ErrorHandler.processError(Libvirt.INSTANCE) ;
+ }
+
+ /**
+ * Constructs a read-write Connect object from the supplied URI.
+ *
+ * @param uri The connection URI
+ * @throws LibvirtException
+ * @see <a
href="http://libvirt.org/uri.html">The URI
documentation</a>
+ */
+ public Connect(String uri) throws LibvirtException {
+ VCP = libvirt.virConnectOpen(uri) ;
+ // Check for an error
+ processError() ;
+ ErrorHandler.processError(Libvirt.INSTANCE) ;
+ }
+
+ public void finalize() throws LibvirtException {
+ close();
+ }
+
+
+ /**
+ * Closes the connection to the hypervisor/driver. Calling any methods on the object
after close() will result in an exception.
+ *
+ * @throws LibvirtException
+ */
+ public void close() throws LibvirtException {
+ libvirt.virConnectClose(VCP) ;
+ processError() ;
+ // If leave an invalid pointer dangling around JVM crashes and burns if
+ // someone tries to call a method on us
+ // We rely on the underlying libvirt error handling to detect that it's called with
a null virConnectPointer
+ VCP = null;
+ }
+
+
+ /**
+ * Provides capabilities of the hypervisor / driver.
+ *
+ * @return an XML String describing the capabilities.
+ * @throws LibvirtException
+ * @see <a
href="http://libvirt.org/format.html#Capa1" >The XML format
description</a>
+ *
+ */
+ public String getCapabilities() throws LibvirtException {
+ String returnValue = libvirt.virConnectGetCapabilities(VCP) ;
+ processError() ;
+ return returnValue ;
+ }
+
+
+ /**
+ * Returns the system hostname on which the hypervisor is running.
+ * (the result of the gethostname(2) system call)
+ * If we are connected to a remote system, then this returns the hostname of the remote
system.
+ *
+ * @return the hostname
+ * @throws LibvirtException
+ */
+ public String getHostName() throws LibvirtException {
+ String returnValue = libvirt.virConnectGetHostname(VCP) ;
+ processError() ;
+ return returnValue ;
+
+ }
+
+
+ /**
+ * Provides the maximum number of virtual CPUs supported for a guest VM of a specific
type.
+ * The 'type' parameter here corresponds to the 'type' attribute in the
<domain> element of the XML.
+ *
+ * @param type
+ * @return the number of CPUs
+ * @throws LibvirtException
+ */
+ public int getMaxVcpus(String type) throws LibvirtException {
+ int returnValue = libvirt.virConnectGetMaxVcpus(VCP, type) ;
+ processError() ;
+ return returnValue ;
+ }
+
+
+ /**
+ * Gets the name of the Hypervisor software used.
+ *
+ * @return the name
+ * @throws LibvirtException
+ */
+ public String getType() throws LibvirtException {
+ String returnValue = libvirt.virConnectGetType(VCP) ;
+ processError() ;
+ return returnValue ;
+ }
+
+
+
+ /**
+ * Returns the URI (name) of the hypervisor connection.
+ * Normally this is the same as or similar to the string passed to the
virConnectOpen/virConnectOpenReadOnly call,
+ * but the driver may make the URI canonical.
+ *
+ * @return the URI
+ * @throws LibvirtException
+ */
+ public String getURI() throws LibvirtException {
+ String returnValue = libvirt.virConnectGetURI(VCP) ;
+ processError() ;
+ return returnValue ;
+ }
+
+
+
+ /**
+ * Gets the version level of the Hypervisor running.
+ * This may work only with hypervisor call, i.e. with priviledged access to the
hypervisor, not with a Read-Only connection.
+ * If the version can't be extracted by lack of capacities returns 0.
+ *
+ * @return major * 1,000,000 + minor * 1,000 + release
+ * @throws LibvirtException
+ */
+ public long getVersion() throws LibvirtException {
+ LongByReference hvVer = new LongByReference() ;
+ libvirt.virConnectGetVersion(VCP, hvVer) ;
+ processError() ;
+ return hvVer.getValue();
+ }
+
+
+ /**
+ * Gets the version of the native libvirt library that the JNI part is linked to.
+ *
+ * @return major * 1,000,000 + minor * 1,000 + release
+ * @throws LibvirtException
+ */
+ public long getLibVirVersion() throws LibvirtException {
+ LongByReference libVer = new LongByReference() ;
+ LongByReference typeVer = new LongByReference() ;
+ libvirt.virGetVersion(libVer, null, typeVer) ;
+ processError() ;
+ return libVer.getValue();
+ }
+
+
+ /**
+ * Returns the version of the hypervisor against which the library was compiled.
+ * The type parameter specified which hypervisor's version is returned
+ *
+ * @param type
+ * @return major * 1,000,000 + minor * 1,000 + release
+ * @throws LibvirtException
+ */
+ public long GetHypervisorVersion(String type) throws LibvirtException {
+ LongByReference libVer = new LongByReference() ;
+ LongByReference typeVer = new LongByReference() ;
+ libvirt.virGetVersion(libVer, type, typeVer) ;
+ processError() ;
+ return libVer.getValue();
+ }
+
+
+ /**
+ * Lists the names of the defined but inactive domains
+ *
+ * @return an Array of Strings that contains the names of the defined domains currently
inactive
+ * @throws LibvirtException
+ */
+ public String[] listDefinedDomains() throws LibvirtException {
+ int maxnames = this.numOfDefinedDomains() ;
+ String[] names = new String[maxnames] ;
+ if (maxnames > 0) {
+ libvirt.virConnectListDefinedDomains(VCP, names, maxnames) ;
+ processError() ;
+ }
+ return names ;
+ }
+
+
+ /**
+ * Lists the inactive networks
+ *
+ * @return an Array of Strings that contains the names of the inactive networks
+ * @throws LibvirtException
+ */
+ public String[] listDefinedNetworks() throws LibvirtException {
+ int maxnames = this.numOfDefinedNetworks() ;
+ String[] names = new String[maxnames] ;
+
+ if (maxnames > 0) {
+ libvirt.virConnectListDefinedNetworks(VCP, names, maxnames) ;
+ processError() ;
+ }
+ return names ;
+ }
+
+
+ /**
+ * Lists the active domains.
+ *
+ * @return and array of the IDs of the active domains
+ * @throws LibvirtException
+ */
+ public int[] listDomains() throws LibvirtException {
+ int maxids = this.numOfDomains() ;
+ int[] ids = new int[maxids] ;
+
+ if (maxids > 0) {
+ libvirt.virConnectListDomains(VCP, ids, maxids) ;
+ processError() ;
+ }
+ return ids ;
+ }
+
+
+ /**
+ * Lists the active networks.
+ *
+ * @return an Array of Strings that contains the names of the active networks
+ * @throws LibvirtException
+ */
+ public String[] listNetworks() throws LibvirtException {
+ int maxnames = this.numOfNetworks() ;
+ String[] names = new String[maxnames] ;
+
+ if (maxnames > 0) {
+ libvirt.virConnectListNetworks(VCP, names, maxnames) ;
+ processError() ;
+ }
+ return names ;
+ }
+
+
+ /**
+ * Provides the number of inactive domains.
+ *
+ * @return the number of inactive domains
+ * @throws LibvirtException
+ */
+ public int numOfDefinedDomains() throws LibvirtException {
+ int returnValue = libvirt.virConnectNumOfDefinedDomains(VCP) ;
+ processError() ;
+ return returnValue ;
+ }
+
+
+
+ /**
+ * Provides the number of inactive networks.
+ *
+ * @return the number of inactive networks
+ * @throws LibvirtException
+ */
+ public int numOfDefinedNetworks() throws LibvirtException {
+ int returnValue = libvirt.virConnectNumOfDefinedNetworks(VCP) ;
+ processError() ;
+ return returnValue ;
+ }
+
+
+ /**
+ * Provides the number of active domains.
+ *
+ * @return the number of active domains
+ * @throws LibvirtException
+ */
+ public int numOfDomains() throws LibvirtException {
+ int returnValue = libvirt.virConnectNumOfDomains(VCP) ;
+ processError() ;
+ return returnValue ;
+ }
+
+
+ /**
+ * Provides the number of active networks.
+ *
+ * @return the number of active networks
+ * @throws LibvirtException
+ */
+ public int numOfNetworks() throws LibvirtException {
+ int returnValue = libvirt.virConnectNumOfNetworks(VCP) ;
+ processError() ;
+ return returnValue ;
+ }
+
+
+ // virNetwork stuff
+
+ /**
+ * Looks up a network on the based on its name.
+ *
+ * @param name name of the network
+ * @return The Network object found
+ * @throws LibvirtException
+ */
+ public Network networkLookupByName(String name)
+ throws LibvirtException {
+ Network returnValue = null ;
+ NetworkPointer ptr = libvirt.virNetworkLookupByName(VCP, name) ;
+ processError() ;
+ if (ptr != null) {
+ returnValue = new Network(this, ptr) ;
+ }
+ return returnValue ;
+ }
+
+
+ /**
+ * Looks up a network based on its UUID represented as an int array.
+ * The UUID Array contains an unpacked representation of the UUID, each int contains
only one byte.
+ *
+ * @param UUID the UUID as an unpacked int array
+ * @return The Network object found
+ * @throws LibvirtException
+ */
+ public Network networkLookupByUUID(int[] UUID)
+ throws LibvirtException {
+ String uuidString = Connect.createUUIDString(UUID) ;
+ Network returnValue = null ;
+ NetworkPointer ptr = libvirt.virNetworkLookupByUUID(VCP, uuidString) ;
+ processError() ;
+ if (ptr != null) {
+ returnValue = new Network(this, ptr) ;
+ }
+ return returnValue ;
+ }
+
+
+ /**
+ * Looks up a network based on its UUID represented as a String.
+ *
+ * @param UUID the UUID in canonical String representation
+ * @return The Network object found
+ * @throws LibvirtException
+ */
+ public Network networkLookupByUUIDString(String UUID)
+ throws LibvirtException {
+ Network returnValue = null ;
+ NetworkPointer ptr = libvirt.virNetworkLookupByUUIDString(VCP, UUID);
+ processError() ;
+ if (ptr != null) {
+ returnValue = new Network(this, ptr) ;
+ }
+ return returnValue ;
+ }
+
+
+ /**
+ * Creates and starts a new virtual network.
+ * The properties of the network are based on an XML description similar to the one
returned by virNetworkGetXMLDesc()
+ *
+ * @param xmlDesc the Network Description
+ * @return the Network object representing the created network
+ * @throws LibvirtException
+ * @see <a
href="http://libvirt.org/format.html#Net1" >The XML format
description</a>
+ */
+ public Network networkCreateXML(String xmlDesc)
+ throws LibvirtException {
+ Network returnValue = null ;
+ NetworkPointer ptr = libvirt.virNetworkCreateXML(VCP, xmlDesc) ;
+ processError() ;
+ if (ptr != null) {
+ returnValue = new Network(this, ptr) ;
+ }
+ return returnValue ;
+ }
+
+
+ /**
+ * Defines a network, but does not create it.
+ * The properties of the network are based on an XML description similar to the one
returned by virNetworkGetXMLDesc()
+ *
+ * @param xmlDesc
+ * @return the resulting Network object
+ * @throws LibvirtException
+ * @see <a
href="http://libvirt.org/format.html#Net1" >The XML format
description</a>
+ */
+ public Network networkDefineXML(String xmlDesc)
+ throws LibvirtException {
+ Network returnValue = null ;
+ NetworkPointer ptr = libvirt.virNetworkDefineXML(VCP, xmlDesc) ;
+ processError() ;
+ if (ptr != null) {
+ returnValue = new Network(this, ptr) ;
+ }
+ return returnValue ;
+ }
+
+
+ /**
+ * Finds a domain based on the hypervisor ID number.
+ *
+ * @param id the hypervisor id
+ * @return the Domain object
+ * @throws LibvirtException
+ */
+ public Domain domainLookupByID(int id) throws LibvirtException {
+ Domain returnValue = null ;
+ DomainPointer ptr = libvirt.virDomainLookupByID(VCP, id) ;
+ processError() ;
+ if (ptr != null) {
+ returnValue = new Domain(this, ptr) ;
+ }
+ return returnValue ;
+ }
+
+
+ /**
+ * Looks up a domain based on its name.
+ *
+ * @param name the name of the domain
+ * @return the Domain object
+ * @throws LibvirtException
+ */
+ public Domain domainLookupByName(String name) throws LibvirtException {
+ Domain returnValue = null ;
+ DomainPointer ptr = libvirt.virDomainLookupByName(VCP, name) ;
+ processError() ;
+ if (ptr != null) {
+ returnValue = new Domain(this, ptr) ;
+ }
+ return returnValue ;
+ }
+
+
+ /**
+ * Looks up a domain based on its UUID in array form.
+ * The UUID Array contains an unpacked representation of the UUID, each int contains
only one byte.
+ *
+ * @param UUID the UUID as an unpacked int array
+ * @return the Domain object
+ * @throws LibvirtException
+ */
+ public Domain domainLookupByUUID(int[] UUID) throws LibvirtException {
+ String uuidString = Connect.createUUIDString(UUID) ;
+ Domain returnValue = null ;
+ DomainPointer ptr = libvirt.virDomainLookupByUUID(VCP, uuidString) ;
+ processError() ;
+ if (ptr != null) {
+ returnValue = new Domain(this, ptr) ;
+ }
+ return returnValue ;
+ }
+
+ /**
+ * Looks up a domain based on its UUID in String form.
+ *
+ * @param UUID the UUID in canonical String representation
+ * @return the Domain object
+ * @throws LibvirtException
+ */
+ public Domain domainLookupByUUIDString(String UUID)
+ throws LibvirtException {
+ Domain returnValue = null ;
+ DomainPointer ptr = libvirt.virDomainLookupByUUIDString(VCP, UUID) ;
+ processError() ;
+ if (ptr != null) {
+ returnValue = new Domain(this, ptr) ;
+ }
+ return returnValue ;
+ }
+
+
+ /**
+ * Launches a new Linux guest domain.
+ * The domain is based on an XML description similar to the one returned by
virDomainGetXMLDesc().
+ * This function may require priviledged access to the hypervisor.
+ *
+ * @param xmlDesc the Domain description in XML
+ * @param flags an optional set of flags (unused)
+ * @return the Domain object
+ * @throws LibvirtException
+ * @see <a
href="http://libvirt.org/format.html#Normal1" > The XML
format description </a>
+ */
+ public Domain domainCreateLinux(String xmlDesc, int flags)
+ throws LibvirtException {
+ Domain returnValue = null ;
+ DomainPointer ptr = libvirt.virDomainCreateLinux(VCP, xmlDesc, flags) ;
+ processError() ;
+ if (ptr != null) {
+ returnValue = new Domain(this, ptr) ;
+ }
+ return returnValue ;
+ }
+
+
+ /**
+ * Defines a domain, but does not start it
+ *
+ * @param xmlDesc
+ * @return the Domain object
+ * @throws LibvirtException
+ * @see <a
href="http://libvirt.org/format.html#Normal1" > The XML
format description </a>
+ */
+ public Domain domainDefineXML(String xmlDesc) throws LibvirtException {
+ Domain returnValue = null ;
+ DomainPointer ptr = libvirt.virDomainDefineXML(VCP, xmlDesc) ;
+ processError() ;
+ if (ptr != null) {
+ returnValue = new Domain(this, ptr) ;
+ }
+ return returnValue ;
+ }
+
+
+ /**
+ * Launch a new guest domain, based on an XML description
+ *
+ * @param xmlDesc
+ * @return the Domain object
+ * @throws LibvirtException
+ * @see <a
href="http://libvirt.org/format.html#Normal1" > The XML
format description </a>
+ */
+ public Domain domainCreateXML(String xmlDesc, int flags) throws LibvirtException {
+ Domain returnValue = null ;
+ DomainPointer ptr = libvirt.virDomainCreateXML(VCP, xmlDesc, flags) ;
+ processError() ;
+ if (ptr != null) {
+ returnValue = new Domain(this, ptr) ;
+ }
+ return returnValue ;
+ }
+
+
+ /**
+ * Restores a domain saved to disk by Domain.save().
+ *
+ * @param from the path of the saved file on the remote host
+ * @throws LibvirtException
+ */
+ public void restore(String from) throws LibvirtException {
+ libvirt.virDomainRestore(VCP, from);
+ processError() ;
+ }
+
+
+ /**
+ * Returns a NodeInfo object describing the hardware configuration of the node.
+ *
+ * @return a NodeInfo object
+ * @throws LibvirtException
+ */
+ public NodeInfo nodeInfo() throws LibvirtException {
+ virNodeInfo vInfo = new virNodeInfo();
+ libvirt.virNodeGetInfo(VCP,vInfo) ;
+ processError() ;
+ return new NodeInfo(vInfo) ;
+ }
+
+
+ /**
+ * change the amount of memory reserved to Domain0.
+ * Domain0 is the domain where the application runs.
+ * This function may requires priviledged access to the hypervisor.
+ *
+ * @param memory in kilobytes
+ * @throws LibvirtException
+ */
+ public void setDom0Memory(long memory) throws LibvirtException {
+ libvirt.virDomainSetMemory(null, new NativeLong(memory)) ;
+ processError() ;
+ }
+
+
+ /**
+ * Provides the number of inactive storage pools
+ *
+ * @return the number of pools found
+ * @throws LibvirtException
+ */
+ public int numOfDefinedStoragePools() throws LibvirtException {
+ int returnValue = libvirt.virConnectNumOfDefinedStoragePools(VCP);
+ processError() ;
+ return returnValue ;
+ }
+
+
+ /**
+ * Provides the number of active storage pools
+ *
+ * @return the number of pools found
+ * @throws LibvirtException
+ */
+ public int numOfStoragePools() throws LibvirtException {
+ int returnValue = libvirt.virConnectNumOfStoragePools(VCP);
+ processError() ;
+ return returnValue ;
+ }
+
+
+ /**
+ * Provides the list of names of inactive storage pools.
+ *
+ * @return an Array of Strings that contains the names of the defined storage pools
+ * @throws LibvirtException
+ */
+ public String[] listDefinedStoragePools() throws LibvirtException {
+ int num = this.numOfDefinedStoragePools() ;
+ String[] returnValue = new String[num] ;
+ libvirt.virConnectListDefinedStoragePools(VCP, returnValue, num) ;
+ processError() ;
+ return returnValue ;
+ }
+
+
+ /**
+ * Provides the list of names of active storage pools.
+ *
+ * @return an Array of Strings that contains the names of the defined storage pools
+ * @throws LibvirtException
+ */
+ public String[] listStoragePools() throws LibvirtException {
+ int num = this.numOfStoragePools() ;
+ String[] returnValue = new String[num] ;
+ libvirt.virConnectListStoragePools(VCP, returnValue, num) ;
+ processError() ;
+ return returnValue ;
+ }
+
+
+ /**
+ * Create a new storage based on its XML description.
+ * The pool is not persistent, so its definition will disappear when it is destroyed, or
if the host is restarted
+ *
+ * @param xmlDesc XML description for new pool
+ * @param flags future flags, use 0 for now
+ * @return StoragePool object
+ * @throws LibvirtException
+ */
+ public StoragePool storagePoolCreateXML(String xmlDesc, int flags)
+ throws LibvirtException {
+ StoragePoolPointer ptr = libvirt.virStoragePoolCreateXML(VCP, xmlDesc, flags) ;
+ processError() ;
+ return new StoragePool(this, ptr) ;
+ }
+
+
+ /**
+ * Define a new inactive storage pool based on its XML description.
+ * The pool is persistent, until explicitly undefined.
+ *
+ * @param xml XML description for new pool
+ * @param flags flags future flags, use 0 for now
+ * @return StoragePool object
+ * @throws LibvirtException
+ */
+ public StoragePool storagePoolDefineXML(String xml, int flags)
+ throws LibvirtException {
+ StoragePoolPointer ptr = libvirt.virStoragePoolDefineXML(VCP, xml, flags) ;
+ processError() ;
+ return new StoragePool(this, ptr) ;
+ }
+
+
+ /**
+ * Fetch a storage pool based on its unique name
+ *
+ * @param name name of pool to fetch
+ * @return StoragePool object
+ * @throws LibvirtException
+ */
+ public StoragePool storagePoolLookupByName(String name)
+ throws LibvirtException {
+ StoragePoolPointer ptr = libvirt.virStoragePoolLookupByName(VCP, name) ;
+ processError() ;
+ return new StoragePool(this, ptr) ;
+ }
+
+
+ /**
+ * Fetch a storage pool based on its globally unique id
+ *
+ * @param UUID globally unique id of pool to fetch
+ * @return a new network object
+ * @throws LibvirtException
+ */
+ public StoragePool storagePoolLookupByUUID(int[] UUID)
+ throws LibvirtException {
+ String uuidString = Connect.createUUIDString(UUID) ;
+ StoragePool returnValue = null ;
+ StoragePoolPointer ptr = libvirt.virStoragePoolLookupByUUID(VCP, uuidString) ;
+ processError() ;
+ if (ptr != null) {
+ returnValue = new StoragePool(this, ptr) ;
+ }
+ return returnValue ;
+ }
+
+
+ /**
+ * Fetch a storage pool based on its globally unique id
+ *
+ * @param UUID globally unique id of pool to fetch
+ * @return VirStoragePool object
+ * @throws LibvirtException
+ */
+ public StoragePool storagePoolLookupByUUIDString(String UUID)
+ throws LibvirtException {
+ StoragePool returnValue = null ;
+ StoragePoolPointer ptr = libvirt.virStoragePoolLookupByUUIDString(VCP, UUID) ;
+ processError() ;
+ if (ptr != null) {
+ returnValue = new StoragePool(this, ptr) ;
+ }
+ return returnValue ;
+ }
+
+
+ /**
+ * Fetch a a storage volume based on its globally unique key
+ *
+ * @param key globally unique key
+ * @return a storage volume
+ */
+ public StorageVol storageVolLookupByKey(String key)
+ throws LibvirtException {
+ StorageVolPointer sPtr = libvirt.virStorageVolLookupByKey(VCP, key) ;
+ processError() ;
+ return new StorageVol(this, sPtr) ;
+ }
+
+
+ /**
+ * Fetch a storage volume based on its locally (host) unique path
+ *
+ * @param path locally unique path
+ * @return a storage volume
+ */
+ public StorageVol storageVolLookupByPath(String path)
+ throws LibvirtException {
+ StorageVolPointer sPtr = libvirt.virStorageVolLookupByPath(VCP, path) ;
+ processError() ;
+ return new StorageVol(this, sPtr) ;
+ }
+
+
+ /**
+ * call the error handling logic. Should be called after
+ * every libvirt call
+ * @throws LibvirtException
+ */
+ protected void processError() throws LibvirtException {
+ ErrorHandler.processError(libvirt, VCP) ;
+ }
+
+
+ /**
+ * Helper function to convert bytes into ints for the
+ * UUID calls
+ */
+ public static int[] convertUUIDBytes(byte bytes[]) {
+ int[] returnValue = new int[Libvirt.VIR_UUID_BUFLEN] ;
+ for (int x = 0 ; x < Libvirt.VIR_UUID_BUFLEN ; x++) {
+ returnValue[x] = (int) bytes[x] ;
+ }
+ return returnValue ;
+ }
+
+
+ /**
+ * Helper function to convert UUIDs into a stirng
+ * for the UUID calls
+ */
+ public static String createUUIDString(int[] UUID) {
+ StringBuilder uuidString = new StringBuilder() ;
+ for (int i : UUID) {
+ uuidString.append(i) ;
+ }
+ return uuidString.toString() ;
+ }
+
+}
diff --git a/src/main/java/org/libvirt/ConnectAuth.java
b/src/main/java/org/libvirt/ConnectAuth.java
new file mode 100644
index 0000000..e29f010
--- /dev/null
+++ b/src/main/java/org/libvirt/ConnectAuth.java
@@ -0,0 +1,153 @@
+package org.libvirt;
+
+import org.libvirt.jna.Libvirt;
+import org.libvirt.jna.virConnectCredential;
+
+import com.sun.jna.Pointer;
+
+/**
+ * We diverge from the C implementation
+ * There is no explicit cbdata field, you should just add any extra data to the child
class's instance.
+ *
+ * @author stoty
+ *
+ */
+public abstract class ConnectAuth implements Libvirt.VirConnectAuthCallback {
+ /**
+ * @author stoty
+ *
+ */
+ public static enum CredentialType {
+ // This is off by one, but we don't care, because we can't convert java Enum to
C enum in a sane way anyway
+ /**
+ * Identity to act as
+ */
+ VIR_CRED_USERNAME,
+ /**
+ * Identify to authorize as
+ */
+ VIR_CRED_AUTHNAME,
+ /**
+ * RFC 1766 languages, comma separated
+ */
+ VIR_CRED_LANGUAGE,
+ /**
+ * client supplies a nonce
+ */
+ VIR_CRED_CNONCE,
+ /**
+ * Passphrase secret
+ */
+ VIR_CRED_PASSPHRASE,
+ /**
+ * Challenge response
+ */
+ VIR_CRED_ECHOPROMPT,
+ /**
+ * Challenge response
+ */
+ VIR_CRED_NOECHOPROMPT,
+ /**
+ * Authentication realm
+ */
+ VIR_CRED_REALM,
+ /**
+ * Externally managed credential More may be added - expect the unexpected
+ */
+ VIR_CRED_EXTERNAL;
+
+ /**
+ * Maps the java CredentialType Enum to libvirt's integer constant
+ *
+ * @return The integer equivalent
+ */
+ @SuppressWarnings("all")
+ private int mapToInt(){
+ switch(this){
+ case VIR_CRED_USERNAME: return 1;
+ case VIR_CRED_AUTHNAME: return 2;
+ case VIR_CRED_LANGUAGE: return 3;
+ case VIR_CRED_CNONCE: return 4;
+ case VIR_CRED_PASSPHRASE: return 5;
+ case VIR_CRED_ECHOPROMPT: return 6;
+ case VIR_CRED_NOECHOPROMPT: return 7;
+ case VIR_CRED_REALM: return 8;
+ case VIR_CRED_EXTERNAL: return 9;
+ }
+ //We may never reach this point
+ assert(false);
+ return 0;
+ }
+ }
+ public class Credential {
+
+
+ /**
+ * One of virConnectCredentialType constants
+ */
+ public CredentialType type;
+ /**
+ * Prompt to show to user
+ */
+ public String prompt;
+ /**
+ * Additional challenge to show
+ */
+ public String challenge;
+ /**
+ * Optional default result
+ */
+ public String defresult;
+ /**
+ * Result to be filled with user response (or defresult)
+ */
+ public String result;
+
+ /**
+ * Convenience constructor to be called from the JNI side
+ *
+ * @param type
+ * @param prompt
+ * @param challenge
+ * @param defresult
+ */
+ Credential(int type, String prompt, String challenge, String defresult){
+ switch(type){
+ case 1: this.type=CredentialType.VIR_CRED_USERNAME; break;
+ case 2: this.type=CredentialType.VIR_CRED_AUTHNAME; break;
+ case 3: this.type=CredentialType.VIR_CRED_LANGUAGE; break;
+ case 4: this.type=CredentialType.VIR_CRED_CNONCE; break;
+ case 5: this.type=CredentialType.VIR_CRED_PASSPHRASE; break;
+ case 6: this.type=CredentialType.VIR_CRED_ECHOPROMPT; break;
+ case 7: this.type=CredentialType.VIR_CRED_NOECHOPROMPT; break;
+ case 8: this.type=CredentialType.VIR_CRED_REALM; break;
+ case 9: this.type=CredentialType.VIR_CRED_EXTERNAL; break;
+ default: assert(false);
+ }
+ this.prompt = prompt;
+ this.challenge = challenge;
+ this.defresult = defresult;
+ }
+
+
+ }
+
+
+ public int authCallback(virConnectCredential cred, int ncred, Pointer cbdata) {
+ System.out.println("HELLO!!!!!!!!!!!!!!!!!!!!!!!!!") ;
+ return 1 ;
+ }
+
+ /**
+ * List of supported ConnectCredential.CredentialType values
+ */
+ public CredentialType credType[];
+
+ /**
+ * The callback function that fills the credentials in
+ * @param cred the array of credentials passed by libvirt
+ * @return 0 if the defresult field contains a vailde response, -1 otherwise
+ */
+ public abstract int callback(Credential[] cred);
+
+}
diff --git a/src/main/java/org/libvirt/ConnectAuthDefault.java
b/src/main/java/org/libvirt/ConnectAuthDefault.java
new file mode 100644
index 0000000..0f979e1
--- /dev/null
+++ b/src/main/java/org/libvirt/ConnectAuthDefault.java
@@ -0,0 +1,59 @@
+package org.libvirt;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+
+/**
+ * @author stoty
+ * Implements virConnectAuthPtrDefault functionality from libvirt.c without the external
method support
+ * It's not officially a part of the libvirt API, but provided here for completeness,
testing, and as an example
+ */
+public final class ConnectAuthDefault extends ConnectAuth {
+
+ {
+ credType= new CredentialType[] {
+ CredentialType.VIR_CRED_AUTHNAME,
+ CredentialType.VIR_CRED_ECHOPROMPT,
+ CredentialType.VIR_CRED_REALM,
+ CredentialType.VIR_CRED_PASSPHRASE,
+ CredentialType.VIR_CRED_NOECHOPROMPT
+ };
+ }
+
+ @Override
+ public int callback(Credential[] cred) {
+ BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
+ try{
+ for(Credential c: cred){
+ String response="";
+ switch(c.type){
+ case VIR_CRED_USERNAME:
+ case VIR_CRED_AUTHNAME:
+ case VIR_CRED_ECHOPROMPT:
+ case VIR_CRED_REALM:
+ System.out.println(c.prompt);
+ response= in.readLine();
+ break;
+ case VIR_CRED_PASSPHRASE:
+ case VIR_CRED_NOECHOPROMPT:
+ System.out.println(c.prompt);
+ System.out.println("WARNING: THE ENTERED PASSWORD WILL NOT BE MASKED!");
+ response= in.readLine();
+ break;
+ }
+ if(response.equals("") && !c.defresult.equals("")){
+ c.result=c.defresult;
+ } else {
+ c.result=response;
+ }
+ if(c.result.equals("")){
+ return -1;
+ }
+ }
+ } catch (Exception e) {
+ return -1;
+ }
+ return 0;
+ }
+
+}
diff --git a/src/main/java/org/libvirt/Domain.java
b/src/main/java/org/libvirt/Domain.java
new file mode 100644
index 0000000..6f57b96
--- /dev/null
+++ b/src/main/java/org/libvirt/Domain.java
@@ -0,0 +1,655 @@
+package org.libvirt;
+
+import org.libvirt.jna.DomainPointer;
+import org.libvirt.jna.Libvirt;
+import org.libvirt.jna.virDomainBlockStats;
+import org.libvirt.jna.virDomainInfo;
+import org.libvirt.jna.virDomainInterfaceStats;
+import org.libvirt.jna.virSchedParameter;
+import org.libvirt.jna.virVcpuInfo;
+
+import com.sun.jna.Native;
+import com.sun.jna.NativeLong;
+import com.sun.jna.Pointer;
+import com.sun.jna.ptr.IntByReference;
+
+public class Domain {
+
+ static final class CreateFlags{
+ static final int VIR_DOMAIN_NONE = 0;
+ }
+
+ static final class MigrateFlags{
+ /**
+ * live migration
+ */
+ static final int VIR_MIGRATE_LIVE = 1;
+ }
+
+ static final class XMLFlags{
+ /**
+ * dump security sensitive information too
+ */
+ static final int VIR_DOMAIN_XML_SECURE = 1;
+ /**
+ * dump inactive domain information
+ */
+ static final int VIR_DOMAIN_XML_INACTIVE = 2;
+ }
+
+ /**
+ * the native virDomainPtr.
+ */
+ private DomainPointer VDP;
+
+ /**
+ * The Connect Object that represents the Hypervisor of this Domain
+ */
+ private Connect virConnect;
+
+ /**
+ * The libvirt connection from the hypervisor
+ */
+ protected Libvirt libvirt ;
+
+
+ /**
+ * Constructs a Domain object from a known native virDomainPtr, and a Connect object.
+ * For use when native libvirt returns a virConnectPtr, i.e. error handling.
+ *
+ * @param virConnect the Domain's hypervisor
+ * @param VDP the native virDomainPtr
+ */
+ Domain(Connect virConnect, DomainPointer VDP){
+ this.virConnect = virConnect;
+ this.VDP = VDP;
+ this.libvirt = virConnect.libvirt ;
+ }
+
+ /**
+ * Provides an XML description of the domain.
+ * The description may be reused later to relaunch the domain with createLinux().
+ *
+ * @param flags not used
+ * @return the XML description String
+ * @throws LibvirtException
+ * @see <a
href="http://libvirt.org/format.html#Normal1" >The XML
Description format </a>
+ */
+ public String getXMLDesc(int flags) throws LibvirtException{
+ String returnValue = libvirt.virDomainGetXMLDesc(VDP, flags) ;
+ processError() ;
+ return returnValue ;
+ }
+
+
+ /**
+ * Provides a boolean value indicating whether the network is configured to be
automatically started when the host machine boots.
+ *
+ * @return the result
+ * @throws LibvirtException
+ */
+ public boolean getAutostart() throws LibvirtException{
+ IntByReference autoStart = new IntByReference() ;
+ libvirt.virDomainGetAutostart(VDP, autoStart) ;
+ processError() ;
+ return autoStart.getValue() != 0 ? true : false ;
+ }
+
+
+ /**
+ * Configures the network to be automatically started when the host machine boots.
+ *
+ * @param autostart
+ * @throws LibvirtException
+ */
+ public void setAutostart(boolean autostart) throws LibvirtException{
+ int autoValue = autostart ? 1 : 0 ;
+ libvirt.virDomainSetAutostart(VDP, autoValue) ;
+ processError() ;
+ }
+
+
+ /**
+ * Provides the connection object associated with a domain.
+ *
+ * @return the Connect object
+ */
+ public Connect getConnect(){
+ return virConnect;
+ }
+
+ /**
+ * Gets the hypervisor ID number for the domain
+ *
+ * @return the hypervisor ID
+ * @throws LibvirtException
+ */
+ public int getID() throws LibvirtException{
+ int returnValue = libvirt.virDomainGetID(VDP);
+ processError() ;
+ return returnValue ;
+ }
+
+
+
+ /**
+ * Extract information about a domain.
+ * Note that if the connection used to get the domain is limited only a partial set of
the information can be extracted.
+ *
+ * @return a DomainInfo object describing this domain
+ * @throws LibvirtException
+ */
+ public DomainInfo getInfo() throws LibvirtException{
+ DomainInfo returnValue = null ;
+ virDomainInfo vInfo = new virDomainInfo() ;
+ int success = libvirt.virDomainGetInfo(VDP, vInfo) ;
+ processError() ;
+ if (success == 0) {
+ returnValue = new DomainInfo(vInfo) ;
+ }
+ return returnValue ;
+ }
+
+ /**
+ * Retrieve the maximum amount of physical memory allocated to a domain.
+ *
+ * @return the memory in kilobytes
+ * @throws LibvirtException
+ */
+ public long getMaxMemory() throws LibvirtException{
+ NativeLong returnValue = libvirt.virDomainGetMaxMemory(VDP) ;
+ processError() ;
+ return returnValue.longValue() ;
+ }
+
+
+ /**
+ * * Dynamically change the maximum amount of physical memory allocated to a domain.
+ * This function requires priviledged access to the hypervisor.
+ *
+ * @param memory the amount memory in kilobytes
+ * @throws LibvirtException
+ */
+ public void setMaxMemory(long memory) throws LibvirtException{
+ libvirt.virDomainSetMaxMemory(VDP, new NativeLong(memory)) ;
+ processError() ;
+ }
+
+
+ /**
+ * Provides the maximum number of virtual CPUs supported for the guest VM.
+ * If the guest is inactive, this is basically the same as virConnectGetMaxVcpus.
+ * If the guest is running this will reflect the maximum number of virtual CPUs the
guest was booted with.
+ *
+ * @return the number of VCPUs
+ * @throws LibvirtException
+ */
+ public int getMaxVcpus() throws LibvirtException{
+ int returnValue = libvirt.virDomainGetMaxVcpus(VDP) ;
+ processError() ;
+ return returnValue ;
+ }
+
+
+ /**
+ * Gets the public name for this domain
+ *
+ * @return the name
+ * @throws LibvirtException
+ */
+ public String getName() throws LibvirtException{
+ String returnValue = libvirt.virDomainGetName(VDP);
+ processError() ;
+ return returnValue ;
+ }
+
+
+ /**
+ * Gets the type of domain operation system.
+ *
+ * @return the type
+ * @throws LibvirtException
+ */
+ public String getOSType() throws LibvirtException{
+ String returnValue = libvirt.virDomainGetOSType(VDP);
+ processError() ;
+ return returnValue ;
+ }
+
+
+ /**
+ * Gets the scheduler parameters.
+ *
+ * @return an array of SchedParameter objects
+ * @throws LibvirtException
+ */
+ public SchedParameter[] getSchedulerParameters() throws LibvirtException{
+ IntByReference nParams = new IntByReference() ;
+ SchedParameter[] returnValue = new SchedParameter[0] ;
+ String scheduler = libvirt.virDomainGetSchedulerType(VDP, nParams) ;
+ processError() ;
+ if (scheduler != null) {
+ virSchedParameter[] nativeParams = new virSchedParameter[nParams.getValue()] ;
+ returnValue = new SchedParameter[nParams.getValue()] ;
+ libvirt.virDomainGetSchedulerParameters(VDP, nativeParams, nParams) ;
+ processError() ;
+ for (int x = 0 ; x < nParams.getValue() ; x++ ) {
+ returnValue[x] = SchedParameter.create(nativeParams[x]) ;
+ }
+ }
+
+ return returnValue ;
+ }
+
+
+ /**
+ * Changes the scheduler parameters
+ *
+ * @param params an array of SchedParameter objects to be changed
+ * @throws LibvirtException
+ */
+ public void setSchedulerParameters(SchedParameter[] params) throws LibvirtException{
+ IntByReference nParams = new IntByReference() ;
+ nParams.setValue(params.length) ;
+ virSchedParameter[] input = new virSchedParameter[params.length] ;
+ for (int x = 0 ; x < params.length ; x++) {
+ input[x] = SchedParameter.toNative(params[x]) ;
+ }
+ libvirt.virDomainSetSchedulerParameters(VDP, input, nParams) ;
+ processError() ;
+ }
+
+
+ //getSchedulerType
+ //We don't expose the nparams return value, it's only needed for the
SchedulerParameters allocations,
+ //but we handle that in getSchedulerParameters internally.
+ /**
+ * Gets the scheduler type.
+ *
+ * @return the type of the scheduler
+ * @throws LibvirtException
+ */
+ public String[] getSchedulerType() throws LibvirtException{
+ IntByReference nParams = new IntByReference() ;
+ String returnValue = libvirt.virDomainGetSchedulerType(VDP, nParams) ;
+ processError() ;
+ String[] array = new String[1] ;
+ array[0] = returnValue ;
+ return array;
+ }
+
+
+ /**
+ * Get the UUID for this domain.
+ *
+ * @return the UUID as an unpacked int array
+ * @throws LibvirtException
+ * @see <a
href="http://www.ietf.org/rfc/rfc4122.txt">rfc4122</a>
+ */
+ public int[] getUUID() throws LibvirtException{
+ byte[] bytes = new byte[Libvirt.VIR_UUID_BUFLEN] ;
+ int success = libvirt.virDomainGetUUID(VDP, bytes) ;
+ processError() ;
+ int[] returnValue = new int[0] ;
+ if (success == 0) {
+ returnValue = Connect.convertUUIDBytes(bytes) ;
+ }
+ return returnValue ;
+ }
+
+
+ /**
+ * Gets the UUID for this domain as string.
+ *
+ * @return the UUID in canonical String format
+ * @throws LibvirtException
+ * @see <a
href="http://www.ietf.org/rfc/rfc4122.txt">rfc4122</a>
+ */
+ public String getUUIDString() throws LibvirtException{
+ byte[] bytes = new byte[Libvirt.VIR_UUID_STRING_BUFLEN] ;
+ int success = libvirt.virDomainGetUUIDString(VDP, bytes) ;
+ processError() ;
+ String returnValue = null ;
+ if (success == 0) {
+ returnValue = Native.toString(bytes) ;
+ }
+ return returnValue ;
+ }
+
+ /**
+ * Extracts information about virtual CPUs of this domain
+ *
+ * @return an array of VcpuInfo object describing the VCPUs
+ * @throws LibvirtException
+ */
+ public VcpuInfo[] getVcpusInfo() throws LibvirtException{
+ int cpuCount = this.getMaxVcpus() ;
+ VcpuInfo[] returnValue = new VcpuInfo[cpuCount] ;
+ virVcpuInfo[] infos = new virVcpuInfo[cpuCount] ;
+ libvirt.virDomainGetVcpus(VDP, infos, cpuCount, null, 0) ;
+ processError() ;
+ for (int x = 0 ; x < cpuCount ; x++) {
+ returnValue[x] = new VcpuInfo(infos[x]) ;
+ }
+ return returnValue ;
+ }
+
+
+
+ /**
+ * Returns the cpumaps for this domain
+ * Only the lower 8 bits of each int in the array contain information.
+ *
+ * @return a bitmap of real CPUs for all vcpus of this domain
+ * @throws LibvirtException
+ */
+ public int[] getVcpusCpuMaps() throws LibvirtException{
+ int[] returnValue = new int[0] ;
+ int cpuCount = this.getMaxVcpus() ;
+
+ if (cpuCount >0) {
+ NodeInfo nodeInfo = virConnect.nodeInfo() ;
+ int maplength = cpuMapLength(nodeInfo.maxCpus()) ;
+ virVcpuInfo[] infos = new virVcpuInfo[cpuCount] ;
+ returnValue = new int[cpuCount*maplength] ;
+ byte[] cpumaps = new byte[cpuCount*maplength] ;
+ libvirt.virDomainGetVcpus(VDP, infos, cpuCount, cpumaps, maplength) ;
+ processError() ;
+ for (int x =0 ; x < cpuCount*maplength ; x++) {
+ returnValue[x] = (int) cpumaps[x] ;
+ }
+ }
+ return returnValue ;
+ }
+
+
+ /**
+ * Dynamically changes the real CPUs which can be allocated to a virtual CPU.
+ * This function requires priviledged access to the hypervisor.
+ *
+ * @param vcpu virtual cpu number
+ * @param cpumap bit map of real CPUs represented by the the lower 8 bits of each int in
the array. Each bit set to 1 means that corresponding CPU is usable. Bytes are stored in
little-endian order: CPU0-7, 8-15... In each byte, lowest CPU number is least significant
bit.
+ * @throws LibvirtException
+ */
+ public void pinVcpu(int vcpu, int[] cpumap) throws LibvirtException{
+ byte[] packedMap = new byte[cpumap.length] ;
+ for (int x = 0 ; x < cpumap.length ; x++) {
+ packedMap[x] = (byte) cpumap[x] ;
+ }
+ libvirt.virDomainPinVcpu(VDP, vcpu, packedMap, cpumap.length) ;
+ processError() ;
+ }
+
+
+ /**
+ * Dynamically changes the number of virtual CPUs used by this domain.
+ * Note that this call may fail if the underlying virtualization hypervisor does not
support it or if growing the number is arbitrary limited.
+ * This function requires priviledged access to the hypervisor.
+ *
+ * @param nvcpus the new number of virtual CPUs for this domain
+ * @throws LibvirtException
+ */
+ public void setVcpus(int nvcpus) throws LibvirtException{
+ libvirt.virDomainSetVcpus(VDP, nvcpus) ;
+ processError() ;
+ }
+
+
+ /**
+ * Creates a virtual device attachment to backend.
+ *
+ * @param xmlDesc XML description of one device
+ * @throws LibvirtException
+ */
+ public void attachDevice(String xmlDesc) throws LibvirtException{
+ libvirt.virDomainAttachDevice(VDP, xmlDesc);
+ processError() ;
+ }
+
+
+ /**
+ * Destroys a virtual device attachment to backend.
+ *
+ * @param xmlDesc XML description of one device
+ * @throws LibvirtException
+ */
+ public void detachDevice(String xmlDesc) throws LibvirtException{
+ libvirt.virDomainDetachDevice(VDP, xmlDesc);
+ processError() ;
+ }
+
+
+
+ /**
+ * Returns block device (disk) stats for block devices attached to this domain.
+ * The path parameter is the name of the block device.
+ * Get this by calling virDomainGetXMLDesc and finding the <target
dev='...'> attribute within //domain/devices/disk.
+ * (For example, "xvda"). Domains may have more than one block device.
+ * To get stats for each you should make multiple calls to this function.
+ * Individual fields within the DomainBlockStats object may be returned as -1, which
indicates that the hypervisor does not support that particular statistic.
+ *
+ * @param path path to the block device
+ * @return the statistics in a DomainBlockStats object
+ * @throws LibvirtException
+ */
+ public DomainBlockStats blockStats(String path) throws LibvirtException{
+ virDomainBlockStats stats = new virDomainBlockStats() ;
+ libvirt.virDomainBlockStats(VDP, path, stats, stats.size()) ;
+ processError() ;
+ return new DomainBlockStats(stats) ;
+ }
+
+
+ /**
+ * Returns network interface stats for interfaces attached to this domain.
+ * The path parameter is the name of the network interface.
+ * Domains may have more than network interface.
+ * To get stats for each you should make multiple calls to this function.
+ * Individual fields within the DomainInterfaceStats object may be returned as -1, which
indicates that the hypervisor does not support that particular statistic.
+ *
+ * @param path path to the interface
+ * @return the statistics in a DomainInterfaceStats object
+ * @throws LibvirtException
+ */
+ public DomainInterfaceStats interfaceStats(String path) throws LibvirtException{
+ virDomainInterfaceStats stats = new virDomainInterfaceStats() ;
+ libvirt.virDomainInterfaceStats(VDP, path, stats, stats.size()) ;
+ processError() ;
+ return new DomainInterfaceStats(stats) ;
+ }
+
+
+ /**
+ * Dumps the core of this domain on a given file for analysis.
+ * Note that for remote Xen Daemon the file path will be interpreted in the remote
host.
+ *
+ * @param to path for the core file
+ * @param flags extra flags, currently unused
+ * @throws LibvirtException
+ */
+ public void coreDump(String to, int flags) throws LibvirtException{
+ libvirt.virDomainCoreDump(VDP, to, flags) ;
+ processError() ;
+ }
+
+
+ /**
+ * Launches this defined domain.
+ * If the call succeed the domain moves from the defined to the running domains pools.
+ *
+ * @throws LibvirtException
+ */
+ public void create() throws LibvirtException{
+ libvirt.virDomainCreate(VDP);
+ processError() ;
+ }
+
+
+ /**
+ * Destroys this domain object.
+ * The running instance is shutdown if not down already and all resources used by it are
given back to the hypervisor.
+ * The data structure is freed and should not be used thereafter if the call does not
return an error.
+ * This function may requires priviledged access
+ *
+ * @throws LibvirtException
+ */
+ public void destroy() throws LibvirtException{
+ libvirt.virDomainDestroy(VDP);
+ processError() ;
+ }
+
+
+ /**
+ * Frees this domain object.
+ * The running instance is kept alive.
+ * The data structure is freed and should not be used thereafter.
+ *
+ * @throws LibvirtException
+ */
+ public void free() throws LibvirtException{
+ libvirt.virDomainFree(VDP);
+ processError() ;
+ VDP=null ;
+ }
+
+
+
+ /**
+ * Migrate this domain object from its current host to the destination host given by
dconn (a connection to the destination host).
+ * Flags may be one of more of the following: Domain.VIR_MIGRATE_LIVE Attempt a live
migration.
+ * If a hypervisor supports renaming domains during migration, then you may set the
dname parameter to the new name (otherwise it keeps the same name).
+ * If this is not supported by the hypervisor, dname must be NULL or else you will get
an error.
+ * Since typically the two hypervisors connect directly to each other in order to
perform the migration, you may need to specify a path from the source to the destination.
+ * This is the purpose of the uri parameter.
+ * If uri is NULL, then libvirt will try to find the best method.
+ * Uri may specify the hostname or IP address of the destination host as seen from the
source.
+ * Or uri may be a URI giving transport, hostname, user, port, etc. in the usual form.
+ * Refer to driver documentation for the particular URIs supported.
+ * The maximum bandwidth (in Mbps) that will be used to do migration can be specified
with the bandwidth parameter.
+ * If set to 0, libvirt will choose a suitable default.
+ * Some hypervisors do not support this feature and will return an error if bandwidth is
not 0.
+ * To see which features are supported by the current hypervisor, see
Connect.getCapabilities,
+ * /capabilities/host/migration_features.
+ * There are many limitations on migration imposed by the underlying technology - for
example it may not be possible to migrate between different processors even with the same
architecture, or between different types of hypervisor.
+ *
+ * @param dconn destination host (a Connect object)
+ * @param flags flags
+ * @param dname (optional) rename domain to this at destination
+ * @param uri (optional) dest hostname/URI as seen from the source host
+ * @param bandwidth optional) specify migration bandwidth limit in Mbps
+ * @return the new domain object if the migration was successful, or NULL in case of
error. Note that the new domain object exists in the scope of the destination connection
(dconn).
+ * @throws LibvirtException
+ */
+ public Domain migrate(Connect dconn, long flags, String dname, String uri, long
bandwidth) throws LibvirtException{
+ DomainPointer newPtr = libvirt.virDomainMigrate(VDP, dconn.VCP, new
NativeLong(flags), dname, uri, new NativeLong(bandwidth)) ;
+ processError() ;
+ return new Domain(dconn, newPtr) ;
+ }
+
+
+ /**
+ * Reboot this domain, the domain object is still usable there after but the domain OS
is being stopped for a restart.
+ * Note that the guest OS may ignore the request.
+ *
+ * @param flags extra flags for the reboot operation, not used yet
+ * @throws LibvirtException
+ */
+ public void reboot(int flags) throws LibvirtException{
+ libvirt.virDomainReboot(VDP, flags);
+ processError() ;
+ }
+
+
+ /**
+ * Suspends this active domain, the process is frozen without further access to CPU
resources and I/O but the memory used by the domain at the hypervisor level will stay
allocated.
+ * Use Domain.resume() to reactivate the domain. This function requires priviledged
access.
+ *
+ * @throws LibvirtException
+ */
+ public void suspend() throws LibvirtException{
+ libvirt.virDomainSuspend(VDP);
+ processError() ;
+ }
+
+
+ /**
+ * Resume this suspended domain, the process is restarted from the state where it was
frozen by calling virSuspendDomain().
+ * This function may requires privileged access
+ *
+ * @throws LibvirtException
+ */
+ public void resume() throws LibvirtException{
+ libvirt.virDomainResume(VDP);
+ processError() ;
+ }
+
+
+ /**
+ * Suspends this domain and saves its memory contents to a file on disk.
+ * After the call, if successful, the domain is not listed as running anymore (this may
be a problem).
+ * Use Connect.virDomainRestore() to restore a domain after saving.
+ *
+ * @param to path for the output file
+ * @throws LibvirtException
+ */
+ public void save(String to) throws LibvirtException{
+ libvirt.virDomainSave(VDP, to);
+ processError() ;
+ }
+
+
+ /**
+ * Shuts down this domain, the domain object is still usable there after but the domain
OS is being stopped.
+ * Note that the guest OS may ignore the request.
+ * TODO: should we add an option for reboot, knowing it may not be doable in the general
case ?
+ *
+ * @throws LibvirtException
+ */
+ public void shutdown() throws LibvirtException{
+ libvirt.virDomainShutdown(VDP);
+ processError() ;
+ }
+
+
+ /**
+ * undefines this domain but does not stop it if it is running
+ *
+ * @throws LibvirtException
+ */
+ public void undefine() throws LibvirtException{
+ libvirt.virDomainUndefine(VDP);
+ processError() ;
+ }
+
+
+ /**
+ * Dynamically changes the target amount of physical memory allocated to this domain.
+ * This function may requires priviledged access to the hypervisor.
+ *
+ * @param memory in kilobytes
+ * @throws LibvirtException
+ */
+ public void setMemory(long memory) throws LibvirtException{
+ libvirt.virDomainSetMemory(VDP, new NativeLong(memory)) ;
+ processError() ;
+ }
+
+ /**
+ * It returns the length (in bytes) required to store the complete
+ * CPU map between a single virtual & all physical CPUs of a domain.
+ *
+ */
+ public int cpuMapLength(int maxCpus) {
+ return (((maxCpus)+7)/8) ;
+ }
+
+ /**
+ * Error handling logic to throw errors. Must be called after every libvirt
+ * call.
+ */
+ protected void processError() throws LibvirtException {
+ virConnect.processError() ;
+ }
+
+
+}
diff --git a/src/main/java/org/libvirt/DomainBlockStats.java
b/src/main/java/org/libvirt/DomainBlockStats.java
new file mode 100644
index 0000000..b48c066
--- /dev/null
+++ b/src/main/java/org/libvirt/DomainBlockStats.java
@@ -0,0 +1,28 @@
+package org.libvirt;
+
+import org.libvirt.jna.virDomainBlockStats;
+
+/**
+ * This class holds the counters for block device statistics.
+ *
+ * @author stoty
+ * @see Domain#blockStats
+ */
+public class DomainBlockStats {
+ public long rd_req;
+ public long rd_bytes;
+ public long wr_req;
+ public long wr_bytes;
+ public long errs;
+
+ public DomainBlockStats() {
+ }
+
+ public DomainBlockStats(virDomainBlockStats vStats) {
+ this.rd_req = vStats.rd_req ;
+ this.rd_bytes = vStats.rd_bytes ;
+ this.wr_req = vStats.wr_req ;
+ this.wr_bytes = vStats.wr_bytes ;
+ this.errs = vStats.errs ;
+ }
+}
diff --git a/src/main/java/org/libvirt/DomainInfo.java
b/src/main/java/org/libvirt/DomainInfo.java
new file mode 100644
index 0000000..e6a03f8
--- /dev/null
+++ b/src/main/java/org/libvirt/DomainInfo.java
@@ -0,0 +1,89 @@
+package org.libvirt;
+
+import org.libvirt.jna.virDomainInfo;
+
+/**
+ * This object is returned by Domain.getInfo()
+ *
+ * @author stoty
+ *
+ */
+public class DomainInfo {
+ /**
+ * the running state, one of virDomainFlag
+ */
+ public DomainState state;
+ /**
+ * the maximum memory in KBytes allowed
+ */
+ public long maxMem;
+ /**
+ * the memory in KBytes used by the domain
+ */
+ public long memory;
+ /**
+ * the number of virtual CPUs for the domain
+ */
+ public int nrVirtCpu;
+ /**
+ * the CPU time used in nanoseconds
+ */
+ public long cpuTime;
+
+ /**
+ * @author stoty
+ *
+ */
+ public static enum DomainState {
+ /**
+ * no state
+ */
+ VIR_DOMAIN_NOSTATE,
+ /**
+ * the domain is running
+ */
+ VIR_DOMAIN_RUNNING,
+ /**
+ * the domain is blocked on resource
+ */
+ VIR_DOMAIN_BLOCKED,
+ /**
+ * the domain is paused by user
+ */
+ VIR_DOMAIN_PAUSED,
+ /**
+ * the domain is being shut down
+ */
+ VIR_DOMAIN_SHUTDOWN,
+ /**
+ * the domain is shut off
+ */
+ VIR_DOMAIN_SHUTOFF,
+ /**
+ * the domain is crashed
+ */
+ VIR_DOMAIN_CRASHED
+ }
+
+ public DomainInfo() {
+
+ }
+
+ public DomainInfo(virDomainInfo info) {
+ this.cpuTime = info.cpuTime ;
+ this.maxMem = info.maxMem.longValue() ;
+ this.memory = info.memory.longValue() ;
+ this.nrVirtCpu = info.nrVirtCpu ;
+ this.state = DomainState.values()[info.state] ;
+ }
+
+ public String toString(){
+ StringBuffer result = new StringBuffer("");
+ result.append("state:" + state + "\n");
+ result.append("maxMem:" + maxMem + "\n");
+ result.append("memory:" + memory + "\n");
+ result.append("nrVirtCpu:" + nrVirtCpu + "\n");
+ result.append("cpuTime:" + cpuTime + "\n");
+ return result.toString();
+ }
+}
diff --git a/src/main/java/org/libvirt/DomainInterfaceStats.java
b/src/main/java/org/libvirt/DomainInterfaceStats.java
new file mode 100644
index 0000000..b60b628
--- /dev/null
+++ b/src/main/java/org/libvirt/DomainInterfaceStats.java
@@ -0,0 +1,36 @@
+package org.libvirt;
+
+import org.libvirt.jna.virDomainInterfaceStats;
+
+
+/**
+ * The Domain.interfaceStats method returns th network counters in this object
+ *
+ * @author stoty
+ *
+ */
+public class DomainInterfaceStats {
+ public long rx_bytes;
+ public long rx_packets;
+ public long rx_errs;
+ public long rx_drop;
+ public long tx_bytes;
+ public long tx_packets;
+ public long tx_errs;
+ public long tx_drop;
+
+ public DomainInterfaceStats() {
+
+ }
+
+ public DomainInterfaceStats(virDomainInterfaceStats vStats) {
+ this.rx_bytes = vStats.rx_bytes ;
+ this.rx_packets = vStats.rx_packets ;
+ this.rx_errs = vStats.rx_errs ;
+ this.rx_drop = vStats.rx_drop ;
+ this.tx_bytes = vStats.tx_bytes ;
+ this.tx_packets = vStats.tx_packets ;
+ this.tx_errs = vStats.tx_errs ;
+ this.tx_drop = vStats.tx_drop ;
+ }
+}
diff --git a/src/main/java/org/libvirt/Error.java b/src/main/java/org/libvirt/Error.java
new file mode 100644
index 0000000..3ba8644
--- /dev/null
+++ b/src/main/java/org/libvirt/Error.java
@@ -0,0 +1,473 @@
+package org.libvirt;
+
+import java.io.Serializable;
+
+import org.libvirt.jna.virError;
+
+import com.sun.jna.Pointer;
+
+public class Error implements Serializable {
+
+ public static enum ErrorDomain {
+ VIR_FROM_NONE,
+ /**
+ * Error at Xen hypervisor layer
+ */
+ VIR_FROM_XEN,
+ /**
+ * Error at connection with xend daemon
+ */
+ VIR_FROM_XEND,
+ /**
+ * Error at connection with xen store
+ */
+ VIR_FROM_XENSTORE,
+ /**
+ * Error in the S-Epression code
+ */
+ VIR_FROM_SEXPR,
+ /**
+ * Error in the XML code
+ */
+ VIR_FROM_XML,
+ /**
+ * Error when operating on a domain
+ */
+ VIR_FROM_DOM,
+ /**
+ * Error in the XML-RPC code
+ */
+ VIR_FROM_RPC,
+ /**
+ * Error in the proxy code
+ */
+ VIR_FROM_PROXY,
+ /**
+ * Error in the configuration file handling
+ */
+ VIR_FROM_CONF,
+ /**
+ * Error at the QEMU daemon
+ */
+ VIR_FROM_QEMU,
+ /**
+ * Error when operating on a network
+ */
+ VIR_FROM_NET,
+ /**
+ * Error from test driver
+ */
+ VIR_FROM_TEST,
+ /**
+ * Error from remote driver
+ */
+ VIR_FROM_REMOTE,
+ /**
+ * Error from OpenVZ driver
+ */
+ VIR_FROM_OPENVZ,
+ /**
+ * Error at Xen XM layer
+ */
+ VIR_FROM_XENXM,
+ /**
+ * Error in the Linux Stats code
+ */
+ VIR_FROM_STATS_LINUX,
+ /**
+ * Error from Linux Container driver
+ */
+ VIR_FROM_LXC,
+ /**
+ * Error from storage driver
+ */
+ VIR_FROM_STORAGE
+ }
+
+ public static enum ErrorLevel {
+ VIR_ERR_NONE,
+ /**
+ * A simple warning
+ */
+ VIR_ERR_WARNING,
+ /**
+ * An error
+ */
+ VIR_ERR_ERROR
+ }
+
+ public static enum ErrorNumber {
+ VIR_ERR_OK,
+ /**
+ * internal error
+ */
+ VIR_ERR_INTERNAL_ERROR,
+ /**
+ * memory allocation failure
+ */
+ VIR_ERR_NO_MEMORY,
+ /**
+ * no support for this function
+ */
+ VIR_ERR_NO_SUPPORT,
+ /**
+ * could not resolve hostname
+ */
+ VIR_ERR_UNKNOWN_HOST,
+ /**
+ * can't connect to hypervisor
+ */
+ VIR_ERR_NO_CONNECT,
+ /**
+ * invalid connection object
+ */
+ VIR_ERR_INVALID_CONN,
+ /**
+ * invalid domain object
+ */
+ VIR_ERR_INVALID_DOMAIN,
+ /**
+ * invalid function argument
+ */
+ VIR_ERR_INVALID_ARG,
+ /**
+ * a command to hypervisor failed
+ */
+ VIR_ERR_OPERATION_FAILED,
+ /**
+ * a HTTP GET command to failed
+ */
+ VIR_ERR_GET_FAILED,
+ /**
+ * a HTTP POST command to failed
+ */
+ VIR_ERR_POST_FAILED,
+ /**
+ * unexpected HTTP error code
+ */
+ VIR_ERR_HTTP_ERROR,
+ /**
+ * failure to serialize an S-Expr
+ */
+ VIR_ERR_SEXPR_SERIAL,
+ /**
+ * could not open Xen hypervisor control
+ */
+ VIR_ERR_NO_XEN,
+ /**
+ * failure doing an hypervisor call
+ */
+ VIR_ERR_XEN_CALL,
+ /**
+ * unknown OS type
+ */
+ VIR_ERR_OS_TYPE,
+ /**
+ * missing kernel information
+ */
+ VIR_ERR_NO_KERNEL,
+ /**
+ * missing root device information
+ */
+ VIR_ERR_NO_ROOT,
+ /**
+ * missing source device information
+ */
+ VIR_ERR_NO_SOURCE,
+ /**
+ * missing target device information
+ */
+ VIR_ERR_NO_TARGET,
+ /**
+ * missing domain name information
+ */
+ VIR_ERR_NO_NAME,
+ /**
+ * missing domain OS information
+ */
+ VIR_ERR_NO_OS,
+ /**
+ * missing domain devices information
+ */
+ VIR_ERR_NO_DEVICE,
+ /**
+ * could not open Xen Store control
+ */
+ VIR_ERR_NO_XENSTORE,
+ /**
+ * too many drivers registered
+ */
+ VIR_ERR_DRIVER_FULL,
+ /**
+ * not supported by the drivers (DEPRECATED)
+ */
+ VIR_ERR_CALL_FAILED,
+ /**
+ * an XML description is not well formed or broken
+ */
+ VIR_ERR_XML_ERROR,
+ /**
+ * the domain already exist
+ */
+ VIR_ERR_DOM_EXIST,
+ /**
+ * operation forbidden on read-only connections
+ */
+ VIR_ERR_OPERATION_DENIED,
+ /**
+ * failed to open a conf file
+ */
+ VIR_ERR_OPEN_FAILED,
+ /**
+ * failed to read a conf file
+ */
+ VIR_ERR_READ_FAILED,
+ /**
+ * failed to parse a conf file
+ */
+ VIR_ERR_PARSE_FAILED,
+ /**
+ * failed to parse the syntax of a conf file
+ */
+ VIR_ERR_CONF_SYNTAX,
+ /**
+ * failed to write a conf file
+ */
+ VIR_ERR_WRITE_FAILED,
+ /**
+ * detail of an XML error
+ */
+ VIR_ERR_XML_DETAIL,
+ /**
+ * invalid network object
+ */
+ VIR_ERR_INVALID_NETWORK,
+ /**
+ * the network already exist
+ */
+ VIR_ERR_NETWORK_EXIST,
+ /**
+ * general system call failure
+ */
+ VIR_ERR_SYSTEM_ERROR,
+ /**
+ * some sort of RPC error
+ */
+ VIR_ERR_RPC,
+ /**
+ * error from a GNUTLS call
+ */
+ VIR_ERR_GNUTLS_ERROR,
+ /**
+ * failed to start network
+ */
+ VIR_WAR_NO_NETWORK,
+ /**
+ * omain not found or unexpectedly disappeared
+ */
+ VIR_ERR_NO_DOMAIN,
+ /**
+ * network not found
+ */
+ VIR_ERR_NO_NETWORK,
+ /**
+ * invalid MAC adress
+ */
+ VIR_ERR_INVALID_MAC,
+ /**
+ * authentication failed
+ */
+ VIR_ERR_AUTH_FAILED,
+ /**
+ * invalid storage pool object
+ */
+ VIR_ERR_INVALID_STORAGE_POOL,
+ /**
+ * invalid storage vol object
+ */
+ VIR_ERR_INVALID_STORAGE_VOL,
+ /**
+ * failed to start storage
+ */
+ VIR_WAR_NO_STORAGE,
+ /**
+ * storage pool not found
+ */
+ VIR_ERR_NO_STORAGE_POOL,
+ /**
+ * storage pool not found
+ */
+ VIR_ERR_NO_STORAGE_VOL
+ }
+
+ ErrorNumber code;
+ ErrorDomain domain;
+ String message;
+ ErrorLevel level;
+ Pointer VCP; /* Deprecated */
+ Pointer VDP; /* Deprecated */
+ String str1;
+ String str2;
+ String str3;
+ int int1;
+ int int2;
+ Pointer VNP; /* Deprecated */
+
+ public Error() {
+
+ }
+
+ public Error(virError vError) {
+ code = ErrorNumber.values()[vError.code] ;
+ domain = ErrorDomain.values()[vError.domain] ;
+ level = ErrorLevel.values()[vError.level] ;
+ message = vError.message ;
+ str1 = vError.str1 ;
+ str2 = vError.str2 ;
+ str3 = vError.str3 ;
+ int1 = vError.int1 ;
+ int2 = vError.int2 ;
+ VCP = vError.conn ;
+ VDP = vError.dom ;
+ VNP =
vError.net ;
+ }
+
+ /**
+ * Gets he error code
+ * @return a VirErroNumber
+ */
+ public ErrorNumber getCode() {
+ return code;
+ }
+ /**
+ * Tells What part of the library raised this error
+ * @return a ErrorDomain
+ */
+ public ErrorDomain getDomain() {
+ return domain;
+ }
+ /**
+ * Returns human-readable informative error messag
+ *
+ * @return error message
+ */
+ public String getMessage() {
+ return message;
+ }
+ /**
+ * Tells how consequent is the error
+ * @return a ErrorLevel
+ */
+ public ErrorLevel getLevel() {
+ return level;
+ }
+ /**
+ * @return extra string information
+ */
+ public String getStr1() {
+ return str1;
+ }
+ /**
+ * @return extra string information
+ */
+ public String getStr2() {
+ return str2;
+ }
+ /**
+ * @return extra string information
+ */
+ public String getStr3() {
+ return str3;
+ }
+ /**
+ * @return extra number information
+ */
+ public int getInt1() {
+ return int1;
+ }
+ /**
+ * @return extra number information
+ */
+ public int getInt2() {
+ return int2;
+ }
+
+ /**
+ * Does this error has a valid Connection object attached?
+ * NOTE: deprecated, should return false
+ *
+ * @return false
+ */
+ public boolean hasConn(){
+ return false;
+ }
+
+ /**
+ * returns the Connection associated with the error, if available
+ * Deprecated, always throw an exception now
+ *
+ * @return the Connect object
+ * @throws ErrorException
+ */
+ public Connect getConn() throws ErrorException{
+ throw new ErrorException("No Connect object available");
+ }
+
+ /**
+ * Does this error has a valid Domain object attached?
+ * NOTE: deprecated, should return false
+ *
+ * @return false
+ */
+ public boolean hasDom(){
+ return false;
+ }
+
+ /**
+ * returns the Domain associated with the error, if available
+ *
+ * @return Domain object
+ * @throws ErrorException
+ */
+ public Domain getDom() throws ErrorException{
+ throw new ErrorException("No Domain object available");
+ }
+
+ /**
+ * Does this error has a valid Network object attached?
+ * NOTE: deprecated, should return false
+ *
+ * @return false
+ */
+ public boolean hasNet(){
+ return false;
+ }
+
+ /**
+ * Returns the network associated with the error, if available
+ *
+ * @return Network object
+ * @throws ErrorException
+ */
+ public Network getNet() throws ErrorException{
+ throw new ErrorException("No Network object available");
+ }
+
+ public String toString(){
+ StringBuffer output= new StringBuffer();
+ output.append("level:" + level + "\n");
+ output.append("code:" + code + "\n");
+ output.append("domain:" + domain + "\n");
+ output.append("hasConn:" + hasConn() + "\n");
+ output.append("hasDom:" + hasDom() + "\n");
+ output.append("hasNet:" + hasNet() + "\n");
+ output.append("message:" + message + "\n");
+ output.append("str1:" + str1 + "\n");
+ output.append("str2:" + str2 + "\n");
+ output.append("str3:" + str3 + "\n");
+ output.append("int1:" + int1 + "\n");
+ output.append("int2:" + int2 + "\n");
+ return output.toString();
+
+ }
+}
diff --git a/src/main/java/org/libvirt/ErrorException.java
b/src/main/java/org/libvirt/ErrorException.java
new file mode 100644
index 0000000..40095fd
--- /dev/null
+++ b/src/main/java/org/libvirt/ErrorException.java
@@ -0,0 +1,15 @@
+package org.libvirt;
+
+/**
+ * This exception signals that a non-existing object was retrieved from the virError
object
+ *
+ * @author stoty
+ *
+ */
+public class ErrorException extends Exception {
+ private static final long serialVersionUID = -4329050530233404971L;
+ public ErrorException(String message) {
+ super(message);
+ }
+
+}
diff --git a/src/main/java/org/libvirt/ErrorHandler.java
b/src/main/java/org/libvirt/ErrorHandler.java
new file mode 100644
index 0000000..2cc260a
--- /dev/null
+++ b/src/main/java/org/libvirt/ErrorHandler.java
@@ -0,0 +1,32 @@
+package org.libvirt;
+
+import org.libvirt.jna.ConnectionPointer;
+import org.libvirt.jna.Libvirt;
+import org.libvirt.jna.virError;
+
+import com.sun.jna.Pointer;
+
+public class ErrorHandler
+{
+
+ public static void processError(Libvirt libvirt) throws LibvirtException {
+ virError vError = new virError() ;
+ int errorCode = libvirt.virCopyLastError(vError) ;
+ if (errorCode > 0) {
+ Error error = new Error(vError) ;
+ libvirt.virResetLastError() ;
+ throw new LibvirtException(error) ;
+ }
+ }
+
+ public static void processError(Libvirt libvirt, ConnectionPointer conn) throws
LibvirtException
+ {
+ virError vError = new virError() ;
+ int errorCode = libvirt.virConnCopyLastError(conn, vError) ;
+ if (errorCode > 0) {
+ Error error = new Error(vError) ;
+ libvirt.virConnResetLastError(conn) ;
+ throw new LibvirtException(error) ;
+ }
+ }
+}
diff --git a/src/main/java/org/libvirt/LibvirtException.java
b/src/main/java/org/libvirt/LibvirtException.java
new file mode 100644
index 0000000..44769ff
--- /dev/null
+++ b/src/main/java/org/libvirt/LibvirtException.java
@@ -0,0 +1,31 @@
+package org.libvirt;
+
+/**
+ * This exception is thrown by all classes and methods of libvirt when the
+ * underlying libvirt library indicates an error
+ *
+ * @author stoty
+ * @see Error
+ */
+public class LibvirtException extends Exception {
+
+ private static final long serialVersionUID = 5566904363426773529L;
+
+ Error virError;
+
+ LibvirtException(Error virError) {
+ super(virError.getMessage());
+ this.virError = virError;
+ }
+
+ /**
+ * Returns the underlying Error objects that contains details
+ * about the cause of the exception
+ *
+ * @return the underlying Error object
+ */
+ public Error getError() {
+ return virError;
+ }
+
+}
diff --git a/src/main/java/org/libvirt/Network.java
b/src/main/java/org/libvirt/Network.java
new file mode 100644
index 0000000..39afde2
--- /dev/null
+++ b/src/main/java/org/libvirt/Network.java
@@ -0,0 +1,217 @@
+package org.libvirt;
+
+import org.libvirt.jna.Libvirt;
+import org.libvirt.jna.NetworkPointer;
+
+import com.sun.jna.Native;
+import com.sun.jna.Pointer;
+import com.sun.jna.ptr.IntByReference;
+import com.sun.jna.ptr.PointerByReference;
+
+public class Network {
+
+ /**
+ * The native virNetworkPtr
+ */
+ protected NetworkPointer VNP;
+
+ /**
+ * The Connect Object that represents the Hypervisor of this Network
+ */
+ protected Connect virConnect;
+
+ /**
+ * The libvirt connection from the hypervisor
+ */
+ protected Libvirt libvirt ;
+
+ /**
+ * Constructs a Network object from a known native virNetworkPtr, and a Connect object.
+ * For use when native libvirt returns a virConnectPtr, i.e. error handling.
+ *
+ * @param virConnect
+ * @param VNP
+ */
+ Network(Connect virConnect, NetworkPointer VNP){
+ this.virConnect = virConnect;
+ this.VNP = VNP;
+ this.libvirt = virConnect.libvirt ;
+ }
+
+ public void finalize() throws LibvirtException{
+ free();
+ }
+
+ /**
+ * Provides an XML description of this network.
+ * The description may be reused later to relaunch the network with
Virconnect.virNetworkCreateXML().
+ *
+ * @param flags and OR'ed set of extraction flags, not used yet
+ * @return The XML representation of this network
+ * @throws LibvirtException
+ */
+ public String getXMLDesc(int flags) throws LibvirtException{
+ String returnValue = libvirt.virNetworkGetXMLDesc(VNP, flags) ;
+ processError() ;
+ return returnValue ;
+ }
+
+
+ /**
+ * Provides a boolean value indicating whether this network is configured to be
automatically started when the host machine boots.
+ *
+ * @return true if autostarted, false otherwise
+ * @throws LibvirtException
+ */
+ public boolean getAutostart() throws LibvirtException{
+ IntByReference autoStart = new IntByReference() ;
+ libvirt.virNetworkGetAutostart(VNP, autoStart) ;
+ processError() ;
+ return autoStart.getValue() != 0 ? true : false ;
+ }
+
+
+
+ /**
+ * Configures this network to be automatically started when the host machine boots.
+ *
+ * @param autostart whether the network should be automatically started 0 or 1
+ * @throws LibvirtException
+ */
+ public void setAutostart(boolean autostart) throws LibvirtException{
+ int autoValue = autostart ? 1 : 0 ;
+ libvirt.virNetworkSetAutostart(VNP, autoValue) ;
+ processError() ;
+ }
+
+
+ /**
+ * Provides a bridge interface name to which a domain may connect a network interface in
order to join this network.
+ *
+ * @return the interface name
+ * @throws LibvirtException
+ */
+ public String getBridgeName() throws LibvirtException{
+ String returnValue = libvirt.virNetworkGetBridgeName(VNP) ;
+ processError() ;
+ return returnValue ;
+ }
+
+
+
+ /**
+ * Provides the connection pointer associated with this network.
+ *
+ * @return the Connect object
+ */
+ public Connect getConnect(){
+ return virConnect;
+ }
+
+
+ /**
+ * Gets the public name for this network
+ *
+ * @return the public name
+ * @throws LibvirtException
+ */
+ public String getName() throws LibvirtException{
+ String returnValue = libvirt.virNetworkGetName(VNP);
+ processError() ;
+ return returnValue ;
+ }
+
+
+ /**
+ * Gets the UUID for this network
+ *
+ * @return the UUID as an unpacked int array
+ * @throws LibvirtException
+ * @see <a
href="http://www.ietf.org/rfc/rfc4122.txt">rfc4122</a>
+ */
+ public int[] getUUID() throws LibvirtException{
+ byte[] bytes = new byte[Libvirt.VIR_UUID_BUFLEN] ;
+ int success = libvirt.virNetworkGetUUID(VNP, bytes) ;
+ processError() ;
+ int[] returnValue = new int[0] ;
+ if (success == 0) {
+ returnValue = Connect.convertUUIDBytes(bytes) ;
+ }
+ return returnValue ;
+ }
+
+ /**
+ * Gets the UUID for a network as string.
+ *
+ * @return the UUID in canonical String format
+ * @throws LibvirtException
+ * @see <a
href="http://www.ietf.org/rfc/rfc4122.txt">rfc4122</a>
+ */
+ public String getUUIDString() throws LibvirtException{
+ byte[] bytes = new byte[Libvirt.VIR_UUID_STRING_BUFLEN] ;
+ int success = libvirt.virNetworkGetUUIDString(VNP, bytes) ;
+ processError() ;
+ String returnValue = null ;
+ if (success == 0) {
+ returnValue = Native.toString(bytes) ;
+ }
+ return returnValue ;
+ }
+
+
+ /**
+ * Creates and starts this defined network.
+ * If the call succeeds the network moves from the defined to the running networks
pools.
+ *
+ * @throws LibvirtException
+ */
+ public void create() throws LibvirtException{
+ libvirt.virNetworkCreate(VNP) ;
+ processError() ;
+ }
+
+
+ /**
+ * Destroy this network object.
+ * The running instance is shutdown if not down already and all resources used by it are
given back to the hypervisor.
+ * The object becomes invalid and should not be used thereafter if the call does not
return an error.
+ * This function may require priviledged access
+ *
+ * @throws LibvirtException
+ */
+ public void destroy() throws LibvirtException{
+ libvirt.virNetworkDestroy(VNP) ;
+ processError() ;
+ }
+
+
+ /**
+ * Frees this network object.
+ * The running instance is kept alive.
+ * The object becomes invalid and should not be used thereafter if the call does not
return an error.
+ *
+ * @throws LibvirtException
+ */
+ public void free() throws LibvirtException{
+ libvirt.virNetworkFree(VNP) ;
+ processError() ;
+ VNP=null;
+ }
+
+
+ /**
+ * Undefines this network but does not stop it if it is running
+ *
+ * @throws LibvirtException
+ */
+ public void undefine() throws LibvirtException{
+ libvirt.virNetworkUndefine(VNP) ;
+ processError() ;
+ }
+
+ protected void processError() throws LibvirtException {
+ virConnect.processError() ;
+ }
+
+
+}
diff --git a/src/main/java/org/libvirt/NodeInfo.java
b/src/main/java/org/libvirt/NodeInfo.java
new file mode 100644
index 0000000..0431ed9
--- /dev/null
+++ b/src/main/java/org/libvirt/NodeInfo.java
@@ -0,0 +1,61 @@
+package org.libvirt;
+
+import org.libvirt.jna.virNodeInfo;
+
+import com.sun.jna.Native;
+
+public class NodeInfo {
+ /**
+ * string indicating the CPU model
+ */
+ public String model;
+ /**
+ * memory size in kilobytes
+ */
+ public long memory;
+ /**
+ * the number of active CPUs
+ */
+ public int cpus;
+ /**
+ * expected CPU frequency
+ */
+ public int mhz;
+ /**
+ * the number of NUMA cell, 1 for uniform
+ */
+ public int nodes;
+ /**
+ * number of CPU socket per node
+ */
+ public int sockets;
+ /**
+ * number of core per socket
+ */
+ public int cores;
+ /**
+ * number of threads per core
+ */
+ public int threads;
+
+
+ public NodeInfo() {
+ }
+
+ public NodeInfo(virNodeInfo vInfo) {
+ this.model = Native.toString(vInfo.model) ;
+ this.memory = vInfo.memory.longValue() ;
+ this.cpus = vInfo.cpus ;
+ this.mhz = vInfo.mhz ;
+ this.nodes = vInfo.nodes ;
+ this.sockets = vInfo.sockets ;
+ this.cores = vInfo.cores ;
+ this.threads = vInfo.threads ;
+ }
+ /**
+ * @return the total number of CPUs supported but not neccessarily active in the host.
+ */
+ public int maxCpus(){
+ return nodes*sockets*cores*threads;
+ }
+}
diff --git a/src/main/java/org/libvirt/SchedBooleanParameter.java
b/src/main/java/org/libvirt/SchedBooleanParameter.java
new file mode 100644
index 0000000..5e681ca
--- /dev/null
+++ b/src/main/java/org/libvirt/SchedBooleanParameter.java
@@ -0,0 +1,40 @@
+package org.libvirt;
+
+/**
+ * Class for representing a boolean scheduler parameter
+ *
+ * @author stoty
+ *
+ */
+public final class SchedBooleanParameter extends SchedParameter{
+ /**
+ * The parameter value
+ */
+ public boolean value;
+
+ public SchedBooleanParameter() {
+
+ }
+
+ public SchedBooleanParameter(boolean value)
+ {
+ this.value = value;
+ }
+
+ public SchedBooleanParameter(byte value)
+ {
+ this.value = (((int)value) != 0)? true : false ;
+ }
+
+ public String getValueAsString(){
+ return Boolean.toString(value);
+ }
+
+ public String getTypeAsString(){
+ return "VIR_DOMAIN_SCHED_FIELD_BOOLEAN";
+ }
+
+ public int getType() {
+ return 6 ;
+ }
+}
diff --git a/src/main/java/org/libvirt/SchedDoubleParameter.java
b/src/main/java/org/libvirt/SchedDoubleParameter.java
new file mode 100644
index 0000000..21bc217
--- /dev/null
+++ b/src/main/java/org/libvirt/SchedDoubleParameter.java
@@ -0,0 +1,35 @@
+package org.libvirt;
+
+/**
+ * Class for representing a double scheduler parameter
+ *
+ * @author stoty
+ *
+ */
+public final class SchedDoubleParameter extends SchedParameter{
+ /**
+ * The parameter value
+ */
+ public double value;
+
+ public SchedDoubleParameter() {
+
+ }
+
+ public SchedDoubleParameter(double value)
+ {
+ this.value = value;
+ }
+
+ public String getValueAsString(){
+ return Double.toString(value);
+ }
+
+ public String getTypeAsString(){
+ return "VIR_DOMAIN_SCHED_FIELD_DOUBLE";
+ }
+
+ public int getType() {
+ return 5 ;
+ }
+}
diff --git a/src/main/java/org/libvirt/SchedIntParameter.java
b/src/main/java/org/libvirt/SchedIntParameter.java
new file mode 100644
index 0000000..af13933
--- /dev/null
+++ b/src/main/java/org/libvirt/SchedIntParameter.java
@@ -0,0 +1,26 @@
+package org.libvirt;
+
+public final class SchedIntParameter extends SchedParameter {
+ public int value;
+
+ public SchedIntParameter() {
+
+ }
+
+ public SchedIntParameter(int value)
+ {
+ this.value = value;
+ }
+
+ public String getValueAsString(){
+ return Integer.toString(value);
+ }
+
+ public String getTypeAsString(){
+ return "VIR_DOMAIN_SCHED_FIELD_INT";
+ }
+
+ public int getType() {
+ return 1 ;
+ }
+}
diff --git a/src/main/java/org/libvirt/SchedLongParameter.java
b/src/main/java/org/libvirt/SchedLongParameter.java
new file mode 100644
index 0000000..1b07971
--- /dev/null
+++ b/src/main/java/org/libvirt/SchedLongParameter.java
@@ -0,0 +1,36 @@
+package org.libvirt;
+
+/**
+ * Class for representing a long int scheduler parameter
+ *
+ * @author stoty
+ *
+ */
+public final class SchedLongParameter extends SchedParameter{
+ /**
+ * The parameter value
+ */
+ public long value;
+
+ public SchedLongParameter() {
+
+ }
+
+ public SchedLongParameter(long value)
+ {
+ this.value = value;
+ }
+
+ public String getValueAsString(){
+ return Long.toString(value);
+ }
+
+ public String getTypeAsString(){
+ return "VIR_DOMAIN_SCHED_FIELD_LLONG";
+ }
+
+ public int getType() {
+ return 2 ;
+ }
+
+}
diff --git a/src/main/java/org/libvirt/SchedParameter.java
b/src/main/java/org/libvirt/SchedParameter.java
new file mode 100644
index 0000000..8f38ef8
--- /dev/null
+++ b/src/main/java/org/libvirt/SchedParameter.java
@@ -0,0 +1,72 @@
+package org.libvirt;
+
+import java.util.Arrays;
+
+import org.libvirt.jna.Libvirt;
+import org.libvirt.jna.virSchedParameter;
+
+import com.sun.jna.Native;
+
+/**
+ * The abstract parent of the actual Schedparameter classes
+ *
+ * @author stoty
+ *
+ */
+public abstract class SchedParameter {
+
+ /**
+ * Parameter name
+ */
+ public String field;
+
+ /**
+ * Utility function for displaying the value
+ *
+ * @return the value of the parameter in String form
+ */
+ public abstract String getValueAsString();
+ /**
+ * Utility function for displaying the type
+ *
+ * @return the Type of the parameter as string
+ */
+ public abstract String getTypeAsString();
+
+ /**
+ * The type of the parameter
+ *
+ * @return the Type of the parameter
+ */
+ public abstract int getType() ;
+
+ public static SchedParameter create(virSchedParameter vParam) {
+ SchedParameter returnValue = null ;
+ switch (vParam.type) {
+ case (1): returnValue = new SchedIntParameter(vParam.value.i) ;break ;
+ case (2): returnValue = new SchedUintParameter(vParam.value.ui) ;break ;
+ case (3): returnValue = new SchedLongParameter(vParam.value.l) ;break ;
+ case (4): returnValue = new SchedUlongParameter(vParam.value.ul) ;break ;
+ case (5): returnValue = new SchedDoubleParameter(vParam.value.d) ;break ;
+ case (6): returnValue = new SchedBooleanParameter(vParam.value.b) ;break ;
+ }
+ returnValue.field = Native.toString(vParam.field) ;
+ return returnValue ;
+ }
+
+ public static virSchedParameter toNative(SchedParameter param) {
+ virSchedParameter returnValue = new virSchedParameter() ;
+ returnValue.field = Arrays.copyOf(param.field.getBytes(),
Libvirt.VIR_DOMAIN_SCHED_FIELD_LENGTH) ;
+ returnValue.type = param.getType() ;
+ switch (param.getType()) {
+ case (1): returnValue.value.i = ((SchedIntParameter)param).value ;break ;
+ case (2): returnValue.value.ui = ((SchedUintParameter)param).value ;break ;
+ case (3): returnValue.value.l = ((SchedLongParameter)param).value ;break ;
+ case (4): returnValue.value.ul = ((SchedUlongParameter)param).value ;break ;
+ case (5): returnValue.value.d = ((SchedDoubleParameter)param).value ;break ;
+ case (6): returnValue.value.b = (byte)(((SchedBooleanParameter)param).value?1:0)
;break ;
+
+ }
+ return returnValue ;
+ }
+}
diff --git a/src/main/java/org/libvirt/SchedUintParameter.java
b/src/main/java/org/libvirt/SchedUintParameter.java
new file mode 100644
index 0000000..8a6ab75
--- /dev/null
+++ b/src/main/java/org/libvirt/SchedUintParameter.java
@@ -0,0 +1,36 @@
+package org.libvirt;
+
+/**
+ * Class for representing an unsigned int scheduler parameter
+ *
+ *
+ * @author stoty
+ *
+ */
+public final class SchedUintParameter extends SchedParameter {
+ /**
+ * The parameter value
+ */
+ public int value;
+
+ public SchedUintParameter() {
+
+ }
+
+ public SchedUintParameter(int value)
+ {
+ this.value = value;
+ }
+
+ public String getValueAsString(){
+ return Integer.toString(value);
+ }
+
+ public String getTypeAsString(){
+ return "VIR_DOMAIN_SCHED_FIELD_UINT";
+ }
+
+ public int getType() {
+ return 3 ;
+ }
+}
diff --git a/src/main/java/org/libvirt/SchedUlongParameter.java
b/src/main/java/org/libvirt/SchedUlongParameter.java
new file mode 100644
index 0000000..419c1a8
--- /dev/null
+++ b/src/main/java/org/libvirt/SchedUlongParameter.java
@@ -0,0 +1,35 @@
+package org.libvirt;
+
+/**
+ * Class for representing an unsigned long int scheduler parameter
+ *
+ * @author stoty
+ *
+ */
+public final class SchedUlongParameter extends SchedParameter{
+ /**
+ * The parameter value
+ */
+ public long value;
+
+ public SchedUlongParameter() {
+
+ }
+
+ public SchedUlongParameter(long value)
+ {
+ this.value = value;
+ }
+
+ public String getValueAsString(){
+ return Long.toString(value);
+ }
+
+ public String getTypeAsString(){
+ return "VIR_DOMAIN_SCHED_FIELD_ULLONG";
+ }
+
+ public int getType() {
+ return 4 ;
+ }
+}
diff --git a/src/main/java/org/libvirt/StoragePool.java
b/src/main/java/org/libvirt/StoragePool.java
new file mode 100644
index 0000000..5ef5423
--- /dev/null
+++ b/src/main/java/org/libvirt/StoragePool.java
@@ -0,0 +1,325 @@
+package org.libvirt;
+
+import org.libvirt.jna.Libvirt;
+import org.libvirt.jna.StoragePoolPointer;
+import org.libvirt.jna.StorageVolPointer;
+import org.libvirt.jna.virStoragePoolInfo;
+
+import com.sun.jna.Native;
+import com.sun.jna.ptr.IntByReference;
+
+public class StoragePool {
+
+ static final class BuildFlags{
+ /**
+ * Regular build from scratch
+ */
+ static final int VIR_STORAGE_POOL_BUILD_NEW = 0;
+ /**
+ * Repair / reinitialize
+ */
+ static final int VIR_STORAGE_POOL_BUILD_REPAIR = 1;
+ /**
+ * Extend existing pool
+ */
+ static final int VIR_STORAGE_POOL_BUILD_RESIZE = 2;
+ }
+
+ static final class DeleteFlags{
+ /**
+ * Delete metadata only (fast)
+ */
+ static final int VIR_STORAGE_POOL_DELETE_NORMAL = 0;
+ /**
+ * Clear all data to zeros (slow)
+ */
+ static final int VIR_STORAGE_POOL_DELETE_ZEROED = 1;
+ }
+
+ /**
+ * the native virStoragePoolPtr.
+ */
+ protected StoragePoolPointer VSPP;
+
+ /**
+ * The VirConnect Object that represents the Hypervisor of this Domain
+ */
+ protected Connect virConnect;
+
+ /**
+ * the libvirt instance
+ */
+ protected Libvirt libvirt ;
+
+
+ /**
+ * Constructs a VirStoragePool object from a known native virStoragePoolPtr, and a
VirConnect object.
+ * For use when native libvirt returns a virStoragePoolPtr, i.e. error handling.
+ *
+ * @param virConnect the Domain's hypervisor
+ * @param VSPP the native virStoragePoolPtr
+ */
+ StoragePool(Connect virConnect, StoragePoolPointer VSPP){
+ this.virConnect = virConnect;
+ this.VSPP = VSPP;
+ this.libvirt = virConnect.libvirt ;
+ }
+
+ /**
+ * Build the underlying storage pool
+ *
+ * @param flags future flags, use 0 for now
+ */
+ public void build(int flags) throws LibvirtException{
+ libvirt.virStoragePoolBuild(VSPP, flags);
+ processError() ;
+ }
+
+
+ /**
+ * Starts this inactive storage pool
+ *
+ * @param flags future flags, use 0 for now
+ */
+ public void create(int flags) throws LibvirtException{
+ libvirt.virStoragePoolCreate(VSPP, flags);
+ processError() ;
+ }
+
+
+ /**
+ * Delete the underlying pool resources. This is a non-recoverable operation.
+ * The virStoragePool object itself is not free'd.
+ *
+ * @param flags flags for obliteration process
+ */
+ public void delete(int flags) throws LibvirtException{
+ libvirt.virStoragePoolDelete(VSPP, flags);
+ processError() ;
+ }
+
+
+ /**
+ * Destroy an active storage pool.
+ * This will deactivate the pool on the host, but keep any persistent config associated
with it.
+ * If it has a persistent config it can later be restarted with virStoragePoolCreate().
+ * This does not free the associated virStoragePoolPtr object.
+ */
+ public void destroy() throws LibvirtException{
+ libvirt.virStoragePoolDestroy(VSPP);
+ processError() ;
+ }
+
+
+ /**
+ * Free a storage pool object, releasing all memory associated with it.
+ * Does not change the state of the pool on the host.
+ */
+ public void free() throws LibvirtException{
+ libvirt.virStoragePoolFree(VSPP);
+ processError() ;
+ }
+
+
+
+ /**
+ * Fetches the value of the autostart flag, which determines whether the pool is
automatically started at boot time
+ *
+ * @return the result
+ * @throws LibvirtException
+ */
+ public boolean getAutostart() throws LibvirtException{
+ IntByReference autoStart = new IntByReference() ;
+ libvirt.virStoragePoolGetAutostart(VSPP, autoStart) ;
+ processError() ;
+ return autoStart.getValue() != 0 ? true : false ;
+ }
+
+
+ /**
+ * Provides the connection pointer associated with a storage pool.
+ *
+ * @return the Connect object
+ */
+ public Connect getConnect(){
+ return virConnect;
+ }
+
+
+ /**
+ * Get volatile information about the storage pool such as free space / usage summary
+ *
+ * @return a StoragePoolInfo object describing this storage pool
+ * @throws LibvirtException
+ */
+ public StoragePoolInfo getInfo() throws LibvirtException{
+ virStoragePoolInfo vInfo = new virStoragePoolInfo() ;
+ libvirt.virStoragePoolGetInfo(VSPP, vInfo ) ;
+ processError() ;
+ return new StoragePoolInfo(vInfo) ;
+ }
+
+
+ /**
+ * Fetch the locally unique name of the storage pool
+ *
+ * @return the name
+ * @throws LibvirtException
+ */
+ public String getName() throws LibvirtException{
+ String returnValue = libvirt.virStoragePoolGetName(VSPP) ;
+ processError() ;
+ return returnValue ;
+ }
+
+
+ /**
+ * Fetch the globally unique ID of this storage pool
+ *
+ * @return the UUID as an unpacked int array
+ * @throws LibvirtException
+ */
+ public int[] getUUID() throws LibvirtException{
+ byte[] bytes = new byte[Libvirt.VIR_UUID_BUFLEN] ;
+ int success = libvirt.virStoragePoolGetUUID(VSPP, bytes) ;
+ processError() ;
+ int[] returnValue = new int[0] ;
+ if (success == 0) {
+ returnValue = Connect.convertUUIDBytes(bytes) ;
+ }
+ return returnValue ;
+ }
+
+
+ /**
+ * Fetch the globally unique ID of the storage pool as a string
+ *
+ * @return the UUID in canonical String format
+ * @throws LibvirtException
+ */
+ public String getUUIDString() throws LibvirtException{
+ byte[] bytes = new byte[Libvirt.VIR_UUID_STRING_BUFLEN] ;
+ int success = libvirt.virStoragePoolGetUUIDString(VSPP, bytes) ;
+ processError() ;
+ String returnValue = null ;
+ if (success == 0) {
+ returnValue = Native.toString(bytes) ;
+ }
+ return returnValue ;
+ }
+
+
+ /**
+ * Fetch an XML document describing all aspects of the storage pool.
+ * This is suitable for later feeding back into the virStoragePoolCreateXML method.
+ *
+ * @param flags flags for XML format options (set of virDomainXMLFlags)
+ * @return a XML document
+ *-java @throws LibvirtException
+ */
+ public String getXMLDesc(int flags) throws LibvirtException{
+ String returnValue = libvirt.virStoragePoolGetXMLDesc(VSPP, flags) ;
+ processError() ;
+ return returnValue ;
+ }
+
+
+ /**
+ * Fetch list of storage volume names
+ *
+ * @return an Array of Strings that contains the names of the storage volumes
+ * @throws LibvirtException
+ */
+ public String[] listVolumes() throws LibvirtException {
+ int num = this.numOfVolumes() ;
+ String[] returnValue = new String[num] ;
+ libvirt.virStoragePoolListVolumes(VSPP, returnValue, num) ;
+ processError() ;
+ return returnValue ;
+ }
+
+
+ /**
+ * Fetch the number of storage volumes within a pool
+ *
+ * @return the number of storage pools
+ * @throws LibvirtException
+ */
+ public int numOfVolumes() throws LibvirtException {
+ int returnValue = libvirt.virStoragePoolNumOfVolumes(VSPP) ;
+ processError() ;
+ return returnValue ;
+ }
+
+
+ /**
+ * Request that the pool refresh its list of volumes.
+ * This may involve communicating with a remote server, and/or initializing new devices
at the OS layer
+ *
+ * @param flags flags to control refresh behaviour (currently unused, use 0)
+ * @throws LibvirtException
+ */
+ public void refresh(int flags) throws LibvirtException {
+ libvirt.virStoragePoolRefresh(VSPP) ;
+ processError() ;
+ }
+
+
+ /**
+ * Sets the autostart flag
+ *
+ * @param autostart new flag setting
+ * @throws LibvirtException
+ */
+ public void setAutostart(int autostart) throws LibvirtException {
+ libvirt.virStoragePoolSetAutostart(VSPP, autostart) ;
+ }
+
+
+ /**
+ * Undefine an inactive storage pool
+ *
+ * @throws LibvirtException
+ */
+ public void undefine() throws LibvirtException {
+ libvirt.virStoragePoolUndefine(VSPP) ;
+ processError() ;
+ }
+
+
+ /**
+ * Fetch an object representing to a storage volume based on its name within a pool
+ *
+ * @param name name of storage volume
+ * @return The StorageVol object found
+ * @throws LibvirtException
+ */
+ public StorageVol storageVolLookupByName(String name)
+ throws LibvirtException {
+ StorageVolPointer sPtr = libvirt.virStorageVolLookupByName(VSPP, name) ;
+ processError() ;
+ return new StorageVol(virConnect, sPtr) ;
+ }
+
+
+ /**
+ * Create a storage volume within a pool based on an XML description. Not all pools
support creation of volumes
+ *
+ * @param xmlDesc description of volume to create
+ * @param flags flags for creation (unused, pass 0)
+ * @return the storage volume
+ * @throws LibvirtException
+ */
+ public StorageVol storageVolCreateXML(String xmlDesc, int flags)
+ throws LibvirtException {
+ StorageVolPointer sPtr = libvirt.virStorageVolCreateXML(VSPP, xmlDesc, flags) ;
+ processError() ;
+ return new StorageVol(virConnect, sPtr) ;
+ }
+
+
+ protected void processError() throws LibvirtException {
+ virConnect.processError() ;
+ }
+
+}
diff --git a/src/main/java/org/libvirt/StoragePoolInfo.java
b/src/main/java/org/libvirt/StoragePoolInfo.java
new file mode 100644
index 0000000..2b5b601
--- /dev/null
+++ b/src/main/java/org/libvirt/StoragePoolInfo.java
@@ -0,0 +1,79 @@
+package org.libvirt;
+
+import org.libvirt.jna.virStoragePoolInfo;
+
+public class StoragePoolInfo {
+
+ /**
+ * the running state
+ */
+ public StoragePoolState state;
+
+ /**
+ * Logical size bytes
+ */
+ public long capacity;
+
+ /**
+ * Current allocation bytes
+ */
+ public long allocation;
+
+ /**
+ * Remaining free space bytes
+ */
+ public long available;
+
+ public static enum StoragePoolState {
+ /**
+ * Not running
+ */
+ VIR_STORAGE_POOL_INACTIVE,
+ /**
+ * Initializing pool, not available
+ */
+ VIR_STORAGE_POOL_BUILDING,
+ /**
+ * Running normally
+ */
+ VIR_STORAGE_POOL_RUNNING,
+ /**
+ * Running degraded
+ */
+ VIR_STORAGE_POOL_DEGRADED
+ };
+
+ /**
+ * This is meant to be called from the JNI side, as a convenience constructor
+ *
+ * @param state the state, as defined by libvirt
+ * @param capacity
+ * @param allocation
+ * @param available
+ */
+ StoragePoolInfo(int state, long capacity, long allocation, long available){
+ switch(state){
+ case 0: this.state=StoragePoolState.VIR_STORAGE_POOL_INACTIVE; break;
+ case 1: this.state=StoragePoolState.VIR_STORAGE_POOL_BUILDING; break;
+ case 2: this.state=StoragePoolState.VIR_STORAGE_POOL_RUNNING; break;
+ case 3: this.state=StoragePoolState.VIR_STORAGE_POOL_DEGRADED; break;
+ default: assert(false);
+ }
+ this.capacity = capacity;
+ this.allocation = allocation;
+ this.available = available;
+ }
+
+ StoragePoolInfo(virStoragePoolInfo vInfo) {
+ this(vInfo.state, vInfo.capacity, vInfo.allocation, vInfo.available) ;
+ }
+
+ public String toString(){
+ StringBuffer result = new StringBuffer("");
+ result.append("state:" + state + "\n");
+ result.append("capacity:" + capacity + "\n");
+ result.append("allocation:" + allocation + "\n");
+ result.append("available:" + available + "\n");
+ return result.toString();
+ }
+}
diff --git a/src/main/java/org/libvirt/StorageVol.java
b/src/main/java/org/libvirt/StorageVol.java
new file mode 100644
index 0000000..0eb4efb
--- /dev/null
+++ b/src/main/java/org/libvirt/StorageVol.java
@@ -0,0 +1,183 @@
+package org.libvirt;
+
+import org.libvirt.jna.Libvirt;
+import org.libvirt.jna.StoragePoolPointer;
+import org.libvirt.jna.StorageVolPointer;
+import org.libvirt.jna.virStorageVolInfo;
+
+public class StorageVol {
+
+ static final class DeleteFlags{
+ /**
+ * Delete metadata only (fast)
+ */
+ static final int VIR_STORAGE_POOL_DELETE_NORMAL = 0;
+ /**
+ * Clear all data to zeros (slow)
+ */
+ static final int VIR_STORAGE_POOL_DELETE_ZEROED = 1;
+ }
+
+ public static enum Type {
+ /**
+ * Regular file based volumes
+ */
+ VIR_STORAGE_VOL_FILE,
+ /**
+ * Block based volumes
+ */
+ VIR_STORAGE_VOL_BLOCK
+ }
+
+ /**
+ * the native virStorageVolPtr.
+ */
+ protected StorageVolPointer VSVP;
+
+ /**
+ * The VirConnect Object that represents the Hypervisor of this Domain
+ */
+ protected Connect virConnect;
+
+ /**
+ * the libvirt instance
+ */
+ protected Libvirt libvirt ;
+
+
+ /**
+ * Constructs a VirStorageVol object from a known native virStoragePoolPtr, and a
VirConnect object.
+ * For use when native libvirt returns a virStorageVolPtr, i.e. error handling.
+ *
+ * @param virConnect the Domain's hypervisor
+ * @param VSVP the native virStorageVolPtr
+ */
+ StorageVol(Connect virConnect, StorageVolPointer VSVP){
+ this.virConnect = virConnect;
+ this.VSVP = VSVP;
+ this.libvirt = virConnect.libvirt ;
+ }
+
+ /**
+ * Fetch a storage pool which contains this volume
+ *
+ * @return StoragePool object,
+ * @throws LibvirtException
+ */
+ public StoragePool storagePoolLookupByVolume()
+ throws LibvirtException {
+ StoragePoolPointer ptr = libvirt.virStoragePoolLookupByVolume(VSVP) ;
+ processError() ;
+ return new StoragePool(virConnect, ptr) ;
+ }
+
+
+ /**
+ * Delete the storage volume from the pool
+ *
+ * @param flags future flags, use 0 for now
+ * @throws LibvirtException
+ */
+ public void delete(int flags) throws LibvirtException{
+ libvirt.virStorageVolDelete(VSVP, flags) ;
+ processError() ;
+ }
+
+
+ /**
+ * Release the storage volume handle. The underlying storage volume contains to exist
+ *
+ * @throws LibvirtException
+ */
+ public void free() throws LibvirtException{
+ libvirt.virStorageVolFree(VSVP) ;
+ processError() ;
+ }
+
+
+ /**
+ * Provides the connection object associated with a storage volume. The reference
counter on the connection is not increased by this call.
+ *
+ * @return the Connect object
+ */
+ public Connect getConnect(){
+ return virConnect;
+ }
+
+ /**
+ * Fetches volatile information about the storage volume such as its current allocation
+ *
+ * @return StorageVolInfo object
+ * @throws LibvirtException
+ */
+ public StorageVolInfo getInfo() throws LibvirtException{
+ virStorageVolInfo vInfo = new virStorageVolInfo() ;
+ libvirt.virStorageVolGetInfo(VSVP, vInfo) ;
+ processError() ;
+ return new StorageVolInfo(vInfo) ;
+ }
+
+
+ /**
+ * Fetch the storage volume key. This is globally unique, so the same volume will have
the same key no matter what host it is accessed from
+ *
+ * @return the key
+ * @throws LibvirtException
+ */
+ public String getKey() throws LibvirtException{
+ String returnValue = libvirt.virStorageVolGetKey(VSVP) ;
+ processError() ;
+ return returnValue ;
+ }
+
+
+ /**
+ * Fetch the storage volume name. This is unique within the scope of a pool
+ *
+ * @return the name
+ * @throws LibvirtException
+ */
+ public String getName() throws LibvirtException{
+ String returnValue = libvirt.virStorageVolGetName(VSVP) ;
+ processError() ;
+ return returnValue ;
+ }
+
+
+ /**
+ * Fetch the storage volume path.
+ * Depending on the pool configuration this is either persistent across hosts, or
dynamically assigned at pool startup.
+ * Consult pool documentation for information on getting the persistent naming
+ *
+ * @return the storage volume path
+ * @throws LibvirtException
+ */
+ public String getPath() throws LibvirtException{
+ String returnValue = libvirt.virStorageVolGetPath(VSVP) ;
+ processError() ;
+ return returnValue ;
+ }
+
+
+ /**
+ * Fetch an XML document describing all aspects of this storage volume
+ *
+ * @param flags flags for XML generation (unused, pass 0)
+ * @return the XML document
+ * @throws LibvirtException
+ */
+ public String getXMLDesc(int flags) throws LibvirtException{
+ String returnValue = libvirt.virStorageVolGetXMLDesc(VSVP, flags) ;
+ processError() ;
+ return returnValue ;
+ }
+
+
+ /**
+ * Error handling logic which should be called after every libvirt call
+ * @throws LibvirtException
+ */
+ protected void processError() throws LibvirtException {
+ virConnect.processError() ;
+ }
+}
diff --git a/src/main/java/org/libvirt/StorageVolInfo.java
b/src/main/java/org/libvirt/StorageVolInfo.java
new file mode 100644
index 0000000..9887d4a
--- /dev/null
+++ b/src/main/java/org/libvirt/StorageVolInfo.java
@@ -0,0 +1,59 @@
+package org.libvirt;
+
+import org.libvirt.jna.virStorageVolInfo;
+
+public class StorageVolInfo {
+
+ /**
+ * The type of the Volume
+ */
+ public VirStorageVolType type;
+ /**
+ * Logical size bytes
+ */
+ public long capacity;
+ /**
+ * Current allocation bytes
+ */
+ public long allocation;
+
+ public static enum VirStorageVolType{
+ /**
+ * Regular file based volumes
+ */
+ VIR_STORAGE_VOL_FILE,
+ /**
+ * Block based volumes
+ */
+ VIR_STORAGE_VOL_BLOCK
+ };
+
+ /**
+ * This is meant to be called from the JNI side, as a convenience constructor
+ *
+ * @param type the type, as defined by libvirt
+ * @param capacity
+ * @param allocation
+ */
+ StorageVolInfo(int type, long capacity, long allocation){
+ switch(type){
+ case 0: this.type=VirStorageVolType.VIR_STORAGE_VOL_FILE; break;
+ case 1: this.type=VirStorageVolType.VIR_STORAGE_VOL_BLOCK; break;
+ default: assert(false);
+ }
+ this.capacity = capacity;
+ this.allocation = allocation;
+ }
+
+ StorageVolInfo(virStorageVolInfo volInfo) {
+ this(volInfo.type, volInfo.capacity, volInfo.allocation) ;
+ }
+
+ public String toString(){
+ StringBuffer result = new StringBuffer("");
+ result.append("type:" + type + "\n");
+ result.append("capacity:" + capacity + "\n");
+ result.append("allocation:" + allocation + "\n");
+ return result.toString();
+ }
+}
diff --git a/src/main/java/org/libvirt/VcpuInfo.java
b/src/main/java/org/libvirt/VcpuInfo.java
new file mode 100644
index 0000000..b10c07d
--- /dev/null
+++ b/src/main/java/org/libvirt/VcpuInfo.java
@@ -0,0 +1,26 @@
+package org.libvirt;
+
+import org.libvirt.jna.virVcpuInfo;
+
+public class VcpuInfo {
+ public int number;
+ public VcpuState state;
+ public long cpuTime;
+ public int cpu;
+
+ public static enum VcpuState {
+ VIR_VCPU_OFFLINE,
+ VIR_VCPU_RUNNING,
+ VIR_VCPU_BLOCKED};
+
+ public VcpuInfo() {
+
+ }
+
+ public VcpuInfo(virVcpuInfo vVcpu) {
+ this.number = vVcpu.number ;
+ this.cpuTime = vVcpu.cpuTime ;
+ this.cpu = vVcpu.cpu ;
+ this.state = VcpuState.values()[vVcpu.state] ;
+ }
+}
diff --git a/src/main/java/org/libvirt/jna/ConnectionPointer.java
b/src/main/java/org/libvirt/jna/ConnectionPointer.java
new file mode 100644
index 0000000..ab98489
--- /dev/null
+++ b/src/main/java/org/libvirt/jna/ConnectionPointer.java
@@ -0,0 +1,7 @@
+package org.libvirt.jna;
+
+import com.sun.jna.PointerType;
+
+public class ConnectionPointer extends PointerType
+{
+}
diff --git a/src/main/java/org/libvirt/jna/DomainPointer.java
b/src/main/java/org/libvirt/jna/DomainPointer.java
new file mode 100644
index 0000000..8abb852
--- /dev/null
+++ b/src/main/java/org/libvirt/jna/DomainPointer.java
@@ -0,0 +1,7 @@
+package org.libvirt.jna;
+
+import com.sun.jna.PointerType;
+
+public class DomainPointer extends PointerType
+{
+}
diff --git a/src/main/java/org/libvirt/jna/Libvirt.java
b/src/main/java/org/libvirt/jna/Libvirt.java
new file mode 100644
index 0000000..5ed9fad
--- /dev/null
+++ b/src/main/java/org/libvirt/jna/Libvirt.java
@@ -0,0 +1,162 @@
+package org.libvirt.jna;
+
+
+import com.sun.jna.Callback;
+import com.sun.jna.Library;
+import com.sun.jna.Native;
+import com.sun.jna.NativeLong;
+import com.sun.jna.Pointer;
+import com.sun.jna.ptr.IntByReference;
+import com.sun.jna.ptr.LongByReference;
+
+public interface Libvirt extends Library
+{
+ Libvirt INSTANCE = (Libvirt) Native.loadLibrary("libvirt", Libvirt.class)
;
+
+ // Constants we need
+ public static int VIR_UUID_BUFLEN = 16 ;
+ public static int VIR_UUID_STRING_BUFLEN = (36+1) ;
+ public static int VIR_DOMAIN_SCHED_FIELD_LENGTH = 80 ;
+
+ // Global functions
+ public int virCopyLastError(virError error) ;
+ public virError virGetLastError() ;
+ public int virGetVersion(LongByReference libVer, String type, LongByReference
typeVer) ;
+ public int virInitialize() ;
+ public void virResetLastError() ;
+
+ //Connection Functions
+ public int virConnCopyLastError(ConnectionPointer virConnectPtr, virError to) ;
+ public int virConnectClose(ConnectionPointer virConnectPtr) ;
+ public String virConnectGetCapabilities(ConnectionPointer virConnectPtr) ;
+ public String virConnectGetHostname(ConnectionPointer virConnectPtr) ;
+ public virError virConnGetLastError(ConnectionPointer virConnectPtr) ;
+ public int virConnectGetMaxVcpus(ConnectionPointer virConnectPtr, String type) ;
+ public String virConnectGetType(ConnectionPointer virConnectPtr) ;
+ public String virConnectGetURI(ConnectionPointer virConnectPtr) ;
+ public int virConnectGetVersion(ConnectionPointer virConnectPtr, LongByReference
hvVer) ;
+ public int virConnectListDomains(ConnectionPointer virConnectPtr, int[] ids, int
maxnames) ;
+ public int virConnectListNetworks(ConnectionPointer virConnectPtr, String[] name, int
maxnames) ;
+ public int virConnectListStoragePools(ConnectionPointer virConnectPtr, String[]
names, int maxnames) ;
+ public int virConnectListDefinedStoragePools(ConnectionPointer virConnectPtr,
String[] names, int maxnames) ;
+ public int virConnectListDefinedDomains(ConnectionPointer virConnectPtr, String[]
name, int maxnames) ;
+ public int virConnectListDefinedNetworks(ConnectionPointer virConnectPtr, String[]
name, int maxnames) ;
+ public int virConnectNumOfDomains(ConnectionPointer virConnectPtr) ;
+ public int virConnectNumOfDefinedDomains(ConnectionPointer virConnectPtr) ;
+ public int virConnectNumOfDefinedNetworks(ConnectionPointer virConnectPtr) ;
+ public int virConnectNumOfDefinedStoragePools(ConnectionPointer virConnectPtr) ;
+ public int virConnectNumOfNetworks(ConnectionPointer virConnectPtr) ;
+ public int virConnectNumOfStoragePools(ConnectionPointer virConnectPtr) ;
+ public int virConnResetLastError(ConnectionPointer virConnectPtr) ;
+ public ConnectionPointer virConnectOpen(String name) ;
+ public ConnectionPointer virConnectOpenAuth(String name, virConnectAuth auth, int
flags) ;
+ public ConnectionPointer virConnectOpenReadOnly(String name) ;
+
+ // Node functions
+ public int virNodeGetInfo(ConnectionPointer virConnectPtr, virNodeInfo virNodeInfo)
;
+
+ // Storage Pool
+ public int virStoragePoolBuild(StoragePoolPointer storagePoolPtr, int flags) ;
+ public int virStoragePoolCreate(StoragePoolPointer storagePoolPtr, int flags) ;
+ public StoragePoolPointer virStoragePoolCreateXML(ConnectionPointer virConnectPtr,
String xml, int flags) ;
+ public StoragePoolPointer virStoragePoolDefineXML(ConnectionPointer virConnectPtr,
String xml, int flags) ;
+ public int virStoragePoolDelete(StoragePoolPointer storagePoolPtr, int flags) ;
+ public int virStoragePoolDestroy(StoragePoolPointer storagePoolPtr) ;
+ public int virStoragePoolFree(StoragePoolPointer storagePoolPtr) ;
+ public int virStoragePoolGetAutostart(StoragePoolPointer storagePoolPtr,
IntByReference value) ;
+ public int virStoragePoolGetInfo(StoragePoolPointer storagePoolPtr,
virStoragePoolInfo info) ;
+ public String virStoragePoolGetName(StoragePoolPointer storagePoolPtr) ;
+ public int virStoragePoolGetUUID(StoragePoolPointer storagePoolPtr, byte[]
uuidString) ;
+ public int virStoragePoolGetUUIDString(StoragePoolPointer storagePoolPtr, byte[]
uuidString) ;
+ public String virStoragePoolGetXMLDesc(StoragePoolPointer storagePoolPtr, int flags)
;
+ public int virStoragePoolListVolumes(StoragePoolPointer storagePoolPtr, String[]
names, int maxnames) ;
+ public StoragePoolPointer virStoragePoolLookupByName(ConnectionPointer virConnectPtr,
String name) ;
+ public StoragePoolPointer virStoragePoolLookupByUUIDString(ConnectionPointer
virConnectPtr, String uuidstr) ;
+ public StoragePoolPointer virStoragePoolLookupByUUID(ConnectionPointer virConnectPtr,
String uuidstr) ;
+ public StoragePoolPointer virStoragePoolLookupByVolume(StorageVolPointer
storageVolPtr) ;
+ public int virStoragePoolNumOfVolumes(StoragePoolPointer storagePoolPtr) ;
+ public int virStoragePoolRefresh(StoragePoolPointer storagePoolPtr) ;
+ public int virStoragePoolSetAutostart(StoragePoolPointer storagePoolPtr, int
autostart) ;
+ public int virStoragePoolUndefine(StoragePoolPointer storagePoolPtr) ;
+
+ // Storage Vol
+ public StorageVolPointer virStorageVolCreateXML(StoragePoolPointer storagePoolPtr,
String xml, int flags) ;
+ public StorageVolPointer virStorageVolLookupByKey(ConnectionPointer virConnectPtr,
String name) ;
+ public StorageVolPointer virStorageVolLookupByName(StoragePoolPointer storagePoolPtr,
String name) ;
+ public StorageVolPointer virStorageVolLookupByPath(ConnectionPointer virConnectPtr,
String path) ;
+ public int virStorageVolDelete(StorageVolPointer storageVolPtr, int flags) ;
+ public int virStorageVolFree(StorageVolPointer storageVolPtr) ;
+ public int virStorageVolGetInfo(StorageVolPointer storageVolPtr, virStorageVolInfo
info) ;
+ public String virStorageVolGetKey(StorageVolPointer storageVolPtr) ;
+ public String virStorageVolGetName(StorageVolPointer storageVolPtr) ;
+ public String virStorageVolGetPath(StorageVolPointer storageVolPtr) ;
+ public String virStorageVolGetXMLDesc(StorageVolPointer storageVolPtr, int flags) ;
+
+ // Network functions
+ public int virNetworkCreate(NetworkPointer virConnectPtr) ;
+ public NetworkPointer virNetworkCreateXML(ConnectionPointer virConnectPtr, String
xmlDesc) ;
+ public NetworkPointer virNetworkDefineXML(ConnectionPointer virConnectPtr, String
xmlDesc) ;
+ public int virNetworkDestroy(NetworkPointer virConnectPtr) ;
+ public int virNetworkFree(NetworkPointer virConnectPtr) ;
+ public int virNetworkGetAutostart(NetworkPointer virNetworkPtr, IntByReference value)
;
+ public String virNetworkGetBridgeName(NetworkPointer virNetworkPtr) ;
+ public String virNetworkGetName(NetworkPointer virNetworkPtr) ;
+ public int virNetworkGetUUID(NetworkPointer virNetworkPtr, byte[] uuidString) ;
+ public int virNetworkGetUUIDString(NetworkPointer virNetworkPtr, byte[] uuidString)
;
+ public String virNetworkGetXMLDesc(NetworkPointer virNetworkPtr, int flags) ;
+ public NetworkPointer virNetworkLookupByName(ConnectionPointer virConnectPtr, String
name) ;
+ public NetworkPointer virNetworkLookupByUUIDString(ConnectionPointer virConnectPtr,
String uuidstr) ;
+ public NetworkPointer virNetworkLookupByUUID(ConnectionPointer virConnectPtr, String
uuidstr) ;
+ public int virNetworkSetAutostart(NetworkPointer virConnectPtr, int autoStart) ;
+ public int virNetworkUndefine(NetworkPointer virConnectPtr) ;
+
+ // Domain functions
+ public int virDomainAttachDevice(DomainPointer virDomainPtr, String deviceXML) ;
+ public int virDomainBlockStats(DomainPointer virDomainPtr, String path,
virDomainBlockStats stats, int size) ;
+ public int virDomainCreate(DomainPointer virDomainPtr) ;
+ public DomainPointer virDomainCreateLinux(ConnectionPointer virConnectPtr, String
xmlDesc, int flags) ;
+ public DomainPointer virDomainCreateXML(ConnectionPointer virConnectPtr, String
xmlDesc, int flags) ;
+ public int virDomainCoreDump(DomainPointer virDomainPtr, String to, int flags) ;
+ public DomainPointer virDomainDefineXML(ConnectionPointer virConnectPtr, String
xmlDesc) ;
+ public int virDomainDetachDevice(DomainPointer virDomainPtr, String deviceXML) ;
+ public int virDomainDestroy(DomainPointer virDomainPtr) ;
+ public int virDomainFree(DomainPointer virDomainPtr) ;
+ public int virDomainGetAutostart(DomainPointer virDomainPtr, IntByReference value) ;
+ public int virDomainGetID(DomainPointer virDomainPtr) ;
+ public int virDomainGetInfo(DomainPointer virDomainPtr, virDomainInfo vInfo) ;
+ public NativeLong virDomainGetMaxMemory(DomainPointer virDomainPtr) ;
+ public int virDomainGetMaxVcpus(DomainPointer virDomainPtr) ;
+ public String virDomainGetName(DomainPointer virDomainPtr) ;
+ public String virDomainGetOSType(DomainPointer virDomainPtr) ;
+ public int virDomainGetUUID(DomainPointer virDomainPtr, byte[] uuidString) ;
+ public int virDomainGetUUIDString(DomainPointer virDomainPtr, byte[] uuidString) ;
+ public String virDomainGetXMLDesc(DomainPointer virDomainPtr, int flags) ;
+ public String virDomainGetSchedulerType(DomainPointer virDomainPtr, IntByReference
nparams) ;
+ public int virDomainGetSchedulerParameters(DomainPointer virDomainPtr,
virSchedParameter[] params, IntByReference nparams) ;
+ public int virDomainGetVcpus(DomainPointer virDomainPtr, virVcpuInfo[] info, int
maxInfo, byte[] cpumaps, int maplen) ;
+ public int virDomainInterfaceStats(DomainPointer virDomainPtr, String path,
virDomainInterfaceStats stats, int size) ;
+ public DomainPointer virDomainLookupByID(ConnectionPointer virConnectPtr, int id) ;
+ public DomainPointer virDomainLookupByName(ConnectionPointer virConnectPtr, String
name) ;
+ public DomainPointer virDomainLookupByUUID(ConnectionPointer virConnectPtr, String
uuidstr) ;
+ public DomainPointer virDomainLookupByUUIDString(ConnectionPointer virConnectPtr,
String uuidstr) ;
+ public DomainPointer virDomainMigrate(DomainPointer virDomainPtr, ConnectionPointer
virConnectPtr, NativeLong flags, String dname, String uri, NativeLong bandwidth) ;
+ public int virDomainPinVcpu(DomainPointer virDomainPtr, int vcpu, byte[] cpumap, int
maplen) ;
+ public int virDomainReboot(DomainPointer virDomainPtr, int flags) ;
+ public int virDomainResume(DomainPointer virDomainPtr) ;
+ public int virDomainRestore(ConnectionPointer virConnectPtr, String from) ;
+ public int virDomainSave(DomainPointer virDomainPtr, String to) ;
+ public int virDomainSetAutostart(DomainPointer virDomainPtr, int autoStart) ;
+ public int virDomainSetSchedulerParameters(DomainPointer virDomainPtr,
virSchedParameter[] params, IntByReference nparams) ;
+ public int virDomainSetMaxMemory(DomainPointer virDomainPtr, NativeLong maxMemory) ;
+ public int virDomainSetMemory(DomainPointer virDomainPtr, NativeLong maxMemory) ;
+ public int virDomainSetVcpus(DomainPointer virDomainPtr, int nvcpus) ;
+ public int virDomainShutdown(DomainPointer virDomainPtr) ;
+ public int virDomainSuspend(DomainPointer virDomainPtr) ;
+ public int virDomainUndefine(DomainPointer virDomainPtr) ;
+
+ // Callbacks
+ interface VirConnectAuthCallback extends Callback {
+ public int authCallback(virConnectCredential cred, int ncred, Pointer cbdata) ;
+
+ }
+}
diff --git a/src/main/java/org/libvirt/jna/NetworkPointer.java
b/src/main/java/org/libvirt/jna/NetworkPointer.java
new file mode 100644
index 0000000..62b710c
--- /dev/null
+++ b/src/main/java/org/libvirt/jna/NetworkPointer.java
@@ -0,0 +1,7 @@
+package org.libvirt.jna;
+
+import com.sun.jna.PointerType;
+
+public class NetworkPointer extends PointerType
+{
+}
diff --git a/src/main/java/org/libvirt/jna/StoragePoolPointer.java
b/src/main/java/org/libvirt/jna/StoragePoolPointer.java
new file mode 100644
index 0000000..e004ee8
--- /dev/null
+++ b/src/main/java/org/libvirt/jna/StoragePoolPointer.java
@@ -0,0 +1,7 @@
+package org.libvirt.jna;
+
+import com.sun.jna.PointerType;
+
+public class StoragePoolPointer extends PointerType
+{
+}
diff --git a/src/main/java/org/libvirt/jna/StorageVolPointer.java
b/src/main/java/org/libvirt/jna/StorageVolPointer.java
new file mode 100644
index 0000000..e0a4acd
--- /dev/null
+++ b/src/main/java/org/libvirt/jna/StorageVolPointer.java
@@ -0,0 +1,7 @@
+package org.libvirt.jna;
+
+import com.sun.jna.PointerType;
+
+public class StorageVolPointer extends PointerType
+{
+}
diff --git a/src/main/java/org/libvirt/jna/virConnectAuth.java
b/src/main/java/org/libvirt/jna/virConnectAuth.java
new file mode 100644
index 0000000..8c94b6e
--- /dev/null
+++ b/src/main/java/org/libvirt/jna/virConnectAuth.java
@@ -0,0 +1,11 @@
+package org.libvirt.jna;
+
+import com.sun.jna.Pointer;
+import com.sun.jna.Structure;
+
+public class virConnectAuth extends Structure {
+ public int[] credtype ;
+ public int ncredtype ;
+ public Libvirt.VirConnectAuthCallback cb ;
+ public Pointer cbdata ;
+}
diff --git a/src/main/java/org/libvirt/jna/virConnectCredential.java
b/src/main/java/org/libvirt/jna/virConnectCredential.java
new file mode 100644
index 0000000..1fbd5e7
--- /dev/null
+++ b/src/main/java/org/libvirt/jna/virConnectCredential.java
@@ -0,0 +1,12 @@
+package org.libvirt.jna;
+
+import com.sun.jna.Structure;
+
+public class virConnectCredential extends Structure {
+ public int type ;
+ public String prompt ;
+ public String challenge ;
+ public String defresult ;
+ public String[] result ;
+ public int resultlen ;
+}
\ No newline at end of file
diff --git a/src/main/java/org/libvirt/jna/virDomainBlockStats.java
b/src/main/java/org/libvirt/jna/virDomainBlockStats.java
new file mode 100644
index 0000000..446e016
--- /dev/null
+++ b/src/main/java/org/libvirt/jna/virDomainBlockStats.java
@@ -0,0 +1,12 @@
+package org.libvirt.jna;
+
+import com.sun.jna.Structure;
+
+public class virDomainBlockStats extends Structure
+{
+ public long rd_req ;
+ public long rd_bytes ;
+ public long wr_req ;
+ public long wr_bytes ;
+ public long errs ;
+}
diff --git a/src/main/java/org/libvirt/jna/virDomainInfo.java
b/src/main/java/org/libvirt/jna/virDomainInfo.java
new file mode 100644
index 0000000..15d4836
--- /dev/null
+++ b/src/main/java/org/libvirt/jna/virDomainInfo.java
@@ -0,0 +1,13 @@
+package org.libvirt.jna;
+
+import com.sun.jna.NativeLong;
+import com.sun.jna.Structure ;
+
+public class virDomainInfo extends Structure
+{
+ public int state ;
+ public NativeLong maxMem ;
+ public NativeLong memory ;
+ public short nrVirtCpu ;
+ public long cpuTime ;
+}
diff --git a/src/main/java/org/libvirt/jna/virDomainInterfaceStats.java
b/src/main/java/org/libvirt/jna/virDomainInterfaceStats.java
new file mode 100644
index 0000000..3fda2dd
--- /dev/null
+++ b/src/main/java/org/libvirt/jna/virDomainInterfaceStats.java
@@ -0,0 +1,16 @@
+package org.libvirt.jna;
+
+import com.sun.jna.Structure;
+
+public class virDomainInterfaceStats extends Structure
+{
+ public long rx_bytes;
+ public long rx_packets;
+ public long rx_errs;
+ public long rx_drop;
+ public long tx_bytes;
+ public long tx_packets;
+ public long tx_errs;
+ public long tx_drop;
+
+}
diff --git a/src/main/java/org/libvirt/jna/virError.java
b/src/main/java/org/libvirt/jna/virError.java
new file mode 100644
index 0000000..10529fe
--- /dev/null
+++ b/src/main/java/org/libvirt/jna/virError.java
@@ -0,0 +1,20 @@
+package org.libvirt.jna;
+
+import com.sun.jna.Pointer;
+import com.sun.jna.Structure ;
+
+public class virError extends Structure
+{
+ public int code ;
+ public int domain ;
+ public String message ;
+ public int level ;
+ public Pointer conn ;
+ public Pointer dom ;
+ public String str1 ;
+ public String str2 ;
+ public String str3 ;
+ public int int1 ;
+ public int int2 ;
+ public Pointer net ;
+}
diff --git a/src/main/java/org/libvirt/jna/virNodeInfo.java
b/src/main/java/org/libvirt/jna/virNodeInfo.java
new file mode 100644
index 0000000..5a6449e
--- /dev/null
+++ b/src/main/java/org/libvirt/jna/virNodeInfo.java
@@ -0,0 +1,19 @@
+package org.libvirt.jna;
+
+import com.sun.jna.NativeLong;
+import com.sun.jna.Structure;
+
+public class virNodeInfo extends Structure
+{
+ public class ByValue extends virNodeInfo implements Structure.ByValue {};
+ public class ByReference extends virNodeInfo implements Structure.ByReference {};
+
+ public byte model[] = new byte[32];
+ public NativeLong memory ;
+ public int cpus ;
+ public int mhz ;
+ public int nodes ;
+ public int sockets ;
+ public int cores ;
+ public int threads ;
+}
\ No newline at end of file
diff --git a/src/main/java/org/libvirt/jna/virSchedParameter.java
b/src/main/java/org/libvirt/jna/virSchedParameter.java
new file mode 100644
index 0000000..f8440e1
--- /dev/null
+++ b/src/main/java/org/libvirt/jna/virSchedParameter.java
@@ -0,0 +1,11 @@
+package org.libvirt.jna;
+
+import com.sun.jna.Structure;
+
+public class virSchedParameter extends Structure
+{
+ public byte field[] = new byte[Libvirt.VIR_DOMAIN_SCHED_FIELD_LENGTH] ;
+ public int type ;
+ public virSchedParameterValue value ;
+
+}
diff --git a/src/main/java/org/libvirt/jna/virSchedParameterValue.java
b/src/main/java/org/libvirt/jna/virSchedParameterValue.java
new file mode 100644
index 0000000..ff2cdfc
--- /dev/null
+++ b/src/main/java/org/libvirt/jna/virSchedParameterValue.java
@@ -0,0 +1,13 @@
+package org.libvirt.jna;
+
+import com.sun.jna.Structure;
+
+public class virSchedParameterValue extends Structure
+{
+ public int i; /* data for integer case */
+ public int ui; /* data for unsigned integer case */
+ public long l; /* data for long long integer case */
+ public long ul; /* data for unsigned long long integer case */
+ public double d; /* data for double case */
+ public byte b; /* data for char case */
+}
diff --git a/src/main/java/org/libvirt/jna/virStoragePoolInfo.java
b/src/main/java/org/libvirt/jna/virStoragePoolInfo.java
new file mode 100644
index 0000000..78915ff
--- /dev/null
+++ b/src/main/java/org/libvirt/jna/virStoragePoolInfo.java
@@ -0,0 +1,11 @@
+package org.libvirt.jna;
+
+import com.sun.jna.Structure;
+
+public class virStoragePoolInfo extends Structure
+{
+ public int state ;
+ public long capacity ;
+ public long allocation ;
+ public long available ;
+}
diff --git a/src/main/java/org/libvirt/jna/virStorageVolInfo.java
b/src/main/java/org/libvirt/jna/virStorageVolInfo.java
new file mode 100644
index 0000000..598f28a
--- /dev/null
+++ b/src/main/java/org/libvirt/jna/virStorageVolInfo.java
@@ -0,0 +1,11 @@
+package org.libvirt.jna;
+
+import com.sun.jna.Structure;
+
+public class virStorageVolInfo extends Structure
+{
+ public int type ;
+ public long capacity ;
+ public long allocation ;
+
+}
\ No newline at end of file
diff --git a/src/main/java/org/libvirt/jna/virVcpuInfo.java
b/src/main/java/org/libvirt/jna/virVcpuInfo.java
new file mode 100644
index 0000000..ba72ce8
--- /dev/null
+++ b/src/main/java/org/libvirt/jna/virVcpuInfo.java
@@ -0,0 +1,12 @@
+package org.libvirt.jna;
+
+import com.sun.jna.Structure;
+
+public class virVcpuInfo extends Structure
+{
+ public int number ;
+ public int state ;
+ public long cpuTime ;
+ public int cpu ;
+
+}
diff --git a/src/org/libvirt/.cvsignore b/src/org/libvirt/.cvsignore
deleted file mode 100644
index 6b468b6..0000000
--- a/src/org/libvirt/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-*.class
diff --git a/src/org/libvirt/Connect.java b/src/org/libvirt/Connect.java
deleted file mode 100644
index 5041611..0000000
--- a/src/org/libvirt/Connect.java
+++ /dev/null
@@ -1,878 +0,0 @@
-package org.libvirt;
-
-import java.util.Arrays;
-
-import org.libvirt.LibvirtException;
-import org.libvirt.StoragePool;
-import org.libvirt.StorageVol;
-import org.libvirt.jna.ConnectionPointer;
-import org.libvirt.jna.DomainPointer;
-import org.libvirt.jna.Libvirt;
-import org.libvirt.jna.NetworkPointer;
-import org.libvirt.jna.StoragePoolPointer;
-import org.libvirt.jna.StorageVolPointer;
-import org.libvirt.jna.virConnectAuth;
-import org.libvirt.jna.virError;
-import org.libvirt.jna.virNodeInfo;
-
-import com.sun.jna.Native;
-import com.sun.jna.NativeLong;
-import com.sun.jna.Pointer;
-import com.sun.jna.ptr.ByReference;
-import com.sun.jna.ptr.LongByReference;
-
-/**
- * The Connect object represents a connection to a local or remote hypervisor/driver.
- *
- * @author stoty
- *
- */
-public class Connect {
-
- // Load the native part
- static {
- Libvirt.INSTANCE.virInitialize() ;
- try {
- ErrorHandler.processError(Libvirt.INSTANCE) ;
- }
- catch (Exception e) {
- e.printStackTrace() ;
- }
- }
-
- /**
- * the native virConnectPtr.
- */
- protected ConnectionPointer VCP;
-
-
- /**
- * The libvirt library
- */
- Libvirt libvirt = Libvirt.INSTANCE ;
-
- /**
- * Construct a Connect object from a known native virConnectPtr
- * For use when native libvirt returns a virConnectPtr, i.e. error handling.
- *
- * @param VCP the virConnectPtr pointing to an existing native virConnect structure
- */
- @Deprecated
- Connect(long VCP) {
- throw new RuntimeException("No longer supported") ;
- }
-
- /**
- * Constructs a Connect object from the supplied URI.
- *
- * @param uri The connection URI
- * @param readOnly Whether the connection is read-only
- * @throws LibvirtException
- * @see <a
href="http://libvirt.org/uri.html">The URI
documentation</a>
- */
- public Connect(String uri, boolean readOnly) throws LibvirtException {
- if (readOnly) {
- VCP = libvirt.virConnectOpenReadOnly(uri) ;
- } else {
- VCP = libvirt.virConnectOpen(uri) ;
- }
- // Check for an error
- processError() ;
- ErrorHandler.processError(Libvirt.INSTANCE) ;
- }
-
- /**
- * Constructs a Connect object from the supplied URI,
- * using the supplied authentication callback
- *
- * @param uri The connection URI
- * @param auth a ConnectAuth object
- * @param flags
- * @throws LibvirtException
- * @see <a
href="http://libvirt.org/uri.html">The URI
documentation</a>
- */
- public Connect(String uri, ConnectAuth auth, int flags) throws LibvirtException {
- virConnectAuth vAuth = new virConnectAuth() ;
- vAuth.cb = auth ;
- vAuth.cbdata = null ;
- vAuth.ncredtype = auth.credType.length ;
- vAuth.credtype = new int[vAuth.ncredtype] ;
-
- for (int x = 0 ; x < vAuth.ncredtype ; x++) {
- vAuth.credtype[x] = auth.credType[x].ordinal() ;
- }
-
- VCP = libvirt.virConnectOpenAuth(uri, vAuth, flags) ;
- // Check for an error
- processError() ;
- ErrorHandler.processError(Libvirt.INSTANCE) ;
- }
-
- /**
- * Constructs a read-write Connect object from the supplied URI.
- *
- * @param uri The connection URI
- * @throws LibvirtException
- * @see <a
href="http://libvirt.org/uri.html">The URI
documentation</a>
- */
- public Connect(String uri) throws LibvirtException {
- VCP = libvirt.virConnectOpen(uri) ;
- // Check for an error
- processError() ;
- ErrorHandler.processError(Libvirt.INSTANCE) ;
- }
-
- public void finalize() throws LibvirtException {
- close();
- }
-
-
- /**
- * Closes the connection to the hypervisor/driver. Calling any methods on the object
after close() will result in an exception.
- *
- * @throws LibvirtException
- */
- public void close() throws LibvirtException {
- libvirt.virConnectClose(VCP) ;
- processError() ;
- // If leave an invalid pointer dangling around JVM crashes and burns if
- // someone tries to call a method on us
- // We rely on the underlying libvirt error handling to detect that it's called with
a null virConnectPointer
- VCP = null;
- }
-
-
- /**
- * Provides capabilities of the hypervisor / driver.
- *
- * @return an XML String describing the capabilities.
- * @throws LibvirtException
- * @see <a
href="http://libvirt.org/format.html#Capa1" >The XML format
description</a>
- *
- */
- public String getCapabilities() throws LibvirtException {
- String returnValue = libvirt.virConnectGetCapabilities(VCP) ;
- processError() ;
- return returnValue ;
- }
-
-
- /**
- * Returns the system hostname on which the hypervisor is running.
- * (the result of the gethostname(2) system call)
- * If we are connected to a remote system, then this returns the hostname of the remote
system.
- *
- * @return the hostname
- * @throws LibvirtException
- */
- public String getHostName() throws LibvirtException {
- String returnValue = libvirt.virConnectGetHostname(VCP) ;
- processError() ;
- return returnValue ;
-
- }
-
-
- /**
- * Provides the maximum number of virtual CPUs supported for a guest VM of a specific
type.
- * The 'type' parameter here corresponds to the 'type' attribute in the
<domain> element of the XML.
- *
- * @param type
- * @return the number of CPUs
- * @throws LibvirtException
- */
- public int getMaxVcpus(String type) throws LibvirtException {
- int returnValue = libvirt.virConnectGetMaxVcpus(VCP, type) ;
- processError() ;
- return returnValue ;
- }
-
-
- /**
- * Gets the name of the Hypervisor software used.
- *
- * @return the name
- * @throws LibvirtException
- */
- public String getType() throws LibvirtException {
- String returnValue = libvirt.virConnectGetType(VCP) ;
- processError() ;
- return returnValue ;
- }
-
-
-
- /**
- * Returns the URI (name) of the hypervisor connection.
- * Normally this is the same as or similar to the string passed to the
virConnectOpen/virConnectOpenReadOnly call,
- * but the driver may make the URI canonical.
- *
- * @return the URI
- * @throws LibvirtException
- */
- public String getURI() throws LibvirtException {
- String returnValue = libvirt.virConnectGetURI(VCP) ;
- processError() ;
- return returnValue ;
- }
-
-
-
- /**
- * Gets the version level of the Hypervisor running.
- * This may work only with hypervisor call, i.e. with priviledged access to the
hypervisor, not with a Read-Only connection.
- * If the version can't be extracted by lack of capacities returns 0.
- *
- * @return major * 1,000,000 + minor * 1,000 + release
- * @throws LibvirtException
- */
- public long getVersion() throws LibvirtException {
- LongByReference hvVer = new LongByReference() ;
- libvirt.virConnectGetVersion(VCP, hvVer) ;
- processError() ;
- return hvVer.getValue();
- }
-
-
- /**
- * Gets the version of the native libvirt library that the JNI part is linked to.
- *
- * @return major * 1,000,000 + minor * 1,000 + release
- * @throws LibvirtException
- */
- public long getLibVirVersion() throws LibvirtException {
- LongByReference libVer = new LongByReference() ;
- LongByReference typeVer = new LongByReference() ;
- libvirt.virGetVersion(libVer, null, typeVer) ;
- processError() ;
- return libVer.getValue();
- }
-
-
- /**
- * Returns the version of the hypervisor against which the library was compiled.
- * The type parameter specified which hypervisor's version is returned
- *
- * @param type
- * @return major * 1,000,000 + minor * 1,000 + release
- * @throws LibvirtException
- */
- public long GetHypervisorVersion(String type) throws LibvirtException {
- LongByReference libVer = new LongByReference() ;
- LongByReference typeVer = new LongByReference() ;
- libvirt.virGetVersion(libVer, type, typeVer) ;
- processError() ;
- return libVer.getValue();
- }
-
-
- /**
- * Lists the names of the defined but inactive domains
- *
- * @return an Array of Strings that contains the names of the defined domains currently
inactive
- * @throws LibvirtException
- */
- public String[] listDefinedDomains() throws LibvirtException {
- int maxnames = this.numOfDefinedDomains() ;
- String[] names = new String[maxnames] ;
- if (maxnames > 0) {
- libvirt.virConnectListDefinedDomains(VCP, names, maxnames) ;
- processError() ;
- }
- return names ;
- }
-
-
- /**
- * Lists the inactive networks
- *
- * @return an Array of Strings that contains the names of the inactive networks
- * @throws LibvirtException
- */
- public String[] listDefinedNetworks() throws LibvirtException {
- int maxnames = this.numOfDefinedNetworks() ;
- String[] names = new String[maxnames] ;
-
- if (maxnames > 0) {
- libvirt.virConnectListDefinedNetworks(VCP, names, maxnames) ;
- processError() ;
- }
- return names ;
- }
-
-
- /**
- * Lists the active domains.
- *
- * @return and array of the IDs of the active domains
- * @throws LibvirtException
- */
- public int[] listDomains() throws LibvirtException {
- int maxids = this.numOfDomains() ;
- int[] ids = new int[maxids] ;
-
- if (maxids > 0) {
- libvirt.virConnectListDomains(VCP, ids, maxids) ;
- processError() ;
- }
- return ids ;
- }
-
-
- /**
- * Lists the active networks.
- *
- * @return an Array of Strings that contains the names of the active networks
- * @throws LibvirtException
- */
- public String[] listNetworks() throws LibvirtException {
- int maxnames = this.numOfNetworks() ;
- String[] names = new String[maxnames] ;
-
- if (maxnames > 0) {
- libvirt.virConnectListNetworks(VCP, names, maxnames) ;
- processError() ;
- }
- return names ;
- }
-
-
- /**
- * Provides the number of inactive domains.
- *
- * @return the number of inactive domains
- * @throws LibvirtException
- */
- public int numOfDefinedDomains() throws LibvirtException {
- int returnValue = libvirt.virConnectNumOfDefinedDomains(VCP) ;
- processError() ;
- return returnValue ;
- }
-
-
-
- /**
- * Provides the number of inactive networks.
- *
- * @return the number of inactive networks
- * @throws LibvirtException
- */
- public int numOfDefinedNetworks() throws LibvirtException {
- int returnValue = libvirt.virConnectNumOfDefinedNetworks(VCP) ;
- processError() ;
- return returnValue ;
- }
-
-
- /**
- * Provides the number of active domains.
- *
- * @return the number of active domains
- * @throws LibvirtException
- */
- public int numOfDomains() throws LibvirtException {
- int returnValue = libvirt.virConnectNumOfDomains(VCP) ;
- processError() ;
- return returnValue ;
- }
-
-
- /**
- * Provides the number of active networks.
- *
- * @return the number of active networks
- * @throws LibvirtException
- */
- public int numOfNetworks() throws LibvirtException {
- int returnValue = libvirt.virConnectNumOfNetworks(VCP) ;
- processError() ;
- return returnValue ;
- }
-
-
- // virNetwork stuff
-
- /**
- * Looks up a network on the based on its name.
- *
- * @param name name of the network
- * @return The Network object found
- * @throws LibvirtException
- */
- public Network networkLookupByName(String name)
- throws LibvirtException {
- Network returnValue = null ;
- NetworkPointer ptr = libvirt.virNetworkLookupByName(VCP, name) ;
- processError() ;
- if (ptr != null) {
- returnValue = new Network(this, ptr) ;
- }
- return returnValue ;
- }
-
-
- /**
- * Looks up a network based on its UUID represented as an int array.
- * The UUID Array contains an unpacked representation of the UUID, each int contains
only one byte.
- *
- * @param UUID the UUID as an unpacked int array
- * @return The Network object found
- * @throws LibvirtException
- */
- public Network networkLookupByUUID(int[] UUID)
- throws LibvirtException {
- String uuidString = Connect.createUUIDString(UUID) ;
- Network returnValue = null ;
- NetworkPointer ptr = libvirt.virNetworkLookupByUUID(VCP, uuidString) ;
- processError() ;
- if (ptr != null) {
- returnValue = new Network(this, ptr) ;
- }
- return returnValue ;
- }
-
-
- /**
- * Looks up a network based on its UUID represented as a String.
- *
- * @param UUID the UUID in canonical String representation
- * @return The Network object found
- * @throws LibvirtException
- */
- public Network networkLookupByUUIDString(String UUID)
- throws LibvirtException {
- Network returnValue = null ;
- NetworkPointer ptr = libvirt.virNetworkLookupByUUIDString(VCP, UUID);
- processError() ;
- if (ptr != null) {
- returnValue = new Network(this, ptr) ;
- }
- return returnValue ;
- }
-
-
- /**
- * Creates and starts a new virtual network.
- * The properties of the network are based on an XML description similar to the one
returned by virNetworkGetXMLDesc()
- *
- * @param xmlDesc the Network Description
- * @return the Network object representing the created network
- * @throws LibvirtException
- * @see <a
href="http://libvirt.org/format.html#Net1" >The XML format
description</a>
- */
- public Network networkCreateXML(String xmlDesc)
- throws LibvirtException {
- Network returnValue = null ;
- NetworkPointer ptr = libvirt.virNetworkCreateXML(VCP, xmlDesc) ;
- processError() ;
- if (ptr != null) {
- returnValue = new Network(this, ptr) ;
- }
- return returnValue ;
- }
-
-
- /**
- * Defines a network, but does not create it.
- * The properties of the network are based on an XML description similar to the one
returned by virNetworkGetXMLDesc()
- *
- * @param xmlDesc
- * @return the resulting Network object
- * @throws LibvirtException
- * @see <a
href="http://libvirt.org/format.html#Net1" >The XML format
description</a>
- */
- public Network networkDefineXML(String xmlDesc)
- throws LibvirtException {
- Network returnValue = null ;
- NetworkPointer ptr = libvirt.virNetworkDefineXML(VCP, xmlDesc) ;
- processError() ;
- if (ptr != null) {
- returnValue = new Network(this, ptr) ;
- }
- return returnValue ;
- }
-
-
- /**
- * Finds a domain based on the hypervisor ID number.
- *
- * @param id the hypervisor id
- * @return the Domain object
- * @throws LibvirtException
- */
- public Domain domainLookupByID(int id) throws LibvirtException {
- Domain returnValue = null ;
- DomainPointer ptr = libvirt.virDomainLookupByID(VCP, id) ;
- processError() ;
- if (ptr != null) {
- returnValue = new Domain(this, ptr) ;
- }
- return returnValue ;
- }
-
-
- /**
- * Looks up a domain based on its name.
- *
- * @param name the name of the domain
- * @return the Domain object
- * @throws LibvirtException
- */
- public Domain domainLookupByName(String name) throws LibvirtException {
- Domain returnValue = null ;
- DomainPointer ptr = libvirt.virDomainLookupByName(VCP, name) ;
- processError() ;
- if (ptr != null) {
- returnValue = new Domain(this, ptr) ;
- }
- return returnValue ;
- }
-
-
- /**
- * Looks up a domain based on its UUID in array form.
- * The UUID Array contains an unpacked representation of the UUID, each int contains
only one byte.
- *
- * @param UUID the UUID as an unpacked int array
- * @return the Domain object
- * @throws LibvirtException
- */
- public Domain domainLookupByUUID(int[] UUID) throws LibvirtException {
- String uuidString = Connect.createUUIDString(UUID) ;
- Domain returnValue = null ;
- DomainPointer ptr = libvirt.virDomainLookupByUUID(VCP, uuidString) ;
- processError() ;
- if (ptr != null) {
- returnValue = new Domain(this, ptr) ;
- }
- return returnValue ;
- }
-
- /**
- * Looks up a domain based on its UUID in String form.
- *
- * @param UUID the UUID in canonical String representation
- * @return the Domain object
- * @throws LibvirtException
- */
- public Domain domainLookupByUUIDString(String UUID)
- throws LibvirtException {
- Domain returnValue = null ;
- DomainPointer ptr = libvirt.virDomainLookupByUUIDString(VCP, UUID) ;
- processError() ;
- if (ptr != null) {
- returnValue = new Domain(this, ptr) ;
- }
- return returnValue ;
- }
-
-
- /**
- * Launches a new Linux guest domain.
- * The domain is based on an XML description similar to the one returned by
virDomainGetXMLDesc().
- * This function may require priviledged access to the hypervisor.
- *
- * @param xmlDesc the Domain description in XML
- * @param flags an optional set of flags (unused)
- * @return the Domain object
- * @throws LibvirtException
- * @see <a
href="http://libvirt.org/format.html#Normal1" > The XML
format description </a>
- */
- public Domain domainCreateLinux(String xmlDesc, int flags)
- throws LibvirtException {
- Domain returnValue = null ;
- DomainPointer ptr = libvirt.virDomainCreateLinux(VCP, xmlDesc, flags) ;
- processError() ;
- if (ptr != null) {
- returnValue = new Domain(this, ptr) ;
- }
- return returnValue ;
- }
-
-
- /**
- * Defines a domain, but does not start it
- *
- * @param xmlDesc
- * @return the Domain object
- * @throws LibvirtException
- * @see <a
href="http://libvirt.org/format.html#Normal1" > The XML
format description </a>
- */
- public Domain domainDefineXML(String xmlDesc) throws LibvirtException {
- Domain returnValue = null ;
- DomainPointer ptr = libvirt.virDomainDefineXML(VCP, xmlDesc) ;
- processError() ;
- if (ptr != null) {
- returnValue = new Domain(this, ptr) ;
- }
- return returnValue ;
- }
-
-
- /**
- * Launch a new guest domain, based on an XML description
- *
- * @param xmlDesc
- * @return the Domain object
- * @throws LibvirtException
- * @see <a
href="http://libvirt.org/format.html#Normal1" > The XML
format description </a>
- */
- public Domain domainCreateXML(String xmlDesc, int flags) throws LibvirtException {
- Domain returnValue = null ;
- DomainPointer ptr = libvirt.virDomainCreateXML(VCP, xmlDesc, flags) ;
- processError() ;
- if (ptr != null) {
- returnValue = new Domain(this, ptr) ;
- }
- return returnValue ;
- }
-
-
- /**
- * Restores a domain saved to disk by Domain.save().
- *
- * @param from the path of the saved file on the remote host
- * @throws LibvirtException
- */
- public void restore(String from) throws LibvirtException {
- libvirt.virDomainRestore(VCP, from);
- processError() ;
- }
-
-
- /**
- * Returns a NodeInfo object describing the hardware configuration of the node.
- *
- * @return a NodeInfo object
- * @throws LibvirtException
- */
- public NodeInfo nodeInfo() throws LibvirtException {
- virNodeInfo vInfo = new virNodeInfo();
- libvirt.virNodeGetInfo(VCP,vInfo) ;
- processError() ;
- return new NodeInfo(vInfo) ;
- }
-
-
- /**
- * change the amount of memory reserved to Domain0.
- * Domain0 is the domain where the application runs.
- * This function may requires priviledged access to the hypervisor.
- *
- * @param memory in kilobytes
- * @throws LibvirtException
- */
- public void setDom0Memory(long memory) throws LibvirtException {
- libvirt.virDomainSetMemory(null, new NativeLong(memory)) ;
- processError() ;
- }
-
-
- /**
- * Provides the number of inactive storage pools
- *
- * @return the number of pools found
- * @throws LibvirtException
- */
- public int numOfDefinedStoragePools() throws LibvirtException {
- int returnValue = libvirt.virConnectNumOfDefinedStoragePools(VCP);
- processError() ;
- return returnValue ;
- }
-
-
- /**
- * Provides the number of active storage pools
- *
- * @return the number of pools found
- * @throws LibvirtException
- */
- public int numOfStoragePools() throws LibvirtException {
- int returnValue = libvirt.virConnectNumOfStoragePools(VCP);
- processError() ;
- return returnValue ;
- }
-
-
- /**
- * Provides the list of names of inactive storage pools.
- *
- * @return an Array of Strings that contains the names of the defined storage pools
- * @throws LibvirtException
- */
- public String[] listDefinedStoragePools() throws LibvirtException {
- int num = this.numOfDefinedStoragePools() ;
- String[] returnValue = new String[num] ;
- libvirt.virConnectListDefinedStoragePools(VCP, returnValue, num) ;
- processError() ;
- return returnValue ;
- }
-
-
- /**
- * Provides the list of names of active storage pools.
- *
- * @return an Array of Strings that contains the names of the defined storage pools
- * @throws LibvirtException
- */
- public String[] listStoragePools() throws LibvirtException {
- int num = this.numOfStoragePools() ;
- String[] returnValue = new String[num] ;
- libvirt.virConnectListStoragePools(VCP, returnValue, num) ;
- processError() ;
- return returnValue ;
- }
-
-
- /**
- * Create a new storage based on its XML description.
- * The pool is not persistent, so its definition will disappear when it is destroyed, or
if the host is restarted
- *
- * @param xmlDesc XML description for new pool
- * @param flags future flags, use 0 for now
- * @return StoragePool object
- * @throws LibvirtException
- */
- public StoragePool storagePoolCreateXML(String xmlDesc, int flags)
- throws LibvirtException {
- StoragePoolPointer ptr = libvirt.virStoragePoolCreateXML(VCP, xmlDesc, flags) ;
- processError() ;
- return new StoragePool(this, ptr) ;
- }
-
-
- /**
- * Define a new inactive storage pool based on its XML description.
- * The pool is persistent, until explicitly undefined.
- *
- * @param xml XML description for new pool
- * @param flags flags future flags, use 0 for now
- * @return StoragePool object
- * @throws LibvirtException
- */
- public StoragePool storagePoolDefineXML(String xml, int flags)
- throws LibvirtException {
- StoragePoolPointer ptr = libvirt.virStoragePoolDefineXML(VCP, xml, flags) ;
- processError() ;
- return new StoragePool(this, ptr) ;
- }
-
-
- /**
- * Fetch a storage pool based on its unique name
- *
- * @param name name of pool to fetch
- * @return StoragePool object
- * @throws LibvirtException
- */
- public StoragePool storagePoolLookupByName(String name)
- throws LibvirtException {
- StoragePoolPointer ptr = libvirt.virStoragePoolLookupByName(VCP, name) ;
- processError() ;
- return new StoragePool(this, ptr) ;
- }
-
-
- /**
- * Fetch a storage pool based on its globally unique id
- *
- * @param UUID globally unique id of pool to fetch
- * @return a new network object
- * @throws LibvirtException
- */
- public StoragePool storagePoolLookupByUUID(int[] UUID)
- throws LibvirtException {
- String uuidString = Connect.createUUIDString(UUID) ;
- StoragePool returnValue = null ;
- StoragePoolPointer ptr = libvirt.virStoragePoolLookupByUUID(VCP, uuidString) ;
- processError() ;
- if (ptr != null) {
- returnValue = new StoragePool(this, ptr) ;
- }
- return returnValue ;
- }
-
-
- /**
- * Fetch a storage pool based on its globally unique id
- *
- * @param UUID globally unique id of pool to fetch
- * @return VirStoragePool object
- * @throws LibvirtException
- */
- public StoragePool storagePoolLookupByUUIDString(String UUID)
- throws LibvirtException {
- StoragePool returnValue = null ;
- StoragePoolPointer ptr = libvirt.virStoragePoolLookupByUUIDString(VCP, UUID) ;
- processError() ;
- if (ptr != null) {
- returnValue = new StoragePool(this, ptr) ;
- }
- return returnValue ;
- }
-
-
- /**
- * Fetch a a storage volume based on its globally unique key
- *
- * @param key globally unique key
- * @return a storage volume
- */
- public StorageVol storageVolLookupByKey(String key)
- throws LibvirtException {
- StorageVolPointer sPtr = libvirt.virStorageVolLookupByKey(VCP, key) ;
- processError() ;
- return new StorageVol(this, sPtr) ;
- }
-
-
- /**
- * Fetch a storage volume based on its locally (host) unique path
- *
- * @param path locally unique path
- * @return a storage volume
- */
- public StorageVol storageVolLookupByPath(String path)
- throws LibvirtException {
- StorageVolPointer sPtr = libvirt.virStorageVolLookupByPath(VCP, path) ;
- processError() ;
- return new StorageVol(this, sPtr) ;
- }
-
-
- /**
- * call the error handling logic. Should be called after
- * every libvirt call
- * @throws LibvirtException
- */
- protected void processError() throws LibvirtException {
- ErrorHandler.processError(libvirt, VCP) ;
- }
-
-
- /**
- * Helper function to convert bytes into ints for the
- * UUID calls
- */
- public static int[] convertUUIDBytes(byte bytes[]) {
- int[] returnValue = new int[Libvirt.VIR_UUID_BUFLEN] ;
- for (int x = 0 ; x < Libvirt.VIR_UUID_BUFLEN ; x++) {
- returnValue[x] = (int) bytes[x] ;
- }
- return returnValue ;
- }
-
-
- /**
- * Helper function to convert UUIDs into a stirng
- * for the UUID calls
- */
- public static String createUUIDString(int[] UUID) {
- StringBuilder uuidString = new StringBuilder() ;
- for (int i : UUID) {
- uuidString.append(i) ;
- }
- return uuidString.toString() ;
- }
-
-}
diff --git a/src/org/libvirt/ConnectAuth.java b/src/org/libvirt/ConnectAuth.java
deleted file mode 100644
index e29f010..0000000
--- a/src/org/libvirt/ConnectAuth.java
+++ /dev/null
@@ -1,153 +0,0 @@
-package org.libvirt;
-
-import org.libvirt.jna.Libvirt;
-import org.libvirt.jna.virConnectCredential;
-
-import com.sun.jna.Pointer;
-
-/**
- * We diverge from the C implementation
- * There is no explicit cbdata field, you should just add any extra data to the child
class's instance.
- *
- * @author stoty
- *
- */
-public abstract class ConnectAuth implements Libvirt.VirConnectAuthCallback {
- /**
- * @author stoty
- *
- */
- public static enum CredentialType {
- // This is off by one, but we don't care, because we can't convert java Enum to
C enum in a sane way anyway
- /**
- * Identity to act as
- */
- VIR_CRED_USERNAME,
- /**
- * Identify to authorize as
- */
- VIR_CRED_AUTHNAME,
- /**
- * RFC 1766 languages, comma separated
- */
- VIR_CRED_LANGUAGE,
- /**
- * client supplies a nonce
- */
- VIR_CRED_CNONCE,
- /**
- * Passphrase secret
- */
- VIR_CRED_PASSPHRASE,
- /**
- * Challenge response
- */
- VIR_CRED_ECHOPROMPT,
- /**
- * Challenge response
- */
- VIR_CRED_NOECHOPROMPT,
- /**
- * Authentication realm
- */
- VIR_CRED_REALM,
- /**
- * Externally managed credential More may be added - expect the unexpected
- */
- VIR_CRED_EXTERNAL;
-
- /**
- * Maps the java CredentialType Enum to libvirt's integer constant
- *
- * @return The integer equivalent
- */
- @SuppressWarnings("all")
- private int mapToInt(){
- switch(this){
- case VIR_CRED_USERNAME: return 1;
- case VIR_CRED_AUTHNAME: return 2;
- case VIR_CRED_LANGUAGE: return 3;
- case VIR_CRED_CNONCE: return 4;
- case VIR_CRED_PASSPHRASE: return 5;
- case VIR_CRED_ECHOPROMPT: return 6;
- case VIR_CRED_NOECHOPROMPT: return 7;
- case VIR_CRED_REALM: return 8;
- case VIR_CRED_EXTERNAL: return 9;
- }
- //We may never reach this point
- assert(false);
- return 0;
- }
- }
- public class Credential {
-
-
- /**
- * One of virConnectCredentialType constants
- */
- public CredentialType type;
- /**
- * Prompt to show to user
- */
- public String prompt;
- /**
- * Additional challenge to show
- */
- public String challenge;
- /**
- * Optional default result
- */
- public String defresult;
- /**
- * Result to be filled with user response (or defresult)
- */
- public String result;
-
- /**
- * Convenience constructor to be called from the JNI side
- *
- * @param type
- * @param prompt
- * @param challenge
- * @param defresult
- */
- Credential(int type, String prompt, String challenge, String defresult){
- switch(type){
- case 1: this.type=CredentialType.VIR_CRED_USERNAME; break;
- case 2: this.type=CredentialType.VIR_CRED_AUTHNAME; break;
- case 3: this.type=CredentialType.VIR_CRED_LANGUAGE; break;
- case 4: this.type=CredentialType.VIR_CRED_CNONCE; break;
- case 5: this.type=CredentialType.VIR_CRED_PASSPHRASE; break;
- case 6: this.type=CredentialType.VIR_CRED_ECHOPROMPT; break;
- case 7: this.type=CredentialType.VIR_CRED_NOECHOPROMPT; break;
- case 8: this.type=CredentialType.VIR_CRED_REALM; break;
- case 9: this.type=CredentialType.VIR_CRED_EXTERNAL; break;
- default: assert(false);
- }
- this.prompt = prompt;
- this.challenge = challenge;
- this.defresult = defresult;
- }
-
-
- }
-
-
- public int authCallback(virConnectCredential cred, int ncred, Pointer cbdata) {
- System.out.println("HELLO!!!!!!!!!!!!!!!!!!!!!!!!!") ;
- return 1 ;
- }
-
- /**
- * List of supported ConnectCredential.CredentialType values
- */
- public CredentialType credType[];
-
- /**
- * The callback function that fills the credentials in
- * @param cred the array of credentials passed by libvirt
- * @return 0 if the defresult field contains a vailde response, -1 otherwise
- */
- public abstract int callback(Credential[] cred);
-
-}
diff --git a/src/org/libvirt/ConnectAuthDefault.java
b/src/org/libvirt/ConnectAuthDefault.java
deleted file mode 100644
index 0f979e1..0000000
--- a/src/org/libvirt/ConnectAuthDefault.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package org.libvirt;
-
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-
-/**
- * @author stoty
- * Implements virConnectAuthPtrDefault functionality from libvirt.c without the external
method support
- * It's not officially a part of the libvirt API, but provided here for completeness,
testing, and as an example
- */
-public final class ConnectAuthDefault extends ConnectAuth {
-
- {
- credType= new CredentialType[] {
- CredentialType.VIR_CRED_AUTHNAME,
- CredentialType.VIR_CRED_ECHOPROMPT,
- CredentialType.VIR_CRED_REALM,
- CredentialType.VIR_CRED_PASSPHRASE,
- CredentialType.VIR_CRED_NOECHOPROMPT
- };
- }
-
- @Override
- public int callback(Credential[] cred) {
- BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
- try{
- for(Credential c: cred){
- String response="";
- switch(c.type){
- case VIR_CRED_USERNAME:
- case VIR_CRED_AUTHNAME:
- case VIR_CRED_ECHOPROMPT:
- case VIR_CRED_REALM:
- System.out.println(c.prompt);
- response= in.readLine();
- break;
- case VIR_CRED_PASSPHRASE:
- case VIR_CRED_NOECHOPROMPT:
- System.out.println(c.prompt);
- System.out.println("WARNING: THE ENTERED PASSWORD WILL NOT BE MASKED!");
- response= in.readLine();
- break;
- }
- if(response.equals("") && !c.defresult.equals("")){
- c.result=c.defresult;
- } else {
- c.result=response;
- }
- if(c.result.equals("")){
- return -1;
- }
- }
- } catch (Exception e) {
- return -1;
- }
- return 0;
- }
-
-}
diff --git a/src/org/libvirt/Domain.java b/src/org/libvirt/Domain.java
deleted file mode 100644
index 6f57b96..0000000
--- a/src/org/libvirt/Domain.java
+++ /dev/null
@@ -1,655 +0,0 @@
-package org.libvirt;
-
-import org.libvirt.jna.DomainPointer;
-import org.libvirt.jna.Libvirt;
-import org.libvirt.jna.virDomainBlockStats;
-import org.libvirt.jna.virDomainInfo;
-import org.libvirt.jna.virDomainInterfaceStats;
-import org.libvirt.jna.virSchedParameter;
-import org.libvirt.jna.virVcpuInfo;
-
-import com.sun.jna.Native;
-import com.sun.jna.NativeLong;
-import com.sun.jna.Pointer;
-import com.sun.jna.ptr.IntByReference;
-
-public class Domain {
-
- static final class CreateFlags{
- static final int VIR_DOMAIN_NONE = 0;
- }
-
- static final class MigrateFlags{
- /**
- * live migration
- */
- static final int VIR_MIGRATE_LIVE = 1;
- }
-
- static final class XMLFlags{
- /**
- * dump security sensitive information too
- */
- static final int VIR_DOMAIN_XML_SECURE = 1;
- /**
- * dump inactive domain information
- */
- static final int VIR_DOMAIN_XML_INACTIVE = 2;
- }
-
- /**
- * the native virDomainPtr.
- */
- private DomainPointer VDP;
-
- /**
- * The Connect Object that represents the Hypervisor of this Domain
- */
- private Connect virConnect;
-
- /**
- * The libvirt connection from the hypervisor
- */
- protected Libvirt libvirt ;
-
-
- /**
- * Constructs a Domain object from a known native virDomainPtr, and a Connect object.
- * For use when native libvirt returns a virConnectPtr, i.e. error handling.
- *
- * @param virConnect the Domain's hypervisor
- * @param VDP the native virDomainPtr
- */
- Domain(Connect virConnect, DomainPointer VDP){
- this.virConnect = virConnect;
- this.VDP = VDP;
- this.libvirt = virConnect.libvirt ;
- }
-
- /**
- * Provides an XML description of the domain.
- * The description may be reused later to relaunch the domain with createLinux().
- *
- * @param flags not used
- * @return the XML description String
- * @throws LibvirtException
- * @see <a
href="http://libvirt.org/format.html#Normal1" >The XML
Description format </a>
- */
- public String getXMLDesc(int flags) throws LibvirtException{
- String returnValue = libvirt.virDomainGetXMLDesc(VDP, flags) ;
- processError() ;
- return returnValue ;
- }
-
-
- /**
- * Provides a boolean value indicating whether the network is configured to be
automatically started when the host machine boots.
- *
- * @return the result
- * @throws LibvirtException
- */
- public boolean getAutostart() throws LibvirtException{
- IntByReference autoStart = new IntByReference() ;
- libvirt.virDomainGetAutostart(VDP, autoStart) ;
- processError() ;
- return autoStart.getValue() != 0 ? true : false ;
- }
-
-
- /**
- * Configures the network to be automatically started when the host machine boots.
- *
- * @param autostart
- * @throws LibvirtException
- */
- public void setAutostart(boolean autostart) throws LibvirtException{
- int autoValue = autostart ? 1 : 0 ;
- libvirt.virDomainSetAutostart(VDP, autoValue) ;
- processError() ;
- }
-
-
- /**
- * Provides the connection object associated with a domain.
- *
- * @return the Connect object
- */
- public Connect getConnect(){
- return virConnect;
- }
-
- /**
- * Gets the hypervisor ID number for the domain
- *
- * @return the hypervisor ID
- * @throws LibvirtException
- */
- public int getID() throws LibvirtException{
- int returnValue = libvirt.virDomainGetID(VDP);
- processError() ;
- return returnValue ;
- }
-
-
-
- /**
- * Extract information about a domain.
- * Note that if the connection used to get the domain is limited only a partial set of
the information can be extracted.
- *
- * @return a DomainInfo object describing this domain
- * @throws LibvirtException
- */
- public DomainInfo getInfo() throws LibvirtException{
- DomainInfo returnValue = null ;
- virDomainInfo vInfo = new virDomainInfo() ;
- int success = libvirt.virDomainGetInfo(VDP, vInfo) ;
- processError() ;
- if (success == 0) {
- returnValue = new DomainInfo(vInfo) ;
- }
- return returnValue ;
- }
-
- /**
- * Retrieve the maximum amount of physical memory allocated to a domain.
- *
- * @return the memory in kilobytes
- * @throws LibvirtException
- */
- public long getMaxMemory() throws LibvirtException{
- NativeLong returnValue = libvirt.virDomainGetMaxMemory(VDP) ;
- processError() ;
- return returnValue.longValue() ;
- }
-
-
- /**
- * * Dynamically change the maximum amount of physical memory allocated to a domain.
- * This function requires priviledged access to the hypervisor.
- *
- * @param memory the amount memory in kilobytes
- * @throws LibvirtException
- */
- public void setMaxMemory(long memory) throws LibvirtException{
- libvirt.virDomainSetMaxMemory(VDP, new NativeLong(memory)) ;
- processError() ;
- }
-
-
- /**
- * Provides the maximum number of virtual CPUs supported for the guest VM.
- * If the guest is inactive, this is basically the same as virConnectGetMaxVcpus.
- * If the guest is running this will reflect the maximum number of virtual CPUs the
guest was booted with.
- *
- * @return the number of VCPUs
- * @throws LibvirtException
- */
- public int getMaxVcpus() throws LibvirtException{
- int returnValue = libvirt.virDomainGetMaxVcpus(VDP) ;
- processError() ;
- return returnValue ;
- }
-
-
- /**
- * Gets the public name for this domain
- *
- * @return the name
- * @throws LibvirtException
- */
- public String getName() throws LibvirtException{
- String returnValue = libvirt.virDomainGetName(VDP);
- processError() ;
- return returnValue ;
- }
-
-
- /**
- * Gets the type of domain operation system.
- *
- * @return the type
- * @throws LibvirtException
- */
- public String getOSType() throws LibvirtException{
- String returnValue = libvirt.virDomainGetOSType(VDP);
- processError() ;
- return returnValue ;
- }
-
-
- /**
- * Gets the scheduler parameters.
- *
- * @return an array of SchedParameter objects
- * @throws LibvirtException
- */
- public SchedParameter[] getSchedulerParameters() throws LibvirtException{
- IntByReference nParams = new IntByReference() ;
- SchedParameter[] returnValue = new SchedParameter[0] ;
- String scheduler = libvirt.virDomainGetSchedulerType(VDP, nParams) ;
- processError() ;
- if (scheduler != null) {
- virSchedParameter[] nativeParams = new virSchedParameter[nParams.getValue()] ;
- returnValue = new SchedParameter[nParams.getValue()] ;
- libvirt.virDomainGetSchedulerParameters(VDP, nativeParams, nParams) ;
- processError() ;
- for (int x = 0 ; x < nParams.getValue() ; x++ ) {
- returnValue[x] = SchedParameter.create(nativeParams[x]) ;
- }
- }
-
- return returnValue ;
- }
-
-
- /**
- * Changes the scheduler parameters
- *
- * @param params an array of SchedParameter objects to be changed
- * @throws LibvirtException
- */
- public void setSchedulerParameters(SchedParameter[] params) throws LibvirtException{
- IntByReference nParams = new IntByReference() ;
- nParams.setValue(params.length) ;
- virSchedParameter[] input = new virSchedParameter[params.length] ;
- for (int x = 0 ; x < params.length ; x++) {
- input[x] = SchedParameter.toNative(params[x]) ;
- }
- libvirt.virDomainSetSchedulerParameters(VDP, input, nParams) ;
- processError() ;
- }
-
-
- //getSchedulerType
- //We don't expose the nparams return value, it's only needed for the
SchedulerParameters allocations,
- //but we handle that in getSchedulerParameters internally.
- /**
- * Gets the scheduler type.
- *
- * @return the type of the scheduler
- * @throws LibvirtException
- */
- public String[] getSchedulerType() throws LibvirtException{
- IntByReference nParams = new IntByReference() ;
- String returnValue = libvirt.virDomainGetSchedulerType(VDP, nParams) ;
- processError() ;
- String[] array = new String[1] ;
- array[0] = returnValue ;
- return array;
- }
-
-
- /**
- * Get the UUID for this domain.
- *
- * @return the UUID as an unpacked int array
- * @throws LibvirtException
- * @see <a
href="http://www.ietf.org/rfc/rfc4122.txt">rfc4122</a>
- */
- public int[] getUUID() throws LibvirtException{
- byte[] bytes = new byte[Libvirt.VIR_UUID_BUFLEN] ;
- int success = libvirt.virDomainGetUUID(VDP, bytes) ;
- processError() ;
- int[] returnValue = new int[0] ;
- if (success == 0) {
- returnValue = Connect.convertUUIDBytes(bytes) ;
- }
- return returnValue ;
- }
-
-
- /**
- * Gets the UUID for this domain as string.
- *
- * @return the UUID in canonical String format
- * @throws LibvirtException
- * @see <a
href="http://www.ietf.org/rfc/rfc4122.txt">rfc4122</a>
- */
- public String getUUIDString() throws LibvirtException{
- byte[] bytes = new byte[Libvirt.VIR_UUID_STRING_BUFLEN] ;
- int success = libvirt.virDomainGetUUIDString(VDP, bytes) ;
- processError() ;
- String returnValue = null ;
- if (success == 0) {
- returnValue = Native.toString(bytes) ;
- }
- return returnValue ;
- }
-
- /**
- * Extracts information about virtual CPUs of this domain
- *
- * @return an array of VcpuInfo object describing the VCPUs
- * @throws LibvirtException
- */
- public VcpuInfo[] getVcpusInfo() throws LibvirtException{
- int cpuCount = this.getMaxVcpus() ;
- VcpuInfo[] returnValue = new VcpuInfo[cpuCount] ;
- virVcpuInfo[] infos = new virVcpuInfo[cpuCount] ;
- libvirt.virDomainGetVcpus(VDP, infos, cpuCount, null, 0) ;
- processError() ;
- for (int x = 0 ; x < cpuCount ; x++) {
- returnValue[x] = new VcpuInfo(infos[x]) ;
- }
- return returnValue ;
- }
-
-
-
- /**
- * Returns the cpumaps for this domain
- * Only the lower 8 bits of each int in the array contain information.
- *
- * @return a bitmap of real CPUs for all vcpus of this domain
- * @throws LibvirtException
- */
- public int[] getVcpusCpuMaps() throws LibvirtException{
- int[] returnValue = new int[0] ;
- int cpuCount = this.getMaxVcpus() ;
-
- if (cpuCount >0) {
- NodeInfo nodeInfo = virConnect.nodeInfo() ;
- int maplength = cpuMapLength(nodeInfo.maxCpus()) ;
- virVcpuInfo[] infos = new virVcpuInfo[cpuCount] ;
- returnValue = new int[cpuCount*maplength] ;
- byte[] cpumaps = new byte[cpuCount*maplength] ;
- libvirt.virDomainGetVcpus(VDP, infos, cpuCount, cpumaps, maplength) ;
- processError() ;
- for (int x =0 ; x < cpuCount*maplength ; x++) {
- returnValue[x] = (int) cpumaps[x] ;
- }
- }
- return returnValue ;
- }
-
-
- /**
- * Dynamically changes the real CPUs which can be allocated to a virtual CPU.
- * This function requires priviledged access to the hypervisor.
- *
- * @param vcpu virtual cpu number
- * @param cpumap bit map of real CPUs represented by the the lower 8 bits of each int in
the array. Each bit set to 1 means that corresponding CPU is usable. Bytes are stored in
little-endian order: CPU0-7, 8-15... In each byte, lowest CPU number is least significant
bit.
- * @throws LibvirtException
- */
- public void pinVcpu(int vcpu, int[] cpumap) throws LibvirtException{
- byte[] packedMap = new byte[cpumap.length] ;
- for (int x = 0 ; x < cpumap.length ; x++) {
- packedMap[x] = (byte) cpumap[x] ;
- }
- libvirt.virDomainPinVcpu(VDP, vcpu, packedMap, cpumap.length) ;
- processError() ;
- }
-
-
- /**
- * Dynamically changes the number of virtual CPUs used by this domain.
- * Note that this call may fail if the underlying virtualization hypervisor does not
support it or if growing the number is arbitrary limited.
- * This function requires priviledged access to the hypervisor.
- *
- * @param nvcpus the new number of virtual CPUs for this domain
- * @throws LibvirtException
- */
- public void setVcpus(int nvcpus) throws LibvirtException{
- libvirt.virDomainSetVcpus(VDP, nvcpus) ;
- processError() ;
- }
-
-
- /**
- * Creates a virtual device attachment to backend.
- *
- * @param xmlDesc XML description of one device
- * @throws LibvirtException
- */
- public void attachDevice(String xmlDesc) throws LibvirtException{
- libvirt.virDomainAttachDevice(VDP, xmlDesc);
- processError() ;
- }
-
-
- /**
- * Destroys a virtual device attachment to backend.
- *
- * @param xmlDesc XML description of one device
- * @throws LibvirtException
- */
- public void detachDevice(String xmlDesc) throws LibvirtException{
- libvirt.virDomainDetachDevice(VDP, xmlDesc);
- processError() ;
- }
-
-
-
- /**
- * Returns block device (disk) stats for block devices attached to this domain.
- * The path parameter is the name of the block device.
- * Get this by calling virDomainGetXMLDesc and finding the <target
dev='...'> attribute within //domain/devices/disk.
- * (For example, "xvda"). Domains may have more than one block device.
- * To get stats for each you should make multiple calls to this function.
- * Individual fields within the DomainBlockStats object may be returned as -1, which
indicates that the hypervisor does not support that particular statistic.
- *
- * @param path path to the block device
- * @return the statistics in a DomainBlockStats object
- * @throws LibvirtException
- */
- public DomainBlockStats blockStats(String path) throws LibvirtException{
- virDomainBlockStats stats = new virDomainBlockStats() ;
- libvirt.virDomainBlockStats(VDP, path, stats, stats.size()) ;
- processError() ;
- return new DomainBlockStats(stats) ;
- }
-
-
- /**
- * Returns network interface stats for interfaces attached to this domain.
- * The path parameter is the name of the network interface.
- * Domains may have more than network interface.
- * To get stats for each you should make multiple calls to this function.
- * Individual fields within the DomainInterfaceStats object may be returned as -1, which
indicates that the hypervisor does not support that particular statistic.
- *
- * @param path path to the interface
- * @return the statistics in a DomainInterfaceStats object
- * @throws LibvirtException
- */
- public DomainInterfaceStats interfaceStats(String path) throws LibvirtException{
- virDomainInterfaceStats stats = new virDomainInterfaceStats() ;
- libvirt.virDomainInterfaceStats(VDP, path, stats, stats.size()) ;
- processError() ;
- return new DomainInterfaceStats(stats) ;
- }
-
-
- /**
- * Dumps the core of this domain on a given file for analysis.
- * Note that for remote Xen Daemon the file path will be interpreted in the remote
host.
- *
- * @param to path for the core file
- * @param flags extra flags, currently unused
- * @throws LibvirtException
- */
- public void coreDump(String to, int flags) throws LibvirtException{
- libvirt.virDomainCoreDump(VDP, to, flags) ;
- processError() ;
- }
-
-
- /**
- * Launches this defined domain.
- * If the call succeed the domain moves from the defined to the running domains pools.
- *
- * @throws LibvirtException
- */
- public void create() throws LibvirtException{
- libvirt.virDomainCreate(VDP);
- processError() ;
- }
-
-
- /**
- * Destroys this domain object.
- * The running instance is shutdown if not down already and all resources used by it are
given back to the hypervisor.
- * The data structure is freed and should not be used thereafter if the call does not
return an error.
- * This function may requires priviledged access
- *
- * @throws LibvirtException
- */
- public void destroy() throws LibvirtException{
- libvirt.virDomainDestroy(VDP);
- processError() ;
- }
-
-
- /**
- * Frees this domain object.
- * The running instance is kept alive.
- * The data structure is freed and should not be used thereafter.
- *
- * @throws LibvirtException
- */
- public void free() throws LibvirtException{
- libvirt.virDomainFree(VDP);
- processError() ;
- VDP=null ;
- }
-
-
-
- /**
- * Migrate this domain object from its current host to the destination host given by
dconn (a connection to the destination host).
- * Flags may be one of more of the following: Domain.VIR_MIGRATE_LIVE Attempt a live
migration.
- * If a hypervisor supports renaming domains during migration, then you may set the
dname parameter to the new name (otherwise it keeps the same name).
- * If this is not supported by the hypervisor, dname must be NULL or else you will get
an error.
- * Since typically the two hypervisors connect directly to each other in order to
perform the migration, you may need to specify a path from the source to the destination.
- * This is the purpose of the uri parameter.
- * If uri is NULL, then libvirt will try to find the best method.
- * Uri may specify the hostname or IP address of the destination host as seen from the
source.
- * Or uri may be a URI giving transport, hostname, user, port, etc. in the usual form.
- * Refer to driver documentation for the particular URIs supported.
- * The maximum bandwidth (in Mbps) that will be used to do migration can be specified
with the bandwidth parameter.
- * If set to 0, libvirt will choose a suitable default.
- * Some hypervisors do not support this feature and will return an error if bandwidth is
not 0.
- * To see which features are supported by the current hypervisor, see
Connect.getCapabilities,
- * /capabilities/host/migration_features.
- * There are many limitations on migration imposed by the underlying technology - for
example it may not be possible to migrate between different processors even with the same
architecture, or between different types of hypervisor.
- *
- * @param dconn destination host (a Connect object)
- * @param flags flags
- * @param dname (optional) rename domain to this at destination
- * @param uri (optional) dest hostname/URI as seen from the source host
- * @param bandwidth optional) specify migration bandwidth limit in Mbps
- * @return the new domain object if the migration was successful, or NULL in case of
error. Note that the new domain object exists in the scope of the destination connection
(dconn).
- * @throws LibvirtException
- */
- public Domain migrate(Connect dconn, long flags, String dname, String uri, long
bandwidth) throws LibvirtException{
- DomainPointer newPtr = libvirt.virDomainMigrate(VDP, dconn.VCP, new
NativeLong(flags), dname, uri, new NativeLong(bandwidth)) ;
- processError() ;
- return new Domain(dconn, newPtr) ;
- }
-
-
- /**
- * Reboot this domain, the domain object is still usable there after but the domain OS
is being stopped for a restart.
- * Note that the guest OS may ignore the request.
- *
- * @param flags extra flags for the reboot operation, not used yet
- * @throws LibvirtException
- */
- public void reboot(int flags) throws LibvirtException{
- libvirt.virDomainReboot(VDP, flags);
- processError() ;
- }
-
-
- /**
- * Suspends this active domain, the process is frozen without further access to CPU
resources and I/O but the memory used by the domain at the hypervisor level will stay
allocated.
- * Use Domain.resume() to reactivate the domain. This function requires priviledged
access.
- *
- * @throws LibvirtException
- */
- public void suspend() throws LibvirtException{
- libvirt.virDomainSuspend(VDP);
- processError() ;
- }
-
-
- /**
- * Resume this suspended domain, the process is restarted from the state where it was
frozen by calling virSuspendDomain().
- * This function may requires privileged access
- *
- * @throws LibvirtException
- */
- public void resume() throws LibvirtException{
- libvirt.virDomainResume(VDP);
- processError() ;
- }
-
-
- /**
- * Suspends this domain and saves its memory contents to a file on disk.
- * After the call, if successful, the domain is not listed as running anymore (this may
be a problem).
- * Use Connect.virDomainRestore() to restore a domain after saving.
- *
- * @param to path for the output file
- * @throws LibvirtException
- */
- public void save(String to) throws LibvirtException{
- libvirt.virDomainSave(VDP, to);
- processError() ;
- }
-
-
- /**
- * Shuts down this domain, the domain object is still usable there after but the domain
OS is being stopped.
- * Note that the guest OS may ignore the request.
- * TODO: should we add an option for reboot, knowing it may not be doable in the general
case ?
- *
- * @throws LibvirtException
- */
- public void shutdown() throws LibvirtException{
- libvirt.virDomainShutdown(VDP);
- processError() ;
- }
-
-
- /**
- * undefines this domain but does not stop it if it is running
- *
- * @throws LibvirtException
- */
- public void undefine() throws LibvirtException{
- libvirt.virDomainUndefine(VDP);
- processError() ;
- }
-
-
- /**
- * Dynamically changes the target amount of physical memory allocated to this domain.
- * This function may requires priviledged access to the hypervisor.
- *
- * @param memory in kilobytes
- * @throws LibvirtException
- */
- public void setMemory(long memory) throws LibvirtException{
- libvirt.virDomainSetMemory(VDP, new NativeLong(memory)) ;
- processError() ;
- }
-
- /**
- * It returns the length (in bytes) required to store the complete
- * CPU map between a single virtual & all physical CPUs of a domain.
- *
- */
- public int cpuMapLength(int maxCpus) {
- return (((maxCpus)+7)/8) ;
- }
-
- /**
- * Error handling logic to throw errors. Must be called after every libvirt
- * call.
- */
- protected void processError() throws LibvirtException {
- virConnect.processError() ;
- }
-
-
-}
diff --git a/src/org/libvirt/DomainBlockStats.java
b/src/org/libvirt/DomainBlockStats.java
deleted file mode 100644
index b48c066..0000000
--- a/src/org/libvirt/DomainBlockStats.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.libvirt;
-
-import org.libvirt.jna.virDomainBlockStats;
-
-/**
- * This class holds the counters for block device statistics.
- *
- * @author stoty
- * @see Domain#blockStats
- */
-public class DomainBlockStats {
- public long rd_req;
- public long rd_bytes;
- public long wr_req;
- public long wr_bytes;
- public long errs;
-
- public DomainBlockStats() {
- }
-
- public DomainBlockStats(virDomainBlockStats vStats) {
- this.rd_req = vStats.rd_req ;
- this.rd_bytes = vStats.rd_bytes ;
- this.wr_req = vStats.wr_req ;
- this.wr_bytes = vStats.wr_bytes ;
- this.errs = vStats.errs ;
- }
-}
diff --git a/src/org/libvirt/DomainInfo.java b/src/org/libvirt/DomainInfo.java
deleted file mode 100644
index e6a03f8..0000000
--- a/src/org/libvirt/DomainInfo.java
+++ /dev/null
@@ -1,89 +0,0 @@
-package org.libvirt;
-
-import org.libvirt.jna.virDomainInfo;
-
-/**
- * This object is returned by Domain.getInfo()
- *
- * @author stoty
- *
- */
-public class DomainInfo {
- /**
- * the running state, one of virDomainFlag
- */
- public DomainState state;
- /**
- * the maximum memory in KBytes allowed
- */
- public long maxMem;
- /**
- * the memory in KBytes used by the domain
- */
- public long memory;
- /**
- * the number of virtual CPUs for the domain
- */
- public int nrVirtCpu;
- /**
- * the CPU time used in nanoseconds
- */
- public long cpuTime;
-
- /**
- * @author stoty
- *
- */
- public static enum DomainState {
- /**
- * no state
- */
- VIR_DOMAIN_NOSTATE,
- /**
- * the domain is running
- */
- VIR_DOMAIN_RUNNING,
- /**
- * the domain is blocked on resource
- */
- VIR_DOMAIN_BLOCKED,
- /**
- * the domain is paused by user
- */
- VIR_DOMAIN_PAUSED,
- /**
- * the domain is being shut down
- */
- VIR_DOMAIN_SHUTDOWN,
- /**
- * the domain is shut off
- */
- VIR_DOMAIN_SHUTOFF,
- /**
- * the domain is crashed
- */
- VIR_DOMAIN_CRASHED
- }
-
- public DomainInfo() {
-
- }
-
- public DomainInfo(virDomainInfo info) {
- this.cpuTime = info.cpuTime ;
- this.maxMem = info.maxMem.longValue() ;
- this.memory = info.memory.longValue() ;
- this.nrVirtCpu = info.nrVirtCpu ;
- this.state = DomainState.values()[info.state] ;
- }
-
- public String toString(){
- StringBuffer result = new StringBuffer("");
- result.append("state:" + state + "\n");
- result.append("maxMem:" + maxMem + "\n");
- result.append("memory:" + memory + "\n");
- result.append("nrVirtCpu:" + nrVirtCpu + "\n");
- result.append("cpuTime:" + cpuTime + "\n");
- return result.toString();
- }
-}
diff --git a/src/org/libvirt/DomainInterfaceStats.java
b/src/org/libvirt/DomainInterfaceStats.java
deleted file mode 100644
index b60b628..0000000
--- a/src/org/libvirt/DomainInterfaceStats.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package org.libvirt;
-
-import org.libvirt.jna.virDomainInterfaceStats;
-
-
-/**
- * The Domain.interfaceStats method returns th network counters in this object
- *
- * @author stoty
- *
- */
-public class DomainInterfaceStats {
- public long rx_bytes;
- public long rx_packets;
- public long rx_errs;
- public long rx_drop;
- public long tx_bytes;
- public long tx_packets;
- public long tx_errs;
- public long tx_drop;
-
- public DomainInterfaceStats() {
-
- }
-
- public DomainInterfaceStats(virDomainInterfaceStats vStats) {
- this.rx_bytes = vStats.rx_bytes ;
- this.rx_packets = vStats.rx_packets ;
- this.rx_errs = vStats.rx_errs ;
- this.rx_drop = vStats.rx_drop ;
- this.tx_bytes = vStats.tx_bytes ;
- this.tx_packets = vStats.tx_packets ;
- this.tx_errs = vStats.tx_errs ;
- this.tx_drop = vStats.tx_drop ;
- }
-}
diff --git a/src/org/libvirt/Error.java b/src/org/libvirt/Error.java
deleted file mode 100644
index 3ba8644..0000000
--- a/src/org/libvirt/Error.java
+++ /dev/null
@@ -1,473 +0,0 @@
-package org.libvirt;
-
-import java.io.Serializable;
-
-import org.libvirt.jna.virError;
-
-import com.sun.jna.Pointer;
-
-public class Error implements Serializable {
-
- public static enum ErrorDomain {
- VIR_FROM_NONE,
- /**
- * Error at Xen hypervisor layer
- */
- VIR_FROM_XEN,
- /**
- * Error at connection with xend daemon
- */
- VIR_FROM_XEND,
- /**
- * Error at connection with xen store
- */
- VIR_FROM_XENSTORE,
- /**
- * Error in the S-Epression code
- */
- VIR_FROM_SEXPR,
- /**
- * Error in the XML code
- */
- VIR_FROM_XML,
- /**
- * Error when operating on a domain
- */
- VIR_FROM_DOM,
- /**
- * Error in the XML-RPC code
- */
- VIR_FROM_RPC,
- /**
- * Error in the proxy code
- */
- VIR_FROM_PROXY,
- /**
- * Error in the configuration file handling
- */
- VIR_FROM_CONF,
- /**
- * Error at the QEMU daemon
- */
- VIR_FROM_QEMU,
- /**
- * Error when operating on a network
- */
- VIR_FROM_NET,
- /**
- * Error from test driver
- */
- VIR_FROM_TEST,
- /**
- * Error from remote driver
- */
- VIR_FROM_REMOTE,
- /**
- * Error from OpenVZ driver
- */
- VIR_FROM_OPENVZ,
- /**
- * Error at Xen XM layer
- */
- VIR_FROM_XENXM,
- /**
- * Error in the Linux Stats code
- */
- VIR_FROM_STATS_LINUX,
- /**
- * Error from Linux Container driver
- */
- VIR_FROM_LXC,
- /**
- * Error from storage driver
- */
- VIR_FROM_STORAGE
- }
-
- public static enum ErrorLevel {
- VIR_ERR_NONE,
- /**
- * A simple warning
- */
- VIR_ERR_WARNING,
- /**
- * An error
- */
- VIR_ERR_ERROR
- }
-
- public static enum ErrorNumber {
- VIR_ERR_OK,
- /**
- * internal error
- */
- VIR_ERR_INTERNAL_ERROR,
- /**
- * memory allocation failure
- */
- VIR_ERR_NO_MEMORY,
- /**
- * no support for this function
- */
- VIR_ERR_NO_SUPPORT,
- /**
- * could not resolve hostname
- */
- VIR_ERR_UNKNOWN_HOST,
- /**
- * can't connect to hypervisor
- */
- VIR_ERR_NO_CONNECT,
- /**
- * invalid connection object
- */
- VIR_ERR_INVALID_CONN,
- /**
- * invalid domain object
- */
- VIR_ERR_INVALID_DOMAIN,
- /**
- * invalid function argument
- */
- VIR_ERR_INVALID_ARG,
- /**
- * a command to hypervisor failed
- */
- VIR_ERR_OPERATION_FAILED,
- /**
- * a HTTP GET command to failed
- */
- VIR_ERR_GET_FAILED,
- /**
- * a HTTP POST command to failed
- */
- VIR_ERR_POST_FAILED,
- /**
- * unexpected HTTP error code
- */
- VIR_ERR_HTTP_ERROR,
- /**
- * failure to serialize an S-Expr
- */
- VIR_ERR_SEXPR_SERIAL,
- /**
- * could not open Xen hypervisor control
- */
- VIR_ERR_NO_XEN,
- /**
- * failure doing an hypervisor call
- */
- VIR_ERR_XEN_CALL,
- /**
- * unknown OS type
- */
- VIR_ERR_OS_TYPE,
- /**
- * missing kernel information
- */
- VIR_ERR_NO_KERNEL,
- /**
- * missing root device information
- */
- VIR_ERR_NO_ROOT,
- /**
- * missing source device information
- */
- VIR_ERR_NO_SOURCE,
- /**
- * missing target device information
- */
- VIR_ERR_NO_TARGET,
- /**
- * missing domain name information
- */
- VIR_ERR_NO_NAME,
- /**
- * missing domain OS information
- */
- VIR_ERR_NO_OS,
- /**
- * missing domain devices information
- */
- VIR_ERR_NO_DEVICE,
- /**
- * could not open Xen Store control
- */
- VIR_ERR_NO_XENSTORE,
- /**
- * too many drivers registered
- */
- VIR_ERR_DRIVER_FULL,
- /**
- * not supported by the drivers (DEPRECATED)
- */
- VIR_ERR_CALL_FAILED,
- /**
- * an XML description is not well formed or broken
- */
- VIR_ERR_XML_ERROR,
- /**
- * the domain already exist
- */
- VIR_ERR_DOM_EXIST,
- /**
- * operation forbidden on read-only connections
- */
- VIR_ERR_OPERATION_DENIED,
- /**
- * failed to open a conf file
- */
- VIR_ERR_OPEN_FAILED,
- /**
- * failed to read a conf file
- */
- VIR_ERR_READ_FAILED,
- /**
- * failed to parse a conf file
- */
- VIR_ERR_PARSE_FAILED,
- /**
- * failed to parse the syntax of a conf file
- */
- VIR_ERR_CONF_SYNTAX,
- /**
- * failed to write a conf file
- */
- VIR_ERR_WRITE_FAILED,
- /**
- * detail of an XML error
- */
- VIR_ERR_XML_DETAIL,
- /**
- * invalid network object
- */
- VIR_ERR_INVALID_NETWORK,
- /**
- * the network already exist
- */
- VIR_ERR_NETWORK_EXIST,
- /**
- * general system call failure
- */
- VIR_ERR_SYSTEM_ERROR,
- /**
- * some sort of RPC error
- */
- VIR_ERR_RPC,
- /**
- * error from a GNUTLS call
- */
- VIR_ERR_GNUTLS_ERROR,
- /**
- * failed to start network
- */
- VIR_WAR_NO_NETWORK,
- /**
- * omain not found or unexpectedly disappeared
- */
- VIR_ERR_NO_DOMAIN,
- /**
- * network not found
- */
- VIR_ERR_NO_NETWORK,
- /**
- * invalid MAC adress
- */
- VIR_ERR_INVALID_MAC,
- /**
- * authentication failed
- */
- VIR_ERR_AUTH_FAILED,
- /**
- * invalid storage pool object
- */
- VIR_ERR_INVALID_STORAGE_POOL,
- /**
- * invalid storage vol object
- */
- VIR_ERR_INVALID_STORAGE_VOL,
- /**
- * failed to start storage
- */
- VIR_WAR_NO_STORAGE,
- /**
- * storage pool not found
- */
- VIR_ERR_NO_STORAGE_POOL,
- /**
- * storage pool not found
- */
- VIR_ERR_NO_STORAGE_VOL
- }
-
- ErrorNumber code;
- ErrorDomain domain;
- String message;
- ErrorLevel level;
- Pointer VCP; /* Deprecated */
- Pointer VDP; /* Deprecated */
- String str1;
- String str2;
- String str3;
- int int1;
- int int2;
- Pointer VNP; /* Deprecated */
-
- public Error() {
-
- }
-
- public Error(virError vError) {
- code = ErrorNumber.values()[vError.code] ;
- domain = ErrorDomain.values()[vError.domain] ;
- level = ErrorLevel.values()[vError.level] ;
- message = vError.message ;
- str1 = vError.str1 ;
- str2 = vError.str2 ;
- str3 = vError.str3 ;
- int1 = vError.int1 ;
- int2 = vError.int2 ;
- VCP = vError.conn ;
- VDP = vError.dom ;
- VNP =
vError.net ;
- }
-
- /**
- * Gets he error code
- * @return a VirErroNumber
- */
- public ErrorNumber getCode() {
- return code;
- }
- /**
- * Tells What part of the library raised this error
- * @return a ErrorDomain
- */
- public ErrorDomain getDomain() {
- return domain;
- }
- /**
- * Returns human-readable informative error messag
- *
- * @return error message
- */
- public String getMessage() {
- return message;
- }
- /**
- * Tells how consequent is the error
- * @return a ErrorLevel
- */
- public ErrorLevel getLevel() {
- return level;
- }
- /**
- * @return extra string information
- */
- public String getStr1() {
- return str1;
- }
- /**
- * @return extra string information
- */
- public String getStr2() {
- return str2;
- }
- /**
- * @return extra string information
- */
- public String getStr3() {
- return str3;
- }
- /**
- * @return extra number information
- */
- public int getInt1() {
- return int1;
- }
- /**
- * @return extra number information
- */
- public int getInt2() {
- return int2;
- }
-
- /**
- * Does this error has a valid Connection object attached?
- * NOTE: deprecated, should return false
- *
- * @return false
- */
- public boolean hasConn(){
- return false;
- }
-
- /**
- * returns the Connection associated with the error, if available
- * Deprecated, always throw an exception now
- *
- * @return the Connect object
- * @throws ErrorException
- */
- public Connect getConn() throws ErrorException{
- throw new ErrorException("No Connect object available");
- }
-
- /**
- * Does this error has a valid Domain object attached?
- * NOTE: deprecated, should return false
- *
- * @return false
- */
- public boolean hasDom(){
- return false;
- }
-
- /**
- * returns the Domain associated with the error, if available
- *
- * @return Domain object
- * @throws ErrorException
- */
- public Domain getDom() throws ErrorException{
- throw new ErrorException("No Domain object available");
- }
-
- /**
- * Does this error has a valid Network object attached?
- * NOTE: deprecated, should return false
- *
- * @return false
- */
- public boolean hasNet(){
- return false;
- }
-
- /**
- * Returns the network associated with the error, if available
- *
- * @return Network object
- * @throws ErrorException
- */
- public Network getNet() throws ErrorException{
- throw new ErrorException("No Network object available");
- }
-
- public String toString(){
- StringBuffer output= new StringBuffer();
- output.append("level:" + level + "\n");
- output.append("code:" + code + "\n");
- output.append("domain:" + domain + "\n");
- output.append("hasConn:" + hasConn() + "\n");
- output.append("hasDom:" + hasDom() + "\n");
- output.append("hasNet:" + hasNet() + "\n");
- output.append("message:" + message + "\n");
- output.append("str1:" + str1 + "\n");
- output.append("str2:" + str2 + "\n");
- output.append("str3:" + str3 + "\n");
- output.append("int1:" + int1 + "\n");
- output.append("int2:" + int2 + "\n");
- return output.toString();
-
- }
-}
diff --git a/src/org/libvirt/ErrorException.java b/src/org/libvirt/ErrorException.java
deleted file mode 100644
index 40095fd..0000000
--- a/src/org/libvirt/ErrorException.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.libvirt;
-
-/**
- * This exception signals that a non-existing object was retrieved from the virError
object
- *
- * @author stoty
- *
- */
-public class ErrorException extends Exception {
- private static final long serialVersionUID = -4329050530233404971L;
- public ErrorException(String message) {
- super(message);
- }
-
-}
diff --git a/src/org/libvirt/ErrorHandler.java b/src/org/libvirt/ErrorHandler.java
deleted file mode 100644
index 2cc260a..0000000
--- a/src/org/libvirt/ErrorHandler.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package org.libvirt;
-
-import org.libvirt.jna.ConnectionPointer;
-import org.libvirt.jna.Libvirt;
-import org.libvirt.jna.virError;
-
-import com.sun.jna.Pointer;
-
-public class ErrorHandler
-{
-
- public static void processError(Libvirt libvirt) throws LibvirtException {
- virError vError = new virError() ;
- int errorCode = libvirt.virCopyLastError(vError) ;
- if (errorCode > 0) {
- Error error = new Error(vError) ;
- libvirt.virResetLastError() ;
- throw new LibvirtException(error) ;
- }
- }
-
- public static void processError(Libvirt libvirt, ConnectionPointer conn) throws
LibvirtException
- {
- virError vError = new virError() ;
- int errorCode = libvirt.virConnCopyLastError(conn, vError) ;
- if (errorCode > 0) {
- Error error = new Error(vError) ;
- libvirt.virConnResetLastError(conn) ;
- throw new LibvirtException(error) ;
- }
- }
-}
diff --git a/src/org/libvirt/LibvirtException.java
b/src/org/libvirt/LibvirtException.java
deleted file mode 100644
index 44769ff..0000000
--- a/src/org/libvirt/LibvirtException.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.libvirt;
-
-/**
- * This exception is thrown by all classes and methods of libvirt when the
- * underlying libvirt library indicates an error
- *
- * @author stoty
- * @see Error
- */
-public class LibvirtException extends Exception {
-
- private static final long serialVersionUID = 5566904363426773529L;
-
- Error virError;
-
- LibvirtException(Error virError) {
- super(virError.getMessage());
- this.virError = virError;
- }
-
- /**
- * Returns the underlying Error objects that contains details
- * about the cause of the exception
- *
- * @return the underlying Error object
- */
- public Error getError() {
- return virError;
- }
-
-}
diff --git a/src/org/libvirt/Network.java b/src/org/libvirt/Network.java
deleted file mode 100644
index 39afde2..0000000
--- a/src/org/libvirt/Network.java
+++ /dev/null
@@ -1,217 +0,0 @@
-package org.libvirt;
-
-import org.libvirt.jna.Libvirt;
-import org.libvirt.jna.NetworkPointer;
-
-import com.sun.jna.Native;
-import com.sun.jna.Pointer;
-import com.sun.jna.ptr.IntByReference;
-import com.sun.jna.ptr.PointerByReference;
-
-public class Network {
-
- /**
- * The native virNetworkPtr
- */
- protected NetworkPointer VNP;
-
- /**
- * The Connect Object that represents the Hypervisor of this Network
- */
- protected Connect virConnect;
-
- /**
- * The libvirt connection from the hypervisor
- */
- protected Libvirt libvirt ;
-
- /**
- * Constructs a Network object from a known native virNetworkPtr, and a Connect object.
- * For use when native libvirt returns a virConnectPtr, i.e. error handling.
- *
- * @param virConnect
- * @param VNP
- */
- Network(Connect virConnect, NetworkPointer VNP){
- this.virConnect = virConnect;
- this.VNP = VNP;
- this.libvirt = virConnect.libvirt ;
- }
-
- public void finalize() throws LibvirtException{
- free();
- }
-
- /**
- * Provides an XML description of this network.
- * The description may be reused later to relaunch the network with
Virconnect.virNetworkCreateXML().
- *
- * @param flags and OR'ed set of extraction flags, not used yet
- * @return The XML representation of this network
- * @throws LibvirtException
- */
- public String getXMLDesc(int flags) throws LibvirtException{
- String returnValue = libvirt.virNetworkGetXMLDesc(VNP, flags) ;
- processError() ;
- return returnValue ;
- }
-
-
- /**
- * Provides a boolean value indicating whether this network is configured to be
automatically started when the host machine boots.
- *
- * @return true if autostarted, false otherwise
- * @throws LibvirtException
- */
- public boolean getAutostart() throws LibvirtException{
- IntByReference autoStart = new IntByReference() ;
- libvirt.virNetworkGetAutostart(VNP, autoStart) ;
- processError() ;
- return autoStart.getValue() != 0 ? true : false ;
- }
-
-
-
- /**
- * Configures this network to be automatically started when the host machine boots.
- *
- * @param autostart whether the network should be automatically started 0 or 1
- * @throws LibvirtException
- */
- public void setAutostart(boolean autostart) throws LibvirtException{
- int autoValue = autostart ? 1 : 0 ;
- libvirt.virNetworkSetAutostart(VNP, autoValue) ;
- processError() ;
- }
-
-
- /**
- * Provides a bridge interface name to which a domain may connect a network interface in
order to join this network.
- *
- * @return the interface name
- * @throws LibvirtException
- */
- public String getBridgeName() throws LibvirtException{
- String returnValue = libvirt.virNetworkGetBridgeName(VNP) ;
- processError() ;
- return returnValue ;
- }
-
-
-
- /**
- * Provides the connection pointer associated with this network.
- *
- * @return the Connect object
- */
- public Connect getConnect(){
- return virConnect;
- }
-
-
- /**
- * Gets the public name for this network
- *
- * @return the public name
- * @throws LibvirtException
- */
- public String getName() throws LibvirtException{
- String returnValue = libvirt.virNetworkGetName(VNP);
- processError() ;
- return returnValue ;
- }
-
-
- /**
- * Gets the UUID for this network
- *
- * @return the UUID as an unpacked int array
- * @throws LibvirtException
- * @see <a
href="http://www.ietf.org/rfc/rfc4122.txt">rfc4122</a>
- */
- public int[] getUUID() throws LibvirtException{
- byte[] bytes = new byte[Libvirt.VIR_UUID_BUFLEN] ;
- int success = libvirt.virNetworkGetUUID(VNP, bytes) ;
- processError() ;
- int[] returnValue = new int[0] ;
- if (success == 0) {
- returnValue = Connect.convertUUIDBytes(bytes) ;
- }
- return returnValue ;
- }
-
- /**
- * Gets the UUID for a network as string.
- *
- * @return the UUID in canonical String format
- * @throws LibvirtException
- * @see <a
href="http://www.ietf.org/rfc/rfc4122.txt">rfc4122</a>
- */
- public String getUUIDString() throws LibvirtException{
- byte[] bytes = new byte[Libvirt.VIR_UUID_STRING_BUFLEN] ;
- int success = libvirt.virNetworkGetUUIDString(VNP, bytes) ;
- processError() ;
- String returnValue = null ;
- if (success == 0) {
- returnValue = Native.toString(bytes) ;
- }
- return returnValue ;
- }
-
-
- /**
- * Creates and starts this defined network.
- * If the call succeeds the network moves from the defined to the running networks
pools.
- *
- * @throws LibvirtException
- */
- public void create() throws LibvirtException{
- libvirt.virNetworkCreate(VNP) ;
- processError() ;
- }
-
-
- /**
- * Destroy this network object.
- * The running instance is shutdown if not down already and all resources used by it are
given back to the hypervisor.
- * The object becomes invalid and should not be used thereafter if the call does not
return an error.
- * This function may require priviledged access
- *
- * @throws LibvirtException
- */
- public void destroy() throws LibvirtException{
- libvirt.virNetworkDestroy(VNP) ;
- processError() ;
- }
-
-
- /**
- * Frees this network object.
- * The running instance is kept alive.
- * The object becomes invalid and should not be used thereafter if the call does not
return an error.
- *
- * @throws LibvirtException
- */
- public void free() throws LibvirtException{
- libvirt.virNetworkFree(VNP) ;
- processError() ;
- VNP=null;
- }
-
-
- /**
- * Undefines this network but does not stop it if it is running
- *
- * @throws LibvirtException
- */
- public void undefine() throws LibvirtException{
- libvirt.virNetworkUndefine(VNP) ;
- processError() ;
- }
-
- protected void processError() throws LibvirtException {
- virConnect.processError() ;
- }
-
-
-}
diff --git a/src/org/libvirt/NodeInfo.java b/src/org/libvirt/NodeInfo.java
deleted file mode 100644
index 0431ed9..0000000
--- a/src/org/libvirt/NodeInfo.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package org.libvirt;
-
-import org.libvirt.jna.virNodeInfo;
-
-import com.sun.jna.Native;
-
-public class NodeInfo {
- /**
- * string indicating the CPU model
- */
- public String model;
- /**
- * memory size in kilobytes
- */
- public long memory;
- /**
- * the number of active CPUs
- */
- public int cpus;
- /**
- * expected CPU frequency
- */
- public int mhz;
- /**
- * the number of NUMA cell, 1 for uniform
- */
- public int nodes;
- /**
- * number of CPU socket per node
- */
- public int sockets;
- /**
- * number of core per socket
- */
- public int cores;
- /**
- * number of threads per core
- */
- public int threads;
-
-
- public NodeInfo() {
- }
-
- public NodeInfo(virNodeInfo vInfo) {
- this.model = Native.toString(vInfo.model) ;
- this.memory = vInfo.memory.longValue() ;
- this.cpus = vInfo.cpus ;
- this.mhz = vInfo.mhz ;
- this.nodes = vInfo.nodes ;
- this.sockets = vInfo.sockets ;
- this.cores = vInfo.cores ;
- this.threads = vInfo.threads ;
- }
- /**
- * @return the total number of CPUs supported but not neccessarily active in the host.
- */
- public int maxCpus(){
- return nodes*sockets*cores*threads;
- }
-}
diff --git a/src/org/libvirt/SchedBooleanParameter.java
b/src/org/libvirt/SchedBooleanParameter.java
deleted file mode 100644
index 5e681ca..0000000
--- a/src/org/libvirt/SchedBooleanParameter.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package org.libvirt;
-
-/**
- * Class for representing a boolean scheduler parameter
- *
- * @author stoty
- *
- */
-public final class SchedBooleanParameter extends SchedParameter{
- /**
- * The parameter value
- */
- public boolean value;
-
- public SchedBooleanParameter() {
-
- }
-
- public SchedBooleanParameter(boolean value)
- {
- this.value = value;
- }
-
- public SchedBooleanParameter(byte value)
- {
- this.value = (((int)value) != 0)? true : false ;
- }
-
- public String getValueAsString(){
- return Boolean.toString(value);
- }
-
- public String getTypeAsString(){
- return "VIR_DOMAIN_SCHED_FIELD_BOOLEAN";
- }
-
- public int getType() {
- return 6 ;
- }
-}
diff --git a/src/org/libvirt/SchedDoubleParameter.java
b/src/org/libvirt/SchedDoubleParameter.java
deleted file mode 100644
index 21bc217..0000000
--- a/src/org/libvirt/SchedDoubleParameter.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package org.libvirt;
-
-/**
- * Class for representing a double scheduler parameter
- *
- * @author stoty
- *
- */
-public final class SchedDoubleParameter extends SchedParameter{
- /**
- * The parameter value
- */
- public double value;
-
- public SchedDoubleParameter() {
-
- }
-
- public SchedDoubleParameter(double value)
- {
- this.value = value;
- }
-
- public String getValueAsString(){
- return Double.toString(value);
- }
-
- public String getTypeAsString(){
- return "VIR_DOMAIN_SCHED_FIELD_DOUBLE";
- }
-
- public int getType() {
- return 5 ;
- }
-}
diff --git a/src/org/libvirt/SchedIntParameter.java
b/src/org/libvirt/SchedIntParameter.java
deleted file mode 100644
index af13933..0000000
--- a/src/org/libvirt/SchedIntParameter.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.libvirt;
-
-public final class SchedIntParameter extends SchedParameter {
- public int value;
-
- public SchedIntParameter() {
-
- }
-
- public SchedIntParameter(int value)
- {
- this.value = value;
- }
-
- public String getValueAsString(){
- return Integer.toString(value);
- }
-
- public String getTypeAsString(){
- return "VIR_DOMAIN_SCHED_FIELD_INT";
- }
-
- public int getType() {
- return 1 ;
- }
-}
diff --git a/src/org/libvirt/SchedLongParameter.java
b/src/org/libvirt/SchedLongParameter.java
deleted file mode 100644
index 1b07971..0000000
--- a/src/org/libvirt/SchedLongParameter.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package org.libvirt;
-
-/**
- * Class for representing a long int scheduler parameter
- *
- * @author stoty
- *
- */
-public final class SchedLongParameter extends SchedParameter{
- /**
- * The parameter value
- */
- public long value;
-
- public SchedLongParameter() {
-
- }
-
- public SchedLongParameter(long value)
- {
- this.value = value;
- }
-
- public String getValueAsString(){
- return Long.toString(value);
- }
-
- public String getTypeAsString(){
- return "VIR_DOMAIN_SCHED_FIELD_LLONG";
- }
-
- public int getType() {
- return 2 ;
- }
-
-}
diff --git a/src/org/libvirt/SchedParameter.java b/src/org/libvirt/SchedParameter.java
deleted file mode 100644
index 8f38ef8..0000000
--- a/src/org/libvirt/SchedParameter.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package org.libvirt;
-
-import java.util.Arrays;
-
-import org.libvirt.jna.Libvirt;
-import org.libvirt.jna.virSchedParameter;
-
-import com.sun.jna.Native;
-
-/**
- * The abstract parent of the actual Schedparameter classes
- *
- * @author stoty
- *
- */
-public abstract class SchedParameter {
-
- /**
- * Parameter name
- */
- public String field;
-
- /**
- * Utility function for displaying the value
- *
- * @return the value of the parameter in String form
- */
- public abstract String getValueAsString();
- /**
- * Utility function for displaying the type
- *
- * @return the Type of the parameter as string
- */
- public abstract String getTypeAsString();
-
- /**
- * The type of the parameter
- *
- * @return the Type of the parameter
- */
- public abstract int getType() ;
-
- public static SchedParameter create(virSchedParameter vParam) {
- SchedParameter returnValue = null ;
- switch (vParam.type) {
- case (1): returnValue = new SchedIntParameter(vParam.value.i) ;break ;
- case (2): returnValue = new SchedUintParameter(vParam.value.ui) ;break ;
- case (3): returnValue = new SchedLongParameter(vParam.value.l) ;break ;
- case (4): returnValue = new SchedUlongParameter(vParam.value.ul) ;break ;
- case (5): returnValue = new SchedDoubleParameter(vParam.value.d) ;break ;
- case (6): returnValue = new SchedBooleanParameter(vParam.value.b) ;break ;
- }
- returnValue.field = Native.toString(vParam.field) ;
- return returnValue ;
- }
-
- public static virSchedParameter toNative(SchedParameter param) {
- virSchedParameter returnValue = new virSchedParameter() ;
- returnValue.field = Arrays.copyOf(param.field.getBytes(),
Libvirt.VIR_DOMAIN_SCHED_FIELD_LENGTH) ;
- returnValue.type = param.getType() ;
- switch (param.getType()) {
- case (1): returnValue.value.i = ((SchedIntParameter)param).value ;break ;
- case (2): returnValue.value.ui = ((SchedUintParameter)param).value ;break ;
- case (3): returnValue.value.l = ((SchedLongParameter)param).value ;break ;
- case (4): returnValue.value.ul = ((SchedUlongParameter)param).value ;break ;
- case (5): returnValue.value.d = ((SchedDoubleParameter)param).value ;break ;
- case (6): returnValue.value.b = (byte)(((SchedBooleanParameter)param).value?1:0)
;break ;
-
- }
- return returnValue ;
- }
-}
diff --git a/src/org/libvirt/SchedUintParameter.java
b/src/org/libvirt/SchedUintParameter.java
deleted file mode 100644
index 8a6ab75..0000000
--- a/src/org/libvirt/SchedUintParameter.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package org.libvirt;
-
-/**
- * Class for representing an unsigned int scheduler parameter
- *
- *
- * @author stoty
- *
- */
-public final class SchedUintParameter extends SchedParameter {
- /**
- * The parameter value
- */
- public int value;
-
- public SchedUintParameter() {
-
- }
-
- public SchedUintParameter(int value)
- {
- this.value = value;
- }
-
- public String getValueAsString(){
- return Integer.toString(value);
- }
-
- public String getTypeAsString(){
- return "VIR_DOMAIN_SCHED_FIELD_UINT";
- }
-
- public int getType() {
- return 3 ;
- }
-}
diff --git a/src/org/libvirt/SchedUlongParameter.java
b/src/org/libvirt/SchedUlongParameter.java
deleted file mode 100644
index 419c1a8..0000000
--- a/src/org/libvirt/SchedUlongParameter.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package org.libvirt;
-
-/**
- * Class for representing an unsigned long int scheduler parameter
- *
- * @author stoty
- *
- */
-public final class SchedUlongParameter extends SchedParameter{
- /**
- * The parameter value
- */
- public long value;
-
- public SchedUlongParameter() {
-
- }
-
- public SchedUlongParameter(long value)
- {
- this.value = value;
- }
-
- public String getValueAsString(){
- return Long.toString(value);
- }
-
- public String getTypeAsString(){
- return "VIR_DOMAIN_SCHED_FIELD_ULLONG";
- }
-
- public int getType() {
- return 4 ;
- }
-}
diff --git a/src/org/libvirt/StoragePool.java b/src/org/libvirt/StoragePool.java
deleted file mode 100644
index 5ef5423..0000000
--- a/src/org/libvirt/StoragePool.java
+++ /dev/null
@@ -1,325 +0,0 @@
-package org.libvirt;
-
-import org.libvirt.jna.Libvirt;
-import org.libvirt.jna.StoragePoolPointer;
-import org.libvirt.jna.StorageVolPointer;
-import org.libvirt.jna.virStoragePoolInfo;
-
-import com.sun.jna.Native;
-import com.sun.jna.ptr.IntByReference;
-
-public class StoragePool {
-
- static final class BuildFlags{
- /**
- * Regular build from scratch
- */
- static final int VIR_STORAGE_POOL_BUILD_NEW = 0;
- /**
- * Repair / reinitialize
- */
- static final int VIR_STORAGE_POOL_BUILD_REPAIR = 1;
- /**
- * Extend existing pool
- */
- static final int VIR_STORAGE_POOL_BUILD_RESIZE = 2;
- }
-
- static final class DeleteFlags{
- /**
- * Delete metadata only (fast)
- */
- static final int VIR_STORAGE_POOL_DELETE_NORMAL = 0;
- /**
- * Clear all data to zeros (slow)
- */
- static final int VIR_STORAGE_POOL_DELETE_ZEROED = 1;
- }
-
- /**
- * the native virStoragePoolPtr.
- */
- protected StoragePoolPointer VSPP;
-
- /**
- * The VirConnect Object that represents the Hypervisor of this Domain
- */
- protected Connect virConnect;
-
- /**
- * the libvirt instance
- */
- protected Libvirt libvirt ;
-
-
- /**
- * Constructs a VirStoragePool object from a known native virStoragePoolPtr, and a
VirConnect object.
- * For use when native libvirt returns a virStoragePoolPtr, i.e. error handling.
- *
- * @param virConnect the Domain's hypervisor
- * @param VSPP the native virStoragePoolPtr
- */
- StoragePool(Connect virConnect, StoragePoolPointer VSPP){
- this.virConnect = virConnect;
- this.VSPP = VSPP;
- this.libvirt = virConnect.libvirt ;
- }
-
- /**
- * Build the underlying storage pool
- *
- * @param flags future flags, use 0 for now
- */
- public void build(int flags) throws LibvirtException{
- libvirt.virStoragePoolBuild(VSPP, flags);
- processError() ;
- }
-
-
- /**
- * Starts this inactive storage pool
- *
- * @param flags future flags, use 0 for now
- */
- public void create(int flags) throws LibvirtException{
- libvirt.virStoragePoolCreate(VSPP, flags);
- processError() ;
- }
-
-
- /**
- * Delete the underlying pool resources. This is a non-recoverable operation.
- * The virStoragePool object itself is not free'd.
- *
- * @param flags flags for obliteration process
- */
- public void delete(int flags) throws LibvirtException{
- libvirt.virStoragePoolDelete(VSPP, flags);
- processError() ;
- }
-
-
- /**
- * Destroy an active storage pool.
- * This will deactivate the pool on the host, but keep any persistent config associated
with it.
- * If it has a persistent config it can later be restarted with virStoragePoolCreate().
- * This does not free the associated virStoragePoolPtr object.
- */
- public void destroy() throws LibvirtException{
- libvirt.virStoragePoolDestroy(VSPP);
- processError() ;
- }
-
-
- /**
- * Free a storage pool object, releasing all memory associated with it.
- * Does not change the state of the pool on the host.
- */
- public void free() throws LibvirtException{
- libvirt.virStoragePoolFree(VSPP);
- processError() ;
- }
-
-
-
- /**
- * Fetches the value of the autostart flag, which determines whether the pool is
automatically started at boot time
- *
- * @return the result
- * @throws LibvirtException
- */
- public boolean getAutostart() throws LibvirtException{
- IntByReference autoStart = new IntByReference() ;
- libvirt.virStoragePoolGetAutostart(VSPP, autoStart) ;
- processError() ;
- return autoStart.getValue() != 0 ? true : false ;
- }
-
-
- /**
- * Provides the connection pointer associated with a storage pool.
- *
- * @return the Connect object
- */
- public Connect getConnect(){
- return virConnect;
- }
-
-
- /**
- * Get volatile information about the storage pool such as free space / usage summary
- *
- * @return a StoragePoolInfo object describing this storage pool
- * @throws LibvirtException
- */
- public StoragePoolInfo getInfo() throws LibvirtException{
- virStoragePoolInfo vInfo = new virStoragePoolInfo() ;
- libvirt.virStoragePoolGetInfo(VSPP, vInfo ) ;
- processError() ;
- return new StoragePoolInfo(vInfo) ;
- }
-
-
- /**
- * Fetch the locally unique name of the storage pool
- *
- * @return the name
- * @throws LibvirtException
- */
- public String getName() throws LibvirtException{
- String returnValue = libvirt.virStoragePoolGetName(VSPP) ;
- processError() ;
- return returnValue ;
- }
-
-
- /**
- * Fetch the globally unique ID of this storage pool
- *
- * @return the UUID as an unpacked int array
- * @throws LibvirtException
- */
- public int[] getUUID() throws LibvirtException{
- byte[] bytes = new byte[Libvirt.VIR_UUID_BUFLEN] ;
- int success = libvirt.virStoragePoolGetUUID(VSPP, bytes) ;
- processError() ;
- int[] returnValue = new int[0] ;
- if (success == 0) {
- returnValue = Connect.convertUUIDBytes(bytes) ;
- }
- return returnValue ;
- }
-
-
- /**
- * Fetch the globally unique ID of the storage pool as a string
- *
- * @return the UUID in canonical String format
- * @throws LibvirtException
- */
- public String getUUIDString() throws LibvirtException{
- byte[] bytes = new byte[Libvirt.VIR_UUID_STRING_BUFLEN] ;
- int success = libvirt.virStoragePoolGetUUIDString(VSPP, bytes) ;
- processError() ;
- String returnValue = null ;
- if (success == 0) {
- returnValue = Native.toString(bytes) ;
- }
- return returnValue ;
- }
-
-
- /**
- * Fetch an XML document describing all aspects of the storage pool.
- * This is suitable for later feeding back into the virStoragePoolCreateXML method.
- *
- * @param flags flags for XML format options (set of virDomainXMLFlags)
- * @return a XML document
- *-java @throws LibvirtException
- */
- public String getXMLDesc(int flags) throws LibvirtException{
- String returnValue = libvirt.virStoragePoolGetXMLDesc(VSPP, flags) ;
- processError() ;
- return returnValue ;
- }
-
-
- /**
- * Fetch list of storage volume names
- *
- * @return an Array of Strings that contains the names of the storage volumes
- * @throws LibvirtException
- */
- public String[] listVolumes() throws LibvirtException {
- int num = this.numOfVolumes() ;
- String[] returnValue = new String[num] ;
- libvirt.virStoragePoolListVolumes(VSPP, returnValue, num) ;
- processError() ;
- return returnValue ;
- }
-
-
- /**
- * Fetch the number of storage volumes within a pool
- *
- * @return the number of storage pools
- * @throws LibvirtException
- */
- public int numOfVolumes() throws LibvirtException {
- int returnValue = libvirt.virStoragePoolNumOfVolumes(VSPP) ;
- processError() ;
- return returnValue ;
- }
-
-
- /**
- * Request that the pool refresh its list of volumes.
- * This may involve communicating with a remote server, and/or initializing new devices
at the OS layer
- *
- * @param flags flags to control refresh behaviour (currently unused, use 0)
- * @throws LibvirtException
- */
- public void refresh(int flags) throws LibvirtException {
- libvirt.virStoragePoolRefresh(VSPP) ;
- processError() ;
- }
-
-
- /**
- * Sets the autostart flag
- *
- * @param autostart new flag setting
- * @throws LibvirtException
- */
- public void setAutostart(int autostart) throws LibvirtException {
- libvirt.virStoragePoolSetAutostart(VSPP, autostart) ;
- }
-
-
- /**
- * Undefine an inactive storage pool
- *
- * @throws LibvirtException
- */
- public void undefine() throws LibvirtException {
- libvirt.virStoragePoolUndefine(VSPP) ;
- processError() ;
- }
-
-
- /**
- * Fetch an object representing to a storage volume based on its name within a pool
- *
- * @param name name of storage volume
- * @return The StorageVol object found
- * @throws LibvirtException
- */
- public StorageVol storageVolLookupByName(String name)
- throws LibvirtException {
- StorageVolPointer sPtr = libvirt.virStorageVolLookupByName(VSPP, name) ;
- processError() ;
- return new StorageVol(virConnect, sPtr) ;
- }
-
-
- /**
- * Create a storage volume within a pool based on an XML description. Not all pools
support creation of volumes
- *
- * @param xmlDesc description of volume to create
- * @param flags flags for creation (unused, pass 0)
- * @return the storage volume
- * @throws LibvirtException
- */
- public StorageVol storageVolCreateXML(String xmlDesc, int flags)
- throws LibvirtException {
- StorageVolPointer sPtr = libvirt.virStorageVolCreateXML(VSPP, xmlDesc, flags) ;
- processError() ;
- return new StorageVol(virConnect, sPtr) ;
- }
-
-
- protected void processError() throws LibvirtException {
- virConnect.processError() ;
- }
-
-}
diff --git a/src/org/libvirt/StoragePoolInfo.java b/src/org/libvirt/StoragePoolInfo.java
deleted file mode 100644
index 2b5b601..0000000
--- a/src/org/libvirt/StoragePoolInfo.java
+++ /dev/null
@@ -1,79 +0,0 @@
-package org.libvirt;
-
-import org.libvirt.jna.virStoragePoolInfo;
-
-public class StoragePoolInfo {
-
- /**
- * the running state
- */
- public StoragePoolState state;
-
- /**
- * Logical size bytes
- */
- public long capacity;
-
- /**
- * Current allocation bytes
- */
- public long allocation;
-
- /**
- * Remaining free space bytes
- */
- public long available;
-
- public static enum StoragePoolState {
- /**
- * Not running
- */
- VIR_STORAGE_POOL_INACTIVE,
- /**
- * Initializing pool, not available
- */
- VIR_STORAGE_POOL_BUILDING,
- /**
- * Running normally
- */
- VIR_STORAGE_POOL_RUNNING,
- /**
- * Running degraded
- */
- VIR_STORAGE_POOL_DEGRADED
- };
-
- /**
- * This is meant to be called from the JNI side, as a convenience constructor
- *
- * @param state the state, as defined by libvirt
- * @param capacity
- * @param allocation
- * @param available
- */
- StoragePoolInfo(int state, long capacity, long allocation, long available){
- switch(state){
- case 0: this.state=StoragePoolState.VIR_STORAGE_POOL_INACTIVE; break;
- case 1: this.state=StoragePoolState.VIR_STORAGE_POOL_BUILDING; break;
- case 2: this.state=StoragePoolState.VIR_STORAGE_POOL_RUNNING; break;
- case 3: this.state=StoragePoolState.VIR_STORAGE_POOL_DEGRADED; break;
- default: assert(false);
- }
- this.capacity = capacity;
- this.allocation = allocation;
- this.available = available;
- }
-
- StoragePoolInfo(virStoragePoolInfo vInfo) {
- this(vInfo.state, vInfo.capacity, vInfo.allocation, vInfo.available) ;
- }
-
- public String toString(){
- StringBuffer result = new StringBuffer("");
- result.append("state:" + state + "\n");
- result.append("capacity:" + capacity + "\n");
- result.append("allocation:" + allocation + "\n");
- result.append("available:" + available + "\n");
- return result.toString();
- }
-}
diff --git a/src/org/libvirt/StorageVol.java b/src/org/libvirt/StorageVol.java
deleted file mode 100644
index 0eb4efb..0000000
--- a/src/org/libvirt/StorageVol.java
+++ /dev/null
@@ -1,183 +0,0 @@
-package org.libvirt;
-
-import org.libvirt.jna.Libvirt;
-import org.libvirt.jna.StoragePoolPointer;
-import org.libvirt.jna.StorageVolPointer;
-import org.libvirt.jna.virStorageVolInfo;
-
-public class StorageVol {
-
- static final class DeleteFlags{
- /**
- * Delete metadata only (fast)
- */
- static final int VIR_STORAGE_POOL_DELETE_NORMAL = 0;
- /**
- * Clear all data to zeros (slow)
- */
- static final int VIR_STORAGE_POOL_DELETE_ZEROED = 1;
- }
-
- public static enum Type {
- /**
- * Regular file based volumes
- */
- VIR_STORAGE_VOL_FILE,
- /**
- * Block based volumes
- */
- VIR_STORAGE_VOL_BLOCK
- }
-
- /**
- * the native virStorageVolPtr.
- */
- protected StorageVolPointer VSVP;
-
- /**
- * The VirConnect Object that represents the Hypervisor of this Domain
- */
- protected Connect virConnect;
-
- /**
- * the libvirt instance
- */
- protected Libvirt libvirt ;
-
-
- /**
- * Constructs a VirStorageVol object from a known native virStoragePoolPtr, and a
VirConnect object.
- * For use when native libvirt returns a virStorageVolPtr, i.e. error handling.
- *
- * @param virConnect the Domain's hypervisor
- * @param VSVP the native virStorageVolPtr
- */
- StorageVol(Connect virConnect, StorageVolPointer VSVP){
- this.virConnect = virConnect;
- this.VSVP = VSVP;
- this.libvirt = virConnect.libvirt ;
- }
-
- /**
- * Fetch a storage pool which contains this volume
- *
- * @return StoragePool object,
- * @throws LibvirtException
- */
- public StoragePool storagePoolLookupByVolume()
- throws LibvirtException {
- StoragePoolPointer ptr = libvirt.virStoragePoolLookupByVolume(VSVP) ;
- processError() ;
- return new StoragePool(virConnect, ptr) ;
- }
-
-
- /**
- * Delete the storage volume from the pool
- *
- * @param flags future flags, use 0 for now
- * @throws LibvirtException
- */
- public void delete(int flags) throws LibvirtException{
- libvirt.virStorageVolDelete(VSVP, flags) ;
- processError() ;
- }
-
-
- /**
- * Release the storage volume handle. The underlying storage volume contains to exist
- *
- * @throws LibvirtException
- */
- public void free() throws LibvirtException{
- libvirt.virStorageVolFree(VSVP) ;
- processError() ;
- }
-
-
- /**
- * Provides the connection object associated with a storage volume. The reference
counter on the connection is not increased by this call.
- *
- * @return the Connect object
- */
- public Connect getConnect(){
- return virConnect;
- }
-
- /**
- * Fetches volatile information about the storage volume such as its current allocation
- *
- * @return StorageVolInfo object
- * @throws LibvirtException
- */
- public StorageVolInfo getInfo() throws LibvirtException{
- virStorageVolInfo vInfo = new virStorageVolInfo() ;
- libvirt.virStorageVolGetInfo(VSVP, vInfo) ;
- processError() ;
- return new StorageVolInfo(vInfo) ;
- }
-
-
- /**
- * Fetch the storage volume key. This is globally unique, so the same volume will have
the same key no matter what host it is accessed from
- *
- * @return the key
- * @throws LibvirtException
- */
- public String getKey() throws LibvirtException{
- String returnValue = libvirt.virStorageVolGetKey(VSVP) ;
- processError() ;
- return returnValue ;
- }
-
-
- /**
- * Fetch the storage volume name. This is unique within the scope of a pool
- *
- * @return the name
- * @throws LibvirtException
- */
- public String getName() throws LibvirtException{
- String returnValue = libvirt.virStorageVolGetName(VSVP) ;
- processError() ;
- return returnValue ;
- }
-
-
- /**
- * Fetch the storage volume path.
- * Depending on the pool configuration this is either persistent across hosts, or
dynamically assigned at pool startup.
- * Consult pool documentation for information on getting the persistent naming
- *
- * @return the storage volume path
- * @throws LibvirtException
- */
- public String getPath() throws LibvirtException{
- String returnValue = libvirt.virStorageVolGetPath(VSVP) ;
- processError() ;
- return returnValue ;
- }
-
-
- /**
- * Fetch an XML document describing all aspects of this storage volume
- *
- * @param flags flags for XML generation (unused, pass 0)
- * @return the XML document
- * @throws LibvirtException
- */
- public String getXMLDesc(int flags) throws LibvirtException{
- String returnValue = libvirt.virStorageVolGetXMLDesc(VSVP, flags) ;
- processError() ;
- return returnValue ;
- }
-
-
- /**
- * Error handling logic which should be called after every libvirt call
- * @throws LibvirtException
- */
- protected void processError() throws LibvirtException {
- virConnect.processError() ;
- }
-}
diff --git a/src/org/libvirt/StorageVolInfo.java b/src/org/libvirt/StorageVolInfo.java
deleted file mode 100644
index 9887d4a..0000000
--- a/src/org/libvirt/StorageVolInfo.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package org.libvirt;
-
-import org.libvirt.jna.virStorageVolInfo;
-
-public class StorageVolInfo {
-
- /**
- * The type of the Volume
- */
- public VirStorageVolType type;
- /**
- * Logical size bytes
- */
- public long capacity;
- /**
- * Current allocation bytes
- */
- public long allocation;
-
- public static enum VirStorageVolType{
- /**
- * Regular file based volumes
- */
- VIR_STORAGE_VOL_FILE,
- /**
- * Block based volumes
- */
- VIR_STORAGE_VOL_BLOCK
- };
-
- /**
- * This is meant to be called from the JNI side, as a convenience constructor
- *
- * @param type the type, as defined by libvirt
- * @param capacity
- * @param allocation
- */
- StorageVolInfo(int type, long capacity, long allocation){
- switch(type){
- case 0: this.type=VirStorageVolType.VIR_STORAGE_VOL_FILE; break;
- case 1: this.type=VirStorageVolType.VIR_STORAGE_VOL_BLOCK; break;
- default: assert(false);
- }
- this.capacity = capacity;
- this.allocation = allocation;
- }
-
- StorageVolInfo(virStorageVolInfo volInfo) {
- this(volInfo.type, volInfo.capacity, volInfo.allocation) ;
- }
-
- public String toString(){
- StringBuffer result = new StringBuffer("");
- result.append("type:" + type + "\n");
- result.append("capacity:" + capacity + "\n");
- result.append("allocation:" + allocation + "\n");
- return result.toString();
- }
-}
diff --git a/src/org/libvirt/VcpuInfo.java b/src/org/libvirt/VcpuInfo.java
deleted file mode 100644
index b10c07d..0000000
--- a/src/org/libvirt/VcpuInfo.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.libvirt;
-
-import org.libvirt.jna.virVcpuInfo;
-
-public class VcpuInfo {
- public int number;
- public VcpuState state;
- public long cpuTime;
- public int cpu;
-
- public static enum VcpuState {
- VIR_VCPU_OFFLINE,
- VIR_VCPU_RUNNING,
- VIR_VCPU_BLOCKED};
-
- public VcpuInfo() {
-
- }
-
- public VcpuInfo(virVcpuInfo vVcpu) {
- this.number = vVcpu.number ;
- this.cpuTime = vVcpu.cpuTime ;
- this.cpu = vVcpu.cpu ;
- this.state = VcpuState.values()[vVcpu.state] ;
- }
-}
diff --git a/src/org/libvirt/jna/ConnectionPointer.java
b/src/org/libvirt/jna/ConnectionPointer.java
deleted file mode 100644
index ab98489..0000000
--- a/src/org/libvirt/jna/ConnectionPointer.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.libvirt.jna;
-
-import com.sun.jna.PointerType;
-
-public class ConnectionPointer extends PointerType
-{
-}
diff --git a/src/org/libvirt/jna/DomainPointer.java
b/src/org/libvirt/jna/DomainPointer.java
deleted file mode 100644
index 8abb852..0000000
--- a/src/org/libvirt/jna/DomainPointer.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.libvirt.jna;
-
-import com.sun.jna.PointerType;
-
-public class DomainPointer extends PointerType
-{
-}
diff --git a/src/org/libvirt/jna/Libvirt.java b/src/org/libvirt/jna/Libvirt.java
deleted file mode 100644
index 5ed9fad..0000000
--- a/src/org/libvirt/jna/Libvirt.java
+++ /dev/null
@@ -1,162 +0,0 @@
-package org.libvirt.jna;
-
-
-import com.sun.jna.Callback;
-import com.sun.jna.Library;
-import com.sun.jna.Native;
-import com.sun.jna.NativeLong;
-import com.sun.jna.Pointer;
-import com.sun.jna.ptr.IntByReference;
-import com.sun.jna.ptr.LongByReference;
-
-public interface Libvirt extends Library
-{
- Libvirt INSTANCE = (Libvirt) Native.loadLibrary("libvirt", Libvirt.class)
;
-
- // Constants we need
- public static int VIR_UUID_BUFLEN = 16 ;
- public static int VIR_UUID_STRING_BUFLEN = (36+1) ;
- public static int VIR_DOMAIN_SCHED_FIELD_LENGTH = 80 ;
-
- // Global functions
- public int virCopyLastError(virError error) ;
- public virError virGetLastError() ;
- public int virGetVersion(LongByReference libVer, String type, LongByReference
typeVer) ;
- public int virInitialize() ;
- public void virResetLastError() ;
-
- //Connection Functions
- public int virConnCopyLastError(ConnectionPointer virConnectPtr, virError to) ;
- public int virConnectClose(ConnectionPointer virConnectPtr) ;
- public String virConnectGetCapabilities(ConnectionPointer virConnectPtr) ;
- public String virConnectGetHostname(ConnectionPointer virConnectPtr) ;
- public virError virConnGetLastError(ConnectionPointer virConnectPtr) ;
- public int virConnectGetMaxVcpus(ConnectionPointer virConnectPtr, String type) ;
- public String virConnectGetType(ConnectionPointer virConnectPtr) ;
- public String virConnectGetURI(ConnectionPointer virConnectPtr) ;
- public int virConnectGetVersion(ConnectionPointer virConnectPtr, LongByReference
hvVer) ;
- public int virConnectListDomains(ConnectionPointer virConnectPtr, int[] ids, int
maxnames) ;
- public int virConnectListNetworks(ConnectionPointer virConnectPtr, String[] name, int
maxnames) ;
- public int virConnectListStoragePools(ConnectionPointer virConnectPtr, String[]
names, int maxnames) ;
- public int virConnectListDefinedStoragePools(ConnectionPointer virConnectPtr,
String[] names, int maxnames) ;
- public int virConnectListDefinedDomains(ConnectionPointer virConnectPtr, String[]
name, int maxnames) ;
- public int virConnectListDefinedNetworks(ConnectionPointer virConnectPtr, String[]
name, int maxnames) ;
- public int virConnectNumOfDomains(ConnectionPointer virConnectPtr) ;
- public int virConnectNumOfDefinedDomains(ConnectionPointer virConnectPtr) ;
- public int virConnectNumOfDefinedNetworks(ConnectionPointer virConnectPtr) ;
- public int virConnectNumOfDefinedStoragePools(ConnectionPointer virConnectPtr) ;
- public int virConnectNumOfNetworks(ConnectionPointer virConnectPtr) ;
- public int virConnectNumOfStoragePools(ConnectionPointer virConnectPtr) ;
- public int virConnResetLastError(ConnectionPointer virConnectPtr) ;
- public ConnectionPointer virConnectOpen(String name) ;
- public ConnectionPointer virConnectOpenAuth(String name, virConnectAuth auth, int
flags) ;
- public ConnectionPointer virConnectOpenReadOnly(String name) ;
-
- // Node functions
- public int virNodeGetInfo(ConnectionPointer virConnectPtr, virNodeInfo virNodeInfo)
;
-
- // Storage Pool
- public int virStoragePoolBuild(StoragePoolPointer storagePoolPtr, int flags) ;
- public int virStoragePoolCreate(StoragePoolPointer storagePoolPtr, int flags) ;
- public StoragePoolPointer virStoragePoolCreateXML(ConnectionPointer virConnectPtr,
String xml, int flags) ;
- public StoragePoolPointer virStoragePoolDefineXML(ConnectionPointer virConnectPtr,
String xml, int flags) ;
- public int virStoragePoolDelete(StoragePoolPointer storagePoolPtr, int flags) ;
- public int virStoragePoolDestroy(StoragePoolPointer storagePoolPtr) ;
- public int virStoragePoolFree(StoragePoolPointer storagePoolPtr) ;
- public int virStoragePoolGetAutostart(StoragePoolPointer storagePoolPtr,
IntByReference value) ;
- public int virStoragePoolGetInfo(StoragePoolPointer storagePoolPtr,
virStoragePoolInfo info) ;
- public String virStoragePoolGetName(StoragePoolPointer storagePoolPtr) ;
- public int virStoragePoolGetUUID(StoragePoolPointer storagePoolPtr, byte[]
uuidString) ;
- public int virStoragePoolGetUUIDString(StoragePoolPointer storagePoolPtr, byte[]
uuidString) ;
- public String virStoragePoolGetXMLDesc(StoragePoolPointer storagePoolPtr, int flags)
;
- public int virStoragePoolListVolumes(StoragePoolPointer storagePoolPtr, String[]
names, int maxnames) ;
- public StoragePoolPointer virStoragePoolLookupByName(ConnectionPointer virConnectPtr,
String name) ;
- public StoragePoolPointer virStoragePoolLookupByUUIDString(ConnectionPointer
virConnectPtr, String uuidstr) ;
- public StoragePoolPointer virStoragePoolLookupByUUID(ConnectionPointer virConnectPtr,
String uuidstr) ;
- public StoragePoolPointer virStoragePoolLookupByVolume(StorageVolPointer
storageVolPtr) ;
- public int virStoragePoolNumOfVolumes(StoragePoolPointer storagePoolPtr) ;
- public int virStoragePoolRefresh(StoragePoolPointer storagePoolPtr) ;
- public int virStoragePoolSetAutostart(StoragePoolPointer storagePoolPtr, int
autostart) ;
- public int virStoragePoolUndefine(StoragePoolPointer storagePoolPtr) ;
-
- // Storage Vol
- public StorageVolPointer virStorageVolCreateXML(StoragePoolPointer storagePoolPtr,
String xml, int flags) ;
- public StorageVolPointer virStorageVolLookupByKey(ConnectionPointer virConnectPtr,
String name) ;
- public StorageVolPointer virStorageVolLookupByName(StoragePoolPointer storagePoolPtr,
String name) ;
- public StorageVolPointer virStorageVolLookupByPath(ConnectionPointer virConnectPtr,
String path) ;
- public int virStorageVolDelete(StorageVolPointer storageVolPtr, int flags) ;
- public int virStorageVolFree(StorageVolPointer storageVolPtr) ;
- public int virStorageVolGetInfo(StorageVolPointer storageVolPtr, virStorageVolInfo
info) ;
- public String virStorageVolGetKey(StorageVolPointer storageVolPtr) ;
- public String virStorageVolGetName(StorageVolPointer storageVolPtr) ;
- public String virStorageVolGetPath(StorageVolPointer storageVolPtr) ;
- public String virStorageVolGetXMLDesc(StorageVolPointer storageVolPtr, int flags) ;
-
- // Network functions
- public int virNetworkCreate(NetworkPointer virConnectPtr) ;
- public NetworkPointer virNetworkCreateXML(ConnectionPointer virConnectPtr, String
xmlDesc) ;
- public NetworkPointer virNetworkDefineXML(ConnectionPointer virConnectPtr, String
xmlDesc) ;
- public int virNetworkDestroy(NetworkPointer virConnectPtr) ;
- public int virNetworkFree(NetworkPointer virConnectPtr) ;
- public int virNetworkGetAutostart(NetworkPointer virNetworkPtr, IntByReference value)
;
- public String virNetworkGetBridgeName(NetworkPointer virNetworkPtr) ;
- public String virNetworkGetName(NetworkPointer virNetworkPtr) ;
- public int virNetworkGetUUID(NetworkPointer virNetworkPtr, byte[] uuidString) ;
- public int virNetworkGetUUIDString(NetworkPointer virNetworkPtr, byte[] uuidString)
;
- public String virNetworkGetXMLDesc(NetworkPointer virNetworkPtr, int flags) ;
- public NetworkPointer virNetworkLookupByName(ConnectionPointer virConnectPtr, String
name) ;
- public NetworkPointer virNetworkLookupByUUIDString(ConnectionPointer virConnectPtr,
String uuidstr) ;
- public NetworkPointer virNetworkLookupByUUID(ConnectionPointer virConnectPtr, String
uuidstr) ;
- public int virNetworkSetAutostart(NetworkPointer virConnectPtr, int autoStart) ;
- public int virNetworkUndefine(NetworkPointer virConnectPtr) ;
-
- // Domain functions
- public int virDomainAttachDevice(DomainPointer virDomainPtr, String deviceXML) ;
- public int virDomainBlockStats(DomainPointer virDomainPtr, String path,
virDomainBlockStats stats, int size) ;
- public int virDomainCreate(DomainPointer virDomainPtr) ;
- public DomainPointer virDomainCreateLinux(ConnectionPointer virConnectPtr, String
xmlDesc, int flags) ;
- public DomainPointer virDomainCreateXML(ConnectionPointer virConnectPtr, String
xmlDesc, int flags) ;
- public int virDomainCoreDump(DomainPointer virDomainPtr, String to, int flags) ;
- public DomainPointer virDomainDefineXML(ConnectionPointer virConnectPtr, String
xmlDesc) ;
- public int virDomainDetachDevice(DomainPointer virDomainPtr, String deviceXML) ;
- public int virDomainDestroy(DomainPointer virDomainPtr) ;
- public int virDomainFree(DomainPointer virDomainPtr) ;
- public int virDomainGetAutostart(DomainPointer virDomainPtr, IntByReference value) ;
- public int virDomainGetID(DomainPointer virDomainPtr) ;
- public int virDomainGetInfo(DomainPointer virDomainPtr, virDomainInfo vInfo) ;
- public NativeLong virDomainGetMaxMemory(DomainPointer virDomainPtr) ;
- public int virDomainGetMaxVcpus(DomainPointer virDomainPtr) ;
- public String virDomainGetName(DomainPointer virDomainPtr) ;
- public String virDomainGetOSType(DomainPointer virDomainPtr) ;
- public int virDomainGetUUID(DomainPointer virDomainPtr, byte[] uuidString) ;
- public int virDomainGetUUIDString(DomainPointer virDomainPtr, byte[] uuidString) ;
- public String virDomainGetXMLDesc(DomainPointer virDomainPtr, int flags) ;
- public String virDomainGetSchedulerType(DomainPointer virDomainPtr, IntByReference
nparams) ;
- public int virDomainGetSchedulerParameters(DomainPointer virDomainPtr,
virSchedParameter[] params, IntByReference nparams) ;
- public int virDomainGetVcpus(DomainPointer virDomainPtr, virVcpuInfo[] info, int
maxInfo, byte[] cpumaps, int maplen) ;
- public int virDomainInterfaceStats(DomainPointer virDomainPtr, String path,
virDomainInterfaceStats stats, int size) ;
- public DomainPointer virDomainLookupByID(ConnectionPointer virConnectPtr, int id) ;
- public DomainPointer virDomainLookupByName(ConnectionPointer virConnectPtr, String
name) ;
- public DomainPointer virDomainLookupByUUID(ConnectionPointer virConnectPtr, String
uuidstr) ;
- public DomainPointer virDomainLookupByUUIDString(ConnectionPointer virConnectPtr,
String uuidstr) ;
- public DomainPointer virDomainMigrate(DomainPointer virDomainPtr, ConnectionPointer
virConnectPtr, NativeLong flags, String dname, String uri, NativeLong bandwidth) ;
- public int virDomainPinVcpu(DomainPointer virDomainPtr, int vcpu, byte[] cpumap, int
maplen) ;
- public int virDomainReboot(DomainPointer virDomainPtr, int flags) ;
- public int virDomainResume(DomainPointer virDomainPtr) ;
- public int virDomainRestore(ConnectionPointer virConnectPtr, String from) ;
- public int virDomainSave(DomainPointer virDomainPtr, String to) ;
- public int virDomainSetAutostart(DomainPointer virDomainPtr, int autoStart) ;
- public int virDomainSetSchedulerParameters(DomainPointer virDomainPtr,
virSchedParameter[] params, IntByReference nparams) ;
- public int virDomainSetMaxMemory(DomainPointer virDomainPtr, NativeLong maxMemory) ;
- public int virDomainSetMemory(DomainPointer virDomainPtr, NativeLong maxMemory) ;
- public int virDomainSetVcpus(DomainPointer virDomainPtr, int nvcpus) ;
- public int virDomainShutdown(DomainPointer virDomainPtr) ;
- public int virDomainSuspend(DomainPointer virDomainPtr) ;
- public int virDomainUndefine(DomainPointer virDomainPtr) ;
-
- // Callbacks
- interface VirConnectAuthCallback extends Callback {
- public int authCallback(virConnectCredential cred, int ncred, Pointer cbdata) ;
-
- }
-}
diff --git a/src/org/libvirt/jna/NetworkPointer.java
b/src/org/libvirt/jna/NetworkPointer.java
deleted file mode 100644
index 62b710c..0000000
--- a/src/org/libvirt/jna/NetworkPointer.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.libvirt.jna;
-
-import com.sun.jna.PointerType;
-
-public class NetworkPointer extends PointerType
-{
-}
diff --git a/src/org/libvirt/jna/StoragePoolPointer.java
b/src/org/libvirt/jna/StoragePoolPointer.java
deleted file mode 100644
index e004ee8..0000000
--- a/src/org/libvirt/jna/StoragePoolPointer.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.libvirt.jna;
-
-import com.sun.jna.PointerType;
-
-public class StoragePoolPointer extends PointerType
-{
-}
diff --git a/src/org/libvirt/jna/StorageVolPointer.java
b/src/org/libvirt/jna/StorageVolPointer.java
deleted file mode 100644
index e0a4acd..0000000
--- a/src/org/libvirt/jna/StorageVolPointer.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.libvirt.jna;
-
-import com.sun.jna.PointerType;
-
-public class StorageVolPointer extends PointerType
-{
-}
diff --git a/src/org/libvirt/jna/virConnectAuth.java
b/src/org/libvirt/jna/virConnectAuth.java
deleted file mode 100644
index 8c94b6e..0000000
--- a/src/org/libvirt/jna/virConnectAuth.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.libvirt.jna;
-
-import com.sun.jna.Pointer;
-import com.sun.jna.Structure;
-
-public class virConnectAuth extends Structure {
- public int[] credtype ;
- public int ncredtype ;
- public Libvirt.VirConnectAuthCallback cb ;
- public Pointer cbdata ;
-}
diff --git a/src/org/libvirt/jna/virConnectCredential.java
b/src/org/libvirt/jna/virConnectCredential.java
deleted file mode 100644
index 1fbd5e7..0000000
--- a/src/org/libvirt/jna/virConnectCredential.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.libvirt.jna;
-
-import com.sun.jna.Structure;
-
-public class virConnectCredential extends Structure {
- public int type ;
- public String prompt ;
- public String challenge ;
- public String defresult ;
- public String[] result ;
- public int resultlen ;
-}
\ No newline at end of file
diff --git a/src/org/libvirt/jna/virDomainBlockStats.java
b/src/org/libvirt/jna/virDomainBlockStats.java
deleted file mode 100644
index 446e016..0000000
--- a/src/org/libvirt/jna/virDomainBlockStats.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.libvirt.jna;
-
-import com.sun.jna.Structure;
-
-public class virDomainBlockStats extends Structure
-{
- public long rd_req ;
- public long rd_bytes ;
- public long wr_req ;
- public long wr_bytes ;
- public long errs ;
-}
diff --git a/src/org/libvirt/jna/virDomainInfo.java
b/src/org/libvirt/jna/virDomainInfo.java
deleted file mode 100644
index 15d4836..0000000
--- a/src/org/libvirt/jna/virDomainInfo.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.libvirt.jna;
-
-import com.sun.jna.NativeLong;
-import com.sun.jna.Structure ;
-
-public class virDomainInfo extends Structure
-{
- public int state ;
- public NativeLong maxMem ;
- public NativeLong memory ;
- public short nrVirtCpu ;
- public long cpuTime ;
-}
diff --git a/src/org/libvirt/jna/virDomainInterfaceStats.java
b/src/org/libvirt/jna/virDomainInterfaceStats.java
deleted file mode 100644
index 3fda2dd..0000000
--- a/src/org/libvirt/jna/virDomainInterfaceStats.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.libvirt.jna;
-
-import com.sun.jna.Structure;
-
-public class virDomainInterfaceStats extends Structure
-{
- public long rx_bytes;
- public long rx_packets;
- public long rx_errs;
- public long rx_drop;
- public long tx_bytes;
- public long tx_packets;
- public long tx_errs;
- public long tx_drop;
-
-}
diff --git a/src/org/libvirt/jna/virError.java b/src/org/libvirt/jna/virError.java
deleted file mode 100644
index 10529fe..0000000
--- a/src/org/libvirt/jna/virError.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.libvirt.jna;
-
-import com.sun.jna.Pointer;
-import com.sun.jna.Structure ;
-
-public class virError extends Structure
-{
- public int code ;
- public int domain ;
- public String message ;
- public int level ;
- public Pointer conn ;
- public Pointer dom ;
- public String str1 ;
- public String str2 ;
- public String str3 ;
- public int int1 ;
- public int int2 ;
- public Pointer net ;
-}
diff --git a/src/org/libvirt/jna/virNodeInfo.java b/src/org/libvirt/jna/virNodeInfo.java
deleted file mode 100644
index 5a6449e..0000000
--- a/src/org/libvirt/jna/virNodeInfo.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package org.libvirt.jna;
-
-import com.sun.jna.NativeLong;
-import com.sun.jna.Structure;
-
-public class virNodeInfo extends Structure
-{
- public class ByValue extends virNodeInfo implements Structure.ByValue {};
- public class ByReference extends virNodeInfo implements Structure.ByReference {};
-
- public byte model[] = new byte[32];
- public NativeLong memory ;
- public int cpus ;
- public int mhz ;
- public int nodes ;
- public int sockets ;
- public int cores ;
- public int threads ;
-}
\ No newline at end of file
diff --git a/src/org/libvirt/jna/virSchedParameter.java
b/src/org/libvirt/jna/virSchedParameter.java
deleted file mode 100644
index f8440e1..0000000
--- a/src/org/libvirt/jna/virSchedParameter.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.libvirt.jna;
-
-import com.sun.jna.Structure;
-
-public class virSchedParameter extends Structure
-{
- public byte field[] = new byte[Libvirt.VIR_DOMAIN_SCHED_FIELD_LENGTH] ;
- public int type ;
- public virSchedParameterValue value ;
-
-}
diff --git a/src/org/libvirt/jna/virSchedParameterValue.java
b/src/org/libvirt/jna/virSchedParameterValue.java
deleted file mode 100644
index ff2cdfc..0000000
--- a/src/org/libvirt/jna/virSchedParameterValue.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.libvirt.jna;
-
-import com.sun.jna.Structure;
-
-public class virSchedParameterValue extends Structure
-{
- public int i; /* data for integer case */
- public int ui; /* data for unsigned integer case */
- public long l; /* data for long long integer case */
- public long ul; /* data for unsigned long long integer case */
- public double d; /* data for double case */
- public byte b; /* data for char case */
-}
diff --git a/src/org/libvirt/jna/virStoragePoolInfo.java
b/src/org/libvirt/jna/virStoragePoolInfo.java
deleted file mode 100644
index 78915ff..0000000
--- a/src/org/libvirt/jna/virStoragePoolInfo.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.libvirt.jna;
-
-import com.sun.jna.Structure;
-
-public class virStoragePoolInfo extends Structure
-{
- public int state ;
- public long capacity ;
- public long allocation ;
- public long available ;
-}
diff --git a/src/org/libvirt/jna/virStorageVolInfo.java
b/src/org/libvirt/jna/virStorageVolInfo.java
deleted file mode 100644
index 598f28a..0000000
--- a/src/org/libvirt/jna/virStorageVolInfo.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.libvirt.jna;
-
-import com.sun.jna.Structure;
-
-public class virStorageVolInfo extends Structure
-{
- public int type ;
- public long capacity ;
- public long allocation ;
-
-}
\ No newline at end of file
diff --git a/src/org/libvirt/jna/virVcpuInfo.java b/src/org/libvirt/jna/virVcpuInfo.java
deleted file mode 100644
index ba72ce8..0000000
--- a/src/org/libvirt/jna/virVcpuInfo.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.libvirt.jna;
-
-import com.sun.jna.Structure;
-
-public class virVcpuInfo extends Structure
-{
- public int number ;
- public int state ;
- public long cpuTime ;
- public int cpu ;
-
-}
diff --git a/src/test.java b/src/test.java
deleted file mode 100644
index 24ed75e..0000000
--- a/src/test.java
+++ /dev/null
@@ -1,269 +0,0 @@
-import org.libvirt.*;
-
-public class test {
-
- public static String FIXME = "<============== FIXME ================>
" ;
- /**
- * @param args
- */
- public static void main(String[] args) {
- //Create the connection
- Connect conn=null;
- Network testNetwork=null;
-
- //Need this for the lookup method testing, it's absolutely horrible in java, but
let's be complete
- int UUID[] = {Integer.decode("0x00"), Integer.decode("0x4b"),
Integer.decode("0x96"), Integer.decode("0xe1"),
- Integer.decode("0x2d"), Integer.decode("0x78"),
- Integer.decode("0xc3"), Integer.decode("0x0f"),
- Integer.decode("0x5a"), Integer.decode("0xa5"),
- Integer.decode("0xf0"), Integer.decode("0x3c"),
Integer.decode("0x87"), Integer.decode("0xd2"),
Integer.decode("0x1e"), Integer.decode("0x67")} ;
-
- //For testing the authentication
- ConnectAuth defaultAuth = new ConnectAuthDefault();
-
- //You need to configure your libvirtd for remote/authenticated connections, and adjust
the URL below
- //for this to work. Otherwise, you'll get an error
- try{
- conn = new Connect("test+tcp://localhost/default", defaultAuth, 0);
- System.out.println("Encrypted connection successful!");
- } catch (LibvirtException e){
- System.out.println("exception caught:"+e);
- System.out.println(e.getError());
- }
-
- try{
- conn = new Connect("test:///default", false);
- //conn = new Connect("qemu:///system", false) ;
- } catch (LibvirtException e){
- System.out.println("exception caught:"+e);
- System.out.println(e.getError());
- }
- try{
- //Check nodeinfo
- NodeInfo nodeInfo=conn.nodeInfo();
- System.out.println("virNodeInfo.model:" + nodeInfo.model);
- System.out.println("virNodeInfo.memory:" + nodeInfo.memory);
- System.out.println("virNodeInfo.cpus:" + nodeInfo.cpus);
- System.out.println("virNodeInfo.nodes:" + nodeInfo.nodes);
- System.out.println("virNodeInfo.sockets:" + nodeInfo.sockets);
- System.out.println("virNodeInfo.cores:" + nodeInfo.cores);
- System.out.println("virNodeInfo.threads:" + nodeInfo.threads);
-
- //Exercise the information getter methods
- System.out.println("getHostName:" + conn.getHostName());
- System.out.println("getCapabilities:" + conn.getCapabilities());
- System.out.println("getMaxVcpus:" + conn.getMaxVcpus("xen"));
- System.out.println("getType:" + conn.getType());
- System.out.println("getURI:" + conn.getURI());
- System.out.println("getVersion:" + conn.getVersion());
- System.out.println("getLibVirVersion:" +
conn.getLibVirVersion());
-
- //By default, there are 1 created and 0 defined networks
-
- //Create a new network to test the create method
- System.out.println("conn.networkCreateXML:
"+conn.networkCreateXML("<network>" +
- " <name>createst</name>"+
- " <uuid>004b96e1-2d78-c30f-5aa5-f03c87d21e68</uuid>"+
- " <bridge name='createst'/>"+
- " <forward dev='eth0'/>"+
- " <ip address='192.168.66.1'
netmask='255.255.255.0'>"+
- " <dhcp>"+
- " <range start='192.168.66.128'
end='192.168.66.253'/>"+
- " </dhcp>"+
- " </ip>"+
- "</network>"));
-
- //Same for the define method
- System.out.println("conn.networkDefineXML:
"+conn.networkDefineXML("<network>" +
- " <name>deftest</name>"+
- " <uuid>004b96e1-2d78-c30f-5aa5-f03c87d21e67</uuid>"+
- " <bridge name='deftest'/>"+
- " <forward dev='eth0'/>"+
- " <ip address='192.168.88.1'
netmask='255.255.255.0'>"+
- " <dhcp>"+
- " <range start='192.168.88.128'
end='192.168.88.253'/>"+
- " </dhcp>"+
- " </ip>"+
- "</network>"));
-
- //We should have 2:1 but it shows up 3:0 hopefully a bug in the test driver
- System.out.println("numOfDefinedNetworks:" + conn.numOfDefinedNetworks());
- System.out.println("listDefinedNetworks:" + conn.listDefinedNetworks());
- for(String c: conn.listDefinedNetworks())
- System.out.println(" -> "+c);
- System.out.println("numOfNetworks:" + conn.numOfNetworks());
- System.out.println("listNetworks:" + conn.listNetworks());
- for(String c: conn.listNetworks())
- System.out.println(" -> "+c);
-
- //Define a new Domain
- System.out.println("conn.domainDefineXML:"+conn.domainDefineXML("<domain
type='test' id='2'>"+
- " <name>deftest</name>"+
- " <uuid>004b96e1-2d78-c30f-5aa5-f03c87d21e70</uuid>"+
- " <memory>8388608</memory>"+
- " <vcpu>2</vcpu>"+
- " <os><type arch='i686'>hvm</type></os>"
+
- " <on_reboot>restart</on_reboot>"+
- " <on_poweroff>destroy</on_poweroff>"+
- " <on_crash>restart</on_crash>"+
- "</domain>"));
-
- System.out.println("conn.domainCreateLinux:"+conn.domainCreateLinux("<domain
type='test' id='3'>"+
- " <name>createst</name>"+
- " <uuid>004b96e1-2d78-c30f-5aa5-f03c87d21e71</uuid>"+
- " <memory>8388608</memory>"+
- " <vcpu>2</vcpu>"+
- " <os><type
arch='i686'>hvm</type></os>" +
- " <on_reboot>restart</on_reboot>"+
- " <on_poweroff>destroy</on_poweroff>"+
- " <on_crash>restart</on_crash>"+
- "</domain>",0));
-
- //Domain enumeration stuff
- System.out.println("numOfDefinedDomains:" + conn.numOfDefinedDomains());
- System.out.println("listDefinedDomains:" + conn.listDefinedDomains());
- for(String c: conn.listDefinedDomains())
- System.out.println(" "+c);
- System.out.println("numOfDomains:" + conn.numOfDomains());
- System.out.println("listDomains:" + conn.listDomains());
- for(int c: conn.listDomains())
- System.out.println(" -> "+c);
-
-
- } catch (LibvirtException e){
- System.out.println("exception caught:"+e);
- System.out.println(e.getError());
- }
-
- //Network Object
-
- try{
- //Choose one, they should have the exact same effect
- testNetwork = conn.networkLookupByName("deftest") ;
- System.out.println("networkLookupByName: " + testNetwork.getName()) ;
- System.out.println(FIXME) ;
-// testNetwork=conn.networkLookupByUUID(UUID);
-// System.out.println("networkLookupByUUID: " +
testNetwork.getName()) ;
- testNetwork =
conn.networkLookupByUUIDString("004b96e1-2d78-c30f-5aa5-f03c87d21e67");
- System.out.println("networkLookupByUUIDString: " +
testNetwork.getName()) ;
-
- //Exercise the getter methods on the default network
- System.out.println("virNetworkGetXMLDesc:" + testNetwork.getXMLDesc(0));
- System.out.println("virNetworkGetAutostart:" + testNetwork.getAutostart());
- System.out.println("virNetworkGetBridgeName:" +
testNetwork.getBridgeName());
- System.out.println("virNetworkGetName:" + testNetwork.getName());
- System.out.println("virNetworkGetUUID:" + testNetwork.getUUID() + "
");
- System.out.println(FIXME) ;
- for(int c: testNetwork.getUUID())
- System.out.print(String.format("%02x", c));
- System.out.println();
- System.out.println("virNetworkGetName:" + testNetwork.getUUIDString());
-
- //Destroy and create the network
- System.out.println("virNetworkDestroy:"); testNetwork.destroy();
- System.out.println("virNetworkCreate:"); testNetwork.create();
- } catch (LibvirtException e){
- System.out.println("exception caught:"+e);
- System.out.println(e.getError());
- }
- //This should raise an excpetion
- try{
- System.out.println("virNetworkCreate (should error):");
- testNetwork.create();
- } catch (LibvirtException e){
- System.out.println("exception caught:"+e);
- System.out.println(e.getError());
- }
-
- //Domain stuff
-
- try{
-//
-//
-// //Domain lookup
- //Domain testDomain=conn.domainLookupByID(1);
- //Domain testDomain=conn.domainLookupByName("test");
- //Domain
testDomain=conn.domainLookupByUUIDString("004b96e1-2d78-c30f-5aa5-f03c87d21e69");
- Domain testDomain = conn.domainLookupByID(1);
- System.out.println("domainLookupByID: " + testDomain) ;
- testDomain = conn.domainLookupByName("test");
- System.out.println("domainLookupByName: " + testDomain) ;
-// Domain testDomain=conn.domainLookupByUUID(UUID);
-// System.out.println("domainLookupByUUID: " + testDomain) ;
-
- //Exercise the getter methods on the default domain
- System.out.println("virDomainGetXMLDesc:" + testDomain.getXMLDesc(0));
- System.out.println("virDomainGetAutostart:" + testDomain.getAutostart());
- System.out.println("virDomainGetConnect:" + testDomain.getConnect());
- System.out.println("virDomainGetID:" + testDomain.getID());
- System.out.println("virDomainGetInfo:" + testDomain.getInfo());
- System.out.println("virDomainGetMaxMemory:" + testDomain.getMaxMemory());
- //Should fail, test driver does not support it
- try {
- System.out.println("virDomainGetMaxVcpus:" + testDomain.getMaxVcpus());
- System.out.println(FIXME) ;
- }
- catch (LibvirtException e) {
-
- }
- System.out.println("virDomainGetName:" + testDomain.getName());
- System.out.println("virDomainGetOSType:" + testDomain.getOSType());
- System.out.println("virDomainGetSchedulerType:" +
testDomain.getSchedulerType());
- System.out.println("virDomainGetSchedulerParameters:" +
testDomain.getSchedulerParameters());
- //Iterate over the parameters the painful way
- for(SchedParameter c: testDomain.getSchedulerParameters()){
- if (c instanceof SchedIntParameter)
- System.out.println("Int:" + ((SchedIntParameter)c).field +":"+
((SchedIntParameter)c).value);
- if (c instanceof SchedUintParameter)
- System.out.println("Uint:" + ((SchedUintParameter)c).field
+":"+ ((SchedUintParameter)c).value);
- if (c instanceof SchedLongParameter)
- System.out.println("Long:" + ((SchedLongParameter)c).field
+":"+ ((SchedLongParameter)c).value);
- if (c instanceof SchedUlongParameter)
- System.out.println("Ulong:" + ((SchedUlongParameter)c).field
+":"+ ((SchedUlongParameter)c).value);
- if (c instanceof SchedDoubleParameter)
- System.out.println("Double:" + ((SchedDoubleParameter)c).field
+":"+ ((SchedDoubleParameter)c).value);
- if (c instanceof SchedBooleanParameter)
- System.out.println("Boolean:" + ((SchedBooleanParameter)c).field
+":"+ ((SchedBooleanParameter)c).value);
- }
- //Iterate over the parameters the easy way
- for(SchedParameter c: testDomain.getSchedulerParameters()){
- System.out.println(c.getTypeAsString() +":"+ c.field +":"+
c.getValueAsString());
- }
- System.out.println("virDomainGetUUID:" + testDomain.getUUID());
- System.out.println(FIXME) ;
- for(int c: testDomain.getUUID())
- System.out.print(String.format("%02x", c));
- System.out.println();
- System.out.println("virDomainGetUUIDString:" + testDomain.getUUIDString());
- //Should fail, unimplemented in test driver
- //System.out.println("virDomainGetVcpusInfo:" + testDomain.getVcpusInfo());
- //Same as above
- //System.out.println("virDomainGetVcpusCpuMap:" +
testDomain.getVcpusCpuMaps());
- //Should test pinVcpu, when we test with real xen
- //Here
- //Attach default network to test domain
- //System.out.println("virDomainGetVcpusCpuMap:" +
testDomain.getVcpusCpuMaps());
-
- //Should test interfacestats and blockstats with real xen
-
- //Close the connection
-
- conn.close();
- } catch (LibvirtException e){
- System.out.println("exception caught:"+e);
- System.out.println(e.getError());
- }
-
-
-
- try{
- //We should get an exception, not a crash
- System.out.println(conn.getHostName());
- }catch (LibvirtException e){
- System.out.println("exception caught:"+e);
- System.out.println(e.getError());
- }
- System.out.println("Fini!");
- }
-
-}
diff --git a/src/test/java/test.java b/src/test/java/test.java
new file mode 100644
index 0000000..793888b
--- /dev/null
+++ b/src/test/java/test.java
@@ -0,0 +1,269 @@
+import org.libvirt.*;
+
+public class test {
+
+ public static String FIXME = "<============== FIXME ================>
" ;
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ //Create the connection
+ Connect conn=null;
+ Network testNetwork=null;
+
+ //Need this for the lookup method testing, it's absolutely horrible in java, but
let's be complete
+ int UUID[] = {Integer.decode("0x00"), Integer.decode("0x4b"),
Integer.decode("0x96"), Integer.decode("0xe1"),
+ Integer.decode("0x2d"), Integer.decode("0x78"),
+ Integer.decode("0xc3"), Integer.decode("0x0f"),
+ Integer.decode("0x5a"), Integer.decode("0xa5"),
+ Integer.decode("0xf0"), Integer.decode("0x3c"),
Integer.decode("0x87"), Integer.decode("0xd2"),
Integer.decode("0x1e"), Integer.decode("0x67")} ;
+
+ //For testing the authentication
+ ConnectAuth defaultAuth = new ConnectAuthDefault();
+
+ //You need to configure your libvirtd for remote/authenticated connections, and adjust
the URL below
+ //for this to work. Otherwise, you'll get an error
+ try{
+ conn = new Connect("test+tcp://localhost/default", defaultAuth, 0);
+ //conn = new Connect("test:///default", defaultAuth, 0);
+ System.out.println("Encrypted connection successful!");
+ } catch (LibvirtException e){
+ System.out.println("exception caught:"+e);
+ System.out.println(e.getError());
+ }
+
+ try{
+ conn = new Connect("test:///default", false);
+ } catch (LibvirtException e){
+ System.out.println("exception caught:"+e);
+ System.out.println(e.getError());
+ }
+ try{
+ //Check nodeinfo
+ NodeInfo nodeInfo=conn.nodeInfo();
+ System.out.println("virNodeInfo.model:" + nodeInfo.model);
+ System.out.println("virNodeInfo.memory:" + nodeInfo.memory);
+ System.out.println("virNodeInfo.cpus:" + nodeInfo.cpus);
+ System.out.println("virNodeInfo.nodes:" + nodeInfo.nodes);
+ System.out.println("virNodeInfo.sockets:" + nodeInfo.sockets);
+ System.out.println("virNodeInfo.cores:" + nodeInfo.cores);
+ System.out.println("virNodeInfo.threads:" + nodeInfo.threads);
+
+ //Exercise the information getter methods
+ System.out.println("getHostName:" + conn.getHostName());
+ System.out.println("getCapabilities:" + conn.getCapabilities());
+ System.out.println("getMaxVcpus:" + conn.getMaxVcpus("xen"));
+ System.out.println("getType:" + conn.getType());
+ System.out.println("getURI:" + conn.getURI());
+ System.out.println("getVersion:" + conn.getVersion());
+ System.out.println("getLibVirVersion:" +
conn.getLibVirVersion());
+
+ //By default, there are 1 created and 0 defined networks
+
+ //Create a new network to test the create method
+ System.out.println("conn.networkCreateXML:
"+conn.networkCreateXML("<network>" +
+ " <name>createst</name>"+
+ " <uuid>004b96e1-2d78-c30f-5aa5-f03c87d21e68</uuid>"+
+ " <bridge name='createst'/>"+
+ " <forward dev='eth0'/>"+
+ " <ip address='192.168.66.1'
netmask='255.255.255.0'>"+
+ " <dhcp>"+
+ " <range start='192.168.66.128'
end='192.168.66.253'/>"+
+ " </dhcp>"+
+ " </ip>"+
+ "</network>"));
+
+ //Same for the define method
+ System.out.println("conn.networkDefineXML:
"+conn.networkDefineXML("<network>" +
+ " <name>deftest</name>"+
+ " <uuid>004b96e1-2d78-c30f-5aa5-f03c87d21e67</uuid>"+
+ " <bridge name='deftest'/>"+
+ " <forward dev='eth0'/>"+
+ " <ip address='192.168.88.1'
netmask='255.255.255.0'>"+
+ " <dhcp>"+
+ " <range start='192.168.88.128'
end='192.168.88.253'/>"+
+ " </dhcp>"+
+ " </ip>"+
+ "</network>"));
+
+ //We should have 2:1 but it shows up 3:0 hopefully a bug in the test driver
+ System.out.println("numOfDefinedNetworks:" + conn.numOfDefinedNetworks());
+ System.out.println("listDefinedNetworks:" + conn.listDefinedNetworks());
+ for(String c: conn.listDefinedNetworks())
+ System.out.println(" -> "+c);
+ System.out.println("numOfNetworks:" + conn.numOfNetworks());
+ System.out.println("listNetworks:" + conn.listNetworks());
+ for(String c: conn.listNetworks())
+ System.out.println(" -> "+c);
+
+ //Define a new Domain
+ System.out.println("conn.domainDefineXML:"+conn.domainDefineXML("<domain
type='test' id='2'>"+
+ " <name>deftest</name>"+
+ " <uuid>004b96e1-2d78-c30f-5aa5-f03c87d21e70</uuid>"+
+ " <memory>8388608</memory>"+
+ " <vcpu>2</vcpu>"+
+ " <os><type arch='i686'>hvm</type></os>"
+
+ " <on_reboot>restart</on_reboot>"+
+ " <on_poweroff>destroy</on_poweroff>"+
+ " <on_crash>restart</on_crash>"+
+ "</domain>"));
+
+ System.out.println("conn.domainCreateLinux:"+conn.domainCreateLinux("<domain
type='test' id='3'>"+
+ " <name>createst</name>"+
+ " <uuid>004b96e1-2d78-c30f-5aa5-f03c87d21e71</uuid>"+
+ " <memory>8388608</memory>"+
+ " <vcpu>2</vcpu>"+
+ " <os><type
arch='i686'>hvm</type></os>" +
+ " <on_reboot>restart</on_reboot>"+
+ " <on_poweroff>destroy</on_poweroff>"+
+ " <on_crash>restart</on_crash>"+
+ "</domain>",0));
+
+ //Domain enumeration stuff
+ System.out.println("numOfDefinedDomains:" + conn.numOfDefinedDomains());
+ System.out.println("listDefinedDomains:" + conn.listDefinedDomains());
+ for(String c: conn.listDefinedDomains())
+ System.out.println(" "+c);
+ System.out.println("numOfDomains:" + conn.numOfDomains());
+ System.out.println("listDomains:" + conn.listDomains());
+ for(int c: conn.listDomains())
+ System.out.println(" -> "+c);
+
+
+ } catch (LibvirtException e){
+ System.out.println("exception caught:"+e);
+ System.out.println(e.getError());
+ }
+
+ //Network Object
+
+ try{
+ //Choose one, they should have the exact same effect
+ testNetwork = conn.networkLookupByName("deftest") ;
+ System.out.println("networkLookupByName: " + testNetwork.getName()) ;
+ System.out.println(FIXME) ;
+// testNetwork=conn.networkLookupByUUID(UUID);
+// System.out.println("networkLookupByUUID: " +
testNetwork.getName()) ;
+ testNetwork =
conn.networkLookupByUUIDString("004b96e1-2d78-c30f-5aa5-f03c87d21e67");
+ System.out.println("networkLookupByUUIDString: " +
testNetwork.getName()) ;
+
+ //Exercise the getter methods on the default network
+ System.out.println("virNetworkGetXMLDesc:" + testNetwork.getXMLDesc(0));
+ System.out.println("virNetworkGetAutostart:" + testNetwork.getAutostart());
+ System.out.println("virNetworkGetBridgeName:" +
testNetwork.getBridgeName());
+ System.out.println("virNetworkGetName:" + testNetwork.getName());
+ System.out.println("virNetworkGetUUID:" + testNetwork.getUUID() + "
");
+ System.out.println(FIXME) ;
+ for(int c: testNetwork.getUUID())
+ System.out.print(String.format("%02x", c));
+ System.out.println();
+ System.out.println("virNetworkGetName:" + testNetwork.getUUIDString());
+
+ //Destroy and create the network
+ System.out.println("virNetworkDestroy:"); testNetwork.destroy();
+ System.out.println("virNetworkCreate:"); testNetwork.create();
+ } catch (LibvirtException e){
+ System.out.println("exception caught:"+e);
+ System.out.println(e.getError());
+ }
+ //This should raise an excpetion
+ try{
+ System.out.println("virNetworkCreate (should error):");
+ testNetwork.create();
+ } catch (LibvirtException e){
+ System.out.println("exception caught:"+e);
+ System.out.println(e.getError());
+ }
+
+ //Domain stuff
+
+ try{
+//
+//
+// //Domain lookup
+ //Domain testDomain=conn.domainLookupByID(1);
+ //Domain testDomain=conn.domainLookupByName("test");
+ //Domain
testDomain=conn.domainLookupByUUIDString("004b96e1-2d78-c30f-5aa5-f03c87d21e69");
+ Domain testDomain = conn.domainLookupByID(1);
+ System.out.println("domainLookupByID: " + testDomain) ;
+ testDomain = conn.domainLookupByName("test");
+ System.out.println("domainLookupByName: " + testDomain) ;
+// Domain testDomain=conn.domainLookupByUUID(UUID);
+// System.out.println("domainLookupByUUID: " + testDomain) ;
+
+ //Exercise the getter methods on the default domain
+ System.out.println("virDomainGetXMLDesc:" + testDomain.getXMLDesc(0));
+ System.out.println("virDomainGetAutostart:" + testDomain.getAutostart());
+ System.out.println("virDomainGetConnect:" + testDomain.getConnect());
+ System.out.println("virDomainGetID:" + testDomain.getID());
+ System.out.println("virDomainGetInfo:" + testDomain.getInfo());
+ System.out.println("virDomainGetMaxMemory:" + testDomain.getMaxMemory());
+ //Should fail, test driver does not support it
+ try {
+ System.out.println("virDomainGetMaxVcpus:" + testDomain.getMaxVcpus());
+ System.out.println(FIXME) ;
+ }
+ catch (LibvirtException e) {
+
+ }
+ System.out.println("virDomainGetName:" + testDomain.getName());
+ System.out.println("virDomainGetOSType:" + testDomain.getOSType());
+ System.out.println("virDomainGetSchedulerType:" +
testDomain.getSchedulerType());
+ System.out.println("virDomainGetSchedulerParameters:" +
testDomain.getSchedulerParameters());
+ //Iterate over the parameters the painful way
+ for(SchedParameter c: testDomain.getSchedulerParameters()){
+ if (c instanceof SchedIntParameter)
+ System.out.println("Int:" + ((SchedIntParameter)c).field +":"+
((SchedIntParameter)c).value);
+ if (c instanceof SchedUintParameter)
+ System.out.println("Uint:" + ((SchedUintParameter)c).field
+":"+ ((SchedUintParameter)c).value);
+ if (c instanceof SchedLongParameter)
+ System.out.println("Long:" + ((SchedLongParameter)c).field
+":"+ ((SchedLongParameter)c).value);
+ if (c instanceof SchedUlongParameter)
+ System.out.println("Ulong:" + ((SchedUlongParameter)c).field
+":"+ ((SchedUlongParameter)c).value);
+ if (c instanceof SchedDoubleParameter)
+ System.out.println("Double:" + ((SchedDoubleParameter)c).field
+":"+ ((SchedDoubleParameter)c).value);
+ if (c instanceof SchedBooleanParameter)
+ System.out.println("Boolean:" + ((SchedBooleanParameter)c).field
+":"+ ((SchedBooleanParameter)c).value);
+ }
+ //Iterate over the parameters the easy way
+ for(SchedParameter c: testDomain.getSchedulerParameters()){
+ System.out.println(c.getTypeAsString() +":"+ c.field +":"+
c.getValueAsString());
+ }
+ System.out.println("virDomainGetUUID:" + testDomain.getUUID());
+ System.out.println(FIXME) ;
+ for(int c: testDomain.getUUID())
+ System.out.print(String.format("%02x", c));
+ System.out.println();
+ System.out.println("virDomainGetUUIDString:" + testDomain.getUUIDString());
+ //Should fail, unimplemented in test driver
+ //System.out.println("virDomainGetVcpusInfo:" + testDomain.getVcpusInfo());
+ //Same as above
+ //System.out.println("virDomainGetVcpusCpuMap:" +
testDomain.getVcpusCpuMaps());
+ //Should test pinVcpu, when we test with real xen
+ //Here
+ //Attach default network to test domain
+ //System.out.println("virDomainGetVcpusCpuMap:" +
testDomain.getVcpusCpuMaps());
+
+ //Should test interfacestats and blockstats with real xen
+
+ //Close the connection
+
+ conn.close();
+ } catch (LibvirtException e){
+ System.out.println("exception caught:"+e);
+ System.out.println(e.getError());
+ }
+
+
+
+ try{
+ //We should get an exception, not a crash
+ System.out.println(conn.getHostName());
+ }catch (LibvirtException e){
+ System.out.println("exception caught:"+e);
+ System.out.println(e.getError());
+ }
+ System.out.println("Fini!");
+ }
+
+}
diff --git a/test.sh b/test.sh
new file mode 100755
index 0000000..a0711ab
--- /dev/null
+++ b/test.sh
@@ -0,0 +1,4 @@
+CLASSPATH=./target/classes:./target/testclasses:/usr/share/java/jna.jar
+#CLASSPATH=./target/classes:/home/bkearney/Download/jna-3.2.0.jar
+java -classpath $CLASSPATH test
+
--
1.6.0.6