From nobody Sun Feb 8 21:06:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) client-ip=209.132.183.24; envelope-from=libvir-list-bounces@redhat.com; helo=mx3-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by mx.zohomail.com with SMTPS id 1487878077319777.3310488944271; Thu, 23 Feb 2017 11:27:57 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1NJOWH9002219; Thu, 23 Feb 2017 14:24:32 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1NJLMQR001374 for ; Thu, 23 Feb 2017 14:21:22 -0500 Received: from angien.brq.redhat.com (dhcp129-47.brq.redhat.com [10.34.129.47]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1NJL8ue028635; Thu, 23 Feb 2017 14:21:22 -0500 From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 23 Feb 2017 20:22:04 +0100 Message-Id: <15c45a476227dc761b8b5bb7d054bb23e68c9ede.1487877253.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [RFC PATCH 11/12] qemu: implement qemuDomainSetBlockThreshold 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add code to call the appropriate monitor command and code to lookup the given disk backing chain member. --- src/qemu/qemu_driver.c | 64 ++++++++++++++++++++++++++++++++++++++++= ++++ src/qemu/qemu_monitor.c | 13 +++++++++ src/qemu/qemu_monitor.h | 5 ++++ src/qemu/qemu_monitor_json.c | 31 +++++++++++++++++++++ src/qemu/qemu_monitor_json.h | 6 +++++ 5 files changed, 119 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 6e1e3d408..279a0033d 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -20283,6 +20283,69 @@ qemuDomainSetVcpu(virDomainPtr dom, } +static int +qemuDomainSetBlockThreshold(virDomainPtr dom, + const char *dev, + unsigned long long threshold, + unsigned int flags) +{ + virQEMUDriverPtr driver =3D dom->conn->privateData; + qemuDomainObjPrivatePtr priv; + virDomainObjPtr vm =3D NULL; + virStorageSourcePtr src; + char *nodename =3D NULL; + int rc; + int ret =3D -1; + + virCheckFlags(0, -1); + + if (!(vm =3D qemuDomObjFromDomain(dom))) + goto cleanup; + + priv =3D vm->privateData; + + if (virDomainSetBlockThresholdEnsureACL(dom->conn, vm->def) < 0) + goto cleanup; + + if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) + goto cleanup; + + if (!virDomainObjIsActive(vm)) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("domain is not running")); + goto endjob; + } + + if (!(src =3D qemuDomainGetStorageSourceByDevstr(dev, vm->def))) + goto endjob; + + if (!src->nodeName) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("threshold currently can't be set for block devic= e '%s'"), + dev); + goto endjob; + } + + if (VIR_STRDUP(nodename, src->nodeName) < 0) + goto endjob; + + qemuDomainObjEnterMonitor(driver, vm); + rc =3D qemuMonitorSetBlockThreshold(priv->mon, nodename, threshold); + if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) + goto endjob; + + ret =3D 0; + + endjob: + qemuDomainObjEndJob(driver, vm); + + cleanup: + VIR_FREE(nodename); + virDomainObjEndAPI(&vm); + return ret; +} + + static virHypervisorDriver qemuHypervisorDriver =3D { .name =3D QEMU_DRIVER_NAME, .connectOpen =3D qemuConnectOpen, /* 0.2.0 */ @@ -20497,6 +20560,7 @@ static virHypervisorDriver qemuHypervisorDriver =3D= { .domainGetGuestVcpus =3D qemuDomainGetGuestVcpus, /* 2.0.0 */ .domainSetGuestVcpus =3D qemuDomainSetGuestVcpus, /* 2.0.0 */ .domainSetVcpu =3D qemuDomainSetVcpu, /* 3.1.0 */ + .domainSetBlockThreshold =3D qemuDomainSetBlockThreshold /* 3.1.0 */ }; diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index a8e113f94..7caced7fe 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -4150,3 +4150,16 @@ qemuMonitorQueryQMPSchema(qemuMonitorPtr mon) return qemuMonitorJSONQueryQMPSchema(mon); } + + +int +qemuMonitorSetBlockThreshold(qemuMonitorPtr mon, + const char *nodename, + unsigned long long threshold) +{ + VIR_DEBUG("mon=3D%p, node=3D'%s', threshold=3D%llu", mon, nodename, th= reshold); + + QEMU_CHECK_MONITOR_JSON(mon); + + return qemuMonitorJSONSetBlockThreshold(mon, nodename, threshold); +} diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index a866685e9..ef5c2fdc8 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1047,4 +1047,9 @@ int qemuMonitorGetRTCTime(qemuMonitorPtr mon, virHashTablePtr qemuMonitorQueryQMPSchema(qemuMonitorPtr mon); +int qemuMonitorSetBlockThreshold(qemuMonitorPtr mon, + const char *nodename, + unsigned long long threshold); + + #endif /* QEMU_MONITOR_H */ diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index b69d870d3..4b8103195 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -7434,3 +7434,34 @@ qemuMonitorJSONQueryQMPSchema(qemuMonitorPtr mon) return ret; } + + +int +qemuMonitorJSONSetBlockThreshold(qemuMonitorPtr mon, + const char *nodename, + unsigned long long threshold) +{ + virJSONValuePtr cmd; + virJSONValuePtr reply =3D NULL; + int ret =3D -1; + + if (!(cmd =3D qemuMonitorJSONMakeCommand("block-set-write-threshold", + "s:node-name", nodename, + "U:write-threshold", threshold, + NULL))) + 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; +} diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 79688c82f..0459356b4 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -511,4 +511,10 @@ int qemuMonitorJSONGetHotpluggableCPUs(qemuMonitorPtr = mon, virHashTablePtr qemuMonitorJSONQueryQMPSchema(qemuMonitorPtr mon) ATTRIBUTE_NONNULL(1); + +int qemuMonitorJSONSetBlockThreshold(qemuMonitorPtr mon, + const char *nodename, + unsigned long long threshold) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); + #endif /* QEMU_MONITOR_JSON_H */ --=20 2.11.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list