From nobody Fri Dec 19 16:07:38 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 ARC-Seal: i=1; a=rsa-sha256; t=1561391820; cv=none; d=zoho.com; s=zohoarc; b=T/gn5bBX/flWxlg6RjtR3iMsHYWUxrKhZu2ng3UrLhzsAdLCqy94hwqQstWWEquAwApK+y8ppXPaO6wJMH8aUdlQjZsb9xHDIUN+LDkSj5KOlJmQ3YRqH7M6yuDH6FRfuxx42liE5FcIUmZpMIyyqu5E04pnehnygsTK7pjMoPw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561391820; h=Content-Type:Content-Transfer-Encoding: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=kIMkTNjkWDGstNJWp/etoQWmwbO2nLfeEPPgJcYQFqc=; b=E20m68owmgoKBQsYV4dmfgNucjudP8yUlT6gOxvGHHkN+N0OesZK4fiH4/1ilaikSHpiq0tlUNmeaFco9cGYMmyt3oEw5LmTOnTHm2WwMlNG17BTvD/jaLg5xFVIFxAQtAoG8bLy5JxUP9X/8Ys31Hr/qyzf9Fyc5RENUnvvzM0= 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 156139182095064.57426213064446; Mon, 24 Jun 2019 08:57:00 -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 DB60F307E04A; Mon, 24 Jun 2019 15:56:43 +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 B04D55D9C5; Mon, 24 Jun 2019 15:56: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 6DA521806B19; Mon, 24 Jun 2019 15:56: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 x5OFt1vc014511 for ; Mon, 24 Jun 2019 11:55:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7A3821001B05; Mon, 24 Jun 2019 15:55:01 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 061A11001B04 for ; Mon, 24 Jun 2019 15:55:00 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 24 Jun 2019 17:54:49 +0200 Message-Id: <71e1d89014c0ce8fe12707838fcc5b19bb57ef4a.1561391499.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 Subject: [libvirt] [PATCH 2/9] qemu: monitor: Add new fields for 'block-commit' command 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.42]); Mon, 24 Jun 2019 15:56:59 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Allow using the node name to specify the base and top of the 'commit' operation, allow specifying explicit job name and add support for delayed dismiss of the job so that we can reap the state even if libvirtd was not running when qemu emitted the job completion event. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 4 ++-- src/qemu/qemu_monitor.c | 21 +++++++++++++++------ src/qemu/qemu_monitor.h | 6 +++++- src/qemu/qemu_monitor_json.c | 22 ++++++++++++++++++++-- src/qemu/qemu_monitor_json.h | 4 ++++ tests/qemumonitorjsontest.c | 2 +- 6 files changed, 47 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index f6178ddd0b..25977dc900 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -18046,8 +18046,8 @@ qemuDomainBlockCommit(virDomainPtr dom, topPath =3D qemuMonitorDiskNameLookup(priv->mon, device, disk->src, topSource); if (basePath && topPath) - ret =3D qemuMonitorBlockCommit(priv->mon, device, - topPath, basePath, backingPath, + ret =3D qemuMonitorBlockCommit(priv->mon, device, NULL, false, + topPath, NULL, basePath, NULL, backin= gPath, speed); if (qemuDomainObjExitMonitor(driver, vm) < 0 || ret < 0) { ret =3D -1; diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index e1ccb324b4..3862a00d7b 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3257,18 +3257,27 @@ qemuMonitorTransaction(qemuMonitorPtr mon, virJSONV= aluePtr *actions) /* Start a block-commit block job. bandwidth is in bytes/sec. */ int -qemuMonitorBlockCommit(qemuMonitorPtr mon, const char *device, - const char *top, const char *base, +qemuMonitorBlockCommit(qemuMonitorPtr mon, + const char *device, + const char *jobname, + bool persistjob, + const char *top, + const char *topNode, + const char *base, + const char *baseNode, const char *backingName, unsigned long long bandwidth) { - VIR_DEBUG("device=3D%s, top=3D%s, base=3D%s, backingName=3D%s, bandwid= th=3D%llu", - device, top, base, NULLSTR(backingName), bandwidth); + VIR_DEBUG("device=3D%s, jobname=3D%s, persistjob=3D%d, top=3D%s, topNo= de=3D%s, " + "base=3D%s, baseNode=3D%s, backingName=3D%s, bandwidth=3D%ll= u", + device, NULLSTR(jobname), persistjob, NULLSTR(top), NULLSTR(= topNode), + NULLSTR(base), NULLSTR(baseNode), NULLSTR(backingName), band= width); QEMU_CHECK_MONITOR(mon); - return qemuMonitorJSONBlockCommit(mon, device, top, base, - backingName, bandwidth); + return qemuMonitorJSONBlockCommit(mon, device, jobname, persistjob, to= p, + topNode, base, baseNode, backingName, + bandwidth); } diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 572a5f84cf..53b5777a84 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -918,11 +918,15 @@ int qemuMonitorDrivePivot(qemuMonitorPtr mon, int qemuMonitorBlockCommit(qemuMonitorPtr mon, const char *device, + const char *jobname, + bool persistjob, const char *top, + const char *topNode, const char *base, + const char *baseNode, const char *backingName, unsigned long long bandwidth) - ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4); + ATTRIBUTE_NONNULL(2); bool qemuMonitorSupportsActiveCommit(qemuMonitorPtr mon); char *qemuMonitorDiskNameLookup(qemuMonitorPtr mon, const char *device, diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index e946c0aeb1..4edf4f8dbc 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -4507,21 +4507,39 @@ qemuMonitorJSONSupportsActiveCommit(qemuMonitorPtr = mon) /* speed is in bytes/sec. Returns 0 on success, -1 with error message * emitted on failure. */ int -qemuMonitorJSONBlockCommit(qemuMonitorPtr mon, const char *device, - const char *top, const char *base, +qemuMonitorJSONBlockCommit(qemuMonitorPtr mon, + const char *device, + const char *jobname, + bool persistjob, + const char *top, + const char *topNode, + const char *base, + const char *baseNode, const char *backingName, unsigned long long speed) { int ret =3D -1; virJSONValuePtr cmd; virJSONValuePtr reply =3D NULL; + virTristateBool autofinalize =3D VIR_TRISTATE_BOOL_ABSENT; + virTristateBool autodismiss =3D VIR_TRISTATE_BOOL_ABSENT; + + if (persistjob) { + autofinalize =3D VIR_TRISTATE_BOOL_YES; + autodismiss =3D VIR_TRISTATE_BOOL_NO; + } cmd =3D qemuMonitorJSONMakeCommand("block-commit", "s:device", device, + "S:job-id", jobname, "Y:speed", speed, "S:top", top, + "S:top-node", topNode, "S:base", base, + "S:base-node", baseNode, "S:backing-file", backingName, + "T:auto-finalize", autofinalize, + "T:auto-dismiss", autodismiss, NULL); if (!cmd) return -1; diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 72255eefbb..2e242a4923 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -270,8 +270,12 @@ bool qemuMonitorJSONSupportsActiveCommit(qemuMonitorPt= r mon) int qemuMonitorJSONBlockCommit(qemuMonitorPtr mon, const char *device, + const char *jobname, + bool persistjob, const char *top, + const char *topNode, const char *base, + const char *baseNode, const char *backingName, unsigned long long bandwidth) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index b60df6f35b..f77f4da9a3 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -1327,7 +1327,7 @@ GEN_TEST_FUNC(qemuMonitorJSONAddDevice, "some_dummy_d= evicestr") 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", "jobname", true, "/foo/ba= r1", "backingnode", "backingfilename", 1024) -GEN_TEST_FUNC(qemuMonitorJSONBlockCommit, "vdb", "/foo/bar1", "/foo/bar2",= "backingfilename", 1024) +GEN_TEST_FUNC(qemuMonitorJSONBlockCommit, "vdb", "jobname", true, "/foo/ba= r1", "topnode", "/foo/bar2", "basenode", "backingfilename", 1024) GEN_TEST_FUNC(qemuMonitorJSONDrivePivot, "vdb") GEN_TEST_FUNC(qemuMonitorJSONScreendump, "devicename", 1, "/foo/bar") GEN_TEST_FUNC(qemuMonitorJSONOpenGraphics, "spice", "spicefd", false) --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list