On 11/03/2009 07:35 AM, Chris Lalancette wrote:
qemudShutdownVMDaemon() calls qemudRemoveDomainStatus(), which
then calls virFileDeletePID(). qemudShutdownVMDaemon() then
unnecessarily calls virFileDeletePID() again. Remove this second
usage of it, and also slightly refactor qemudRemoveDomainStatus()
to VIR_WARN appropriate error messages.
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
---
src/qemu/qemu_driver.c | 31 +++++++++----------------------
1 files changed, 9 insertions(+), 22 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index fd064af..38fe19e 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -269,7 +269,7 @@ qemudRemoveDomainStatus(virConnectPtr conn,
struct qemud_driver *driver,
virDomainObjPtr vm)
{
- int rc = -1;
+ char ebuf[1024];
char *file = NULL;
if (virAsprintf(&file, "%s/%s.xml", driver->stateDir,
vm->def->name) < 0) {
@@ -277,19 +277,14 @@ qemudRemoveDomainStatus(virConnectPtr conn,
goto cleanup;
}
- if (unlink(file) < 0 && errno != ENOENT && errno != ENOTDIR) {
- qemudReportError(conn, vm, NULL, VIR_ERR_INTERNAL_ERROR,
- _("Failed to unlink status file %s"), file);
- goto cleanup;
- }
-
- if(virFileDeletePid(driver->stateDir, vm->def->name))
- goto cleanup;
+ if (unlink(file) < 0 && errno != ENOENT && errno != ENOTDIR)
+ VIR_WARN(_("Failed to remove domain XML for %s: %s"),
+ vm->def->name, virStrerror(errno, buf, sizeof(ebuf)));
+ if (virFileDeletePid(driver->stateDir, vm->def->name) != 0)
+ VIR_WARN(_("Failed to remove PID file for %s: %s"),
+ vm->def->name, virStrerror(errno, ebuf, sizeof(ebuf)));
- rc = 0;
-cleanup:
- VIR_FREE(file);
- return rc;
+ return 0;
}
@@ -2224,15 +2219,7 @@ retry:
vm->def->name);
}
- if (qemudRemoveDomainStatus(conn, driver, vm) < 0) {
- VIR_WARN(_("Failed to remove domain status for %s"),
- vm->def->name);
- }
- if ((ret = virFileDeletePid(driver->stateDir, vm->def->name)) != 0) {
- char ebuf[1024];
- VIR_WARN(_("Failed to remove PID file for %s: %s"),
- vm->def->name, virStrerror(errno, ebuf, sizeof ebuf));
- }
+ qemudRemoveDomainStatus(conn, driver, vm);
vm->pid = -1;
vm->def->id = -1;
ACK
- Cole