[libvirt] [PATCH 0/3] lxc: Fix domain lookup and error handling

From: Jiri Denemark <jdenemar@redhat.com> Jiri Denemark (3): lxc: Use virDomainFindByUUID for domain lookup lxc: Make SetMemory work for active domains only lxc: Check domain is active/inactive as required by operation src/lxc/lxc_driver.c | 138 ++++++++++++++++++++++++++++++++++---------------- 1 files changed, 94 insertions(+), 44 deletions(-)

From: Jiri Denemark <jdenemar@redhat.com> Consistently use virDomainFindByUUID instead of virDomainFindByID and virDomainFindByName and report VIR_ERR_NO_DOMAIN when domain cannot be found. --- src/lxc/lxc_driver.c | 81 ++++++++++++++++++++++++++++++++++---------------- 1 files changed, 55 insertions(+), 26 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 554bf66..f118b7d 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -200,7 +200,8 @@ static virDomainPtr lxcDomainLookupByID(virConnectPtr conn, lxcDriverUnlock(driver); if (!vm) { - lxcError(VIR_ERR_NO_DOMAIN, NULL); + lxcError(VIR_ERR_NO_DOMAIN, + _("No domain with matching id %d"), id); goto cleanup; } @@ -226,7 +227,10 @@ static virDomainPtr lxcDomainLookupByUUID(virConnectPtr conn, lxcDriverUnlock(driver); if (!vm) { - lxcError(VIR_ERR_NO_DOMAIN, NULL); + char uuidstr[VIR_UUID_STRING_BUFLEN]; + virUUIDFormat(uuid, uuidstr); + lxcError(VIR_ERR_NO_DOMAIN, + _("No domain with matching uuid '%s'"), uuidstr); goto cleanup; } @@ -251,7 +255,8 @@ static virDomainPtr lxcDomainLookupByName(virConnectPtr conn, vm = virDomainFindByName(&driver->domains, name); lxcDriverUnlock(driver); if (!vm) { - lxcError(VIR_ERR_NO_DOMAIN, NULL); + lxcError(VIR_ERR_NO_DOMAIN, + _("No domain with matching name '%s'"), name); goto cleanup; } @@ -276,7 +281,10 @@ static int lxcDomainIsActive(virDomainPtr dom) obj = virDomainFindByUUID(&driver->domains, dom->uuid); lxcDriverUnlock(driver); if (!obj) { - lxcError(VIR_ERR_NO_DOMAIN, NULL); + char uuidstr[VIR_UUID_STRING_BUFLEN]; + virUUIDFormat(dom->uuid, uuidstr); + lxcError(VIR_ERR_NO_DOMAIN, + _("No domain with matching uuid '%s'"), uuidstr); goto cleanup; } ret = virDomainObjIsActive(obj); @@ -298,7 +306,10 @@ static int lxcDomainIsPersistent(virDomainPtr dom) obj = virDomainFindByUUID(&driver->domains, dom->uuid); lxcDriverUnlock(driver); if (!obj) { - lxcError(VIR_ERR_NO_DOMAIN, NULL); + char uuidstr[VIR_UUID_STRING_BUFLEN]; + virUUIDFormat(dom->uuid, uuidstr); + lxcError(VIR_ERR_NO_DOMAIN, + _("No domain with matching uuid '%s'"), uuidstr); goto cleanup; } ret = obj->persistent; @@ -424,8 +435,10 @@ static int lxcDomainUndefine(virDomainPtr dom) lxcDriverLock(driver); vm = virDomainFindByUUID(&driver->domains, dom->uuid); if (!vm) { - lxcError(VIR_ERR_INVALID_DOMAIN, - "%s", _("No domain with matching uuid")); + char uuidstr[VIR_UUID_STRING_BUFLEN]; + virUUIDFormat(dom->uuid, uuidstr); + lxcError(VIR_ERR_NO_DOMAIN, + _("No domain with matching uuid '%s'"), uuidstr); goto cleanup; } @@ -475,8 +488,10 @@ static int lxcDomainGetInfo(virDomainPtr dom, vm = virDomainFindByUUID(&driver->domains, dom->uuid); if (!vm) { - lxcError(VIR_ERR_INVALID_DOMAIN, - "%s", _("No domain with matching uuid")); + char uuidstr[VIR_UUID_STRING_BUFLEN]; + virUUIDFormat(dom->uuid, uuidstr); + lxcError(VIR_ERR_NO_DOMAIN, + _("No domain with matching uuid '%s'"), uuidstr); goto cleanup; } @@ -528,8 +543,10 @@ static char *lxcGetOSType(virDomainPtr dom) lxcDriverUnlock(driver); if (!vm) { - lxcError(VIR_ERR_INVALID_DOMAIN, - "%s", _("No domain with matching uuid")); + char uuidstr[VIR_UUID_STRING_BUFLEN]; + virUUIDFormat(dom->uuid, uuidstr); + lxcError(VIR_ERR_NO_DOMAIN, + _("No domain with matching uuid '%s'"), uuidstr); goto cleanup; } @@ -668,8 +685,10 @@ static char *lxcDomainDumpXML(virDomainPtr dom, lxcDriverUnlock(driver); if (!vm) { - lxcError(VIR_ERR_INVALID_DOMAIN, - "%s", _("No domain with matching uuid")); + char uuidstr[VIR_UUID_STRING_BUFLEN]; + virUUIDFormat(dom->uuid, uuidstr); + lxcError(VIR_ERR_NO_DOMAIN, + _("No domain with matching uuid '%s'"), uuidstr); goto cleanup; } @@ -1341,10 +1360,12 @@ static int lxcDomainStart(virDomainPtr dom) int ret = -1; lxcDriverLock(driver); - vm = virDomainFindByName(&driver->domains, dom->name); + vm = virDomainFindByUUID(&driver->domains, dom->uuid); if (!vm) { - lxcError(VIR_ERR_INVALID_DOMAIN, - _("No domain named %s"), dom->name); + char uuidstr[VIR_UUID_STRING_BUFLEN]; + virUUIDFormat(dom->uuid, uuidstr); + lxcError(VIR_ERR_NO_DOMAIN, + _("No domain with matching uuid '%s'"), uuidstr); goto cleanup; } @@ -1450,10 +1471,12 @@ static int lxcDomainShutdown(virDomainPtr dom) int ret = -1; lxcDriverLock(driver); - vm = virDomainFindByID(&driver->domains, dom->id); + vm = virDomainFindByUUID(&driver->domains, dom->uuid); if (!vm) { - lxcError(VIR_ERR_INVALID_DOMAIN, - _("No domain with id %d"), dom->id); + char uuidstr[VIR_UUID_STRING_BUFLEN]; + virUUIDFormat(dom->uuid, uuidstr); + lxcError(VIR_ERR_NO_DOMAIN, + _("No domain with matching uuid '%s'"), uuidstr); goto cleanup; } @@ -1627,10 +1650,12 @@ static int lxcDomainDestroy(virDomainPtr dom) int ret = -1; lxcDriverLock(driver); - vm = virDomainFindByID(&driver->domains, dom->id); + vm = virDomainFindByUUID(&driver->domains, dom->uuid); if (!vm) { - lxcError(VIR_ERR_INVALID_DOMAIN, - _("No domain with id %d"), dom->id); + char uuidstr[VIR_UUID_STRING_BUFLEN]; + virUUIDFormat(dom->uuid, uuidstr); + lxcError(VIR_ERR_NO_DOMAIN, + _("No domain with matching uuid '%s'"), uuidstr); goto cleanup; } @@ -1996,8 +2021,10 @@ static int lxcSetSchedulerParameters(virDomainPtr domain, vm = virDomainFindByUUID(&driver->domains, domain->uuid); if (vm == NULL) { - lxcError(VIR_ERR_INTERNAL_ERROR, - _("No such domain %s"), domain->uuid); + char uuidstr[VIR_UUID_STRING_BUFLEN]; + virUUIDFormat(domain->uuid, uuidstr); + lxcError(VIR_ERR_NO_DOMAIN, + _("No domain with matching uuid '%s'"), uuidstr); goto cleanup; } @@ -2054,8 +2081,10 @@ static int lxcGetSchedulerParameters(virDomainPtr domain, vm = virDomainFindByUUID(&driver->domains, domain->uuid); if (vm == NULL) { - lxcError(VIR_ERR_INTERNAL_ERROR, - _("No such domain %s"), domain->uuid); + char uuidstr[VIR_UUID_STRING_BUFLEN]; + virUUIDFormat(domain->uuid, uuidstr); + lxcError(VIR_ERR_NO_DOMAIN, + _("No domain with matching uuid '%s'"), uuidstr); goto cleanup; } -- 1.7.1

On Mon, May 03, 2010 at 02:20:26PM +0200, jdenemar@redhat.com wrote:
From: Jiri Denemark <jdenemar@redhat.com>
Consistently use virDomainFindByUUID instead of virDomainFindByID and virDomainFindByName and report VIR_ERR_NO_DOMAIN when domain cannot be found.
That's actually 2 patches in one, one using uuid for lookups, and the second fixing the whole set of messages. ACK, Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

From: Jiri Denemark <jdenemar@redhat.com> --- src/lxc/lxc_driver.c | 39 +++++++++++++++++++++------------------ 1 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index f118b7d..6884fea 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -642,27 +642,30 @@ static int lxcDomainSetMemory(virDomainPtr dom, unsigned long newmem) { goto cleanup; } - if (virDomainObjIsActive(vm)) { - if (driver->cgroup == NULL) { - lxcError(VIR_ERR_NO_SUPPORT, - "%s", _("cgroups must be configured on the host")); - goto cleanup; - } + if (!virDomainObjIsActive(vm)) { + lxcError(VIR_ERR_OPERATION_INVALID, + "%s", _("Domain is not running")); + goto cleanup; + } - if (virCgroupForDomain(driver->cgroup, vm->def->name, &cgroup, 0) != 0) { - lxcError(VIR_ERR_INTERNAL_ERROR, - _("Unable to get cgroup for %s"), vm->def->name); - goto cleanup; - } + if (driver->cgroup == NULL) { + lxcError(VIR_ERR_NO_SUPPORT, + "%s", _("cgroups must be configured on the host")); + goto cleanup; + } - if (virCgroupSetMemory(cgroup, newmem) < 0) { - lxcError(VIR_ERR_OPERATION_FAILED, - "%s", _("Failed to set memory for domain")); - goto cleanup; - } - } else { - vm->def->memory = newmem; + if (virCgroupForDomain(driver->cgroup, vm->def->name, &cgroup, 0) != 0) { + lxcError(VIR_ERR_INTERNAL_ERROR, + _("Unable to get cgroup for %s"), vm->def->name); + goto cleanup; + } + + if (virCgroupSetMemory(cgroup, newmem) < 0) { + lxcError(VIR_ERR_OPERATION_FAILED, + "%s", _("Failed to set memory for domain")); + goto cleanup; } + ret = 0; cleanup: -- 1.7.1

On Mon, May 03, 2010 at 02:20:27PM +0200, jdenemar@redhat.com wrote:
From: Jiri Denemark <jdenemar@redhat.com>
--- src/lxc/lxc_driver.c | 39 +++++++++++++++++++++------------------ 1 files changed, 21 insertions(+), 18 deletions(-)
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index f118b7d..6884fea 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -642,27 +642,30 @@ static int lxcDomainSetMemory(virDomainPtr dom, unsigned long newmem) { goto cleanup; }
- if (virDomainObjIsActive(vm)) { - if (driver->cgroup == NULL) { - lxcError(VIR_ERR_NO_SUPPORT, - "%s", _("cgroups must be configured on the host")); - goto cleanup; - } + if (!virDomainObjIsActive(vm)) { + lxcError(VIR_ERR_OPERATION_INVALID, + "%s", _("Domain is not running")); + goto cleanup; + }
- if (virCgroupForDomain(driver->cgroup, vm->def->name, &cgroup, 0) != 0) { - lxcError(VIR_ERR_INTERNAL_ERROR, - _("Unable to get cgroup for %s"), vm->def->name); - goto cleanup; - } + if (driver->cgroup == NULL) { + lxcError(VIR_ERR_NO_SUPPORT, + "%s", _("cgroups must be configured on the host")); + goto cleanup; + }
- if (virCgroupSetMemory(cgroup, newmem) < 0) { - lxcError(VIR_ERR_OPERATION_FAILED, - "%s", _("Failed to set memory for domain")); - goto cleanup; - } - } else { - vm->def->memory = newmem; + if (virCgroupForDomain(driver->cgroup, vm->def->name, &cgroup, 0) != 0) { + lxcError(VIR_ERR_INTERNAL_ERROR, + _("Unable to get cgroup for %s"), vm->def->name); + goto cleanup; + } + + if (virCgroupSetMemory(cgroup, newmem) < 0) { + lxcError(VIR_ERR_OPERATION_FAILED, + "%s", _("Failed to set memory for domain")); + goto cleanup; } + ret = 0;
cleanup:
I'm not 100% sure of the patch but the new sequence look more logical, I'm still concerned that the new code seems to not update vm->def->memory ACK, once double-checked it's not needed :-) Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

On Mon, May 3, 2010 at 10:48 PM, Daniel Veillard <veillard@redhat.com> wrote:
On Mon, May 03, 2010 at 02:20:27PM +0200, jdenemar@redhat.com wrote:
From: Jiri Denemark <jdenemar@redhat.com>
--- src/lxc/lxc_driver.c | 39 +++++++++++++++++++++------------------ 1 files changed, 21 insertions(+), 18 deletions(-)
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index f118b7d..6884fea 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -642,27 +642,30 @@ static int lxcDomainSetMemory(virDomainPtr dom, unsigned long newmem) { goto cleanup; }
- if (virDomainObjIsActive(vm)) { - if (driver->cgroup == NULL) { - lxcError(VIR_ERR_NO_SUPPORT, - "%s", _("cgroups must be configured on the host")); - goto cleanup; - } + if (!virDomainObjIsActive(vm)) { + lxcError(VIR_ERR_OPERATION_INVALID, + "%s", _("Domain is not running")); + goto cleanup; + }
- if (virCgroupForDomain(driver->cgroup, vm->def->name, &cgroup, 0) != 0) { - lxcError(VIR_ERR_INTERNAL_ERROR, - _("Unable to get cgroup for %s"), vm->def->name); - goto cleanup; - } + if (driver->cgroup == NULL) { + lxcError(VIR_ERR_NO_SUPPORT, + "%s", _("cgroups must be configured on the host")); + goto cleanup; + }
- if (virCgroupSetMemory(cgroup, newmem) < 0) { - lxcError(VIR_ERR_OPERATION_FAILED, - "%s", _("Failed to set memory for domain")); - goto cleanup; - } - } else { - vm->def->memory = newmem; + if (virCgroupForDomain(driver->cgroup, vm->def->name, &cgroup, 0) != 0) { + lxcError(VIR_ERR_INTERNAL_ERROR, + _("Unable to get cgroup for %s"), vm->def->name); + goto cleanup; + } + + if (virCgroupSetMemory(cgroup, newmem) < 0) { + lxcError(VIR_ERR_OPERATION_FAILED, + "%s", _("Failed to set memory for domain")); + goto cleanup; } + ret = 0;
cleanup:
I'm not 100% sure of the patch but the new sequence look more logical, I'm still concerned that the new code seems to not update vm->def->memory
I think it's OK because the behavior is same as qemu driver and does not bother me, a user of lxc ;-) Thanks, ozaki-r
ACK, once double-checked it's not needed :-)
Daniel
-- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

@@ -642,27 +642,30 @@ static int lxcDomainSetMemory(virDomainPtr dom, unsigned long newmem) { goto cleanup; }
- if (virDomainObjIsActive(vm)) { - if (driver->cgroup == NULL) { - lxcError(VIR_ERR_NO_SUPPORT, - "%s", _("cgroups must be configured on the host")); - goto cleanup; - } + if (!virDomainObjIsActive(vm)) { + lxcError(VIR_ERR_OPERATION_INVALID, + "%s", _("Domain is not running")); + goto cleanup; + }
- if (virCgroupForDomain(driver->cgroup, vm->def->name, &cgroup, 0) != 0) { - lxcError(VIR_ERR_INTERNAL_ERROR, - _("Unable to get cgroup for %s"), vm->def->name); - goto cleanup; - } + if (driver->cgroup == NULL) { + lxcError(VIR_ERR_NO_SUPPORT, + "%s", _("cgroups must be configured on the host")); + goto cleanup; + }
- if (virCgroupSetMemory(cgroup, newmem) < 0) { - lxcError(VIR_ERR_OPERATION_FAILED, - "%s", _("Failed to set memory for domain")); - goto cleanup; - } - } else { - vm->def->memory = newmem; + if (virCgroupForDomain(driver->cgroup, vm->def->name, &cgroup, 0) != 0) { + lxcError(VIR_ERR_INTERNAL_ERROR, + _("Unable to get cgroup for %s"), vm->def->name); + goto cleanup; + } + + if (virCgroupSetMemory(cgroup, newmem) < 0) { + lxcError(VIR_ERR_OPERATION_FAILED, + "%s", _("Failed to set memory for domain")); + goto cleanup; } + ret = 0;
cleanup:
I'm not 100% sure of the patch but the new sequence look more logical, I'm still concerned that the new code seems to not update vm->def->memory
Hmm, the patch generated by git is a bit confusing. In reality it's quite simple... Before the patch, there was a whole bunch of code within "if (virDomainObjIsActive(vm))" and "vm->def->memory = newmem;" if the VM wasn't active. Now, the function works only for active VMs (which is it's correct behavior as it was never supposed to work offline, one has to change domain XML to make offline changes), that is "vm->def->memory = newmem;" is replaced with VIR_ERR_OPERATION_INVALID error. There is no change in semantics for active VMs. Jirka

On Tue, May 04, 2010 at 11:56:56AM +0200, Jiri Denemark wrote:
@@ -642,27 +642,30 @@ static int lxcDomainSetMemory(virDomainPtr dom, unsigned long newmem) { goto cleanup; }
- if (virDomainObjIsActive(vm)) { - if (driver->cgroup == NULL) { - lxcError(VIR_ERR_NO_SUPPORT, - "%s", _("cgroups must be configured on the host")); - goto cleanup; - } + if (!virDomainObjIsActive(vm)) { + lxcError(VIR_ERR_OPERATION_INVALID, + "%s", _("Domain is not running")); + goto cleanup; + }
- if (virCgroupForDomain(driver->cgroup, vm->def->name, &cgroup, 0) != 0) { - lxcError(VIR_ERR_INTERNAL_ERROR, - _("Unable to get cgroup for %s"), vm->def->name); - goto cleanup; - } + if (driver->cgroup == NULL) { + lxcError(VIR_ERR_NO_SUPPORT, + "%s", _("cgroups must be configured on the host")); + goto cleanup; + }
- if (virCgroupSetMemory(cgroup, newmem) < 0) { - lxcError(VIR_ERR_OPERATION_FAILED, - "%s", _("Failed to set memory for domain")); - goto cleanup; - } - } else { - vm->def->memory = newmem; + if (virCgroupForDomain(driver->cgroup, vm->def->name, &cgroup, 0) != 0) { + lxcError(VIR_ERR_INTERNAL_ERROR, + _("Unable to get cgroup for %s"), vm->def->name); + goto cleanup; + } + + if (virCgroupSetMemory(cgroup, newmem) < 0) { + lxcError(VIR_ERR_OPERATION_FAILED, + "%s", _("Failed to set memory for domain")); + goto cleanup; } + ret = 0;
cleanup:
I'm not 100% sure of the patch but the new sequence look more logical, I'm still concerned that the new code seems to not update vm->def->memory
Hmm, the patch generated by git is a bit confusing. In reality it's quite simple... Before the patch, there was a whole bunch of code within "if (virDomainObjIsActive(vm))" and "vm->def->memory = newmem;" if the VM wasn't active. Now, the function works only for active VMs (which is it's correct behavior as it was never supposed to work offline, one has to change domain XML to make offline changes), that is "vm->def->memory = newmem;" is replaced with VIR_ERR_OPERATION_INVALID error. There is no change in semantics for active VMs.
Ah, okay, I didn't realized the vm->def->memory = newmem was only for non-running domains, ACK, thanks ! Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

From: Jiri Denemark <jdenemar@redhat.com> Report VIR_ERR_OPERATION_INVALID when operation which requires running domain is called on inactive domain and vice versa. --- src/lxc/lxc_driver.c | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 6884fea..fc0df37 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1378,6 +1378,12 @@ static int lxcDomainStart(virDomainPtr dom) goto cleanup; } + if (virDomainObjIsActive(vm)) { + lxcError(VIR_ERR_OPERATION_INVALID, + "%s", _("Domain is already running")); + goto cleanup; + } + ret = lxcVmStart(dom->conn, driver, vm); if (ret == 0) @@ -1483,6 +1489,12 @@ static int lxcDomainShutdown(virDomainPtr dom) goto cleanup; } + if (!virDomainObjIsActive(vm)) { + lxcError(VIR_ERR_OPERATION_INVALID, + "%s", _("Domain is not running")); + goto cleanup; + } + ret = lxcVmTerminate(driver, vm, 0); event = virDomainEventNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED, @@ -1662,6 +1674,12 @@ static int lxcDomainDestroy(virDomainPtr dom) goto cleanup; } + if (!virDomainObjIsActive(vm)) { + lxcError(VIR_ERR_OPERATION_INVALID, + "%s", _("Domain is not running")); + goto cleanup; + } + ret = lxcVmTerminate(driver, vm, SIGKILL); event = virDomainEventNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED, -- 1.7.1

On Mon, May 03, 2010 at 02:20:28PM +0200, jdenemar@redhat.com wrote:
From: Jiri Denemark <jdenemar@redhat.com>
Report VIR_ERR_OPERATION_INVALID when operation which requires running domain is called on inactive domain and vice versa. --- src/lxc/lxc_driver.c | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 6884fea..fc0df37 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1378,6 +1378,12 @@ static int lxcDomainStart(virDomainPtr dom) goto cleanup; }
+ if (virDomainObjIsActive(vm)) { + lxcError(VIR_ERR_OPERATION_INVALID, + "%s", _("Domain is already running")); + goto cleanup; + } + ret = lxcVmStart(dom->conn, driver, vm);
if (ret == 0) @@ -1483,6 +1489,12 @@ static int lxcDomainShutdown(virDomainPtr dom) goto cleanup; }
+ if (!virDomainObjIsActive(vm)) { + lxcError(VIR_ERR_OPERATION_INVALID, + "%s", _("Domain is not running")); + goto cleanup; + } + ret = lxcVmTerminate(driver, vm, 0); event = virDomainEventNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED, @@ -1662,6 +1674,12 @@ static int lxcDomainDestroy(virDomainPtr dom) goto cleanup; }
+ if (!virDomainObjIsActive(vm)) { + lxcError(VIR_ERR_OPERATION_INVALID, + "%s", _("Domain is not running")); + goto cleanup; + } + ret = lxcVmTerminate(driver, vm, SIGKILL); event = virDomainEventNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED,
Ah, sure :-) ACK Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

Jiri Denemark (3): lxc: Use virDomainFindByUUID for domain lookup lxc: Make SetMemory work for active domains only lxc: Check domain is active/inactive as required by operation
src/lxc/lxc_driver.c | 138 ++++++++++++++++++++++++++++++++++---------------- 1 files changed, 94 insertions(+), 44 deletions(-)
I pushed this series. Thanks for the reviews. Jirka
participants (4)
-
Daniel Veillard
-
jdenemar@redhat.com
-
Jiri Denemark
-
Ryota Ozaki