From nobody Mon Dec 15 23:04:53 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1513788486647429.8702190726058; Wed, 20 Dec 2017 08:48:06 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 995C96016A; Wed, 20 Dec 2017 16:48:04 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 784D1600D4; Wed, 20 Dec 2017 16:48:04 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 40B054A469; Wed, 20 Dec 2017 16:48:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vBKGm3Bq008436 for ; Wed, 20 Dec 2017 11:48:03 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0823F18E4C; Wed, 20 Dec 2017 16:48:03 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.42.22.189]) by smtp.corp.redhat.com (Postfix) with ESMTP id BF2C060C20; Wed, 20 Dec 2017 16:48:01 +0000 (UTC) From: "Daniel P. Berrange" To: libvir-list@redhat.com Date: Wed, 20 Dec 2017 16:47:47 +0000 Message-Id: <20171220164750.26419-3-berrange@redhat.com> In-Reply-To: <20171220164750.26419-1-berrange@redhat.com> References: <20171220164750.26419-1-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Martin Kletzander , David Vossel , Fabian Deutsch Subject: [libvirt] [PATCH 2/5] conf: expose APIs to let drivers load individual config / status files 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 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 20 Dec 2017 16:48:05 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Currently drivers can only do a bulk load of config / status files for their guests. This exposes some helper methods to allow individual guests to be loaded. Signed-off-by: Daniel P. Berrange --- src/conf/virdomainobjlist.c | 98 ++++++++++++++++++++++++++++++++---------= ---- src/conf/virdomainobjlist.h | 17 ++++++++ src/libvirt_private.syms | 2 + 3 files changed, 89 insertions(+), 28 deletions(-) diff --git a/src/conf/virdomainobjlist.c b/src/conf/virdomainobjlist.c index 87a742b1ea..37f795fe6d 100644 --- a/src/conf/virdomainobjlist.c +++ b/src/conf/virdomainobjlist.c @@ -443,16 +443,15 @@ void virDomainObjListRemoveLocked(virDomainObjListPtr= doms, virObjectUnlock(dom); } =20 - static virDomainObjPtr -virDomainObjListLoadConfig(virDomainObjListPtr doms, - virCapsPtr caps, - virDomainXMLOptionPtr xmlopt, - const char *configDir, - const char *autostartDir, - const char *name, - virDomainLoadConfigNotify notify, - void *opaque) +virDomainObjListLoadConfigLocked(virDomainObjListPtr doms, + virCapsPtr caps, + virDomainXMLOptionPtr xmlopt, + const char *configDir, + const char *autostartDir, + const char *name, + virDomainLoadConfigNotify notify, + void *opaque) { char *configFile =3D NULL, *autostartLink =3D NULL; virDomainDefPtr def =3D NULL; @@ -496,14 +495,36 @@ virDomainObjListLoadConfig(virDomainObjListPtr doms, } =20 =20 -static virDomainObjPtr -virDomainObjListLoadStatus(virDomainObjListPtr doms, - const char *statusDir, - const char *name, +virDomainObjPtr +virDomainObjListLoadConfig(virDomainObjListPtr doms, virCapsPtr caps, virDomainXMLOptionPtr xmlopt, + const char *configDir, + const char *autostartDir, + const char *name, virDomainLoadConfigNotify notify, void *opaque) +{ + virDomainObjPtr vm =3D NULL; + virObjectRWLockWrite(doms); + + vm =3D virDomainObjListLoadConfigLocked(doms, caps, xmlopt, configDir, + autostartDir, name, notify, opaq= ue); + virObjectRef(vm); + + virObjectRWUnlock(doms); + return vm; +} + + +static virDomainObjPtr +virDomainObjListLoadStatusLocked(virDomainObjListPtr doms, + const char *statusDir, + const char *name, + virCapsPtr caps, + virDomainXMLOptionPtr xmlopt, + virDomainLoadConfigNotify notify, + void *opaque) { char *statusFile =3D NULL; virDomainObjPtr obj =3D NULL; @@ -555,6 +576,27 @@ virDomainObjListLoadStatus(virDomainObjListPtr doms, } =20 =20 +virDomainObjPtr +virDomainObjListLoadStatus(virDomainObjListPtr doms, + const char *statusDir, + const char *name, + virCapsPtr caps, + virDomainXMLOptionPtr xmlopt, + virDomainLoadConfigNotify notify, + void *opaque) +{ + virDomainObjPtr vm =3D NULL; + virObjectRWLockWrite(doms); + + vm =3D virDomainObjListLoadStatusLocked(doms, statusDir, name, caps, x= mlopt, + notify, opaque); + virObjectRef(vm); + + virObjectRWUnlock(doms); + return vm; +} + + int virDomainObjListLoadAllConfigs(virDomainObjListPtr doms, const char *configDir, @@ -587,22 +629,22 @@ virDomainObjListLoadAllConfigs(virDomainObjListPtr do= ms, kill the whole process */ VIR_INFO("Loading config file '%s.xml'", entry->d_name); if (liveStatus) - dom =3D virDomainObjListLoadStatus(doms, - configDir, - entry->d_name, - caps, - xmlopt, - notify, - opaque); + dom =3D virDomainObjListLoadStatusLocked(doms, + configDir, + entry->d_name, + caps, + xmlopt, + notify, + opaque); else - dom =3D virDomainObjListLoadConfig(doms, - caps, - xmlopt, - configDir, - autostartDir, - entry->d_name, - notify, - opaque); + dom =3D virDomainObjListLoadConfigLocked(doms, + caps, + xmlopt, + configDir, + autostartDir, + entry->d_name, + notify, + opaque); if (dom) { if (!liveStatus) dom->persistent =3D 1; diff --git a/src/conf/virdomainobjlist.h b/src/conf/virdomainobjlist.h index bb186bde30..4aee8fae13 100644 --- a/src/conf/virdomainobjlist.h +++ b/src/conf/virdomainobjlist.h @@ -77,6 +77,23 @@ int virDomainObjListLoadAllConfigs(virDomainObjListPtr d= oms, virDomainXMLOptionPtr xmlopt, virDomainLoadConfigNotify notify, void *opaque); +virDomainObjPtr +virDomainObjListLoadConfig(virDomainObjListPtr doms, + virCapsPtr caps, + virDomainXMLOptionPtr xmlopt, + const char *configDir, + const char *autostartDir, + const char *name, + virDomainLoadConfigNotify notify, + void *opaque); +virDomainObjPtr +virDomainObjListLoadStatus(virDomainObjListPtr doms, + const char *statusDir, + const char *name, + virCapsPtr caps, + virDomainXMLOptionPtr xmlopt, + virDomainLoadConfigNotify notify, + void *opaque); =20 int virDomainObjListNumOfDomains(virDomainObjListPtr doms, bool active, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index a0fde65dba..be631e3dd7 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -938,6 +938,8 @@ virDomainObjListForEach; virDomainObjListGetActiveIDs; virDomainObjListGetInactiveNames; virDomainObjListLoadAllConfigs; +virDomainObjListLoadConfig; +virDomainObjListLoadStatus; virDomainObjListNew; virDomainObjListNumOfDomains; virDomainObjListRemove; --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list