From nobody Fri May 17 07:07:57 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 1531927339097130.61449198995592; Wed, 18 Jul 2018 08:22:19 -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 D168581112; Wed, 18 Jul 2018 15:22: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 66BEE60851; Wed, 18 Jul 2018 15:22:15 +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 96D9D24F61; Wed, 18 Jul 2018 15:22:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6IFMC8O001244 for ; Wed, 18 Jul 2018 11:22:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id B6C082156897; Wed, 18 Jul 2018 15:22:12 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 55BD82156893 for ; Wed, 18 Jul 2018 15:22:12 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 18 Jul 2018 17:22:02 +0200 Message-Id: <9e56bda4e723a3de825b0e7ceb43e8d9e97a7063.1531927224.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/9] qemu: driver: Reuse qemuDomainBlocksStatsGather in qemuDomainGetBlockInfo 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.28]); Wed, 18 Jul 2018 15:22:18 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Allow updating capacity for the block devices returned by qemuDomainBlocksStatsGather and replace the open-coded call to qemuMonitorGetAllBlockStatsInfo by the helper. Signed-off-by: Peter Krempa Reviewed-by: J=EF=BF=BDn Tomko --- src/qemu/qemu_driver.c | 41 ++++++++++++----------------------------- 1 file changed, 12 insertions(+), 29 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 847dab2edc..4f2855a26b 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -11063,6 +11063,7 @@ qemuDomainBlockStatsGatherTotals(void *payload, * @driver: driver object * @vm: domain object * @path: to gather the statistics for + * @capacity: refresh capacity of the backing image * @retstats: returns pointer to structure holding the stats * * Gathers the block statistics for use in qemuDomainBlockStats* APIs. @@ -11073,6 +11074,7 @@ static int qemuDomainBlocksStatsGather(virQEMUDriverPtr driver, virDomainObjPtr vm, const char *path, + bool capacity, qemuBlockStatsPtr *retstats) { qemuDomainObjPrivatePtr priv =3D vm->privateData; @@ -11101,6 +11103,11 @@ qemuDomainBlocksStatsGather(virQEMUDriverPtr drive= r, qemuDomainObjEnterMonitor(driver, vm); nstats =3D qemuMonitorGetAllBlockStatsInfo(priv->mon, &blockstats, fal= se); + + if (capacity && nstats >=3D 0 && + qemuMonitorBlockStatsUpdateCapacity(priv->mon, blockstats, false) = < 0) + nstats =3D -1; + if (qemuDomainObjExitMonitor(driver, vm) < 0 || nstats < 0) goto cleanup; @@ -11154,7 +11161,7 @@ qemuDomainBlockStats(virDomainPtr dom, if (virDomainObjCheckActive(vm) < 0) goto endjob; - if (qemuDomainBlocksStatsGather(driver, vm, path, &blockstats) < 0) + if (qemuDomainBlocksStatsGather(driver, vm, path, false, &blockstats) = < 0) goto endjob; stats->rd_req =3D blockstats->rd_req; @@ -11208,7 +11215,7 @@ qemuDomainBlockStatsFlags(virDomainPtr dom, if (virDomainObjCheckActive(vm) < 0) goto endjob; - if ((nstats =3D qemuDomainBlocksStatsGather(driver, vm, path, + if ((nstats =3D qemuDomainBlocksStatsGather(driver, vm, path, false, &blockstats)) < 0) goto endjob; @@ -12021,10 +12028,7 @@ qemuDomainGetBlockInfo(virDomainPtr dom, int ret =3D -1; virDomainDiskDefPtr disk; virQEMUDriverConfigPtr cfg =3D NULL; - int rc; - virHashTablePtr stats =3D NULL; - qemuBlockStats *entry; - char *alias =3D NULL; + qemuBlockStatsPtr entry =3D NULL; virCheckFlags(0, -1); @@ -12065,28 +12069,8 @@ qemuDomainGetBlockInfo(virDomainPtr dom, goto endjob; } - if (!disk->info.alias || - !(alias =3D qemuDomainStorageAlias(disk->info.alias, 0))) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("missing disk device alias name for %s"), disk->d= st); + if (qemuDomainBlocksStatsGather(driver, vm, path, true, &entry) < 0) goto endjob; - } - - qemuDomainObjEnterMonitor(driver, vm); - rc =3D qemuMonitorGetAllBlockStatsInfo(qemuDomainGetMonitor(vm), - &stats, false); - if (rc >=3D 0) - rc =3D qemuMonitorBlockStatsUpdateCapacity(qemuDomainGetMonitor(vm= ), - stats, false); - - if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) - goto endjob; - - if (!(entry =3D virHashLookup(stats, alias))) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("failed to gather stats for disk '%s'"), disk->ds= t); - goto endjob; - } if (!entry->wr_highest_offset_valid) { info->allocation =3D entry->physical; @@ -12131,8 +12115,7 @@ qemuDomainGetBlockInfo(virDomainPtr dom, endjob: qemuDomainObjEndJob(driver, vm); cleanup: - VIR_FREE(alias); - virHashFree(stats); + VIR_FREE(entry); virDomainObjEndAPI(&vm); virObjectUnref(cfg); return ret; --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 17 07:07:57 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 1531927349505533.7475021362143; Wed, 18 Jul 2018 08:22:29 -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 926BBC049D40; Wed, 18 Jul 2018 15:22: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 F06B45C20D; Wed, 18 Jul 2018 15:22:25 +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 504FD18037F1; Wed, 18 Jul 2018 15:22:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6IFMDqo001249 for ; Wed, 18 Jul 2018 11:22:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id 649BB2156897; Wed, 18 Jul 2018 15:22:13 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 04D112156893 for ; Wed, 18 Jul 2018 15:22:12 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 18 Jul 2018 17:22:03 +0200 Message-Id: <3e6fe20eb4579fc90a6cc72337eac1c8724f7679.1531927224.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/9] qemu: domain: Move out clearing of backing chain in qemuDomainDetermineDiskChain 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, 18 Jul 2018 15:22:28 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In some cases backing chain needs to be cleared prior to re-detection. Move this step out of qemuDomainDetermineDiskChain as only certain places need it and the function itself is able to skip to the end of the chain to perform detection. Signed-off-by: Peter Krempa Reviewed-by: J=EF=BF=BDn Tomko --- src/qemu/qemu_blockjob.c | 4 ++-- src/qemu/qemu_domain.c | 4 ---- src/qemu/qemu_domain.h | 1 - src/qemu/qemu_driver.c | 4 ++-- src/qemu/qemu_hotplug.c | 2 +- src/qemu/qemu_process.c | 7 +++++-- 6 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index b08e047490..0f52996ade 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -175,8 +175,8 @@ qemuBlockJobEventProcess(virQEMUDriverPtr driver, disk->mirrorState =3D VIR_DOMAIN_DISK_MIRROR_STATE_NONE; disk->mirrorJob =3D VIR_DOMAIN_BLOCK_JOB_TYPE_UNKNOWN; disk->src->id =3D 0; - ignore_value(qemuDomainDetermineDiskChain(driver, vm, disk, - true, true)); + virStorageSourceBackingStoreClear(disk->src); + ignore_value(qemuDomainDetermineDiskChain(driver, vm, disk, true)); ignore_value(qemuBlockNodeNamesDetect(driver, vm, asyncJob)); diskPriv->blockjob =3D false; break; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index ed76495309..c92ac8c926 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8352,7 +8352,6 @@ int qemuDomainDetermineDiskChain(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainDiskDefPtr disk, - bool force_probe, bool report_broken) { virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); @@ -8368,9 +8367,6 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver, goto cleanup; } - if (force_probe) - virStorageSourceBackingStoreClear(src); - /* There is no need to check the backing chain for disks without backi= ng * support */ if (virStorageSourceIsLocalStorage(src) && diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index e748d78adb..1692fa9838 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -718,7 +718,6 @@ int qemuDomainCheckDiskPresence(virQEMUDriverPtr driver, int qemuDomainDetermineDiskChain(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainDiskDefPtr disk, - bool force_probe, bool report_broken); bool qemuDomainDiskSourceDiffers(virDomainDiskDefPtr disk, diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 4f2855a26b..64e2c274c2 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7850,7 +7850,7 @@ qemuDomainChangeDiskLive(virDomainObjPtr vm, if (virDomainDiskTranslateSourcePool(disk) < 0) goto cleanup; - if (qemuDomainDetermineDiskChain(driver, vm, disk, false, true) < 0) + if (qemuDomainDetermineDiskChain(driver, vm, disk, true) < 0) goto cleanup; if (!(orig_disk =3D virDomainDiskFindByBusAndDst(vm->def, @@ -16931,7 +16931,7 @@ qemuDomainBlockPivot(virQEMUDriverPtr driver, oldsrc =3D disk->src; disk->src =3D disk->mirror; - if (qemuDomainDetermineDiskChain(driver, vm, disk, false, true) < = 0) + if (qemuDomainDetermineDiskChain(driver, vm, disk, true) < 0) goto cleanup; if (disk->mirror->format && diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 2b6633a998..98f7a28826 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -669,7 +669,7 @@ qemuDomainAttachDeviceDiskLive(virQEMUDriverPtr driver, if (qemuSetUnprivSGIO(dev) < 0) goto cleanup; - if (qemuDomainDetermineDiskChain(driver, vm, disk, false, true) < 0) + if (qemuDomainDetermineDiskChain(driver, vm, disk, true) < 0) goto cleanup; switch ((virDomainDiskDevice) disk->device) { diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index c903a8e5c8..138e128807 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6015,7 +6015,9 @@ qemuProcessPrepareHostStorage(virQEMUDriverPtr driver, if (virStorageSourceIsEmpty(disk->src)) continue; - if (qemuDomainDetermineDiskChain(driver, vm, disk, true, true) >= =3D 0) + virStorageSourceBackingStoreClear(disk->src); + + if (qemuDomainDetermineDiskChain(driver, vm, disk, true) >=3D 0) continue; if (qemuDomainCheckDiskStartupPolicy(driver, vm, idx, cold_boot) >= =3D 0) @@ -7691,7 +7693,8 @@ qemuProcessReconnect(void *opaque) /* This should be the only place that calls * qemuDomainDetermineDiskChain with @report_broken =3D=3D fal= se * to guarantee best-effort domain reconnect */ - if (qemuDomainDetermineDiskChain(driver, obj, disk, true, fals= e) < 0) + virStorageSourceBackingStoreClear(disk->src); + if (qemuDomainDetermineDiskChain(driver, obj, disk, false) < 0) goto error; } else { VIR_DEBUG("skipping backing chain detection for '%s'", disk->d= st); --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 17 07:07:57 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 1531927350554367.6229197580527; Wed, 18 Jul 2018 08:22:30 -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 459623081258; Wed, 18 Jul 2018 15:22:27 +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 C4AAB5C8A0; Wed, 18 Jul 2018 15:22: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 F338624F62; Wed, 18 Jul 2018 15:22:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6IFMECY001254 for ; Wed, 18 Jul 2018 11:22:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1AE312156897; Wed, 18 Jul 2018 15:22:14 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id AF49B2156893 for ; Wed, 18 Jul 2018 15:22:13 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 18 Jul 2018 17:22:04 +0200 Message-Id: <68d393170f18e1508297232c644668b99ccf8677.1531927224.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/9] qemu: domain: Add helper for getting the disk backend alias 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.49]); Wed, 18 Jul 2018 15:22:29 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The disk backend alias was historically the alias of the -drive backing the storage. For setups with -blockdev this will become more complex as it will depend on other configs and generally will differ. Reviewed-by: J=EF=BF=BDn Tomko --- src/qemu/qemu_domain.c | 28 ++++++++++++++++++++++++++++ src/qemu/qemu_domain.h | 6 ++++++ 2 files changed, 34 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index c92ac8c926..f8a621a5c9 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8449,6 +8449,34 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver, } +/** + * qemuDomainDiskGetBackendAlias: + * @disk: disk definition + * @qemuCaps: emulator capabilities + * @backendAlias: filled with the alias of the disk storage backend + * + * Returns the correct alias for the disk backend. This may be the alias of + * -drive for legacy setup or the correct node name for -blockdev setups. + * + * @backendAlias may be NULL on success if the backend does not exist + * (disk is empty). Caller is responsible for freeing @backendAlias. + * + * Returns 0 on success, -1 on error with libvirt error reported. + */ +int +qemuDomainDiskGetBackendAlias(virDomainDiskDefPtr disk, + virQEMUCapsPtr qemuCaps ATTRIBUTE_UNUSED, + char **backendAlias) +{ + *backendAlias =3D NULL; + + if (!(*backendAlias =3D qemuAliasDiskDriveFromDisk(disk))) + return -1; + + return 0; +} + + /** * qemuDomainDiskChainElementRevoke: * diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 1692fa9838..22c3a51354 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -732,6 +732,12 @@ int qemuDomainStorageFileInit(virQEMUDriverPtr driver, virStorageSourcePtr parent); char *qemuDomainStorageAlias(const char *device, int depth); +int qemuDomainDiskGetBackendAlias(virDomainDiskDefPtr disk, + virQEMUCapsPtr qemuCaps, + char **backendAlias) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) + ATTRIBUTE_NONNULL(3) ATTRIBUTE_RETURN_CHECK; + void qemuDomainDiskChainElementRevoke(virQEMUDriverPtr driver, virDomainObjPtr vm, virStorageSourcePtr elem); --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 17 07:07:57 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 1531927356487919.4449111043868; Wed, 18 Jul 2018 08:22:36 -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 D4F1730832F4; Wed, 18 Jul 2018 15:22:34 +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 7151E60FA6; Wed, 18 Jul 2018 15:22: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 F123A18037F5; Wed, 18 Jul 2018 15:22:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6IFME7i001262 for ; Wed, 18 Jul 2018 11:22:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id C75932156897; Wed, 18 Jul 2018 15:22:14 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 677AC2156893 for ; Wed, 18 Jul 2018 15:22:14 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 18 Jul 2018 17:22:05 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/9] qemu: command: use qemuDomainDiskGetBackendAlias in commandline building 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.44]); Wed, 18 Jul 2018 15:22:35 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Use the proper backend for the block device both when using -drive and when using -blockdev for disk drives and floppy disks. Signed-off-by: Peter Krempa Reviewed-by: J=EF=BF=BDn Tomko --- src/qemu/qemu_command.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 44ae8dcef7..6e550cf951 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1818,7 +1818,7 @@ qemuBuildDiskDeviceStr(const virDomainDef *def, virBuffer opt =3D VIR_BUFFER_INITIALIZER; const char *bus =3D virDomainDiskQEMUBusTypeToString(disk->bus); const char *contAlias; - char *drivealias; + char *backendAlias =3D NULL; int controllerModel; if (qemuCheckDiskConfig(disk, qemuCaps) < 0) @@ -2077,10 +2077,14 @@ qemuBuildDiskDeviceStr(const virDomainDef *def, virQEMUCapsGet(qemuCaps, QEMU_CAPS_DISK_SHARE_RW)) virBufferAddLit(&opt, ",share-rw=3Don"); - if (!(drivealias =3D qemuAliasDiskDriveFromDisk(disk))) + if (qemuDomainDiskGetBackendAlias(disk, qemuCaps, &backendAlias) < 0) goto error; - virBufferAsprintf(&opt, ",drive=3D%s,id=3D%s", drivealias, disk->info.= alias); - VIR_FREE(drivealias); + + if (backendAlias) + virBufferAsprintf(&opt, ",drive=3D%s", backendAlias); + VIR_FREE(backendAlias); + + virBufferAsprintf(&opt, ",id=3D%s", disk->info.alias); if (bootindex && virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX)) virBufferAsprintf(&opt, ",bootindex=3D%u", bootindex); if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKIO)) { @@ -2139,6 +2143,7 @@ qemuBuildDiskDeviceStr(const virDomainDef *def, return virBufferContentAndReset(&opt); error: + VIR_FREE(backendAlias); virBufferFreeAndReset(&opt); return NULL; } @@ -2148,8 +2153,8 @@ static int qemuBuildFloppyCommandLineOptions(virCommandPtr cmd, const virDomainDef *def, virDomainDiskDefPtr disk, + virQEMUCapsPtr qemuCaps, unsigned int bootindex) - { virBuffer fdc_opts =3D VIR_BUFFER_INITIALIZER; char driveLetter; @@ -2163,10 +2168,11 @@ qemuBuildFloppyCommandLineOptions(virCommandPtr cmd, else driveLetter =3D 'A'; - if (!(backendAlias =3D qemuAliasDiskDriveFromDisk(disk))) - return -1; + if (qemuDomainDiskGetBackendAlias(disk, qemuCaps, &backendAlias) < 0) + goto cleanup; - if (virAsprintf(&backendStr, "drive%c=3D%s", driveLetter, backendAlias= ) < 0) + if (backendAlias && + virAsprintf(&backendStr, "drive%c=3D%s", driveLetter, backendAlias= ) < 0) goto cleanup; if (bootindex && @@ -2281,7 +2287,7 @@ qemuBuildDiskCommandLine(virCommandPtr cmd, if (!qemuDiskBusNeedsDriveArg(disk->bus)) { if (disk->bus =3D=3D VIR_DOMAIN_DISK_BUS_FDC) { - if (qemuBuildFloppyCommandLineOptions(cmd, def, disk, + if (qemuBuildFloppyCommandLineOptions(cmd, def, disk, qemuCaps, bootindex) < 0) return -1; } else { --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 17 07:07:57 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 1531927368375573.9577551508627; Wed, 18 Jul 2018 08:22:48 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9F3D53001745; Wed, 18 Jul 2018 15:22:42 +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 5D2983001A50; Wed, 18 Jul 2018 15:22:42 +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 77A6C18037F6; Wed, 18 Jul 2018 15:22:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6IFMFJ1001272 for ; Wed, 18 Jul 2018 11:22:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id 81CDC2156897; Wed, 18 Jul 2018 15:22:15 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 220582156893 for ; Wed, 18 Jul 2018 15:22:14 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 18 Jul 2018 17:22:06 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 5/9] qemu: monitor: Add the 'query-nodes' argument for query-blockstats 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.84 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Wed, 18 Jul 2018 15:22:43 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The 'query-blockstats' command does not return statistics for the explicitly named nodes unless the new argument is specified. Add infrastrucuture that will allow us to use the new approach if desired. Signed-off-by: Peter Krempa Reviewed-by: J=EF=BF=BDn Tomko --- src/qemu/qemu_block.c | 2 +- src/qemu/qemu_monitor.c | 8 ++++++-- src/qemu/qemu_monitor.h | 3 ++- src/qemu/qemu_monitor_json.c | 9 ++++++--- src/qemu/qemu_monitor_json.h | 3 ++- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 7ad79c7e7d..a633bfa0b0 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -356,7 +356,7 @@ qemuBlockNodeNamesDetect(virQEMUDriverPtr driver, return -1; data =3D qemuMonitorQueryNamedBlockNodes(qemuDomainGetMonitor(vm)); - blockstats =3D qemuMonitorQueryBlockstats(qemuDomainGetMonitor(vm)); + blockstats =3D qemuMonitorQueryBlockstats(qemuDomainGetMonitor(vm), fa= lse); if (qemuDomainObjExitMonitor(driver, vm) < 0 || !data || !blockstats) goto cleanup; diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index bc116e4e2d..8618a44f32 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -2243,15 +2243,19 @@ qemuMonitorGetBlockInfo(qemuMonitorPtr mon) /** * qemuMonitorQueryBlockstats: * @mon: monitor object + * @nodenames: include backing chain nodes with explicitly specified name * * Returns data from a call to 'query-blockstats'. */ virJSONValuePtr -qemuMonitorQueryBlockstats(qemuMonitorPtr mon) +qemuMonitorQueryBlockstats(qemuMonitorPtr mon, + bool nodenames) { QEMU_CHECK_MONITOR_NULL(mon); - return qemuMonitorJSONQueryBlockstats(mon); + VIR_DEBUG("nodenames: %d", nodenames); + + return qemuMonitorJSONQueryBlockstats(mon, nodenames); } diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 81474a04f6..b4b9cf91eb 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -563,7 +563,8 @@ int qemuMonitorSetMemoryStatsPeriod(qemuMonitorPtr mon, int qemuMonitorBlockIOStatusToError(const char *status); virHashTablePtr qemuMonitorGetBlockInfo(qemuMonitorPtr mon); -virJSONValuePtr qemuMonitorQueryBlockstats(qemuMonitorPtr mon); +virJSONValuePtr qemuMonitorQueryBlockstats(qemuMonitorPtr mon, + bool nodenames); typedef struct _qemuBlockStats qemuBlockStats; typedef qemuBlockStats *qemuBlockStatsPtr; diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index cc3c8f2dd6..e41c1d47aa 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -2326,13 +2326,16 @@ qemuMonitorJSONGetOneBlockStatsInfo(virJSONValuePtr= dev, virJSONValuePtr -qemuMonitorJSONQueryBlockstats(qemuMonitorPtr mon) +qemuMonitorJSONQueryBlockstats(qemuMonitorPtr mon, + bool nodenames) { virJSONValuePtr cmd; virJSONValuePtr reply =3D NULL; virJSONValuePtr ret =3D NULL; - if (!(cmd =3D qemuMonitorJSONMakeCommand("query-blockstats", NULL))) + if (!(cmd =3D qemuMonitorJSONMakeCommand("query-blockstats", + "B:query-nodes", nodenames, + NULL))) return NULL; if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) @@ -2361,7 +2364,7 @@ qemuMonitorJSONGetAllBlockStatsInfo(qemuMonitorPtr mo= n, size_t i; virJSONValuePtr devices; - if (!(devices =3D qemuMonitorJSONQueryBlockstats(mon))) + if (!(devices =3D qemuMonitorJSONQueryBlockstats(mon, false))) return -1; for (i =3D 0; i < virJSONValueArraySize(devices); i++) { diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 66536ceb97..a6b6579849 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -82,7 +82,8 @@ int qemuMonitorJSONSetMemoryStatsPeriod(qemuMonitorPtr mo= n, int qemuMonitorJSONGetBlockInfo(qemuMonitorPtr mon, virHashTablePtr table); -virJSONValuePtr qemuMonitorJSONQueryBlockstats(qemuMonitorPtr mon); +virJSONValuePtr qemuMonitorJSONQueryBlockstats(qemuMonitorPtr mon, + bool nodenames); int qemuMonitorJSONGetAllBlockStatsInfo(qemuMonitorPtr mon, virHashTablePtr hash, bool backingChain); --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 17 07:07:57 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 1531927343930641.2463036773564; Wed, 18 Jul 2018 08:22:23 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 897AF3086273; Wed, 18 Jul 2018 15:22:20 +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 174542010CE6; Wed, 18 Jul 2018 15:22:20 +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 99A3518037EF; Wed, 18 Jul 2018 15:22:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6IFMGRt001282 for ; Wed, 18 Jul 2018 11:22:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3039E2156897; Wed, 18 Jul 2018 15:22:16 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id C1B092156893 for ; Wed, 18 Jul 2018 15:22:15 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 18 Jul 2018 17:22:07 +0200 Message-Id: <995c472f7e18ce5c554f72d82154e8b72804ee10.1531927224.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 6/9] qemu: json: Extract gathering of block statistics 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.84 on 10.5.11.25 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Wed, 18 Jul 2018 15:22:23 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The code is useful also when gathering statistics per node name, so extract it to a separate functions. Signed-off-by: Peter Krempa Reviewed-by: J=EF=BF=BDn Tomko --- src/qemu/qemu_monitor_json.c | 51 ++++++++++++++++++++++++++++++----------= ---- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index e41c1d47aa..37a4e59189 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -2253,26 +2253,15 @@ int qemuMonitorJSONGetBlockInfo(qemuMonitorPtr mon, } -static int -qemuMonitorJSONGetOneBlockStatsInfo(virJSONValuePtr dev, - const char *dev_name, - int depth, - virHashTablePtr hash, - bool backingChain) +static qemuBlockStatsPtr +qemuMonitorJSONBlockStatsCollectData(virJSONValuePtr dev, + int *nstats) { qemuBlockStatsPtr bstats =3D NULL; - virJSONValuePtr stats; + qemuBlockStatsPtr ret =3D NULL; virJSONValuePtr parent; virJSONValuePtr parentstats; - int ret =3D -1; - int nstats =3D 0; - char *entry_name =3D qemuDomainStorageAlias(dev_name, depth); - virJSONValuePtr backing; - - if (!entry_name) - goto cleanup; - if (VIR_ALLOC(bstats) < 0) - goto cleanup; + virJSONValuePtr stats; if ((stats =3D virJSONValueObjectGetObject(dev, "stats")) =3D=3D NULL)= { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -2281,6 +2270,9 @@ qemuMonitorJSONGetOneBlockStatsInfo(virJSONValuePtr d= ev, goto cleanup; } + if (VIR_ALLOC(bstats) < 0) + goto cleanup; + #define QEMU_MONITOR_BLOCK_STAT_GET(NAME, VAR, MANDATORY) \ if (MANDATORY || virJSONValueObjectHasKey(stats, NAME)) { \ nstats++; \ @@ -2307,6 +2299,33 @@ qemuMonitorJSONGetOneBlockStatsInfo(virJSONValuePtr = dev, bstats->wr_highest_offset_valid =3D true; } + VIR_STEAL_PTR(ret, bstats); + + cleanup: + VIR_FREE(bstats); + return ret; +} + + +static int +qemuMonitorJSONGetOneBlockStatsInfo(virJSONValuePtr dev, + const char *dev_name, + int depth, + virHashTablePtr hash, + bool backingChain) +{ + qemuBlockStatsPtr bstats =3D NULL; + int ret =3D -1; + int nstats =3D 0; + char *entry_name =3D qemuDomainStorageAlias(dev_name, depth); + virJSONValuePtr backing; + + if (!entry_name) + goto cleanup; + + if (!(bstats =3D qemuMonitorJSONBlockStatsCollectData(dev, &nstats))) + goto cleanup; + if (virHashAddEntry(hash, entry_name, bstats) < 0) goto cleanup; bstats =3D NULL; --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 17 07:07:57 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 1531927372889248.00821346094517; Wed, 18 Jul 2018 08:22:52 -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 E06C8356D2; Wed, 18 Jul 2018 15:22:48 +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 A5AB25D70C; Wed, 18 Jul 2018 15:22:48 +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 2C26C24F59; Wed, 18 Jul 2018 15:22:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6IFMGif001287 for ; Wed, 18 Jul 2018 11:22:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id DF58D2156897; Wed, 18 Jul 2018 15:22:16 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7848F2156893 for ; Wed, 18 Jul 2018 15:22:16 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 18 Jul 2018 17:22:08 +0200 Message-Id: <099eb854730798ffc25025cf6f68f5e31c4b839d.1531927224.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 7/9] qemu: monitor: Split out code to gather data from 'query-block' 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.30]); Wed, 18 Jul 2018 15:22:51 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Extract the code for future reuse. Signed-off-by: Peter Krempa Reviewed-by: J=EF=BF=BDn Tomko --- src/qemu/qemu_monitor_json.c | 43 +++++++++++++++++++++++++++-------------= --- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 37a4e59189..81043e2af5 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -2423,39 +2423,50 @@ qemuMonitorJSONGetAllBlockStatsInfo(qemuMonitorPtr = mon, static int -qemuMonitorJSONBlockStatsUpdateCapacityOne(virJSONValuePtr image, - const char *dev_name, - int depth, - virHashTablePtr stats, - bool backingChain) +qemuMonitorJSONBlockStatsUpdateCapacityData(virJSONValuePtr image, + const char *name, + virHashTablePtr stats) { qemuBlockStatsPtr bstats; - int ret =3D -1; - char *entry_name =3D qemuDomainStorageAlias(dev_name, depth); - virJSONValuePtr backing; - if (!(bstats =3D virHashLookup(stats, entry_name))) { + if (!(bstats =3D virHashLookup(stats, name))) { if (VIR_ALLOC(bstats) < 0) - goto cleanup; + return -1; - if (virHashAddEntry(stats, entry_name, bstats) < 0) { + if (virHashAddEntry(stats, name, bstats) < 0) { VIR_FREE(bstats); - goto cleanup; + return -1; } } - /* After this point, we ignore failures; the stats were - * zero-initialized when created which is a sane fallback. */ - ret =3D 0; + /* failures can be ignored after this point */ if (virJSONValueObjectGetNumberUlong(image, "virtual-size", &bstats->capacity) < 0) - goto cleanup; + return 0; /* if actual-size is missing, image is not thin provisioned */ if (virJSONValueObjectGetNumberUlong(image, "actual-size", &bstats->physical) < 0) bstats->physical =3D bstats->capacity; + return 0; +} + + +static int +qemuMonitorJSONBlockStatsUpdateCapacityOne(virJSONValuePtr image, + const char *dev_name, + int depth, + virHashTablePtr stats, + bool backingChain) +{ + int ret =3D -1; + char *entry_name =3D qemuDomainStorageAlias(dev_name, depth); + virJSONValuePtr backing; + + if (qemuMonitorJSONBlockStatsUpdateCapacityData(image, entry_name, sta= ts) < 0) + goto cleanup; + if (backingChain && (backing =3D virJSONValueObjectGetObject(image, "backing-image")))= { ret =3D qemuMonitorJSONBlockStatsUpdateCapacityOne(backing, --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 17 07:07:57 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 1531927379711617.1629868030046; Wed, 18 Jul 2018 08:22:59 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9BB8E89E5; Wed, 18 Jul 2018 15:22:57 +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 5CB99CB5EE; Wed, 18 Jul 2018 15:22:57 +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 F13C218037F5; Wed, 18 Jul 2018 15:22:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6IFMHJN001292 for ; Wed, 18 Jul 2018 11:22:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 836EC2156897; Wed, 18 Jul 2018 15:22:17 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 24A912156893 for ; Wed, 18 Jul 2018 15:22:17 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 18 Jul 2018 17:22:09 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 8/9] utils: storage: Add helper for checking if storage source is the same 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.84 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 18 Jul 2018 15:22:58 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" To allow checking whether a storage source points to the same location add a helper which checks the relevant fields. This will allow replacing a similar check done by formatting the command line arguments for qemu-like syntax. Signed-off-by: Peter Krempa Reviewed-by: J=EF=BF=BDn Tomko --- src/libvirt_private.syms | 1 + src/util/virstoragefile.c | 43 +++++++++++++++++++++++++++++++++++++++++++ src/util/virstoragefile.h | 3 +++ 3 files changed, 47 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 1caecb96b6..fb7c8c724d 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2855,6 +2855,7 @@ virStorageSourceIsBlockLocal; virStorageSourceIsEmpty; virStorageSourceIsLocalStorage; virStorageSourceIsRelative; +virStorageSourceIsSameLocation; virStorageSourceNetworkAssignDefaultPorts; virStorageSourceNewFromBacking; virStorageSourceNewFromBackingAbsolute; diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 58f67278da..96ed4b1489 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -2259,6 +2259,49 @@ virStorageSourceCopy(const virStorageSource *src, } +/** + * virStorageSourceIsSameLocation: + * + * Returns true if the sources @a and @b point to the same storage locatio= n. + * This does not compare any other configuration option + */ +bool +virStorageSourceIsSameLocation(virStorageSourcePtr a, + virStorageSourcePtr b) +{ + size_t i; + + /* there are multiple possibilities to define an empty source */ + if (virStorageSourceIsEmpty(a) && + virStorageSourceIsEmpty(b)) + return true; + + if (virStorageSourceGetActualType(a) !=3D virStorageSourceGetActualTyp= e(b)) + return false; + + if (STRNEQ_NULLABLE(a->path, b->path) || + STRNEQ_NULLABLE(a->volume, b->volume) || + STRNEQ_NULLABLE(a->snapshot, b->snapshot)) + return false; + + if (a->type =3D=3D VIR_STORAGE_TYPE_NETWORK) { + if (a->protocol !=3D b->protocol || + a->nhosts !=3D b->nhosts) + return false; + + for (i =3D 0; i < a->nhosts; i++) { + if (a->hosts[i].transport !=3D b->hosts[i].transport || + a->hosts[i].port !=3D b->hosts[i].port || + STRNEQ_NULLABLE(a->hosts[i].name, b->hosts[i].name) || + STRNEQ_NULLABLE(a->hosts[i].socket, b->hosts[i].socket)) + return false; + } + } + + return true; +} + + /** * virStorageSourceInitChainElement: * @newelem: New backing chain element disk source diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index 991098e6c6..c2c40edf68 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -436,6 +436,9 @@ virStorageSourcePtr virStorageSourceNewFromBacking(virS= torageSourcePtr parent); virStorageSourcePtr virStorageSourceCopy(const virStorageSource *src, bool backingChain) ATTRIBUTE_NONNULL(1); +bool virStorageSourceIsSameLocation(virStorageSourcePtr a, + virStorageSourcePtr b) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); int virStorageSourceParseRBDColonString(const char *rbdstr, virStorageSourcePtr src) --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 17 07:07:57 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 1531927350437452.36575068643674; Wed, 18 Jul 2018 08:22:30 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 62EACC04B920; Wed, 18 Jul 2018 15:22:28 +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 DCBAD194AF; Wed, 18 Jul 2018 15:22:27 +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 66F4D24F61; Wed, 18 Jul 2018 15:22:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6IFMIec001301 for ; Wed, 18 Jul 2018 11:22:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 321E92156897; Wed, 18 Jul 2018 15:22:18 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id C5ADC2156893 for ; Wed, 18 Jul 2018 15:22:17 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 18 Jul 2018 17:22:10 +0200 Message-Id: <3a104d3aac5d745417878ea0dd020aa9fd3942c6.1531927224.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 9/9] qemu: Replace qemuDomainDiskSourceDiffers by virStorageSourceIsSameLocation 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.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 18 Jul 2018 15:22:29 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Now that we have a saner replacement for checking if the disk source is the same use it instead of formatting qemu command-line chunks. Signed-off-by: Peter Krempa Reviewed-by: J=EF=BF=BDn Tomko --- src/qemu/qemu_domain.c | 34 ---------------------------------- src/qemu/qemu_domain.h | 3 --- src/qemu/qemu_driver.c | 2 +- 3 files changed, 1 insertion(+), 38 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index f8a621a5c9..acf5cc8dd2 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8555,40 +8555,6 @@ qemuDomainDiskChainElementPrepare(virQEMUDriverPtr d= river, } -bool -qemuDomainDiskSourceDiffers(virDomainDiskDefPtr disk, - virDomainDiskDefPtr origDisk) -{ - char *diskSrc =3D NULL, *origDiskSrc =3D NULL; - bool diskEmpty, origDiskEmpty; - bool ret =3D true; - - diskEmpty =3D virStorageSourceIsEmpty(disk->src); - origDiskEmpty =3D virStorageSourceIsEmpty(origDisk->src); - - if (diskEmpty && origDiskEmpty) - return false; - - if (diskEmpty ^ origDiskEmpty) - return true; - - /* This won't be a network storage, so no need to get the diskPriv - * in order to fetch the secret, thus NULL for param2 */ - if (qemuGetDriveSourceString(disk->src, NULL, &diskSrc) < 0 || - qemuGetDriveSourceString(origDisk->src, NULL, &origDiskSrc) < 0) - goto cleanup; - - /* So far in qemu disk sources are considered different - * if either path to disk or its format changes. */ - ret =3D virDomainDiskGetFormat(disk) !=3D virDomainDiskGetFormat(origD= isk) || - STRNEQ_NULLABLE(diskSrc, origDiskSrc); - cleanup: - VIR_FREE(diskSrc); - VIR_FREE(origDiskSrc); - return ret; -} - - /* * Makes sure the @disk differs from @orig_disk only by the source * path and nothing else. Fields that are being checked and the diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 22c3a51354..bff293fc0a 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -720,9 +720,6 @@ int qemuDomainDetermineDiskChain(virQEMUDriverPtr drive= r, virDomainDiskDefPtr disk, bool report_broken); -bool qemuDomainDiskSourceDiffers(virDomainDiskDefPtr disk, - virDomainDiskDefPtr origDisk); - bool qemuDomainDiskChangeSupported(virDomainDiskDefPtr disk, virDomainDiskDefPtr orig_disk); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 64e2c274c2..dea548f982 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7871,7 +7871,7 @@ qemuDomainChangeDiskLive(virDomainObjPtr vm, if (!qemuDomainDiskChangeSupported(disk, orig_disk)) goto cleanup; - if (qemuDomainDiskSourceDiffers(disk, orig_disk)) { + if (!virStorageSourceIsSameLocation(disk->src, orig_disk->src)) { /* Disk source can be changed only for removable devices */ if (disk->device !=3D VIR_DOMAIN_DISK_DEVICE_CDROM && disk->device !=3D VIR_DOMAIN_DISK_DEVICE_FLOPPY) { --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list