<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Webdings;
        panose-1:5 3 1 2 1 5 9 6 7 3;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
        {mso-style-priority:99;
        mso-style-link:"Texte brut Car";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Texte de bulles Car";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";
        mso-fareast-language:EN-US;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.TextedebullesCar
        {mso-style-name:"Texte de bulles Car";
        mso-style-priority:99;
        mso-style-link:"Texte de bulles";
        font-family:"Tahoma","sans-serif";}
span.TextebrutCar
        {mso-style-name:"Texte brut Car";
        mso-style-priority:99;
        mso-style-link:"Texte brut";
        font-family:"Calibri","sans-serif";}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="FR" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoPlainText"><span lang="EN-US">Hi,<o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US">This is what I tried :<o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US">Y , how enter    an answer in the thread ?)<o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US">virsh -c qemu+ssh://127.0.0.1:22/system  hostname
</span><a href="mailto:root@127.0.0.1's"><span lang="EN-US">root@127.0.0.1's</span></a><span lang="EN-US"> password:<o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US">error: End of file while reading data: : Input/output error<o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US">error: failed to connect to the hypervisor<o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US">In another hand ,as we have few information  to share ,  I was thinking to use a virtio channel to dialog between host and guest .<o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US">Does it fit ?<o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US">Thx<o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US">J.P. ?<o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoPlainText">-----Message d'origine-----<o:p></o:p></p>
<p class="MsoPlainText">De : Eric Blake [<a href="mailto:eblake@redhat.com">mailto:eblake@redhat.com</a>] Envoyé : vendredi 4 juillet 2014 15:20 À : Jean-Pierre Ribeauville;
<a href="mailto:libvirt-users@redhat.com">libvirt-users@redhat.com</a> Objet : Re: [libvirt-users] Acces to hypervisor from a KVM guest<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText"><span lang="EN-US">On 07/04/2014 04:23 AM, Jean-Pierre Ribeauville wrote:<o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US">> Hi,<o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US">> <o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US">>>From a KVM guest, I want to retrieve  the hostname of the host on which the hypervisor is running.<o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US">> Before doing that by using libvirt API, I first try via virsh.<o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US">Well, virsh just uses the libvirt API under the hood.  I'd suggest that you try: virsh -c qemu://host/system hostname<o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US">except that this is a chicken-and-egg situation, because virsh in the guest doesn't know what host to connect to.<o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US">If you are using the out-of-the-box NAT setup, then you could use qemu://192.168.122.1/system, since your guest will be using an IP address assigned from that subnet from the host.<o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US">Other than that, libvirt is not really designed for guest-to-host communication, but for host management of guests.  You'll have to solve your problem in some other way.  Consider the same situation with bare metal
 hosts - if you are provisioning a cluster, and want machines in the cluster to communicate to a particular controller, but not all machines connect to the same controller, how would you do that?  If you can solve that problem, then you can use it to solve
 your guest provisioning problem.<o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US">> error: Failed to reconnect to the hypervisor<o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US">> error: no valid connection<o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US">> error: internal error Unable to locate libvirtd daemon in /usr/sbin
<o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US">> (to override, set $LIBVIRTD_PATH to the name of the libvirtd binary)<o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US">This failure is because you did not use -c to connect to a remote daemon, but don't have libvirtd running in the guest.  You do not need libvirtd running locally to use virsh for remote connections, but you do need
 to know where the remote connection lives.<o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US">-- <o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US">Eric Blake   eblake redhat com    +1-919-301-3266<o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US">Libvirt virtualization library </span>
<a href="http://libvirt.org"><span lang="EN-US">http://libvirt.org</span></a><span lang="EN-US"><o:p></o:p></span></p>
<p class="MsoPlainText"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:FR"><img border="0" width="134" height="34" id="Image_x0020_2" src="cid:image001.png@01CF9939.B81C1EF0" alt="cid:image001.png@01CF75CE.35F97F50"></span><span lang="EN-US" style="mso-fareast-language:FR"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:FR"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Arial","sans-serif";mso-fareast-language:FR">Jean-Pierre RIBEAUVILLE</span><span style="font-size:8.0pt;mso-fareast-language:FR"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Arial","sans-serif";mso-fareast-language:FR">Developer</span><span style="font-size:8.0pt;mso-fareast-language:FR"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Arial","sans-serif";mso-fareast-language:FR">Tel: 01 49 11 45 81</span><span style="font-size:8.0pt;mso-fareast-language:FR"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Arial","sans-serif";color:#1F497D;mso-fareast-language:FR"> </span><span style="font-size:8.0pt;color:#1F497D;mso-fareast-language:FR"><o:p></o:p></span></p>
<p class="MsoNormal"><u><span lang="EN-US" style="font-size:8.0pt;font-family:"Arial","sans-serif";color:#C00000;mso-fareast-language:FR"><a href="https://www.youtube.com/channel/UCvyaJkMXCGFo8_XZYd9rcBw"><span style="color:#C00000">Discover Systar’s Videos!</span></a><o:p></o:p></span></u></p>
<p class="MsoNormal"><u><span lang="EN-US" style="color:#1F497D;mso-fareast-language:FR"><o:p><span style="text-decoration:none"> </span></o:p></span></u></p>
<p class="MsoNormal"><b><span lang="EN-GB" style="font-size:9.0pt;font-family:Webdings;color:green;mso-fareast-language:FR">P</span></b><b><span lang="EN-GB" style="font-size:9.0pt;font-family:"Tahoma","sans-serif";color:green;mso-fareast-language:FR">
</span></b><span lang="EN-GB" style="font-size:10.0pt;font-family:"Arial","sans-serif";color:green;mso-fareast-language:FR">Please consider the environment before printing this e-mail</span><u><span lang="EN-GB" style="color:blue;mso-fareast-language:FR"><o:p></o:p></span></u></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
</div>
</body>
</html>