From nobody Sat Apr 27 16:23:32 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15210995869851017.2946477438252; Thu, 15 Mar 2018 00:39:46 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2554E7D0DE; Thu, 15 Mar 2018 07:39:42 +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 6D10860C1B; Thu, 15 Mar 2018 07:39:41 +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 383425BBB3; Thu, 15 Mar 2018 07:39:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2EBPL8p028738 for ; Wed, 14 Mar 2018 07:25:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id 52700AFD42; Wed, 14 Mar 2018 11:25:21 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3025D1DB23 for ; Wed, 14 Mar 2018 11:25:19 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 0BA85100213; Wed, 14 Mar 2018 12:25:18 +0100 (CET) From: Jiri Denemark To: libvir-list@redhat.com Date: Wed, 14 Mar 2018 12:25:13 +0100 Message-Id: <06f80c630b62e15f0fd07c8475969e6faddd4053.1521026651.git.jdenemar@redhat.com> In-Reply-To: References: In-Reply-To: References: Mail-Followup-To: libvir-list@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/2] qemu: Parse all job related private XML in dedicated function 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 15 Mar 2018 07:39:42 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Commit dc567cc22b introduced qemuDomainObjPrivateXMLParseJob, but forgot to move "./job[1]/@type" parsing into it. Signed-off-by: Jiri Denemark --- src/qemu/qemu_domain.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 2d108bec1b..a08a1825e9 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2337,6 +2337,18 @@ qemuDomainObjPrivateXMLParseJob(virDomainObjPtr vm, int n; int ret =3D -1; =20 + if ((tmp =3D virXPathString("string(./job[1]/@type)", ctxt))) { + int type; + + if ((type =3D qemuDomainJobTypeFromString(tmp)) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unknown job type %s"), tmp); + goto cleanup; + } + VIR_FREE(tmp); + priv->job.active =3D type; + } + if ((tmp =3D virXPathString("string(./job[1]/@async)", ctxt))) { int async; =20 @@ -2502,19 +2514,6 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, =20 priv->lockState =3D virXPathString("string(./lockstate)", ctxt); =20 - if ((tmp =3D virXPathString("string(./job[1]/@type)", ctxt))) { - int type; - - if ((type =3D qemuDomainJobTypeFromString(tmp)) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unknown job type %s"), tmp); - VIR_FREE(tmp); - goto error; - } - VIR_FREE(tmp); - priv->job.active =3D type; - } - if (qemuDomainObjPrivateXMLParseJob(vm, priv, ctxt) < 0) goto error; =20 --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 16:23:32 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1521099627805314.37770122863856; Thu, 15 Mar 2018 00:40:27 -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 8A01843A44; Thu, 15 Mar 2018 07:40:26 +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 5AA1761781; Thu, 15 Mar 2018 07:40:26 +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 1D9DE181D0BC; Thu, 15 Mar 2018 07:40:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2EBPLMM028737 for ; Wed, 14 Mar 2018 07:25:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id 49F901142373; Wed, 14 Mar 2018 11:25:21 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 289251142372 for ; Wed, 14 Mar 2018 11:25:19 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 0D6F910B995; Wed, 14 Mar 2018 12:25:18 +0100 (CET) From: Jiri Denemark To: libvir-list@redhat.com Date: Wed, 14 Mar 2018 12:25:14 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: Mail-Followup-To: libvir-list@redhat.com X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/2] qemu: Switch context for job related private XML parsing 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.30]); Thu, 15 Mar 2018 07:40:26 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Having to repeat "./job[1]/" XPath prefix for every single element or attribute we want to parse is suboptimal. And even more so once we further extract code from qemuDomainObjPrivateXMLParseJob into separate functions. Signed-off-by: Jiri Denemark --- src/qemu/qemu_domain.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index a08a1825e9..570ad4ea8f 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2332,12 +2332,18 @@ qemuDomainObjPrivateXMLParseJob(virDomainObjPtr vm, xmlXPathContextPtr ctxt) { xmlNodePtr *nodes =3D NULL; + xmlNodePtr node =3D ctxt->node; char *tmp =3D NULL; size_t i; int n; int ret =3D -1; =20 - if ((tmp =3D virXPathString("string(./job[1]/@type)", ctxt))) { + if (!(ctxt->node =3D virXPathNode("./job[1]", ctxt))) { + ret =3D 0; + goto cleanup; + } + + if ((tmp =3D virXPathString("string(@type)", ctxt))) { int type; =20 if ((type =3D qemuDomainJobTypeFromString(tmp)) < 0) { @@ -2349,7 +2355,7 @@ qemuDomainObjPrivateXMLParseJob(virDomainObjPtr vm, priv->job.active =3D type; } =20 - if ((tmp =3D virXPathString("string(./job[1]/@async)", ctxt))) { + if ((tmp =3D virXPathString("string(@async)", ctxt))) { int async; =20 if ((async =3D qemuDomainAsyncJobTypeFromString(tmp)) < 0) { @@ -2360,7 +2366,7 @@ qemuDomainObjPrivateXMLParseJob(virDomainObjPtr vm, VIR_FREE(tmp); priv->job.asyncJob =3D async; =20 - if ((tmp =3D virXPathString("string(./job[1]/@phase)", ctxt))) { + if ((tmp =3D virXPathString("string(@phase)", ctxt))) { priv->job.phase =3D qemuDomainAsyncJobPhaseFromString(async, t= mp); if (priv->job.phase < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -2371,7 +2377,7 @@ qemuDomainObjPrivateXMLParseJob(virDomainObjPtr vm, } } =20 - if ((n =3D virXPathNodeSet("./job[1]/disk[@migrating=3D'yes']", ctxt, = &nodes)) < 0) + if ((n =3D virXPathNodeSet("./disk[@migrating=3D'yes']", ctxt, &nodes)= ) < 0) goto cleanup; =20 if (n > 0) { @@ -2394,6 +2400,7 @@ qemuDomainObjPrivateXMLParseJob(virDomainObjPtr vm, ret =3D 0; =20 cleanup: + ctxt->node =3D node; VIR_FREE(tmp); VIR_FREE(nodes); return ret; --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list