[libvirt] C# bindings (Was: First patch)

Justin Clift jclift at redhat.com
Tue Oct 19 19:46:03 UTC 2010


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?
>>>
>>> http://justinclift.fedorapeople.org/csharp/csharp.html
>>
>> 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




More information about the libvir-list mailing list