From nobody Fri May 3 09:52:26 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 ARC-Seal: i=1; a=rsa-sha256; t=1558363480; cv=none; d=zoho.com; s=zohoarc; b=Tm3/pI8IoX3nxEcQG8Uce/0N97F3o6yjKFZ7vRfu9IomsU7D4f7V0QKr9kF+mS10TZhosRXWK8R63hvnQ7gSgGkAnBJCnTxSbUcT9Z/02rK/e+IiKXJjh34HcX+LS68Lzk2RhBxVTINAg+jCU6CFuuKyjutjvyU+/nO7002s1+o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558363480; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=+KNM3OCNOoR+A28DlxGCjXKeKqYeolws6wNj8zC8bl0=; b=lK1f7VBLTv2/59DObyY6cVYBhZEoilUku3Zp+5YAcuYe925hnovDTmmqLVSmFx22IZ1CphdTBgGGLeOMZO5J/Z9G9BO9H05YzRXBiP8OOJbbjdEWXplVCfx+wP0s4duG9dSGDo5UG8GQkktrCGIUMcNeqfQPUQGPmyrZRSb3Lug= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1558363480220178.2901264253427; Mon, 20 May 2019 07:44:40 -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 CF7AD3086222; Mon, 20 May 2019 14:44:13 +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 9EA65176B1; Mon, 20 May 2019 14:44:07 +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 435071806B14; Mon, 20 May 2019 14:44:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x4KEGco5021650 for ; Mon, 20 May 2019 10:16:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id E2610101E695; Mon, 20 May 2019 14:16:37 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 120A1101E69B; Mon, 20 May 2019 14:16:36 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 20 May 2019 16:16:30 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 1/4] qemu: migration: Don't pass around flags for different API 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: , 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.42]); Mon, 20 May 2019 14:44:39 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The NBD migration code uses drive/blockdev-mirror internally. In those APIs we pass around flags for the monitor commands which are based on the flags for the virDomainBlockRebase API. Since there's only one flag which changes, pass it around explicitly rather than obscuring it in a bitfield. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_migration.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index e3ad4e52a7..7b1e392f73 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -785,7 +785,7 @@ qemuMigrationSrcNBDStorageCopyBlockdev(virQEMUDriverPtr= driver, const char *host, int port, unsigned long long mirror_speed, - unsigned int mirror_flags, + unsigned int mirror_shallow, const char *tlsAlias) { VIR_AUTOPTR(qemuBlockStorageSourceAttachData) data =3D NULL; @@ -793,6 +793,10 @@ qemuMigrationSrcNBDStorageCopyBlockdev(virQEMUDriverPt= r driver, int mon_ret =3D 0; int ret =3D -1; VIR_AUTOUNREF(virStorageSourcePtr) copysrc =3D NULL; + unsigned int mirror_flags =3D 0; + + if (mirror_shallow) + mirror_flags |=3D VIR_DOMAIN_BLOCK_REBASE_SHALLOW; VIR_DEBUG("starting blockdev mirror for disk=3D%s to host=3D%s", diskA= lias, host); @@ -861,11 +865,15 @@ qemuMigrationSrcNBDStorageCopyDriveMirror(virQEMUDriv= erPtr driver, const char *host, int port, unsigned long long mirror_speed, - unsigned int mirror_flags) + bool mirror_shallow) { char *nbd_dest =3D NULL; int mon_ret; int ret =3D -1; + unsigned int mirror_flags =3D VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT; + + if (mirror_shallow) + mirror_flags |=3D VIR_DOMAIN_BLOCK_REBASE_SHALLOW; if (strchr(host, ':')) { if (virAsprintf(&nbd_dest, "nbd:[%s]:%d:exportname=3D%s", @@ -903,7 +911,7 @@ qemuMigrationSrcNBDStorageCopyOne(virQEMUDriverPtr driv= er, const char *host, int port, unsigned long long mirror_speed, - unsigned int mirror_flags, + bool mirror_shallow, const char *tlsAlias, unsigned int flags) { @@ -926,13 +934,13 @@ qemuMigrationSrcNBDStorageCopyOne(virQEMUDriverPtr dr= iver, disk, diskAlias, host, port, mirror_speed, - mirror_flags, + mirror_shallow, tlsAlias); } else { rc =3D qemuMigrationSrcNBDStorageCopyDriveMirror(driver, vm, diskA= lias, host, port, mirror_speed, - mirror_flags); + mirror_shallow); } if (rc < 0) @@ -987,7 +995,7 @@ qemuMigrationSrcNBDStorageCopy(virQEMUDriverPtr driver, int port; size_t i; unsigned long long mirror_speed =3D speed; - unsigned int mirror_flags =3D VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT; + bool mirror_shallow =3D *migrate_flags & QEMU_MONITOR_MIGRATE_NON_SHAR= ED_INC; int rv; virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); @@ -1005,9 +1013,6 @@ qemuMigrationSrcNBDStorageCopy(virQEMUDriverPtr drive= r, port =3D mig->nbd->port; mig->nbd->port =3D 0; - if (*migrate_flags & QEMU_MONITOR_MIGRATE_NON_SHARED_INC) - mirror_flags |=3D VIR_DOMAIN_BLOCK_REBASE_SHALLOW; - for (i =3D 0; i < vm->def->ndisks; i++) { virDomainDiskDefPtr disk =3D vm->def->disks[i]; @@ -1016,7 +1021,7 @@ qemuMigrationSrcNBDStorageCopy(virQEMUDriverPtr drive= r, continue; if (qemuMigrationSrcNBDStorageCopyOne(driver, vm, disk, host, port, - mirror_speed, mirror_flags, + mirror_speed, mirror_shallow, tlsAlias, flags) < 0) goto cleanup; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 09:52:26 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 ARC-Seal: i=1; a=rsa-sha256; t=1558361815; cv=none; d=zoho.com; s=zohoarc; b=nMBnjTTQUranfJ9Qktt0DmjvUrED1byJYmLC6P9dk09exBvUnIec+A/rI30pnBdtiHfQWiWOwNjqJzKmNyJo4hUd6RQm8Wwu4koFvC0U7myfk8Bh6mLqAetu0voJWKnBrLDKDdI56+fYqQdubKS2PoPn7tYS2pbhIpAa270aPg8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558361815; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=ZQv7Lfjh6B0cv/M1XCwn/p96tZb1y+ZkfUFU6Ybo0mM=; b=E7LfFWYsJGjqAcA35TsyRmZjXa0iEimO/YiLEiBGze4Hbbyewgrg6UPuv6+WK/33mcXlwWABqcFqzZpNYzLQKqEmbHbKK3nF8NZwOXxEyTRiCNjB2nvo9GQe9xgjbZQhJHUle1QWc/Q6CG1zAZMMqQOxAPkX07CQwiBdpxCh10s= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1558361815672645.6000132399507; Mon, 20 May 2019 07:16:55 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7062CC09AD17; Mon, 20 May 2019 14:16:44 +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 21A671001DD9; Mon, 20 May 2019 14:16:43 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id AB9781806B15; Mon, 20 May 2019 14:16:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x4KEGdOX021690 for ; Mon, 20 May 2019 10:16:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id C833D104B4F3; Mon, 20 May 2019 14:16:38 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1448B104C460; Mon, 20 May 2019 14:16:37 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 20 May 2019 16:16:31 +0200 Message-Id: <329d1a4fa313cf2a59e83491814af69a99a54027.1558361762.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 2/4] qemu: monitor: Don't pass full flags to qemuMonitorJSONBlockdevMirror 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: , 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.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 20 May 2019 14:16:50 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Split out the 'shallow' flag as a boolean argument rather than passing in flags and constructing them in irrelevant APIs. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_migration.c | 6 +----- src/qemu/qemu_monitor.c | 8 ++++---- src/qemu/qemu_monitor.h | 2 +- src/qemu/qemu_monitor_json.c | 3 +-- src/qemu/qemu_monitor_json.h | 2 +- tests/qemumonitorjsontest.c | 3 +-- 6 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 7b1e392f73..832f98346d 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -793,10 +793,6 @@ qemuMigrationSrcNBDStorageCopyBlockdev(virQEMUDriverPt= r driver, int mon_ret =3D 0; int ret =3D -1; VIR_AUTOUNREF(virStorageSourcePtr) copysrc =3D NULL; - unsigned int mirror_flags =3D 0; - - if (mirror_shallow) - mirror_flags |=3D VIR_DOMAIN_BLOCK_REBASE_SHALLOW; VIR_DEBUG("starting blockdev mirror for disk=3D%s to host=3D%s", diskA= lias, host); @@ -841,7 +837,7 @@ qemuMigrationSrcNBDStorageCopyBlockdev(virQEMUDriverPtr= driver, if (mon_ret =3D=3D 0) mon_ret =3D qemuMonitorBlockdevMirror(qemuDomainGetMonitor(vm), NU= LL, diskAlias, copysrc->nodeformat, - mirror_speed, 0, 0, mirror_fla= gs); + mirror_speed, 0, 0, mirror_sha= llow); if (mon_ret !=3D 0) qemuBlockStorageSourceAttachRollback(qemuDomainGetMonitor(vm), dat= a); diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index e1fcbac13f..9a796db3cb 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3266,17 +3266,17 @@ qemuMonitorBlockdevMirror(qemuMonitorPtr mon, unsigned long long bandwidth, unsigned int granularity, unsigned long long buf_size, - unsigned int flags) + bool shallow) { VIR_DEBUG("jobname=3D%s, device=3D%s, target=3D%s, bandwidth=3D%lld, " - "granularity=3D%#x, buf_size=3D%lld, flags=3D0x%x", + "granularity=3D%#x, buf_size=3D%lld, shallow=3D%d", NULLSTR(jobname), device, target, bandwidth, granularity, - buf_size, flags); + buf_size, shallow); QEMU_CHECK_MONITOR(mon); return qemuMonitorJSONBlockdevMirror(mon, jobname, device, target, ban= dwidth, - granularity, buf_size, flags); + granularity, buf_size, shallow); } diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 9242d37407..438c3c38ed 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -893,7 +893,7 @@ int qemuMonitorBlockdevMirror(qemuMonitorPtr mon, unsigned long long bandwidth, unsigned int granularity, unsigned long long buf_size, - unsigned int flags) + bool shallow) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4); int qemuMonitorDrivePivot(qemuMonitorPtr mon, const char *jobname) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 5e3df5e759..a75e660d07 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -4320,12 +4320,11 @@ qemuMonitorJSONBlockdevMirror(qemuMonitorPtr mon, unsigned long long speed, unsigned int granularity, unsigned long long buf_size, - unsigned int flags) + bool shallow) { int ret =3D -1; virJSONValuePtr cmd; virJSONValuePtr reply =3D NULL; - bool shallow =3D (flags & VIR_DOMAIN_BLOCK_REBASE_SHALLOW) !=3D 0; cmd =3D qemuMonitorJSONMakeCommand("blockdev-mirror", "S:job-id", jobname, diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 746b7072ca..174db7a2e9 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -259,7 +259,7 @@ int qemuMonitorJSONBlockdevMirror(qemuMonitorPtr mon, unsigned long long speed, unsigned int granularity, unsigned long long buf_size, - unsigned int flags) + bool shallow) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4); int qemuMonitorJSONDrivePivot(qemuMonitorPtr mon, const char *jobname) diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 923f6d7d9c..c2bb3a6c4f 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -1343,8 +1343,7 @@ GEN_TEST_FUNC(qemuMonitorJSONDelDevice, "ide0") GEN_TEST_FUNC(qemuMonitorJSONAddDevice, "some_dummy_devicestr") GEN_TEST_FUNC(qemuMonitorJSONDriveMirror, "vdb", "/foo/bar", "formatstr", = 1024, 1234, 31234, VIR_DOMAIN_BLOCK_REBASE_SHALLOW | VIR_DOMAIN_BLOCK_REBASE_RE= USE_EXT) -GEN_TEST_FUNC(qemuMonitorJSONBlockdevMirror, "jobname", "vdb", "targetnode= ", 1024, 1234, 31234, - VIR_DOMAIN_BLOCK_REBASE_SHALLOW | VIR_DOMAIN_BLOCK_REBASE_RE= USE_EXT) +GEN_TEST_FUNC(qemuMonitorJSONBlockdevMirror, "jobname", "vdb", "targetnode= ", 1024, 1234, 31234, true) GEN_TEST_FUNC(qemuMonitorJSONBlockStream, "vdb", "/foo/bar1", "backingfile= name", 1024) GEN_TEST_FUNC(qemuMonitorJSONBlockCommit, "vdb", "/foo/bar1", "/foo/bar2",= "backingfilename", 1024) GEN_TEST_FUNC(qemuMonitorJSONDrivePivot, "vdb") --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 09:52:26 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 ARC-Seal: i=1; a=rsa-sha256; t=1558361821; cv=none; d=zoho.com; s=zohoarc; b=X/wfCKE+CnIb6asemQeiKHDyWpaJyd580/1i2h1U/McSmuVLUTA2ahaArSXCrMiyhQnVav3cEqkEJsOxc7AUKnWQsqMxIp6/lizsXhVJTlEeavi48HTJI+FcMFWipaNu8OSTSAsPceE6O45uRnKbN3qvz7J1MT/loTi4QZCrYUc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558361821; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=phGHLaz9rKXPMsZgVIRsMQ6LAt/WLG3vvkFt97relns=; b=HbtHzkFfk7+HBXJ6j0uPObwq96hHBTXF/UdS8XqTTU51y0QRKDvBrNRGDBTrTX24LcwUqpdFKbuWijN5ba3hz/+CMQkhnabXsimekzkBjZ5uSqaB5xRmKdKpX8YL2lV6y/nqsX5zwCVvW76idzLgmP/KzEW1y9TB8Vob4XqrYP8= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1558361821978399.81204499476496; Mon, 20 May 2019 07:17:01 -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 9C1CAFFCBF; Mon, 20 May 2019 14:16:49 +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 8B6136085B; Mon, 20 May 2019 14:16:46 +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 45B835B426; Mon, 20 May 2019 14:16:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x4KEGdw4021718 for ; Mon, 20 May 2019 10:16:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id C3F481001DD9; Mon, 20 May 2019 14:16:39 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 23DB5105B1E8; Mon, 20 May 2019 14:16:38 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 20 May 2019 16:16:32 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 3/4] qemu: monitor: Don't pass full flags to qemuMonitorJSONDriveMirror 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: , 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.38]); Mon, 20 May 2019 14:16:51 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Split out the 'shallow' and 'reuse' flags as booleans rather than passing in flags and constructing them in irrelevant APIs. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 4 +++- src/qemu/qemu_migration.c | 6 +----- src/qemu/qemu_monitor.c | 9 +++++---- src/qemu/qemu_monitor.h | 3 ++- src/qemu/qemu_monitor_json.c | 5 ++--- src/qemu/qemu_monitor_json.h | 3 ++- tests/qemumonitorjsontest.c | 3 +-- 7 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 9c0796b0a4..95c84b46ae 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -17764,7 +17764,9 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, /* qemuMonitorDriveMirror needs to honor the REUSE_EXT flag as specifi= ed * by the user regardless of how @reuse was modified */ ret =3D qemuMonitorDriveMirror(priv->mon, device, mirror->path, format, - bandwidth, granularity, buf_size, flags); + bandwidth, granularity, buf_size, + flags & VIR_DOMAIN_BLOCK_COPY_SHALLOW, + flags & VIR_DOMAIN_BLOCK_COPY_REUSE_EXT); virDomainAuditDisk(vm, NULL, mirror, "mirror", ret >=3D 0); if (qemuDomainObjExitMonitor(driver, vm) < 0) ret =3D -1; diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 832f98346d..32b3040473 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -866,10 +866,6 @@ qemuMigrationSrcNBDStorageCopyDriveMirror(virQEMUDrive= rPtr driver, char *nbd_dest =3D NULL; int mon_ret; int ret =3D -1; - unsigned int mirror_flags =3D VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT; - - if (mirror_shallow) - mirror_flags |=3D VIR_DOMAIN_BLOCK_REBASE_SHALLOW; if (strchr(host, ':')) { if (virAsprintf(&nbd_dest, "nbd:[%s]:%d:exportname=3D%s", @@ -887,7 +883,7 @@ qemuMigrationSrcNBDStorageCopyDriveMirror(virQEMUDriver= Ptr driver, mon_ret =3D qemuMonitorDriveMirror(qemuDomainGetMonitor(vm), diskAlias, nbd_dest, "raw", - mirror_speed, 0, 0, mirror_flags); + mirror_speed, 0, 0, mirror_shallow, t= rue); if (qemuDomainObjExitMonitor(driver, vm) < 0 || mon_ret < 0) goto cleanup; diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 9a796db3cb..6b731cd91a 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3244,17 +3244,18 @@ qemuMonitorDriveMirror(qemuMonitorPtr mon, const char *device, const char *file, const char *format, unsigned long long bandwidth, unsigned int granularity, unsigned long long buf_si= ze, - unsigned int flags) + bool shallow, + bool reuse) { VIR_DEBUG("device=3D%s, file=3D%s, format=3D%s, bandwidth=3D%lld, " - "granularity=3D%#x, buf_size=3D%lld, flags=3D0x%x", + "granularity=3D%#x, buf_size=3D%lld, shallow=3D%d, reuse=3D%= d", device, file, NULLSTR(format), bandwidth, granularity, - buf_size, flags); + buf_size, shallow, reuse); QEMU_CHECK_MONITOR(mon); return qemuMonitorJSONDriveMirror(mon, device, file, format, bandwidth, - granularity, buf_size, flags); + granularity, buf_size, shallow, reus= e); } diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 438c3c38ed..dee594fa66 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -884,7 +884,8 @@ int qemuMonitorDriveMirror(qemuMonitorPtr mon, unsigned long long bandwidth, unsigned int granularity, unsigned long long buf_size, - unsigned int flags) + bool shallow, + bool reuse) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); int qemuMonitorBlockdevMirror(qemuMonitorPtr mon, const char *jobname, diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index a75e660d07..4152d44331 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -4277,13 +4277,12 @@ qemuMonitorJSONDriveMirror(qemuMonitorPtr mon, const char *format, unsigned long long speed, unsigned int granularity, unsigned long long buf_size, - unsigned int flags) + bool shallow, + bool reuse) { int ret =3D -1; virJSONValuePtr cmd; virJSONValuePtr reply =3D NULL; - bool shallow =3D (flags & VIR_DOMAIN_BLOCK_REBASE_SHALLOW) !=3D 0; - bool reuse =3D (flags & VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT) !=3D 0; cmd =3D qemuMonitorJSONMakeCommand("drive-mirror", "s:device", device, diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 174db7a2e9..acef1a0a79 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -250,7 +250,8 @@ int qemuMonitorJSONDriveMirror(qemuMonitorPtr mon, unsigned long long speed, unsigned int granularity, unsigned long long buf_size, - unsigned int flags) + bool shallow, + bool reuse) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); int qemuMonitorJSONBlockdevMirror(qemuMonitorPtr mon, const char *jobname, diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index c2bb3a6c4f..0894e748ae 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -1341,8 +1341,7 @@ GEN_TEST_FUNC(qemuMonitorJSONAddNetdev, "id=3Dnet0,ty= pe=3Dtest") GEN_TEST_FUNC(qemuMonitorJSONRemoveNetdev, "net0") GEN_TEST_FUNC(qemuMonitorJSONDelDevice, "ide0") GEN_TEST_FUNC(qemuMonitorJSONAddDevice, "some_dummy_devicestr") -GEN_TEST_FUNC(qemuMonitorJSONDriveMirror, "vdb", "/foo/bar", "formatstr", = 1024, 1234, 31234, - VIR_DOMAIN_BLOCK_REBASE_SHALLOW | VIR_DOMAIN_BLOCK_REBASE_RE= USE_EXT) +GEN_TEST_FUNC(qemuMonitorJSONDriveMirror, "vdb", "/foo/bar", "formatstr", = 1024, 1234, 31234, true, true) GEN_TEST_FUNC(qemuMonitorJSONBlockdevMirror, "jobname", "vdb", "targetnode= ", 1024, 1234, 31234, true) GEN_TEST_FUNC(qemuMonitorJSONBlockStream, "vdb", "/foo/bar1", "backingfile= name", 1024) GEN_TEST_FUNC(qemuMonitorJSONBlockCommit, "vdb", "/foo/bar1", "/foo/bar2",= "backingfilename", 1024) --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 09:52:26 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 ARC-Seal: i=1; a=rsa-sha256; t=1558361830; cv=none; d=zoho.com; s=zohoarc; b=KG9wYhLx7agOBsm1hoEy+YqWQkDwcqGFzMcVjPg7ZOf6FCe/IG8DnLeMP+rY36p0n6oMtDWnxRzRM1HHv6GBEUapdaV2mA17IXxUmB5B7VHL2V7714yU1ONEcGSpMGtIfi1JSdgLUlQzirur3tjczJx/k4mZGKYC98fp7/h1FcA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558361830; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=TTEZZmL9u243ghgniyS/wIMjxDU962xpXaNw9olFSK4=; b=T92IoXlCgY7dghid6bdevWX1YPmGX3K8AWOJZJQrUctB8Ve8xNXwfp1m9mx2RPzfa8mI92JpToX/adPAleeCK2blwgZHAOp2LayaOKeeKoT73BGjxjXGVgrIqMDvzbB/XTIiGzsBVC+Z9cONCxsWR3a0Gb3Ro8uG2u5fP09lHW8= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 155836183029471.63373335102222; Mon, 20 May 2019 07:17:10 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 18ED1821DE; Mon, 20 May 2019 14:16:59 +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 DF28D5D9C8; Mon, 20 May 2019 14:16: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 8AF8B1806B15; Mon, 20 May 2019 14:16:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x4KEGe5E021859 for ; Mon, 20 May 2019 10:16:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id BF5E11001F41; Mon, 20 May 2019 14:16:40 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 221611019616; Mon, 20 May 2019 14:16:39 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 20 May 2019 16:16:33 +0200 Message-Id: <70835f848f2505343ccbc7a487f350b1f093ca04.1558361762.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 4/4] qemu: monitor: Use VIR_AUTOPTR in qemuMonitorJSON(Drive/Blockdev)Mirror 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 20 May 2019 14:17:04 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_monitor_json.c | 71 ++++++++++++++---------------------- 1 file changed, 28 insertions(+), 43 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 4152d44331..4f9a0cb960 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -4280,34 +4280,25 @@ qemuMonitorJSONDriveMirror(qemuMonitorPtr mon, bool shallow, bool reuse) { - int ret =3D -1; - virJSONValuePtr cmd; - virJSONValuePtr reply =3D NULL; + VIR_AUTOPTR(virJSONValue) cmd =3D NULL; + VIR_AUTOPTR(virJSONValue) reply =3D NULL; - cmd =3D qemuMonitorJSONMakeCommand("drive-mirror", - "s:device", device, - "s:target", file, - "Y:speed", speed, - "z:granularity", granularity, - "P:buf-size", buf_size, - "s:sync", shallow ? "top" : "full", - "s:mode", reuse ? "existing" : "absol= ute-paths", - "S:format", format, - NULL); - if (!cmd) + if (!(cmd =3D qemuMonitorJSONMakeCommand("drive-mirror", + "s:device", device, + "s:target", file, + "Y:speed", speed, + "z:granularity", granularity, + "P:buf-size", buf_size, + "s:sync", shallow ? "top" : "fu= ll", + "s:mode", reuse ? "existing" : = "absolute-paths", + "S:format", format, + NULL))) return -1; if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; - - if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; + return -1; - ret =3D 0; - cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); - return ret; + return qemuMonitorJSONCheckError(cmd, reply); } @@ -4321,30 +4312,24 @@ qemuMonitorJSONBlockdevMirror(qemuMonitorPtr mon, unsigned long long buf_size, bool shallow) { - int ret =3D -1; - virJSONValuePtr cmd; - virJSONValuePtr reply =3D NULL; + VIR_AUTOPTR(virJSONValue) cmd =3D NULL; + VIR_AUTOPTR(virJSONValue) reply =3D NULL; - cmd =3D qemuMonitorJSONMakeCommand("blockdev-mirror", - "S:job-id", jobname, - "s:device", device, - "s:target", target, - "Y:speed", speed, - "z:granularity", granularity, - "P:buf-size", buf_size, - "s:sync", shallow ? "top" : "full", - NULL); - if (!cmd) + if (!(cmd =3D qemuMonitorJSONMakeCommand("blockdev-mirror", + "S:job-id", jobname, + "s:device", device, + "s:target", target, + "Y:speed", speed, + "z:granularity", granularity, + "P:buf-size", buf_size, + "s:sync", shallow ? "top" : "fu= ll", + NULL))) return -1; - if ((ret =3D qemuMonitorJSONCommand(mon, cmd, &reply)) < 0) - goto cleanup; - ret =3D qemuMonitorJSONCheckError(cmd, reply); + if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) + return -1; - cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); - return ret; + return qemuMonitorJSONCheckError(cmd, reply); } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list