From patchwork Thu Jun 23 00:12:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 70700 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp167488qgy; Wed, 22 Jun 2016 17:14:54 -0700 (PDT) X-Received: by 10.28.103.2 with SMTP id b2mr10851701wmc.28.1466640894397; Wed, 22 Jun 2016 17:14:54 -0700 (PDT) Return-Path: Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com. [209.132.183.39]) by mx.google.com with ESMTPS id z2si3033624wje.23.2016.06.22.17.14.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Jun 2016 17:14:54 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.39 as permitted sender) client-ip=209.132.183.39; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.39 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u5N0CS2R065444; Wed, 22 Jun 2016 20:12:28 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u5N0CNTi003825 for ; Wed, 22 Jun 2016 20:12:23 -0400 Received: from colepc.redhat.com (ovpn-116-65.rdu2.redhat.com [10.10.116.65]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u5N0CHC7010243; Wed, 22 Jun 2016 20:12:22 -0400 From: Cole Robinson To: libvirt-list@redhat.com Date: Wed, 22 Jun 2016 20:12:16 -0400 Message-Id: <4f5de6852f65c4b7c305b05975a8c4ed05b36387.1466640165.git.crobinso@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 6/6] conf: sync error reporting for object configFile unlinking X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com The various object implementations for configFile unlinking have subtly different error handling behavior. Sync the impls to use a single error string, and consistently ignore ENOENT, to allow undefining an object whose configFile was deleted behind libvirt's back --- src/conf/domain_conf.c | 7 ++----- src/conf/network_conf.c | 6 ++---- src/conf/nwfilter_conf.c | 6 ++---- src/conf/storage_conf.c | 7 +++---- src/conf/virsecretobj.c | 2 +- 5 files changed, 10 insertions(+), 18 deletions(-) -- 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 75ad03f..9e5af3f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -23881,11 +23881,8 @@ virDomainDeleteConfig(const char *configDir, unlink(autostartLink); dom->autostart = 0; - if (unlink(configFile) < 0 && - errno != ENOENT) { - virReportSystemError(errno, - _("cannot remove config %s"), - configFile); + if (unlink(configFile) < 0 && errno != ENOENT) { + virReportSystemError(errno, _("cannot remove config %s"), configFile); goto cleanup; } diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index 02b8cd7..4732766 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -3319,10 +3319,8 @@ int virNetworkDeleteConfig(const char *configDir, unlink(autostartLink); net->autostart = 0; - if (unlink(configFile) < 0) { - virReportSystemError(errno, - _("cannot remove config file '%s'"), - configFile); + if (unlink(configFile) < 0 && errno != ENOENT) { + virReportSystemError(errno, _("cannot remove config %s"), configFile); goto error; } diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c index 3f90f65..64dbe8b 100644 --- a/src/conf/nwfilter_conf.c +++ b/src/conf/nwfilter_conf.c @@ -3283,10 +3283,8 @@ virNWFilterObjDeleteDef(const char *configDir, goto error; } - if (unlink(configFile) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot remove config for %s"), - nwfilter->def->name); + if (unlink(configFile) < 0 && errno != ENOENT) { + virReportSystemError(errno, _("cannot remove config %s"), configFile); goto error; } diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 6932195..e45e197 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -2129,10 +2129,9 @@ virStoragePoolObjDeleteDef(virStoragePoolObjPtr pool) return -1; } - if (unlink(pool->configFile) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot remove config for %s"), - pool->def->name); + if (unlink(pool->configFile) < 0 && errno != ENOENT) { + virReportSystemError(errno, _("cannot remove config %s"), + pool->configFile); return -1; } diff --git a/src/conf/virsecretobj.c b/src/conf/virsecretobj.c index c46d22c..2a5cd31 100644 --- a/src/conf/virsecretobj.c +++ b/src/conf/virsecretobj.c @@ -663,7 +663,7 @@ virSecretObjDeleteConfig(virSecretObjPtr secret) { if (!secret->def->isephemeral && unlink(secret->configFile) < 0 && errno != ENOENT) { - virReportSystemError(errno, _("cannot unlink '%s'"), + virReportSystemError(errno, _("cannot remove config %s"), secret->configFile); return -1; }