From nobody Sun May 19 17:42:32 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=1561391733; cv=none; d=zoho.com; s=zohoarc; b=Gwl0UV6CgHnrx86og2uYxaZAgNym2uK6yhHQ4ZRkIpiQMlzU5/g+mGjUKuMenataG7VpVu14SWOMVBDUjpelbPuGHxadKBXljhARYwr9MRKxZyELEW4yttGNVdefhMybPcPdDYLH2DxTmTBZflOyAK9UjIJVBIyRfZf3y1pX+hM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561391733; 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=acTqG7PG9AzAyGPbscxz3BJJ7KpqhJ5et52sEGx3yNY=; b=fFQKYKHQs8FE33eAeepsiBoGGHnMtF2I5t3+Uqu5l/YPKj1R1hIx/HBI5MqHunNNtvQoCzdfA0MVZA4pDdEpixUNUxQHmYgSnRn1hmzUdiXMwWFUgd+v+Pqevcr1LaF+SpU+l9oT8+EBOCCqqDRM5eT1nTwQJCSw4djZxvwW2ps= 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 1561391733453249.99177819210695; Mon, 24 Jun 2019 08:55:33 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0EB00C4EC4; Mon, 24 Jun 2019 15:55:11 +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 CFB31600CD; Mon, 24 Jun 2019 15:55:06 +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 3C0D21806B16; Mon, 24 Jun 2019 15:55:03 +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 x5OFt0fq014487 for ; Mon, 24 Jun 2019 11:55:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id AD4641001B05; Mon, 24 Jun 2019 15:55:00 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 394291001B04 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:48 +0200 Message-Id: <317939506a4f4a4080b3b087df9068d166fb23ba.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 1/9] qemu: monitor: Add new fields for 'block-stream' 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 24 Jun 2019 15:55:29 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Allow using the node name to specify the base of the 'stream' 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 | 18 +++++++++++++++--- src/qemu/qemu_monitor.h | 3 +++ src/qemu/qemu_monitor_json.c | 14 ++++++++++++++ src/qemu/qemu_monitor_json.h | 3 +++ tests/qemumonitorjsontest.c | 2 +- 6 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index ec08dd939e..f6178ddd0b 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -17080,8 +17080,8 @@ qemuDomainBlockPullCommon(virQEMUDriverPtr driver, basePath =3D qemuMonitorDiskNameLookup(priv->mon, device, disk->sr= c, baseSource); if (!baseSource || basePath) - ret =3D qemuMonitorBlockStream(priv->mon, device, basePath, backin= gPath, - speed); + ret =3D qemuMonitorBlockStream(priv->mon, device, NULL, false, bas= ePath, + NULL, backingPath, speed); if (qemuDomainObjExitMonitor(driver, vm) < 0) ret =3D -1; diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 731be2e5a6..e1ccb324b4 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3365,16 +3365,28 @@ qemuMonitorScreendump(qemuMonitorPtr mon, int qemuMonitorBlockStream(qemuMonitorPtr mon, const char *device, + const char *jobname, + bool persistjob, const char *base, + const char *baseNode, const char *backingName, unsigned long long bandwidth) { - VIR_DEBUG("device=3D%s, base=3D%s, backingName=3D%s, bandwidth=3D%lluB= ", - device, NULLSTR(base), NULLSTR(backingName), bandwidth); + VIR_DEBUG("device=3D%s, jobname=3D%s, persistjob=3D%d, base=3D%s, base= Node=3D%s, " + "backingName=3D%s, bandwidth=3D%lluB", + device, NULLSTR(jobname), persistjob, NULLSTR(base), + NULLSTR(baseNode), NULLSTR(backingName), bandwidth); QEMU_CHECK_MONITOR(mon); - return qemuMonitorJSONBlockStream(mon, device, base, backingName, band= width); + if (base && baseNode) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("'base' and 'baseNode' can't be used together")); + return -1; + } + + return qemuMonitorJSONBlockStream(mon, device, jobname, persistjob, ba= se, + baseNode, backingName, bandwidth); } diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index c41428b048..572a5f84cf 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -949,7 +949,10 @@ int qemuMonitorSendKey(qemuMonitorPtr mon, int qemuMonitorBlockStream(qemuMonitorPtr mon, const char *device, + const char *jobname, + bool persistjob, const char *base, + const char *baseNode, const char *backingName, unsigned long long bandwidth) ATTRIBUTE_NONNULL(2); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 8723ff49c7..e946c0aeb1 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -4907,19 +4907,33 @@ qemuMonitorJSONBlockJobError(virJSONValuePtr cmd, int qemuMonitorJSONBlockStream(qemuMonitorPtr mon, const char *device, + const char *jobname, + bool persistjob, const char *base, + const char *baseNode, const char *backingName, unsigned long long speed) { int ret =3D -1; virJSONValuePtr cmd =3D NULL; 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; + } if (!(cmd =3D qemuMonitorJSONMakeCommand("block-stream", "s:device", device, + "S:job-id", jobname, "Y:speed", speed, "S:base", base, + "S:base-node", baseNode, "S:backing-file", backingName, + "T:auto-finalize", autofinalize, + "T:auto-dismiss", autodismiss, NULL))) return -1; diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index d0b519c88e..72255eefbb 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -302,7 +302,10 @@ int qemuMonitorJSONScreendump(qemuMonitorPtr mon, int qemuMonitorJSONBlockStream(qemuMonitorPtr mon, const char *device, + const char *jobname, + bool persistjob, const char *base, + const char *baseNode, const char *backingName, unsigned long long speed) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 2ed9133c06..b60df6f35b 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -1326,7 +1326,7 @@ GEN_TEST_FUNC(qemuMonitorJSONDelDevice, "ide0") GEN_TEST_FUNC(qemuMonitorJSONAddDevice, "some_dummy_devicestr") 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(qemuMonitorJSONBlockStream, "vdb", "jobname", true, "/foo/ba= r1", "backingnode", "backingfilename", 1024) GEN_TEST_FUNC(qemuMonitorJSONBlockCommit, "vdb", "/foo/bar1", "/foo/bar2",= "backingfilename", 1024) GEN_TEST_FUNC(qemuMonitorJSONDrivePivot, "vdb") GEN_TEST_FUNC(qemuMonitorJSONScreendump, "devicename", 1, "/foo/bar") --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 17:42:32 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=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 From nobody Sun May 19 17:42:32 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=1561391829; cv=none; d=zoho.com; s=zohoarc; b=aj5E3oMfUNe/uaWopF/rhZdI4b1ZzBfB4iZS18FlpW/PM3zQ5zHNpTPv+n954s0CRqD91K773BQX6z2E2tQGt05XRiSLu88p0suIxzUf3d2nlB7SIxuV3ZCJwjm413jRccUlXsbn/oD0kJotCWc77CWXpPJqdlu0Du4MONAmvFg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561391829; 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=Ga5/IV+lz9nCRVvD0g75U8kMLPVfvPi1TGFL3sNuX4s=; b=akPWMcS2tsGe+mfkfdOzy4quFcrlAzBZG1uQVWFkoa0oHduHuL+xY2WWfsuHCr086NNvqj6MItPmDXiHlrcXrGvYXhiamGeX04ca8btv3e8GsHn3KZSYQaoe7tCm95Ne68XpW6mULZi5UO0bi5qu84r9r3Ls4shbx/kT/3SI88k= 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 1561391829271955.8463239868152; Mon, 24 Jun 2019 08:57:09 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 97E6330044CA; Mon, 24 Jun 2019 15:57:02 +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 6D8236014E; Mon, 24 Jun 2019 15:57:00 +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 2DA94206D2; Mon, 24 Jun 2019 15:56:57 +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 x5OFt2Hn014540 for ; Mon, 24 Jun 2019 11:55:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4CE631001DC0; Mon, 24 Jun 2019 15:55:02 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id CAC761001B04 for ; Mon, 24 Jun 2019 15:55:01 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 24 Jun 2019 17:54:50 +0200 Message-Id: <5d55325eec648309924cb912e08d8853d006cf43.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 3/9] qemu: monitor: Add new fields for 'blockdev-mirror' 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Mon, 24 Jun 2019 15:57:08 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Allow using the 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_migration.c | 2 +- src/qemu/qemu_monitor.c | 9 +++++---- src/qemu/qemu_monitor.h | 3 ++- src/qemu/qemu_monitor_json.c | 10 ++++++++++ src/qemu/qemu_monitor_json.h | 3 ++- tests/qemumonitorjsontest.c | 2 +- 6 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 2436f5051b..1fb88c11b6 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -840,7 +840,7 @@ qemuMigrationSrcNBDStorageCopyBlockdev(virQEMUDriverPtr= driver, mon_ret =3D qemuBlockStorageSourceAttachApply(qemuDomainGetMonitor(vm)= , data); if (mon_ret =3D=3D 0) - mon_ret =3D qemuMonitorBlockdevMirror(qemuDomainGetMonitor(vm), NU= LL, + mon_ret =3D qemuMonitorBlockdevMirror(qemuDomainGetMonitor(vm), NU= LL, false, diskAlias, copysrc->nodeformat, mirror_speed, 0, 0, mirror_sha= llow); diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 3862a00d7b..1a7cfd291b 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3224,6 +3224,7 @@ qemuMonitorDriveMirror(qemuMonitorPtr mon, int qemuMonitorBlockdevMirror(qemuMonitorPtr mon, const char *jobname, + bool persistjob, const char *device, const char *target, unsigned long long bandwidth, @@ -3231,15 +3232,15 @@ qemuMonitorBlockdevMirror(qemuMonitorPtr mon, unsigned long long buf_size, bool shallow) { - VIR_DEBUG("jobname=3D%s, device=3D%s, target=3D%s, bandwidth=3D%lld, " + VIR_DEBUG("jobname=3D%s, persistjob=3D%d, device=3D%s, target=3D%s, ba= ndwidth=3D%lld, " "granularity=3D%#x, buf_size=3D%lld, shallow=3D%d", - NULLSTR(jobname), device, target, bandwidth, granularity, + NULLSTR(jobname), persistjob, device, target, bandwidth, gra= nularity, buf_size, shallow); QEMU_CHECK_MONITOR(mon); - return qemuMonitorJSONBlockdevMirror(mon, jobname, device, target, ban= dwidth, - granularity, buf_size, shallow); + return qemuMonitorJSONBlockdevMirror(mon, jobname, persistjob, device,= target, + bandwidth, granularity, buf_size,= shallow); } diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 53b5777a84..42d6e36b4d 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -905,13 +905,14 @@ int qemuMonitorDriveMirror(qemuMonitorPtr mon, ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); int qemuMonitorBlockdevMirror(qemuMonitorPtr mon, const char *jobname, + bool persistjob, const char *device, const char *target, unsigned long long bandwidth, unsigned int granularity, unsigned long long buf_size, bool shallow) - ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4); + ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5); int qemuMonitorDrivePivot(qemuMonitorPtr mon, const char *jobname) ATTRIBUTE_NONNULL(2); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 4edf4f8dbc..98846740e5 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -4415,6 +4415,7 @@ qemuMonitorJSONDriveMirror(qemuMonitorPtr mon, int qemuMonitorJSONBlockdevMirror(qemuMonitorPtr mon, const char *jobname, + bool persistjob, const char *device, const char *target, unsigned long long speed, @@ -4424,6 +4425,13 @@ qemuMonitorJSONBlockdevMirror(qemuMonitorPtr mon, { VIR_AUTOPTR(virJSONValue) cmd =3D NULL; VIR_AUTOPTR(virJSONValue) 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("blockdev-mirror", "S:job-id", jobname, @@ -4433,6 +4441,8 @@ qemuMonitorJSONBlockdevMirror(qemuMonitorPtr mon, "z:granularity", granularity, "P:buf-size", buf_size, "s:sync", shallow ? "top" : "full", + "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 2e242a4923..069f6dca62 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -254,13 +254,14 @@ int qemuMonitorJSONDriveMirror(qemuMonitorPtr mon, ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); int qemuMonitorJSONBlockdevMirror(qemuMonitorPtr mon, const char *jobname, + bool persistjob, const char *device, const char *target, unsigned long long speed, unsigned int granularity, unsigned long long buf_size, bool shallow) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4); + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5); int qemuMonitorJSONDrivePivot(qemuMonitorPtr mon, const char *jobname) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index f77f4da9a3..07dd746850 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -1325,7 +1325,7 @@ 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, true, true) -GEN_TEST_FUNC(qemuMonitorJSONBlockdevMirror, "jobname", "vdb", "targetnode= ", 1024, 1234, 31234, true) +GEN_TEST_FUNC(qemuMonitorJSONBlockdevMirror, "jobname", true, "vdb", "targ= etnode", 1024, 1234, 31234, true) GEN_TEST_FUNC(qemuMonitorJSONBlockStream, "vdb", "jobname", true, "/foo/ba= r1", "backingnode", "backingfilename", 1024) GEN_TEST_FUNC(qemuMonitorJSONBlockCommit, "vdb", "jobname", true, "/foo/ba= r1", "topnode", "/foo/bar2", "basenode", "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 Sun May 19 17:42:32 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=1561391870; cv=none; d=zoho.com; s=zohoarc; b=KsbGlZI4+gppmdIsiIKxtXlwUuIojIC0GpiEkxGNbV+n341zPlWlD1MWwSYZLVErG0m7UMTOjNtr+2cfw5udtTxOqLlk+XiaYD9x+4mytVHkrIdLZSnWdHq5MVvg9+oeq3lAXoM1VDlK9oPrro1U+207mpbkVpF+/fyt76PMG9c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561391870; 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=yzJCA1eXyXi/wtl4JhAhH8d3YCYn8aF52slz7GjjqBQ=; b=NJL5XUHVbYBK19bYhDKjxopxmMKWFzMMRjiUVNcXzd6osqDAPNGrFqoPElPJDGgn5Tbsb3Prn81SpaMy5lnem8RqvGhqLL+riSTA5mNrNMwh6CcuH1Tp6A8X50NMcMWXodpPJ8gryOomHefWbN8WeJhksD4H678MqonsNvZnYo0= 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 1561391870174689.6515710700425; Mon, 24 Jun 2019 08:57:50 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A1CA63086224; Mon, 24 Jun 2019 15:57:48 +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 7BE3F600CD; Mon, 24 Jun 2019 15:57:47 +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 03D161806B18; Mon, 24 Jun 2019 15:57:45 +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 x5OFt3Ck014566 for ; Mon, 24 Jun 2019 11:55:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1A9F71001B1B; Mon, 24 Jun 2019 15:55:03 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 994871001DC0 for ; Mon, 24 Jun 2019 15:55:02 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 24 Jun 2019 17:54:51 +0200 Message-Id: <43867c8b7fef6c05ce7778995e44755e99e94ddf.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 4/9] qemu: monitor: Add support for 'job-dismiss' 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.11 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:57:49 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This belongs to the new job management API for generic jobs. The dismiss command is meant to remove a concluded job after we were able to get the final status. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_monitor.c | 12 ++++++++++++ src/qemu/qemu_monitor.h | 4 ++++ src/qemu/qemu_monitor_json.c | 22 ++++++++++++++++++++++ src/qemu/qemu_monitor_json.h | 4 ++++ tests/qemumonitorjsontest.c | 2 ++ 5 files changed, 44 insertions(+) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 1a7cfd291b..d9196434ba 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3463,6 +3463,18 @@ qemuMonitorGetBlockJobInfo(qemuMonitorPtr mon, } +int +qemuMonitorJobDismiss(qemuMonitorPtr mon, + const char *jobname) +{ + VIR_DEBUG("jobname=3D%s", jobname); + + QEMU_CHECK_MONITOR(mon); + + return qemuMonitorJSONJobDismiss(mon, jobname); +} + + int qemuMonitorSetBlockIoThrottle(qemuMonitorPtr mon, const char *drivealias, diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 42d6e36b4d..56c68683f5 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -987,6 +987,10 @@ int qemuMonitorGetBlockJobInfo(qemuMonitorPtr mon, qemuMonitorBlockJobInfoPtr info) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); +int qemuMonitorJobDismiss(qemuMonitorPtr mon, + const char *jobname) + ATTRIBUTE_NONNULL(2); + int qemuMonitorOpenGraphics(qemuMonitorPtr mon, const char *protocol, int fd, diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 98846740e5..2ef2299a68 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5066,6 +5066,28 @@ qemuMonitorJSONDrivePivot(qemuMonitorPtr mon, } +int +qemuMonitorJSONJobDismiss(qemuMonitorPtr mon, + const char *jobname) +{ + VIR_AUTOPTR(virJSONValue) cmd =3D NULL; + VIR_AUTOPTR(virJSONValue) reply =3D NULL; + + if (!(cmd =3D qemuMonitorJSONMakeCommand("job-dismiss", + "s:id", jobname, + NULL))) + return -1; + + if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) + return -1; + + if (qemuMonitorJSONBlockJobError(cmd, reply, jobname) < 0) + return -1; + + return 0; +} + + int qemuMonitorJSONOpenGraphics(qemuMonitorPtr mon, const char *protocol, const char *fdname, diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 069f6dca62..1719509ec8 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -328,6 +328,10 @@ virHashTablePtr qemuMonitorJSONGetAllBlockJobInfo(qemu= MonitorPtr mon, bool rawjobname) ATTRIBUTE_NONNULL(1); +int qemuMonitorJSONJobDismiss(qemuMonitorPtr mon, + const char *jobname) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); + int qemuMonitorJSONSetLink(qemuMonitorPtr mon, const char *name, virDomainNetInterfaceLinkState state); diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 07dd746850..e872f93490 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -1340,6 +1340,7 @@ GEN_TEST_FUNC(qemuMonitorJSONBlockdevMediumInsert, "f= oodev", "newnode") GEN_TEST_FUNC(qemuMonitorJSONAddBitmap, "node", "bitmap", true) GEN_TEST_FUNC(qemuMonitorJSONEnableBitmap, "node", "bitmap") GEN_TEST_FUNC(qemuMonitorJSONDeleteBitmap, "node", "bitmap") +GEN_TEST_FUNC(qemuMonitorJSONJobDismiss, "jobname") static int testQemuMonitorJSONqemuMonitorJSONNBDServerStart(const void *opaque) @@ -3057,6 +3058,7 @@ mymain(void) DO_TEST_GEN(qemuMonitorJSONAddBitmap); DO_TEST_GEN(qemuMonitorJSONEnableBitmap); DO_TEST_GEN(qemuMonitorJSONDeleteBitmap); + DO_TEST_GEN(qemuMonitorJSONJobDismiss); DO_TEST(qemuMonitorJSONGetBalloonInfo); DO_TEST(qemuMonitorJSONGetBlockInfo); DO_TEST(qemuMonitorJSONGetAllBlockStatsInfo); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 17:42:32 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=1561391876; cv=none; d=zoho.com; s=zohoarc; b=RhQK8rrTbnOF3dF/Gb/OhNwgsDOggXNGgRz5lBY41T/+i3f0cmYm2ovs/uzUTTERwv/8v37YyhrO8YZW+tCJRRf1w1Molui7k4H78Y7osuQ/Dj9diD9y4y9AYkYgdSTgMoAhMquhrx4WGQG2xZzPHHmOx74+3xXsNGtjsVPuT8g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561391876; 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=wHx6wMlQSLAUhzVawBNm80ItncQxdqa/nWCPEtQQaQM=; b=hsY3bzCxrKACbVwdR8s+ECX8gEvtcvyiIFRWuVhkcRiNefIC1TZWG0xlq5Zcs+8IyyzcwtBnFo7MNe0xp8mnqMLmMJqL1XBQFZmzobJVZ8SVfKGscVDsCMU5qPE++ENlbnofjZ5GJNGNycWqVtAgTolmMnYirdPUIeel61RXZVc= 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 1561391876995394.3923397640766; Mon, 24 Jun 2019 08:57:56 -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 66C66307D983; Mon, 24 Jun 2019 15:57:55 +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 3E9D25C25A; Mon, 24 Jun 2019 15:57:55 +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 030D11806B1B; Mon, 24 Jun 2019 15:57:54 +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 x5OFt3uN014589 for ; Mon, 24 Jun 2019 11:55:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id E15CF1001DE9; Mon, 24 Jun 2019 15:55:03 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 680971001DEA for ; Mon, 24 Jun 2019 15:55:03 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 24 Jun 2019 17:54:52 +0200 Message-Id: <95e54f541034c36268c579b4e5603ea36ab00243.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 5/9] qemu: monitor: Add support for 'job-cancel' 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Mon, 24 Jun 2019 15:57:55 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This belongs to the new job management API which can manage also non-block based jobs. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_monitor.c | 12 ++++++++++++ src/qemu/qemu_monitor.h | 4 ++++ src/qemu/qemu_monitor_json.c | 22 ++++++++++++++++++++++ src/qemu/qemu_monitor_json.h | 4 ++++ tests/qemumonitorjsontest.c | 2 ++ 5 files changed, 44 insertions(+) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index d9196434ba..815ce58b69 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3475,6 +3475,18 @@ qemuMonitorJobDismiss(qemuMonitorPtr mon, } +int +qemuMonitorJobCancel(qemuMonitorPtr mon, + const char *jobname) +{ + VIR_DEBUG("jobname=3D%s", jobname); + + QEMU_CHECK_MONITOR(mon); + + return qemuMonitorJSONJobCancel(mon, jobname); +} + + int qemuMonitorSetBlockIoThrottle(qemuMonitorPtr mon, const char *drivealias, diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 56c68683f5..b306ff0314 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -991,6 +991,10 @@ int qemuMonitorJobDismiss(qemuMonitorPtr mon, const char *jobname) ATTRIBUTE_NONNULL(2); +int qemuMonitorJobCancel(qemuMonitorPtr mon, + const char *jobname) + ATTRIBUTE_NONNULL(2); + int qemuMonitorOpenGraphics(qemuMonitorPtr mon, const char *protocol, int fd, diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 2ef2299a68..84b5c30577 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5088,6 +5088,28 @@ qemuMonitorJSONJobDismiss(qemuMonitorPtr mon, } +int +qemuMonitorJSONJobCancel(qemuMonitorPtr mon, + const char *jobname) +{ + VIR_AUTOPTR(virJSONValue) cmd =3D NULL; + VIR_AUTOPTR(virJSONValue) reply =3D NULL; + + if (!(cmd =3D qemuMonitorJSONMakeCommand("job-cancel", + "s:id", jobname, + NULL))) + return -1; + + if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) + return -1; + + if (qemuMonitorJSONBlockJobError(cmd, reply, jobname) < 0) + return -1; + + return 0; +} + + int qemuMonitorJSONOpenGraphics(qemuMonitorPtr mon, const char *protocol, const char *fdname, diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 1719509ec8..aeaf332943 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -332,6 +332,10 @@ int qemuMonitorJSONJobDismiss(qemuMonitorPtr mon, const char *jobname) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); +int qemuMonitorJSONJobCancel(qemuMonitorPtr mon, + const char *jobname) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); + int qemuMonitorJSONSetLink(qemuMonitorPtr mon, const char *name, virDomainNetInterfaceLinkState state); diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index e872f93490..eabd834861 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -1341,6 +1341,7 @@ GEN_TEST_FUNC(qemuMonitorJSONAddBitmap, "node", "bitm= ap", true) GEN_TEST_FUNC(qemuMonitorJSONEnableBitmap, "node", "bitmap") GEN_TEST_FUNC(qemuMonitorJSONDeleteBitmap, "node", "bitmap") GEN_TEST_FUNC(qemuMonitorJSONJobDismiss, "jobname") +GEN_TEST_FUNC(qemuMonitorJSONJobCancel, "jobname") static int testQemuMonitorJSONqemuMonitorJSONNBDServerStart(const void *opaque) @@ -3059,6 +3060,7 @@ mymain(void) DO_TEST_GEN(qemuMonitorJSONEnableBitmap); DO_TEST_GEN(qemuMonitorJSONDeleteBitmap); DO_TEST_GEN(qemuMonitorJSONJobDismiss); + DO_TEST_GEN(qemuMonitorJSONJobCancel); DO_TEST(qemuMonitorJSONGetBalloonInfo); DO_TEST(qemuMonitorJSONGetBlockInfo); DO_TEST(qemuMonitorJSONGetAllBlockStatsInfo); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 17:42:32 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=1561391881; cv=none; d=zoho.com; s=zohoarc; b=RJWJOmXIMylC11Rb6SmCavP/ndZX/M5525thE5Lf6bFWnkEOdj7hRZxltopeoJrG1LJTCBhxgvLictU7jAyncQiD6gIHYv09LYs628IM1Fl5pDeIZrOFY6ZMWuiwcAEtHwP0jUZiWVBLMJ9HNO5J/eg3ScgXVFWMVC6zTee921w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561391881; 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=NnrwWNIcDZGhi4aPPoC7kQqVeHDUWuw8BOLQM4X+50E=; b=QiS5d4zIHxJp+NtIqaFPa47q9Pc8Yna0sSMRJ/BgQPdjHNAHkc209Ok7QACJtt8sh85a2a9nC05yauRWABmQ96CEg6BMM5PXI8Oi3w8sk1LXS07Mjk1fAyIeGqpXs2WNJ3VHaf4fbP5IwjdeyWFKm56UM/nbow743syN23CyvNg= 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 1561391881451476.368199878311; Mon, 24 Jun 2019 08:58:01 -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 D07C48830A; Mon, 24 Jun 2019 15:57: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 A589119722; Mon, 24 Jun 2019 15:57:59 +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 6BB1A1806B1D; Mon, 24 Jun 2019 15:57:59 +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 x5OFt4Gu014616 for ; Mon, 24 Jun 2019 11:55:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id ABC511001B07; Mon, 24 Jun 2019 15:55:04 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 35CC81001DC0 for ; Mon, 24 Jun 2019 15:55:04 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 24 Jun 2019 17:54:53 +0200 Message-Id: <890228dc4d7579d4c52cc5d91e2ab23b4de17980.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 6/9] qemu: monitor: Add support for 'job-complete' 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.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.28]); Mon, 24 Jun 2019 15:58:00 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This belongs to the new job management API which can manage also non-block based jobs. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_monitor.c | 12 ++++++++++++ src/qemu/qemu_monitor.h | 4 ++++ src/qemu/qemu_monitor_json.c | 22 ++++++++++++++++++++++ src/qemu/qemu_monitor_json.h | 4 ++++ tests/qemumonitorjsontest.c | 2 ++ 5 files changed, 44 insertions(+) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 815ce58b69..3cd037fdba 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3487,6 +3487,18 @@ qemuMonitorJobCancel(qemuMonitorPtr mon, } +int +qemuMonitorJobComplete(qemuMonitorPtr mon, + const char *jobname) +{ + VIR_DEBUG("jobname=3D%s", jobname); + + QEMU_CHECK_MONITOR(mon); + + return qemuMonitorJSONJobComplete(mon, jobname); +} + + int qemuMonitorSetBlockIoThrottle(qemuMonitorPtr mon, const char *drivealias, diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index b306ff0314..e3a3c212fd 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -995,6 +995,10 @@ int qemuMonitorJobCancel(qemuMonitorPtr mon, const char *jobname) ATTRIBUTE_NONNULL(2); +int qemuMonitorJobComplete(qemuMonitorPtr mon, + const char *jobname) + ATTRIBUTE_NONNULL(2); + int qemuMonitorOpenGraphics(qemuMonitorPtr mon, const char *protocol, int fd, diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 84b5c30577..33ee026fe1 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5110,6 +5110,28 @@ qemuMonitorJSONJobCancel(qemuMonitorPtr mon, } +int +qemuMonitorJSONJobComplete(qemuMonitorPtr mon, + const char *jobname) +{ + VIR_AUTOPTR(virJSONValue) cmd =3D NULL; + VIR_AUTOPTR(virJSONValue) reply =3D NULL; + + if (!(cmd =3D qemuMonitorJSONMakeCommand("job-complete", + "s:id", jobname, + NULL))) + return -1; + + if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) + return -1; + + if (qemuMonitorJSONBlockJobError(cmd, reply, jobname) < 0) + return -1; + + return 0; +} + + int qemuMonitorJSONOpenGraphics(qemuMonitorPtr mon, const char *protocol, const char *fdname, diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index aeaf332943..c2b47e6129 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -336,6 +336,10 @@ int qemuMonitorJSONJobCancel(qemuMonitorPtr mon, const char *jobname) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); +int qemuMonitorJSONJobComplete(qemuMonitorPtr mon, + const char *jobname) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); + int qemuMonitorJSONSetLink(qemuMonitorPtr mon, const char *name, virDomainNetInterfaceLinkState state); diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index eabd834861..798b7beca3 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -1342,6 +1342,7 @@ GEN_TEST_FUNC(qemuMonitorJSONEnableBitmap, "node", "b= itmap") GEN_TEST_FUNC(qemuMonitorJSONDeleteBitmap, "node", "bitmap") GEN_TEST_FUNC(qemuMonitorJSONJobDismiss, "jobname") GEN_TEST_FUNC(qemuMonitorJSONJobCancel, "jobname") +GEN_TEST_FUNC(qemuMonitorJSONJobComplete, "jobname") static int testQemuMonitorJSONqemuMonitorJSONNBDServerStart(const void *opaque) @@ -3061,6 +3062,7 @@ mymain(void) DO_TEST_GEN(qemuMonitorJSONDeleteBitmap); DO_TEST_GEN(qemuMonitorJSONJobDismiss); DO_TEST_GEN(qemuMonitorJSONJobCancel); + DO_TEST_GEN(qemuMonitorJSONJobComplete); DO_TEST(qemuMonitorJSONGetBalloonInfo); DO_TEST(qemuMonitorJSONGetBlockInfo); DO_TEST(qemuMonitorJSONGetAllBlockStatsInfo); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 17:42:32 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=1561391887; cv=none; d=zoho.com; s=zohoarc; b=A+qCG/yEZH8x4GWEVdC7kh+2yz1B2FcqY2qC1OduSgsNQ4KZmWKMWgFtI9sU5ko93teAZ4IAOvI6IU4lBm8UvKsDIUPFZ8MhRcj9WPBVXVPngLSAz0CKE2/fgMiQF+G7jTuqB0uSR4szBQbR7esuvR1YbzFHUKSaGd/VYvTZ60k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561391887; 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=3sV8vOgUbI3B12ieZgXhimktz4PXAinyJQOPHJOCT3g=; b=ILoH+Gche0yemmHoxOFN3I9guiKLxGpeShB4mOjA7aXjyjsR1jHtI9Q7XcR6YVnCDfhCA2ii+/jJ5p7pePMD9+33ldswj5Ka45s4Gpw6ZDd5+Gsh67IeNB2PlPcUn1VuS0rcv4LhS608otnO+ezoGMSM5EtuxMOelsJeu6D8lnE= 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 1561391887348461.73927688674394; Mon, 24 Jun 2019 08:58:07 -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 B08663688B; Mon, 24 Jun 2019 15:58:05 +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 87A9B1001B07; Mon, 24 Jun 2019 15:58:05 +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 45D2A206D2; Mon, 24 Jun 2019 15:58:05 +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 x5OFt5Kf014642 for ; Mon, 24 Jun 2019 11:55:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id 797D81001B05; Mon, 24 Jun 2019 15:55:05 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 034261001B04 for ; Mon, 24 Jun 2019 15:55:04 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 24 Jun 2019 17:54:54 +0200 Message-Id: <5bbac8937df2711e643f0970738441789b3bac94.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 7/9] qemu: monitor: Add infrastructure for 'query-jobs' 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.30]); Mon, 24 Jun 2019 15:58:06 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_monitor.c | 23 +++++ src/qemu/qemu_monitor.h | 49 +++++++++++ src/qemu/qemu_monitor_json.c | 79 +++++++++++++++++ src/qemu/qemu_monitor_json.h | 6 ++ .../query-jobs-create.json | 20 +++++ .../query-jobs-create.result | 11 +++ .../qemumonitorjsondata/query-jobs-empty.json | 1 + .../query-jobs-empty.result | 0 tests/qemumonitorjsontest.c | 85 +++++++++++++++++++ 9 files changed, 274 insertions(+) create mode 100644 tests/qemumonitorjsondata/query-jobs-create.json create mode 100644 tests/qemumonitorjsondata/query-jobs-create.result create mode 100644 tests/qemumonitorjsondata/query-jobs-empty.json create mode 100644 tests/qemumonitorjsondata/query-jobs-empty.result diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 3cd037fdba..c9dbc67f53 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -4584,3 +4584,26 @@ qemuMonitorDeleteBitmap(qemuMonitorPtr mon, return qemuMonitorJSONDeleteBitmap(mon, node, bitmap); } + + +void +qemuMonitorJobInfoFree(qemuMonitorJobInfoPtr job) +{ + if (!job) + return; + + VIR_FREE(job->id); + VIR_FREE(job->error); + VIR_FREE(job); +} + + +int +qemuMonitorGetJobInfo(qemuMonitorPtr mon, + qemuMonitorJobInfoPtr **jobs, + size_t *njobs) +{ + QEMU_CHECK_MONITOR(mon); + + return qemuMonitorJSONGetJobInfo(mon, jobs, njobs); +} diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index e3a3c212fd..4cbe185c5c 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -117,6 +117,48 @@ struct _qemuMonitorRdmaGidStatus { }; +typedef enum { + QEMU_MONITOR_JOB_TYPE_UNKNOWN, /* internal value, not exposed by qemu = */ + QEMU_MONITOR_JOB_TYPE_COMMIT, + QEMU_MONITOR_JOB_TYPE_STREAM, + QEMU_MONITOR_JOB_TYPE_MIRROR, + QEMU_MONITOR_JOB_TYPE_BACKUP, + QEMU_MONITOR_JOB_TYPE_CREATE, + QEMU_MONITOR_JOB_TYPE_LAST +} qemuMonitorJobType; + +VIR_ENUM_DECL(qemuMonitorJob); + +typedef enum { + QEMU_MONITOR_JOB_STATUS_UNKNOWN, /* internal value, not exposed by qem= u */ + QEMU_MONITOR_JOB_STATUS_CREATED, + QEMU_MONITOR_JOB_STATUS_RUNNING, + QEMU_MONITOR_JOB_STATUS_PAUSED, + QEMU_MONITOR_JOB_STATUS_READY, + QEMU_MONITOR_JOB_STATUS_STANDBY, + QEMU_MONITOR_JOB_STATUS_WAITING, + QEMU_MONITOR_JOB_STATUS_PENDING, + QEMU_MONITOR_JOB_STATUS_ABORTING, + QEMU_MONITOR_JOB_STATUS_CONCLUDED, + QEMU_MONITOR_JOB_STATUS_UNDEFINED, /* the job states below should not = be visible outside of qemu */ + QEMU_MONITOR_JOB_STATUS_NULL, + QEMU_MONITOR_JOB_STATUS_LAST +} qemuMonitorJobStatus; + +VIR_ENUM_DECL(qemuMonitorJobStatus); + +typedef struct _qemuMonitorJobInfo qemuMonitorJobInfo; +typedef qemuMonitorJobInfo *qemuMonitorJobInfoPtr; +struct _qemuMonitorJobInfo { + char *id; + qemuMonitorJobType type; + qemuMonitorJobStatus status; + char *error; + long long progressCurrent; + long long progressTotal; +}; + + char *qemuMonitorGuestPanicEventInfoFormatMsg(qemuMonitorEventPanicInfoPtr= info); void qemuMonitorEventPanicInfoFree(qemuMonitorEventPanicInfoPtr info); void qemuMonitorEventRdmaGidStatusFree(qemuMonitorRdmaGidStatusPtr info); @@ -1278,3 +1320,10 @@ struct _qemuMonitorCurrentMachineInfo { int qemuMonitorGetCurrentMachineInfo(qemuMonitorPtr mon, qemuMonitorCurrentMachineInfoPtr info= ); +void qemuMonitorJobInfoFree(qemuMonitorJobInfoPtr job); + +VIR_DEFINE_AUTOPTR_FUNC(qemuMonitorJobInfo, qemuMonitorJobInfoFree); + +int qemuMonitorGetJobInfo(qemuMonitorPtr mon, + qemuMonitorJobInfoPtr **jobs, + size_t *njobs); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 33ee026fe1..68780a5a4f 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -56,6 +56,14 @@ VIR_LOG_INIT("qemu.qemu_monitor_json"); #define LINE_ENDING "\r\n" +VIR_ENUM_IMPL(qemuMonitorJob, + QEMU_MONITOR_JOB_TYPE_LAST, + "", "commit", "stream", "mirror", "backup", "create"); +VIR_ENUM_IMPL(qemuMonitorJobStatus, + QEMU_MONITOR_JOB_STATUS_LAST, + "", "created", "running", "paused", "ready", "standby", "wai= ting", + "pending", "aborting", "concluded", "undefined", "null"); + static void qemuMonitorJSONHandleShutdown(qemuMonitorPtr mon, virJSONValue= Ptr data); static void qemuMonitorJSONHandleReset(qemuMonitorPtr mon, virJSONValuePtr= data); static void qemuMonitorJSONHandlePowerdown(qemuMonitorPtr mon, virJSONValu= ePtr data); @@ -9038,3 +9046,74 @@ qemuMonitorJSONDeleteBitmap(qemuMonitorPtr mon, virJSONValueFree(reply); return ret; } + + +static qemuMonitorJobInfoPtr +qemuMonitorJSONGetJobInfoOne(virJSONValuePtr data) +{ + const char *id =3D virJSONValueObjectGetString(data, "id"); + const char *type =3D virJSONValueObjectGetString(data, "type"); + const char *status =3D virJSONValueObjectGetString(data, "status"); + const char *errmsg =3D virJSONValueObjectGetString(data, "error"); + int tmp; + VIR_AUTOPTR(qemuMonitorJobInfo) job =3D NULL; + qemuMonitorJobInfoPtr ret =3D NULL; + + if (!data) + return NULL; + + if (VIR_ALLOC(job) < 0) + return NULL; + + if ((tmp =3D qemuMonitorJobTypeFromString(type)) < 0) + tmp =3D QEMU_MONITOR_JOB_TYPE_UNKNOWN; + + job->type =3D tmp; + + if ((tmp =3D qemuMonitorJobStatusTypeFromString(status)) < 0) + tmp =3D QEMU_MONITOR_JOB_STATUS_UNKNOWN; + + job->status =3D tmp; + + if (VIR_STRDUP(job->id, id) < 0 || + VIR_STRDUP(job->error, errmsg) < 0) + return NULL; + + VIR_STEAL_PTR(ret, job); + return ret; +} + + +int +qemuMonitorJSONGetJobInfo(qemuMonitorPtr mon, + qemuMonitorJobInfoPtr **jobs, + size_t *njobs) +{ + virJSONValuePtr data; + VIR_AUTOPTR(virJSONValue) cmd =3D NULL; + VIR_AUTOPTR(virJSONValue) reply =3D NULL; + size_t i; + + if (!(cmd =3D qemuMonitorJSONMakeCommand("query-jobs", NULL))) + return -1; + + if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) + return -1; + + if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0) + return -1; + + data =3D virJSONValueObjectGetArray(reply, "return"); + + for (i =3D 0; i < virJSONValueArraySize(data); i++) { + qemuMonitorJobInfoPtr job =3D NULL; + + if (!(job =3D qemuMonitorJSONGetJobInfoOne(virJSONValueArrayGet(da= ta, i)))) + return -1; + + if (VIR_APPEND_ELEMENT(*jobs, *njobs, job) < 0) + return -1; + } + + return 0; +} diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index c2b47e6129..a50d4d7b23 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -319,6 +319,12 @@ int qemuMonitorJSONBlockJobCancel(qemuMonitorPtr mon, const char *jobname) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); +int +qemuMonitorJSONGetJobInfo(qemuMonitorPtr mon, + qemuMonitorJobInfoPtr **jobs, + size_t *njobs); + + int qemuMonitorJSONBlockJobSetSpeed(qemuMonitorPtr mon, const char *jobname, unsigned long long speed) diff --git a/tests/qemumonitorjsondata/query-jobs-create.json b/tests/qemum= onitorjsondata/query-jobs-create.json new file mode 100644 index 0000000000..fbc7c4b15d --- /dev/null +++ b/tests/qemumonitorjsondata/query-jobs-create.json @@ -0,0 +1,20 @@ +{ + "return": [ + { + "current-progress": 1, + "status": "concluded", + "total-progress": 1, + "type": "create", + "id": "createjob-fail", + "error": "Image size must be a multiple of 512 bytes" + }, + { + "current-progress": 1, + "status": "concluded", + "total-progress": 1, + "type": "create", + "id": "createjob" + } + ], + "id": "libvirt-24" +} diff --git a/tests/qemumonitorjsondata/query-jobs-create.result b/tests/qem= umonitorjsondata/query-jobs-create.result new file mode 100644 index 0000000000..a43282fe67 --- /dev/null +++ b/tests/qemumonitorjsondata/query-jobs-create.result @@ -0,0 +1,11 @@ +[job] +id=3Dcreatejob-fail +type=3Dcreate +status=3Dconcluded +error=3DImage size must be a multiple of 512 bytes + +[job] +id=3Dcreatejob +type=3Dcreate +status=3Dconcluded +error=3D diff --git a/tests/qemumonitorjsondata/query-jobs-empty.json b/tests/qemumo= nitorjsondata/query-jobs-empty.json new file mode 100644 index 0000000000..c1ede999e5 --- /dev/null +++ b/tests/qemumonitorjsondata/query-jobs-empty.json @@ -0,0 +1 @@ +{ "return": [] } diff --git a/tests/qemumonitorjsondata/query-jobs-empty.result b/tests/qemu= monitorjsondata/query-jobs-empty.result new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 798b7beca3..171a7cc104 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -2925,6 +2925,79 @@ testQAPISchemaValidate(const void *opaque) } +static void +testQueryJobsPrintJob(virBufferPtr buf, + qemuMonitorJobInfoPtr job) +{ + virBufferAddLit(buf, "[job]\n"); + virBufferAsprintf(buf, "id=3D%s\n", NULLSTR(job->id)); + virBufferAsprintf(buf, "type=3D%s\n", NULLSTR(qemuMonitorJobTypeToStri= ng(job->type))); + virBufferAsprintf(buf, "status=3D%s\n", NULLSTR(qemuMonitorJobStatusTy= peToString(job->status))); + virBufferAsprintf(buf, "error=3D%s\n", NULLSTR(job->error)); + virBufferAddLit(buf, "\n"); +} + + +struct testQueryJobsData { + const char *name; + virDomainXMLOptionPtr xmlopt; +}; + + +static int +testQueryJobs(const void *opaque) +{ + const struct testQueryJobsData *data =3D opaque; + qemuMonitorTestPtr test =3D qemuMonitorTestNewSimple(data->xmlopt); + VIR_AUTOFREE(char *) filenameJSON =3D NULL; + VIR_AUTOFREE(char *) fileJSON =3D NULL; + VIR_AUTOFREE(char *) filenameResult =3D NULL; + VIR_AUTOFREE(char *) actual =3D NULL; + qemuMonitorJobInfoPtr *jobs =3D NULL; + virBuffer buf =3D VIR_BUFFER_INITIALIZER; + size_t njobs =3D 0; + size_t i; + int ret =3D -1; + + if (virAsprintf(&filenameJSON, + abs_srcdir "/qemumonitorjsondata/query-jobs-%s.json", + data->name) < 0 || + virAsprintf(&filenameResult, + abs_srcdir "/qemumonitorjsondata/query-jobs-%s.result", + data->name) < 0) + goto cleanup; + + if (virTestLoadFile(filenameJSON, &fileJSON) < 0) + goto cleanup; + + if (qemuMonitorTestAddItem(test, "query-jobs", fileJSON) < 0) + goto cleanup; + + if (qemuMonitorJSONGetJobInfo(qemuMonitorTestGetMonitor(test), + &jobs, &njobs) < 0) + goto cleanup; + + for (i =3D 0; i < njobs; i++) + testQueryJobsPrintJob(&buf, jobs[i]); + + virBufferTrim(&buf, "\n", -1); + + if (virBufferCheckError(&buf) < 0) + goto cleanup; + + actual =3D virBufferContentAndReset(&buf); + + if (virTestCompareToFile(actual, filenameResult) < 0) + goto cleanup; + + ret =3D 0; + + cleanup: + qemuMonitorTestFree(test); + return ret; +} + + static int mymain(void) { @@ -3199,6 +3272,18 @@ mymain(void) #undef DO_TEST_QAPI_VALIDATE +#define DO_TEST_QUERY_JOBS(name) \ + do { \ + struct testQueryJobsData data =3D { name, driver.xmlopt}; \ + if (virTestRun("query-jobs-" name, testQueryJobs, &data) < 0) \ + ret =3D -1; \ + } while (0) + + DO_TEST_QUERY_JOBS("empty"); + DO_TEST_QUERY_JOBS("create"); + +#undef DO_TEST_QUERY_JOBS + cleanup: VIR_FREE(metaschemastr); virJSONValueFree(metaschema); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 17:42:32 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=1561391891; cv=none; d=zoho.com; s=zohoarc; b=d4YMKUNZGf0w93lnn+mSiahdXsnvHYuBv1IQ5ifs9mqAhtWyaeNIJQCvFQ8PF8JG8mPCxw52wETllda0x6sqq110xy8Z7/MSQjkL0Q0Zo9ipL4oPak1kre0mAoVlLhAUQ2EWp2t/HaIb/Q3Ihk4JDWV2sNqPKdtQuwHmDdC2osU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561391891; 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=XdJPL2bE7OmWL7OcX4Qg7qTpJos1tUZYR2WkuIFRewM=; b=Z7uk7RKasKGxEvrHZrUYPRlID65dwG6tK19mWEApi9qvjEPNQjLGNWlRPLunJq2cSONA+DB+jImluKrFi7ZvAM4cchpSz0a/bPjA+D5SYSaQHVrXCIQTUwh8ATyUbNzHFXx/ss9p/QlHOAq+pkJXn8DgZH87ZiKk6ekphLh1Kc4= 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 1561391891933798.9626917809318; Mon, 24 Jun 2019 08:58:11 -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 555283082E64; Mon, 24 Jun 2019 15:58:10 +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 2E2701001B1B; Mon, 24 Jun 2019 15:58:10 +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 E0FC51806B1E; Mon, 24 Jun 2019 15:58:09 +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 x5OFt6kg014668 for ; Mon, 24 Jun 2019 11:55:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id 48B661001B05; Mon, 24 Jun 2019 15:55:06 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id C68ED1001B04 for ; Mon, 24 Jun 2019 15:55:05 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 24 Jun 2019 17:54:55 +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 Subject: [libvirt] [PATCH 8/9] qemu: monitor: Implement support for 'JOB_STATUS_CHANGE' event 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.46]); Mon, 24 Jun 2019 15:58:10 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This new event is a superset of the BLOCK_JOB* events and also covers jobs which don't bind to a VM disk. In this patch the monitor part is implemented. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_monitor.c | 13 +++++++++++++ src/qemu/qemu_monitor.h | 9 +++++++++ src/qemu/qemu_monitor_json.c | 26 ++++++++++++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index c9dbc67f53..9358d0b1e2 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -1503,6 +1503,19 @@ qemuMonitorEmitBlockJob(qemuMonitorPtr mon, } +int +qemuMonitorEmitJobStatusChange(qemuMonitorPtr mon, + const char *jobname, + qemuMonitorJobStatus status) +{ + int ret =3D -1; + VIR_DEBUG("mon=3D%p", mon); + + QEMU_MONITOR_CALLBACK(mon, ret, jobStatusChange, mon->vm, jobname, sta= tus); + return ret; +} + + int qemuMonitorEmitBalloonChange(qemuMonitorPtr mon, unsigned long long actual) diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 4cbe185c5c..c6dddd1e9e 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -230,6 +230,11 @@ typedef int (*qemuMonitorDomainBlockJobCallback)(qemuM= onitorPtr mon, int status, const char *error, void *opaque); +typedef int (*qemuMonitorDomainJobStatusChangeCallback)(qemuMonitorPtr mon, + virDomainObjPtr vm, + const char *jobnam= e, + int status, + void *opaque); typedef int (*qemuMonitorDomainTrayChangeCallback)(qemuMonitorPtr mon, virDomainObjPtr vm, const char *devAlias, @@ -357,6 +362,7 @@ struct _qemuMonitorCallbacks { qemuMonitorDomainIOErrorCallback domainIOError; qemuMonitorDomainGraphicsCallback domainGraphics; qemuMonitorDomainBlockJobCallback domainBlockJob; + qemuMonitorDomainJobStatusChangeCallback jobStatusChange; qemuMonitorDomainTrayChangeCallback domainTrayChange; qemuMonitorDomainPMWakeupCallback domainPMWakeup; qemuMonitorDomainPMSuspendCallback domainPMSuspend; @@ -467,6 +473,9 @@ int qemuMonitorEmitBlockJob(qemuMonitorPtr mon, int type, int status, const char *error); +int qemuMonitorEmitJobStatusChange(qemuMonitorPtr mon, + const char *jobname, + qemuMonitorJobStatus status); int qemuMonitorEmitBalloonChange(qemuMonitorPtr mon, unsigned long long actual); int qemuMonitorEmitPMSuspendDisk(qemuMonitorPtr mon); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 68780a5a4f..04538bc46c 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -84,6 +84,7 @@ static void qemuMonitorJSONHandlePMSuspend(qemuMonitorPtr= mon, virJSONValuePtr d static void qemuMonitorJSONHandleBlockJobCompleted(qemuMonitorPtr mon, vir= JSONValuePtr data); static void qemuMonitorJSONHandleBlockJobCanceled(qemuMonitorPtr mon, virJ= SONValuePtr data); static void qemuMonitorJSONHandleBlockJobReady(qemuMonitorPtr mon, virJSON= ValuePtr data); +static void qemuMonitorJSONHandleJobStatusChange(qemuMonitorPtr mon, virJS= ONValuePtr data); static void qemuMonitorJSONHandleBalloonChange(qemuMonitorPtr mon, virJSON= ValuePtr data); static void qemuMonitorJSONHandlePMSuspendDisk(qemuMonitorPtr mon, virJSON= ValuePtr data); static void qemuMonitorJSONHandleGuestPanic(qemuMonitorPtr mon, virJSONVal= uePtr data); @@ -116,6 +117,7 @@ static qemuEventHandler eventHandlers[] =3D { { "DEVICE_TRAY_MOVED", qemuMonitorJSONHandleTrayChange, }, { "DUMP_COMPLETED", qemuMonitorJSONHandleDumpCompleted, }, { "GUEST_PANICKED", qemuMonitorJSONHandleGuestPanic, }, + { "JOB_STATUS_CHANGE", qemuMonitorJSONHandleJobStatusChange, }, { "MIGRATION", qemuMonitorJSONHandleMigrationStatus, }, { "MIGRATION_PASS", qemuMonitorJSONHandleMigrationPass, }, { "NIC_RX_FILTER_CHANGED", qemuMonitorJSONHandleNicRxFilterChanged, }, @@ -1156,6 +1158,30 @@ qemuMonitorJSONHandleBlockJobImpl(qemuMonitorPtr mon, qemuMonitorEmitBlockJob(mon, device, type, event, error); } + +static void +qemuMonitorJSONHandleJobStatusChange(qemuMonitorPtr mon, + virJSONValuePtr data) +{ + const char *jobname =3D virJSONValueObjectGetString(data, "id"); + const char *statusstr =3D virJSONValueObjectGetString(data, "status"); + int status; + + if (!jobname) { + VIR_WARN("missing job name in JOB_STATUS_CHANGE event"); + return; + } + + if ((status =3D qemuMonitorJobStatusTypeFromString(statusstr)) < 0) { + VIR_WARN("unknown job status '%s' for job '%s' in JOB_STATUS_CHANG= E event", + statusstr, jobname); + return; + } + + qemuMonitorEmitJobStatusChange(mon, jobname, status); +} + + static void qemuMonitorJSONHandleTrayChange(qemuMonitorPtr mon, virJSONValuePtr data) --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 17:42:32 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=1561391965; cv=none; d=zoho.com; s=zohoarc; b=D2nYADaq7mHZuAH95jdQiSWCivTVC1/n1IWmml2ZVLv1hApYGAhP4HZFia8qjGs/0k2B8i6/FFAOVexgpLWDgdm8SJGU9t5hv/rQzlGOfeSwYwz6wiuzI9F8XcYnKjLMRKpfhOrBFnPjtUnks21zczeZPSRl72KuyXzoShiXpRQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561391965; 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=XMTWyqNdqu4nUS91YSF33WDwyAn5ckPXCDRelk6LrA8=; b=RNvL27mK36rfrt2QWN0T9py+vI/0SHbjizuhQE2rjf5APsm+V6VszxxBHxdYi71p29E+k9MFVmIIdfxaz6MN+kM8MeocWdnR5VF5Y6oFyv1Lfgp8wgrzBxllEgwcl99djFshfOJI2Oxhg2ahedQHUXbuueqJ9+EK9Ka7fCeg/Lc= 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 1561391965387922.0237221809931; Mon, 24 Jun 2019 08:59:25 -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 C4EC130872EE; Mon, 24 Jun 2019 15:59:23 +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 7DD381001B05; Mon, 24 Jun 2019 15:59:22 +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 36F35206D2; Mon, 24 Jun 2019 15:59:22 +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 x5OFt73u014692 for ; Mon, 24 Jun 2019 11:55:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id 159A41001B19; Mon, 24 Jun 2019 15:55:07 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 953961001B04 for ; Mon, 24 Jun 2019 15:55:06 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 24 Jun 2019 17:54:56 +0200 Message-Id: <98c17764ee063a5738f4ad8b8b60cf56d1730906.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 9/9] qemu: monitor: Add APIs for 'blockdev-create' 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.47]); Mon, 24 Jun 2019 15:59:24 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The 'blockdev-create' starts a job which creates a storage volume using the given protocol or formats an existing (added) volume with one of the supported storage formats. This patch adds the monitor interaction bits. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_monitor.c | 30 ++++++++++++++++++++++++++++++ src/qemu/qemu_monitor.h | 4 ++++ src/qemu/qemu_monitor_json.c | 26 ++++++++++++++++++++++++++ src/qemu/qemu_monitor_json.h | 5 +++++ 4 files changed, 65 insertions(+) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 9358d0b1e2..90cd5ea9bd 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -4418,6 +4418,36 @@ qemuMonitorSetWatchdogAction(qemuMonitorPtr mon, } +/** + * qemuMonitorBlockdevCreate: + * @mon: monitor object + * @jobname: name of the job + * @props: JSON object describing the blockdev to add + * + * Instructs qemu to create/format a new stroage or format layer. Note that + * the job does not add the created/formatted image into qemu and + * qemuMonitorBlockdevAdd needs to be called separately with corresponding + * arguments. Note that the argumetns for creating and adding are differen= t. + * + * Note that @props is always consumed by this function and should not be + * accessed after calling this function. + */ +int +qemuMonitorBlockdevCreate(qemuMonitorPtr mon, + const char *jobname, + virJSONValuePtr props) +{ + VIR_DEBUG("jobname=3D%s props=3D%p", jobname, props); + + QEMU_CHECK_MONITOR_GOTO(mon, error); + + return qemuMonitorJSONBlockdevCreate(mon, jobname, props); + + error: + virJSONValueFree(props); + return -1; +} + /** * qemuMonitorBlockdevAdd: * @mon: monitor object diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index c6dddd1e9e..aafea6350c 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1289,6 +1289,10 @@ virJSONValuePtr qemuMonitorQueryNamedBlockNodes(qemu= MonitorPtr mon); int qemuMonitorSetWatchdogAction(qemuMonitorPtr mon, const char *action); +int qemuMonitorBlockdevCreate(qemuMonitorPtr mon, + const char *jobname, + virJSONValuePtr props); + int qemuMonitorBlockdevAdd(qemuMonitorPtr mon, virJSONValuePtr props); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 04538bc46c..22fbd84e90 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -8616,6 +8616,32 @@ qemuMonitorJSONSetWatchdogAction(qemuMonitorPtr mon, } +int +qemuMonitorJSONBlockdevCreate(qemuMonitorPtr mon, + const char *jobname, + virJSONValuePtr props) +{ + VIR_AUTOPTR(virJSONValue) cmd =3D NULL; + VIR_AUTOPTR(virJSONValue) reply =3D NULL; + + cmd =3D qemuMonitorJSONMakeCommand("blockdev-create", + "s:job-id", jobname, + "a:options", &props, + NULL); + virJSONValueFree(props); + if (!cmd) + return -1; + + if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) + return -1; + + if (qemuMonitorJSONCheckError(cmd, reply) < 0) + return -1; + + return 0; +} + + int qemuMonitorJSONBlockdevAdd(qemuMonitorPtr mon, virJSONValuePtr props) diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index a50d4d7b23..00e6b3d68f 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -580,6 +580,11 @@ int qemuMonitorJSONSetWatchdogAction(qemuMonitorPtr mo= n, const char *action) ATTRIBUTE_NONNULL(1); +int qemuMonitorJSONBlockdevCreate(qemuMonitorPtr mon, + const char *jobname, + virJSONValuePtr props) + ATTRIBUTE_NONNULL(1); + int qemuMonitorJSONBlockdevAdd(qemuMonitorPtr mon, virJSONValuePtr props) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list