domain: relax the UNDEFINE_NVRAM condition precisely to libvirtd's one

(1) A separate nvram (ie. variable store) file for the domain exists if
and only if the following condition holds:

    (self.get_xmlobj().os.loader_ro is True and
     self.get_xmlobj().os.loader_type == "pflash")

(Refer to libvirtd's qemuPrepareNVRAM() function, as of commit 742b08e30.)

(2) The

    self.get_xmlobj().os.nvram

condition is sufficient, but not necessary, for the separate varstore file
to exist. That is, if the condition holds, then the separate varstore file
exists for sure, but if the condition doesn't hold, the file may exist
nonetheless. (Because libvirtd can auto-generate the varstore file's
pathname.)

This means that requiring condition (2) for setting UNDEFINE_NVRAM on
domain deletion will miss a subset of the cases, ie. when the necessary
and sufficient condition (1) holds, but the sufficient-only condition (2)
doesn't.

Make sure that the code uses the necessary and sufficient condition (1).

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
This commit is contained in:
Laszlo Ersek 2014-09-21 13:12:48 +02:00 committed by Cole Robinson
parent b3fa8bb650
commit 3e5b61da86
1 changed files with 1 additions and 2 deletions

View File

@ -1399,8 +1399,7 @@ class vmmDomain(vmmLibvirtObject):
"VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA", 0)
flags |= getattr(libvirt, "VIR_DOMAIN_UNDEFINE_MANAGED_SAVE", 0)
if (self.get_xmlobj().os.loader_ro is True and
self.get_xmlobj().os.loader_type == "pflash" and
self.get_xmlobj().os.nvram):
self.get_xmlobj().os.loader_type == "pflash"):
flags |= getattr(libvirt, "VIR_DOMAIN_UNDEFINE_NVRAM", 0)
try:
self._backend.undefineFlags(flags)