<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#ffffff">
On 11/12/2010 02:07 AM, 黄亮 wrote:
<blockquote cite="mid:201011121007066565474@163.com" type="cite">
  <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>
  <div><font face="Verdana" size="2" color="#000080">Hi Alex</font></div>
  <div> </div>
  <div><font color="#000080">Thank you for your reply.</font></div>
  <div><font color="#000080">I just wanna make sure I'm not
misunderstanding, virStorageVolGetXMLDesc &
virStorageVolCreateXMLFrom together can do the clone process, am I
right?</font></div>
</blockquote>
In fact, libvirt will call a group of APIs to complete vol-clone
operation, you can track the whole calling process, it  looks like this:<br>
                                              virsh vol-clone
<vol-key> <newname><br>
                                                                          
|<br>
                                                                         
V<br>
                                                            
virConnectOpenAuth<br>
                                                                          
|<br>
                                                                         
V<br>
                                                       
virStorageVolLookupByKey<br>
                                                                          
|<br>
                                                                         
V<br>
                                                      
virStoragePoolLookupByVolume  ('default' is default pool)<br>
                                                                          
|<br>
                                                                       
  V<br>
                                                      
virStorageVolGetXMLDesc<br>
                                                                          
|<br>
                                                                         
V<br>
                                                    
virStorageVolCreateXMLFrom<br>
                                                                          
|<br>
                                                                         
V<br>
                                                          
virStorageVolGetName (twice)<br>
                                                                       
   |<br>
                                                                       
  V<br>
                                                             
virStorageVolFree    (twice) <br>
                                                                       
   |<br>
                                                                         
V<br>
                                                            
virStoragePoolFree<br>
                                                                          
|<br>
                                                                         
V<br>
                                                              
virConnectClose<br>
                                                    <br>
                                                           
                                       <br>
  Alex<br>
<blockquote cite="mid:201011121007066565474@163.com" type="cite">
  <div> </div>
  <div><font color="#000080">Regards</font></div>
  <div> </div>
  <div> </div>
  <div><font face="Verdana" size="2" color="#c0c0c0">2010-11-12 </font></div>
  <font face="Verdana" size="2" color="#000080">
  <hr style="width: 100px;" size="1" align="left" color="#b5c4df"></font>
  <div><font face="Verdana" size="2" color="#c0c0c0">Lancer </font></div>
  <hr size="1" color="#b5c4df">
  <div><font face="Verdana" size="2"><strong>发件人:</strong> Alex Jia </font></div>
  <div><font face="Verdana" size="2"><strong>发送时间:</strong> 2010-11-10 
13:28:21 </font></div>
  <div><font face="Verdana" size="2"><strong>收件人:</strong> 黄亮 </font></div>
  <div><font face="Verdana" size="2"><strong>抄送:</strong> libvir-list </font></div>
  <div><font face="Verdana" size="2"><strong>主题:</strong> Re: [libvirt]
Is there an API for clone? </font></div>
  <div> </div>
  <div><font face="Verdana" size="2">
  <div>Hi lancer,</div>
  <div>As Osier said, libvirt hasn't a independent API for cloning an</div>
  <div>existing guest, instead of using virStorageVolGetXMLDesc API to </div>
  <div>get a guest volume xml description and then calling  </div>
  <div>virStorageVolCreateXMLFrom API to clone a new volume.</div>
  <div>For python-virtinst component, you may use virt-clone to implement</div>
  <div>this, for libvirt component, you may directly use python binding</div>
  <div>API or virsh tool 'vol-clone' to implement it.</div>
  <div>I hope it's helpful for you.</div>
  <div>- Alex</div>
  <div>----- Original Message -----</div>
  <div>From: "黄亮" <a class="moz-txt-link-rfc2396E" href="mailto:lancerhuang@163.com"><lancerhuang@163.com></a></div>
  <div>To: "libvir-list" <a class="moz-txt-link-rfc2396E" href="mailto:libvir-list@redhat.com"><libvir-list@redhat.com></a></div>
  <div>Sent: Wednesday, November 10, 2010 9:30:28 AM GMT +08:00 Beijing / Chongqing / Hong Kong / Urumqi</div>
  <div>Subject: [libvirt] Is there an API for clone?</div>
  <div>Hi, guys </div>
  <div>I know there is a command "virt-clone", but I couldn't find the equivalent API here : <a class="moz-txt-link-freetext" href="http://libvirt.org/html/libvirt-libvirt.html">http://libvirt.org/html/libvirt-libvirt.html</a> </div>
  <div>So, is there an API to clone an existing VM or not? </div>
  <div>Thank you! </div>
  <div>Regards </div>
  <div>2010-11-10 </div>
  <div>Lancer </div>
  <div>--</div>
  <div>libvir-list mailing list</div>
  <div><a class="moz-txt-link-abbreviated" href="mailto:libvir-list@redhat.com">libvir-list@redhat.com</a></div>
  <div><a class="moz-txt-link-freetext" href="https://www.redhat.com/mailman/listinfo/libvir-list">https://www.redhat.com/mailman/listinfo/libvir-list</a></div>
  <div>__________ Information from ESET Smart Security, version of virus signature database 5605 (20101109) __________</div>
  <div>The message was checked by ESET Smart Security.</div>
  <div><a class="moz-txt-link-freetext" href="http://www.eset.com">http://www.eset.com</a></div>
  </font></div>
</blockquote>
<br>
</body>
</html>