[libvirt] First patch

?Hi, this is my first patch import for libvirt C# bindings. Sorry I haven't been able to change the mime type for the patch (Windows Mail doesn't allow this it seems) Arnaud

On Mon, Oct 18, 2010 at 02:41:26PM +0200, arnaud.champion@devatom.fr wrote:
?Hi,
Hi Arnaud,
this is my first patch import for libvirt C# bindings. Sorry I haven't been able to change the mime type for the patch (Windows Mail doesn't allow this it seems)
Okay, I can't really test this, but I have a few comments: - Properties/AssemblyInfo.cs has comments in french, I could try to translate them, probably not urgent, and seems like directive on how to generate the binary for C#, so not very urgent - Since the COPYING.LIB in the current git is LGPLv2+ and since it's referenced, I assume that's the licence intended for this contribution - in Properties/AssemblyInfo.cs I see references to Microsoft and especially "Copyright © Microsoft 2010" do we really want to do this ? - for each entry point I see [DllImport("libvirt-0.dll")] public static extern .... I have 2 questions: - should the DllImport be factored in some ways or is that just a C# construct interpreted just at compile time - assuming we want to add Mono compatibility it seems the library would be named differently on a Linux system, is there a way to at least factor out the string of the library being imported (maybe in an initialization routine ?) Anyway, since the git tree was currently empty (except for Licence files) I commited and pushed the patch (just cleaned up a few trailing whitespaces). It's there now http://libvirt.org/git/?p=libvirt-csharp.git So the best from now on is to provide patches against git, I suggest to use this list for further discussions and patches as we do for Java, thanks a lot ! 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/

?Hi, so, in fact, strings in Properties/AssemblyInfo.cs are auto generated by Visual Studio. I can change strings values, but I have to know What to put as society and copyright. For the comments in this file, they are also generated by visual Studio and as my installation is in french, comments are in french. I appreciate that you translate them (I'm not fluent in english as you can read ;) ) About DllImport method attributes, they are interpreted at compile time. And we can use a variable or a function return to set the library file name (libvirt-0.dll under windows, and <I don't knowwhat>.so under linux). Arnaud -------------------------------------------------- From: "Daniel Veillard" <veillard@redhat.com> Sent: Monday, October 18, 2010 3:25 PM To: <arnaud.champion@devatom.fr> Cc: <libvir-list@redhat.com> Subject: C# bindings (Was: [libvirt] First patch)
On Mon, Oct 18, 2010 at 02:41:26PM +0200, arnaud.champion@devatom.fr wrote:
?Hi,
Hi Arnaud,
this is my first patch import for libvirt C# bindings. Sorry I haven't been able to change the mime type for the patch (Windows Mail doesn't allow this it seems)
Okay, I can't really test this, but I have a few comments: - Properties/AssemblyInfo.cs has comments in french, I could try to translate them, probably not urgent, and seems like directive on how to generate the binary for C#, so not very urgent - Since the COPYING.LIB in the current git is LGPLv2+ and since it's referenced, I assume that's the licence intended for this contribution - in Properties/AssemblyInfo.cs I see references to Microsoft and especially "Copyright © Microsoft 2010" do we really want to do this ? - for each entry point I see [DllImport("libvirt-0.dll")] public static extern .... I have 2 questions: - should the DllImport be factored in some ways or is that just a C# construct interpreted just at compile time - assuming we want to add Mono compatibility it seems the library would be named differently on a Linux system, is there a way to at least factor out the string of the library being imported (maybe in an initialization routine ?)
Anyway, since the git tree was currently empty (except for Licence files) I commited and pushed the patch (just cleaned up a few trailing whitespaces). It's there now http://libvirt.org/git/?p=libvirt-csharp.git
So the best from now on is to provide patches against git, I suggest to use this list for further discussions and patches as we do for Java,
thanks a lot !
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 10/19/2010 12:25 AM, Daniel Veillard wrote: <snip>
Anyway, since the git tree was currently empty (except for Licence files) I commited and pushed the patch (just cleaned up a few trailing whitespaces). It's there now http://libvirt.org/git/?p=libvirt-csharp.git
Are the C# bindings there "ok" for people to use? Should be update the documentation page to point to them? + Justin

?Hi justin, here is a xls that I use to keep advance of bindings. Arnaud -------------------------------------------------- From: "Justin Clift" <jclift@redhat.com> Sent: Monday, October 18, 2010 5:18 PM To: <veillard@redhat.com> Cc: <arnaud.champion@devatom.fr>; <libvir-list@redhat.com> Subject: Re: [libvirt] C# bindings (Was: First patch)
On 10/19/2010 12:25 AM, Daniel Veillard wrote: <snip>
Anyway, since the git tree was currently empty (except for Licence files) I commited and pushed the patch (just cleaned up a few trailing whitespaces). It's there now http://libvirt.org/git/?p=libvirt-csharp.git
Are the C# bindings there "ok" for people to use?
Should be update the documentation page to point to them?
+ Justin

On 10/19/2010 02:29 AM, arnaud.champion@devatom.fr wrote:
?Hi justin,
here is a xls that I use to keep advance of bindings.
Nice. :) Converted it into HTML, for adding to the libvirt documentation. Here is what it looks like: http://justinclift.fedorapeople.org/csharp/csharp.html Does anything there need changing, before this page is added to the proper libvirt website? Regards and best wishes, Justin Clift

?Wow it's very nice :) Just one thing you had to know, I plan to add sample code of using libvirt bindings, so in the future, I will add a column to indicate the sample code snippet for each function et bindings. Arnaud -------------------------------------------------- From: "Justin Clift" <jclift@redhat.com> Sent: Monday, October 18, 2010 7:21 PM To: <arnaud.champion@devatom.fr> Cc: <veillard@redhat.com>; <libvir-list@redhat.com> Subject: Re: [libvirt] C# bindings (Was: First patch)
On 10/19/2010 02:29 AM, arnaud.champion@devatom.fr wrote:
?Hi justin,
here is a xls that I use to keep advance of bindings.
Nice. :)
Converted it into HTML, for adding to the libvirt documentation.
Here is what it looks like:
http://justinclift.fedorapeople.org/csharp/csharp.html
Does anything there need changing, before this page is added to the proper libvirt website?
Regards and best wishes,
Justin Clift

?Whoops, just a little thing, there coverage table show only types, there is another tab in the excel that show function coverage. -------------------------------------------------- From: <arnaud.champion@devatom.fr> Sent: Monday, October 18, 2010 8:13 PM To: "Justin Clift" <jclift@redhat.com> Cc: <libvir-list@redhat.com> Subject: Re: [libvirt] C# bindings (Was: First patch)
?Wow it's very nice :)
Just one thing you had to know, I plan to add sample code of using libvirt bindings, so in the future, I will add a column to indicate the sample code snippet for each function et bindings.
Arnaud
-------------------------------------------------- From: "Justin Clift" <jclift@redhat.com> Sent: Monday, October 18, 2010 7:21 PM To: <arnaud.champion@devatom.fr> Cc: <veillard@redhat.com>; <libvir-list@redhat.com> Subject: Re: [libvirt] C# bindings (Was: First patch)
On 10/19/2010 02:29 AM, arnaud.champion@devatom.fr wrote:
?Hi justin,
here is a xls that I use to keep advance of bindings.
Nice. :)
Converted it into HTML, for adding to the libvirt documentation.
Here is what it looks like:
http://justinclift.fedorapeople.org/csharp/csharp.html
Does anything there need changing, before this page is added to the proper libvirt website?
Regards and best wishes,
Justin Clift
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

On 10/19/2010 05:13 AM, arnaud.champion@devatom.fr wrote:
?Wow it's very nice :)
Just one thing you had to know, I plan to add sample code of using libvirt bindings, so in the future, I will add a column to indicate the sample code snippet for each function et bindings.
That sounds like a really good idea. :) As a thought, are there instruction that people should be using? Suddenly worried that people might download the git source code for this, and not know what to do with it. ? Regards and best wishes, Justin Clift
Arnaud

?In fact, yes. The current content is a Visual Studio solution/project architecture, tested only with windows .Net, not Mono. Also it's an evidence but bindings require the libvirt binary, in the .Net case the "libvirt-0.dll" which is the result of the compilation of libvirt for windows. Maybe we can also add a little explaination. I can try to give you one, but my english is really not perfect :S (but you can read that ever :) ) Here is my explaination : CSharp libvirt bindings is a class library. Compiling it result to a dll "LibvirtBindings.dll" which can be added as a .Net reference to any .Net project which need access to libvirt. The class library expose the "LibvirtBindings" namespace. This namespace expose all needed types (enum, struct). It also expose 2 main classes : "libVirt" and "libvirtError". The "libVirt" class expose all interfaces of the libvirt library to handle virtualized domains and "libvirtError" class expose all interfaces of the libvirt library to handle errors raised while using the library. Let me know if my explaination is not clear :S Arnaud Champion -------------------------------------------------- From: "Justin Clift" <jclift@redhat.com> Sent: Monday, October 18, 2010 8:53 PM To: <arnaud.champion@devatom.fr> Cc: <veillard@redhat.com>; <libvir-list@redhat.com> Subject: Re: [libvirt] C# bindings (Was: First patch)
On 10/19/2010 05:13 AM, arnaud.champion@devatom.fr wrote:
?Wow it's very nice :)
Just one thing you had to know, I plan to add sample code of using libvirt bindings, so in the future, I will add a column to indicate the sample code snippet for each function et bindings.
That sounds like a really good idea. :)
As a thought, are there instruction that people should be using?
Suddenly worried that people might download the git source code for this, and not know what to do with it.
?
Regards and best wishes,
Justin Clift
Arnaud

2010/10/18 <arnaud.champion@devatom.fr>:
The class library expose the "LibvirtBindings" namespace. This namespace expose all needed types (enum, struct). It also expose 2 main classes : "libVirt" and "libvirtError". The "libVirt" class expose all interfaces of the libvirt library to handle virtualized domains and "libvirtError" class expose all interfaces of the libvirt library to handle errors raised while using the library.
Is there a specific reason to use three different ways to capitalize libvirt in the C# code? LibvirtBindings libVirt libvirtError I suggest you choose one form and stick with it, for example LibvirtBindings Libvirt LibvirtError Matthias

The idea was to stick to libvirt API documentation which contain a libvirt part and a virError part. Types are used everywhere that's why they are at a upper level (LibvirtBindings). In fact, libVirt and libvirtError are in the LibvirtBindings, as they are classes. This is useful to clean the code and not have all the code in one class... But I don't know what is better, usually, in this kind of project, I'm used to separate things. -------------------------------------------------- From: "Matthias Bolte" <matthias.bolte@googlemail.com> Sent: Tuesday, October 19, 2010 5:43 PM To: <arnaud.champion@devatom.fr> Cc: "Justin Clift" <jclift@redhat.com>; <libvir-list@redhat.com> Subject: Re: [libvirt] C# bindings (Was: First patch)
2010/10/18 <arnaud.champion@devatom.fr>:
The class library expose the "LibvirtBindings" namespace. This namespace expose all needed types (enum, struct). It also expose 2 main classes : "libVirt" and "libvirtError". The "libVirt" class expose all interfaces of the libvirt library to handle virtualized domains and "libvirtError" class expose all interfaces of the libvirt library to handle errors raised while using the library.
Is there a specific reason to use three different ways to capitalize libvirt in the C# code?
LibvirtBindings libVirt libvirtError
I suggest you choose one form and stick with it, for example
LibvirtBindings Libvirt LibvirtError
Matthias

On 19/10/10 17:58, arnaud.champion@devatom.fr wrote:
The idea was to stick to libvirt API documentation which contain a libvirt part and a virError part. Types are used everywhere that's why they are at a upper level (LibvirtBindings). In fact, libVirt and libvirtError are in the LibvirtBindings, as they are classes. This is useful to clean the code and not have all the code in one class... But I don't know what is better, usually, in this kind of project, I'm used to separate things.
Libvirt or libvirt, but [Ll]ibVirt hurts :) regards, Alejandro Mery

On Tue, Oct 19, 2010 at 05:43:50PM +0200, Matthias Bolte wrote:
2010/10/18 <arnaud.champion@devatom.fr>:
The class library expose the "LibvirtBindings" namespace. This namespace expose all needed types (enum, struct). It also expose 2 main classes : "libVirt" and "libvirtError". The "libVirt" class expose all interfaces of the libvirt library to handle virtualized domains and "libvirtError" class expose all interfaces of the libvirt library to handle errors raised while using the library.
Is there a specific reason to use three different ways to capitalize libvirt in the C# code?
LibvirtBindings libVirt libvirtError
I suggest you choose one form and stick with it, for example
LibvirtBindings Libvirt LibvirtError
Personally I'd make the naming look much more like the Java bindings. Instead of following the C naming directly which is fugly for non-C languages, have a 'libvirt' namespace, and then use plain names like 'Connect', 'Domain', 'Network' for the objects and strip the prefix off the method names to 'Connect.open', 'Domain.dump_xml' etc Regards, Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

Okay, it's a good idea, I'm going for it -------------------------------------------------- From: "Daniel P. Berrange" <berrange@redhat.com> Sent: Tuesday, October 19, 2010 6:15 PM To: "Matthias Bolte" <matthias.bolte@googlemail.com> Cc: <arnaud.champion@devatom.fr>; <libvir-list@redhat.com> Subject: Re: [libvirt] C# bindings (Was: First patch)
On Tue, Oct 19, 2010 at 05:43:50PM +0200, Matthias Bolte wrote:
2010/10/18 <arnaud.champion@devatom.fr>:
The class library expose the "LibvirtBindings" namespace. This namespace expose all needed types (enum, struct). It also expose 2 main classes : "libVirt" and "libvirtError". The "libVirt" class expose all interfaces of the libvirt library to handle virtualized domains and "libvirtError" class expose all interfaces of the libvirt library to handle errors raised while using the library.
Is there a specific reason to use three different ways to capitalize libvirt in the C# code?
LibvirtBindings libVirt libvirtError
I suggest you choose one form and stick with it, for example
LibvirtBindings Libvirt LibvirtError
Personally I'd make the naming look much more like the Java bindings. Instead of following the C naming directly which is fugly for non-C languages, have a 'libvirt' namespace, and then use plain names like 'Connect', 'Domain', 'Network' for the objects and strip the prefix off the method names to 'Connect.open', 'Domain.dump_xml' etc
Regards, Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On Tue, Oct 19, 2010 at 04:21:19AM +1100, Justin Clift wrote:
On 10/19/2010 02:29 AM, arnaud.champion@devatom.fr wrote:
?Hi justin,
here is a xls that I use to keep advance of bindings.
Nice. :)
Converted it into HTML, for adding to the libvirt documentation.
Here is what it looks like:
http://justinclift.fedorapeople.org/csharp/csharp.html
Does anything there need changing, before this page is added to the proper libvirt website?
Nice, I would still add something about the fact that it has not been tested with Mono (and unlikely to work at all due to the "libvirt-0.dll" name), but that help is welcome for a port, 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 10/19/2010 02:29 AM, arnaud.champion@devatom.fr wrote:
?Hi justin,
here is a xls that I use to keep advance of bindings.
In the .xls file, in the "Types" tab, it looks like "virStoragePool" and "virStorageVol" are both in there two times. ?

?You are right, my mistake :) You'll find an update version attached to this mail. There is some new columns in the xls. "Sample Code" refer the name of the sample code project (the name is the same for Mono on .Net) "Test .Net/Windows Works" indicate the test state under .Net/Windows "Test Mono/Windows Works" indicate the test state under Mono/Windows "Test Mono/Windows Works" indicate the test state under Mono/Linux The joined xls assume the patch I have just sended to the list. For information, tests under windows are done under Windows 7 with .Net 4 and Visual Studio 2010 and MonoDevelop 2.4. Tests under linux are done under Fedora 13 i686 and MonoDevelop 2.2 Arnaud -------------------------------------------------- From: "Justin Clift" <jclift@redhat.com> Sent: Tuesday, October 19, 2010 4:00 PM To: <arnaud.champion@devatom.fr> Cc: <libvir-list@redhat.com> Subject: Re: [libvirt] C# bindings (Was: First patch)
On 10/19/2010 02:29 AM, arnaud.champion@devatom.fr wrote:
?Hi justin,
here is a xls that I use to keep advance of bindings.
In the .xls file, in the "Types" tab, it looks like "virStoragePool" and "virStorageVol" are both in there two times.
?

On 10/20/2010 01:32 AM, arnaud.champion@devatom.fr wrote:
?You are right, my mistake :)
You'll find an update version attached to this mail.
There is some new columns in the xls.
"Sample Code" refer the name of the sample code project (the name is the same for Mono on .Net) "Test .Net/Windows Works" indicate the test state under .Net/Windows "Test Mono/Windows Works" indicate the test state under Mono/Windows "Test Mono/Windows Works" indicate the test state under Mono/Linux
The joined xls assume the patch I have just sended to the list.
For information, tests under windows are done under Windows 7 with .Net 4 and Visual Studio 2010 and MonoDevelop 2.4. Tests under linux are done under Fedora 13 i686 and MonoDevelop 2.2
Cool. :) Should we create a .zip file or similar, so people can download it? Maybe something like "libvirt-java-0.0.1.zip" ? + Justin
Arnaud

?Why not, no problem for me. -------------------------------------------------- From: "Justin Clift" <jclift@redhat.com> Sent: Tuesday, October 19, 2010 4:36 PM To: <arnaud.champion@devatom.fr> Cc: <libvir-list@redhat.com> Subject: Re: [libvirt] C# bindings (Was: First patch)
On 10/20/2010 01:32 AM, arnaud.champion@devatom.fr wrote:
?You are right, my mistake :)
You'll find an update version attached to this mail.
There is some new columns in the xls.
"Sample Code" refer the name of the sample code project (the name is the same for Mono on .Net) "Test .Net/Windows Works" indicate the test state under .Net/Windows "Test Mono/Windows Works" indicate the test state under Mono/Windows "Test Mono/Windows Works" indicate the test state under Mono/Linux
The joined xls assume the patch I have just sended to the list.
For information, tests under windows are done under Windows 7 with .Net 4 and Visual Studio 2010 and MonoDevelop 2.4. Tests under linux are done under Fedora 13 i686 and MonoDevelop 2.2
Cool. :)
Should we create a .zip file or similar, so people can download it?
Maybe something like "libvirt-java-0.0.1.zip" ?
+ Justin
Arnaud

On 10/20/2010 01:32 AM, arnaud.champion@devatom.fr wrote:
?You are right, my mistake :)
You'll find an update version attached to this mail.
There is some new columns in the xls.
Ok, how's this? http://justinclift.fedorapeople.org/csharp/csharp.html

On 10/19/2010 11:49 AM, Justin Clift wrote:
On 10/20/2010 01:32 AM, arnaud.champion@devatom.fr wrote:
?You are right, my mistake :)
You'll find an update version attached to this mail.
There is some new columns in the xls.
Ok, how's this?
Can we also include a sample program using the bindings, as is done in http://justinclift.fedorapeople.org/csharp/python.html and http://justinclift.fedorapeople.org/csharp/java.html? -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On 10/20/2010 04:57 AM, Eric Blake wrote: <snip>
Ok, how's this?
Can we also include a sample program using the bindings, as is done in http://justinclift.fedorapeople.org/csharp/python.html and http://justinclift.fedorapeople.org/csharp/java.html?
Good idea. Just added a space for one in the layout. Arnaud, would I be able to get an example program from you, for adding there? Is "virConnectOpenAuth" the correct kind of thing?

On 10/20/2010 05:08 AM, Justin Clift wrote:
On 10/20/2010 04:57 AM, Eric Blake wrote: <snip>
Ok, how's this?
Can we also include a sample program using the bindings, as is done in http://justinclift.fedorapeople.org/csharp/python.html and http://justinclift.fedorapeople.org/csharp/java.html?
Good idea. Just added a space for one in the layout.
Arnaud, would I be able to get an example program from you, for adding there? Is "virConnectOpenAuth" the correct kind of thing?
Looked at the virConnectOpenAuth example (from Arnauds patches waiting for review). It doesn't seem like a suitable example for the web page, as the example code is a lot longer/larger than we'd like for this. Arnaud, do you have time to create an extremely simple example? Something that shows the very minimum needed. Sort of like this: (I do not know C# at all though :>) using System; using LibvirtBindings; // Fill a virConnectAuth structure virConnectAuth auth = new virConnectAuth { cbdata = authData, // The authData structure cb = AuthCallback, // the method called by callbacks CredTypes = new[] { // The list of credentials types virConnectCredentialType.VIR_CRED_AUTHNAME, virConnectCredentialType.VIR_CRED_PASSPHRASE } }; // Request the connection IntPtr conn = libVirt.virConnectOpenAuth(tbURI.Text, ref auth, 0); // Get the pointer to the domain string domainName = new string "MyGuest"; IntPtr domainPtr = libVirt.virDomainLookupByName(conn, domainName); // Start the domain Int something = libVirt.virDomainCreate(domainPtr); // Close the connection libVirt.virConnectClose(conn); ? Regards and best wishes, Justin Clift

?Well, I can make a little sample, with virConnectOpen instead of virConnectOpenAuth, because virConnectOpenAuth cannot work without callback handling, that's why it's larger. But I will be tomorrow ;) it's time to sleep for me. -------------------------------------------------- From: "Justin Clift" <jclift@redhat.com> Sent: Tuesday, October 19, 2010 9:46 PM To: "Arnaud Champion" <arnaud.champion@devatom.fr> Cc: "Libvirt Developers Mailing List" <libvir-list@redhat.com> Subject: Re: [libvirt] C# bindings (Was: First patch)
On 10/20/2010 05:08 AM, Justin Clift wrote:
On 10/20/2010 04:57 AM, Eric Blake wrote: <snip>
Ok, how's this?
Can we also include a sample program using the bindings, as is done in http://justinclift.fedorapeople.org/csharp/python.html and http://justinclift.fedorapeople.org/csharp/java.html?
Good idea. Just added a space for one in the layout.
Arnaud, would I be able to get an example program from you, for adding there? Is "virConnectOpenAuth" the correct kind of thing?
Looked at the virConnectOpenAuth example (from Arnauds patches waiting for review). It doesn't seem like a suitable example for the web page, as the example code is a lot longer/larger than we'd like for this.
Arnaud, do you have time to create an extremely simple example?
Something that shows the very minimum needed. Sort of like this: (I do not know C# at all though :>)
using System; using LibvirtBindings;
// Fill a virConnectAuth structure virConnectAuth auth = new virConnectAuth { cbdata = authData, // The authData structure cb = AuthCallback, // the method called by callbacks CredTypes = new[] { // The list of credentials types virConnectCredentialType.VIR_CRED_AUTHNAME, virConnectCredentialType.VIR_CRED_PASSPHRASE } };
// Request the connection IntPtr conn = libVirt.virConnectOpenAuth(tbURI.Text, ref auth, 0);
// Get the pointer to the domain string domainName = new string "MyGuest"; IntPtr domainPtr = libVirt.virDomainLookupByName(conn, domainName);
// Start the domain Int something = libVirt.virDomainCreate(domainPtr);
// Close the connection libVirt.virConnectClose(conn);
?
Regards and best wishes,
Justin Clift

On 10/20/2010 06:59 AM, arnaud.champion@devatom.fr wrote:
?Well, I can make a little sample, with virConnectOpen instead of virConnectOpenAuth, because virConnectOpenAuth cannot work without callback handling, that's why it's larger. But I will be tomorrow ;) it's time to sleep for me.
Not a problem. :)

?Hi Justin, I have written a little simple sample of using of C# bindings. In fact it is a sample project which connect to a clear TCP libvirt/qemu via virConnectOpen the list the storage pools. Here's the code : /* * Copyright (C) * Arnaud Champion <arnaud.champion@devatom.fr> * Jaromír Cervenka <cervajz@cervajz.com> * * See COPYING.LIB for the License of this software * * Sample code for : * Function : * virConnectOpen * virConnectNumOfStoragePools * virConnectListStoragePools */ using System; using System.Windows.Forms; using LibvirtBindings; namespace virConnectOpen { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void btnConnect_Click(object sender, EventArgs e) { IntPtr conn = virConnect.Open(tbURI.Text); if (conn != IntPtr.Zero) { int numOfStoragePools = virConnect.NumOfStoragePools(conn); if (numOfStoragePools == -1) ShowError("Unable to get the number of storage pools"); string[] storagePoolsNames = new string[numOfStoragePools]; int listStoragePools = virConnect.ListStoragePools(conn, ref storagePoolsNames, numOfStoragePools); if (listStoragePools == -1) ShowError("Unable to list storage pools"); foreach (string storagePoolName in storagePoolsNames) lbStoragePool.Items.Add(storagePoolName); } else { ShowError("Unable to connect"); } } private void ShowError(string message) { MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } Also, the xls has some little change, you'll find the update joined to this email. Regards, Arnaud -------------------------------------------------- From: <arnaud.champion@devatom.fr> Sent: Tuesday, October 19, 2010 9:59 PM To: "Justin Clift" <jclift@redhat.com> Cc: "Libvirt Developers Mailing List" <libvir-list@redhat.com> Subject: Re: [libvirt] C# bindings (Was: First patch)
?Well, I can make a little sample, with virConnectOpen instead of virConnectOpenAuth, because virConnectOpenAuth cannot work without callback handling, that's why it's larger. But I will be tomorrow ;) it's time to sleep for me.
-------------------------------------------------- From: "Justin Clift" <jclift@redhat.com> Sent: Tuesday, October 19, 2010 9:46 PM To: "Arnaud Champion" <arnaud.champion@devatom.fr> Cc: "Libvirt Developers Mailing List" <libvir-list@redhat.com> Subject: Re: [libvirt] C# bindings (Was: First patch)
On 10/20/2010 05:08 AM, Justin Clift wrote:
On 10/20/2010 04:57 AM, Eric Blake wrote: <snip>
Ok, how's this?
Can we also include a sample program using the bindings, as is done in http://justinclift.fedorapeople.org/csharp/python.html and http://justinclift.fedorapeople.org/csharp/java.html?
Good idea. Just added a space for one in the layout.
Arnaud, would I be able to get an example program from you, for adding there? Is "virConnectOpenAuth" the correct kind of thing?
Looked at the virConnectOpenAuth example (from Arnauds patches waiting for review). It doesn't seem like a suitable example for the web page, as the example code is a lot longer/larger than we'd like for this.
Arnaud, do you have time to create an extremely simple example?
Something that shows the very minimum needed. Sort of like this: (I do not know C# at all though :>)
using System; using LibvirtBindings;
// Fill a virConnectAuth structure virConnectAuth auth = new virConnectAuth { cbdata = authData, // The authData structure cb = AuthCallback, // the method called by callbacks CredTypes = new[] { // The list of credentials types virConnectCredentialType.VIR_CRED_AUTHNAME, virConnectCredentialType.VIR_CRED_PASSPHRASE } };
// Request the connection IntPtr conn = libVirt.virConnectOpenAuth(tbURI.Text, ref auth, 0);
// Get the pointer to the domain string domainName = new string "MyGuest"; IntPtr domainPtr = libVirt.virDomainLookupByName(conn, domainName);
// Start the domain Int something = libVirt.virDomainCreate(domainPtr);
// Close the connection libVirt.virConnectClose(conn);
?
Regards and best wishes,
Justin Clift
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

On 10/20/2010 11:05 PM, arnaud.champion@devatom.fr wrote:
?Hi Justin,
I have written a little simple sample of using of C# bindings. In fact it is a sample project which connect to a clear TCP libvirt/qemu via virConnectOpen the list the storage pools. Here's the code :
Thanks. I should probably wait until you have finished renaming things inside the code. :)

?Well, it's really nice -------------------------------------------------- From: "Justin Clift" <jclift@redhat.com> Sent: Tuesday, October 19, 2010 7:49 PM To: <arnaud.champion@devatom.fr> Cc: <libvir-list@redhat.com> Subject: Re: [libvirt] C# bindings (Was: First patch)
On 10/20/2010 01:32 AM, arnaud.champion@devatom.fr wrote:
?You are right, my mistake :)
You'll find an update version attached to this mail.
There is some new columns in the xls.
Ok, how's this?
participants (7)
-
Alejandro Mery
-
arnaud.champion@devatom.fr
-
Daniel P. Berrange
-
Daniel Veillard
-
Eric Blake
-
Justin Clift
-
Matthias Bolte