Change in vdsm[ovirt-3.4]: vm: add extra recovery checking for ppc

fromani at redhat.com fromani at redhat.com
Thu Aug 7 15:08:56 UTC 2014


Francesco Romani has uploaded a new change for review.

Change subject: vm: add extra recovery checking for ppc
......................................................................

vm: add extra recovery checking for ppc

On recovery, VDSM checks each VM listed by libvirt
to see if it should take care of it.
The check is done by using some system properties
added in the smbios domain element, which is lacking
outside x86_64.

As result, recovery finds no VMs on PPC64.

This patch adds an extra checks in addition to the
existing one, based on the guest agent channels, to overcome
this limitation.

guest agent channels can be disabled by configuration,
but this is a rare and unlikely scenario; moreover,
this is still the most reliable indicator left of
a VM created by VDSM.

This patch is 3.4.x only, since master and 3.5.x
use a more robust and forward compatible approach
based on libvirt domain metadata.

Change-Id: I7a299732fb7f9b67066b18aded48f35a88066338
Bug-Url: https://bugzilla.redhat.com/1126887
Signed-off-by: Francesco Romani <fromani at redhat.com>
---
M tests/vmTests.py
M tests/vmTestsData.py
M vdsm/clientIF.py
M vdsm/vm.py
4 files changed, 110 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/13/31213/1

diff --git a/tests/vmTests.py b/tests/vmTests.py
index bd5a904..69d1f00 100644
--- a/tests/vmTests.py
+++ b/tests/vmTests.py
@@ -22,6 +22,7 @@
 import shutil
 import tempfile
 import xml.etree.ElementTree as ET
+import xml.dom.minidom as MD
 
 import libvirt
 
@@ -35,6 +36,7 @@
 from monkeypatch import MonkeyPatch, MonkeyPatchScope
 from vmTestsData import CONF_TO_DOMXML_X86_64
 from vmTestsData import CONF_TO_DOMXML_PPC64
+from vmTestsData import DOMXML_NO_VDSM_CHANNEL
 
 
 class ConnectionMock:
@@ -665,6 +667,18 @@
     def testBuildCmdLinePPC64(self):
         self.assertBuildCmdLine(CONF_TO_DOMXML_PPC64)
 
+    def testHasVDSMChannelsX86_64(self):
+        vmdom = MD.parseString(CONF_TO_DOMXML_X86_64[0][1])
+        self.assertTrue(vm.hasVDSMChannels(vmdom))
+
+    def testHasVDSMChannelsPPC64(self):
+        vmdom = MD.parseString(CONF_TO_DOMXML_PPC64[0][1])
+        self.assertTrue(vm.hasVDSMChannels(vmdom))
+
+    def testHasNotVdsmChannels(self):
+        vmdom = MD.parseString(DOMXML_NO_VDSM_CHANNEL)
+        self.assertFalse(vm.hasVDSMChannels(vmdom))
+
 
 class FakeGuestAgent(object):
     def getGuestInfo(self):
diff --git a/tests/vmTestsData.py b/tests/vmTestsData.py
index b75c9dc..fb48d94 100644
--- a/tests/vmTestsData.py
+++ b/tests/vmTestsData.py
@@ -144,3 +144,77 @@
                 </qemu:commandline>
             </domain>
 """, )]
+
+DOMXML_NO_VDSM_CHANNEL = """
+<domain type="kvm">
+	<name>SuperTiny_C0</name>
+	<uuid>b63bfabf-6be6-4273-b133-3f8a068f52ac</uuid>
+	<memory>65536</memory>
+	<currentMemory>65536</currentMemory>
+	<vcpu current="1">160</vcpu>
+	<memtune>
+		<min_guarantee>16384</min_guarantee>
+	</memtune>
+	<devices>
+		<channel type="unix">
+			<target name="org.qemu.guest_agent.0" type="virtio"/>
+			<source mode="bind" path="/var/lib/libvirt/qemu/channels/b63bfabf-6be6-4273-b133-3f8a068f52ac.org.qemu.guest_agent.0"/>
+		</channel>
+		<input bus="ps2" type="mouse"/>
+		<memballoon model="none"/>
+		<controller index="0" model="virtio-scsi" type="scsi">
+			<address bus="0x00" domain="0x0000" function="0x0" slot="0x03" type="pci"/>
+		</controller>
+		<video>
+			<address bus="0x00" domain="0x0000" function="0x0" slot="0x02" type="pci"/>
+			<model heads="1" type="qxl" vram="32768"/>
+		</video>
+		<graphics autoport="yes" keymap="en-us" passwd="*****" passwdValidTo="1970-01-01T00:00:01" port="-1" tlsPort="-1" type="spice">
+			<listen network="vdsm-ovirtmgmt" type="network"/>
+		</graphics>
+		<disk device="cdrom" snapshot="no" type="file">
+			<address bus="1" controller="0" target="0" type="drive" unit="0"/>
+			<source file="" startupPolicy="optional"/>
+			<target bus="ide" dev="hdc"/>
+			<readonly/>
+			<serial/>
+			<boot order="1"/>
+		</disk>
+		<disk device="disk" snapshot="no" type="block">
+			<address bus="0x00" domain="0x0000" function="0x0" slot="0x05" type="pci"/>
+			<source dev="/rhev/data-center/00000002-0002-0002-0002-0000000003dd/fde1a05c-66ad-4846-b6cf-d8bca4656689/images/524f0170-68fe-4acf-94c9-923cb510e1d1/e86bb357-d216-4f27-b40a-39c20da77a79"/>
+			<target bus="virtio" dev="vda"/>
+			<serial>524f0170-68fe-4acf-94c9-923cb510e1d1</serial>
+			<driver cache="none" error_policy="stop" io="native" name="qemu" type="qcow2"/>
+		</disk>
+		<channel type="spicevmc">
+			<target name="com.redhat.spice.0" type="virtio"/>
+		</channel>
+	</devices>
+	<os>
+		<type arch="x86_64" machine="rhel6.5.0">hvm</type>
+		<smbios mode="sysinfo"/>
+	</os>
+	<sysinfo type="smbios">
+		<system>
+			<entry name="manufacturer">oVirt</entry>
+			<entry name="product">oVirt Node</entry>
+			<entry name="version">6Server-6.5.0.1.el6</entry>
+			<entry name="serial">4C4C4544-0059-4410-8043-B6C04F4E5A31_10:fe:ed:02:02:e4</entry>
+			<entry name="uuid">b63bfabf-6be6-4273-b133-3f8a068f52ac</entry>
+		</system>
+	</sysinfo>
+	<clock adjustment="0" offset="variable">
+		<timer name="rtc" tickpolicy="catchup"/>
+		<timer name="pit" tickpolicy="delay"/>
+		<timer name="hpet" present="no"/>
+	</clock>
+	<features>
+		<acpi/>
+	</features>
+	<cpu match="exact">
+		<model>SandyBridge</model>
+		<topology cores="1" sockets="160" threads="1"/>
+	</cpu>
+</domain>
+"""
diff --git a/vdsm/clientIF.py b/vdsm/clientIF.py
index 987b7f3..7c4840d 100644
--- a/vdsm/clientIF.py
+++ b/vdsm/clientIF.py
@@ -37,7 +37,7 @@
 from vdsm import utils
 import caps
 from vmChannels import Listener
-from vm import Vm
+from vm import Vm, hasVDSMChannels
 import blkid
 import supervdsm
 import sampling
@@ -443,15 +443,14 @@
         """
         try:
             vmdom = minidom.parseString(vm.XMLDesc(0))
-            sysinfo = vmdom.getElementsByTagName("sysinfo")[0]
         except libvirt.libvirtError as e:
             if e.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN:
                 self.log.error("domId: %s is dead", vm.UUIDString())
             else:
                 raise
-        except IndexError:
-            pass  # no sysinfo in xml
-        else:
+        infos = vmdom.getElementsByTagName("sysinfo")
+        if infos:
+            sysinfo = infos[0]
             systype = sysinfo.getAttribute("type")
             if systype == "smbios":
                 entries = sysinfo.getElementsByTagName("entry")
@@ -462,7 +461,14 @@
                                     caps.OSName.RHEVH, caps.OSName.FEDORA,
                                     caps.OSName.DEBIAN):
                             return True
-        return False
+        # else no sysinfo in xml, fallback to less reliable guest agent
+        # channel detection (mostly PPC)
+        try:
+            return hasVDSMChannels(vmdom)
+        except IndexError:
+            # recovery must not fail
+            return False
+
 
     def _getVDSMVms(self):
         """
diff --git a/vdsm/vm.py b/vdsm/vm.py
index 3b947c1..a4da973 100644
--- a/vdsm/vm.py
+++ b/vdsm/vm.py
@@ -80,6 +80,16 @@
 SMARTCARD_DEVICES = 'smartcard'
 
 
+def hasVDSMChannels(vmdom):
+    devices = vmdom.getElementsByTagName('devices')[0]
+    for chan in devices.getElementsByTagName('channel'):
+        target = chan.getElementsByTagName('target')[0]
+        if target.getAttribute('name') == _VMCHANNEL_DEVICE_NAME:
+            return True
+
+    return False
+
+
 def isVdsmImage(drive):
     """
     Tell if drive looks like a vdsm image


-- 
To view, visit http://gerrit.ovirt.org/31213
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7a299732fb7f9b67066b18aded48f35a88066338
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.4
Gerrit-Owner: Francesco Romani <fromani at redhat.com>


More information about the vdsm-patches mailing list