From nobody Mon May 6 02:52:59 2024 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 1502895617037240.00092783624189; Wed, 16 Aug 2017 08:00:17 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 220D5D7E91; Wed, 16 Aug 2017 15:00:15 +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 ED6E46FA8B; Wed, 16 Aug 2017 15:00:14 +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 A8D0E3FAD8; Wed, 16 Aug 2017 14:59:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7GEvxce007944 for ; Wed, 16 Aug 2017 10:57:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id 84C2D6FA93; Wed, 16 Aug 2017 14:57:59 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id CA2FA6FA91; Wed, 16 Aug 2017 14:57:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 220D5D7E91 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 16 Aug 2017 16:57:50 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 01/12] conf: domainlist: Explicitly report failure to load domain config 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 16 Aug 2017 15:00:15 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" When dropping a domain report which one was dropped so that it's not necessary to rummage through the logs. --- src/conf/virdomainobjlist.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/conf/virdomainobjlist.c b/src/conf/virdomainobjlist.c index d874133a7..a8b3f4124 100644 --- a/src/conf/virdomainobjlist.c +++ b/src/conf/virdomainobjlist.c @@ -605,6 +605,8 @@ virDomainObjListLoadAllConfigs(virDomainObjListPtr doms, if (!liveStatus) dom->persistent =3D 1; virObjectUnlock(dom); + } else { + VIR_ERROR(_("Failed to load config for domain '%s'"), entry->d= _name); } } --=20 2.14.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 02:52:59 2024 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 1502895606603468.88575959943864; Wed, 16 Aug 2017 08:00:06 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6BC98788B9; Wed, 16 Aug 2017 15:00:04 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 463DB7DFD2; Wed, 16 Aug 2017 15:00: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 6C0AC1800C8A; Wed, 16 Aug 2017 15:00:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7GEw0QF007960 for ; Wed, 16 Aug 2017 10:58:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id A13516FA89; Wed, 16 Aug 2017 14:58:00 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id D57746FA9E; Wed, 16 Aug 2017 14:57:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6BC98788B9 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 16 Aug 2017 16:57:51 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 02/12] conf: Add 'basic' post parse callback 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 16 Aug 2017 15:00:05 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add yet another post parse callback, which is executed prior the real one without @parseOpaque. This is meant to set basics before @parseOpaque (in case of the qemu driver qemuCaps) can be allocated. This callback will allow to optimize passing of custom parseOpaque through the callbacks. --- src/conf/domain_conf.c | 9 +++++++++ src/conf/domain_conf.h | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 281dc68f0..7c5e6b95a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4825,6 +4825,15 @@ virDomainDefPostParse(virDomainDefPtr def, .parseOpaque =3D parseOpaque, }; + /* call the basic post parse callback */ + if (xmlopt->config.domainPostParseBasicCallback) { + ret =3D xmlopt->config.domainPostParseBasicCallback(def, caps, + xmlopt->config.p= riv); + + if (ret < 0) + return ret; + } + /* this must be done before the hypervisor-specific callback, * in case presence of a controller at a specific index is checked */ diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index f857f509e..4daf024ea 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2497,6 +2497,15 @@ typedef enum { typedef struct _virDomainXMLOption virDomainXMLOption; typedef virDomainXMLOption *virDomainXMLOptionPtr; + +/* Called after everything else has been parsed, for adjusting basics. + * This has similar semantics to virDomainDefPostParseCallback, but no + * parseOpaque is used used. This callback is run prior to + * virDomainDefPostParseCallback. */ +typedef int (*virDomainDefPostParseBasicCallback)(virDomainDefPtr def, + virCapsPtr caps, + void *opaque); + /* Called once after everything else has been parsed, for adjusting * overall domain defaults. * @parseOpaque is opaque data passed by virDomainDefParse* caller, @@ -2546,6 +2555,7 @@ typedef struct _virDomainDefParserConfig virDomainDef= ParserConfig; typedef virDomainDefParserConfig *virDomainDefParserConfigPtr; struct _virDomainDefParserConfig { /* driver domain definition callbacks */ + virDomainDefPostParseBasicCallback domainPostParseBasicCallback; virDomainDefPostParseCallback domainPostParseCallback; virDomainDeviceDefPostParseCallback devicesPostParseCallback; virDomainDefAssignAddressesCallback assignAddressesCallback; --=20 2.14.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 02:52:59 2024 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 150289557434037.04056873332638; Wed, 16 Aug 2017 07:59:34 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8A779C057FAF; Wed, 16 Aug 2017 14:59:32 +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 6910A7E39D; Wed, 16 Aug 2017 14:59:32 +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 31B493FAD0; Wed, 16 Aug 2017 14:59:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7GEw1Fu007974 for ; Wed, 16 Aug 2017 10:58:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id BA0736FA89; Wed, 16 Aug 2017 14:58:01 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 160EC6FA8D; Wed, 16 Aug 2017 14:58:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8A779C057FAF Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 16 Aug 2017 16:57:52 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 03/12] qemu: Move assignment of default emulator to the basic post parse callback 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 16 Aug 2017 14:59:33 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" --- src/qemu/qemu_domain.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 40608554c..9e395aec9 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2924,9 +2924,23 @@ qemuDomainDefVerifyFeatures(const virDomainDef *def) } +static int +qemuDomainDefPostParseBasic(virDomainDefPtr def, + virCapsPtr caps, + void *opaque ATTRIBUTE_UNUSED) +{ + /* check for emulator and create a default one if needed */ + if (!def->emulator && + !(def->emulator =3D virDomainDefGetDefaultEmulator(def, caps))) + return -1; + + return 0; +} + + static int qemuDomainDefPostParse(virDomainDefPtr def, - virCapsPtr caps, + virCapsPtr caps ATTRIBUTE_UNUSED, unsigned int parseFlags, void *opaque, void *parseOpaque) @@ -2957,11 +2971,6 @@ qemuDomainDefPostParse(virDomainDefPtr def, goto cleanup; } - /* check for emulator and create a default one if needed */ - if (!def->emulator && - !(def->emulator =3D virDomainDefGetDefaultEmulator(def, caps))) - goto cleanup; - if (qemuCaps) { virObjectRef(qemuCaps); } else { @@ -3716,6 +3725,7 @@ qemuDomainDefAssignAddresses(virDomainDef *def, virDomainDefParserConfig virQEMUDriverDomainDefParserConfig =3D { + .domainPostParseBasicCallback =3D qemuDomainDefPostParseBasic, .devicesPostParseCallback =3D qemuDomainDeviceDefPostParse, .domainPostParseCallback =3D qemuDomainDefPostParse, .assignAddressesCallback =3D qemuDomainDefAssignAddresses, --=20 2.14.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 02:52:59 2024 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 1502895577530865.6793466111062; Wed, 16 Aug 2017 07:59:37 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1FD877975B; Wed, 16 Aug 2017 14:59:35 +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 EFA776EE25; Wed, 16 Aug 2017 14:59:34 +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 B84963FAD4; Wed, 16 Aug 2017 14:59:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7GEw3qW007989 for ; Wed, 16 Aug 2017 10:58:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1B0066EE34; Wed, 16 Aug 2017 14:58:03 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 582E66FA9E; Wed, 16 Aug 2017 14:58:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1FD877975B Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 16 Aug 2017 16:57:53 +0200 Message-Id: <5791dbf066ae10466db7b74ecbd18cf343c0ab65.1502895317.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 04/12] conf: Add callbacks that allocate per-def private data 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 16 Aug 2017 14:59:35 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Some drivers use def-specific private data across callbacks (e.g. qemuCaps in the qemu driver). Currently it's mostly allocated in every single callback. This is rather wasteful, given that every single call to the device callback allocates it. The new callback will allocate the data (if not provided externally) and then use it for the VM, address and device post parse callbacks. --- src/conf/domain_conf.c | 63 ++++++++++++++++++++++++++++++++++++++++++----= ---- src/conf/domain_conf.h | 9 ++++++++ 2 files changed, 62 insertions(+), 10 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7c5e6b95a..298fe9b4e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4672,6 +4672,31 @@ virDomainDeviceDefPostParse(virDomainDeviceDefPtr de= v, return 0; } +static int +virDomainDeviceDefPostParseOne(virDomainDeviceDefPtr dev, + const virDomainDef *def, + virCapsPtr caps, + unsigned int flags, + virDomainXMLOptionPtr xmlopt) +{ + void *parseOpaque =3D NULL; + int ret; + + if (xmlopt->config.domainPostParseDataAlloc) { + if (xmlopt->config.domainPostParseDataAlloc(def, caps, flags, + xmlopt->config.priv, + &parseOpaque) < 0) + return -1; + } + + ret =3D virDomainDeviceDefPostParse(dev, def, caps, flags, xmlopt, par= seOpaque); + + if (parseOpaque && xmlopt->config.domainPostParseDataFree) + xmlopt->config.domainPostParseDataFree(parseOpaque); + + return ret; +} + struct virDomainDefPostParseDeviceIteratorData { virCapsPtr caps; @@ -4818,6 +4843,7 @@ virDomainDefPostParse(virDomainDefPtr def, void *parseOpaque) { int ret; + bool localParseOpaque =3D false; struct virDomainDefPostParseDeviceIteratorData data =3D { .caps =3D caps, .xmlopt =3D xmlopt, @@ -4834,6 +4860,17 @@ virDomainDefPostParse(virDomainDefPtr def, return ret; } + if (!data.parseOpaque && + xmlopt->config.domainPostParseDataAlloc) { + ret =3D xmlopt->config.domainPostParseDataAlloc(def, caps, parseFl= ags, + xmlopt->config.priv, + &data.parseOpaque); + + if (ret < 0) + return ret; + localParseOpaque =3D true; + } + /* this must be done before the hypervisor-specific callback, * in case presence of a controller at a specific index is checked */ @@ -4843,9 +4880,9 @@ virDomainDefPostParse(virDomainDefPtr def, if (xmlopt->config.domainPostParseCallback) { ret =3D xmlopt->config.domainPostParseCallback(def, caps, parseFla= gs, xmlopt->config.priv, - parseOpaque); + data.parseOpaque); if (ret < 0) - return ret; + goto cleanup; } /* iterate the devices */ @@ -4853,24 +4890,30 @@ virDomainDefPostParse(virDomainDefPtr def, virDomainDefPostParseDev= iceIterator, true, &data)) < 0) - return ret; + goto cleanup; if ((ret =3D virDomainDefPostParseInternal(def, &data)) < 0) - return ret; + goto cleanup; if (xmlopt->config.assignAddressesCallback) { ret =3D xmlopt->config.assignAddressesCallback(def, caps, parseFla= gs, xmlopt->config.priv, - parseOpaque); + data.parseOpaque); if (ret < 0) - return ret; + goto cleanup; } - if (virDomainDefPostParseCheckFeatures(def, xmlopt) < 0) - return -1; + if ((ret =3D virDomainDefPostParseCheckFeatures(def, xmlopt)) < 0) + goto cleanup; - return 0; + ret =3D 0; + + cleanup: + if (localParseOpaque && xmlopt->config.domainPostParseDataFree) + xmlopt->config.domainPostParseDataFree(data.parseOpaque); + + return ret; } @@ -14653,7 +14696,7 @@ virDomainDeviceDefParse(const char *xmlStr, } /* callback to fill driver specific device aspects */ - if (virDomainDeviceDefPostParse(dev, def, caps, flags, xmlopt, NULL) <= 0) + if (virDomainDeviceDefPostParseOne(dev, def, caps, flags, xmlopt) < 0) goto error; /* validate the configuration */ diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 4daf024ea..be7298137 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2538,6 +2538,13 @@ typedef int (*virDomainDefAssignAddressesCallback)(v= irDomainDef *def, void *opaque, void *parseOpaque); +typedef int (*virDomainDefPostParseDataAlloc)(const virDomainDef *def, + virCapsPtr caps, + unsigned int parseFlags, + void *opaque, + void **parseOpaque); +typedef void (*virDomainDefPostParseDataFree)(void *parseOpaque); + /* Called in appropriate places where the domain conf parser can return fa= ilure * for configurations that were previously accepted. This shall not modify= the * config. */ @@ -2556,9 +2563,11 @@ typedef virDomainDefParserConfig *virDomainDefParser= ConfigPtr; struct _virDomainDefParserConfig { /* driver domain definition callbacks */ virDomainDefPostParseBasicCallback domainPostParseBasicCallback; + virDomainDefPostParseDataAlloc domainPostParseDataAlloc; virDomainDefPostParseCallback domainPostParseCallback; virDomainDeviceDefPostParseCallback devicesPostParseCallback; virDomainDefAssignAddressesCallback assignAddressesCallback; + virDomainDefPostParseDataFree domainPostParseDataFree; /* validation callbacks */ virDomainDefValidateCallback domainValidateCallback; --=20 2.14.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 02:52:59 2024 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 1502895580405795.0245933597648; Wed, 16 Aug 2017 07:59:40 -0700 (PDT) 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 4011B806CA; Wed, 16 Aug 2017 14:59:38 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7E850E9957; Wed, 16 Aug 2017 14:59:37 +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 280BF1800C8A; Wed, 16 Aug 2017 14:59:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7GEw4CW008002 for ; Wed, 16 Aug 2017 10:58:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3C8186FA89; Wed, 16 Aug 2017 14:58:04 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8E6B06FA91; Wed, 16 Aug 2017 14:58:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4011B806CA Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 16 Aug 2017 16:57:54 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 05/12] qemu: domain: Don't re-allocate qemuCaps in post parse callbacks 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.26]); Wed, 16 Aug 2017 14:59:38 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The domain post parse callback, domain address callback and the domain device callback (for every single device) would each grab qemuCaps for the current emulator. This is quite wasteful. Use the new callback to do this just once. --- src/qemu/qemu_domain.c | 54 +++++++++++++++++++++++-----------------------= ---- 1 file changed, 25 insertions(+), 29 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 9e395aec9..dc8041b86 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2971,14 +2971,6 @@ qemuDomainDefPostParse(virDomainDefPtr def, goto cleanup; } - if (qemuCaps) { - virObjectRef(qemuCaps); - } else { - if (!(qemuCaps =3D virQEMUCapsCacheLookup(driver->qemuCapsCache, - def->emulator))) - goto cleanup; - } - if (qemuDomainDefAddDefaultDevices(def, qemuCaps) < 0) goto cleanup; @@ -3004,7 +2996,6 @@ qemuDomainDefPostParse(virDomainDefPtr def, ret =3D 0; cleanup: - virObjectUnref(qemuCaps); virObjectUnref(cfg); return ret; } @@ -3573,13 +3564,6 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr d= ev, virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); int ret =3D -1; - if (qemuCaps) { - virObjectRef(qemuCaps); - } else { - qemuCaps =3D virQEMUCapsCacheLookup(driver->qemuCapsCache, - def->emulator); - } - if (dev->type =3D=3D VIR_DOMAIN_DEVICE_NET && dev->data.net->type !=3D VIR_DOMAIN_NET_TYPE_HOSTDEV && !dev->data.net->model) { @@ -3688,7 +3672,6 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr de= v, ret =3D 0; cleanup: - virObjectUnref(qemuCaps); virObjectUnref(cfg); return ret; } @@ -3703,29 +3686,42 @@ qemuDomainDefAssignAddresses(virDomainDef *def, { virQEMUDriverPtr driver =3D opaque; virQEMUCapsPtr qemuCaps =3D parseOpaque; - int ret =3D -1; bool newDomain =3D parseFlags & VIR_DOMAIN_DEF_PARSE_ABI_UPDATE; - if (qemuCaps) { - virObjectRef(qemuCaps); - } else { - if (!(qemuCaps =3D virQEMUCapsCacheLookup(driver->qemuCapsCache, + return qemuDomainAssignAddresses(def, qemuCaps, driver, NULL, newDomai= n); +} + + +static int +qemuDomainPostParseDataAlloc(const virDomainDef *def, + virCapsPtr caps ATTRIBUTE_UNUSED, + unsigned int parseFlags ATTRIBUTE_UNUSED, + void *opaque, + void **parseOpaque) +{ + virQEMUDriverPtr driver =3D opaque; + + if (!(*parseOpaque =3D virQEMUCapsCacheLookup(driver->qemuCapsCache, def->emulator))) - goto cleanup; - } + return -1; - if (qemuDomainAssignAddresses(def, qemuCaps, driver, NULL, newDomain) = < 0) - goto cleanup; + return 0; +} + + +static void +qemuDomainPostParseDataFree(void *parseOpaque) +{ + virQEMUCapsPtr qemuCaps =3D parseOpaque; - ret =3D 0; - cleanup: virObjectUnref(qemuCaps); - return ret; } virDomainDefParserConfig virQEMUDriverDomainDefParserConfig =3D { .domainPostParseBasicCallback =3D qemuDomainDefPostParseBasic, + .domainPostParseDataAlloc =3D qemuDomainPostParseDataAlloc, + .domainPostParseDataFree =3D qemuDomainPostParseDataFree, .devicesPostParseCallback =3D qemuDomainDeviceDefPostParse, .domainPostParseCallback =3D qemuDomainDefPostParse, .assignAddressesCallback =3D qemuDomainDefAssignAddresses, --=20 2.14.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 02:52:59 2024 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 1502895583070950.4552518688122; Wed, 16 Aug 2017 07:59:43 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F21CC2C85; Wed, 16 Aug 2017 14:59:40 +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 C19B26EE25; Wed, 16 Aug 2017 14:59:40 +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 84ED53FAD4; Wed, 16 Aug 2017 14:59:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7GEw6Ai008013 for ; Wed, 16 Aug 2017 10:58:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5AA5D6EE34; Wed, 16 Aug 2017 14:58:06 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id A3C4E6FA84; Wed, 16 Aug 2017 14:58:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com F21CC2C85 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 16 Aug 2017 16:57:55 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 06/12] conf: Return any non-zero value from virDomainDeviceInfoIterateInternal callback 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 16 Aug 2017 14:59:41 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Post parse callbacks will need to be able to signal that they failed non-fatally. This means that we need to return the value returned by the callback without modification. --- src/conf/domain_conf.c | 93 +++++++++++++++++++++++++---------------------= ---- 1 file changed, 47 insertions(+), 46 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 298fe9b4e..f94317e52 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3570,146 +3570,147 @@ virDomainDeviceInfoIterateInternal(virDomainDefPt= r def, void *opaque) { size_t i; + int ret; virDomainDeviceDef device; device.type =3D VIR_DOMAIN_DEVICE_DISK; for (i =3D 0; i < def->ndisks; i++) { device.data.disk =3D def->disks[i]; - if (cb(def, &device, &def->disks[i]->info, opaque) < 0) - return -1; + if ((ret =3D cb(def, &device, &def->disks[i]->info, opaque)) !=3D = 0) + return ret; } device.type =3D VIR_DOMAIN_DEVICE_NET; for (i =3D 0; i < def->nnets; i++) { device.data.net =3D def->nets[i]; - if (cb(def, &device, &def->nets[i]->info, opaque) < 0) - return -1; + if ((ret =3D cb(def, &device, &def->nets[i]->info, opaque)) !=3D 0) + return ret; } device.type =3D VIR_DOMAIN_DEVICE_SOUND; for (i =3D 0; i < def->nsounds; i++) { device.data.sound =3D def->sounds[i]; - if (cb(def, &device, &def->sounds[i]->info, opaque) < 0) - return -1; + if ((ret =3D cb(def, &device, &def->sounds[i]->info, opaque)) !=3D= 0) + return ret; } device.type =3D VIR_DOMAIN_DEVICE_HOSTDEV; for (i =3D 0; i < def->nhostdevs; i++) { device.data.hostdev =3D def->hostdevs[i]; - if (cb(def, &device, def->hostdevs[i]->info, opaque) < 0) - return -1; + if ((ret =3D cb(def, &device, def->hostdevs[i]->info, opaque)) != =3D 0) + return ret; } device.type =3D VIR_DOMAIN_DEVICE_VIDEO; for (i =3D 0; i < def->nvideos; i++) { device.data.video =3D def->videos[i]; - if (cb(def, &device, &def->videos[i]->info, opaque) < 0) - return -1; + if ((ret =3D cb(def, &device, &def->videos[i]->info, opaque)) !=3D= 0) + return ret; } device.type =3D VIR_DOMAIN_DEVICE_CONTROLLER; for (i =3D 0; i < def->ncontrollers; i++) { device.data.controller =3D def->controllers[i]; - if (cb(def, &device, &def->controllers[i]->info, opaque) < 0) - return -1; + if ((ret =3D cb(def, &device, &def->controllers[i]->info, opaque))= !=3D 0) + return ret; } device.type =3D VIR_DOMAIN_DEVICE_SMARTCARD; for (i =3D 0; i < def->nsmartcards; i++) { device.data.smartcard =3D def->smartcards[i]; - if (cb(def, &device, &def->smartcards[i]->info, opaque) < 0) - return -1; + if ((ret =3D cb(def, &device, &def->smartcards[i]->info, opaque)) = !=3D 0) + return ret; } device.type =3D VIR_DOMAIN_DEVICE_CHR; for (i =3D 0; i < def->nserials; i++) { device.data.chr =3D def->serials[i]; - if (cb(def, &device, &def->serials[i]->info, opaque) < 0) - return -1; + if ((ret =3D cb(def, &device, &def->serials[i]->info, opaque)) != =3D 0) + return ret; } for (i =3D 0; i < def->nparallels; i++) { device.data.chr =3D def->parallels[i]; - if (cb(def, &device, &def->parallels[i]->info, opaque) < 0) - return -1; + if ((ret =3D cb(def, &device, &def->parallels[i]->info, opaque)) != =3D 0) + return ret; } for (i =3D 0; i < def->nchannels; i++) { device.data.chr =3D def->channels[i]; - if (cb(def, &device, &def->channels[i]->info, opaque) < 0) - return -1; + if ((ret =3D cb(def, &device, &def->channels[i]->info, opaque)) != =3D 0) + return ret; } for (i =3D 0; i < def->nconsoles; i++) { if (virDomainSkipBackcompatConsole(def, i, all)) continue; device.data.chr =3D def->consoles[i]; - if (cb(def, &device, &def->consoles[i]->info, opaque) < 0) - return -1; + if ((ret =3D cb(def, &device, &def->consoles[i]->info, opaque)) != =3D 0) + return ret; } device.type =3D VIR_DOMAIN_DEVICE_INPUT; for (i =3D 0; i < def->ninputs; i++) { device.data.input =3D def->inputs[i]; - if (cb(def, &device, &def->inputs[i]->info, opaque) < 0) - return -1; + if ((ret =3D cb(def, &device, &def->inputs[i]->info, opaque)) !=3D= 0) + return ret; } device.type =3D VIR_DOMAIN_DEVICE_FS; for (i =3D 0; i < def->nfss; i++) { device.data.fs =3D def->fss[i]; - if (cb(def, &device, &def->fss[i]->info, opaque) < 0) - return -1; + if ((ret =3D cb(def, &device, &def->fss[i]->info, opaque)) !=3D 0) + return ret; } if (def->watchdog) { device.type =3D VIR_DOMAIN_DEVICE_WATCHDOG; device.data.watchdog =3D def->watchdog; - if (cb(def, &device, &def->watchdog->info, opaque) < 0) - return -1; + if ((ret =3D cb(def, &device, &def->watchdog->info, opaque)) !=3D = 0) + return ret; } if (def->memballoon) { device.type =3D VIR_DOMAIN_DEVICE_MEMBALLOON; device.data.memballoon =3D def->memballoon; - if (cb(def, &device, &def->memballoon->info, opaque) < 0) - return -1; + if ((ret =3D cb(def, &device, &def->memballoon->info, opaque)) != =3D 0) + return ret; } device.type =3D VIR_DOMAIN_DEVICE_RNG; for (i =3D 0; i < def->nrngs; i++) { device.data.rng =3D def->rngs[i]; - if (cb(def, &device, &def->rngs[i]->info, opaque) < 0) - return -1; + if ((ret =3D cb(def, &device, &def->rngs[i]->info, opaque)) !=3D 0) + return ret; } if (def->nvram) { device.type =3D VIR_DOMAIN_DEVICE_NVRAM; device.data.nvram =3D def->nvram; - if (cb(def, &device, &def->nvram->info, opaque) < 0) - return -1; + if ((ret =3D cb(def, &device, &def->nvram->info, opaque)) !=3D 0) + return ret; } device.type =3D VIR_DOMAIN_DEVICE_HUB; for (i =3D 0; i < def->nhubs; i++) { device.data.hub =3D def->hubs[i]; - if (cb(def, &device, &def->hubs[i]->info, opaque) < 0) - return -1; + if ((ret =3D cb(def, &device, &def->hubs[i]->info, opaque)) !=3D 0) + return ret; } device.type =3D VIR_DOMAIN_DEVICE_SHMEM; for (i =3D 0; i < def->nshmems; i++) { device.data.shmem =3D def->shmems[i]; - if (cb(def, &device, &def->shmems[i]->info, opaque) < 0) - return -1; + if ((ret =3D cb(def, &device, &def->shmems[i]->info, opaque)) !=3D= 0) + return ret; } if (def->tpm) { device.type =3D VIR_DOMAIN_DEVICE_TPM; device.data.tpm =3D def->tpm; - if (cb(def, &device, &def->tpm->info, opaque) < 0) - return -1; + if ((ret =3D cb(def, &device, &def->tpm->info, opaque)) !=3D 0) + return ret; } device.type =3D VIR_DOMAIN_DEVICE_PANIC; for (i =3D 0; i < def->npanics; i++) { device.data.panic =3D def->panics[i]; - if (cb(def, &device, &def->panics[i]->info, opaque) < 0) - return -1; + if ((ret =3D cb(def, &device, &def->panics[i]->info, opaque)) !=3D= 0) + return ret; } device.type =3D VIR_DOMAIN_DEVICE_MEMORY; for (i =3D 0; i < def->nmems; i++) { device.data.memory =3D def->mems[i]; - if (cb(def, &device, &def->mems[i]->info, opaque) < 0) - return -1; + if ((ret =3D cb(def, &device, &def->mems[i]->info, opaque)) !=3D 0) + return ret; } device.type =3D VIR_DOMAIN_DEVICE_REDIRDEV; for (i =3D 0; i < def->nredirdevs; i++) { device.data.redirdev =3D def->redirdevs[i]; - if (cb(def, &device, &def->redirdevs[i]->info, opaque) < 0) - return -1; + if ((ret =3D cb(def, &device, &def->redirdevs[i]->info, opaque)) != =3D 0) + return ret; } /* Coverity is not very happy with this - all dead_error_condition */ --=20 2.14.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 02:52:59 2024 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 150289562441428.11455922767516; Wed, 16 Aug 2017 08:00:24 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8F773272AF; Wed, 16 Aug 2017 15:00:22 +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 69B3C7DFC9; Wed, 16 Aug 2017 15:00:22 +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 1F2584EBDD; Wed, 16 Aug 2017 15:00:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7GEw7Vd008029 for ; Wed, 16 Aug 2017 10:58:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id 555796EE39; Wed, 16 Aug 2017 14:58:07 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id AA4A16FA8B; Wed, 16 Aug 2017 14:58:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8F773272AF Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 16 Aug 2017 16:57:56 +0200 Message-Id: <6533d9c2277191c968348729230c00de4d571a9d.1502895317.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 07/12] conf: add infrastructure for tolerating certain post parse callback failures 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 16 Aug 2017 15:00:23 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Some failures of the post parse callback can be tolerated. This is specifically desired when loading the configs of existing VMs. In such case the post parse callback should not really be modifying anything in the definition. This patch adds a parse flag VIR_DOMAIN_DEF_PARSE_ALLOW_POST_PARSE_FAIL which will allow the callbacks to report non-fatal failures by returning a positive return value. In such case the field 'postParseFailed' in the domain definition is set to true, to notify the drivers that the callback failed and possibly needs to be re-run. --- src/conf/domain_conf.c | 47 +++++++++++++++++++++++++++++++++--------= ---- src/conf/domain_conf.h | 16 ++++++++++++++- src/conf/virdomainobjlist.c | 6 ++++-- 3 files changed, 54 insertions(+), 15 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f94317e52..fdac9a443 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4836,6 +4836,23 @@ virDomainDefPostParseInternal(virDomainDefPtr def, } +static int +virDomainDefPostParseCheckFailure(virDomainDefPtr def, + unsigned int parseFlags, + int ret) +{ + if (ret <=3D 0) + return ret; + + if (!(parseFlags & VIR_DOMAIN_DEF_PARSE_ALLOW_POST_PARSE_FAIL)) + return -1; + + virResetLastError(); + def->postParseFailed =3D true; + return 0; +} + + int virDomainDefPostParse(virDomainDefPtr def, virCapsPtr caps, @@ -4843,7 +4860,7 @@ virDomainDefPostParse(virDomainDefPtr def, virDomainXMLOptionPtr xmlopt, void *parseOpaque) { - int ret; + int ret =3D -1; bool localParseOpaque =3D false; struct virDomainDefPostParseDeviceIteratorData data =3D { .caps =3D caps, @@ -4852,13 +4869,15 @@ virDomainDefPostParse(virDomainDefPtr def, .parseOpaque =3D parseOpaque, }; + def->postParseFailed =3D false; + /* call the basic post parse callback */ if (xmlopt->config.domainPostParseBasicCallback) { ret =3D xmlopt->config.domainPostParseBasicCallback(def, caps, xmlopt->config.p= riv); - if (ret < 0) - return ret; + if (virDomainDefPostParseCheckFailure(def, parseFlags, ret) < 0) + goto cleanup; } if (!data.parseOpaque && @@ -4867,8 +4886,8 @@ virDomainDefPostParse(virDomainDefPtr def, xmlopt->config.priv, &data.parseOpaque); - if (ret < 0) - return ret; + if (virDomainDefPostParseCheckFailure(def, parseFlags, ret) < 0) + goto cleanup; localParseOpaque =3D true; } @@ -4882,17 +4901,18 @@ virDomainDefPostParse(virDomainDefPtr def, ret =3D xmlopt->config.domainPostParseCallback(def, caps, parseFla= gs, xmlopt->config.priv, data.parseOpaque); - if (ret < 0) + if (virDomainDefPostParseCheckFailure(def, parseFlags, ret) < 0) goto cleanup; } /* iterate the devices */ - if ((ret =3D virDomainDeviceInfoIterateInternal(def, - virDomainDefPostParseDev= iceIterator, - true, - &data)) < 0) - goto cleanup; + ret =3D virDomainDeviceInfoIterateInternal(def, + virDomainDefPostParseDeviceIt= erator, + true, + &data); + if (virDomainDefPostParseCheckFailure(def, parseFlags, ret) < 0) + goto cleanup; if ((ret =3D virDomainDefPostParseInternal(def, &data)) < 0) goto cleanup; @@ -4901,7 +4921,7 @@ virDomainDefPostParse(virDomainDefPtr def, ret =3D xmlopt->config.assignAddressesCallback(def, caps, parseFla= gs, xmlopt->config.priv, data.parseOpaque); - if (ret < 0) + if (virDomainDefPostParseCheckFailure(def, parseFlags, ret) < 0) goto cleanup; } @@ -4914,6 +4934,9 @@ virDomainDefPostParse(virDomainDefPtr def, if (localParseOpaque && xmlopt->config.domainPostParseDataFree) xmlopt->config.domainPostParseDataFree(data.parseOpaque); + if (ret =3D=3D 1) + ret =3D -1; + return ret; } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index be7298137..13bdd2bc4 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2411,6 +2411,12 @@ struct _virDomainDef { /* Application-specific custom metadata */ xmlNodePtr metadata; + + /* internal fields */ + bool postParseFailed; /* set to true if one of the custom post parse + callbacks failed for a non-critical reason + (was not able to fill in some data) and thus + should be re-run before starting */ }; @@ -2510,7 +2516,10 @@ typedef int (*virDomainDefPostParseBasicCallback)(vi= rDomainDefPtr def, * overall domain defaults. * @parseOpaque is opaque data passed by virDomainDefParse* caller, * @opaque is opaque data set by driver (usually pointer to driver - * private data). */ + * private data). Non-fatal failures should be reported by returning 1. In + * cases when that is allowed, such failure is translated to a success ret= urn + * value and the failure is noted in def->postParseFailed. Drivers should = then + * re-run the post parse callback when attempting to use such definition. = */ typedef int (*virDomainDefPostParseCallback)(virDomainDefPtr def, virCapsPtr caps, unsigned int parseFlags, @@ -2825,6 +2834,11 @@ typedef enum { * that would break ABI otherwise. This should be used only if it's s= afe * to do such change. */ VIR_DOMAIN_DEF_PARSE_ABI_UPDATE_MIGRATION =3D 1 << 12, + /* Allows to ignore certain failures in the post parse callbacks, which + * may happen due to missing packages and can be fixed by re-running t= he + * post parse callbacks before starting. Failure of the post parse cal= lback + * is recorded as def->postParseFail */ + VIR_DOMAIN_DEF_PARSE_ALLOW_POST_PARSE_FAIL =3D 1 << 13, } virDomainDefParseFlags; typedef enum { diff --git a/src/conf/virdomainobjlist.c b/src/conf/virdomainobjlist.c index a8b3f4124..b9f78c572 100644 --- a/src/conf/virdomainobjlist.c +++ b/src/conf/virdomainobjlist.c @@ -465,7 +465,8 @@ virDomainObjListLoadConfig(virDomainObjListPtr doms, if (!(def =3D virDomainDefParseFile(configFile, caps, xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE | VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHE= CKS | - VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE))) + VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE | + VIR_DOMAIN_DEF_PARSE_ALLOW_POST_PARS= E_FAIL))) goto error; if ((autostartLink =3D virDomainConfigFile(autostartDir, name)) =3D=3D= NULL) @@ -516,7 +517,8 @@ virDomainObjListLoadStatus(virDomainObjListPtr doms, VIR_DOMAIN_DEF_PARSE_ACTUAL_NET | VIR_DOMAIN_DEF_PARSE_PCI_ORIG_STATES= | VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHE= CKS | - VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE))) + VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE | + VIR_DOMAIN_DEF_PARSE_ALLOW_POST_PARS= E_FAIL))) goto error; virUUIDFormat(obj->def->uuid, uuidstr); --=20 2.14.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 02:52:59 2024 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 1502895545715991.3582720699624; Wed, 16 Aug 2017 07:59:05 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D9202432B7; Wed, 16 Aug 2017 14:59:03 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B751B7E380; Wed, 16 Aug 2017 14:59:03 +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 72F8D1803B21; Wed, 16 Aug 2017 14:59:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7GEw8jI008050 for ; Wed, 16 Aug 2017 10:58:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id E037A6EE39; Wed, 16 Aug 2017 14:58:08 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 31C7A6FAAC; Wed, 16 Aug 2017 14:58:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D9202432B7 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 16 Aug 2017 16:57:57 +0200 Message-Id: <2d33b6936dd1d5006264bca291f71acaee48f8f8.1502895317.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 08/12] qemu: capabilities: Tolerate missing @qemuCaps in virQEMUCapsGetCanonicalMachine 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 16 Aug 2017 14:59:04 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" If qemuCaps are not present, just return the original machine type name. This will help in situations when qemuCaps is not available in the post parse callback. --- src/qemu/qemu_capabilities.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index e61d2f7b0..f05e7650a 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -2739,15 +2739,21 @@ int virQEMUCapsGetMachineTypesCaps(virQEMUCapsPtr q= emuCaps, } - - +/** + * virQEMUCapsGetCanonicalMachine: + * @qemuCaps: qemu capabilities object + * @name: machine name + * + * Resolves aliased machine names to the actual machine name. If qemuCaps = isn't + * present @name is returned. + */ const char *virQEMUCapsGetCanonicalMachine(virQEMUCapsPtr qemuCaps, const char *name) { size_t i; - if (!name) - return NULL; + if (!name || !qemuCaps) + return name; for (i =3D 0; i < qemuCaps->nmachineTypes; i++) { if (!qemuCaps->machineTypes[i].alias) --=20 2.14.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 02:52:59 2024 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 1502895585155424.2145880302056; Wed, 16 Aug 2017 07:59:45 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 71BF27CDE7; Wed, 16 Aug 2017 14:59:43 +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 503C47D92C; Wed, 16 Aug 2017 14:59:43 +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 1AA0D3FAD7; Wed, 16 Aug 2017 14:59:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7GEw9Si008071 for ; Wed, 16 Aug 2017 10:58:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id E51926FA84; Wed, 16 Aug 2017 14:58:09 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 44D366EE34; Wed, 16 Aug 2017 14:58:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 71BF27CDE7 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 16 Aug 2017 16:57:58 +0200 Message-Id: <016a59a274d986565ff9ad4970cca34885090d6f.1502895317.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 09/12] qemu: capabilities: Tolerate missing @qemuCaps in virQEMUCapsSupportsGICVersion 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 16 Aug 2017 14:59:43 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Report the given GIC version as unsupported if @qemuCapsi is NULL. This will be helpful to run post parse callbacks even if qemu is not currently installed. --- src/qemu/qemu_capabilities.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index f05e7650a..38a9f09f5 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -5676,7 +5676,8 @@ virQEMUCapsFillDomainDeviceHostdevCaps(virQEMUCapsPtr= qemuCaps, * @version: GIC version * * Checks the QEMU binary with capabilities @qemuCaps supports a specific - * GIC version for a domain of type @virtType. + * GIC version for a domain of type @virtType. If @qemuCaps is NULL, the G= IC + * @version is considered unsupported. * * Returns: true if the binary supports the requested GIC version, false * otherwise @@ -5688,6 +5689,9 @@ virQEMUCapsSupportsGICVersion(virQEMUCapsPtr qemuCaps, { size_t i; + if (!qemuCaps) + return false; + for (i =3D 0; i < qemuCaps->ngicCapabilities; i++) { virGICCapabilityPtr cap =3D &(qemuCaps->gicCapabilities[i]); --=20 2.14.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 02:52:59 2024 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 1502895662366435.0249991346293; Wed, 16 Aug 2017 08:01:02 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0535EC047B7C; Wed, 16 Aug 2017 15:01:00 +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 901D4C661B; Wed, 16 Aug 2017 15:00:59 +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 5EB3D62CEE; Wed, 16 Aug 2017 15:00:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7GEwF1h008093 for ; Wed, 16 Aug 2017 10:58:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0B7676FA84; Wed, 16 Aug 2017 14:58:15 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5D9B26EE37; Wed, 16 Aug 2017 14:58:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0535EC047B7C Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 16 Aug 2017 16:57:59 +0200 Message-Id: <56f5247d1d7dbb06ae8d102c82ce45fc21bdf212.1502895317.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 10/12] qemu: domain: Don't return default NIC model if @qemuCaps are missing 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 16 Aug 2017 15:01:00 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Return NULL in qemuDomainDefaultNetModel if qemuCaps is missing and the network card model would be determined by the capabilities. --- src/qemu/qemu_domain.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index dc8041b86..802dd9e39 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3263,6 +3263,15 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef= *dev, } +/** + * qemuDomainDefaultNetModel: + * @def: domain definition + * @qemuCaps: qemu capabilities + * + * Returns the default network model for a given domain. Note that if @qem= uCaps + * is NULL this function may return NULL if the default model depends on t= he + * capabilities. + */ static const char * qemuDomainDefaultNetModel(const virDomainDef *def, virQEMUCapsPtr qemuCaps) @@ -3283,6 +3292,11 @@ qemuDomainDefaultNetModel(const virDomainDef *def, return "lan9118"; } + /* In all other cases the model depends on the capabilities. If they w= ere + * not provided don't report any default. */ + if (!qemuCaps) + return NULL; + /* Try several network devices in turn; each of these devices is * less likely be supported out-of-the-box by the guest operating * system than the previous one */ --=20 2.14.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 02:52:59 2024 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 1502895601582612.8946703535438; Wed, 16 Aug 2017 08:00:01 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6783D7C850; Wed, 16 Aug 2017 14:59:59 +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 47AD37DFC9; Wed, 16 Aug 2017 14:59:59 +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 AB9A53FAED; Wed, 16 Aug 2017 14:59:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7GEwGde008098 for ; Wed, 16 Aug 2017 10:58:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2471A6FA9F; Wed, 16 Aug 2017 14:58:16 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 57D436EE34; Wed, 16 Aug 2017 14:58:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6783D7C850 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 16 Aug 2017 16:58:00 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 11/12] qemu: domain: Don't set default USB model if qemuCaps is missing 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 16 Aug 2017 15:00:00 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" qemuDomainControllerDefPostParse assigns the default USB controller model when it was not specified by the user. Skip this step if @qemuCaps is missing so that we don't fill wrong data. This will then be fixes by re-running the post parse callback. --- src/qemu/qemu_domain.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 802dd9e39..e28b373a9 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3438,9 +3438,10 @@ qemuDomainControllerDefPostParse(virDomainController= DefPtr cont, break; case VIR_DOMAIN_CONTROLLER_TYPE_USB: - if (cont->model =3D=3D -1) { + if (cont->model =3D=3D -1 && qemuCaps) { /* Pick a suitable default model for the USB controller if none - * has been selected by the user. + * has been selected by the user and we have the qemuCaps for + * figuring out which contollers are supported. * * We rely on device availability instead of setting the model * unconditionally because, for some machine types, there's a --=20 2.14.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 02:52:59 2024 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 1502895667320172.03695823223995; Wed, 16 Aug 2017 08:01:07 -0700 (PDT) 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 5D3F090E4F; Wed, 16 Aug 2017 15:01:05 +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 0BAADE9940; Wed, 16 Aug 2017 15:01:05 +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 6DC1C62CF3; Wed, 16 Aug 2017 15:00:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7GEwH8j008108 for ; Wed, 16 Aug 2017 10:58:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1B42D6EE37; Wed, 16 Aug 2017 14:58:17 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6FC8B6EE34; Wed, 16 Aug 2017 14:58:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5D3F090E4F Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 16 Aug 2017 16:58:01 +0200 Message-Id: <24719798b6463389678655c177f3f908e0b689e1.1502895317.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 12/12] qemu: Implement postParse callback skipping on config reload 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.26]); Wed, 16 Aug 2017 15:01:06 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Use the new facility which allows to ignore failures in post parse callbacks if they are not fatal so that VM configs are not lost if the emulator binary is missing. If qemuCaps can't be populated on daemon restart skip certain portions of the post parse callbacks during config reload and re-run the callback during VM startup. This fixes VMs vanishing if the emulator binary was broken or uninstalled and libvirtd was restarted. --- src/qemu/qemu_domain.c | 20 ++++++++++++++++++-- src/qemu/qemu_process.c | 9 +++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index e28b373a9..e2531cdcf 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2932,7 +2932,7 @@ qemuDomainDefPostParseBasic(virDomainDefPtr def, /* check for emulator and create a default one if needed */ if (!def->emulator && !(def->emulator =3D virDomainDefGetDefaultEmulator(def, caps))) - return -1; + return 1; return 0; } @@ -2947,6 +2947,9 @@ qemuDomainDefPostParse(virDomainDefPtr def, { virQEMUDriverPtr driver =3D opaque; virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); + /* Note that qemuCaps may be NULL when this function is called. This + * function shall not fail in that case. It will be re-run on VM start= up + * with the capabilities populated. */ virQEMUCapsPtr qemuCaps =3D parseOpaque; int ret =3D -1; @@ -3575,6 +3578,9 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr de= v, void *parseOpaque) { virQEMUDriverPtr driver =3D opaque; + /* Note that qemuCaps may be NULL when this function is called. This + * function shall not fail in that case. It will be re-run on VM start= up + * with the capabilities populated. */ virQEMUCapsPtr qemuCaps =3D parseOpaque; virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); int ret =3D -1; @@ -3700,9 +3706,19 @@ qemuDomainDefAssignAddresses(virDomainDef *def, void *parseOpaque) { virQEMUDriverPtr driver =3D opaque; + /* Note that qemuCaps may be NULL when this function is called. This + * function shall not fail in that case. It will be re-run on VM start= up + * with the capabilities populated. */ virQEMUCapsPtr qemuCaps =3D parseOpaque; bool newDomain =3D parseFlags & VIR_DOMAIN_DEF_PARSE_ABI_UPDATE; + /* Skip address assignment if @qemuCaps is not present. In such case d= evices + * which are automatically added may be missing. Additionally @qemuCap= s should + * only be missing when reloading configs, thus addresses were already + * assigned. */ + if (!qemuCaps) + return 1; + return qemuDomainAssignAddresses(def, qemuCaps, driver, NULL, newDomai= n); } @@ -3718,7 +3734,7 @@ qemuDomainPostParseDataAlloc(const virDomainDef *def, if (!(*parseOpaque =3D virQEMUCapsCacheLookup(driver->qemuCapsCache, def->emulator))) - return -1; + return 1; return 0; } diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index fed2bc588..589d0ed2c 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4691,6 +4691,15 @@ qemuProcessInit(virQEMUDriverPtr driver, if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) goto cleanup; + /* in case when the post parse callback failed we need to re-run it on= the + * old config prior we start the VM */ + if (vm->def->postParseFailed) { + VIR_DEBUG("re-running the post parse callback"); + + if (virDomainDefPostParse(vm->def, caps, 0, driver->xmlopt, NULL) = < 0) + goto cleanup; + } + VIR_DEBUG("Determining emulator version"); virObjectUnref(priv->qemuCaps); if (!(priv->qemuCaps =3D virQEMUCapsCacheLookupCopy(driver->qemuCapsCa= che, --=20 2.14.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list