[libvirt] [PATCH] Allow byte[] arrays to be set as a secretValue

Signed-off-by: Wido den Hollander <wido@widodh.nl> --- src/main/java/org/libvirt/Secret.java | 11 +++++++++++ src/main/java/org/libvirt/jna/Libvirt.java | 1 + 2 files changed, 12 insertions(+), 0 deletions(-) diff --git a/src/main/java/org/libvirt/Secret.java b/src/main/java/org/libvirt/Secret.java index e536cf4..48f7895 100644 --- a/src/main/java/org/libvirt/Secret.java +++ b/src/main/java/org/libvirt/Secret.java @@ -146,6 +146,17 @@ public class Secret { } /** + * Sets the value of the secret + * + * @return 0 on success, -1 on failure. + */ + public int setValue(byte[] value) throws LibvirtException { + int returnValue = libvirt.virSecretSetValue(VSP, value, new NativeLong(value.length), 0); + processError(); + return returnValue; + } + + /** * Undefines, but does not free, the Secret. * * @return 0 on success, -1 on failure. diff --git a/src/main/java/org/libvirt/jna/Libvirt.java b/src/main/java/org/libvirt/jna/Libvirt.java index 2c8c03d..b1e53a2 100644 --- a/src/main/java/org/libvirt/jna/Libvirt.java +++ b/src/main/java/org/libvirt/jna/Libvirt.java @@ -336,6 +336,7 @@ public interface Libvirt extends Library { 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); //Stream Methods -- 1.7.5.4

On 03/09/2012 07:23 AM, Wido den Hollander wrote:
Signed-off-by: Wido den Hollander <wido@widodh.nl> --- src/main/java/org/libvirt/Secret.java | 11 +++++++++++ src/main/java/org/libvirt/jna/Libvirt.java | 1 + 2 files changed, 12 insertions(+), 0 deletions(-)
If you will do: git config format.subjectprefix 'PATCH libvirt-jaba' it will make it easier to identify when you are patching the java bindings.
diff --git a/src/main/java/org/libvirt/Secret.java b/src/main/java/org/libvirt/Secret.java index e536cf4..48f7895 100644 --- a/src/main/java/org/libvirt/Secret.java +++ b/src/main/java/org/libvirt/Secret.java @@ -146,6 +146,17 @@ public class Secret { }
/** + * Sets the value of the secret + * + * @return 0 on success, -1 on failure. + */ + public int setValue(byte[] value) throws LibvirtException { + int returnValue = libvirt.virSecretSetValue(VSP, value, new NativeLong(value.length), 0); + processError(); + return returnValue; + }
It looks like the last commit to libvirt-java.git was more than a year ago; there's a lot of missing bindings. Would you be willing to step in and provide even more patches on this front? Meanwhile, this patch looks okay to me, but I've never contributed to libvirt-java; I'll wait to see if someone who has actually participated in this project has comments. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 03/09/2012 03:58 PM, Eric Blake wrote:
On 03/09/2012 07:23 AM, Wido den Hollander wrote:
Signed-off-by: Wido den Hollander<wido@widodh.nl> --- src/main/java/org/libvirt/Secret.java | 11 +++++++++++ src/main/java/org/libvirt/jna/Libvirt.java | 1 + 2 files changed, 12 insertions(+), 0 deletions(-)
If you will do:
git config format.subjectprefix 'PATCH libvirt-jaba'
it will make it easier to identify when you are patching the java bindings.
I'll do! Will re-send the correct patch shortly.
diff --git a/src/main/java/org/libvirt/Secret.java b/src/main/java/org/libvirt/Secret.java index e536cf4..48f7895 100644 --- a/src/main/java/org/libvirt/Secret.java +++ b/src/main/java/org/libvirt/Secret.java @@ -146,6 +146,17 @@ public class Secret { }
/** + * Sets the value of the secret + * + * @return 0 on success, -1 on failure. + */ + public int setValue(byte[] value) throws LibvirtException { + int returnValue = libvirt.virSecretSetValue(VSP, value, new NativeLong(value.length), 0); + processError(); + return returnValue; + }
It looks like the last commit to libvirt-java.git was more than a year ago; there's a lot of missing bindings. Would you be willing to step in and provide even more patches on this front?
Meanwhile, this patch looks okay to me, but I've never contributed to
It's indeed pretty old. I ran into this issue when working with Ceph/RBD. It uses a binary key and that won't go into a String. I'm currently not available to pick this up further. In the future I might run into it when working with CloudStack, but at this point I'm a bit busy. libvirt-java; I'll wait
to see if someone who has actually participated in this project has comments.
Great! Wido

Signed-off-by: Wido den Hollander <wido@widodh.nl> --- src/main/java/org/libvirt/Secret.java | 11 +++++++++++ src/main/java/org/libvirt/jna/Libvirt.java | 1 + 2 files changed, 12 insertions(+), 0 deletions(-) diff --git a/src/main/java/org/libvirt/Secret.java b/src/main/java/org/libvirt/Secret.java index e536cf4..48f7895 100644 --- a/src/main/java/org/libvirt/Secret.java +++ b/src/main/java/org/libvirt/Secret.java @@ -146,6 +146,17 @@ public class Secret { } /** + * Sets the value of the secret + * + * @return 0 on success, -1 on failure. + */ + public int setValue(byte[] value) throws LibvirtException { + int returnValue = libvirt.virSecretSetValue(VSP, value, new NativeLong(value.length), 0); + processError(); + return returnValue; + } + + /** * Undefines, but does not free, the Secret. * * @return 0 on success, -1 on failure. diff --git a/src/main/java/org/libvirt/jna/Libvirt.java b/src/main/java/org/libvirt/jna/Libvirt.java index 2c8c03d..b1e53a2 100644 --- a/src/main/java/org/libvirt/jna/Libvirt.java +++ b/src/main/java/org/libvirt/jna/Libvirt.java @@ -336,6 +336,7 @@ public interface Libvirt extends Library { 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); //Stream Methods -- 1.7.5.4

On Fri, Mar 09, 2012 at 04:12:46PM +0100, Wido den Hollander wrote:
Signed-off-by: Wido den Hollander <wido@widodh.nl> --- src/main/java/org/libvirt/Secret.java | 11 +++++++++++ src/main/java/org/libvirt/jna/Libvirt.java | 1 + 2 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/src/main/java/org/libvirt/Secret.java b/src/main/java/org/libvirt/Secret.java index e536cf4..48f7895 100644 --- a/src/main/java/org/libvirt/Secret.java +++ b/src/main/java/org/libvirt/Secret.java @@ -146,6 +146,17 @@ public class Secret { }
/** + * Sets the value of the secret + * + * @return 0 on success, -1 on failure. + */ + public int setValue(byte[] value) throws LibvirtException { + int returnValue = libvirt.virSecretSetValue(VSP, value, new NativeLong(value.length), 0); + processError(); + return returnValue; + } + + /** * Undefines, but does not free, the Secret. * * @return 0 on success, -1 on failure. diff --git a/src/main/java/org/libvirt/jna/Libvirt.java b/src/main/java/org/libvirt/jna/Libvirt.java index 2c8c03d..b1e53a2 100644 --- a/src/main/java/org/libvirt/jna/Libvirt.java +++ b/src/main/java/org/libvirt/jna/Libvirt.java @@ -336,6 +336,7 @@ public interface Libvirt extends Library { 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);
//Stream Methods
Patch looks fine, pushed, thanks ! BTW will you come up with a second version of the patch for secretGetValue as Eric suggested ? Or I didn't see it :-) thanks ! Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

On 06/26/2012 05:37 AM, Daniel Veillard wrote:
On Fri, Mar 09, 2012 at 04:12:46PM +0100, Wido den Hollander wrote:
Signed-off-by: Wido den Hollander <wido@widodh.nl> --- src/main/java/org/libvirt/Secret.java | 11 +++++++++++ src/main/java/org/libvirt/jna/Libvirt.java | 1 + 2 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/src/main/java/org/libvirt/Secret.java b/src/main/java/org/libvirt/Secret.java index e536cf4..48f7895 100644 --- a/src/main/java/org/libvirt/Secret.java +++ b/src/main/java/org/libvirt/Secret.java @@ -146,6 +146,17 @@ public class Secret { }
/** + * Sets the value of the secret + * + * @return 0 on success, -1 on failure. + */ + public int setValue(byte[] value) throws LibvirtException { + int returnValue = libvirt.virSecretSetValue(VSP, value, new NativeLong(value.length), 0); + processError(); + return returnValue; + } + + /** * Undefines, but does not free, the Secret. * * @return 0 on success, -1 on failure. diff --git a/src/main/java/org/libvirt/jna/Libvirt.java b/src/main/java/org/libvirt/jna/Libvirt.java index 2c8c03d..b1e53a2 100644 --- a/src/main/java/org/libvirt/jna/Libvirt.java +++ b/src/main/java/org/libvirt/jna/Libvirt.java @@ -336,6 +336,7 @@ public interface Libvirt extends Library { 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);
//Stream Methods
Patch looks fine, pushed, thanks !
BTW will you come up with a second version of the patch for secretGetValue as Eric suggested ? Or I didn't see it :-)
Oh, totally forgot! I wrote it, but never submitted it :-) I'll re-submit it asap! Wido
thanks !
Daniel
participants (3)
-
Daniel Veillard
-
Eric Blake
-
Wido den Hollander