<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=text/html;charset=iso-8859-1 http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.7600.16490"></HEAD>
<BODY style="PADDING-LEFT: 10px; PADDING-RIGHT: 10px; PADDING-TOP: 15px" 
id=MailContainerBody leftMargin=0 topMargin=0 CanvasTabStop="true" 
name="Compose message area">
<DIV><FONT face=Calibri>Hi,</FONT></DIV>
<DIV><FONT face=Calibri></FONT> </DIV>
<DIV><FONT face=Calibri>I have compiled LibVirt 0.7.4 under mingw, and I want to 
use it with domain callback. Here is a a code sample of my situation (I'm 
using visual studio) :</FONT></DIV>
<DIV><FONT face=Calibri></FONT> </DIV>
<DIV><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>static</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT 
color=#0000ff size=2>int</FONT></FONT><FONT size=2> domain_event(virConnectPtr 
conn,</P>
<P>virDomainPtr dom,</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff 
size=2>int</FONT></FONT><FONT size=2> evt,</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff 
size=2>int</FONT></FONT><FONT size=2> detail,</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff 
size=2>void</FONT></FONT><FONT size=2> *opaque)</P>
<P>{</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff 
size=2>bool</FONT></FONT><FONT size=2> test = </FONT><FONT color=#0000ff 
size=2><FONT color=#0000ff size=2>true</FONT></FONT><FONT size=2>;</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff 
size=2>return</FONT></FONT><FONT size=2> 0;</P>
<P>}</P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>int</FONT></FONT><FONT size=2> _tmain(</FONT><FONT color=#0000ff size=2><FONT 
color=#0000ff size=2>int</FONT></FONT><FONT size=2> argc, _TCHAR* argv[])</P>
<P>{</P>
<P>virConnectPtr conn = virConnectOpen(</FONT><FONT color=#a31515 size=2><FONT 
color=#a31515 size=2>"qemu+tcp://192.168.220.198/session"</FONT></FONT><FONT 
size=2>);</P>
<P></FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>// Set 
Callback</P></FONT></FONT><FONT size=2>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff 
size=2>int</FONT></FONT><FONT size=2> cbresult = 
virConnectDomainEventRegister(conn, domain_event, NULL, NULL);</P>
<P></FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>// Lookup 
Domain</P></FONT></FONT><FONT size=2>
<P>virDomainPtr dom = virDomainLookupByName(conn, </FONT><FONT color=#a31515 
size=2><FONT color=#a31515 size=2>"Test1"</FONT></FONT><FONT size=2>);</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff 
size=2>if</FONT></FONT><FONT size=2> (virDomainIsActive(dom) == 1)</P>
<P>{</P>
<P></FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>// Start 
Domain</P></FONT></FONT><FONT size=2>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff 
size=2>int</FONT></FONT><FONT size=2> startDom = virDomainCreate(dom);</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff 
size=2>if</FONT></FONT><FONT size=2> (startDom != 0)</P>
<P>{</P>
<P>virErrorPtr e = virGetLastError();</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff 
size=2>bool</FONT></FONT><FONT size=2> test = </FONT><FONT color=#0000ff 
size=2><FONT color=#0000ff size=2>true</FONT></FONT><FONT size=2>;</P>
<P>}</P>
<P>}</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff 
size=2>else</P></FONT></FONT><FONT size=2>
<P>{</P>
<P></FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>// Stop 
Domain</P></FONT></FONT><FONT size=2>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff 
size=2>int</FONT></FONT><FONT size=2> StopDom = virDomainDestroy(dom);</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff 
size=2>if</FONT></FONT><FONT size=2> (StopDom != 0)</P>
<P>{</P>
<P>virErrorPtr e = virGetLastError();</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff 
size=2>bool</FONT></FONT><FONT size=2> test = </FONT><FONT color=#0000ff 
size=2><FONT color=#0000ff size=2>true</FONT></FONT><FONT size=2>;</P>
<P>}</P>
<P>}</P>
<P></P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff 
size=2>return</FONT></FONT><FONT size=2> 0;</P>
<P>}</P></FONT></DIV>
<DIV><FONT face=Calibri></FONT> </DIV>
<DIV><FONT face=Calibri>This code works well when I did'nt use callbacks, but 
when I use it, it throw an error at the virDomainCreate or virDomainDestroy 
call. In the application windows (console) I have an "unmarshaling msg", I have 
study the case it comme from the call of "xdr_string" method in the 
"xdr_remote_nonull_string" method (remote_protocol.c).</FONT></DIV>
<DIV><FONT face=Calibri></FONT> </DIV>
<DIV><FONT face=Calibri>I think, the xdr_string method is unable to marshall 
strings from the XDR* object to a char**.</FONT></DIV>
<DIV><FONT face=Calibri></FONT> </DIV>
<DIV><FONT face=Calibri>I've tried with dynamic linking or static linking of 
libvirt lib. Have you any clue to have work callbacks ?</FONT></DIV>
<DIV><FONT face=Calibri></FONT> </DIV>
<DIV><FONT face=Calibri>Best Regards,</FONT></DIV>
<DIV><FONT face=Calibri></FONT> </DIV>
<DIV><FONT face=Calibri>Arnaud Champion</FONT></DIV></BODY></HTML>