From patchwork Sun Apr 24 23:22:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 66548 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp758403qge; Sun, 24 Apr 2016 16:26:16 -0700 (PDT) X-Received: by 10.140.105.134 with SMTP id c6mr12477954qgf.31.1461540376051; Sun, 24 Apr 2016 16:26:16 -0700 (PDT) Return-Path: Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com. [209.132.183.37]) by mx.google.com with ESMTPS id e24si8967701qkj.236.2016.04.24.16.26.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Apr 2016 16:26:16 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.37 as permitted sender) client-ip=209.132.183.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.37 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 mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3ONNgvg034702; Sun, 24 Apr 2016 19:23:42 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u3ONMxru015477 for ; Sun, 24 Apr 2016 19:22:59 -0400 Received: from colepc.redhat.com (ovpn-113-101.phx2.redhat.com [10.3.113.101]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3ONMu3W006147; Sun, 24 Apr 2016 19:22:59 -0400 From: Cole Robinson To: libvirt-list@redhat.com Date: Sun, 24 Apr 2016 19:22:52 -0400 Message-Id: <18a6aa054fda62a41746a97346c8714a14824f8d.1461540078.git.crobinso@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/4] nwfilter: Save config to disk if we generated a UUID 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 libvirt-daemon-config-nwfilter will put a bunch of xml configs into /etc/libvirt/nwfilter. These configs don't hardcode a UUID and depends on libvirt to generate one. However the generated UUID is never saved to disk, unless the user manually calls Define. This makes daemon reload quite noisy with many errors like: error : virNWFilterObjAssignDef:3101 : operation failed: filter 'allow-incoming-ipv4' already exists with uuid 50def3b5-48d6-46a3-b005-cc22df4e5c5c Because a new UUID is generated every time the config is read from disk, so libvirt constantly thinks it's finding a new nwfilter. Detect if we generated a UUID when the config file is loaded; if so, resave the new contents to disk to ensure the UUID is persisteny. This is similar to what was done in commit a47ae7c0 with virtual networks and generated MAC addresses --- src/conf/nwfilter_conf.c | 6 ++++++ src/conf/nwfilter_conf.h | 1 + 2 files changed, 7 insertions(+) -- 2.7.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c index d8e83f0..f9cb8ea 100644 --- a/src/conf/nwfilter_conf.c +++ b/src/conf/nwfilter_conf.c @@ -2658,6 +2658,7 @@ virNWFilterDefParseXML(xmlXPathContextPtr ctxt) } uuid = virXPathString("string(./uuid)", ctxt); + ret->uuid_specified = (uuid != NULL); if (uuid == NULL) { if (virUUIDGenerate(ret->uuid) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -3178,6 +3179,11 @@ virNWFilterLoadConfig(virNWFilterObjListPtr nwfilters, goto error; } + /* We generated a UUID, make it permanent by saving the config to disk */ + if (!def->uuid_specified && + virNWFilterSaveConfig(configDir, def) < 0) + goto error; + if (!(nwfilter = virNWFilterObjAssignDef(nwfilters, def))) { goto error; } diff --git a/src/conf/nwfilter_conf.h b/src/conf/nwfilter_conf.h index 823cfa4..ea3cd5c 100644 --- a/src/conf/nwfilter_conf.h +++ b/src/conf/nwfilter_conf.h @@ -536,6 +536,7 @@ typedef virNWFilterDef *virNWFilterDefPtr; struct _virNWFilterDef { char *name; unsigned char uuid[VIR_UUID_BUFLEN]; + bool uuid_specified; char *chainsuffix; virNWFilterChainPriority chainPriority;