[libvirt] (no subject)
by cbley@av-test.de
>From 98a7ebaee92eb92fb7ee4a9f06097aec8c626468 Mon Sep 17 00:00:00 2001
Message-Id: <98a7ebaee92eb92fb7ee4a9f06097aec8c626468.1350037981.git.cbley(a)av-test.de>
In-Reply-To: <cover.1350037981.git.cbley(a)av-test.de>
References: <2DA6F4A3691599408358374D182280F9141CF6(a)xmb-rcd-x04.cisco.com> <cover.1350037981.git.cbley(a)av-test.de>
From: cbley(a)av-test.de (Claudio Bley)
Date: Mon, 20 Aug 2012 15:18:46 +0200
Subject: [PATCH 05/15] Remove redundant public modifier from Libvirt interface methods.
To: libvir-list(a)redhat.com
Organization: AV-Test GmbH, Germany
This prevents errors reported by checkstyle, see
http://checkstyle.sourceforge.net/config_modifier.html#RedundantModifier
JSL 9.4: It is permitted, but discouraged as a matter of style, to
redundantly specify the public and/or abstract modifier for a method
declared in an interface.
---
src/main/java/org/libvirt/jna/Libvirt.java | 486 ++++++++++++++--------------
1 file changed, 243 insertions(+), 243 deletions(-)
diff --git a/src/main/java/org/libvirt/jna/Libvirt.java b/src/main/java/org/libvirt/jna/Libvirt.java
index e68d9ed..02457b7 100644
--- a/src/main/java/org/libvirt/jna/Libvirt.java
+++ b/src/main/java/org/libvirt/jna/Libvirt.java
@@ -64,40 +64,40 @@ public interface Libvirt extends Library {
* Callback interface for authorization
*/
interface VirConnectAuthCallback extends Callback {
- public int authCallback(virConnectCredential cred, int ncred, Pointer cbdata);
+ int authCallback(virConnectCredential cred, int ncred, Pointer cbdata);
}
/**
* Error callback
*/
interface VirErrorCallback extends Callback {
- public void errorCallback(Pointer userData, virError error);
+ void errorCallback(Pointer userData, virError error);
}
/**
* Stream callbacks
*/
interface VirStreamSinkFunc extends Callback {
- public int sinkCallback(StreamPointer virStreamPtr, String data, NativeLong nbytes, Pointer opaque) ;
+ int sinkCallback(StreamPointer virStreamPtr, String data, NativeLong nbytes, Pointer opaque) ;
}
interface VirStreamSourceFunc extends Callback {
- public int sourceCallback(StreamPointer virStreamPtr, String data, NativeLong nbytes, Pointer opaque) ;
+ int sourceCallback(StreamPointer virStreamPtr, String data, NativeLong nbytes, Pointer opaque) ;
}
interface VirStreamEventCallback extends Callback {
- public void eventCallback(StreamPointer virStreamPointer, int events, Pointer opaque) ;
+ void eventCallback(StreamPointer virStreamPointer, int events, Pointer opaque) ;
}
/**
* Generic Callbacks
*/
interface VirFreeCallback extends Callback {
- public void freeCallback(Pointer opaque) ;
+ void freeCallback(Pointer opaque) ;
}
interface VirConnectDomainEventGenericCallback extends Callback {
- public void eventCallback(ConnectionPointer virConnectPtr, DomainPointer virDomainPointer, Pointer opaque) ;
+ void eventCallback(ConnectionPointer virConnectPtr, DomainPointer virDomainPointer, Pointer opaque) ;
}
Libvirt INSTANCE = (Libvirt) Native.loadLibrary("virt", Libvirt.class);
@@ -108,274 +108,274 @@ public interface Libvirt extends Library {
public static int VIR_DOMAIN_SCHED_FIELD_LENGTH = 80;
// Connection Functions
- public String virConnectBaselineCPU(ConnectionPointer virConnectPtr, String[] xmlCPUs, int ncpus, int flags);
- public int virConnCopyLastError(ConnectionPointer virConnectPtr, virError to);
- public int virConnectClose(ConnectionPointer virConnectPtr);
- public int virConnectCompareCPU(ConnectionPointer virConnectPtr, String xmlDesc, int flags);
- public int virConnectDomainEventRegisterAny(ConnectionPointer virConnectPtr, DomainPointer virDomainPtr, int eventID, Libvirt.VirConnectDomainEventGenericCallback cb, Pointer opaque, Libvirt.VirFreeCallback freecb);
- public int virConnectDomainEventDeregisterAny(ConnectionPointer virConnectPtr, int callbackID) ;
- public void virConnSetErrorFunc(ConnectionPointer virConnectPtr, Pointer userData, VirErrorCallback callback);
- public int virConnectIsEncrypted(ConnectionPointer virConnectPtr) ;
- public int virConnectIsSecure(ConnectionPointer virConnectPtr) ;
- public String virConnectFindStoragePoolSources(ConnectionPointer virConnectPtr, String type, String srcSpec, int flags);
- public String virConnectGetCapabilities(ConnectionPointer virConnectPtr);
- public String virConnectGetHostname(ConnectionPointer virConnectPtr);
- public int virConnectGetLibVersion(ConnectionPointer virConnectPtr, LongByReference libVer);
- 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 virConnectListDefinedDomains(ConnectionPointer virConnectPtr, String[] name, int maxnames);
- public int virConnectListDefinedNetworks(ConnectionPointer virConnectPtr, String[] name, int maxnames);
- public int virConnectListDefinedStoragePools(ConnectionPointer virConnectPtr, String[] names, int maxnames);
- public int virConnectListDefinedInterfaces(ConnectionPointer virConnectPtr, String[] name, int maxNames);
- public int virConnectListDomains(ConnectionPointer virConnectPtr, int[] ids, int maxnames);
- public int virConnectListInterfaces(ConnectionPointer virConnectPtr, String[] name, int maxNames);
- public int virConnectListNetworks(ConnectionPointer virConnectPtr, String[] name, int maxnames);
- public int virConnectListNWFilters(ConnectionPointer virConnectPtr, String[] name, int maxnames);
- public int virConnectListSecrets(ConnectionPointer virConnectPtr, String[] uids, int maxUids);
- public int virConnectListStoragePools(ConnectionPointer virConnectPtr, String[] names, int maxnames);
- public int virConnectNumOfDefinedDomains(ConnectionPointer virConnectPtr);
- public int virConnectNumOfDefinedNetworks(ConnectionPointer virConnectPtr);
- public int virConnectNumOfDefinedInterfaces(ConnectionPointer virConnectPtr);
- public int virConnectNumOfDefinedStoragePools(ConnectionPointer virConnectPtr);
- public int virConnectNumOfDomains(ConnectionPointer virConnectPtr);
- public int virConnectNumOfInterfaces(ConnectionPointer virConnectPtr);
- public int virConnectNumOfNetworks(ConnectionPointer virConnectPtr);
- public int virConnectNumOfNWFilters(ConnectionPointer virConnectPtr);
- public int virConnectNumOfSecrets(ConnectionPointer virConnectPtr);
- public int virConnectNumOfStoragePools(ConnectionPointer virConnectPtr);
- public ConnectionPointer virConnectOpen(String name);
- public ConnectionPointer virConnectOpenAuth(String name, virConnectAuth auth, int flags);
- public ConnectionPointer virConnectOpenReadOnly(String name);
- public virError virConnGetLastError(ConnectionPointer virConnectPtr);
- public int virConnResetLastError(ConnectionPointer virConnectPtr);
- public String virConnectDomainXMLFromNative(ConnectionPointer virConnectPtr, String nativeFormat,
+ String virConnectBaselineCPU(ConnectionPointer virConnectPtr, String[] xmlCPUs, int ncpus, int flags);
+ int virConnCopyLastError(ConnectionPointer virConnectPtr, virError to);
+ int virConnectClose(ConnectionPointer virConnectPtr);
+ int virConnectCompareCPU(ConnectionPointer virConnectPtr, String xmlDesc, int flags);
+ int virConnectDomainEventRegisterAny(ConnectionPointer virConnectPtr, DomainPointer virDomainPtr, int eventID, Libvirt.VirConnectDomainEventGenericCallback cb, Pointer opaque, Libvirt.VirFreeCallback freecb);
+ int virConnectDomainEventDeregisterAny(ConnectionPointer virConnectPtr, int callbackID) ;
+ void virConnSetErrorFunc(ConnectionPointer virConnectPtr, Pointer userData, VirErrorCallback callback);
+ int virConnectIsEncrypted(ConnectionPointer virConnectPtr) ;
+ int virConnectIsSecure(ConnectionPointer virConnectPtr) ;
+ String virConnectFindStoragePoolSources(ConnectionPointer virConnectPtr, String type, String srcSpec, int flags);
+ String virConnectGetCapabilities(ConnectionPointer virConnectPtr);
+ String virConnectGetHostname(ConnectionPointer virConnectPtr);
+ int virConnectGetLibVersion(ConnectionPointer virConnectPtr, LongByReference libVer);
+ int virConnectGetMaxVcpus(ConnectionPointer virConnectPtr, String type);
+ String virConnectGetType(ConnectionPointer virConnectPtr);
+ String virConnectGetURI(ConnectionPointer virConnectPtr);
+ int virConnectGetVersion(ConnectionPointer virConnectPtr, LongByReference hvVer);
+ int virConnectListDefinedDomains(ConnectionPointer virConnectPtr, String[] name, int maxnames);
+ int virConnectListDefinedNetworks(ConnectionPointer virConnectPtr, String[] name, int maxnames);
+ int virConnectListDefinedStoragePools(ConnectionPointer virConnectPtr, String[] names, int maxnames);
+ int virConnectListDefinedInterfaces(ConnectionPointer virConnectPtr, String[] name, int maxNames);
+ int virConnectListDomains(ConnectionPointer virConnectPtr, int[] ids, int maxnames);
+ int virConnectListInterfaces(ConnectionPointer virConnectPtr, String[] name, int maxNames);
+ int virConnectListNetworks(ConnectionPointer virConnectPtr, String[] name, int maxnames);
+ int virConnectListNWFilters(ConnectionPointer virConnectPtr, String[] name, int maxnames);
+ int virConnectListSecrets(ConnectionPointer virConnectPtr, String[] uids, int maxUids);
+ int virConnectListStoragePools(ConnectionPointer virConnectPtr, String[] names, int maxnames);
+ int virConnectNumOfDefinedDomains(ConnectionPointer virConnectPtr);
+ int virConnectNumOfDefinedNetworks(ConnectionPointer virConnectPtr);
+ int virConnectNumOfDefinedInterfaces(ConnectionPointer virConnectPtr);
+ int virConnectNumOfDefinedStoragePools(ConnectionPointer virConnectPtr);
+ int virConnectNumOfDomains(ConnectionPointer virConnectPtr);
+ int virConnectNumOfInterfaces(ConnectionPointer virConnectPtr);
+ int virConnectNumOfNetworks(ConnectionPointer virConnectPtr);
+ int virConnectNumOfNWFilters(ConnectionPointer virConnectPtr);
+ int virConnectNumOfSecrets(ConnectionPointer virConnectPtr);
+ int virConnectNumOfStoragePools(ConnectionPointer virConnectPtr);
+ ConnectionPointer virConnectOpen(String name);
+ ConnectionPointer virConnectOpenAuth(String name, virConnectAuth auth, int flags);
+ ConnectionPointer virConnectOpenReadOnly(String name);
+ virError virConnGetLastError(ConnectionPointer virConnectPtr);
+ int virConnResetLastError(ConnectionPointer virConnectPtr);
+ String virConnectDomainXMLFromNative(ConnectionPointer virConnectPtr, String nativeFormat,
String nativeConfig, int flags);
- public String virConnectDomainXMLToNative(ConnectionPointer virConnectPtr, String nativeFormat, String domainXML,
+ String virConnectDomainXMLToNative(ConnectionPointer virConnectPtr, String nativeFormat, String domainXML,
int flags);
// Global functions
- public int virGetVersion(LongByReference libVer, String type, LongByReference typeVer);
- public int virInitialize();
- public int virCopyLastError(virError error);
- public virError virGetLastError();
- public void virResetLastError();
- public void virSetErrorFunc(Pointer userData, VirErrorCallback callback);
+ int virGetVersion(LongByReference libVer, String type, LongByReference typeVer);
+ int virInitialize();
+ int virCopyLastError(virError error);
+ virError virGetLastError();
+ void virResetLastError();
+ void virSetErrorFunc(Pointer userData, VirErrorCallback callback);
// Domain functions
- public int virDomainAbortJob(DomainPointer virDomainPtr);
- public int virDomainAttachDevice(DomainPointer virDomainPtr, String deviceXML);
- public int virDomainAttachDeviceFlags(DomainPointer virDomainPtr, String deviceXML, int flags);
- public int virDomainBlockStats(DomainPointer virDomainPtr, String path, virDomainBlockStats stats, int size);
- public int virDomainCoreDump(DomainPointer virDomainPtr, String to, int flags);
- public int virDomainCreate(DomainPointer virDomainPtr);
- public int virDomainCreateWithFlags(DomainPointer virDomainPtr, int flags);
- public DomainPointer virDomainCreateLinux(ConnectionPointer virConnectPtr, String xmlDesc, int flags);
- public DomainPointer virDomainCreateXML(ConnectionPointer virConnectPtr, String xmlDesc, int flags);
- public DomainPointer virDomainDefineXML(ConnectionPointer virConnectPtr, String xmlDesc);
- public int virDomainDestroy(DomainPointer virDomainPtr);
- public int virDomainDetachDevice(DomainPointer virDomainPtr, String deviceXML);
- public int virDomainDetachDeviceFlags(DomainPointer virDomainPtr, String deviceXML, int flags);
- public int virDomainFree(DomainPointer virDomainPtr);
- public int virDomainGetAutostart(DomainPointer virDomainPtr, IntByReference value);
- public ConnectionPointer virDomainGetConnect(DomainPointer virDomainPtr);
- public int virDomainGetBlockInfo(DomainPointer virDomainPtr, String path, virDomainBlockInfo info, int flags);
- public int virDomainGetID(DomainPointer virDomainPtr);
- public int virDomainGetInfo(DomainPointer virDomainPtr, virDomainInfo vInfo);
- public int virDomainGetJobInfo(DomainPointer virDomainPtr, virDomainJobInfo vInfo);
- public NativeLong virDomainGetMaxMemory(DomainPointer virDomainPtr);
- public int virDomainGetMaxVcpus(DomainPointer virDomainPtr);
- public String virDomainGetName(DomainPointer virDomainPtr);
- public String virDomainGetOSType(DomainPointer virDomainPtr);
- public int virDomainGetSchedulerParameters(DomainPointer virDomainPtr, virSchedParameter[] params,
+ int virDomainAbortJob(DomainPointer virDomainPtr);
+ int virDomainAttachDevice(DomainPointer virDomainPtr, String deviceXML);
+ int virDomainAttachDeviceFlags(DomainPointer virDomainPtr, String deviceXML, int flags);
+ int virDomainBlockStats(DomainPointer virDomainPtr, String path, virDomainBlockStats stats, int size);
+ int virDomainCoreDump(DomainPointer virDomainPtr, String to, int flags);
+ int virDomainCreate(DomainPointer virDomainPtr);
+ int virDomainCreateWithFlags(DomainPointer virDomainPtr, int flags);
+ DomainPointer virDomainCreateLinux(ConnectionPointer virConnectPtr, String xmlDesc, int flags);
+ DomainPointer virDomainCreateXML(ConnectionPointer virConnectPtr, String xmlDesc, int flags);
+ DomainPointer virDomainDefineXML(ConnectionPointer virConnectPtr, String xmlDesc);
+ int virDomainDestroy(DomainPointer virDomainPtr);
+ int virDomainDetachDevice(DomainPointer virDomainPtr, String deviceXML);
+ int virDomainDetachDeviceFlags(DomainPointer virDomainPtr, String deviceXML, int flags);
+ int virDomainFree(DomainPointer virDomainPtr);
+ int virDomainGetAutostart(DomainPointer virDomainPtr, IntByReference value);
+ ConnectionPointer virDomainGetConnect(DomainPointer virDomainPtr);
+ int virDomainGetBlockInfo(DomainPointer virDomainPtr, String path, virDomainBlockInfo info, int flags);
+ int virDomainGetID(DomainPointer virDomainPtr);
+ int virDomainGetInfo(DomainPointer virDomainPtr, virDomainInfo vInfo);
+ int virDomainGetJobInfo(DomainPointer virDomainPtr, virDomainJobInfo vInfo);
+ NativeLong virDomainGetMaxMemory(DomainPointer virDomainPtr);
+ int virDomainGetMaxVcpus(DomainPointer virDomainPtr);
+ String virDomainGetName(DomainPointer virDomainPtr);
+ String virDomainGetOSType(DomainPointer virDomainPtr);
+ int virDomainGetSchedulerParameters(DomainPointer virDomainPtr, virSchedParameter[] params,
IntByReference nparams);
Pointer virDomainGetSchedulerType(DomainPointer virDomainPtr, IntByReference nparams);
- public int virDomainGetUUID(DomainPointer virDomainPtr, byte[] uuidString);
- public int virDomainGetUUIDString(DomainPointer virDomainPtr, byte[] uuidString);
- public int virDomainGetVcpus(DomainPointer virDomainPtr, virVcpuInfo[] info, int maxInfo, byte[] cpumaps, int maplen);
- public String virDomainGetXMLDesc(DomainPointer virDomainPtr, int flags);
- public int virDomainHasCurrentSnapshot(DomainPointer virDomainPtr, int flags);
- public int virDomainHasManagedSaveImage(DomainPointer virDomainPtr, int flags);
- public int virDomainInterfaceStats(DomainPointer virDomainPtr, String path, virDomainInterfaceStats stats, int size);
- public int virDomainIsActive(DomainPointer virDomainPtr);
- public int virDomainIsPersistent(DomainPointer virDomainPtr);
- public DomainPointer virDomainLookupByID(ConnectionPointer virConnectPtr, int id);
- public DomainPointer virDomainLookupByName(ConnectionPointer virConnectPtr, String name);
- public DomainPointer virDomainLookupByUUID(ConnectionPointer virConnectPtr, byte[] uuidBytes);
- public DomainPointer virDomainLookupByUUIDString(ConnectionPointer virConnectPtr, String uuidstr);
- public int virDomainManagedSave(DomainPointer virDomainPtr, int flags);
- public int virDomainManagedSaveRemove(DomainPointer virDomainPtr, int flags);
- public DomainPointer virDomainMigrate(DomainPointer virDomainPtr, ConnectionPointer virConnectPtr,
+ int virDomainGetUUID(DomainPointer virDomainPtr, byte[] uuidString);
+ int virDomainGetUUIDString(DomainPointer virDomainPtr, byte[] uuidString);
+ int virDomainGetVcpus(DomainPointer virDomainPtr, virVcpuInfo[] info, int maxInfo, byte[] cpumaps, int maplen);
+ String virDomainGetXMLDesc(DomainPointer virDomainPtr, int flags);
+ int virDomainHasCurrentSnapshot(DomainPointer virDomainPtr, int flags);
+ int virDomainHasManagedSaveImage(DomainPointer virDomainPtr, int flags);
+ int virDomainInterfaceStats(DomainPointer virDomainPtr, String path, virDomainInterfaceStats stats, int size);
+ int virDomainIsActive(DomainPointer virDomainPtr);
+ int virDomainIsPersistent(DomainPointer virDomainPtr);
+ DomainPointer virDomainLookupByID(ConnectionPointer virConnectPtr, int id);
+ DomainPointer virDomainLookupByName(ConnectionPointer virConnectPtr, String name);
+ DomainPointer virDomainLookupByUUID(ConnectionPointer virConnectPtr, byte[] uuidBytes);
+ DomainPointer virDomainLookupByUUIDString(ConnectionPointer virConnectPtr, String uuidstr);
+ int virDomainManagedSave(DomainPointer virDomainPtr, int flags);
+ int virDomainManagedSaveRemove(DomainPointer virDomainPtr, int flags);
+ DomainPointer virDomainMigrate(DomainPointer virDomainPtr, ConnectionPointer virConnectPtr,
NativeLong flags, String dname, String uri, NativeLong bandwidth);
- public int virDomainMigrateSetMaxDowntime(DomainPointer virDomainPtr, long downtime, int flags);
- public int virDomainMigrateToURI(DomainPointer virDomainPtr, String duri,
+ int virDomainMigrateSetMaxDowntime(DomainPointer virDomainPtr, long downtime, int flags);
+ int virDomainMigrateToURI(DomainPointer virDomainPtr, String duri,
NativeLong flags, String dname, NativeLong bandwidth);
- public int virDomainMemoryStats(DomainPointer virDomainPtr, virDomainMemoryStats[] stats, int nr_stats, int flags);
- public int virDomainPinVcpu(DomainPointer virDomainPtr, int vcpu, byte[] cpumap, int maplen);
- public int virDomainReboot(DomainPointer virDomainPtr, int flags);
- public int virDomainRestore(ConnectionPointer virConnectPtr, String from);
- public int virDomainRevertToSnapshot(DomainSnapshotPointer virDomainSnapshotPtr, int flags);
- public int virDomainResume(DomainPointer virDomainPtr);
- public int virDomainSave(DomainPointer virDomainPtr, String to);
- public int virDomainSetAutostart(DomainPointer virDomainPtr, int autoStart);
- public int virDomainSetMaxMemory(DomainPointer virDomainPtr, NativeLong maxMemory);
- public int virDomainSetMemory(DomainPointer virDomainPtr, NativeLong maxMemory);
- public int virDomainSetSchedulerParameters(DomainPointer virDomainPtr, virSchedParameter[] params, int nparams);
- public int virDomainSetVcpus(DomainPointer virDomainPtr, int nvcpus);
- public int virDomainShutdown(DomainPointer virDomainPtr);
- public int virDomainSuspend(DomainPointer virDomainPtr);
- public int virDomainUpdateDeviceFlags(DomainPointer virDomainPtr, String xml, int flags);
- public int virDomainUndefine(DomainPointer virDomainPtr);
+ int virDomainMemoryStats(DomainPointer virDomainPtr, virDomainMemoryStats[] stats, int nr_stats, int flags);
+ int virDomainPinVcpu(DomainPointer virDomainPtr, int vcpu, byte[] cpumap, int maplen);
+ int virDomainReboot(DomainPointer virDomainPtr, int flags);
+ int virDomainRestore(ConnectionPointer virConnectPtr, String from);
+ int virDomainRevertToSnapshot(DomainSnapshotPointer virDomainSnapshotPtr, int flags);
+ int virDomainResume(DomainPointer virDomainPtr);
+ int virDomainSave(DomainPointer virDomainPtr, String to);
+ int virDomainSetAutostart(DomainPointer virDomainPtr, int autoStart);
+ int virDomainSetMaxMemory(DomainPointer virDomainPtr, NativeLong maxMemory);
+ int virDomainSetMemory(DomainPointer virDomainPtr, NativeLong maxMemory);
+ int virDomainSetSchedulerParameters(DomainPointer virDomainPtr, virSchedParameter[] params, int nparams);
+ int virDomainSetVcpus(DomainPointer virDomainPtr, int nvcpus);
+ int virDomainShutdown(DomainPointer virDomainPtr);
+ int virDomainSuspend(DomainPointer virDomainPtr);
+ int virDomainUpdateDeviceFlags(DomainPointer virDomainPtr, String xml, int flags);
+ int virDomainUndefine(DomainPointer virDomainPtr);
// Network functions
- public ConnectionPointer virNetworkGetConnect(NetworkPointer virnetworkPtr);
- 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 int virNetworkIsActive(NetworkPointer virNetworkPtr);
- public int virNetworkIsPersistent(NetworkPointer virNetworkPtr);
- public NetworkPointer virNetworkLookupByName(ConnectionPointer virConnectPtr, String name);
- public NetworkPointer virNetworkLookupByUUID(ConnectionPointer virConnectPtr, byte[] uuidBytes);
- public NetworkPointer virNetworkLookupByUUIDString(ConnectionPointer virConnectPtr, String uuidstr);
- public int virNetworkSetAutostart(NetworkPointer virConnectPtr, int autoStart);
- public int virNetworkUndefine(NetworkPointer virConnectPtr);
+ ConnectionPointer virNetworkGetConnect(NetworkPointer virnetworkPtr);
+ int virNetworkCreate(NetworkPointer virConnectPtr);
+ NetworkPointer virNetworkCreateXML(ConnectionPointer virConnectPtr, String xmlDesc);
+ NetworkPointer virNetworkDefineXML(ConnectionPointer virConnectPtr, String xmlDesc);
+ int virNetworkDestroy(NetworkPointer virConnectPtr);
+ int virNetworkFree(NetworkPointer virConnectPtr);
+ int virNetworkGetAutostart(NetworkPointer virNetworkPtr, IntByReference value);
+ String virNetworkGetBridgeName(NetworkPointer virNetworkPtr);
+ String virNetworkGetName(NetworkPointer virNetworkPtr);
+ int virNetworkGetUUID(NetworkPointer virNetworkPtr, byte[] uuidString);
+ int virNetworkGetUUIDString(NetworkPointer virNetworkPtr, byte[] uuidString);
+ String virNetworkGetXMLDesc(NetworkPointer virNetworkPtr, int flags);
+ int virNetworkIsActive(NetworkPointer virNetworkPtr);
+ int virNetworkIsPersistent(NetworkPointer virNetworkPtr);
+ NetworkPointer virNetworkLookupByName(ConnectionPointer virConnectPtr, String name);
+ NetworkPointer virNetworkLookupByUUID(ConnectionPointer virConnectPtr, byte[] uuidBytes);
+ NetworkPointer virNetworkLookupByUUIDString(ConnectionPointer virConnectPtr, String uuidstr);
+ int virNetworkSetAutostart(NetworkPointer virConnectPtr, int autoStart);
+ int virNetworkUndefine(NetworkPointer virConnectPtr);
// Node functions
- public int virNodeGetInfo(ConnectionPointer virConnectPtr, virNodeInfo virNodeInfo);
- public int virNodeGetCellsFreeMemory(ConnectionPointer virConnectPtr, LongByReference freeMems, int startCell,
+ int virNodeGetInfo(ConnectionPointer virConnectPtr, virNodeInfo virNodeInfo);
+ int virNodeGetCellsFreeMemory(ConnectionPointer virConnectPtr, LongByReference freeMems, int startCell,
int maxCells);
- public long virNodeGetFreeMemory(ConnectionPointer virConnectPtr);
+ long virNodeGetFreeMemory(ConnectionPointer virConnectPtr);
// Node/Device functions
- public int virNodeNumOfDevices(ConnectionPointer virConnectPtr, String capabilityName, int flags);
- public int virNodeListDevices(ConnectionPointer virConnectPtr, String capabilityName, String[] names, int maxnames,
+ int virNodeNumOfDevices(ConnectionPointer virConnectPtr, String capabilityName, int flags);
+ int virNodeListDevices(ConnectionPointer virConnectPtr, String capabilityName, String[] names, int maxnames,
int flags);
- public DevicePointer virNodeDeviceLookupByName(ConnectionPointer virConnectPtr, String name);
- public String virNodeDeviceGetName(DevicePointer virDevicePointer);
- public String virNodeDeviceGetParent(DevicePointer virDevicePointer);
- public int virNodeDeviceNumOfCaps(DevicePointer virDevicePointer);
- public int virNodeDeviceListCaps(DevicePointer virDevicePointer, String[] names, int maxNames);
- public String virNodeDeviceGetXMLDesc(DevicePointer virDevicePointer);
- public int virNodeDeviceFree(DevicePointer virDevicePointer);
- public int virNodeDeviceDettach(DevicePointer virDevicePointer);
- public int virNodeDeviceReAttach(DevicePointer virDevicePointer);
- public int virNodeDeviceReset(DevicePointer virDevicePointer);
- public DevicePointer virNodeDeviceCreateXML(ConnectionPointer virConnectPtr, String xml, int flags);
- public int virNodeDeviceDestroy(DevicePointer virDevicePointer);
+ DevicePointer virNodeDeviceLookupByName(ConnectionPointer virConnectPtr, String name);
+ String virNodeDeviceGetName(DevicePointer virDevicePointer);
+ String virNodeDeviceGetParent(DevicePointer virDevicePointer);
+ int virNodeDeviceNumOfCaps(DevicePointer virDevicePointer);
+ int virNodeDeviceListCaps(DevicePointer virDevicePointer, String[] names, int maxNames);
+ String virNodeDeviceGetXMLDesc(DevicePointer virDevicePointer);
+ int virNodeDeviceFree(DevicePointer virDevicePointer);
+ int virNodeDeviceDettach(DevicePointer virDevicePointer);
+ int virNodeDeviceReAttach(DevicePointer virDevicePointer);
+ int virNodeDeviceReset(DevicePointer virDevicePointer);
+ DevicePointer virNodeDeviceCreateXML(ConnectionPointer virConnectPtr, String xml, int flags);
+ int virNodeDeviceDestroy(DevicePointer virDevicePointer);
// 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 int virStoragePoolIsActive(StoragePoolPointer storagePoolPtr);
- public int virStoragePoolIsPersistent(StoragePoolPointer storagePoolPtr);
- public StoragePoolPointer virStoragePoolLookupByName(ConnectionPointer virConnectPtr, String name);
- public StoragePoolPointer virStoragePoolLookupByUUID(ConnectionPointer virConnectPtr, byte[] uuidBytes);
- public StoragePoolPointer virStoragePoolLookupByUUIDString(ConnectionPointer virConnectPtr, String uuidstr);
- public StoragePoolPointer virStoragePoolLookupByVolume(StorageVolPointer storageVolPtr);
- public int virStoragePoolNumOfVolumes(StoragePoolPointer storagePoolPtr);
- public int virStoragePoolRefresh(StoragePoolPointer storagePoolPtr, int flags);
- public int virStoragePoolSetAutostart(StoragePoolPointer storagePoolPtr, int autostart);
- public int virStoragePoolUndefine(StoragePoolPointer storagePoolPtr);
+ int virStoragePoolBuild(StoragePoolPointer storagePoolPtr, int flags);
+ int virStoragePoolCreate(StoragePoolPointer storagePoolPtr, int flags);
+ StoragePoolPointer virStoragePoolCreateXML(ConnectionPointer virConnectPtr, String xml, int flags);
+ StoragePoolPointer virStoragePoolDefineXML(ConnectionPointer virConnectPtr, String xml, int flags);
+ int virStoragePoolDelete(StoragePoolPointer storagePoolPtr, int flags);
+ int virStoragePoolDestroy(StoragePoolPointer storagePoolPtr);
+ int virStoragePoolFree(StoragePoolPointer storagePoolPtr);
+ int virStoragePoolGetAutostart(StoragePoolPointer storagePoolPtr, IntByReference value);
+ int virStoragePoolGetInfo(StoragePoolPointer storagePoolPtr, virStoragePoolInfo info);
+ String virStoragePoolGetName(StoragePoolPointer storagePoolPtr);
+ int virStoragePoolGetUUID(StoragePoolPointer storagePoolPtr, byte[] uuidString);
+ int virStoragePoolGetUUIDString(StoragePoolPointer storagePoolPtr, byte[] uuidString);
+ String virStoragePoolGetXMLDesc(StoragePoolPointer storagePoolPtr, int flags);
+ int virStoragePoolListVolumes(StoragePoolPointer storagePoolPtr, String[] names, int maxnames);
+ int virStoragePoolIsActive(StoragePoolPointer storagePoolPtr);
+ int virStoragePoolIsPersistent(StoragePoolPointer storagePoolPtr);
+ StoragePoolPointer virStoragePoolLookupByName(ConnectionPointer virConnectPtr, String name);
+ StoragePoolPointer virStoragePoolLookupByUUID(ConnectionPointer virConnectPtr, byte[] uuidBytes);
+ StoragePoolPointer virStoragePoolLookupByUUIDString(ConnectionPointer virConnectPtr, String uuidstr);
+ StoragePoolPointer virStoragePoolLookupByVolume(StorageVolPointer storageVolPtr);
+ int virStoragePoolNumOfVolumes(StoragePoolPointer storagePoolPtr);
+ int virStoragePoolRefresh(StoragePoolPointer storagePoolPtr, int flags);
+ int virStoragePoolSetAutostart(StoragePoolPointer storagePoolPtr, int autostart);
+ int virStoragePoolUndefine(StoragePoolPointer storagePoolPtr);
// Storage Vol
- public StorageVolPointer virStorageVolCreateXML(StoragePoolPointer storagePoolPtr, String xml, int flags);
- public StorageVolPointer virStorageVolCreateXMLFrom(StoragePoolPointer storagePoolPtr, String xml,
+ StorageVolPointer virStorageVolCreateXML(StoragePoolPointer storagePoolPtr, String xml, int flags);
+ StorageVolPointer virStorageVolCreateXMLFrom(StoragePoolPointer storagePoolPtr, String xml,
StorageVolPointer cloneVolume, int flags);
- 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);
- public StorageVolPointer virStorageVolLookupByKey(ConnectionPointer virConnectPtr, String name);
- public StorageVolPointer virStorageVolLookupByName(StoragePoolPointer storagePoolPtr, String name);
- public StorageVolPointer virStorageVolLookupByPath(ConnectionPointer virConnectPtr, String path);
- public int virStorageVolWipe(StorageVolPointer storageVolPtr, int flags);
+ int virStorageVolDelete(StorageVolPointer storageVolPtr, int flags);
+ int virStorageVolFree(StorageVolPointer storageVolPtr);
+ int virStorageVolGetInfo(StorageVolPointer storageVolPtr, virStorageVolInfo info);
+ String virStorageVolGetKey(StorageVolPointer storageVolPtr);
+ String virStorageVolGetName(StorageVolPointer storageVolPtr);
+ String virStorageVolGetPath(StorageVolPointer storageVolPtr);
+ String virStorageVolGetXMLDesc(StorageVolPointer storageVolPtr, int flags);
+ StorageVolPointer virStorageVolLookupByKey(ConnectionPointer virConnectPtr, String name);
+ StorageVolPointer virStorageVolLookupByName(StoragePoolPointer storagePoolPtr, String name);
+ StorageVolPointer virStorageVolLookupByPath(ConnectionPointer virConnectPtr, String path);
+ int virStorageVolWipe(StorageVolPointer storageVolPtr, int flags);
// Interface Methods
- public int virInterfaceCreate(InterfacePointer virDevicePointer);
- public InterfacePointer virInterfaceDefineXML(ConnectionPointer virConnectPtr, String xml, int flags);
- public int virInterfaceDestroy(InterfacePointer virDevicePointer);
- public int virInterfaceFree(InterfacePointer virDevicePointer);
- public String virInterfaceGetName(InterfacePointer virInterfacePtr);
- public String virInterfaceGetMACString(InterfacePointer virInterfacePtr);
- public String virInterfaceGetXMLDesc(InterfacePointer virInterfacePtr, int flags);
- public int virInterfaceIsActive(InterfacePointer virDevicePointer);
- public InterfacePointer virInterfaceLookupByMACString(ConnectionPointer virConnectPtr, String mac);
- public InterfacePointer virInterfaceLookupByName(ConnectionPointer virConnectPtr, String name);
- public int virInterfaceUndefine(InterfacePointer virDevicePointer);
+ int virInterfaceCreate(InterfacePointer virDevicePointer);
+ InterfacePointer virInterfaceDefineXML(ConnectionPointer virConnectPtr, String xml, int flags);
+ int virInterfaceDestroy(InterfacePointer virDevicePointer);
+ int virInterfaceFree(InterfacePointer virDevicePointer);
+ String virInterfaceGetName(InterfacePointer virInterfacePtr);
+ String virInterfaceGetMACString(InterfacePointer virInterfacePtr);
+ String virInterfaceGetXMLDesc(InterfacePointer virInterfacePtr, int flags);
+ int virInterfaceIsActive(InterfacePointer virDevicePointer);
+ InterfacePointer virInterfaceLookupByMACString(ConnectionPointer virConnectPtr, String mac);
+ InterfacePointer virInterfaceLookupByName(ConnectionPointer virConnectPtr, String name);
+ int virInterfaceUndefine(InterfacePointer virDevicePointer);
// Secret Methods
- public ConnectionPointer virSecretGetConnect(SecretPointer virSecretPtr);
- public int virSecretFree(SecretPointer virSecretPtr);
- public SecretPointer virSecretDefineXML(ConnectionPointer virConnectPtr, String xml, int flags);
- public int virSecretGetUUID(SecretPointer virSecretPtr, byte[] uuidString);
- public int virSecretGetUUIDString(SecretPointer virSecretPtr, byte[] uuidString);
- public String virSecretGetUsageID(SecretPointer virSecretPtr);
- public Pointer virSecretGetValue(SecretPointer virSecretPtr, LongByReference value_size, int flags);
- public String virSecretGetXMLDesc(SecretPointer virSecretPtr, int flags);
- public SecretPointer virSecretLookupByUsage(ConnectionPointer virConnectPtr, int usageType, String usageID);
- public SecretPointer virSecretLookupByUUID(ConnectionPointer virConnectPtr, byte[] uuidBytes);
- public SecretPointer virSecretLookupByUUIDString(ConnectionPointer virConnectPtr, String uuidstr);
- public int virSecretSetValue(SecretPointer virSecretPtr, String value, NativeLong value_size, int flags);
- public int virSecretSetValue(SecretPointer virSecretPtr, byte[] value, NativeLong value_size, int flags);
- public int virSecretUndefine(SecretPointer virSecretPtr);
+ ConnectionPointer virSecretGetConnect(SecretPointer virSecretPtr);
+ int virSecretFree(SecretPointer virSecretPtr);
+ SecretPointer virSecretDefineXML(ConnectionPointer virConnectPtr, String xml, int flags);
+ int virSecretGetUUID(SecretPointer virSecretPtr, byte[] uuidString);
+ int virSecretGetUUIDString(SecretPointer virSecretPtr, byte[] uuidString);
+ String virSecretGetUsageID(SecretPointer virSecretPtr);
+ Pointer virSecretGetValue(SecretPointer virSecretPtr, LongByReference value_size, int flags);
+ String virSecretGetXMLDesc(SecretPointer virSecretPtr, int flags);
+ SecretPointer virSecretLookupByUsage(ConnectionPointer virConnectPtr, int usageType, String usageID);
+ SecretPointer virSecretLookupByUUID(ConnectionPointer virConnectPtr, byte[] uuidBytes);
+ SecretPointer virSecretLookupByUUIDString(ConnectionPointer virConnectPtr, String uuidstr);
+ int virSecretSetValue(SecretPointer virSecretPtr, String value, NativeLong value_size, int flags);
+ int virSecretSetValue(SecretPointer virSecretPtr, byte[] value, NativeLong value_size, int flags);
+ int virSecretUndefine(SecretPointer virSecretPtr);
//Stream Methods
- public int virStreamAbort(StreamPointer virStreamPtr) ;
- public int virStreamEventAddCallback(StreamPointer virStreamPtr, int events, Libvirt.VirStreamEventCallback cb,
+ int virStreamAbort(StreamPointer virStreamPtr) ;
+ int virStreamEventAddCallback(StreamPointer virStreamPtr, int events, Libvirt.VirStreamEventCallback cb,
Pointer opaque, Libvirt.VirFreeCallback ff);
- public int virStreamEventUpdateCallback(StreamPointer virStreamPtr, int events);
- public int virStreamEventRemoveCallback(StreamPointer virStreamPtr);
- public int virStreamFinish(StreamPointer virStreamPtr) ;
- public int virStreamFree(StreamPointer virStreamPtr) ;
- public StreamPointer virStreamNew(ConnectionPointer virConnectPtr, int flags) ;
- public int virStreamSend(StreamPointer virStreamPtr, String data, NativeLong size);
- public int virStreamSendAll(StreamPointer virStreamPtr, Libvirt.VirStreamSourceFunc handler, Pointer opaque);
- public int virStreamRecv(StreamPointer virStreamPtr, byte[] data, NativeLong length);
- public int virStreamRecvAll(StreamPointer virStreamPtr, Libvirt.VirStreamSinkFunc handler, Pointer opaque);
+ int virStreamEventUpdateCallback(StreamPointer virStreamPtr, int events);
+ int virStreamEventRemoveCallback(StreamPointer virStreamPtr);
+ int virStreamFinish(StreamPointer virStreamPtr) ;
+ int virStreamFree(StreamPointer virStreamPtr) ;
+ StreamPointer virStreamNew(ConnectionPointer virConnectPtr, int flags) ;
+ int virStreamSend(StreamPointer virStreamPtr, String data, NativeLong size);
+ int virStreamSendAll(StreamPointer virStreamPtr, Libvirt.VirStreamSourceFunc handler, Pointer opaque);
+ int virStreamRecv(StreamPointer virStreamPtr, byte[] data, NativeLong length);
+ int virStreamRecvAll(StreamPointer virStreamPtr, Libvirt.VirStreamSinkFunc handler, Pointer opaque);
//DomainSnapshot Methods
- public DomainSnapshotPointer virDomainSnapshotCreateXML(DomainPointer virDomainPtr, String xmlDesc, int flags);
- public DomainSnapshotPointer virDomainSnapshotCurrent(DomainPointer virDomainPtr, int flags);
- public int virDomainSnapshotDelete(DomainSnapshotPointer virDomainSnapshotPtr, int flags);
- public String virDomainSnapshotGetXMLDesc(DomainSnapshotPointer virDomainSnapshotPtr, int flags);
- public int virDomainSnapshotFree(DomainSnapshotPointer virDomainSnapshotPtr);
- public int virDomainSnapshotListNames(DomainPointer virDomainPtr, String[] names, int nameslen, int flags);
- public DomainSnapshotPointer virDomainSnapshotLookupByName(DomainPointer virDomainPtr, String name, int flags);
- public int virDomainSnapshotNum(DomainPointer virDomainPtr, int flags);
+ DomainSnapshotPointer virDomainSnapshotCreateXML(DomainPointer virDomainPtr, String xmlDesc, int flags);
+ DomainSnapshotPointer virDomainSnapshotCurrent(DomainPointer virDomainPtr, int flags);
+ int virDomainSnapshotDelete(DomainSnapshotPointer virDomainSnapshotPtr, int flags);
+ String virDomainSnapshotGetXMLDesc(DomainSnapshotPointer virDomainSnapshotPtr, int flags);
+ int virDomainSnapshotFree(DomainSnapshotPointer virDomainSnapshotPtr);
+ int virDomainSnapshotListNames(DomainPointer virDomainPtr, String[] names, int nameslen, int flags);
+ DomainSnapshotPointer virDomainSnapshotLookupByName(DomainPointer virDomainPtr, String name, int flags);
+ int virDomainSnapshotNum(DomainPointer virDomainPtr, int flags);
// Network Filter Methods
- public String virNWFilterGetXMLDesc(NetworkFilterPointer virNWFilterPtr, int flags);
- public NetworkFilterPointer virNWFilterDefineXML(ConnectionPointer virConnectPtr, String xml);
- public int virNWFilterFree(NetworkFilterPointer virNWFilterPtr);
- public NetworkFilterPointer virNWFilterLookupByName(ConnectionPointer virConnectPtr, String name);
- public NetworkFilterPointer virNWFilterLookupByUUID(ConnectionPointer virConnectPtr, byte[] uuidBytes);
- public NetworkFilterPointer virNWFilterLookupByUUIDString(ConnectionPointer virConnectPtr, String uuidstr);
- public String virNWFilterGetName(NetworkFilterPointer virNWFilterPtr);
- public int virNWFilterGetUUID(NetworkFilterPointer virNWFilterPtr, byte[] uuidString);
- public int virNWFilterGetUUIDString(NetworkFilterPointer virNWFilterPtr, byte[] uuidString);
- public int virNWFilterUndefine(NetworkFilterPointer virNWFilterPtr);
+ String virNWFilterGetXMLDesc(NetworkFilterPointer virNWFilterPtr, int flags);
+ NetworkFilterPointer virNWFilterDefineXML(ConnectionPointer virConnectPtr, String xml);
+ int virNWFilterFree(NetworkFilterPointer virNWFilterPtr);
+ NetworkFilterPointer virNWFilterLookupByName(ConnectionPointer virConnectPtr, String name);
+ NetworkFilterPointer virNWFilterLookupByUUID(ConnectionPointer virConnectPtr, byte[] uuidBytes);
+ NetworkFilterPointer virNWFilterLookupByUUIDString(ConnectionPointer virConnectPtr, String uuidstr);
+ String virNWFilterGetName(NetworkFilterPointer virNWFilterPtr);
+ int virNWFilterGetUUID(NetworkFilterPointer virNWFilterPtr, byte[] uuidString);
+ int virNWFilterGetUUIDString(NetworkFilterPointer virNWFilterPtr, byte[] uuidString);
+ int virNWFilterUndefine(NetworkFilterPointer virNWFilterPtr);
}
--
AV-Test GmbH, Henricistraße 20, 04155 Leipzig, Germany
Phone: +49 341 265 310 19
Web:<http://www.av-test.org>
Eingetragen am / Registered at: Amtsgericht Stendal (HRB 114076)
Geschaeftsfuehrer (CEO): Andreas Marx, Guido Habicht, Maik Morgenstern
12 years, 1 month
[libvirt] (no subject)
by cbley@av-test.de
>From 7c2399ae2a65c60203b29ce02b694f80505ffc8c Mon Sep 17 00:00:00 2001
Message-Id: <7c2399ae2a65c60203b29ce02b694f80505ffc8c.1350037981.git.cbley(a)av-test.de>
In-Reply-To: <cover.1350037981.git.cbley(a)av-test.de>
References: <2DA6F4A3691599408358374D182280F9141CF6(a)xmb-rcd-x04.cisco.com> <cover.1350037981.git.cbley(a)av-test.de>
From: cbley(a)av-test.de (Claudio Bley)
Date: Thu, 23 Aug 2012 14:51:28 +0200
Subject: [PATCH 11/15] Avoid unnecessary copying and calling virResetLastError.
To: libvir-list(a)redhat.com
Organization: AV-Test GmbH, Germany
Just use virGetLastError instead of virCopyLastError.
Calling virResetLastError is unnecessary because every public
libvirt function will first reset the error when being called.
---
src/main/java/org/libvirt/ErrorHandler.java | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/src/main/java/org/libvirt/ErrorHandler.java b/src/main/java/org/libvirt/ErrorHandler.java
index 543829e..4dd7c90 100644
--- a/src/main/java/org/libvirt/ErrorHandler.java
+++ b/src/main/java/org/libvirt/ErrorHandler.java
@@ -20,14 +20,11 @@ public class ErrorHandler {
* @throws LibvirtException
*/
public static void processError(Libvirt libvirt) throws LibvirtException {
- virError vError = new virError();
- int errorCode = libvirt.virCopyLastError(vError);
- if (errorCode > 0) {
+ virError vError = libvirt.virGetLastError();
+ if (vError != null) {
Error error = new Error(vError);
- libvirt.virResetLastError();
/*
- * FIXME: Don't throw exceptions for VIR_ERR_WARNING
- * level errors
+ * Don't throw exceptions for VIR_ERR_WARNING level errors
*/
if (error.getLevel() == Error.ErrorLevel.VIR_ERR_ERROR) {
throw new LibvirtException(error);
--
AV-Test GmbH, Henricistraße 20, 04155 Leipzig, Germany
Phone: +49 341 265 310 19
Web:<http://www.av-test.org>
Eingetragen am / Registered at: Amtsgericht Stendal (HRB 114076)
Geschaeftsfuehrer (CEO): Andreas Marx, Guido Habicht, Maik Morgenstern
12 years, 1 month
[libvirt] (no subject)
by cbley@av-test.de
>From 2dfe78ef3c2e5e69bb41d8db02eb433379d12fda Mon Sep 17 00:00:00 2001
Message-Id: <2dfe78ef3c2e5e69bb41d8db02eb433379d12fda.1350037981.git.cbley(a)av-test.de>
In-Reply-To: <cover.1350037981.git.cbley(a)av-test.de>
References: <2DA6F4A3691599408358374D182280F9141CF6(a)xmb-rcd-x04.cisco.com> <cover.1350037981.git.cbley(a)av-test.de>
From: cbley(a)av-test.de (Claudio Bley)
Date: Mon, 20 Aug 2012 16:50:00 +0200
Subject: [PATCH 06/15] Change visibility of class members to private to enforce encapsulation.
To: libvir-list(a)redhat.com
Organization: AV-Test GmbH, Germany
---
src/main/java/org/libvirt/Error.java | 24 +++++++++++------------
src/main/java/org/libvirt/LibvirtException.java | 2 +-
src/main/java/org/libvirt/Stream.java | 2 +-
3 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/src/main/java/org/libvirt/Error.java b/src/main/java/org/libvirt/Error.java
index e3c3246..114e758 100644
--- a/src/main/java/org/libvirt/Error.java
+++ b/src/main/java/org/libvirt/Error.java
@@ -199,18 +199,18 @@ public class Error implements Serializable {
*/
private static final long serialVersionUID = -4780109197014633842L;
- ErrorNumber code;
- ErrorDomain domain;
- String message;
- ErrorLevel level;
- ConnectionPointer VCP; /* Deprecated */
- DomainPointer VDP; /* Deprecated */
- String str1;
- String str2;
- String str3;
- int int1;
- int int2;
- NetworkPointer VNP; /* Deprecated */
+ private ErrorNumber code;
+ private ErrorDomain domain;
+ private String message;
+ private ErrorLevel level;
+ private ConnectionPointer VCP; /* Deprecated */
+ private DomainPointer VDP; /* Deprecated */
+ private String str1;
+ private String str2;
+ private String str3;
+ private int int1;
+ private int int2;
+ private NetworkPointer VNP; /* Deprecated */
public Error(virError vError) {
code = code.wrap(vError.code);
diff --git a/src/main/java/org/libvirt/LibvirtException.java b/src/main/java/org/libvirt/LibvirtException.java
index 5bd2d6e..f9546be 100644
--- a/src/main/java/org/libvirt/LibvirtException.java
+++ b/src/main/java/org/libvirt/LibvirtException.java
@@ -11,7 +11,7 @@ public class LibvirtException extends Exception {
private static final long serialVersionUID = 5566904363426773529L;
- Error virError;
+ private Error virError;
LibvirtException(Error virError) {
super(virError.getMessage());
diff --git a/src/main/java/org/libvirt/Stream.java b/src/main/java/org/libvirt/Stream.java
index 0056a78..06b67cf 100644
--- a/src/main/java/org/libvirt/Stream.java
+++ b/src/main/java/org/libvirt/Stream.java
@@ -12,7 +12,7 @@ public class Stream {
/**
* the native virStreamPtr.
*/
- StreamPointer VSP;
+ private StreamPointer VSP;
/**
* The Connect Object that represents the Hypervisor of this Domain
--
AV-Test GmbH, Henricistraße 20, 04155 Leipzig, Germany
Phone: +49 341 265 310 19
Web:<http://www.av-test.org>
Eingetragen am / Registered at: Amtsgericht Stendal (HRB 114076)
Geschaeftsfuehrer (CEO): Andreas Marx, Guido Habicht, Maik Morgenstern
12 years, 1 month
[libvirt] (no subject)
by cbley@av-test.de
>From af35ffd9f22c16f6162ec814f0acd93daeb94adf Mon Sep 17 00:00:00 2001
Message-Id: <af35ffd9f22c16f6162ec814f0acd93daeb94adf.1350037981.git.cbley(a)av-test.de>
In-Reply-To: <cover.1350037981.git.cbley(a)av-test.de>
References: <2DA6F4A3691599408358374D182280F9141CF6(a)xmb-rcd-x04.cisco.com> <cover.1350037981.git.cbley(a)av-test.de>
From: cbley(a)av-test.de (Claudio Bley)
Date: Fri, 17 Aug 2012 14:50:44 +0200
Subject: [PATCH 04/15] Make finalize() methods protected.
To: libvir-list(a)redhat.com
Organization: AV-Test GmbH, Germany
Reported by findbugs:
Finalizer should be protected, not public
A class's finalize() method should have protected access, not public.
Bug kind and pattern: FI - FI_PUBLIC_SHOULD_BE_PROTECTED
---
src/main/java/org/libvirt/Connect.java | 2 +-
src/main/java/org/libvirt/Device.java | 2 +-
src/main/java/org/libvirt/Domain.java | 2 +-
src/main/java/org/libvirt/DomainSnapshot.java | 2 +-
src/main/java/org/libvirt/Interface.java | 2 +-
src/main/java/org/libvirt/Network.java | 2 +-
src/main/java/org/libvirt/NetworkFilter.java | 2 +-
src/main/java/org/libvirt/Secret.java | 2 +-
src/main/java/org/libvirt/StoragePool.java | 2 +-
src/main/java/org/libvirt/StorageVol.java | 2 +-
src/main/java/org/libvirt/Stream.java | 2 +-
11 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/src/main/java/org/libvirt/Connect.java b/src/main/java/org/libvirt/Connect.java
index 0a94976..5419e85 100644
--- a/src/main/java/org/libvirt/Connect.java
+++ b/src/main/java/org/libvirt/Connect.java
@@ -533,7 +533,7 @@ public class Connect {
}
@Override
- public void finalize() throws LibvirtException {
+ protected void finalize() throws LibvirtException {
close();
}
diff --git a/src/main/java/org/libvirt/Device.java b/src/main/java/org/libvirt/Device.java
index 8a52e81..bc25258 100644
--- a/src/main/java/org/libvirt/Device.java
+++ b/src/main/java/org/libvirt/Device.java
@@ -68,7 +68,7 @@ public class Device {
}
@Override
- public void finalize() throws LibvirtException {
+ protected void finalize() throws LibvirtException {
free();
}
diff --git a/src/main/java/org/libvirt/Domain.java b/src/main/java/org/libvirt/Domain.java
index fc1f665..f4f5225 100644
--- a/src/main/java/org/libvirt/Domain.java
+++ b/src/main/java/org/libvirt/Domain.java
@@ -284,7 +284,7 @@ public class Domain {
}
@Override
- public void finalize() throws LibvirtException {
+ protected void finalize() throws LibvirtException {
free();
}
diff --git a/src/main/java/org/libvirt/DomainSnapshot.java b/src/main/java/org/libvirt/DomainSnapshot.java
index add6830..3083ca0 100644
--- a/src/main/java/org/libvirt/DomainSnapshot.java
+++ b/src/main/java/org/libvirt/DomainSnapshot.java
@@ -49,7 +49,7 @@ public class DomainSnapshot {
}
@Override
- public void finalize() throws LibvirtException {
+ protected void finalize() throws LibvirtException {
free();
}
diff --git a/src/main/java/org/libvirt/Interface.java b/src/main/java/org/libvirt/Interface.java
index 1ae8b94..17c189d 100644
--- a/src/main/java/org/libvirt/Interface.java
+++ b/src/main/java/org/libvirt/Interface.java
@@ -68,7 +68,7 @@ public class Interface {
}
@Override
- public void finalize() throws LibvirtException {
+ protected void finalize() throws LibvirtException {
free();
}
diff --git a/src/main/java/org/libvirt/Network.java b/src/main/java/org/libvirt/Network.java
index 9684cb4..acaef0e 100644
--- a/src/main/java/org/libvirt/Network.java
+++ b/src/main/java/org/libvirt/Network.java
@@ -65,7 +65,7 @@ public class Network {
}
@Override
- public void finalize() throws LibvirtException {
+ protected void finalize() throws LibvirtException {
free();
}
diff --git a/src/main/java/org/libvirt/NetworkFilter.java b/src/main/java/org/libvirt/NetworkFilter.java
index 016cf1a..7bc07a5 100644
--- a/src/main/java/org/libvirt/NetworkFilter.java
+++ b/src/main/java/org/libvirt/NetworkFilter.java
@@ -28,7 +28,7 @@ public class NetworkFilter {
}
@Override
- public void finalize() throws LibvirtException {
+ protected void finalize() throws LibvirtException {
free();
}
diff --git a/src/main/java/org/libvirt/Secret.java b/src/main/java/org/libvirt/Secret.java
index febd75b..888cdf3 100644
--- a/src/main/java/org/libvirt/Secret.java
+++ b/src/main/java/org/libvirt/Secret.java
@@ -36,7 +36,7 @@ public class Secret {
}
@Override
- public void finalize() throws LibvirtException {
+ protected void finalize() throws LibvirtException {
free();
}
diff --git a/src/main/java/org/libvirt/StoragePool.java b/src/main/java/org/libvirt/StoragePool.java
index 0328d8c..29a18ed 100644
--- a/src/main/java/org/libvirt/StoragePool.java
+++ b/src/main/java/org/libvirt/StoragePool.java
@@ -116,7 +116,7 @@ public class StoragePool {
}
@Override
- public void finalize() throws LibvirtException {
+ protected void finalize() throws LibvirtException {
free();
}
diff --git a/src/main/java/org/libvirt/StorageVol.java b/src/main/java/org/libvirt/StorageVol.java
index 1bed6e1..e2bc717 100644
--- a/src/main/java/org/libvirt/StorageVol.java
+++ b/src/main/java/org/libvirt/StorageVol.java
@@ -76,7 +76,7 @@ public class StorageVol {
}
@Override
- public void finalize() throws LibvirtException {
+ protected void finalize() throws LibvirtException {
free();
}
diff --git a/src/main/java/org/libvirt/Stream.java b/src/main/java/org/libvirt/Stream.java
index 6374567..0056a78 100644
--- a/src/main/java/org/libvirt/Stream.java
+++ b/src/main/java/org/libvirt/Stream.java
@@ -61,7 +61,7 @@ public class Stream {
}
@Override
- public void finalize() throws LibvirtException {
+ protected void finalize() throws LibvirtException {
free();
}
--
AV-Test GmbH, Henricistraße 20, 04155 Leipzig, Germany
Phone: +49 341 265 310 19
Web:<http://www.av-test.org>
Eingetragen am / Registered at: Amtsgericht Stendal (HRB 114076)
Geschaeftsfuehrer (CEO): Andreas Marx, Guido Habicht, Maik Morgenstern
12 years, 1 month
[libvirt] (no subject)
by cbley@av-test.de
>From ed6209290f9f2d03b26705ca3f9c03eb40309a94 Mon Sep 17 00:00:00 2001
Message-Id: <ed6209290f9f2d03b26705ca3f9c03eb40309a94.1350037981.git.cbley(a)av-test.de>
In-Reply-To: <cover.1350037981.git.cbley(a)av-test.de>
References: <2DA6F4A3691599408358374D182280F9141CF6(a)xmb-rcd-x04.cisco.com> <cover.1350037981.git.cbley(a)av-test.de>
From: cbley(a)av-test.de (Claudio Bley)
Date: Tue, 21 Aug 2012 16:31:12 +0200
Subject: [PATCH 09/15] Split JUnit tests and use a fixture for Connect.
To: libvir-list(a)redhat.com
Organization: AV-Test GmbH, Germany
The tests have been separated into a test case requiring
a libvirt connection and a test case which does not.
Every test gets a new Connect instance by using a fixture.
This avoids duplicate code and makes tests more consistent.
---
build.xml | 9 ++--
src/test/java/org/libvirt/TestJavaBindings.java | 47 +++++++++++----------
src/test/java/org/libvirt/TestLibvirtGlobals.java | 21 +++++++++
3 files changed, 51 insertions(+), 26 deletions(-)
diff --git a/build.xml b/build.xml
index 0b147b0..4b73562 100644
--- a/build.xml
+++ b/build.xml
@@ -49,11 +49,14 @@
</target>
<target name="test" depends="build" description="tests the code">
- <junit printsummary="yes" fork="yes">
+ <junit printsummary="yes" fork="yes" forkMode="perBatch">
<formatter type="plain" />
<classpath refid="test.classpath" />
- <test name="org.libvirt.TestJavaBindings" outfile="target/testResults">
- </test>
+ <batchtest todir="target">
+ <fileset dir="src/test/java">
+ <include name="**/Test*.java" />
+ </fileset>
+ </batchtest>
</junit>
</target>
diff --git a/src/test/java/org/libvirt/TestJavaBindings.java b/src/test/java/org/libvirt/TestJavaBindings.java
index bac7a82..55ca64b 100644
--- a/src/test/java/org/libvirt/TestJavaBindings.java
+++ b/src/test/java/org/libvirt/TestJavaBindings.java
@@ -4,28 +4,35 @@ import java.util.UUID;
import junit.framework.TestCase;
-public class TestJavaBindings extends TestCase {
-
- int UUIDArray[] = { Integer.decode("0x00"), Integer.decode("0x4b"), Integer.decode("0x96"), Integer.decode("0xe1"),
+public final class TestJavaBindings extends TestCase {
+ final int UUIDArray[] = { 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") };
- public void testErrorCallback() throws Exception {
+ private Connect conn;
+
+ protected void setUp() throws LibvirtException {
+ conn = new Connect("test:///default", false);
+ }
+
+ protected void tearDown() throws LibvirtException {
+ conn.close();
+ conn = null;
+ }
+
+ public void testConnectionErrorCallback() throws LibvirtException {
DummyErrorCallback cb = new DummyErrorCallback();
- Connect.setErrorCallback(cb);
+ conn.setConnectionErrorCallback(cb);
+
try {
- Connect conn = new Connect("test:///someUrl", false);
- } catch (Exception e) {
- // eat it
- }
- assertTrue("We should have caught an error", cb.error);
- Connect conn = new Connect("test:///default", false);
- conn.setConnectionErrorCallback(cb) ;
+ conn.domainDefineXML("fail, miserably");
+ } catch (LibvirtException e) {} // ignore
+
+ assertTrue("Error callback was not called", cb.error);
}
public void testConnection() throws Exception {
- Connect conn = new Connect("test:///default", false);
assertEquals("conn.getType()", "Test", conn.getType());
assertEquals("conn.getURI()", "test:///default", conn.getURI());
assertEquals("conn.getMaxVcpus(xen)", 32, conn.getMaxVcpus("xen"));
@@ -39,7 +46,6 @@ public class TestJavaBindings extends TestCase {
}
public void testNodeInfo() throws Exception {
- Connect conn = new Connect("test:///default", false);
NodeInfo nodeInfo = conn.nodeInfo();
assertEquals("nodeInfo.model", "i686", nodeInfo.model);
assertEquals("nodeInfo.memory", 3145728, nodeInfo.memory);
@@ -56,8 +62,6 @@ public class TestJavaBindings extends TestCase {
}
public void testNetworkCreate() throws Exception {
- Connect conn = new Connect("test:///default", false);
-
Network network1 = 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>"
@@ -103,8 +107,6 @@ public class TestJavaBindings extends TestCase {
}
public void testDomainCreate() throws Exception {
- Connect conn = new Connect("test:///default", false);
-
Domain dom1 = 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>"
@@ -129,7 +131,7 @@ public class TestJavaBindings extends TestCase {
this.validateDomainData(conn.domainLookupByUUID(UUID.fromString("004b96e1-2d78-c30f-5aa5-f03c87d21e67")));
}
- public void validateDomainData(Domain dom) throws Exception {
+ private void validateDomainData(Domain dom) throws Exception {
assertEquals("dom.getName()", "createst", dom.getName());
assertEquals("dom.getMaxMemory()", 8388608, dom.getMaxMemory());
// Not supported by the test driver
@@ -162,7 +164,6 @@ public class TestJavaBindings extends TestCase {
}
public void testInterfaces() throws Exception {
- Connect conn = new Connect("test:///default", false);
assertEquals("numOfInterfaces:", 1, conn.numOfInterfaces());
assertEquals("numOfInterfaces:", 0, conn.numOfDefinedInterfaces());
assertEquals("listDefinedInterfaces:", "eth1", conn.listInterfaces()[0]);
@@ -188,18 +189,18 @@ public class TestJavaBindings extends TestCase {
}
public void testAccessAfterClose() throws Exception {
- Connect conn = new Connect("test:///default", false);
conn.close();
assertTrue("conn.isConnected should be false", !conn.isConnected());
+ LibvirtException virException = null;
try {
conn.getHostName();
} catch (LibvirtException e) {
- // eat it
+ virException = e;
}
+ assertNotNull(virException);
}
public void testStoragePool() throws Exception {
- Connect conn = new Connect("test:///default", false);
StoragePool pool1 = conn.storagePoolDefineXML("<pool type='dir'>"
+ " <name>pool1</name>"
+ " <target>"
diff --git a/src/test/java/org/libvirt/TestLibvirtGlobals.java b/src/test/java/org/libvirt/TestLibvirtGlobals.java
new file mode 100644
index 0000000..b2b0d9f
--- /dev/null
+++ b/src/test/java/org/libvirt/TestLibvirtGlobals.java
@@ -0,0 +1,21 @@
+package org.libvirt;
+
+import java.util.UUID;
+
+import junit.framework.TestCase;
+
+/**
+ * libvirt tests not requiring an active connection
+ */
+public class TestLibvirtGlobals extends TestCase {
+ public void testErrorCallback() throws Exception {
+ DummyErrorCallback cb = new DummyErrorCallback();
+ Connect.setErrorCallback(cb);
+ try {
+ Connect conn = new Connect("test:///someUrl", false);
+ } catch (LibvirtException e) {
+ // eat it
+ }
+ assertTrue("We should have caught an error", cb.error);
+ }
+}
--
AV-Test GmbH, Henricistraße 20, 04155 Leipzig, Germany
Phone: +49 341 265 310 19
Web:<http://www.av-test.org>
Eingetragen am / Registered at: Amtsgericht Stendal (HRB 114076)
Geschaeftsfuehrer (CEO): Andreas Marx, Guido Habicht, Maik Morgenstern
12 years, 1 month
[libvirt] (no subject)
by cbley@av-test.de
>From 017d4d3ade44f117d4a03747fe1b2d9ee5762c0c Mon Sep 17 00:00:00 2001
Message-Id: <017d4d3ade44f117d4a03747fe1b2d9ee5762c0c.1350037981.git.cbley(a)av-test.de>
In-Reply-To: <cover.1350037981.git.cbley(a)av-test.de>
References: <2DA6F4A3691599408358374D182280F9141CF6(a)xmb-rcd-x04.cisco.com> <cover.1350037981.git.cbley(a)av-test.de>
From: cbley(a)av-test.de (Claudio Bley)
Date: Fri, 17 Aug 2012 14:47:38 +0200
Subject: [PATCH 03/15] Add findbugs build file for ant.
To: libvir-list(a)redhat.com
Organization: AV-Test GmbH, Germany
This requires a findbugs installation and the findbugs ant library.
---
findbugs.xml | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/findbugs.xml b/findbugs.xml
new file mode 100644
index 0000000..18d51f2
--- /dev/null
+++ b/findbugs.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- This runs the findbugs [http://findbugs.sourceforge.net/] ant task for -->
+<!-- the libvirt-java jar file. -->
+
+<!-- You must have findbugs installed and Ant needs to be able to -->
+<!-- locate the findbugs-java.jar file. -->
+
+<!-- Either use the -lib command line option or copy this jar -->
+<!-- to ${user.home}/.ant/lib or ${ant.home}/lib. -->
+
+<!-- E.g. -->
+
+<!-- "ant -Dfindbugs.home=/path/fb -lib /path/fb/lib/findbugs-ant.jar -f findbugs.xml" -->
+
+<project name="Libvirt Java Bindings - Findbugs" default="findbugs">
+ <!-- findbugs task definition -->
+ <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" />
+
+ <!-- enable debugging to let findbugs report line numbers -->
+ <property name="javac.debug" value="on" />
+
+ <import file="build.xml"/>
+
+ <property name="findbugs.output" value="text" />
+
+ <target name="findbugs" depends="build">
+ <findbugs home="${findbugs.home}"
+ output="${findbugs.output}" >
+ <auxClasspath refid="compile.classpath" />
+ <sourcePath path="${basedir}/src/main/java" />
+ <class location="${jar.file}" />
+ </findbugs>
+ </target>
+
+</project>
--
AV-Test GmbH, Henricistraße 20, 04155 Leipzig, Germany
Phone: +49 341 265 310 19
Web:<http://www.av-test.org>
Eingetragen am / Registered at: Amtsgericht Stendal (HRB 114076)
Geschaeftsfuehrer (CEO): Andreas Marx, Guido Habicht, Maik Morgenstern
12 years, 1 month
[libvirt] (no subject)
by cbley@av-test.de
>From 6f7b9301dd9983ff9f761e6503cebbdb2d45e750 Mon Sep 17 00:00:00 2001
Message-Id: <6f7b9301dd9983ff9f761e6503cebbdb2d45e750.1350037981.git.cbley(a)av-test.de>
In-Reply-To: <cover.1350037981.git.cbley(a)av-test.de>
References: <2DA6F4A3691599408358374D182280F9141CF6(a)xmb-rcd-x04.cisco.com> <cover.1350037981.git.cbley(a)av-test.de>
From: cbley(a)av-test.de (Claudio Bley)
Date: Wed, 10 Oct 2012 11:23:14 +0200
Subject: [PATCH 14/15] Remove functions not intended to be used by libvirt bindings.
To: libvir-list(a)redhat.com
Organization: AV-Test GmbH, Germany
This affects virSecretGetConnect, virNetworkGetConnect and
virDomainGetConnect.
The libvirt API documentation has this to say about those functions:
WARNING: When writing libvirt bindings in other languages, do not use this
function. Instead, store the connection and the ... object together.
---
src/main/java/org/libvirt/Connect.java | 39 -----------------------
src/main/java/org/libvirt/jna/Libvirt.java | 3 --
src/test/java/org/libvirt/TestJavaBindings.java | 3 --
3 files changed, 45 deletions(-)
diff --git a/src/main/java/org/libvirt/Connect.java b/src/main/java/org/libvirt/Connect.java
index a775ce1..b3e29be 100644
--- a/src/main/java/org/libvirt/Connect.java
+++ b/src/main/java/org/libvirt/Connect.java
@@ -31,45 +31,6 @@ import com.sun.jna.ptr.LongByReference;
public class Connect {
/**
- * Creates a new connection object from the domain. If all you want is the
- * existing domain's connection, use the getConnection method directly. Thie
- * method returns a new connection.
- *
- * @param domain
- * @return a new connection
- */
- public static Connect connectionForDomain(Domain domain) {
- ConnectionPointer conn = Libvirt.INSTANCE.virDomainGetConnect(domain.VDP);
- return new Connect(conn);
- }
-
- /**
- * Creates a new connection object from the network. If all you want is the
- * existing network's connection, use the getConnection method directly.
- * Thie method returns a new connection.
- *
- * @param network
- * @return a new connection
- */
- public static Connect connectionForNetwork(Network network) {
- ConnectionPointer conn = Libvirt.INSTANCE.virNetworkGetConnect(network.VNP);
- return new Connect(conn);
- }
-
- /**
- * Creates a new connection object from the network. If all you want is the
- * existing network's connection, use the getConnection method directly.
- * Thie method returns a new connection.
- *
- * @param secret
- * @return a new connection
- */
- public static Connect connectionForSecret(Secret secret) {
- ConnectionPointer conn = Libvirt.INSTANCE.virSecretGetConnect(secret.VSP);
- return new Connect(conn);
- }
-
- /**
* Get the version of a connection.
*
* @see <a
diff --git a/src/main/java/org/libvirt/jna/Libvirt.java b/src/main/java/org/libvirt/jna/Libvirt.java
index 5d2a291..87979cd 100644
--- a/src/main/java/org/libvirt/jna/Libvirt.java
+++ b/src/main/java/org/libvirt/jna/Libvirt.java
@@ -192,7 +192,6 @@ public interface Libvirt extends Library {
int virDomainDetachDeviceFlags(DomainPointer virDomainPtr, String deviceXML, int flags);
int virDomainFree(DomainPointer virDomainPtr);
int virDomainGetAutostart(DomainPointer virDomainPtr, IntByReference value);
- ConnectionPointer virDomainGetConnect(DomainPointer virDomainPtr);
int virDomainGetBlockInfo(DomainPointer virDomainPtr, String path, virDomainBlockInfo info, int flags);
int virDomainGetID(DomainPointer virDomainPtr);
int virDomainGetInfo(DomainPointer virDomainPtr, virDomainInfo vInfo);
@@ -242,7 +241,6 @@ public interface Libvirt extends Library {
int virDomainUndefine(DomainPointer virDomainPtr);
// Network functions
- ConnectionPointer virNetworkGetConnect(NetworkPointer virnetworkPtr);
int virNetworkCreate(NetworkPointer virConnectPtr);
NetworkPointer virNetworkCreateXML(ConnectionPointer virConnectPtr, String xmlDesc);
NetworkPointer virNetworkDefineXML(ConnectionPointer virConnectPtr, String xmlDesc);
@@ -341,7 +339,6 @@ public interface Libvirt extends Library {
int virInterfaceUndefine(InterfacePointer virDevicePointer);
// Secret Methods
- ConnectionPointer virSecretGetConnect(SecretPointer virSecretPtr);
int virSecretFree(SecretPointer virSecretPtr);
SecretPointer virSecretDefineXML(ConnectionPointer virConnectPtr, String xml, int flags);
int virSecretGetUUID(SecretPointer virSecretPtr, byte[] uuidString);
diff --git a/src/test/java/org/libvirt/TestJavaBindings.java b/src/test/java/org/libvirt/TestJavaBindings.java
index 55ca64b..bba4cdb 100644
--- a/src/test/java/org/libvirt/TestJavaBindings.java
+++ b/src/test/java/org/libvirt/TestJavaBindings.java
@@ -158,9 +158,6 @@ public final class TestJavaBindings extends TestCase {
dom.setSchedulerParameters(pars);
dom.getSchedulerParameters() ;
-
- assertNotNull(Connect.connectionForDomain(dom));
- assertTrue(Connect.connectionForDomain(dom) != dom.getConnect());
}
public void testInterfaces() throws Exception {
--
AV-Test GmbH, Henricistraße 20, 04155 Leipzig, Germany
Phone: +49 341 265 310 19
Web:<http://www.av-test.org>
Eingetragen am / Registered at: Amtsgericht Stendal (HRB 114076)
Geschaeftsfuehrer (CEO): Andreas Marx, Guido Habicht, Maik Morgenstern
12 years, 1 month
[libvirt] (no subject)
by cbley@av-test.de
>From 36816ec8660c0bdf964d8d6e745754382c9f001f Mon Sep 17 00:00:00 2001
Message-Id: <36816ec8660c0bdf964d8d6e745754382c9f001f.1350037981.git.cbley(a)av-test.de>
In-Reply-To: <cover.1350037981.git.cbley(a)av-test.de>
References: <2DA6F4A3691599408358374D182280F9141CF6(a)xmb-rcd-x04.cisco.com> <cover.1350037981.git.cbley(a)av-test.de>
From: cbley(a)av-test.de (Claudio Bley)
Date: Thu, 23 Aug 2012 09:36:39 +0200
Subject: [PATCH 10/15] Split "build" target and automatically rebuild out of date files.
To: libvir-list(a)redhat.com
Organization: AV-Test GmbH, Germany
The "build" target was split into these individual targets:
"build" (default target) only compiles the main files
"jar" packages the main files into a jar
"buildtests" compiles the test classes
The class files are rebuild when any of their dependent source
file changed.
---
build.xml | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/build.xml b/build.xml
index 4b73562..970b91a 100644
--- a/build.xml
+++ b/build.xml
@@ -33,6 +33,7 @@
<target name="init">
<mkdir dir="target/classes" />
<mkdir dir="target/testclasses" />
+ <mkdir dir="target/cache" />
<copy file="README.in" tofile="README" overwrite="true" filtering="true">
<filterset filtersfile="build.properties" />
</copy>
@@ -42,13 +43,27 @@
<delete dir="target" />
</target>
- <target name="build" depends="init" description="builds the code and jar files">
- <javac srcdir="src/main/java" debug="${javac.debug}" includes="**/*.java" classpathref="compile.classpath" destdir="target/classes" includeAntRuntime="false" />
- <javac srcdir="src/test/java" debug="${javac.debug}" includes="**/*.java" classpathref="test.classpath" destdir="target/testclasses" includeAntRuntime="false" />
+ <target name="jar" description="build the jar" depends="build">
<jar destfile="${jar.file}" basedir="target/classes" />
</target>
- <target name="test" depends="build" description="tests the code">
+ <target name="buildtests" description="build test classes" depends="build">
+ <depend srcdir="src/test/java"
+ destdir="target/testclasses"
+ cache="target/cache"
+ closure="true" />
+ <javac srcdir="src/test/java" debug="${javac.debug}" includes="**/*.java" classpathref="test.classpath" destdir="target/testclasses" includeAntRuntime="false" />
+ </target>
+
+ <target name="build" depends="init" description="builds the code">
+ <depend srcdir="src/main/java"
+ destdir="target/classes"
+ cache="target/cache"
+ closure="true" />
+ <javac srcdir="src/main/java" debug="${javac.debug}" includes="**/*.java" classpathref="compile.classpath" destdir="target/classes" includeAntRuntime="false" />
+ </target>
+
+ <target name="test" depends="buildtests" description="tests the code">
<junit printsummary="yes" fork="yes" forkMode="perBatch">
<formatter type="plain" />
<classpath refid="test.classpath" />
@@ -81,7 +96,7 @@
</copy>
</target>
- <target name="deb" depends="build" description="build a debian Debian package">
+ <target name="deb" depends="build,jar" description="build a debian Debian package">
<mkdir dir="${debian.pkgdir}/DEBIAN" />
<copy file="debian/control.in" tofile="${debian.controlfile}" overwrite="true" filtering="true">
<filterset filtersfile="build.properties" />
@@ -103,7 +118,7 @@
<rpm specfile="${spec}" command="-ba" topdir="${rpm.topdir}" />
</target>
- <target name="maven" depends="build,docs,src" description="publish the maven repo">
+ <target name="maven" depends="build,jar,docs,src" description="publish the maven repo">
<mkdir dir="target/repo" />
<get src="http://repo1.maven.org/maven2/org/apache/maven/maven-ant-tasks/2.1.3/mave..." dest="target/maven-ant-tasks-2.1.3.jar" />
<copy file="pom.xml.in" tofile="target/pom.xml" overwrite="true" filtering="true">
--
AV-Test GmbH, Henricistraße 20, 04155 Leipzig, Germany
Phone: +49 341 265 310 19
Web:<http://www.av-test.org>
Eingetragen am / Registered at: Amtsgericht Stendal (HRB 114076)
Geschaeftsfuehrer (CEO): Andreas Marx, Guido Habicht, Maik Morgenstern
12 years, 1 month
[libvirt] (no subject)
by cbley@av-test.de
>From 285e443aa24cde2324380ebeac83c97efc456f94 Mon Sep 17 00:00:00 2001
Message-Id: <285e443aa24cde2324380ebeac83c97efc456f94.1350037981.git.cbley(a)av-test.de>
In-Reply-To: <cover.1350037981.git.cbley(a)av-test.de>
References: <2DA6F4A3691599408358374D182280F9141CF6(a)xmb-rcd-x04.cisco.com> <cover.1350037981.git.cbley(a)av-test.de>
From: cbley(a)av-test.de (Claudio Bley)
Date: Thu, 11 Oct 2012 14:58:57 +0200
Subject: [PATCH 15/15] Explicitely define the order of a struct's fields.
To: libvir-list(a)redhat.com
Organization: AV-Test GmbH, Germany
The latest JNA version requires us to define the order of the fields
in a struct explicitely because the JVM does not guarantee the order
of the fields returned by Class.getFields().
---
src/main/java/org/libvirt/jna/virConnectAuth.java | 10 ++++++++++
.../java/org/libvirt/jna/virConnectCredential.java | 12 ++++++++++++
.../java/org/libvirt/jna/virDomainBlockInfo.java | 8 ++++++++
.../java/org/libvirt/jna/virDomainBlockStats.java | 11 +++++++++++
src/main/java/org/libvirt/jna/virDomainInfo.java | 11 +++++++++++
.../org/libvirt/jna/virDomainInterfaceStats.java | 13 +++++++++++++
.../java/org/libvirt/jna/virDomainJobInfo.java | 18 ++++++++++++++++++
.../java/org/libvirt/jna/virDomainMemoryStats.java | 7 +++++++
src/main/java/org/libvirt/jna/virError.java | 19 +++++++++++++++++++
src/main/java/org/libvirt/jna/virNodeInfo.java | 15 +++++++++++++++
.../java/org/libvirt/jna/virSchedParameter.java | 9 +++++++++
.../java/org/libvirt/jna/virStoragePoolInfo.java | 10 ++++++++++
.../java/org/libvirt/jna/virStorageVolInfo.java | 8 ++++++++
src/main/java/org/libvirt/jna/virVcpuInfo.java | 9 +++++++++
14 files changed, 160 insertions(+)
diff --git a/src/main/java/org/libvirt/jna/virConnectAuth.java b/src/main/java/org/libvirt/jna/virConnectAuth.java
index 74dd65c..f805b89 100644
--- a/src/main/java/org/libvirt/jna/virConnectAuth.java
+++ b/src/main/java/org/libvirt/jna/virConnectAuth.java
@@ -3,6 +3,9 @@ package org.libvirt.jna;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
+import java.util.List;
+import java.util.Arrays;
+
/**
* JNA mapping for the virConnectAuth structure
*/
@@ -11,4 +14,11 @@ public class virConnectAuth extends Structure {
public int ncredtype;
public Libvirt.VirConnectAuthCallback cb;
public Pointer cbdata;
+
+ protected List getFieldOrder() {
+ return Arrays.asList("credtype",
+ "ncredtype",
+ "cb",
+ "cbdata");
+ }
}
diff --git a/src/main/java/org/libvirt/jna/virConnectCredential.java b/src/main/java/org/libvirt/jna/virConnectCredential.java
index ba47482..7a750d1 100644
--- a/src/main/java/org/libvirt/jna/virConnectCredential.java
+++ b/src/main/java/org/libvirt/jna/virConnectCredential.java
@@ -2,6 +2,9 @@ package org.libvirt.jna;
import com.sun.jna.Structure;
+import java.util.List;
+import java.util.Arrays;
+
/**
* JNA mapping for the virConnectCredential structure
*/
@@ -13,4 +16,13 @@ public class virConnectCredential extends Structure implements Structure.ByRefer
// public Pointer result;
public String result;
public int resultlen;
+
+ protected List getFieldOrder() {
+ return Arrays.asList("type",
+ "prompt",
+ "challenge",
+ "defresult",
+ "result",
+ "resultlen");
+ }
}
diff --git a/src/main/java/org/libvirt/jna/virDomainBlockInfo.java b/src/main/java/org/libvirt/jna/virDomainBlockInfo.java
index 234a381..fdf8bb1 100644
--- a/src/main/java/org/libvirt/jna/virDomainBlockInfo.java
+++ b/src/main/java/org/libvirt/jna/virDomainBlockInfo.java
@@ -2,9 +2,17 @@ package org.libvirt.jna;
import com.sun.jna.Structure;
+import java.util.List;
+import java.util.Arrays;
+
public class virDomainBlockInfo extends Structure {
public long capacity;
public long allocation;
public long physical;
+ protected List getFieldOrder() {
+ return Arrays.asList("capacity",
+ "allocation",
+ "physical");
+ }
}
diff --git a/src/main/java/org/libvirt/jna/virDomainBlockStats.java b/src/main/java/org/libvirt/jna/virDomainBlockStats.java
index f29dba0..c7f0d8c 100644
--- a/src/main/java/org/libvirt/jna/virDomainBlockStats.java
+++ b/src/main/java/org/libvirt/jna/virDomainBlockStats.java
@@ -2,6 +2,9 @@ package org.libvirt.jna;
import com.sun.jna.Structure;
+import java.util.List;
+import java.util.Arrays;
+
/**
* JNA mapping for the virDomainBlockStats structure
*/
@@ -16,4 +19,12 @@ public class virDomainBlockStats extends Structure {
// is correct
public long errs; // this is a long long in the code, so a long mapping is
// correct
+
+ protected List getFieldOrder() {
+ return Arrays.asList("rd_req",
+ "rd_bytes",
+ "wr_req",
+ "wr_bytes",
+ "errs");
+ }
}
diff --git a/src/main/java/org/libvirt/jna/virDomainInfo.java b/src/main/java/org/libvirt/jna/virDomainInfo.java
index a93c0a5..8525f37 100644
--- a/src/main/java/org/libvirt/jna/virDomainInfo.java
+++ b/src/main/java/org/libvirt/jna/virDomainInfo.java
@@ -3,6 +3,9 @@ package org.libvirt.jna;
import com.sun.jna.NativeLong;
import com.sun.jna.Structure;
+import java.util.List;
+import java.util.Arrays;
+
/**
* JNA mapping for the virDomainInfo structure
*/
@@ -12,4 +15,12 @@ public class virDomainInfo extends Structure {
public NativeLong memory;
public short nrVirtCpu;
public long cpuTime;
+
+ protected List getFieldOrder() {
+ return Arrays.asList("state",
+ "maxMem",
+ "memory",
+ "nrVirtCpu",
+ "cpuTime");
+ }
}
diff --git a/src/main/java/org/libvirt/jna/virDomainInterfaceStats.java b/src/main/java/org/libvirt/jna/virDomainInterfaceStats.java
index 1cb0e66..39ceb52 100644
--- a/src/main/java/org/libvirt/jna/virDomainInterfaceStats.java
+++ b/src/main/java/org/libvirt/jna/virDomainInterfaceStats.java
@@ -2,6 +2,9 @@ package org.libvirt.jna;
import com.sun.jna.Structure;
+import java.util.List;
+import java.util.Arrays;
+
/**
* JNA mapping for the virDomainInterfaceStats structure
*/
@@ -23,4 +26,14 @@ public class virDomainInterfaceStats extends Structure {
public long tx_drop; // this is a long long in the code, so a long mapping
// is correct
+ protected List getFieldOrder() {
+ return Arrays.asList("rx_bytes",
+ "rx_packets",
+ "rx_errs",
+ "rx_drop",
+ "tx_bytes",
+ "tx_packets",
+ "tx_errs",
+ "tx_drop");
+ }
}
diff --git a/src/main/java/org/libvirt/jna/virDomainJobInfo.java b/src/main/java/org/libvirt/jna/virDomainJobInfo.java
index 98b4f59..f8b63e0 100644
--- a/src/main/java/org/libvirt/jna/virDomainJobInfo.java
+++ b/src/main/java/org/libvirt/jna/virDomainJobInfo.java
@@ -2,6 +2,9 @@ package org.libvirt.jna;
import com.sun.jna.Structure;
+import java.util.List;
+import java.util.Arrays;
+
public class virDomainJobInfo extends Structure {
public int type;
public long timeElapsed;
@@ -15,4 +18,19 @@ public class virDomainJobInfo extends Structure {
public long fileTotal;
public long fileProcessed;
public long fileRemaining;
+
+ protected List getFieldOrder() {
+ return Arrays.asList("type",
+ "timeElapsed",
+ "timeRemaining",
+ "dataTotal",
+ "dataProcessed",
+ "dataRemaining",
+ "memTotal",
+ "memProcessed",
+ "memRemaining",
+ "fileTotal",
+ "fileProcessed",
+ "fileRemaining");
+ }
}
diff --git a/src/main/java/org/libvirt/jna/virDomainMemoryStats.java b/src/main/java/org/libvirt/jna/virDomainMemoryStats.java
index 7a9f5d2..1d4e075 100644
--- a/src/main/java/org/libvirt/jna/virDomainMemoryStats.java
+++ b/src/main/java/org/libvirt/jna/virDomainMemoryStats.java
@@ -2,7 +2,14 @@ package org.libvirt.jna;
import com.sun.jna.Structure;
+import java.util.List;
+import java.util.Arrays;
+
public class virDomainMemoryStats extends Structure {
public int tag ;
public long val ;
+
+ protected List getFieldOrder() {
+ return Arrays.asList("tag", "val");
+ }
}
diff --git a/src/main/java/org/libvirt/jna/virError.java b/src/main/java/org/libvirt/jna/virError.java
index e2580dd..b3fad6d 100644
--- a/src/main/java/org/libvirt/jna/virError.java
+++ b/src/main/java/org/libvirt/jna/virError.java
@@ -3,6 +3,9 @@ package org.libvirt.jna;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
+import java.util.List;
+import java.util.Arrays;
+
/**
* JNA mapping for the virError structure
*/
@@ -19,4 +22,20 @@ public class virError extends Structure {
public int int1;
public int int2;
public NetworkPointer net;
+
+ protected List getFieldOrder() {
+ return Arrays.asList(
+ "code",
+ "domain",
+ "message",
+ "level",
+ "conn",
+ "dom",
+ "str1",
+ "str2",
+ "str3",
+ "int1",
+ "int2",
+ "net");
+ }
}
diff --git a/src/main/java/org/libvirt/jna/virNodeInfo.java b/src/main/java/org/libvirt/jna/virNodeInfo.java
index 532aad9..6f0d002 100644
--- a/src/main/java/org/libvirt/jna/virNodeInfo.java
+++ b/src/main/java/org/libvirt/jna/virNodeInfo.java
@@ -3,6 +3,9 @@ package org.libvirt.jna;
import com.sun.jna.NativeLong;
import com.sun.jna.Structure;
+import java.util.List;
+import java.util.Arrays;
+
/**
* JNA mapping for the virNodeInfo structure
*/
@@ -21,4 +24,16 @@ public class virNodeInfo extends Structure {
public int sockets;
public int cores;
public int threads;
+
+ protected List getFieldOrder() {
+ return Arrays.asList(
+ "model",
+ "memory",
+ "cpus",
+ "mhz",
+ "nodes",
+ "sockets",
+ "cores",
+ "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
index 0013fff..e213f04 100644
--- a/src/main/java/org/libvirt/jna/virSchedParameter.java
+++ b/src/main/java/org/libvirt/jna/virSchedParameter.java
@@ -2,6 +2,9 @@ package org.libvirt.jna;
import com.sun.jna.Structure;
+import java.util.List;
+import java.util.Arrays;
+
/**
* JNA mapping for the virSchedParameter structure
*/
@@ -9,4 +12,10 @@ public class virSchedParameter extends Structure {
public byte field[] = new byte[Libvirt.VIR_DOMAIN_SCHED_FIELD_LENGTH];
public int type;
public virSchedParameterValue value;
+
+ protected List getFieldOrder() {
+ return Arrays.asList("field",
+ "type",
+ "value");
+ }
}
diff --git a/src/main/java/org/libvirt/jna/virStoragePoolInfo.java b/src/main/java/org/libvirt/jna/virStoragePoolInfo.java
index 5a98e08..860b78e 100644
--- a/src/main/java/org/libvirt/jna/virStoragePoolInfo.java
+++ b/src/main/java/org/libvirt/jna/virStoragePoolInfo.java
@@ -2,6 +2,9 @@ package org.libvirt.jna;
import com.sun.jna.Structure;
+import java.util.List;
+import java.util.Arrays;
+
/**
* JNA mapping for the virStoragePoolInfo structure
*/
@@ -13,4 +16,11 @@ public class virStoragePoolInfo extends Structure {
// mapping is correct
public long available; // this is a long long in the code, so a long mapping
// is correct
+
+ protected List getFieldOrder() {
+ return Arrays.asList("state",
+ "capacity",
+ "allocation",
+ "available");
+ }
}
diff --git a/src/main/java/org/libvirt/jna/virStorageVolInfo.java b/src/main/java/org/libvirt/jna/virStorageVolInfo.java
index db8a5bd..d07b22e 100644
--- a/src/main/java/org/libvirt/jna/virStorageVolInfo.java
+++ b/src/main/java/org/libvirt/jna/virStorageVolInfo.java
@@ -2,6 +2,9 @@ package org.libvirt.jna;
import com.sun.jna.Structure;
+import java.util.List;
+import java.util.Arrays;
+
/**
* JNA mapping for the virStorageVolInfo structure
*/
@@ -12,4 +15,9 @@ public class virStorageVolInfo extends Structure {
public long allocation; // this is a long long in the code, so a long
// mapping is correct
+ protected List getFieldOrder() {
+ return Arrays.asList("type",
+ "capacity",
+ "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
index 16f237d..7bf3448 100644
--- a/src/main/java/org/libvirt/jna/virVcpuInfo.java
+++ b/src/main/java/org/libvirt/jna/virVcpuInfo.java
@@ -2,6 +2,9 @@ package org.libvirt.jna;
import com.sun.jna.Structure;
+import java.util.List;
+import java.util.Arrays;
+
/**
* JNA mapping for the virVcpuInfo structure
*/
@@ -12,4 +15,10 @@ public class virVcpuInfo extends Structure {
// is correct
public int cpu;
+ protected List getFieldOrder() {
+ return Arrays.asList("number",
+ "state",
+ "cpuTime",
+ "cpu");
+ }
}
--
AV-Test GmbH, Henricistraße 20, 04155 Leipzig, Germany
Phone: +49 341 265 310 19
Web:<http://www.av-test.org>
Eingetragen am / Registered at: Amtsgericht Stendal (HRB 114076)
Geschaeftsfuehrer (CEO): Andreas Marx, Guido Habicht, Maik Morgenstern
12 years, 1 month
[libvirt] (no subject)
by cbley@av-test.de
>From 7c51b39360f49bb06d36abafe68a9e0ca40556ae Mon Sep 17 00:00:00 2001
Message-Id: <7c51b39360f49bb06d36abafe68a9e0ca40556ae.1350037981.git.cbley(a)av-test.de>
In-Reply-To: <cover.1350037981.git.cbley(a)av-test.de>
References: <2DA6F4A3691599408358374D182280F9141CF6(a)xmb-rcd-x04.cisco.com> <cover.1350037981.git.cbley(a)av-test.de>
From: cbley(a)av-test.de (Claudio Bley)
Date: Wed, 10 Oct 2012 11:03:34 +0200
Subject: [PATCH 13/15] Fix memory leaks for libvirt functions returning newly allocated memory.
To: libvir-list(a)redhat.com
Organization: AV-Test GmbH, Germany
Use JNA's Native.free() method to free memory. This requires JNA version
3.3.0 or later.
Remove virFree from Libvirt interface.
---
src/main/java/org/libvirt/Connect.java | 109 ++++++++++++++++++----------
src/main/java/org/libvirt/Domain.java | 24 ++++--
src/main/java/org/libvirt/Interface.java | 10 ++-
src/main/java/org/libvirt/Library.java | 62 ++++++++++++++++
src/main/java/org/libvirt/Network.java | 17 ++++-
src/main/java/org/libvirt/jna/Libvirt.java | 37 +++++-----
6 files changed, 187 insertions(+), 72 deletions(-)
diff --git a/src/main/java/org/libvirt/Connect.java b/src/main/java/org/libvirt/Connect.java
index ae306d6..a775ce1 100644
--- a/src/main/java/org/libvirt/Connect.java
+++ b/src/main/java/org/libvirt/Connect.java
@@ -19,6 +19,7 @@ import static org.libvirt.Library.libvirt;
import com.sun.jna.Memory;
import com.sun.jna.NativeLong;
+import com.sun.jna.Pointer;
import com.sun.jna.ptr.LongByReference;
/**
@@ -510,8 +511,12 @@ public class Connect {
* description</a>
*/
public String getCapabilities() throws LibvirtException {
- String returnValue = libvirt.virConnectGetCapabilities(VCP);
- return processError(returnValue);
+ Pointer ptr = processError(libvirt.virConnectGetCapabilities(VCP));
+ try {
+ return Library.getString(ptr);
+ } finally {
+ Library.free(ptr);
+ }
}
/**
@@ -545,7 +550,12 @@ public class Connect {
* @throws LibvirtException
*/
public String getHostName() throws LibvirtException {
- return processError(libvirt.virConnectGetHostname(VCP));
+ Pointer ptr = processError(libvirt.virConnectGetHostname(VCP));
+ try {
+ return Library.getString(ptr);
+ } finally {
+ Library.free(ptr);
+ }
}
/**
@@ -701,11 +711,13 @@ public class Connect {
*/
public String[] listDefinedDomains() throws LibvirtException {
int maxnames = numOfDefinedDomains();
- String[] names = new String[maxnames];
if (maxnames > 0) {
- processError(libvirt.virConnectListDefinedDomains(VCP, names, maxnames));
+ final Pointer[] names = new Pointer[maxnames];
+ final int n = processError(libvirt.virConnectListDefinedDomains(VCP, names, maxnames));
+ return Library.toStringArray(names, n);
+ } else {
+ return Library.NO_STRINGS;
}
- return names;
}
/**
@@ -716,12 +728,14 @@ public class Connect {
* @throws LibvirtException
*/
public String[] listDefinedInterfaces() throws LibvirtException {
- int num = numOfDefinedInterfaces();
- String[] returnValue = new String[num];
- if (num > 0) {
- processError(libvirt.virConnectListDefinedInterfaces(VCP, returnValue, num));
+ final int max = numOfDefinedInterfaces();
+ if (max > 0) {
+ final Pointer[] ifs = new Pointer[max];
+ final int n = processError(libvirt.virConnectListDefinedInterfaces(VCP, ifs, max));
+ return Library.toStringArray(ifs, n);
+ } else {
+ return Library.NO_STRINGS;
}
- return returnValue;
}
/**
@@ -733,12 +747,13 @@ public class Connect {
*/
public String[] listDefinedNetworks() throws LibvirtException {
int maxnames = numOfDefinedNetworks();
- String[] names = new String[maxnames];
-
if (maxnames > 0) {
- processError(libvirt.virConnectListDefinedNetworks(VCP, names, maxnames));
+ final Pointer[] names = new Pointer[maxnames];
+ final int n = processError(libvirt.virConnectListDefinedNetworks(VCP, names, maxnames));
+ return Library.toStringArray(names, n);
+ } else {
+ return Library.NO_STRINGS;
}
- return names;
}
/**
@@ -750,9 +765,13 @@ public class Connect {
*/
public String[] listDefinedStoragePools() throws LibvirtException {
int num = numOfDefinedStoragePools();
- String[] returnValue = new String[num];
- processError(libvirt.virConnectListDefinedStoragePools(VCP, returnValue, num));
- return returnValue;
+ if (num > 0) {
+ Pointer[] pools = new Pointer[num];
+ final int n = processError(libvirt.virConnectListDefinedStoragePools(VCP, pools, num));
+ return Library.toStringArray(pools, n);
+ } else {
+ return Library.NO_STRINGS;
+ }
}
/**
@@ -763,12 +782,13 @@ public class Connect {
*/
public String[] listDevices(String capabilityName) throws LibvirtException {
int maxDevices = numOfDevices(capabilityName);
- String[] names = new String[maxDevices];
-
if (maxDevices > 0) {
- processError(libvirt.virNodeListDevices(VCP, capabilityName, names, maxDevices, 0));
+ Pointer[] names = new Pointer[maxDevices];
+ final int n = processError(libvirt.virNodeListDevices(VCP, capabilityName, names, maxDevices, 0));
+ return Library.toStringArray(names, n);
+ } else {
+ return Library.NO_STRINGS;
}
- return names;
}
/**
@@ -796,11 +816,13 @@ public class Connect {
*/
public String[] listInterfaces() throws LibvirtException {
int num = numOfInterfaces();
- String[] returnValue = new String[num];
if (num > 0) {
- processError(libvirt.virConnectListInterfaces(VCP, returnValue, num));
+ Pointer[] ifs = new Pointer[num];
+ final int n = processError(libvirt.virConnectListInterfaces(VCP, ifs, num));
+ return Library.toStringArray(ifs, n);
+ } else {
+ return Library.NO_STRINGS;
}
- return returnValue;
}
/**
@@ -811,11 +833,13 @@ public class Connect {
*/
public String[] listNetworkFilters() throws LibvirtException {
int maxnames = numOfNetworkFilters();
- String[] names = new String[maxnames];
if (maxnames > 0) {
- processError(libvirt.virConnectListNWFilters(VCP, names, maxnames));
+ Pointer[] names = new Pointer[maxnames];
+ final int n = processError(libvirt.virConnectListNWFilters(VCP, names, maxnames));
+ return Library.toStringArray(names, n);
+ } else {
+ return Library.NO_STRINGS;
}
- return names;
}
/**
@@ -827,12 +851,13 @@ public class Connect {
*/
public String[] listNetworks() throws LibvirtException {
int maxnames = numOfNetworks();
- String[] names = new String[maxnames];
-
if (maxnames > 0) {
- processError(libvirt.virConnectListNetworks(VCP, names, maxnames));
+ Pointer[] names = new Pointer[maxnames];
+ final int n = processError(libvirt.virConnectListNetworks(VCP, names, maxnames));
+ return Library.toStringArray(names, n);
+ } else {
+ return Library.NO_STRINGS;
}
- return names;
}
/**
@@ -843,9 +868,13 @@ public class Connect {
*/
public String[] listSecrets() throws LibvirtException {
int num = numOfSecrets();
- String[] returnValue = new String[num];
- processError(libvirt.virConnectListSecrets(VCP, returnValue, num));
- return returnValue;
+ if (num > 0) {
+ Pointer[] returnValue = new Pointer[num];
+ final int n = processError(libvirt.virConnectListSecrets(VCP, returnValue, num));
+ return Library.toStringArray(returnValue, n);
+ } else {
+ return Library.NO_STRINGS;
+ }
}
/**
@@ -857,9 +886,13 @@ public class Connect {
*/
public String[] listStoragePools() throws LibvirtException {
int num = numOfStoragePools();
- String[] returnValue = new String[num];
- processError(libvirt.virConnectListStoragePools(VCP, returnValue, num));
- return returnValue;
+ if (num > 0) {
+ Pointer[] returnValue = new Pointer[num];
+ final int n = processError(libvirt.virConnectListStoragePools(VCP, returnValue, num));
+ return Library.toStringArray(returnValue, n);
+ } else {
+ return Library.NO_STRINGS;
+ }
}
/**
diff --git a/src/main/java/org/libvirt/Domain.java b/src/main/java/org/libvirt/Domain.java
index 45fba26..1c86bd4 100644
--- a/src/main/java/org/libvirt/Domain.java
+++ b/src/main/java/org/libvirt/Domain.java
@@ -426,9 +426,13 @@ public class Domain {
* @throws LibvirtException
*/
public String getOSType() throws LibvirtException {
- String returnValue = libvirt.virDomainGetOSType(VDP);
+ Pointer ptr = libvirt.virDomainGetOSType(VDP);
processError();
- return returnValue;
+ try {
+ return Library.getString(ptr);
+ } finally {
+ Library.free(ptr);
+ }
}
/**
@@ -443,8 +447,8 @@ public class Domain {
Pointer pScheduler = libvirt.virDomainGetSchedulerType(VDP, nParams);
processError();
if (pScheduler != null) {
- String scheduler = pScheduler.getString(0);
- libvirt.virFree(new PointerByReference(pScheduler));
+ String scheduler = Library.getString(pScheduler);
+ Library.free(pScheduler);
virSchedParameter[] nativeParams = new virSchedParameter[nParams.getValue()];
returnValue = new SchedParameter[nParams.getValue()];
libvirt.virDomainGetSchedulerParameters(VDP, nativeParams, nParams);
@@ -472,8 +476,8 @@ public class Domain {
Pointer pScheduler = libvirt.virDomainGetSchedulerType(VDP, nParams);
processError();
String[] array = new String[1];
- array[0] = pScheduler.getString(0);
- libvirt.virFree(new PointerByReference(pScheduler));
+ array[0] = Library.getString(pScheduler);
+ Library.free(pScheduler);
return array;
}
@@ -569,9 +573,13 @@ public class Domain {
* Description format </a>
*/
public String getXMLDesc(int flags) throws LibvirtException {
- String returnValue = libvirt.virDomainGetXMLDesc(VDP, flags);
+ Pointer ptr = libvirt.virDomainGetXMLDesc(VDP, flags);
processError();
- return returnValue;
+ try {
+ return Library.getString(ptr);
+ } finally {
+ Library.free(ptr);
+ }
}
/**
diff --git a/src/main/java/org/libvirt/Interface.java b/src/main/java/org/libvirt/Interface.java
index 684adca..71ba3da 100644
--- a/src/main/java/org/libvirt/Interface.java
+++ b/src/main/java/org/libvirt/Interface.java
@@ -4,6 +4,8 @@ import org.libvirt.jna.InterfacePointer;
import org.libvirt.jna.Libvirt;
import static org.libvirt.Library.libvirt;
+import com.sun.jna.Pointer;
+
/**
* A device which is attached to a node
*/
@@ -113,9 +115,13 @@ public class Interface {
* @throws LibvirtException
*/
public String getXMLDescription(int flags) throws LibvirtException {
- String xml = libvirt.virInterfaceGetXMLDesc(VIP, flags);
+ Pointer xml = libvirt.virInterfaceGetXMLDesc(VIP, flags);
processError();
- return xml;
+ try {
+ return Library.getString(xml);
+ } finally {
+ Library.free(xml);
+ }
}
/**
diff --git a/src/main/java/org/libvirt/Library.java b/src/main/java/org/libvirt/Library.java
index 035ed06..0136095 100644
--- a/src/main/java/org/libvirt/Library.java
+++ b/src/main/java/org/libvirt/Library.java
@@ -2,15 +2,25 @@ package org.libvirt;
import org.libvirt.jna.Libvirt;
+import com.sun.jna.Native;
+import com.sun.jna.Pointer;
+
/**
* This class represents an instance of the JNA mapped libvirt
* library.
*
* The library will get loaded when first accessing this class.
+ *
+ * Additionally, this class contains internal methods to ease
+ * implementing the public API.
*/
final class Library {
final static Libvirt libvirt;
+ // an empty string array constant
+ // prefer this over creating empty arrays dynamically.
+ final static String[] NO_STRINGS = {};
+
// Load the native part
static {
Libvirt.INSTANCE.virInitialize();
@@ -23,4 +33,56 @@ final class Library {
}
private Library() {}
+
+ /**
+ * Free memory pointed to by ptr.
+ */
+ static void free(Pointer ptr) {
+ Native.free(Pointer.nativeValue(ptr));
+ Pointer.nativeValue(ptr, 0L);
+ }
+
+ /**
+ * Convert the data pointed to by {@code ptr} to a String.
+ */
+ static String getString(Pointer ptr) {
+ final long len = ptr.indexOf(0, (byte)0);
+ assert (len != -1): "C-Strings must be \\0 terminated.";
+
+ final byte[] data = ptr.getByteArray(0, (int)len);
+ try {
+ return new String(data, "utf-8");
+ } catch (java.io.UnsupportedEncodingException e) {
+ throw new RuntimeException("Libvirt problem: UTF-8 decoding error.", e);
+ }
+ }
+
+ /**
+ * Calls {@link #toStringArray(Pointer[], int)}.
+ */
+ static String[] toStringArray(Pointer[] ptrArr) {
+ return toStringArray(ptrArr, ptrArr.length);
+ }
+
+ /**
+ * Convert the given array of native pointers to "char" in
+ * UTF-8 encoding to an array of Strings.
+ *
+ * \note The memory used by the elements of the original array
+ * is freed and ptrArr is modified.
+ */
+ static String[] toStringArray(Pointer[] ptrArr, final int size) {
+ try {
+ final String[] result = new String[size];
+ for (int i = 0; i < size; ++i) {
+ result[i] = Library.getString(ptrArr[i]);
+ }
+ return result;
+ } finally {
+ for (int i = 0; i < size; ++i) {
+ Library.free(ptrArr[i]);
+ ptrArr[i] = null;
+ }
+ }
+ }
}
diff --git a/src/main/java/org/libvirt/Network.java b/src/main/java/org/libvirt/Network.java
index bdb0d78..2244c5d 100644
--- a/src/main/java/org/libvirt/Network.java
+++ b/src/main/java/org/libvirt/Network.java
@@ -5,6 +5,7 @@ import org.libvirt.jna.NetworkPointer;
import static org.libvirt.Library.libvirt;
import com.sun.jna.Native;
+import com.sun.jna.Pointer;
import com.sun.jna.ptr.IntByReference;
/**
@@ -105,9 +106,13 @@ public class Network {
* @throws LibvirtException
*/
public String getBridgeName() throws LibvirtException {
- String returnValue = libvirt.virNetworkGetBridgeName(VNP);
+ final Pointer ptr = libvirt.virNetworkGetBridgeName(VNP);
processError();
- return returnValue;
+ try {
+ return Library.getString(ptr);
+ } finally {
+ Library.free(ptr);
+ }
}
/**
@@ -178,9 +183,13 @@ public class Network {
* @throws LibvirtException
*/
public String getXMLDesc(int flags) throws LibvirtException {
- String returnValue = libvirt.virNetworkGetXMLDesc(VNP, flags);
+ Pointer ptr = libvirt.virNetworkGetXMLDesc(VNP, flags);
processError();
- return returnValue;
+ try {
+ return Library.getString(ptr);
+ } finally {
+ Library.free(ptr);
+ }
}
/**
diff --git a/src/main/java/org/libvirt/jna/Libvirt.java b/src/main/java/org/libvirt/jna/Libvirt.java
index be0de3b..5d2a291 100644
--- a/src/main/java/org/libvirt/jna/Libvirt.java
+++ b/src/main/java/org/libvirt/jna/Libvirt.java
@@ -56,9 +56,6 @@ import com.sun.jna.ptr.PointerByReference;
*
*/
public interface Libvirt extends Library {
- // Memory management
- void virFree(PointerByReference ptr);
-
// Callbacks
/**
* Callback interface for authorization
@@ -126,23 +123,23 @@ public interface Libvirt extends Library {
int virConnectIsEncrypted(ConnectionPointer virConnectPtr) ;
int virConnectIsSecure(ConnectionPointer virConnectPtr) ;
String virConnectFindStoragePoolSources(ConnectionPointer virConnectPtr, String type, String srcSpec, int flags);
- String virConnectGetCapabilities(ConnectionPointer virConnectPtr);
- String virConnectGetHostname(ConnectionPointer virConnectPtr);
+ Pointer virConnectGetCapabilities(ConnectionPointer virConnectPtr);
+ Pointer virConnectGetHostname(ConnectionPointer virConnectPtr);
int virConnectGetLibVersion(ConnectionPointer virConnectPtr, LongByReference libVer);
int virConnectGetMaxVcpus(ConnectionPointer virConnectPtr, String type);
String virConnectGetType(ConnectionPointer virConnectPtr);
String virConnectGetURI(ConnectionPointer virConnectPtr);
int virConnectGetVersion(ConnectionPointer virConnectPtr, LongByReference hvVer);
- int virConnectListDefinedDomains(ConnectionPointer virConnectPtr, String[] name, int maxnames);
- int virConnectListDefinedNetworks(ConnectionPointer virConnectPtr, String[] name, int maxnames);
- int virConnectListDefinedStoragePools(ConnectionPointer virConnectPtr, String[] names, int maxnames);
- int virConnectListDefinedInterfaces(ConnectionPointer virConnectPtr, String[] name, int maxNames);
+ int virConnectListDefinedDomains(ConnectionPointer virConnectPtr, Pointer[] name, int maxnames);
+ int virConnectListDefinedNetworks(ConnectionPointer virConnectPtr, Pointer[] name, int maxnames);
+ int virConnectListDefinedStoragePools(ConnectionPointer virConnectPtr, Pointer[] names, int maxnames);
+ int virConnectListDefinedInterfaces(ConnectionPointer virConnectPtr, Pointer[] name, int maxNames);
int virConnectListDomains(ConnectionPointer virConnectPtr, int[] ids, int maxnames);
- int virConnectListInterfaces(ConnectionPointer virConnectPtr, String[] name, int maxNames);
- int virConnectListNetworks(ConnectionPointer virConnectPtr, String[] name, int maxnames);
- int virConnectListNWFilters(ConnectionPointer virConnectPtr, String[] name, int maxnames);
- int virConnectListSecrets(ConnectionPointer virConnectPtr, String[] uids, int maxUids);
- int virConnectListStoragePools(ConnectionPointer virConnectPtr, String[] names, int maxnames);
+ int virConnectListInterfaces(ConnectionPointer virConnectPtr, Pointer[] name, int maxNames);
+ int virConnectListNetworks(ConnectionPointer virConnectPtr, Pointer[] name, int maxnames);
+ int virConnectListNWFilters(ConnectionPointer virConnectPtr, Pointer[] name, int maxnames);
+ int virConnectListSecrets(ConnectionPointer virConnectPtr, Pointer[] uids, int maxUids);
+ int virConnectListStoragePools(ConnectionPointer virConnectPtr, Pointer[] names, int maxnames);
int virConnectNumOfDefinedDomains(ConnectionPointer virConnectPtr);
int virConnectNumOfDefinedNetworks(ConnectionPointer virConnectPtr);
int virConnectNumOfDefinedInterfaces(ConnectionPointer virConnectPtr);
@@ -203,14 +200,14 @@ public interface Libvirt extends Library {
NativeLong virDomainGetMaxMemory(DomainPointer virDomainPtr);
int virDomainGetMaxVcpus(DomainPointer virDomainPtr);
String virDomainGetName(DomainPointer virDomainPtr);
- String virDomainGetOSType(DomainPointer virDomainPtr);
+ Pointer virDomainGetOSType(DomainPointer virDomainPtr);
int virDomainGetSchedulerParameters(DomainPointer virDomainPtr, virSchedParameter[] params,
IntByReference nparams);
Pointer virDomainGetSchedulerType(DomainPointer virDomainPtr, IntByReference nparams);
int virDomainGetUUID(DomainPointer virDomainPtr, byte[] uuidString);
int virDomainGetUUIDString(DomainPointer virDomainPtr, byte[] uuidString);
int virDomainGetVcpus(DomainPointer virDomainPtr, virVcpuInfo[] info, int maxInfo, byte[] cpumaps, int maplen);
- String virDomainGetXMLDesc(DomainPointer virDomainPtr, int flags);
+ Pointer virDomainGetXMLDesc(DomainPointer virDomainPtr, int flags);
int virDomainHasCurrentSnapshot(DomainPointer virDomainPtr, int flags);
int virDomainHasManagedSaveImage(DomainPointer virDomainPtr, int flags);
int virDomainInterfaceStats(DomainPointer virDomainPtr, String path, virDomainInterfaceStats stats, int size);
@@ -252,11 +249,11 @@ public interface Libvirt extends Library {
int virNetworkDestroy(NetworkPointer virConnectPtr);
int virNetworkFree(NetworkPointer virConnectPtr);
int virNetworkGetAutostart(NetworkPointer virNetworkPtr, IntByReference value);
- String virNetworkGetBridgeName(NetworkPointer virNetworkPtr);
+ Pointer virNetworkGetBridgeName(NetworkPointer virNetworkPtr);
String virNetworkGetName(NetworkPointer virNetworkPtr);
int virNetworkGetUUID(NetworkPointer virNetworkPtr, byte[] uuidString);
int virNetworkGetUUIDString(NetworkPointer virNetworkPtr, byte[] uuidString);
- String virNetworkGetXMLDesc(NetworkPointer virNetworkPtr, int flags);
+ Pointer virNetworkGetXMLDesc(NetworkPointer virNetworkPtr, int flags);
int virNetworkIsActive(NetworkPointer virNetworkPtr);
int virNetworkIsPersistent(NetworkPointer virNetworkPtr);
NetworkPointer virNetworkLookupByName(ConnectionPointer virConnectPtr, String name);
@@ -273,7 +270,7 @@ public interface Libvirt extends Library {
// Node/Device functions
int virNodeNumOfDevices(ConnectionPointer virConnectPtr, String capabilityName, int flags);
- int virNodeListDevices(ConnectionPointer virConnectPtr, String capabilityName, String[] names, int maxnames,
+ int virNodeListDevices(ConnectionPointer virConnectPtr, String capabilityName, Pointer[] names, int maxnames,
int flags);
DevicePointer virNodeDeviceLookupByName(ConnectionPointer virConnectPtr, String name);
String virNodeDeviceGetName(DevicePointer virDevicePointer);
@@ -337,7 +334,7 @@ public interface Libvirt extends Library {
int virInterfaceFree(InterfacePointer virDevicePointer);
String virInterfaceGetName(InterfacePointer virInterfacePtr);
String virInterfaceGetMACString(InterfacePointer virInterfacePtr);
- String virInterfaceGetXMLDesc(InterfacePointer virInterfacePtr, int flags);
+ Pointer virInterfaceGetXMLDesc(InterfacePointer virInterfacePtr, int flags);
int virInterfaceIsActive(InterfacePointer virDevicePointer);
InterfacePointer virInterfaceLookupByMACString(ConnectionPointer virConnectPtr, String mac);
InterfacePointer virInterfaceLookupByName(ConnectionPointer virConnectPtr, String name);
--
AV-Test GmbH, Henricistraße 20, 04155 Leipzig, Germany
Phone: +49 341 265 310 19
Web:<http://www.av-test.org>
Eingetragen am / Registered at: Amtsgericht Stendal (HRB 114076)
Geschaeftsfuehrer (CEO): Andreas Marx, Guido Habicht, Maik Morgenstern
12 years, 1 month