Domain dm = null;
try {
dm = conn.domainLookupByName(vmName);
if (dm != null && dm.isPersistent() == 1) {
// this is safe because it doesn't stop running VMs
dm.undefine();
}
} catch (LibvirtException e) {
// this is what we want, no domain found
} finally {
if (dm != null) {