static virDomainPtr
vzDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags)
{
@@ -782,6 +798,9 @@ vzDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags)
goto cleanup;
job = true;
+ if (!vzDomainObjIsExist(dom))
+ goto cleanup;
+
if (prlsdkApplyConfig(driver, dom, def))
goto cleanup;
@@ -1012,6 +1031,9 @@ vzDomainUndefineFlags(virDomainPtr domain,
goto cleanup;
job = true;
+ if (!vzDomainObjIsExist(dom))
+ goto cleanup;
+
ret = prlsdkUnregisterDomain(privconn->driver, dom, flags);
cleanup:
@@ -1070,6 +1092,9 @@ vzDomainManagedSave(virDomainPtr domain, unsigned int flags)
goto cleanup;
job = true;
+ if (!vzDomainObjIsExist(dom))
+ goto cleanup;
+
state = virDomainObjGetState(dom, &reason);
if (state == VIR_DOMAIN_RUNNING && (flags & VIR_DOMAIN_SAVE_PAUSED)) {
@@ -1160,6 +1185,9 @@ static int vzDomainAttachDeviceFlags(virDomainPtr domain, const char *xml,
goto cleanup;
job = true;
+ if (!vzDomainObjIsExist(dom))
+ goto cleanup;
+
switch (dev->type) {
case VIR_DOMAIN_DEVICE_DISK:
ret = prlsdkAttachVolume(privconn->driver, dom, dev->data.disk);
@@ -1228,6 +1256,9 @@ static int vzDomainDetachDeviceFlags(virDomainPtr domain, const char *xml,
goto cleanup;
job = true;
+ if (!vzDomainObjIsExist(dom))
+ goto cleanup;
+
switch (dev->type) {
case VIR_DOMAIN_DEVICE_DISK:
ret = prlsdkDetachVolume(dom, dev->data.disk);
@@ -1285,6 +1316,9 @@ vzDomainSetUserPassword(virDomainPtr domain,
goto cleanup;
job = true;
+ if (!vzDomainObjIsExist(dom))
+ goto cleanup;
+
ret = prlsdkDomainSetUserPassword(dom, user, password);
cleanup:
@@ -1618,6 +1652,9 @@ static int vzDomainSetMemoryFlagsImpl(virDomainPtr domain, unsigned long memory,
goto cleanup;
job = true;
+ if (!vzDomainObjIsExist(dom))
+ goto cleanup;
+
ret = prlsdkSetMemsize(dom, memory >> 10);
cleanup:
@@ -2102,6 +2139,9 @@ vzDomainSnapshotCreateXML(virDomainPtr domain,
goto cleanup;
job = true;
+ if (!vzDomainObjIsExist(dom))
+ goto cleanup;
+
/* snaphot name is ignored, it will be set to auto generated by sdk uuid */
if (prlsdkCreateSnapshot(dom, def->description) < 0)
goto cleanup;
@@ -2163,6 +2203,9 @@ vzDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, unsigned int flags)
goto cleanup;
job = true;
+ if (!vzDomainObjIsExist(dom))
+ goto cleanup;
+
ret = prlsdkSwitchToSnapshot(dom, snapshot->name,
flags & VIR_DOMAIN_SNAPSHOT_REVERT_PAUSED);
cleanup:
@@ -2533,6 +2576,9 @@ vzDomainMigratePerformStep(virDomainPtr domain,
goto cleanup;
job = true;
+ if (!vzDomainObjIsExist(dom))
+ goto cleanup;
+
if (!(vzuri = vzParseVzURI(miguri)))
goto cleanup;
diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index 551df10..ba3c28e 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -1812,6 +1812,9 @@ prlsdkHandleVmConfigEvent(vzDriverPtr driver,
goto cleanup;
job = true;
+ if (dom->removing)
+ goto cleanup;
+
if (prlsdkUpdateDomain(driver, dom) < 0)
goto cleanup;
@@ -2078,6 +2081,16 @@ prlsdkDomainChangeState(virDomainPtr domain,
goto cleanup;
job = true;
+ if (dom->removing) {
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
+
+ virUUIDFormat(dom->def->uuid, uuidstr);
+ virReportError(VIR_ERR_NO_DOMAIN,
+ _("no domain with matching uuid '%s' (%s)"),
+ uuidstr, dom->def->name);
+ goto cleanup;
+ }
+
ret = prlsdkDomainChangeStateLocked(privconn->driver, dom, chstate);
cleanup: