<html><head><meta http-equiv="content-type" content="text/html; charset=GB2312"><style>body { line-height: 1.5; }blockquote { margin-top: 0px; margin-bottom: 0px; margin-left: 0.5em; }div.foxdiv20161023174301248335 { }body { font-size: 10.5pt; font-family: 'Microsoft YaHei UI'; color: rgb(0, 0, 0); line-height: 1.5; }</style></head><body>
<div><span></span><br></div>
<div><br></div><hr style="width: 210px; height: 1px;" color="#b5c4df" size="1" align="left">
<div><span><div style="MARGIN: 10px; FONT-FAMILY: verdana; FONT-SIZE: 10pt"><div>zhunxun@gmail.com</div></div></span></div>
<blockquote style="margin-top: 0px; margin-bottom: 0px; margin-left: 0.5em;"><div> </div><div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm"><div style="PADDING-RIGHT: 8px; PADDING-LEFT: 8px; FONT-SIZE: 12px;FONT-FAMILY:tahoma;COLOR:#000000; BACKGROUND: #efefef; PADDING-BOTTOM: 8px; PADDING-TOP: 8px"><div><b>发件人:</b> <a href="mailto:zhunxun@gmail.com">zhunxun@gmail.com</a></div><div><b>发送时间:</b> 2016-10-23 17:42</div><div><b>收件人:</b> <a href="mailto:berrange@redhat.com">berrange</a></div><div><b>主题:</b> Re: Re: [libvirt] How libvirt address qemu command line args</div></div></div><div><div class="FoxDiv20161023174301248335">
<div><span></span>Thanks,However,I have to use this method.Now I wander how get the VM xml contents in Libvirt source code,I try output some message in qemuProcessStart function like this ,but I get nothing,anyone can help me??</div><div>thanks!</div><div>my code is :</div><div>in qemuStartProcess function</div>
<div><span style="font-family: "" microsoft="" yahei="" ui'";="" font-size:="" 14px;="" color:="" rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,="" font-weight:="" normal;="" font-style:="" normal;text-decoration:="" none;'="">char *str=qemuDomainDefFormatXML(driver, vm->def, 0);<br>        FILE *op=fopen("/root/libvirt.log","a");<br>        if(op!=NULL){<br>                if(str!=NULL)<br>                        fprintf(op,"str----cmd : %s\n",str);<br>                else<br>                        fprintf(op,"str is null\n");<br>                fclose(op);<br>        }else{<br>                fprintf(op,"open file error!\n");<br>        }<br></span></div><hr style="WIDTH: 210px; HEIGHT: 1px" color="#b5c4df" size="1" align="left">
<div><span><div style="MARGIN: 10px; FONT-FAMILY: verdana; FONT-SIZE: 10pt"><div>zhunxun@gmail.com</div></div></span></div>
<blockquote style="margin-top: 0px; margin-bottom: 0px; margin-left: 0.5em;"><div> </div><div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm"><div style="PADDING-RIGHT: 8px; PADDING-LEFT: 8px; FONT-SIZE: 12px;FONT-FAMILY:tahoma;COLOR:#000000; BACKGROUND: #efefef; PADDING-BOTTOM: 8px; PADDING-TOP: 8px"><div><b>From:</b> <a href="mailto:berrange@redhat.com">Daniel P. Berrange</a></div><div><b>Date:</b> 2016-10-19 15:35</div><div><b>To:</b> <a href="mailto:mprivozn@redhat.com">Michal Privoznik</a></div><div><b>CC:</b> <a href="mailto:zhunxun@gmail.com">zhunxun@gmail.com</a>; <a href="mailto:libvir-list@redhat.com">libvir-list</a></div><div><b>Subject:</b> Re: [libvirt] How libvirt address qemu command line args</div></div></div><div><div>On Wed, Oct 19, 2016 at 10:17:21AM +0800, Michal Privoznik wrote:</div>
<div>> On 18.10.2016 14:59, zhunxun@gmail.com wrote:</div>
<div>> > Now I want to add some args about TPM  to domain's XML,so I can start a domain by virt-manager or other virsh command,and then ,I would like to use sVIrt security context to label vTPM and correspondingVM,But I do not know how to get these XML  args in libvirt.</div>
<div>> > the key problem is that how can i get and recognize these args!!!</div>
<div>> > related XML content :</div>
<div>> </div>
<div>> Usually, grepping the code for cmd name <-> XML element/attribute</div>
<div>> translation is sufficient (esp. if you grep tests/)</div>
<div>> </div>
<div>> > </div>
<div>> > <qemu:commandline></div>
<div>> >     <qemu:arg value='-enable-kvm'/></div>
<div>> </div>
<div>> Firstly, this is obsolete in favour of "-machine accel=kvm". In any</div>
<div>> case, <domain type='kvm'/> will do the trick (libvirt will use whatever</div>
<div>> is supported by qemu binary in your system).</div>
<div>> </div>
<div>> >     <qemu:arg value='-drive'/></div>
<div>> >     <qemu:arg value='file=/root/nvram_2.0-jin.qcow2,if=none,id=nvram0-0-0,format=qcow2'/></div>
<div>> </div>
<div>> Okay, this is not supported by libvirt yet. We don't really have a way</div>
<div>> how to specify NVRAM in anything other than a raw file. BTW: isn't qcow</div>
<div>> too big gun for NVRAM? I mean, NVRAM has a fixed size of what ~190 KB?</div>
<div>> QCOW header is about the same size.</div>
<div>> </div>
<div>> >     <qemu:arg value='-device'/></div>
<div>> >     <qemu:arg value='tpm-tis,tpmdev=tpm-tpm0,id=tpm0'/></div>
<div>> >     <qemu:arg value='-tpmdev'/></div>
<div>> >     <qemu:arg value='libtpms,id=tpm-tpm0,nvram=nvram0-0-0,startup=clear'/></div>
<div>> </div>
<div>> I'm not sure there's a way how to put startup=clean on the cmd line. I'm</div>
<div>> not even sure what it does.</div>
<div>> And I have not idea what libtpms is either :-)</div>
<div>> </div>
<div>> >     <qemu:arg value='-bios'/></div>
<div>> >     <qemu:arg value='/root/xenSeabios/out/bios.bin'/></div>
<div>> >   </qemu:commandline></div>
<div>> ></div>
<div> </div>
<div>On top of all that - QEMU is likely to fail to start since libvirt by</div>
<div>default runs it as qemu:qemu user/group, and so it won't have permission</div>
<div>to read any of the files in /root. If you have selinux/apparmour that</div>
<div>will also block permission.</div>
<div> </div>
<div>This is an example of why usage of qemu:commandline is discouraged - it</div>
<div>will always have problems with permissions if you pass files using it.</div>
<div> </div>
<div>Regards,</div>
<div>Daniel</div>
<div>-- </div>
<div>|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|</div>
<div>|: http://libvirt.org              -o-             http://virt-manager.org :|</div>
<div>|: http://entangle-photo.org       -o-    http://search.cpan.org/~danberr/ :|</div>
</div></blockquote>
</div></div></blockquote>
</body></html>