From nobody Wed May 14 06:58:25 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1526642978415286.4026954791984; Fri, 18 May 2018 04:29:38 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F0A453C7A4B; Fri, 18 May 2018 11:29:36 +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 A553930012A4; Fri, 18 May 2018 11:29:36 +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 5DE323FCFC; Fri, 18 May 2018 11:29:36 +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 w4IBTLgB016051 for ; Fri, 18 May 2018 07:29:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id DE0CA2026E03; Fri, 18 May 2018 11:29:20 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 831062026DFD for ; Fri, 18 May 2018 11:29:20 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 18 May 2018 13:28:57 +0200 Message-Id: <31afb1ca53273ff13a51f6ba6e5efb8e583abd8d.1526642823.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 Subject: [libvirt] [PATCH 07/15] qemu: monitor: Introduce support for 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: , 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.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 18 May 2018 11:29:37 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" drive-mirror allows only file targets. Introduce support for blockdev-mirror that is able to copy to any BDS described by a node name in qemu. Signed-off-by: Peter Krempa --- src/qemu/qemu_monitor.c | 22 ++++++++++++++++++++++ src/qemu/qemu_monitor.h | 9 +++++++++ src/qemu/qemu_monitor_json.c | 39 +++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_monitor_json.h | 9 +++++++++ 4 files changed, 79 insertions(+) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index fb9583e405..315bb460b9 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3362,6 +3362,28 @@ qemuMonitorDriveMirror(qemuMonitorPtr mon, } +int +qemuMonitorBlockdevMirror(qemuMonitorPtr mon, + const char *jobname, + const char *device, + const char *target, + unsigned long long bandwidth, + unsigned int granularity, + unsigned long long buf_size, + unsigned int flags) +{ + VIR_DEBUG("jobname=3D%s, device=3D%s, target=3D%s, bandwidth=3D%lld, " + "granularity=3D%#x, buf_size=3D%lld, flags=3D0x%x", + NULLSTR(jobname), device, target, bandwidth, granularity, + buf_size, flags); + + QEMU_CHECK_MONITOR_JSON(mon); + + return qemuMonitorJSONBlockdevMirror(mon, jobname, device, target, ban= dwidth, + granularity, buf_size, flags); +} + + /* Use the transaction QMP command to run atomic snapshot commands. */ int qemuMonitorTransaction(qemuMonitorPtr mon, virJSONValuePtr *actions) diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 52ad843029..6acc4edffa 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -860,6 +860,15 @@ int qemuMonitorDriveMirror(qemuMonitorPtr mon, unsigned long long buf_size, unsigned int flags) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); +int qemuMonitorBlockdevMirror(qemuMonitorPtr mon, + const char *jobname, + const char *device, + const char *target, + unsigned long long bandwidth, + unsigned int granularity, + unsigned long long buf_size, + unsigned int flags) + ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4); int qemuMonitorDrivePivot(qemuMonitorPtr mon, const char *device) ATTRIBUTE_NONNULL(2); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 61554a7ebc..2a7abf538e 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -4189,6 +4189,45 @@ qemuMonitorJSONDriveMirror(qemuMonitorPtr mon, return ret; } + +int +qemuMonitorJSONBlockdevMirror(qemuMonitorPtr mon, + const char *jobname, + const char *device, + const char *target, + unsigned long long speed, + unsigned int granularity, + unsigned long long buf_size, + unsigned int flags) +{ + 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, + "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) + return -1; + + if ((ret =3D qemuMonitorJSONCommand(mon, cmd, &reply)) < 0) + goto cleanup; + ret =3D qemuMonitorJSONCheckError(cmd, reply); + + cleanup: + virJSONValueFree(cmd); + virJSONValueFree(reply); + return ret; +} + + int qemuMonitorJSONTransaction(qemuMonitorPtr mon, virJSONValuePtr *actions) { diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 22bcc1e8ef..646cfcc8ac 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -264,6 +264,15 @@ int qemuMonitorJSONDriveMirror(qemuMonitorPtr mon, unsigned long long buf_size, unsigned int flags) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); +int qemuMonitorJSONBlockdevMirror(qemuMonitorPtr mon, + const char *jobname, + const char *device, + const char *target, + unsigned long long speed, + unsigned int granularity, + unsigned long long buf_size, + unsigned int flags) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4); int qemuMonitorJSONDrivePivot(qemuMonitorPtr mon, const char *device) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list