On Thu, Sep 17, 2009 at 12:42:08AM +0900, Ryota Ozaki wrote: > +static int lxcDomainSuspend(virDomainPtr dom) > +{ > + lxc_driver_t *driver = dom->conn->privateData; > + virDomainObjPtr vm; > + virDomainEventPtr event = NULL; > + int ret = -1; > + > + lxcDriverLock(driver); > + vm = virDomainFindByUUID(&driver->domains, dom->uuid); > + > + if (!vm) { > + char uuidstr[VIR_UUID_STRING_BUFLEN]; > + virUUIDFormat(dom->uuid, uuidstr); > + lxcError(dom->conn, dom, VIR_ERR_NO_DOMAIN, > + _("no domain with matching uuid '%s'"), uuidstr); > + goto cleanup; > + } > + > + if (!virDomainIsActive(vm)) { > + lxcError(dom->conn, dom, VIR_ERR_OPERATION_INVALID, > + "%s", _("domain is not running")); > + goto cleanup; > + } > + > + if (vm->state != VIR_DOMAIN_PAUSED) { > + if (lxcFreezeContainer(driver, vm) < 0) { > + lxcError(dom->conn, dom, VIR_ERR_OPERATION_FAILED, > + "%s", _("suspend operation failed")); > + goto cleanup; > + } > + vm->state = VIR_DOMAIN_PAUSED; > + } > + > + if (virDomainSaveStatus(dom->conn, driver->stateDir, vm) < 0) > + goto cleanup; > + ret = 0; > + > + event = virDomainEventNewFromObj(vm, > + VIR_DOMAIN_EVENT_SUSPENDED, > + VIR_DOMAIN_EVENT_SUSPENDED_PAUSED); The virDomainSaveStatus/virDomainEventNewFromObj calls need to be moved up inside the "if (vm->state != VIR_DOMAIN_PAUSED) {" conditional, since you don't want to dispatch an event if its already paused. > +static int lxcDomainResume(virDomainPtr dom) > +{ > + lxc_driver_t *driver = dom->conn->privateData; > + virDomainObjPtr vm; > + virDomainEventPtr event = NULL; > + int ret = -1; > + > + lxcDriverLock(driver); > + vm = virDomainFindByUUID(&driver->domains, dom->uuid); > + > + if (!vm) { > + char uuidstr[VIR_UUID_STRING_BUFLEN]; > + virUUIDFormat(dom->uuid, uuidstr); > + lxcError(dom->conn, dom, VIR_ERR_NO_DOMAIN, > + _("no domain with matching uuid '%s'"), uuidstr); > + goto cleanup; > + } > + > + if (!virDomainIsActive(vm)) { > + lxcError(dom->conn, dom, VIR_ERR_OPERATION_INVALID, > + "%s", _("domain is not running")); > + goto cleanup; > + } > + > + if (vm->state == VIR_DOMAIN_PAUSED) { > + if (lxcUnfreezeContainer(driver, vm) < 0) { > + lxcError(dom->conn, dom, VIR_ERR_OPERATION_FAILED, > + "%s", _("resume operation failed")); > + goto cleanup; > + } > + vm->state = VIR_DOMAIN_RUNNING; > + } > + > + if (virDomainSaveStatus(dom->conn, driver->stateDir, vm) < 0) > + goto cleanup; > + ret = 0; > + > + event = virDomainEventNewFromObj(vm, > + VIR_DOMAIN_EVENT_RESUMED, > + VIR_DOMAIN_EVENT_RESUMED_UNPAUSED); Same as above - the virDomainSaveStatus/virDomainEventNewFromObj cals need to be moved inside the "if (vm->state == VIR_DOMAIN_PAUSED) " conditional Aside from that, this patch looks good. Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :| -- Libvir-list mailing list Libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list