Product SiteDocumentation Site

4.3.5. Determining if the domain has managed save images

The hasManagedSaveImages method returns a boolean value indicating if a domain a managed save image. Note that a running domain should never have a saved image because that image should have been removed when the domain was restarted.

Example 4.11. Determining if the domain has a managed save images

# Example-48.py
#!/usr/bin/env python3
import sys
import libvirt
from xml.dom import minidom

domName = 'CentOS7'

conn = None
try:
    conn = libvirt.open("qemu:///system")
except libvirt.libvirtError as e:
    print(repr(e), file=sys.stderr)
    exit(1)

dom = None
try:
    dom = conn.lookupByName(domName)
except libvirt.libvirtError as e:
    print(repr(e), file=sys.stderr)
    exit(1)

flag = dom.hasManagedSaveImage()
print('The value of the manaed save images flag is ' + str(flag))

conn.close()
exit(0)