From nobody Mon Apr 29 19:39:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1534333995522802.4074433104536; Wed, 15 Aug 2018 04:53:15 -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 6A1C430832E0; Wed, 15 Aug 2018 11:53:13 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 341175D9C6; Wed, 15 Aug 2018 11:53:12 +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 C72CD18037F4; Wed, 15 Aug 2018 11:53:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w7FBr3ph010043 for ; Wed, 15 Aug 2018 07:53:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id E57512027047; Wed, 15 Aug 2018 11:53:02 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 84E332026D7E for ; Wed, 15 Aug 2018 11:53:02 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 15 Aug 2018 13:52:52 +0200 Message-Id: <507f76772c3547c31cf5ca91f092fc48ea826eef.1534333853.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/8] qemu: monitor: Remove error classes not conforming to QAPI schema X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Wed, 15 Aug 2018 11:53:13 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Both were removed prior to qemu v1.2.0-rc0 when switching to the new error format where almost all error types were converted to GenericError. Relevant qemu commits are and Signed-off-by: Peter Krempa Reviewed-by: John Ferlan --- src/qemu/qemu_monitor_json.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 2921f110a9..7bb3e85229 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -4670,12 +4670,6 @@ qemuMonitorJSONBlockJobError(virJSONValuePtr reply, if (qemuMonitorJSONErrorIsClass(error, "DeviceNotActive")) { virReportError(VIR_ERR_OPERATION_INVALID, _("No active operation on device: %s"), device); - } else if (qemuMonitorJSONErrorIsClass(error, "DeviceInUse")) { - virReportError(VIR_ERR_OPERATION_FAILED, - _("Device %s in use"), device); - } else if (qemuMonitorJSONErrorIsClass(error, "NotSupported")) { - virReportError(VIR_ERR_OPERATION_INVALID, - _("Operation is not supported for device: %s"), dev= ice); } else if (qemuMonitorJSONErrorIsClass(error, "CommandNotFound")) { virReportError(VIR_ERR_OPERATION_INVALID, _("Command '%s' is not found"), cmd_name); --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 19:39:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1534333989948748.5882289932582; Wed, 15 Aug 2018 04:53:09 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B294F5D678; Wed, 15 Aug 2018 11:53:07 +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 A2DDE308BDAC; Wed, 15 Aug 2018 11:53: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 398C718037F0; Wed, 15 Aug 2018 11:53:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w7FBr3WL010048 for ; Wed, 15 Aug 2018 07:53:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id 935472027047; Wed, 15 Aug 2018 11:53:03 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 31AC22026D7E for ; Wed, 15 Aug 2018 11:53:03 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 15 Aug 2018 13:52:53 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/8] qemu: monitor: Use qemuMonitorJSONCheckError in qemuMonitorJSONBlockJobError X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 15 Aug 2018 11:53:08 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Report the generic errors using the existing function so that we don't reimplement the same functionality multiple times. Signed-off-by: Peter Krempa Reviewed-by: John Ferlan --- src/qemu/qemu_monitor_json.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 7bb3e85229..a361a0acd9 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -4658,29 +4658,20 @@ qemuMonitorJSONGetAllBlockJobInfo(qemuMonitorPtr mo= n) static int -qemuMonitorJSONBlockJobError(virJSONValuePtr reply, - const char *cmd_name, +qemuMonitorJSONBlockJobError(virJSONValuePtr cmd, + virJSONValuePtr reply, const char *device) { virJSONValuePtr error; - if (!(error =3D virJSONValueObjectGet(reply, "error"))) - return 0; - - if (qemuMonitorJSONErrorIsClass(error, "DeviceNotActive")) { + if ((error =3D virJSONValueObjectGet(reply, "error")) && + (qemuMonitorJSONErrorIsClass(error, "DeviceNotActive"))) { virReportError(VIR_ERR_OPERATION_INVALID, _("No active operation on device: %s"), device); - } else if (qemuMonitorJSONErrorIsClass(error, "CommandNotFound")) { - virReportError(VIR_ERR_OPERATION_INVALID, - _("Command '%s' is not found"), cmd_name); - } else { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unexpected error: (%s) '%s'"), - NULLSTR(virJSONValueObjectGetString(error, "class")= ), - NULLSTR(virJSONValueObjectGetString(error, "desc"))= ); + return -1; } - return -1; + return qemuMonitorJSONCheckError(cmd, reply); } @@ -4708,7 +4699,7 @@ qemuMonitorJSONBlockStream(qemuMonitorPtr mon, if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) goto cleanup; - if (qemuMonitorJSONBlockJobError(reply, cmd_name, device) < 0) + if (qemuMonitorJSONBlockJobError(cmd, reply, device) < 0) goto cleanup; ret =3D 0; @@ -4737,7 +4728,7 @@ qemuMonitorJSONBlockJobCancel(qemuMonitorPtr mon, if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) goto cleanup; - if (qemuMonitorJSONBlockJobError(reply, cmd_name, device) < 0) + if (qemuMonitorJSONBlockJobError(cmd, reply, device) < 0) goto cleanup; ret =3D 0; @@ -4768,7 +4759,7 @@ qemuMonitorJSONBlockJobSetSpeed(qemuMonitorPtr mon, if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) goto cleanup; - if (qemuMonitorJSONBlockJobError(reply, cmd_name, device) < 0) + if (qemuMonitorJSONBlockJobError(cmd, reply, device) < 0) goto cleanup; ret =3D 0; --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 19:39:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1534333996439135.43703051021157; Wed, 15 Aug 2018 04:53:16 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EBC3231500BD; Wed, 15 Aug 2018 11:53:12 +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 B69885D6A8; Wed, 15 Aug 2018 11:53:11 +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 5E41E4A465; Wed, 15 Aug 2018 11:53:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w7FBr4Af010056 for ; Wed, 15 Aug 2018 07:53:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id 404202027047; Wed, 15 Aug 2018 11:53:04 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id D39902026D7E for ; Wed, 15 Aug 2018 11:53:03 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 15 Aug 2018 13:52:54 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/8] qemu: monitor: Remove temporary variables X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Wed, 15 Aug 2018 11:53:14 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Now that the job name is used in single place in the respective functions remove the temporary strings. Signed-off-by: Peter Krempa Reviewed-by: John Ferlan --- src/qemu/qemu_monitor_json.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index a361a0acd9..931d3dd985 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -4686,9 +4686,8 @@ qemuMonitorJSONBlockStream(qemuMonitorPtr mon, int ret =3D -1; virJSONValuePtr cmd =3D NULL; virJSONValuePtr reply =3D NULL; - const char *cmd_name =3D "block-stream"; - if (!(cmd =3D qemuMonitorJSONMakeCommand(cmd_name, + if (!(cmd =3D qemuMonitorJSONMakeCommand("block-stream", "s:device", device, "Y:speed", speed, "S:base", base, @@ -4718,9 +4717,8 @@ qemuMonitorJSONBlockJobCancel(qemuMonitorPtr mon, int ret =3D -1; virJSONValuePtr cmd =3D NULL; virJSONValuePtr reply =3D NULL; - const char *cmd_name =3D "block-job-cancel"; - if (!(cmd =3D qemuMonitorJSONMakeCommand(cmd_name, + if (!(cmd =3D qemuMonitorJSONMakeCommand("block-job-cancel", "s:device", device, NULL))) return -1; @@ -4748,9 +4746,8 @@ qemuMonitorJSONBlockJobSetSpeed(qemuMonitorPtr mon, int ret =3D -1; virJSONValuePtr cmd; virJSONValuePtr reply =3D NULL; - const char *cmd_name =3D "block-job-set-speed"; - if (!(cmd =3D qemuMonitorJSONMakeCommand(cmd_name, + if (!(cmd =3D qemuMonitorJSONMakeCommand("block-job-set-speed", "s:device", device, "J:speed", speed, NULL))) --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 19:39:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1534333991447819.4806320322455; Wed, 15 Aug 2018 04:53:11 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 67BEF30832DE; Wed, 15 Aug 2018 11:53:09 +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 2939D3001A70; Wed, 15 Aug 2018 11:53:08 +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 CAA184A460; Wed, 15 Aug 2018 11:53:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w7FBr5Rb010063 for ; Wed, 15 Aug 2018 07:53:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id E26C92027047; Wed, 15 Aug 2018 11:53:04 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 80C472026D7E for ; Wed, 15 Aug 2018 11:53:04 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 15 Aug 2018 13:52:55 +0200 Message-Id: <5158fdef104ebbd422352140f0b6f6d1ebeb3ce7.1534333853.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/8] qemu: monitor: Use qemuMonitorJSONCheckError in qemuMonitorJSONBlockStream X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Wed, 15 Aug 2018 11:53:10 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The API does not report any special job-related error so the generic error function should be used. Signed-off-by: Peter Krempa Reviewed-by: John Ferlan --- src/qemu/qemu_monitor_json.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 931d3dd985..a1c0d5fc15 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -4698,7 +4698,7 @@ qemuMonitorJSONBlockStream(qemuMonitorPtr mon, if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) goto cleanup; - if (qemuMonitorJSONBlockJobError(cmd, reply, device) < 0) + if (qemuMonitorJSONCheckError(cmd, reply) < 0) goto cleanup; ret =3D 0; --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 19:39:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1534333996578965.3929418867049; Wed, 15 Aug 2018 04:53:16 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 94E97C04AC4D; Wed, 15 Aug 2018 11:53:13 +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 5FD023001A41; Wed, 15 Aug 2018 11:53:13 +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 072244A46D; Wed, 15 Aug 2018 11:53:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w7FBr521010068 for ; Wed, 15 Aug 2018 07:53:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id 901132027047; Wed, 15 Aug 2018 11:53:05 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2EC782026D7E for ; Wed, 15 Aug 2018 11:53:05 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 15 Aug 2018 13:52:56 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 5/8] qemu: monitor: Move qemuMonitorJSONDrivePivot together with block-job APIs X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 15 Aug 2018 11:53:14 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Move all relevant APIs dealing with existing jobs together. Signed-off-by: Peter Krempa Reviewed-by: John Ferlan --- src/qemu/qemu_monitor_json.c | 55 ++++++++++++++++++++++------------------= ---- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index a1c0d5fc15..fed2f50e28 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -4288,33 +4288,6 @@ qemuMonitorJSONBlockCommit(qemuMonitorPtr mon, const= char *device, return ret; } -int -qemuMonitorJSONDrivePivot(qemuMonitorPtr mon, - const char *device) -{ - int ret =3D -1; - virJSONValuePtr cmd; - virJSONValuePtr reply =3D NULL; - - cmd =3D qemuMonitorJSONMakeCommand("block-job-complete", - "s:device", device, - NULL); - if (!cmd) - return -1; - - if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; - - if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; - - ret =3D 0; - cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); - return ret; -} - static char * qemuMonitorJSONDiskNameLookupOne(virJSONValuePtr image, @@ -4768,6 +4741,34 @@ qemuMonitorJSONBlockJobSetSpeed(qemuMonitorPtr mon, } +int +qemuMonitorJSONDrivePivot(qemuMonitorPtr mon, + const char *device) +{ + int ret =3D -1; + virJSONValuePtr cmd; + virJSONValuePtr reply =3D NULL; + + cmd =3D qemuMonitorJSONMakeCommand("block-job-complete", + "s:device", device, + NULL); + if (!cmd) + return -1; + + if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) + goto cleanup; + + if (qemuMonitorJSONCheckError(cmd, reply) < 0) + goto cleanup; + + ret =3D 0; + cleanup: + virJSONValueFree(cmd); + virJSONValueFree(reply); + return ret; +} + + int qemuMonitorJSONOpenGraphics(qemuMonitorPtr mon, const char *protocol, const char *fdname, --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 19:39:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1534334005414453.8518241916745; Wed, 15 Aug 2018 04:53: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 CFA6813A9E; Wed, 15 Aug 2018 11:53:22 +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 8FEED1073022; Wed, 15 Aug 2018 11:53: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 13EAC18037FA; Wed, 15 Aug 2018 11:53:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w7FBr6lC010073 for ; Wed, 15 Aug 2018 07:53:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id 43B2F2027047; Wed, 15 Aug 2018 11:53:06 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id D72C02026D7E for ; Wed, 15 Aug 2018 11:53:05 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 15 Aug 2018 13:52:57 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 6/8] qemu: monitor: Use qemuMonitorJSONBlockJobError in qemuMonitorJSONDrivePivot X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 15 Aug 2018 11:53:23 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The API deals with a block job so use the common error reporting function for it. Signed-off-by: Peter Krempa Reviewed-by: John Ferlan --- src/qemu/qemu_monitor_json.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index fed2f50e28..670089b87c 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -4758,7 +4758,7 @@ qemuMonitorJSONDrivePivot(qemuMonitorPtr mon, if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) goto cleanup; - if (qemuMonitorJSONCheckError(cmd, reply) < 0) + if (qemuMonitorJSONBlockJobError(cmd, reply, device) < 0) goto cleanup; ret =3D 0; --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 19:39:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1534333999046147.48606086404652; Wed, 15 Aug 2018 04:53:19 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0C947300270F; Wed, 15 Aug 2018 11:53:17 +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 C216418111; Wed, 15 Aug 2018 11:53:16 +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 2152818037F5; Wed, 15 Aug 2018 11:53:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w7FBr7cf010079 for ; Wed, 15 Aug 2018 07:53:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id E53472027047; Wed, 15 Aug 2018 11:53:06 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8468F2026D7E for ; Wed, 15 Aug 2018 11:53:06 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 15 Aug 2018 13:52:58 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 7/8] qemu: monitor: Rename 'device' argument for block job control APIs X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Wed, 15 Aug 2018 11:53:17 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Starting from qemu 2.7 the 'device' argument is in fact a name of the job itself. Change our APIs accordingly and adjust the error message. Signed-off-by: Peter Krempa Reviewed-by: John Ferlan --- src/qemu/qemu_monitor.c | 18 +++++++++--------- src/qemu/qemu_monitor.h | 6 +++--- src/qemu/qemu_monitor_json.c | 22 +++++++++++----------- src/qemu/qemu_monitor_json.h | 6 +++--- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 6e0644221b..9bc7aa9ed1 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3306,13 +3306,13 @@ qemuMonitorDiskNameLookup(qemuMonitorPtr mon, /* Use the block-job-complete monitor command to pivot a block copy job. = */ int qemuMonitorDrivePivot(qemuMonitorPtr mon, - const char *device) + const char *jobname) { - VIR_DEBUG("device=3D%s", device); + VIR_DEBUG("jobname=3D%s", jobname); QEMU_CHECK_MONITOR(mon); - return qemuMonitorJSONDrivePivot(mon, device); + return qemuMonitorJSONDrivePivot(mon, jobname); } @@ -3386,26 +3386,26 @@ qemuMonitorBlockStream(qemuMonitorPtr mon, int qemuMonitorBlockJobCancel(qemuMonitorPtr mon, - const char *device) + const char *jobname) { - VIR_DEBUG("device=3D%s", device); + VIR_DEBUG("jobname=3D%s", jobname); QEMU_CHECK_MONITOR(mon); - return qemuMonitorJSONBlockJobCancel(mon, device); + return qemuMonitorJSONBlockJobCancel(mon, jobname); } int qemuMonitorBlockJobSetSpeed(qemuMonitorPtr mon, - const char *device, + const char *jobname, unsigned long long bandwidth) { - VIR_DEBUG("device=3D%s, bandwidth=3D%lluB", device, bandwidth); + VIR_DEBUG("jobname=3D%s, bandwidth=3D%lluB", jobname, bandwidth); QEMU_CHECK_MONITOR(mon); - return qemuMonitorJSONBlockJobSetSpeed(mon, device, bandwidth); + return qemuMonitorJSONBlockJobSetSpeed(mon, jobname, bandwidth); } diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 2fa8d5b51d..ac41827693 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -861,7 +861,7 @@ int qemuMonitorBlockdevMirror(qemuMonitorPtr mon, unsigned int flags) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4); int qemuMonitorDrivePivot(qemuMonitorPtr mon, - const char *device) + const char *jobname) ATTRIBUTE_NONNULL(2); int qemuMonitorBlockCommit(qemuMonitorPtr mon, @@ -903,11 +903,11 @@ int qemuMonitorBlockStream(qemuMonitorPtr mon, ATTRIBUTE_NONNULL(2); int qemuMonitorBlockJobCancel(qemuMonitorPtr mon, - const char *device) + const char *jobname) ATTRIBUTE_NONNULL(2); int qemuMonitorBlockJobSetSpeed(qemuMonitorPtr mon, - const char *device, + const char *jobname, unsigned long long bandwidth); typedef struct _qemuMonitorBlockJobInfo qemuMonitorBlockJobInfo; diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 670089b87c..51b1fddccf 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -4633,14 +4633,14 @@ qemuMonitorJSONGetAllBlockJobInfo(qemuMonitorPtr mo= n) static int qemuMonitorJSONBlockJobError(virJSONValuePtr cmd, virJSONValuePtr reply, - const char *device) + const char *jobname) { virJSONValuePtr error; if ((error =3D virJSONValueObjectGet(reply, "error")) && (qemuMonitorJSONErrorIsClass(error, "DeviceNotActive"))) { virReportError(VIR_ERR_OPERATION_INVALID, - _("No active operation on device: %s"), device); + _("No active block job '%s'"), jobname); return -1; } @@ -4685,21 +4685,21 @@ qemuMonitorJSONBlockStream(qemuMonitorPtr mon, int qemuMonitorJSONBlockJobCancel(qemuMonitorPtr mon, - const char *device) + const char *jobname) { int ret =3D -1; virJSONValuePtr cmd =3D NULL; virJSONValuePtr reply =3D NULL; if (!(cmd =3D qemuMonitorJSONMakeCommand("block-job-cancel", - "s:device", device, + "s:device", jobname, NULL))) return -1; if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) goto cleanup; - if (qemuMonitorJSONBlockJobError(cmd, reply, device) < 0) + if (qemuMonitorJSONBlockJobError(cmd, reply, jobname) < 0) goto cleanup; ret =3D 0; @@ -4713,7 +4713,7 @@ qemuMonitorJSONBlockJobCancel(qemuMonitorPtr mon, int qemuMonitorJSONBlockJobSetSpeed(qemuMonitorPtr mon, - const char *device, + const char *jobname, unsigned long long speed) { int ret =3D -1; @@ -4721,7 +4721,7 @@ qemuMonitorJSONBlockJobSetSpeed(qemuMonitorPtr mon, virJSONValuePtr reply =3D NULL; if (!(cmd =3D qemuMonitorJSONMakeCommand("block-job-set-speed", - "s:device", device, + "s:device", jobname, "J:speed", speed, NULL))) return -1; @@ -4729,7 +4729,7 @@ qemuMonitorJSONBlockJobSetSpeed(qemuMonitorPtr mon, if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) goto cleanup; - if (qemuMonitorJSONBlockJobError(cmd, reply, device) < 0) + if (qemuMonitorJSONBlockJobError(cmd, reply, jobname) < 0) goto cleanup; ret =3D 0; @@ -4743,14 +4743,14 @@ qemuMonitorJSONBlockJobSetSpeed(qemuMonitorPtr mon, int qemuMonitorJSONDrivePivot(qemuMonitorPtr mon, - const char *device) + const char *jobname) { int ret =3D -1; virJSONValuePtr cmd; virJSONValuePtr reply =3D NULL; cmd =3D qemuMonitorJSONMakeCommand("block-job-complete", - "s:device", device, + "s:device", jobname, NULL); if (!cmd) return -1; @@ -4758,7 +4758,7 @@ qemuMonitorJSONDrivePivot(qemuMonitorPtr mon, if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) goto cleanup; - if (qemuMonitorJSONBlockJobError(cmd, reply, device) < 0) + if (qemuMonitorJSONBlockJobError(cmd, reply, jobname) < 0) goto cleanup; ret =3D 0; diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 2408ab0c5b..013bee3364 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -264,7 +264,7 @@ int qemuMonitorJSONBlockdevMirror(qemuMonitorPtr mon, unsigned int flags) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4); int qemuMonitorJSONDrivePivot(qemuMonitorPtr mon, - const char *device) + const char *jobname) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); int qemuMonitorJSONBlockCommit(qemuMonitorPtr mon, @@ -307,11 +307,11 @@ int qemuMonitorJSONBlockStream(qemuMonitorPtr mon, ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); int qemuMonitorJSONBlockJobCancel(qemuMonitorPtr mon, - const char *device) + const char *jobname) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); int qemuMonitorJSONBlockJobSetSpeed(qemuMonitorPtr mon, - const char *device, + const char *jobname, unsigned long long speed) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 19:39:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1534334000461905.5329671958461; Wed, 15 Aug 2018 04:53:20 -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 5D097308625C; Wed, 15 Aug 2018 11:53:18 +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 1EC93600C4; Wed, 15 Aug 2018 11:53:18 +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 A086618037F8; Wed, 15 Aug 2018 11:53:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w7FBr7nI010087 for ; Wed, 15 Aug 2018 07:53:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9213A2027047; Wed, 15 Aug 2018 11:53:07 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3166D2026D7E for ; Wed, 15 Aug 2018 11:53:07 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 15 Aug 2018 13:52:59 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 8/8] qemu: monitor: Separate probing for active block commit X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Wed, 15 Aug 2018 11:53:18 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Extract the code used to probe for the functionality so that it does not litter the code used for actual work. Signed-off-by: Peter Krempa Reviewed-by: John Ferlan --- src/qemu/qemu_monitor.c | 2 +- src/qemu/qemu_monitor_json.c | 58 ++++++++++++++++++++++++++--------------= ---- src/qemu/qemu_monitor_json.h | 3 +++ 3 files changed, 39 insertions(+), 24 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 9bc7aa9ed1..a60e78d967 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3285,7 +3285,7 @@ qemuMonitorSupportsActiveCommit(qemuMonitorPtr mon) if (!mon || !mon->json) return false; - return qemuMonitorJSONBlockCommit(mon, "bogus", NULL, NULL, NULL, 0) = =3D=3D -2; + return qemuMonitorJSONSupportsActiveCommit(mon); } diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 51b1fddccf..68ef9b3ae4 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -4231,14 +4231,42 @@ qemuMonitorJSONTransaction(qemuMonitorPtr mon, virJ= SONValuePtr *actions) return ret; } +/* Probe if active commit is supported: pass in a bogus device and NULL top + * and base. The probe return is true if active commit is detected or fal= se + * if not supported or on any error */ +bool +qemuMonitorJSONSupportsActiveCommit(qemuMonitorPtr mon) +{ + bool ret =3D false; + virJSONValuePtr cmd; + virJSONValuePtr reply =3D NULL; + + if (!(cmd =3D qemuMonitorJSONMakeCommand("block-commit", "s:device", + "bogus", NULL))) + return false; + + if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) + goto cleanup; + + if (qemuMonitorJSONHasError(reply, "DeviceNotFound")) { + VIR_DEBUG("block-commit supports active commit"); + ret =3D true; + goto cleanup; + } + + /* This is a false negative for qemu 2.0; but probably not + * worth the additional complexity to worry about it */ + VIR_DEBUG("block-commit requires 'top' parameter, " + "assuming it lacks active commit"); + cleanup: + virJSONValueFree(cmd); + virJSONValueFree(reply); + return ret; +} + + /* speed is in bytes/sec. Returns 0 on success, -1 with error message - * emitted on failure. - * - * Additionally, can be used to probe if active commit is supported: - * pass in a bogus device and NULL top and base. The probe return is - * -2 if active commit is detected, -3 if inconclusive; with no error - * message issued. - */ + * emitted on failure. */ int qemuMonitorJSONBlockCommit(qemuMonitorPtr mon, const char *device, const char *top, const char *base, @@ -4261,22 +4289,6 @@ qemuMonitorJSONBlockCommit(qemuMonitorPtr mon, const= char *device, if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) goto cleanup; - if (!top && !base) { - /* Normally we always specify top and base; but omitting them - * allows for probing whether qemu is new enough to support - * live commit. */ - if (qemuMonitorJSONHasError(reply, "DeviceNotFound")) { - VIR_DEBUG("block-commit supports active commit"); - ret =3D -2; - } else { - /* This is a false negative for qemu 2.0; but probably not - * worth the additional complexity to worry about it */ - VIR_DEBUG("block-commit requires 'top' parameter, " - "assuming it lacks active commit"); - ret =3D -3; - } - goto cleanup; - } if (qemuMonitorJSONCheckError(cmd, reply) < 0) goto cleanup; diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 013bee3364..6930ef34c4 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -267,6 +267,9 @@ int qemuMonitorJSONDrivePivot(qemuMonitorPtr mon, const char *jobname) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); +bool qemuMonitorJSONSupportsActiveCommit(qemuMonitorPtr mon) + ATTRIBUTE_NONNULL(1); + int qemuMonitorJSONBlockCommit(qemuMonitorPtr mon, const char *device, const char *top, --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list