diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index ce43d1b963ec0f9ea9f41d4f7d772552d25f2e18..343145510ab62aafb47c9c7e335aedcf21af0797 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -714,6 +714,22 @@ vzDomainGetAutostart(virDomainPtr domain, int *autostart) return 0; } +static int +vzEnsureDomainExists(virDomainObjPtr dom) +{ + char uuidstr[VIR_UUID_STRING_BUFLEN]; + + if (!dom->removing) + return 0; + + virUUIDFormat(dom->def->uuid, uuidstr); + virReportError(VIR_ERR_NO_DOMAIN, + _("no domain with matching uuid '%s' (%s)"), + uuidstr, dom->def->name); + + return -1; +} + static virDomainPtr vzDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags) { @@ -780,6 +796,9 @@ vzDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags) goto cleanup; job = true; + if (vzEnsureDomainExists(dom) < 0) + goto cleanup; + if (prlsdkApplyConfig(driver, dom, def)) goto cleanup; @@ -1010,6 +1029,9 @@ vzDomainUndefineFlags(virDomainPtr domain, goto cleanup; job = true; + if (vzEnsureDomainExists(dom) < 0) + goto cleanup; + ret = prlsdkUnregisterDomain(privconn->driver, dom, flags); cleanup: @@ -1066,6 +1088,9 @@ vzDomainManagedSave(virDomainPtr domain, unsigned int flags) goto cleanup; job = true; + if (vzEnsureDomainExists(dom) < 0) + goto cleanup; + state = virDomainObjGetState(dom, &reason); if (state == VIR_DOMAIN_RUNNING && (flags & VIR_DOMAIN_SAVE_PAUSED)) { @@ -1157,6 +1182,9 @@ static int vzDomainAttachDeviceFlags(virDomainPtr domain, const char *xml, goto cleanup; job = true; + if (vzEnsureDomainExists(dom) < 0) + goto cleanup; + if (prlsdkAttachDevice(driver, dom, dev) < 0) goto cleanup; @@ -1206,6 +1234,9 @@ static int vzDomainDetachDeviceFlags(virDomainPtr domain, const char *xml, goto cleanup; job = true; + if (vzEnsureDomainExists(dom) < 0) + goto cleanup; + if (prlsdkDetachDevice(driver, dom, dev) < 0) goto cleanup; @@ -1243,6 +1274,9 @@ vzDomainSetUserPassword(virDomainPtr domain, goto cleanup; job = true; + if (vzEnsureDomainExists(dom) < 0) + goto cleanup; + ret = prlsdkDomainSetUserPassword(dom, user, password); cleanup: @@ -1281,6 +1315,9 @@ static int vzDomainUpdateDeviceFlags(virDomainPtr domain, goto cleanup; job = true; + if (vzEnsureDomainExists(dom) < 0) + goto cleanup; + if (prlsdkUpdateDevice(driver, dom, dev) < 0) goto cleanup; @@ -1619,6 +1656,9 @@ static int vzDomainSetMemoryFlagsImpl(virDomainPtr domain, unsigned long memory, goto cleanup; job = true; + if (vzEnsureDomainExists(dom) < 0) + goto cleanup; + ret = prlsdkSetMemsize(dom, memory >> 10); cleanup: @@ -2103,6 +2143,9 @@ vzDomainSnapshotCreateXML(virDomainPtr domain, goto cleanup; job = true; + if (vzEnsureDomainExists(dom) < 0) + goto cleanup; + /* snaphot name is ignored, it will be set to auto generated by sdk uuid */ if (prlsdkCreateSnapshot(dom, def->description) < 0) goto cleanup; @@ -2164,6 +2207,9 @@ vzDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, unsigned int flags) goto cleanup; job = true; + if (vzEnsureDomainExists(dom) < 0) + goto cleanup; + ret = prlsdkSwitchToSnapshot(dom, snapshot->name, flags & VIR_DOMAIN_SNAPSHOT_REVERT_PAUSED); cleanup: @@ -2534,6 +2580,9 @@ vzDomainMigratePerformStep(virDomainPtr domain, goto cleanup; job = true; + if (vzEnsureDomainExists(dom) < 0) + goto cleanup; + if (!(vzuri = vzParseVzURI(miguri))) goto cleanup; diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index 5c2a6c59619407845e2ba6c076527a15f64437d4..38254c05e2df1d91e0d62825cf66338bbb629b4d 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -2067,6 +2067,9 @@ prlsdkHandleVmConfigEvent(vzDriverPtr driver, goto cleanup; job = true; + if (dom->removing) + goto cleanup; + if (prlsdkUpdateDomain(driver, dom) < 0) goto cleanup; @@ -2333,6 +2336,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: