<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
{font-family:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;}
@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;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
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.MsoAcetate, li.MsoAcetate, div.MsoAcetate
{mso-style-priority:99;
mso-style-link:"Balloon Text Char";
margin:0in;
margin-bottom:.0001pt;
font-size:8.0pt;
font-family:"Tahoma","sans-serif";}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
{mso-style-priority:34;
margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
span.EmailStyle17
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:windowtext;}
span.EmailStyle18
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.EmailStyle19
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.BalloonTextChar
{mso-style-name:"Balloon Text Char";
mso-style-priority:99;
mso-style-link:"Balloon Text";
font-family:"Tahoma","sans-serif";}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
/* List Definitions */
@list l0
{mso-list-id:290944846;
mso-list-type:hybrid;
mso-list-template-ids:1357393950 -921942986 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;}
@list l0:level1
{mso-level-start-at:0;
mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;
font-family:Symbol;
mso-fareast-font-family:Calibri;
mso-bidi-font-family:"Times New Roman";}
@list l0:level2
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;
font-family:"Courier New";}
@list l0:level3
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;
font-family:Wingdings;}
@list l0:level4
{mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;
font-family:Symbol;}
@list l0:level5
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;
font-family:"Courier New";}
@list l0:level6
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;
font-family:Wingdings;}
@list l0:level7
{mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;
font-family:Symbol;}
@list l0:level8
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;
font-family:"Courier New";}
@list l0:level9
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;
font-family:Wingdings;}
ol
{margin-bottom:0in;}
ul
{margin-bottom:0in;}
--></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="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="color:#1F497D">Don’t mean to keep replying to myself, but here are the details:<o:p></o:p></span></p>
<p class="MsoListParagraph" style="text-indent:-.25in;mso-list:l0 level1 lfo1"><![if !supportLists]><span style="font-family:Symbol;color:#1F497D"><span style="mso-list:Ignore">·<span style="font:7.0pt "Times New Roman"">
</span></span></span><![endif]><span style="color:#1F497D">Kilo (RHEL OSP 7.0, but installed via packstack)<o:p></o:p></span></p>
<p class="MsoListParagraph" style="text-indent:-.25in;mso-list:l0 level1 lfo1"><![if !supportLists]><span style="font-family:Symbol;color:#1F497D"><span style="mso-list:Ignore">·<span style="font:7.0pt "Times New Roman"">
</span></span></span><![endif]><span style="color:#1F497D">Compute host is RHEL 7.1<o:p></o:p></span></p>
<p class="MsoListParagraph" style="text-indent:-.25in;mso-list:l0 level1 lfo1"><![if !supportLists]><span style="font-family:Symbol;color:#1F497D"><span style="mso-list:Ignore">·<span style="font:7.0pt "Times New Roman"">
</span></span></span><![endif]><span style="color:#1F497D">VM is Centos 7.1<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Sundar Nadathur
<br>
<b>Sent:</b> Sunday, November 29, 2015 10:03 PM<br>
<b>To:</b> 'openstack-dev@lists.openstack.org'<br>
<b>Subject:</b> RE: Devices in VM that are not in instance XML<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="color:#1F497D">Typo: </span><span style="font-family:"Courier New";color:#1F497D">nova/virt/libvirt/libvirt.p</span><span style="color:#1F497D">y
</span><span style="font-family:Wingdings;color:#1F497D">à</span><span style="color:#1F497D">
</span><span style="font-family:"Courier New";color:#1F497D">nova/virt/libvirt/<b>driver</b>.py</span><span style="color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal"><span style="color:#1F497D">Cheers,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">Sundar<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Sundar Nadathur
<br>
<b>Sent:</b> Sunday, November 29, 2015 9:59 PM<br>
<b>To:</b> 'openstack-dev@lists.openstack.org'<br>
<b>Subject:</b> Devices in VM that are not in instance XML<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Hi,<o:p></o:p></p>
<p class="MsoNormal"> I am facing a strange issue where I remove some devices from a VM’s xml before creating the domain, but both device types are still present in the VM, but with a different definition.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><b>Background</b>:<o:p></o:p></p>
<p class="MsoNormal"> I am attempting to inject or remove some devices from specific VMs before they are brought up. More specifically, I'd like to update the instance's domain XML on the compute host before the instance is launched, as part of Nova Compute.
This is to be done programmatically, not manually. <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">However, the build_instance hook in Nova compute doesn't quite let one do that. In the 'pre' hook, the instance XML is not yet defined. In the post hook, it is defined but it already too late because the domain has been created from the
xml.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><b>What I did</b>:<o:p></o:p></p>
<p class="MsoNormal">So, as an experiment, I modified nova/virt/libvirt/libvirt.py, specifically
<o:p></o:p></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">def spawn(...):<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> disk_info = ...<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> self._create_image(...)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> xml = self._get_guest_xml(..., write_to_disk=<span style="color:red">False</span>)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> # -- <span style="color:red">
Modify the xml here and write it to libvirt.xml</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> self._create_domain_and_network(context, xml, ...)<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Also, I verified in <span style="font-family:"Courier New"">
_create_domain</span>, just before:<o:p></o:p></p>
<p class="MsoNormal"> <span style="font-family:"Courier New"">domain = self._conn.defineXML(xml)<o:p></o:p></span></p>
<p class="MsoNormal">that the xml is as I intended.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><b>Problem</b>:<o:p></o:p></p>
<p class="MsoNormal">But it doesn't work. In this experiment, I am trying to remove the memballoon (virtio) device and an USB device from the domain XML. But both show up in the VM under lspci after the VM boots up, but with a different definition.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The original XML had:<o:p></o:p></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> <input type="tablet" bus="usb"/><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> <memballoon model="virtio"> <stats period="10"/> </memballoon><o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Both got removed. But 'virsh dumpxml' of the VM shows:<o:p></o:p></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> <controller type='usb' index='0'><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> <alias name='usb0'/><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> </controller><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> <memballoon model='virtio'><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> <alias name='balloon0'/><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> </memballoon></span><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Where are these devices coming from, since they are not present in the defineXML that nova.compute.libvirt driver invokes?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Cheers,<o:p></o:p></p>
<p class="MsoNormal">Sundar<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<br>
<hr>
<font face="Arial" color="Black" size="2"><br>
Confidentiality Notice.<br>
This message may contain information that is confidential or otherwise protected from disclosure. If you are not the intended recipient, you are hereby notified that any use, disclosure, dissemination, distribution, or copying of this message, or any attachments,
is strictly prohibited. If you have received this message in error, please advise the sender by reply e-mail, and delete the message and any attachments. Thank you.<br>
</font>
</body>
</html>