<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=utf-8" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.18975">
<STYLE>@font-face {
        font-family: 宋体;
}
@font-face {
        font-family: Verdana;
}
@font-face {
        font-family: @宋体;
}
@page Section1 {size: 595.3pt 841.9pt; margin: 72.0pt 90.0pt 72.0pt 90.0pt; layout-grid: 15.6pt; }
P.MsoNormal {
        TEXT-JUSTIFY: inter-ideograph; TEXT-ALIGN: justify; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Times New Roman"; FONT-SIZE: 10.5pt
}
LI.MsoNormal {
        TEXT-JUSTIFY: inter-ideograph; TEXT-ALIGN: justify; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Times New Roman"; FONT-SIZE: 10.5pt
}
DIV.MsoNormal {
        TEXT-JUSTIFY: inter-ideograph; TEXT-ALIGN: justify; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Times New Roman"; FONT-SIZE: 10.5pt
}
A:link {
        COLOR: blue; TEXT-DECORATION: underline
}
SPAN.MsoHyperlink {
        COLOR: blue; TEXT-DECORATION: underline
}
A:visited {
        COLOR: purple; TEXT-DECORATION: underline
}
SPAN.MsoHyperlinkFollowed {
        COLOR: purple; TEXT-DECORATION: underline
}
SPAN.EmailStyle17 {
        FONT-STYLE: normal; FONT-FAMILY: Verdana; COLOR: windowtext; FONT-WEIGHT: normal; TEXT-DECORATION: none; mso-style-type: personal-compose
}
DIV.Section1 {
        page: Section1
}
UNKNOWN {
        FONT-SIZE: 10pt
}
BLOCKQUOTE {
        MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; MARGIN-LEFT: 2em
}
OL {
        MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
UL {
        MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
</STYLE>
</HEAD>
<BODY style="MARGIN: 10px; FONT-FAMILY: verdana; FONT-SIZE: 10pt">
<DIV><FONT color=#000080 size=2 face=Verdana>Well, after "make clean", I run the 
compiled start.c, still won't work.</FONT></DIV>
<DIV><FONT color=#000080>And I forget to metion, an error msg is 
shown:</FONT></DIV>
<DIV><FONT color=#000080></FONT> </DIV>
<DIV>libvir: Xen error : Domain not found: xenUnifiedDomainLookupByName 
</DIV>
<DIV><FONT color=#000080></FONT> </DIV>
<DIV><FONT color=#000080>is that means I missed something?</FONT></DIV>
<DIV><FONT color=#000080 size=2 face=Verdana></FONT> </DIV>
<DIV><FONT color=#000080 size=2 face=Verdana></FONT> </DIV>
<DIV><FONT color=#c0c0c0 size=2 face=Verdana>2010-10-26 </FONT></DIV><FONT 
color=#000080 size=2 face=Verdana>
<HR style="WIDTH: 100px" align=left color=#b5c4df SIZE=1>
</FONT>
<DIV><FONT color=#c0c0c0 size=2 face=Verdana><SPAN>黄亮</SPAN> </FONT></DIV>
<HR color=#b5c4df SIZE=1>

<DIV><FONT size=2 face=Verdana><STRONG>发件人:</STRONG> Osier </FONT></DIV>
<DIV><FONT size=2 face=Verdana><STRONG>发送时间:</STRONG> 2010-10-26  18:05:46 
</FONT></DIV>
<DIV><FONT size=2 face=Verdana><STRONG>收件人:</STRONG> 黄亮 </FONT></DIV>
<DIV><FONT size=2 face=Verdana><STRONG>抄送:</STRONG> </FONT></DIV>
<DIV><FONT size=2 face=Verdana><STRONG>主题:</STRONG> Re: [libvirt] How to start a 
defined domain </FONT></DIV>
<DIV><FONT size=2 face=Verdana></FONT> </DIV>
<DIV><FONT size=2 face=Verdana>
<DIV></DIV>
<DIV>----- "黄亮" <lancerhuang@163.com> wrote:</DIV>
<DIV></DIV>
<DIV>> </DIV>
<DIV>> Accroding to your case, it seems I have no need to upgrade libvirt to</DIV>
<DIV>> 0.8.4</DIV>
<DIV>> Will that work if I erase 0.8.4 using "make clean" and draw back to</DIV>
<DIV>> 0.6.3 ?</DIV>
<DIV></DIV>
<DIV>yep, think so, if you don't need the new features, and 0.6.3 is enough</DIV>
<DIV>for your project requirement.. :-)</DIV>
<DIV></DIV>
<DIV>- Osier</DIV>
<DIV>> </DIV>
<DIV>> </DIV>
<DIV>> </DIV>
<DIV>> 2010-10-26</DIV>
<DIV>> </DIV>
<DIV>> 黄亮</DIV>
<DIV>> </DIV>
<DIV>> 发件人: Osier</DIV>
<DIV>> 发送时间: 2010-10-26 17:10:40</DIV>
<DIV>> 收件人: 黄亮</DIV>
<DIV>> 抄送:</DIV>
<DIV>> 主题: Re: [libvirt] How to start a defined domain</DIV>
<DIV>> </DIV>
<DIV>> </DIV>
<DIV>> </DIV>
<DIV>> ----- "黄亮" <lancerhuang@163.com> wrote:</DIV>
<DIV>> </DIV>
<DIV>> > </DIV>
<DIV>> > Thanks for your reply, Osier.</DIV>
<DIV>> ></DIV>
<DIV>> ></DIV>
<DIV>> > The distro I'm using is CentOS release 5.5 (Final)</DIV>
<DIV>> ></DIV>
<DIV>> > I'm not quite sure about the version of libvirt. At first, it seems</DIV>
<DIV>> to</DIV>
<DIV>> > be 0.6.3, because /usr/lib64/libvirt.so.0 points to</DIV>
<DIV>> > /usr/lib64/libvirt.so.0.6.3</DIV>
<DIV>> > Then I downloaded the src of libvirt_0.8.4 from offical website, and</DIV>
<DIV>> > configure, make, make install.</DIV>
<DIV>> > But now it show errors when I type "virsh". The error message lies</DIV>
<DIV>> > below:</DIV>
<DIV>> ></DIV>
<DIV>> > virsh: /usr/local/lib/libvirt.so.0: version `LIBVIRT_0.8.2' not</DIV>
<DIV>> found</DIV>
<DIV>> > (required by virsh)</DIV>
<DIV>> > virsh: /usr/local/lib/libvirt.so.0: version `LIBVIRT_0.7.1' not</DIV>
<DIV>> found</DIV>
<DIV>> > (required by virsh)</DIV>
<DIV>> > virsh: /usr/local/lib/libvirt.so.0: version `LIBVIRT_0.7.5' not</DIV>
<DIV>> found</DIV>
<DIV>> > (required by virsh)</DIV>
<DIV>> > virsh: /usr/local/lib/libvirt.so.0: version `LIBVIRT_0.8.1' not</DIV>
<DIV>> found</DIV>
<DIV>> > (required by virsh)</DIV>
<DIV>> > virsh: /usr/local/lib/libvirt.so.0: version `LIBVIRT_0.7.0' not</DIV>
<DIV>> found</DIV>
<DIV>> > (required by virsh)</DIV>
<DIV>> > virsh: /usr/local/lib/libvirt.so.0: version `LIBVIRT_0.7.2' not</DIV>
<DIV>> found</DIV>
<DIV>> > (required by virsh)</DIV>
<DIV>> > virsh: /usr/local/lib/libvirt.so.0: version `LIBVIRT_0.7.3' not</DIV>
<DIV>> found</DIV>
<DIV>> > (required by virsh)</DIV>
<DIV>> > virsh: /usr/local/lib/libvirt.so.0: version `LIBVIRT_0.8.0' not</DIV>
<DIV>> found</DIV>
<DIV>> > (required by virsh)</DIV>
<DIV>> > virsh: /usr/local/lib/libvirt.so.0: version `LIBVIRT_PRIVATE_0.8.4'</DIV>
<DIV>> > not found (required by virsh)</DIV>
<DIV>> > virsh: /usr/local/lib/libvirt.so.0: version `LIBVIRT_0.7.7' not</DIV>
<DIV>> found</DIV>
<DIV>> > (required by virsh)</DIV>
<DIV>> > virsh: /usr/local/lib/libvirt.so.0: version `LIBVIRT_0.6.4' not</DIV>
<DIV>> found</DIV>
<DIV>> > (required by virsh)</DIV>
<DIV>> </DIV>
<DIV>> probly you should try to erase the 0.6.3, then compile and install</DIV>
<DIV>> libvirt</DIV>
<DIV>> like:</DIV>
<DIV>> </DIV>
<DIV>> # ./configure --prefix=/usr --libdir=/usr/lib64</DIV>
<DIV>> # make</DIV>
<DIV>> # make install</DIV>
<DIV>> </DIV>
<DIV>> your test program has no problem on my box. the libvirt on my box also</DIV>
<DIV>> is</DIV>
<DIV>> 0.6.3.</DIV>
<DIV>> </DIV>
<DIV>> Regards</DIV>
<DIV>> </DIV>
<DIV>> - Osier</DIV>
<DIV>> ></DIV>
<DIV>> > As for xen, it is 3.3.2. The full "xm info" message is listed below:</DIV>
<DIV>> > host : testbed01</DIV>
<DIV>> > release : 2.6.18-194.11.4.el5xen</DIV>
<DIV>> > version : #1 SMP Tue Sep 21 05:40:24 EDT 2010</DIV>
<DIV>> > machine : x86_64</DIV>
<DIV>> > nr_cpus : 8</DIV>
<DIV>> > nr_nodes : 1</DIV>
<DIV>> > cores_per_socket : 4</DIV>
<DIV>> > threads_per_core : 2</DIV>
<DIV>> > cpu_mhz : 2793</DIV>
<DIV>> > hw_caps :</DIV>
<DIV>> ></DIV>
<DIV>> bfebfbff:28100800:00000000:00000140:0098e3fd:00000000:00000001:00000000</DIV>
<DIV>> > virt_caps : hvm</DIV>
<DIV>> > total_memory : 4055</DIV>
<DIV>> > free_memory : 533</DIV>
<DIV>> > node_to_cpu : node0:0-7</DIV>
<DIV>> > node_to_memory : node0:533</DIV>
<DIV>> > xen_major : 3</DIV>
<DIV>> > xen_minor : 3</DIV>
<DIV>> > xen_extra : .2</DIV>
<DIV>> > xen_caps : xen-3.0-x86_64 xen-3.0-x86_32p hvm-3.0-x86_32</DIV>
<DIV>> > hvm-3.0-x86_32p hvm-3.0-x86_64</DIV>
<DIV>> > xen_scheduler : credit</DIV>
<DIV>> > xen_pagesize : 4096</DIV>
<DIV>> > platform_params : virt_start=0xffff800000000000</DIV>
<DIV>> > xen_changeset : unavailable</DIV>
<DIV>> > cc_compiler : gcc version 4.1.2 20080704 (Red Hat 4.1.2-44)</DIV>
<DIV>> > cc_compile_by : root</DIV>
<DIV>> > cc_compile_domain : gitco.tld</DIV>
<DIV>> > cc_compile_date : Tue Aug 18 21:07:28 CEST 2009</DIV>
<DIV>> > xend_config_format : 4</DIV>
<DIV>> ></DIV>
<DIV>> > I've write a simple c program to test the api, and it is listed</DIV>
<DIV>> below:</DIV>
<DIV>> ></DIV>
<DIV>> > 1 // This program aims to test the api which can start the VM</DIV>
<DIV>> > 2</DIV>
<DIV>> > 3 #include "stdio.h"</DIV>
<DIV>> > 4 #include "stdlib.h"</DIV>
<DIV>> > 5 #include "libvirt/libvirt.h"</DIV>
<DIV>> > 6</DIV>
<DIV>> > 7 int main(int argc ,char* argv[])</DIV>
<DIV>> > 8 {</DIV>
<DIV>> > 9 virConnectPtr conn;</DIV>
<DIV>> > 10 conn = virConnectOpen( "xen+tcp://localhost?no_Verify=1" );</DIV>
<DIV>> > 11 if( conn == NULL )</DIV>
<DIV>> > 12 {</DIV>
<DIV>> > 13 printf( "Failed to Connect\n" );</DIV>
<DIV>> > 14 return 1;</DIV>
<DIV>> > 15 }</DIV>
<DIV>> > 16 const char* host = "vm01";</DIV>
<DIV>> > 17 virDomainPtr dom;</DIV>
<DIV>> > 18 dom = virDomainLookupByName( conn, host );</DIV>
<DIV>> > 19 if( dom == NULL )</DIV>
<DIV>> > 20 {</DIV>
<DIV>> > 21 printf( "can't find dom\n" );</DIV>
<DIV>> > 22 return 1;</DIV>
<DIV>> > 23 }</DIV>
<DIV>> > 24 // else</DIV>
<DIV>> > 25 // {</DIV>
<DIV>> > 26 // virDomainFree( dom );</DIV>
<DIV>> > 27 // virConnectClose( conn );</DIV>
<DIV>> > 28 // printf("done\n");</DIV>
<DIV>> > 29 // return 0;</DIV>
<DIV>> > 30 // }</DIV>
<DIV>> > 31 if( virDomainCreate( dom ) == -1 )</DIV>
<DIV>> > 32 {</DIV>
<DIV>> > 33 printf( "failed to Start\n" );</DIV>
<DIV>> > 34 virDomainFree( dom );</DIV>
<DIV>> > 35 virConnectClose( conn );</DIV>
<DIV>> > 36 return 1;</DIV>
<DIV>> > 37 }</DIV>
<DIV>> > 38 else</DIV>
<DIV>> > 39 {</DIV>
<DIV>> > 40 printf( "Started\n" );</DIV>
<DIV>> > 41 virDomainFree( dom );</DIV>
<DIV>> > 42 virConnectClose( conn );</DIV>
<DIV>> > 43 return 0;</DIV>
<DIV>> > 44 }</DIV>
<DIV>> > 45 }</DIV>
<DIV>> ></DIV>
<DIV>> > 2010-10-26</DIV>
<DIV>> ></DIV>
<DIV>> > Lancer</DIV>
<DIV>> ></DIV>
<DIV>> > 发件人: Osier</DIV>
<DIV>> > 发送时间: 2010-10-26 11:35:31</DIV>
<DIV>> > 收件人: 黄亮</DIV>
<DIV>> > 抄送: libvir-list</DIV>
<DIV>> > 主题: Re: [libvirt] How to start a defined domain</DIV>
<DIV>> ></DIV>
<DIV>> ></DIV>
<DIV>> ></DIV>
<DIV>> > ----- "黄亮" <lancerhuang@163.com> wrote:</DIV>
<DIV>> ></DIV>
<DIV>> > > I've create a domain called "vm01" using Virt-Manager, the GUI</DIV>
<DIV>> tool.</DIV>
<DIV>> > > Now I wanna use libvirt api to control the life cycle of vm01.</DIV>
<DIV>> > > It went on well with shutdown and reboot, but how to start it</DIV>
<DIV>> became</DIV>
<DIV>> > a</DIV>
<DIV>> > > problem.</DIV>
<DIV>> > ></DIV>
<DIV>> > > I was intended to get the virDomainPtr by using</DIV>
<DIV>> > virDomainLookupByName</DIV>
<DIV>> > > api, and then start it using virDomainCreate api.</DIV>
<DIV>> > > But it turns out that virDomainLookupByName api cannot return a</DIV>
<DIV>> > > virDomainPtr for a defined but not running domain.</DIV>
<DIV>> > ></DIV>
<DIV>> ></DIV>
<DIV>> > no, it can :-)</DIV>
<DIV>> ></DIV>
<DIV>> > If it really doesn't work for you, could you write a simple program</DIV>
<DIV>> to</DIV>
<DIV>> > reproduce it? and try to explain what's the version of libvirt you</DIV>
<DIV>> > use,</DIV>
<DIV>> > on which distro, etc, any helpful info is welcomed. :-)</DIV>
<DIV>> ></DIV>
<DIV>> > Thanks</DIV>
<DIV>> ></DIV>
<DIV>> > - Osier</DIV>
<DIV>> ></DIV>
<DIV>> > > That's my situation, what do you suggest I do now?</DIV>
<DIV>> > > Thanks in advance.</DIV>
<DIV>> > ></DIV>
<DIV>> > > 2010-10-26</DIV>
<DIV>> > ></DIV>
<DIV>> > > Lancer</DIV>
<DIV>> > > --</DIV>
<DIV>> > > libvir-list mailing list</DIV>
<DIV>> > > libvir-list@redhat.com</DIV>
<DIV>> > > https://www.redhat.com/mailman/listinfo/libvir-list</DIV>
<DIV>> ></DIV>
<DIV>> > __________ Information from ESET Smart Security, version of virus</DIV>
<DIV>> > signature database 5562 (20101025) __________</DIV>
<DIV>> ></DIV>
<DIV>> > The message was checked by ESET Smart Security.</DIV>
<DIV>> ></DIV>
<DIV>> > http://www.eset.com</DIV>
<DIV>> </DIV>
<DIV>> __________ Information from ESET Smart Security, version of virus</DIV>
<DIV>> signature database 5562 (20101025) __________</DIV>
<DIV>> </DIV>
<DIV>> The message was checked by ESET Smart Security.</DIV>
<DIV>> </DIV>
<DIV>> http://www.eset.com</DIV>
<DIV></DIV>
<DIV>__________ Information from ESET Smart Security, version of virus signature database 5563 (20101026) __________</DIV>
<DIV></DIV>
<DIV>The message was checked by ESET Smart Security.</DIV>
<DIV></DIV>
<DIV>http://www.eset.com</DIV>
<DIV></DIV>
<DIV></DIV>
<DIV></DIV></FONT></DIV></BODY></HTML>