From nobody Thu May 15 00:16:52 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; 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 1519927272797153.95074683788846; Thu, 1 Mar 2018 10:01:12 -0800 (PST) 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 3107A7FDD1; Thu, 1 Mar 2018 18:01:11 +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 0C35360BEB; Thu, 1 Mar 2018 18:01:11 +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 CBABF41F7C; Thu, 1 Mar 2018 18:01:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w21I0XCT017010 for ; Thu, 1 Mar 2018 13:00:33 -0500 Received: by smtp.corp.redhat.com (Postfix) id 991412024CAC; Thu, 1 Mar 2018 18:00:33 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 241A62024CA6; Thu, 1 Mar 2018 18:00:33 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 1 Mar 2018 18:59:47 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 6/6] qemu: domain: Extract parsing of job-related private XML 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]); Thu, 01 Mar 2018 18:01:11 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Similarly to the formatter extract the parser code. Signed-off-by: Peter Krempa --- src/qemu/qemu_domain.c | 108 ++++++++++++++++++++++++++++-----------------= ---- 1 file changed, 63 insertions(+), 45 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index e4088665ee..a6521d5f94 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2304,6 +2304,68 @@ qemuDomainObjPrivateXMLParseAllowReboot(xmlXPathCont= extPtr ctxt, } +static int +qemuDomainObjPrivateXMLParseJob(virDomainObjPtr vm, + qemuDomainObjPrivatePtr priv, + xmlXPathContextPtr ctxt) +{ + xmlNodePtr *nodes =3D NULL; + char *tmp =3D NULL; + size_t i; + int n; + int ret =3D -1; + + if ((tmp =3D virXPathString("string(./job[1]/@async)", ctxt))) { + int async; + + if ((async =3D qemuDomainAsyncJobTypeFromString(tmp)) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unknown async job type %s"), tmp); + goto cleanup; + } + VIR_FREE(tmp); + priv->job.asyncJob =3D async; + + if ((tmp =3D virXPathString("string(./job[1]/@phase)", ctxt))) { + priv->job.phase =3D qemuDomainAsyncJobPhaseFromString(async, t= mp); + if (priv->job.phase < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unknown job phase %s"), tmp); + goto cleanup; + } + VIR_FREE(tmp); + } + } + + if ((n =3D virXPathNodeSet("./job[1]/disk[@migrating=3D'yes']", ctxt, = &nodes)) < 0) + goto cleanup; + + if (n > 0) { + if (priv->job.asyncJob !=3D QEMU_ASYNC_JOB_MIGRATION_OUT) { + VIR_WARN("Found disks marked for migration but we were not " + "migrating"); + n =3D 0; + } + for (i =3D 0; i < n; i++) { + char *dst =3D virXMLPropString(nodes[i], "dev"); + virDomainDiskDefPtr disk; + + if (dst && (disk =3D virDomainDiskByName(vm->def, dst, false))) + QEMU_DOMAIN_DISK_PRIVATE(disk)->migrating =3D true; + VIR_FREE(dst); + } + } + VIR_FREE(nodes); + + ret =3D 0; + + cleanup: + VIR_FREE(tmp); + VIR_FREE(nodes); + return ret; +} + + static int qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, virDomainObjPtr vm, @@ -2431,52 +2493,8 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, priv->job.active =3D type; } - if ((tmp =3D virXPathString("string(./job[1]/@async)", ctxt))) { - int async; - - if ((async =3D qemuDomainAsyncJobTypeFromString(tmp)) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unknown async job type %s"), tmp); - VIR_FREE(tmp); - goto error; - } - VIR_FREE(tmp); - priv->job.asyncJob =3D async; - - if ((tmp =3D virXPathString("string(./job[1]/@phase)", ctxt))) { - priv->job.phase =3D qemuDomainAsyncJobPhaseFromString(async, t= mp); - if (priv->job.phase < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unknown job phase %s"), tmp); - VIR_FREE(tmp); - goto error; - } - VIR_FREE(tmp); - } - } - - if ((n =3D virXPathNodeSet("./job[1]/disk[@migrating=3D'yes']", - ctxt, &nodes)) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("failed to parse list of disks marked for migrati= on")); + if (qemuDomainObjPrivateXMLParseJob(vm, priv, ctxt) < 0) goto error; - } - if (n > 0) { - if (priv->job.asyncJob !=3D QEMU_ASYNC_JOB_MIGRATION_OUT) { - VIR_WARN("Found disks marked for migration but we were not " - "migrating"); - n =3D 0; - } - for (i =3D 0; i < n; i++) { - char *dst =3D virXMLPropString(nodes[i], "dev"); - virDomainDiskDefPtr disk; - - if (dst && (disk =3D virDomainDiskByName(vm->def, dst, false))) - QEMU_DOMAIN_DISK_PRIVATE(disk)->migrating =3D true; - VIR_FREE(dst); - } - } - VIR_FREE(nodes); priv->fakeReboot =3D virXPathBoolean("boolean(./fakereboot)", ctxt) = =3D=3D 1; --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list