Hi,
 
So, at first, are you sure that conn != IntPtr.Zero and pDomain != IntPtr.Zero.
if both pointer are ok, can you please check the DomainInfo marshal, I have just sended patch today around this structure, and I think the patch is not yet pushed to the git.
The DomainInfo structure must be marshaled in this way :
 

/// <summary>

/// Structure to handle domain informations

/// </summary>

[StructLayout(LayoutKind.Sequential)]

public class DomainInfo

{

/// <summary>

/// The running state, one of virDomainState.

/// </summary>

private byte state;

/// <summary>

/// The maximum memory in KBytes allowed.

/// </summary>

[MarshalAs(UnmanagedType.SysUInt)]

public UIntPtr maxMem;

/// <summary>

/// The memory in KBytes used by the domain.

/// </summary>

[MarshalAs(UnmanagedType.SysUInt)]

public UIntPtr memory;

/// <summary>

/// The number of virtual CPUs for the domain.

/// </summary>

public ushort nrVirtCpu;

/// <summary>

/// The CPU time used in nanoseconds.

/// </summary>

[MarshalAs(UnmanagedType.SysUInt)]

public UIntPtr cpuTime;

/// <summary>

/// The running state, one of virDomainState.

/// </summary>

public DomainState State { get { return (DomainState)state; } }

}

 

Also, another important thing change : the libvirt bindings project must have an x86 target to make this marshaling working. This is also in the patch.

 

Another thing, you can also use Errors.GetLastErro() method to identify the problem, it return an error class which can inform you about the problem.

 

Best regards,

 

Arnaud

 

PS : are you sure also that libvirt dll is compiled with xen support ?


From: »ÆÁÁ
Sent: Saturday, October 30, 2010 7:07 PM
To: arnaud.champion
Subject: SPAM-LOW: Domain.GetInfo error

Dear Arnaud
 
Here is my test code. Function Domain.GetInfo return -1 and I don't know where is the mistake.
Would you do me a favor to point out the problem? Thank you!
 
Code:
 
   IntPtr conn = Connect.Open("xen+tcp://192.168.0.1?no_verify=1");
   String DomainName = e.Node.Text;
   IntPtr pDomain = Domain.LookupByName(conn, DomainName);
 
   DomainInfo aInfo = new DomainInfo();
   if (Domain.GetInfo(pDomain, aInfo) == -1)
   {
    MessageBox.Show("Get Info error");
    return;
   }
 
2010-10-31

»ÆÁÁ