From nobody Sun May 5 14:45:13 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 1519927234367417.5298435959014; Thu, 1 Mar 2018 10:00:34 -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 452EA83F43; Thu, 1 Mar 2018 18:00: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 E5167620A8; Thu, 1 Mar 2018 18:00:31 +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 25A2041F67; Thu, 1 Mar 2018 18:00:31 +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 w21I0UWk016936 for ; Thu, 1 Mar 2018 13:00:30 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0A59D200A3A9; Thu, 1 Mar 2018 18:00:30 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 897662026E04; Thu, 1 Mar 2018 18:00:29 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 1 Mar 2018 18:59:42 +0100 Message-Id: <8a3f094361f42534ece8ee6f3b3e0193563f515c.1519927146.git.pkrempa@redhat.com> 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 1/6] qemu: Add qemu functions for storage source private data handling 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.27]); Thu, 01 Mar 2018 18:00:32 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The qemu driver registered the helpers from util code, but it will be necessary to format also some qemu-specific data. Signed-off-by: Peter Krempa Reviewed-by: John Ferlan --- src/qemu/qemu_domain.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 8b4efc82de..dabc78e6bf 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2530,6 +2530,28 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, } +static int +qemuStorageSourcePrivateDataParse(xmlXPathContextPtr ctxt, + virStorageSourcePtr src) +{ + if (virStorageSourcePrivateDataParseRelPath(ctxt, src) < 0) + return -1; + + return 0; +} + + +static int +qemuStorageSourcePrivateDataFormat(virStorageSourcePtr src, + virBufferPtr buf) +{ + if (virStorageSourcePrivateDataFormatRelPath(src, buf) < 0) + return -1; + + return 0; +} + + virDomainXMLPrivateDataCallbacks virQEMUDriverPrivateDataCallbacks =3D { .alloc =3D qemuDomainObjPrivateAlloc, .free =3D qemuDomainObjPrivateFree, @@ -2538,8 +2560,8 @@ virDomainXMLPrivateDataCallbacks virQEMUDriverPrivate= DataCallbacks =3D { .chrSourceNew =3D qemuDomainChrSourcePrivateNew, .parse =3D qemuDomainObjPrivateXMLParse, .format =3D qemuDomainObjPrivateXMLFormat, - .storageParse =3D virStorageSourcePrivateDataParseRelPath, - .storageFormat =3D virStorageSourcePrivateDataFormatRelPath, + .storageParse =3D qemuStorageSourcePrivateDataParse, + .storageFormat =3D qemuStorageSourcePrivateDataFormat, }; --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 14:45:13 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 1519927247554518.1549333395616; Thu, 1 Mar 2018 10:00:47 -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 6C22A3DFCD; Thu, 1 Mar 2018 18:00:45 +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 1CE1260BE3; Thu, 1 Mar 2018 18:00:45 +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 CBA5041F72; Thu, 1 Mar 2018 18:00:44 +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 w21I0UEO016969 for ; Thu, 1 Mar 2018 13:00:31 -0500 Received: by smtp.corp.redhat.com (Postfix) id B9C0E2024CA8; Thu, 1 Mar 2018 18:00:30 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 43FB42024CA6; Thu, 1 Mar 2018 18:00:30 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 1 Mar 2018 18:59:43 +0100 Message-Id: <0e9177dc52227a768663e557d505f4f713b0fd62.1519927146.git.pkrempa@redhat.com> 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 2/6] qemu: domain: Split out formating of Job data from private data formatter 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.29]); Thu, 01 Mar 2018 18:00:46 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Separate the code for later refactoring Signed-off-by: Peter Krempa Reviewed-by: John Ferlan --- src/qemu/qemu_domain.c | 84 ++++++++++++++++++++++++++++------------------= ---- 1 file changed, 47 insertions(+), 37 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index dabc78e6bf..2db736fbed 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2035,13 +2035,58 @@ qemuDomainObjPrivateXMLFormatAllowReboot(virBufferP= tr buf, } +static void +qemuDomainObjPrivateXMLFormatJob(virBufferPtr buf, + virDomainObjPtr vm, + qemuDomainObjPrivatePtr priv) +{ + qemuDomainJob job; + + job =3D priv->job.active; + if (!qemuDomainTrackJob(job)) + priv->job.active =3D QEMU_JOB_NONE; + + if (priv->job.active || priv->job.asyncJob) { + virBufferAsprintf(buf, "job.active), + qemuDomainAsyncJobTypeToString(priv->job.asyncJo= b)); + if (priv->job.phase) { + virBufferAsprintf(buf, " phase=3D'%s'", + qemuDomainAsyncJobPhaseToString( + priv->job.asyncJob, priv->job.phase)); + } + if (priv->job.asyncJob !=3D QEMU_ASYNC_JOB_MIGRATION_OUT) { + virBufferAddLit(buf, "/>\n"); + } else { + size_t i; + virDomainDiskDefPtr disk; + qemuDomainDiskPrivatePtr diskPriv; + + virBufferAddLit(buf, ">\n"); + virBufferAdjustIndent(buf, 2); + + for (i =3D 0; i < vm->def->ndisks; i++) { + disk =3D vm->def->disks[i]; + diskPriv =3D QEMU_DOMAIN_DISK_PRIVATE(disk); + virBufferAsprintf(buf, "\n", + disk->dst, + diskPriv->migrating ? "yes" : "no"); + } + + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + } + } + priv->job.active =3D job; +} + + static int qemuDomainObjPrivateXMLFormat(virBufferPtr buf, virDomainObjPtr vm) { qemuDomainObjPrivatePtr priv =3D vm->privateData; const char *monitorpath; - qemuDomainJob job; /* priv->monitor_chr is set only for qemu */ if (priv->monConfig) { @@ -2092,42 +2137,7 @@ qemuDomainObjPrivateXMLFormat(virBufferPtr buf, if (priv->lockState) virBufferAsprintf(buf, "%s\n", priv->lockSt= ate); - job =3D priv->job.active; - if (!qemuDomainTrackJob(job)) - priv->job.active =3D QEMU_JOB_NONE; - - if (priv->job.active || priv->job.asyncJob) { - virBufferAsprintf(buf, "job.active), - qemuDomainAsyncJobTypeToString(priv->job.asyncJo= b)); - if (priv->job.phase) { - virBufferAsprintf(buf, " phase=3D'%s'", - qemuDomainAsyncJobPhaseToString( - priv->job.asyncJob, priv->job.phase)); - } - if (priv->job.asyncJob !=3D QEMU_ASYNC_JOB_MIGRATION_OUT) { - virBufferAddLit(buf, "/>\n"); - } else { - size_t i; - virDomainDiskDefPtr disk; - qemuDomainDiskPrivatePtr diskPriv; - - virBufferAddLit(buf, ">\n"); - virBufferAdjustIndent(buf, 2); - - for (i =3D 0; i < vm->def->ndisks; i++) { - disk =3D vm->def->disks[i]; - diskPriv =3D QEMU_DOMAIN_DISK_PRIVATE(disk); - virBufferAsprintf(buf, "\n", - disk->dst, - diskPriv->migrating ? "yes" : "no"); - } - - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); - } - } - priv->job.active =3D job; + qemuDomainObjPrivateXMLFormatJob(buf, vm, priv); if (priv->fakeReboot) virBufferAddLit(buf, "\n"); --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 14:45:13 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 1519927236578415.0246024158263; Thu, 1 Mar 2018 10:00:36 -0800 (PST) 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 BC8427FDD5; Thu, 1 Mar 2018 18:00:34 +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 722065F708; Thu, 1 Mar 2018 18:00: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 18C5241F69; Thu, 1 Mar 2018 18:00:33 +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 w21I0V39016980 for ; Thu, 1 Mar 2018 13:00:31 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7402B2026E04; Thu, 1 Mar 2018 18:00:31 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id F37D32024CA6; Thu, 1 Mar 2018 18:00:30 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 1 Mar 2018 18:59:44 +0100 Message-Id: <54d1569e545a32edce5a332cba9055f5d16b1c42.1519927146.git.pkrempa@redhat.com> 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 3/6] qemu: domain: Don't overwrite job type in 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.16 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:00:35 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The code overwrote the internal job type and then fixed it back. Since the job type is not accessed in the code this does not make much sense. Use the temporary value instead. Signed-off-by: Peter Krempa Reviewed-by: John Ferlan --- src/qemu/qemu_domain.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 2db736fbed..e5b494fa2a 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2040,15 +2040,14 @@ qemuDomainObjPrivateXMLFormatJob(virBufferPtr buf, virDomainObjPtr vm, qemuDomainObjPrivatePtr priv) { - qemuDomainJob job; + qemuDomainJob job =3D priv->job.active; - job =3D priv->job.active; if (!qemuDomainTrackJob(job)) - priv->job.active =3D QEMU_JOB_NONE; + job =3D QEMU_JOB_NONE; - if (priv->job.active || priv->job.asyncJob) { + if (job || priv->job.asyncJob) { virBufferAsprintf(buf, "job.active), + qemuDomainJobTypeToString(job), qemuDomainAsyncJobTypeToString(priv->job.asyncJo= b)); if (priv->job.phase) { virBufferAsprintf(buf, " phase=3D'%s'", @@ -2077,7 +2076,6 @@ qemuDomainObjPrivateXMLFormatJob(virBufferPtr buf, virBufferAddLit(buf, "\n"); } } - priv->job.active =3D job; } --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 14:45:13 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 1519927254426152.23175524142687; Thu, 1 Mar 2018 10:00:54 -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 5C81F80474; Thu, 1 Mar 2018 18:00:52 +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 324AB620BA; Thu, 1 Mar 2018 18:00:52 +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 EA058183390F; Thu, 1 Mar 2018 18:00:51 +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 w21I0WGA016987 for ; Thu, 1 Mar 2018 13:00:32 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2F2FD2024CA8; Thu, 1 Mar 2018 18:00:32 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id ADAD12024CA6; Thu, 1 Mar 2018 18:00:31 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 1 Mar 2018 18:59:45 +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 4/6] qemu: domain: Return early in qemuDomainObjPrivateXMLFormatJob 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.28]); Thu, 01 Mar 2018 18:00:52 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Remove one level of nesting by returing early. Signed-off-by: Peter Krempa Reviewed-by: John Ferlan --- src/qemu/qemu_domain.c | 54 ++++++++++++++++++++++++++--------------------= ---- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index e5b494fa2a..b7fb9f264d 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2045,36 +2045,38 @@ qemuDomainObjPrivateXMLFormatJob(virBufferPtr buf, if (!qemuDomainTrackJob(job)) job =3D QEMU_JOB_NONE; - if (job || priv->job.asyncJob) { - virBufferAsprintf(buf, "job.asyncJo= b)); - if (priv->job.phase) { - virBufferAsprintf(buf, " phase=3D'%s'", - qemuDomainAsyncJobPhaseToString( - priv->job.asyncJob, priv->job.phase)); - } - if (priv->job.asyncJob !=3D QEMU_ASYNC_JOB_MIGRATION_OUT) { - virBufferAddLit(buf, "/>\n"); - } else { - size_t i; - virDomainDiskDefPtr disk; - qemuDomainDiskPrivatePtr diskPriv; + if (job =3D=3D QEMU_JOB_NONE && + priv->job.asyncJob =3D=3D QEMU_ASYNC_JOB_NONE) + return; - virBufferAddLit(buf, ">\n"); - virBufferAdjustIndent(buf, 2); + virBufferAsprintf(buf, "job.asyncJob)); + if (priv->job.phase) { + virBufferAsprintf(buf, " phase=3D'%s'", + qemuDomainAsyncJobPhaseToString(priv->job.asyncJ= ob, + priv->job.phase)= ); + } + if (priv->job.asyncJob !=3D QEMU_ASYNC_JOB_MIGRATION_OUT) { + virBufferAddLit(buf, "/>\n"); + } else { + size_t i; + virDomainDiskDefPtr disk; + qemuDomainDiskPrivatePtr diskPriv; - for (i =3D 0; i < vm->def->ndisks; i++) { - disk =3D vm->def->disks[i]; - diskPriv =3D QEMU_DOMAIN_DISK_PRIVATE(disk); - virBufferAsprintf(buf, "\n", - disk->dst, - diskPriv->migrating ? "yes" : "no"); - } + virBufferAddLit(buf, ">\n"); + virBufferAdjustIndent(buf, 2); - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); + for (i =3D 0; i < vm->def->ndisks; i++) { + disk =3D vm->def->disks[i]; + diskPriv =3D QEMU_DOMAIN_DISK_PRIVATE(disk); + virBufferAsprintf(buf, "\n", + disk->dst, + diskPriv->migrating ? "yes" : "no"); } + + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); } } --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 14:45:13 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 1519927265308532.9338750804894; Thu, 1 Mar 2018 10:01:05 -0800 (PST) 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 45A145AFD9; Thu, 1 Mar 2018 18:01:03 +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 0C0A95F70A; Thu, 1 Mar 2018 18:01: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 C3FC141F72; Thu, 1 Mar 2018 18:01:02 +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 w21I0XPc017003 for ; Thu, 1 Mar 2018 13:00:33 -0500 Received: by smtp.corp.redhat.com (Postfix) id DE0FD2026609; Thu, 1 Mar 2018 18:00:32 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 690CE2026E04; Thu, 1 Mar 2018 18:00:32 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 1 Mar 2018 18:59:46 +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 5/6] qemu: domain: Use virXMLFormatElement in qemuDomainObjPrivateXMLFormatJob 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.39]); Thu, 01 Mar 2018 18:01:03 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Modernize the code by using the clever formatter rather than checking manually when to format the end of the element. Signed-off-by: Peter Krempa Reviewed-by: John Ferlan --- src/qemu/qemu_domain.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index b7fb9f264d..e4088665ee 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2035,11 +2035,13 @@ qemuDomainObjPrivateXMLFormatAllowReboot(virBufferP= tr buf, } -static void +static int qemuDomainObjPrivateXMLFormatJob(virBufferPtr buf, virDomainObjPtr vm, qemuDomainObjPrivatePtr priv) { + virBuffer attrBuf =3D VIR_BUFFER_INITIALIZER; + virBuffer childBuf =3D VIR_BUFFER_INITIALIZER; qemuDomainJob job =3D priv->job.active; if (!qemuDomainTrackJob(job)) @@ -2047,37 +2049,34 @@ qemuDomainObjPrivateXMLFormatJob(virBufferPtr buf, if (job =3D=3D QEMU_JOB_NONE && priv->job.asyncJob =3D=3D QEMU_ASYNC_JOB_NONE) - return; + return 0; + + virBufferSetChildIndent(&childBuf, buf); - virBufferAsprintf(buf, "job.asyncJob)); + if (priv->job.phase) { - virBufferAsprintf(buf, " phase=3D'%s'", + virBufferAsprintf(&attrBuf, " phase=3D'%s'", qemuDomainAsyncJobPhaseToString(priv->job.asyncJ= ob, priv->job.phase)= ); } - if (priv->job.asyncJob !=3D QEMU_ASYNC_JOB_MIGRATION_OUT) { - virBufferAddLit(buf, "/>\n"); - } else { + + if (priv->job.asyncJob =3D=3D QEMU_ASYNC_JOB_MIGRATION_OUT) { size_t i; virDomainDiskDefPtr disk; qemuDomainDiskPrivatePtr diskPriv; - virBufferAddLit(buf, ">\n"); - virBufferAdjustIndent(buf, 2); - for (i =3D 0; i < vm->def->ndisks; i++) { disk =3D vm->def->disks[i]; diskPriv =3D QEMU_DOMAIN_DISK_PRIVATE(disk); - virBufferAsprintf(buf, "\n", - disk->dst, - diskPriv->migrating ? "yes" : "no"); + virBufferAsprintf(&childBuf, "\n", + disk->dst, diskPriv->migrating ? "yes" : "no= "); } - - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); } + + return virXMLFormatElement(buf, "job", &attrBuf, &childBuf); } @@ -2137,7 +2136,8 @@ qemuDomainObjPrivateXMLFormat(virBufferPtr buf, if (priv->lockState) virBufferAsprintf(buf, "%s\n", priv->lockSt= ate); - qemuDomainObjPrivateXMLFormatJob(buf, vm, priv); + if (qemuDomainObjPrivateXMLFormatJob(buf, vm, priv) < 0) + return -1; if (priv->fakeReboot) virBufferAddLit(buf, "\n"); --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 14:45:13 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 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 Reviewed-by: John Ferlan --- 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