From nobody Fri Apr 26 20:19:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) client-ip=209.132.183.39; envelope-from=libvir-list-bounces@redhat.com; helo=mx6-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) by mx.zohomail.com with SMTPS id 1487877873373725.7422715659023; Thu, 23 Feb 2017 11:24:33 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1NJLEsB057102; Thu, 23 Feb 2017 14:21:15 -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 v1NJLB8Z001282 for ; Thu, 23 Feb 2017 14:21:11 -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 v1NJL8uU028635; Thu, 23 Feb 2017 14:21:10 -0500 From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 23 Feb 2017 20:21:54 +0100 Message-Id: <3c336801634cf426f4440eef31ffa109386acb99.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 01/12] util: storage: Split out useful bits of virStorageFileParseChainIndex 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" The function has very specific semantics. Split out the part that parses the backing store specification string into a separate helper so that it can be reused later while keeping the wrapper with existing semantics. Note that virStorageFileParseChainIndex is pretty well covered by the test suite. --- src/libvirt_private.syms | 1 + src/util/virstoragefile.c | 68 +++++++++++++++++++++++++++++++++++++++----= ---- src/util/virstoragefile.h | 5 ++++ 3 files changed, 63 insertions(+), 11 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 07a35333b..69d1bc860 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2462,6 +2462,7 @@ virStorageFileGetMetadataInternal; virStorageFileGetRelativeBackingPath; virStorageFileGetSCSIKey; virStorageFileIsClusterFS; +virStorageFileParseBackingStoreStr; virStorageFileParseChainIndex; virStorageFileProbeFormat; virStorageFileResize; diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index c9420fdb7..3e711228b 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -1442,32 +1442,78 @@ int virStorageFileGetSCSIKey(const char *path, } #endif + +/** + * virStorageFileParseBackingStoreStr: + * @str: backing store specifier string to parse + * @target: returns target device portion of the string + * @chainIndex: returns the backing store portion of the string + * + * Parses the backing store specifier string such as vda[1], or sda into + * components and returns them via arguments. If the string did not specif= y an + * index 0 is assumed. + * + * Returns 0 on success -1 on error + */ +int +virStorageFileParseBackingStoreStr(const char *str, + char **target, + unsigned int *chainIndex) +{ + char **strings =3D NULL; + size_t nstrings; + unsigned int idx =3D 0; + char *suffix; + int ret =3D -1; + + *chainIndex =3D 0; + + if (!(strings =3D virStringSplitCount(str, "[", 2, &nstrings))) + return -1; + + if (nstrings =3D=3D 2) { + if (virStrToLong_uip(strings[1], &suffix, 10, &idx) < 0 || + STRNEQ(suffix, "]")) + goto cleanup; + } + + if (target && + VIR_STRDUP(*target, strings[0]) < 0) + goto cleanup; + + *chainIndex =3D idx; + ret =3D 0; + + cleanup: + virStringListFreeCount(strings, nstrings); + return ret; +} + + int virStorageFileParseChainIndex(const char *diskTarget, const char *name, unsigned int *chainIndex) { - char **strings =3D NULL; unsigned int idx =3D 0; - char *suffix; + char *target =3D NULL; int ret =3D 0; *chainIndex =3D 0; - if (name && diskTarget) - strings =3D virStringSplit(name, "[", 2); + if (!name || !diskTarget) + return 0; - if (virStringListLength((const char * const *)strings) !=3D 2) - goto cleanup; + if (virStorageFileParseBackingStoreStr(name, &target, &idx) < 0) + return 0; - if (virStrToLong_uip(strings[1], &suffix, 10, &idx) < 0 || - STRNEQ(suffix, "]")) + if (idx =3D=3D 0) goto cleanup; - if (STRNEQ(diskTarget, strings[0])) { + if (STRNEQ(diskTarget, target)) { virReportError(VIR_ERR_INVALID_ARG, _("requested target '%s' does not match target '%s'= "), - strings[0], diskTarget); + target, diskTarget); ret =3D -1; goto cleanup; } @@ -1475,7 +1521,7 @@ virStorageFileParseChainIndex(const char *diskTarget, *chainIndex =3D idx; cleanup: - virStringListFree(strings); + VIR_FREE(target); return ret; } diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index bea1c35a2..5f6e41911 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -309,6 +309,11 @@ int virStorageFileParseChainIndex(const char *diskTarg= et, unsigned int *chainIndex) ATTRIBUTE_NONNULL(3); +int virStorageFileParseBackingStoreStr(const char *str, + char **target, + unsigned int *chainIndex) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3); + virStorageSourcePtr virStorageFileChainLookup(virStorageSourcePtr chain, virStorageSourcePtr startFro= m, const char *name, --=20 2.11.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 20:19:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) client-ip=209.132.183.39; envelope-from=libvir-list-bounces@redhat.com; helo=mx6-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) by mx.zohomail.com with SMTPS id 1487877886869644.6504243724092; Thu, 23 Feb 2017 11:24:46 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1NJLFuF057105; Thu, 23 Feb 2017 14:21:15 -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 v1NJLCBB001290 for ; Thu, 23 Feb 2017 14:21:12 -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 v1NJL8uV028635; Thu, 23 Feb 2017 14:21:11 -0500 From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 23 Feb 2017 20:21:55 +0100 Message-Id: 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 02/12] util: storage: Add preliminary storage for node names into virStorageSource 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" --- src/libvirt_private.syms | 1 + src/util/virstoragefile.c | 37 +++++++++++++++++++++++++++++++++++++ src/util/virstoragefile.h | 9 +++++++++ 3 files changed, 47 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 69d1bc860..078cca001 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2476,6 +2476,7 @@ virStorageNetProtocolTypeToString; virStorageSourceBackingStoreClear; virStorageSourceClear; virStorageSourceCopy; +virStorageSourceFindByNodeName; virStorageSourceFree; virStorageSourceGetActualType; virStorageSourceGetSecurityLabelDef; diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 3e711228b..d8f66a8a1 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -2012,6 +2012,7 @@ virStorageSourceCopy(const virStorageSource *src, VIR_STRDUP(ret->backingStoreRaw, src->backingStoreRaw) < 0 || VIR_STRDUP(ret->snapshot, src->snapshot) < 0 || VIR_STRDUP(ret->configFile, src->configFile) < 0 || + VIR_STRDUP(ret->nodeName, src->nodeName) < 0 || VIR_STRDUP(ret->compat, src->compat) < 0) goto error; @@ -2232,6 +2233,8 @@ virStorageSourceClear(virStorageSourcePtr def) virStorageNetHostDefFree(def->nhosts, def->hosts); virStorageAuthDefFree(def->auth); + VIR_FREE(def->nodeName); + virStorageSourceBackingStoreClear(def); } @@ -3781,3 +3784,37 @@ virStorageSourceIsRelative(virStorageSourcePtr src) return false; } + + +/** + * virStorageSourceFindByNodeName: + * @top: backing chain top + * @nodeName: node name to find in backing chain + * @index: if provided the index in the backing chain + * + * Looks up the given storage source in the backing chain and returns the + * pointer to it. If @index is passed then it's filled by the index in the + * backing chain. On failure NULL is returned and no error is reported. + */ +virStorageSourcePtr +virStorageSourceFindByNodeName(virStorageSourcePtr top, + const char *nodeName, + unsigned int *index) +{ + virStorageSourcePtr tmp; + + if (index) + *index =3D 0; + + for (tmp =3D top; tmp; tmp =3D tmp->backingStore) { + if (STREQ_NULLABLE(tmp->nodeName, nodeName)) + return tmp; + + if (index) + (*index)++; + } + + if (index) + *index =3D 0; + return NULL; +} diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index 5f6e41911..ffea60075 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -276,6 +276,9 @@ struct _virStorageSource { /* Name of the child backing store recorded in metadata of the * current file. */ char *backingStoreRaw; + + /* metadata that allows identifying given storage source */ + char *nodeName; }; @@ -395,4 +398,10 @@ virStorageSourcePtr virStorageSourceNewFromBackingAbso= lute(const char *path); bool virStorageSourceIsRelative(virStorageSourcePtr src); +virStorageSourcePtr +virStorageSourceFindByNodeName(virStorageSourcePtr top, + const char *nodeName, + unsigned int *index) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); + #endif /* __VIR_STORAGE_FILE_H__ */ --=20 2.11.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 20:19:13 2024 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 1487877959203926.1725415313338; Thu, 23 Feb 2017 11:25:59 -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 v1NJLq0s002078; Thu, 23 Feb 2017 14:21:52 -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 v1NJLD61001297 for ; Thu, 23 Feb 2017 14:21:13 -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 v1NJL8uW028635; Thu, 23 Feb 2017 14:21:12 -0500 From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 23 Feb 2017 20:21:56 +0100 Message-Id: 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 03/12] lib: Introduce event for tracking disk backing file write threshold 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" When using thin provisioning, management tools need to resize the disk in certain cases. To avoid having them to poll disk fillng introduce an event whic will be fired when a given offset of the storage is written by the hypervisor. Together with the API which will be added later, it will allow to register thresholds for given storage backing volumes and this event will then notify management if the threshold is exceeded. --- daemon/remote.c | 43 ++++++++++++++++ examples/object-events/event-test.c | 19 ++++++++ include/libvirt/libvirt-domain.h | 31 ++++++++++++ src/conf/domain_event.c | 97 +++++++++++++++++++++++++++++++++= ++++ src/conf/domain_event.h | 15 ++++++ src/libvirt_private.syms | 2 + src/remote/remote_driver.c | 33 +++++++++++++ src/remote/remote_protocol.x | 18 ++++++- src/remote_protocol-structs | 9 ++++ tools/virsh-domain.c | 21 ++++++++ 10 files changed, 287 insertions(+), 1 deletion(-) diff --git a/daemon/remote.c b/daemon/remote.c index f2b9b9aec..511f499de 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -1295,6 +1295,48 @@ remoteRelayDomainEventMetadataChange(virConnectPtr c= onn, } +static int +remoteRelayDomainEventBlockThreshold(virConnectPtr conn, + virDomainPtr dom, + const char *dev, + const char *path, + unsigned long long threshold, + unsigned long long excess, + void *opaque) +{ + daemonClientEventCallbackPtr callback =3D opaque; + remote_domain_event_block_threshold_msg data; + + if (callback->callbackID < 0 || + !remoteRelayDomainEventCheckACL(callback->client, conn, dom)) + return -1; + + VIR_DEBUG("Relaying domain block threshold event %s %d %s %s %llu %llu= , callback %d", + dom->name, dom->id, dev, NULLSTR(path), threshold, excess, c= allback->callbackID); + + /* build return data */ + memset(&data, 0, sizeof(data)); + data.callbackID =3D callback->callbackID; + if (VIR_STRDUP(data.dev, dev) < 0) + goto error; + if (VIR_ALLOC(data.path) < 0) + goto error; + if (VIR_STRDUP(*(data.path), path) < 0) + goto error; + data.threshold =3D threshold; + data.excess =3D excess; + make_nonnull_domain(&data.dom, dom); + + remoteDispatchObjectEventSend(callback->client, remoteProgram, + REMOTE_PROC_DOMAIN_EVENT_BLOCK_THRESHOLD, + (xdrproc_t)xdr_remote_domain_event_block= _threshold_msg, &data); + + return 0; + error: + VIR_FREE(data.dev); + return -1; +} + static virConnectDomainEventGenericCallback domainEventCallbacks[] =3D { VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventLifecycle), @@ -1321,6 +1363,7 @@ static virConnectDomainEventGenericCallback domainEve= ntCallbacks[] =3D { VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventJobCompleted), VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventDeviceRemovalFailed), VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventMetadataChange), + VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventBlockThreshold), }; verify(ARRAY_CARDINALITY(domainEventCallbacks) =3D=3D VIR_DOMAIN_EVENT_ID_= LAST); diff --git a/examples/object-events/event-test.c b/examples/object-events/e= vent-test.c index 55c004f93..12690cac0 100644 --- a/examples/object-events/event-test.c +++ b/examples/object-events/event-test.c @@ -15,6 +15,7 @@ #define ARRAY_CARDINALITY(Array) (sizeof(Array) / sizeof(*(Array))) #define STREQ(a, b) (strcmp(a, b) =3D=3D 0) +#define NULLSTR(s) ((s) ? (s) : "") #ifndef ATTRIBUTE_UNUSED # define ATTRIBUTE_UNUSED __attribute__((__unused__)) @@ -925,6 +926,23 @@ myDomainEventBlockJobCallback(virConnectPtr conn ATTRI= BUTE_UNUSED, static int +myDomainEventBlockThresholdCallback(virConnectPtr conn ATTRIBUTE_UNUSED, + virDomainPtr dom, + const char *dev, + const char *path, + unsigned long long threshold, + unsigned long long excess, + void *opaque ATTRIBUTE_UNUSED) +{ + printf("%s EVENT: Domain %s(%d) block threshold callback dev '%s'(%s),= " + "threshold: '%llu', excess: '%llu'", + __func__, virDomainGetName(dom), virDomainGetID(dom), + dev, NULLSTR(path), threshold, excess); + return 0; +} + + +static int myDomainEventMigrationIterationCallback(virConnectPtr conn ATTRIBUTE_UNUSE= D, virDomainPtr dom, int iteration, @@ -1053,6 +1071,7 @@ struct domainEventData domainEvents[] =3D { DOMAIN_EVENT(VIR_DOMAIN_EVENT_ID_JOB_COMPLETED, myDomainEventJobComple= tedCallback), DOMAIN_EVENT(VIR_DOMAIN_EVENT_ID_DEVICE_REMOVAL_FAILED, myDomainEventD= eviceRemovalFailedCallback), DOMAIN_EVENT(VIR_DOMAIN_EVENT_ID_METADATA_CHANGE, myDomainEventMetadat= aChangeCallback), + DOMAIN_EVENT(VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD, myDomainEventBlockTh= resholdCallback), }; struct storagePoolEventData { diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index c0f715d66..892cf2cc5 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -4175,6 +4175,36 @@ typedef void (*virConnectDomainEventAgentLifecycleCa= llback)(virConnectPtr conn, /** + * virConnectDomainEventBlockThresholdCallback: + * @conn: connection object + * @dom: domain on which the event occurred + * @dev: name associated with the affected disk or storage backing chain + * element + * @path: for local storage, the path of the backing chain element + * @threshold: threshold + * @excess: WTF + * @opaque: application specified data + * + * The callback occurs when the hypervisor detects that the given storage + * element was written beyond the point specified by @threshold. The excess + * data size written beyond @threshold is reported by @excess (if supported + * by the hypervisor, 0 otherwise). The event is useful for thin-provision= ed + * storage. + * + * The threshold size can be set via the virDomainSetBlockThreshold API. + * + * The callback signature to use when registering for an event of type + * VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD with virConnectDomainEventRegisterA= ny() + */ +typedef void (*virConnectDomainEventBlockThresholdCallback)(virConnectPtr = conn, + virDomainPtr d= om, + const char *de= v, + const char *pa= th, + unsigned long = long threshold, + unsigned long = long excess, + void *opaque); + +/** * VIR_DOMAIN_EVENT_CALLBACK: * * Used to cast the event specific callback into the generic one @@ -4215,6 +4245,7 @@ typedef enum { VIR_DOMAIN_EVENT_ID_JOB_COMPLETED =3D 21, /* virConnectDomainEventJob= CompletedCallback */ VIR_DOMAIN_EVENT_ID_DEVICE_REMOVAL_FAILED =3D 22, /* virConnectDomainE= ventDeviceRemovalFailedCallback */ VIR_DOMAIN_EVENT_ID_METADATA_CHANGE =3D 23, /* virConnectDomainEventMe= tadataChangeCallback */ + VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD =3D 24, /* virConnectDomainEventBl= ockThresholdCallback */ # ifdef VIR_ENUM_SENTINELS VIR_DOMAIN_EVENT_ID_LAST diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c index da503f3ee..6243b4262 100644 --- a/src/conf/domain_event.c +++ b/src/conf/domain_event.c @@ -60,6 +60,7 @@ static virClassPtr virDomainEventMigrationIterationClass; static virClassPtr virDomainEventJobCompletedClass; static virClassPtr virDomainEventDeviceRemovalFailedClass; static virClassPtr virDomainEventMetadataChangeClass; +static virClassPtr virDomainEventBlockThresholdClass; static void virDomainEventDispose(void *obj); static void virDomainEventLifecycleDispose(void *obj); @@ -81,6 +82,7 @@ static void virDomainEventMigrationIterationDispose(void = *obj); static void virDomainEventJobCompletedDispose(void *obj); static void virDomainEventDeviceRemovalFailedDispose(void *obj); static void virDomainEventMetadataChangeDispose(void *obj); +static void virDomainEventBlockThresholdDispose(void *obj); static void virDomainEventDispatchDefaultFunc(virConnectPtr conn, @@ -277,6 +279,17 @@ struct _virDomainEventMetadataCange { typedef struct _virDomainEventMetadataCange virDomainEventMetadataChange; typedef virDomainEventMetadataChange *virDomainEventMetadataChangePtr; +struct _virDomainEventBlockThreshold { + virDomainEvent parent; + + char *dev; + char *path; + + unsigned long long threshold; + unsigned long long excess; +}; +typedef struct _virDomainEventBlockThreshold virDomainEventBlockThreshold; +typedef virDomainEventBlockThreshold *virDomainEventBlockThresholdPtr; static int @@ -402,6 +415,12 @@ virDomainEventsOnceInit(void) sizeof(virDomainEventMetadataChange), virDomainEventMetadataChangeDispose))) return -1; + if (!(virDomainEventBlockThresholdClass =3D + virClassNew(virDomainEventClass, + "virDomainEventBlockThreshold", + sizeof(virDomainEventBlockThreshold), + virDomainEventBlockThresholdDispose))) + return -1; return 0; } @@ -600,6 +619,17 @@ virDomainEventMetadataChangeDispose(void *obj) } +static void +virDomainEventBlockThresholdDispose(void *obj) +{ + virDomainEventBlockThresholdPtr event =3D obj; + VIR_DEBUG("obj=3D%p", event); + + VIR_FREE(event->dev); + VIR_FREE(event->path); +} + + static void * virDomainEventNew(virClassPtr klass, int eventID, @@ -1674,6 +1704,60 @@ virDomainEventMetadataChangeNewFromDom(virDomainPtr = dom, } +static virObjectEventPtr +virDomainEventBlockThresholdNew(int id, + const char *name, + unsigned char *uuid, + const char *dev, + const char *path, + unsigned long long threshold, + unsigned long long excess) +{ + virDomainEventBlockThresholdPtr ev; + + if (virDomainEventsInitialize() < 0) + return NULL; + + if (!(ev =3D virDomainEventNew(virDomainEventBlockThresholdClass, + VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD, + id, name, uuid))) + return NULL; + + if (VIR_STRDUP(ev->dev, dev) < 0 || + VIR_STRDUP(ev->path, path) < 0) { + virObjectUnref(ev); + return NULL; + } + ev->threshold =3D threshold; + ev->excess =3D excess; + + return (virObjectEventPtr)ev; +} + +virObjectEventPtr +virDomainEventBlockThresholdNewFromObj(virDomainObjPtr obj, + const char *dev, + const char *path, + unsigned long long threshold, + unsigned long long excess) +{ + return virDomainEventBlockThresholdNew(obj->def->id, obj->def->name, + obj->def->uuid, dev, path, + threshold, excess); +} + +virObjectEventPtr +virDomainEventBlockThresholdNewFromDom(virDomainPtr dom, + const char *dev, + const char *path, + unsigned long long threshold, + unsigned long long excess) +{ + return virDomainEventBlockThresholdNew(dom->id, dom->name, dom->uuid, + dev, path, threshold, excess); +} + + static void virDomainEventDispatchDefaultFunc(virConnectPtr conn, virObjectEventPtr event, @@ -1943,6 +2027,19 @@ virDomainEventDispatchDefaultFunc(virConnectPtr conn, goto cleanup; } + case VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD: + { + virDomainEventBlockThresholdPtr blockThresholdEvent; + + blockThresholdEvent =3D (virDomainEventBlockThresholdPtr)event; + ((virConnectDomainEventBlockThresholdCallback)cb)(conn, dom, + blockThresho= ldEvent->dev, + blockThresho= ldEvent->path, + blockThresho= ldEvent->threshold, + blockThresho= ldEvent->excess, + cbopaque); + goto cleanup; + } case VIR_DOMAIN_EVENT_ID_LAST: break; } diff --git a/src/conf/domain_event.h b/src/conf/domain_event.h index 1933f4724..3992a29c5 100644 --- a/src/conf/domain_event.h +++ b/src/conf/domain_event.h @@ -244,6 +244,21 @@ virDomainEventMetadataChangeNewFromDom(virDomainPtr do= m, int type, const char *nsuri); + +virObjectEventPtr +virDomainEventBlockThresholdNewFromObj(virDomainObjPtr obj, + const char *dev, + const char *path, + unsigned long long threshold, + unsigned long long excess); + +virObjectEventPtr +virDomainEventBlockThresholdNewFromDom(virDomainPtr dom, + const char *dev, + const char *path, + unsigned long long threshold, + unsigned long long excess); + int virDomainEventStateRegister(virConnectPtr conn, virObjectEventStatePtr state, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 078cca001..c0a037011 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -536,6 +536,8 @@ virDomainEventBlockJob2NewFromDom; virDomainEventBlockJob2NewFromObj; virDomainEventBlockJobNewFromDom; virDomainEventBlockJobNewFromObj; +virDomainEventBlockThresholdNewFromDom; +virDomainEventBlockThresholdNewFromObj; virDomainEventControlErrorNewFromDom; virDomainEventControlErrorNewFromObj; virDomainEventDeviceAddedNewFromDom; diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 0c8bfeed1..efa47beaf 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -396,6 +396,11 @@ remoteSecretBuildEventValueChanged(virNetClientProgram= Ptr prog ATTRIBUTE_UNUSED, void *evdata, void *opaque); static void +remoteDomainBuildEventBlockThreshold(virNetClientProgramPtr prog, + virNetClientPtr client, + void *evdata, void *opaque); + +static void remoteConnectNotifyEventConnectionClosed(virNetClientProgramPtr prog ATTRI= BUTE_UNUSED, virNetClientPtr client ATTRIBUTE_= UNUSED, void *evdata, void *opaque); @@ -602,6 +607,10 @@ static virNetClientProgramEvent remoteEvents[] =3D { remoteSecretBuildEventValueChanged, sizeof(remote_secret_event_value_changed_msg), (xdrproc_t)xdr_remote_secret_event_value_changed_msg }, + { REMOTE_PROC_DOMAIN_EVENT_BLOCK_THRESHOLD, + remoteDomainBuildEventBlockThreshold, + sizeof(remote_domain_event_block_threshold_msg), + (xdrproc_t)xdr_remote_domain_event_block_threshold_msg }, }; static void @@ -5577,6 +5586,30 @@ remoteSecretGetValue(virSecretPtr secret, size_t *va= lue_size, } +static void +remoteDomainBuildEventBlockThreshold(virNetClientProgramPtr prog ATTRIBUTE= _UNUSED, + virNetClientPtr client ATTRIBUTE_UNUS= ED, + void *evdata, void *opaque) +{ + virConnectPtr conn =3D opaque; + remote_domain_event_block_threshold_msg *msg =3D evdata; + struct private_data *priv =3D conn->privateData; + virDomainPtr dom; + virObjectEventPtr event =3D NULL; + + if (!(dom =3D get_nonnull_domain(conn, msg->dom))) + return; + + event =3D virDomainEventBlockThresholdNewFromDom(dom, msg->dev, + msg->path ? *msg->path = : NULL, + msg->threshold, msg->ex= cess); + + virObjectUnref(dom); + + remoteEventQueue(priv, event, msg->callbackID); +} + + static int remoteStreamSend(virStreamPtr st, const char *data, diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index abe63af07..39dd2b728 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -3071,6 +3071,15 @@ struct remote_domain_event_block_job_2_msg { int status; }; +struct remote_domain_event_block_threshold_msg { + int callbackID; + remote_nonnull_domain dom; + remote_nonnull_string dev; + remote_string path; + unsigned hyper threshold; + unsigned hyper excess; +}; + struct remote_domain_event_callback_tunable_msg { int callbackID; remote_nonnull_domain dom; @@ -6033,5 +6042,12 @@ enum remote_procedure { * @acl: domain:save:!VIR_DOMAIN_AFFECT_CONFIG|VIR_DOMAIN_AFFECT_LIVE * @acl: domain:save:VIR_DOMAIN_AFFECT_CONFIG */ - REMOTE_PROC_DOMAIN_SET_VCPU =3D 384 + REMOTE_PROC_DOMAIN_SET_VCPU =3D 384, + + /** + * @generate: both + * @acl: none + */ + REMOTE_PROC_DOMAIN_EVENT_BLOCK_THRESHOLD =3D 385 + }; diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index e1e53d21b..67e43a4ac 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -2516,6 +2516,14 @@ struct remote_domain_event_block_job_2_msg { int type; int status; }; +struct remote_domain_event_block_threshold_msg { + int callbackID; + remote_nonnull_domain dom; + remote_nonnull_string dev; + remote_string path; + uint64_t threshold; + uint64_t excess; +}; struct remote_domain_event_callback_tunable_msg { int callbackID; remote_nonnull_domain dom; @@ -3217,4 +3225,5 @@ enum remote_procedure { REMOTE_PROC_SECRET_EVENT_LIFECYCLE =3D 382, REMOTE_PROC_SECRET_EVENT_VALUE_CHANGED =3D 383, REMOTE_PROC_DOMAIN_SET_VCPU =3D 384, + REMOTE_PROC_DOMAIN_EVENT_BLOCK_THRESHOLD =3D 385, }; diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 09a9f8203..ee702f3c4 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -12870,6 +12870,25 @@ virshEventMetadataChangePrint(virConnectPtr conn A= TTRIBUTE_UNUSED, } +static void +virshEventBlockThresholdPrint(virConnectPtr conn ATTRIBUTE_UNUSED, + virDomainPtr dom, + const char *dev, + const char *path, + unsigned long long threshold, + unsigned long long excess, + void *opaque) +{ + virBuffer buf =3D VIR_BUFFER_INITIALIZER; + + virBufferAsprintf(&buf, _("event 'block-threshold' for domain %s: " + "dev: %s(%s) %llu %llu\n"), + virDomainGetName(dom), + dev, NULLSTR(path), threshold, excess); + virshEventPrint(opaque, &buf); +} + + static vshEventCallback vshEventCallbacks[] =3D { { "lifecycle", VIR_DOMAIN_EVENT_CALLBACK(virshEventLifecyclePrint), }, @@ -12917,6 +12936,8 @@ static vshEventCallback vshEventCallbacks[] =3D { VIR_DOMAIN_EVENT_CALLBACK(virshEventDeviceRemovalFailedPrint), }, { "metadata-change", VIR_DOMAIN_EVENT_CALLBACK(virshEventMetadataChangePrint), }, + { "block-threshold", + VIR_DOMAIN_EVENT_CALLBACK(virshEventBlockThresholdPrint), }, }; verify(VIR_DOMAIN_EVENT_ID_LAST =3D=3D ARRAY_CARDINALITY(vshEventCallbacks= )); --=20 2.11.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 20:19:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) client-ip=209.132.183.25; envelope-from=libvir-list-bounces@redhat.com; helo=mx4-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by mx.zohomail.com with SMTPS id 1487877910267622.3571135178079; Thu, 23 Feb 2017 11:25:10 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1NJLuGN008318; Thu, 23 Feb 2017 14:21:56 -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 v1NJLEx7001305 for ; Thu, 23 Feb 2017 14:21:14 -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 v1NJL8uX028635; Thu, 23 Feb 2017 14:21:14 -0500 From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 23 Feb 2017 20:21:57 +0100 Message-Id: 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 04/12] qemu: monitor: Add support for BLOCK_WRITE_THRESHOLD 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: , 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" The event is fired when a given block backend node (identified by the node name) experiences a write beyond the bound set via block-set-write-threshold QMP command. This wires up the monitor code to extract the data and allow us receiving the events and the capability. --- src/qemu/qemu_capabilities.c | 2 ++ src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_monitor.c | 18 +++++++++++++++ src/qemu/qemu_monitor.h | 14 ++++++++++++ src/qemu/qemu_monitor_json.c | 26 ++++++++++++++++++= ++++ tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml | 1 + .../caps_2.6.0-gicv2.aarch64.xml | 1 + .../caps_2.6.0-gicv3.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml | 1 + tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml | 1 + 16 files changed, 72 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 5b5e3ac18..927ac49cf 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -358,6 +358,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, "query-cpu-model-expansion", /* 245 */ "virtio-net.host_mtu", "spice-rendernode", + "BLOCK_WRITE_THRESHOLD", ); @@ -1535,6 +1536,7 @@ struct virQEMUCapsStringFlags virQEMUCapsEvents[] =3D= { { "MIGRATION", QEMU_CAPS_MIGRATION_EVENT }, { "VSERPORT_CHANGE", QEMU_CAPS_VSERPORT_CHANGE }, { "DEVICE_TRAY_MOVED", QEMU_CAPS_DEVICE_TRAY_MOVED }, + { "BLOCK_WRITE_THRESHOLD", QEMU_CAPS_BLOCK_WRITE_THRESHOLD }, }; struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] =3D { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 0f998c473..83fb3acaf 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -394,6 +394,7 @@ typedef enum { QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION, /* qmp query-cpu-model-expansion = */ QEMU_CAPS_VIRTIO_NET_HOST_MTU, /* virtio-net-*.host_mtu */ QEMU_CAPS_SPICE_RENDERNODE, /* -spice rendernode */ + QEMU_CAPS_BLOCK_WRITE_THRESHOLD, /* BLOCK_WRITE_THRESHOLD event */ QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index b15207a69..a8e113f94 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -1580,6 +1580,24 @@ qemuMonitorEmitAcpiOstInfo(qemuMonitorPtr mon, int +qemuMonitorEmitBlockThreshold(qemuMonitorPtr mon, + const char *nodename, + unsigned long long threshold, + unsigned long long excess) +{ + int ret =3D -1; + + VIR_DEBUG("mon=3D%p, node-name=3D'%s', threshold=3D'%llu', excess=3D'%= llu'", + mon, nodename, threshold, excess); + + QEMU_MONITOR_CALLBACK(mon, ret, domainBlockThreshold, mon->vm, + nodename, threshold, excess); + + return ret; +} + + +int qemuMonitorSetCapabilities(qemuMonitorPtr mon) { QEMU_CHECK_MONITOR(mon); diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 8811d8501..a866685e9 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -207,6 +207,14 @@ typedef int (*qemuMonitorDomainAcpiOstInfoCallback)(qe= muMonitorPtr mon, void *opaque); +typedef int (*qemuMonitorDomainBlockThresholdCallback)(qemuMonitorPtr mon, + virDomainObjPtr vm, + const char *nodenam= e, + unsigned long long = threshold, + unsigned long long = excess, + void *opaque); + + typedef struct _qemuMonitorCallbacks qemuMonitorCallbacks; typedef qemuMonitorCallbacks *qemuMonitorCallbacksPtr; struct _qemuMonitorCallbacks { @@ -238,6 +246,7 @@ struct _qemuMonitorCallbacks { qemuMonitorDomainMigrationStatusCallback domainMigrationStatus; qemuMonitorDomainMigrationPassCallback domainMigrationPass; qemuMonitorDomainAcpiOstInfoCallback domainAcpiOstInfo; + qemuMonitorDomainBlockThresholdCallback domainBlockThreshold; }; char *qemuMonitorEscapeArg(const char *in); @@ -357,6 +366,11 @@ int qemuMonitorEmitAcpiOstInfo(qemuMonitorPtr mon, unsigned int source, unsigned int status); +int qemuMonitorEmitBlockThreshold(qemuMonitorPtr mon, + const char *nodename, + unsigned long long threshold, + unsigned long long excess); + int qemuMonitorStartCPUs(qemuMonitorPtr mon, virConnectPtr conn); int qemuMonitorStopCPUs(qemuMonitorPtr mon); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 7aa9e314c..b69d870d3 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -89,6 +89,7 @@ static void qemuMonitorJSONHandleSpiceMigrated(qemuMonito= rPtr mon, virJSONValueP static void qemuMonitorJSONHandleMigrationStatus(qemuMonitorPtr mon, virJS= ONValuePtr data); static void qemuMonitorJSONHandleMigrationPass(qemuMonitorPtr mon, virJSON= ValuePtr data); static void qemuMonitorJSONHandleAcpiOstInfo(qemuMonitorPtr mon, virJSONVa= luePtr data); +static void qemuMonitorJSONHandleBlockThreshold(qemuMonitorPtr mon, virJSO= NValuePtr data); typedef struct { const char *type; @@ -102,6 +103,7 @@ static qemuEventHandler eventHandlers[] =3D { { "BLOCK_JOB_CANCELLED", qemuMonitorJSONHandleBlockJobCanceled, }, { "BLOCK_JOB_COMPLETED", qemuMonitorJSONHandleBlockJobCompleted, }, { "BLOCK_JOB_READY", qemuMonitorJSONHandleBlockJobReady, }, + { "BLOCK_WRITE_THRESHOLD", qemuMonitorJSONHandleBlockThreshold, }, { "DEVICE_DELETED", qemuMonitorJSONHandleDeviceDeleted, }, { "DEVICE_TRAY_MOVED", qemuMonitorJSONHandleTrayChange, }, { "GUEST_PANICKED", qemuMonitorJSONHandleGuestPanic, }, @@ -1065,6 +1067,30 @@ qemuMonitorJSONHandleAcpiOstInfo(qemuMonitorPtr mon,= virJSONValuePtr data) } +static void +qemuMonitorJSONHandleBlockThreshold(qemuMonitorPtr mon, virJSONValuePtr da= ta) +{ + const char *nodename; + unsigned long long threshold; + unsigned long long excess; + + if (!(nodename =3D virJSONValueObjectGetString(data, "node-name"))) + goto error; + + if (virJSONValueObjectGetNumberUlong(data, "write-threshold", &thresho= ld) < 0) + goto error; + + if (virJSONValueObjectGetNumberUlong(data, "amount-exceeded", &excess)= < 0) + goto error; + + qemuMonitorEmitBlockThreshold(mon, nodename, threshold, excess); + return; + + error: + VIR_WARN("malformed 'BLOCK_WRITE_THRESHOLD' event"); +} + + int qemuMonitorJSONHumanCommandWithFd(qemuMonitorPtr mon, const char *cmd_str, diff --git a/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_2.4.0.x86_64.xml index 9248a0634..e22099fb3 100644 --- a/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml @@ -183,6 +183,7 @@ + 2004000 0 diff --git a/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_2.5.0.x86_64.xml index 96e62d3e5..95006d0b4 100644 --- a/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml @@ -189,6 +189,7 @@ + 2005000 0 diff --git a/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml b/test= s/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml index 0aed651e7..707ddd02f 100644 --- a/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml @@ -164,6 +164,7 @@ + 2006000 0 diff --git a/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml b/test= s/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml index 1041a12c1..953e3f073 100644 --- a/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml @@ -164,6 +164,7 @@ + 2006000 0 diff --git a/tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml b/tests/qemu= capabilitiesdata/caps_2.6.0.ppc64le.xml index 92e27810f..f271915bd 100644 --- a/tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml +++ b/tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml @@ -159,6 +159,7 @@ + 2006000 0 diff --git a/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_2.6.0.x86_64.xml index faddd5065..efc1324ee 100644 --- a/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml @@ -198,6 +198,7 @@ + 2006000 0 diff --git a/tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml b/tests/qemuca= pabilitiesdata/caps_2.7.0.s390x.xml index af21017bc..787c6811c 100644 --- a/tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml @@ -127,6 +127,7 @@ + 2007000 0 diff --git a/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_2.7.0.x86_64.xml index c789f0eaa..7393d9da4 100644 --- a/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml @@ -200,6 +200,7 @@ + 2007000 0 (v2.7.0) diff --git a/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml b/tests/qemuca= pabilitiesdata/caps_2.8.0.s390x.xml index c4c9bf9d5..547a74820 100644 --- a/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml @@ -129,6 +129,7 @@ + 2007093 0 diff --git a/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_2.8.0.x86_64.xml index caa14c41e..a81c66694 100644 --- a/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml @@ -201,6 +201,7 @@ + 2008000 0 (v2.8.0) diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_2.9.0.x86_64.xml index dcdc0e621..272adfb3c 100644 --- a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml @@ -202,6 +202,7 @@ + 2008050 0 (v2.8.0-1321-gad584d3) --=20 2.11.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 20:19:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) client-ip=209.132.183.39; envelope-from=libvir-list-bounces@redhat.com; helo=mx6-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) by mx.zohomail.com with SMTPS id 1487877989751538.4096963395519; Thu, 23 Feb 2017 11:26:29 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1NJMYVJ057179; Thu, 23 Feb 2017 14:22:34 -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 v1NJLGJj001315 for ; Thu, 23 Feb 2017 14:21:16 -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 v1NJL8uY028635; Thu, 23 Feb 2017 14:21:15 -0500 From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 23 Feb 2017 20:21:58 +0100 Message-Id: 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 05/12] qemu: domain: Add helper to lookup disk by node name 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" Looks up a disk and it's corresponding backing chain element by node name. --- src/qemu/qemu_domain.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_domain.h | 6 ++++++ 2 files changed, 50 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index c187214dc..4b446f1e8 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8275,3 +8275,47 @@ qemuDomainNamespaceTeardownRNG(virQEMUDriverPtr driv= er, cleanup: return ret; } + + +/** + * qemuDomainDiskLookupByNodename: + * @def: domain definition to look for the disk + * @nodename: block backend node name to find + * @src: filled with the specific backing store element if provided + * @idx: index of @src in the backing chain, if provided + * + * Looks up the disk in the domain via @nodename and returns it's definiti= on. + * Optionally fills @src and @idx if provided with the specific backing ch= ain + * element which corresponds to the node name. + */ +virDomainDiskDefPtr +qemuDomainDiskLookupByNodename(virDomainDefPtr def, + const char *nodename, + virStorageSourcePtr *src, + unsigned int *idx) +{ + size_t i; + unsigned int srcindex; + virStorageSourcePtr tmp =3D NULL; + + if (src) + *src =3D NULL; + + if (idx) + *idx =3D 0; + + for (i =3D 0; i < def->ndisks; i++) { + if ((tmp =3D virStorageSourceFindByNodeName(def->disks[i]->src, + nodename, &srcindex))) { + if (src) + *src =3D tmp; + + if (idx) + *idx =3D srcindex; + + return def->disks[i]; + } + } + + return NULL; +} diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 72efa3336..03377645f 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -849,4 +849,10 @@ int qemuDomainNamespaceSetupRNG(virQEMUDriverPtr drive= r, int qemuDomainNamespaceTeardownRNG(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainRNGDefPtr rng); + +virDomainDiskDefPtr qemuDomainDiskLookupByNodename(virDomainDefPtr def, + const char *nodename, + virStorageSourcePtr *sr= c, + unsigned int *idx); + #endif /* __QEMU_DOMAIN_H__ */ --=20 2.11.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 20:19:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) client-ip=209.132.183.25; envelope-from=libvir-list-bounces@redhat.com; helo=mx4-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by mx.zohomail.com with SMTPS id 1487877994568376.0562347282373; Thu, 23 Feb 2017 11:26:34 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1NJMUqC008353; Thu, 23 Feb 2017 14:22:30 -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 v1NJLH57001325 for ; Thu, 23 Feb 2017 14:21:17 -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 v1NJL8uZ028635; Thu, 23 Feb 2017 14:21:16 -0500 From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 23 Feb 2017 20:21:59 +0100 Message-Id: <70fe08de4d2e605f3cc791a5b83d639aac9a2702.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 06/12] qemu: domain: Add helper to generate indexed backing store names 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" The code is currently simple, but if we later add node names, it will be necessary to generate the names based on the node name. Add a helper so that there's a central point to fix once we add self-generated node names. --- src/qemu/qemu_domain.c | 22 ++++++++++++++++++++++ src/qemu/qemu_domain.h | 4 ++++ 2 files changed, 26 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 4b446f1e8..b8a65cfd5 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8319,3 +8319,25 @@ qemuDomainDiskLookupByNodename(virDomainDefPtr def, return NULL; } + + +/** + * qemuDomainDiskBackingStoreGetName: + * + * Creates a name using the indexed syntax (vda[1])for the given backing s= tore + * entry for a disk. + */ +char * +qemuDomainDiskBackingStoreGetName(virDomainDiskDefPtr disk, + virStorageSourcePtr src ATTRIBUTE_UNUSED, + unsigned int idx) +{ + char *ret =3D NULL; + + if (idx) + ignore_value(virAsprintf(&ret, "%s[%d]", disk->dst, idx)); + else + ignore_value(VIR_STRDUP(ret, disk->dst)); + + return ret; +} diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 03377645f..6e847c7ae 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -855,4 +855,8 @@ virDomainDiskDefPtr qemuDomainDiskLookupByNodename(virD= omainDefPtr def, virStorageSourcePtr *sr= c, unsigned int *idx); +char *qemuDomainDiskBackingStoreGetName(virDomainDiskDefPtr disk, + virStorageSourcePtr src, + unsigned int idx); + #endif /* __QEMU_DOMAIN_H__ */ --=20 2.11.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 20:19:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) client-ip=209.132.183.37; envelope-from=libvir-list-bounces@redhat.com; helo=mx5-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) by mx.zohomail.com with SMTPS id 1487877999547141.06012278730884; Thu, 23 Feb 2017 11:26:39 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1NJNCLw047049; Thu, 23 Feb 2017 14:23:12 -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 v1NJLIEu001332 for ; Thu, 23 Feb 2017 14:21:18 -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 v1NJL8ua028635; Thu, 23 Feb 2017 14:21:17 -0500 From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 23 Feb 2017 20:22:00 +0100 Message-Id: <8f29ee660574e1d9d622cc7dd30c7c39b1074335.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 07/12] qemu: process: Wire up firing of the VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD 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: , 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" Bind it to qemus BLOCK_WRITE_THRESHOLD event. Look up the disk by nodename and construct the string to return. --- src/qemu/qemu_process.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index ea10fff45..cfe4073de 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -1439,6 +1439,45 @@ qemuProcessHandleAcpiOstInfo(qemuMonitorPtr mon ATTR= IBUTE_UNUSED, static int +qemuProcessHandleBlockThreshold(qemuMonitorPtr mon ATTRIBUTE_UNUSED, + virDomainObjPtr vm, + const char *nodename, + unsigned long long threshold, + unsigned long long excess, + void *opaque) +{ + virQEMUDriverPtr driver =3D opaque; + virObjectEventPtr event =3D NULL; + virDomainDiskDefPtr disk; + virStorageSourcePtr src; + unsigned int idx; + char *dev =3D NULL; + const char *path =3D NULL; + + virObjectLock(vm); + + VIR_DEBUG("BLOCK_WRITE_THRESHOLD event for block node '%s' in domain %= p %s:" + "threshold '%llu' exceeded by '%llu'", + nodename, vm, vm->def->name, threshold, excess); + + if ((disk =3D qemuDomainDiskLookupByNodename(vm->def, nodename, &src, = &idx))) { + if (virStorageSourceIsLocalStorage(src)) + path =3D src->path; + + if ((dev =3D qemuDomainDiskBackingStoreGetName(disk, src, idx))) { + event =3D virDomainEventBlockThresholdNewFromObj(vm, dev, path, + threshold, exce= ss); + } + } + + virObjectUnlock(vm); + qemuDomainEventQueue(driver, event); + + return 0; +} + + +static int qemuProcessHandleNicRxFilterChanged(qemuMonitorPtr mon ATTRIBUTE_UNUSED, virDomainObjPtr vm, const char *devAlias, @@ -1634,6 +1673,7 @@ static qemuMonitorCallbacks monitorCallbacks =3D { .domainMigrationStatus =3D qemuProcessHandleMigrationStatus, .domainMigrationPass =3D qemuProcessHandleMigrationPass, .domainAcpiOstInfo =3D qemuProcessHandleAcpiOstInfo, + .domainBlockThreshold =3D qemuProcessHandleBlockThreshold, }; static void --=20 2.11.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 20:19:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) client-ip=209.132.183.25; envelope-from=libvir-list-bounces@redhat.com; helo=mx4-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by mx.zohomail.com with SMTPS id 1487878043804719.6317300236749; Thu, 23 Feb 2017 11:27:23 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1NJNo0g008425; Thu, 23 Feb 2017 14:23:50 -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 v1NJLJQt001341 for ; Thu, 23 Feb 2017 14:21:19 -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 v1NJL8ub028635; Thu, 23 Feb 2017 14:21:18 -0500 From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 23 Feb 2017 20:22:01 +0100 Message-Id: <2589891c931b54291f265fda7953036b0048d4f3.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 08/12] lib: Add API for setting the threshold size for VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD 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" The new API can be used to configure the threshold when VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD should be fired. --- include/libvirt/libvirt-domain.h | 5 ++++ src/driver-hypervisor.h | 8 +++++++ src/libvirt-domain.c | 51 ++++++++++++++++++++++++++++++++++++= ++++ src/libvirt_public.syms | 1 + src/remote/remote_driver.c | 1 + src/remote/remote_protocol.x | 17 +++++++++++++- src/remote_protocol-structs | 7 ++++++ 7 files changed, 89 insertions(+), 1 deletion(-) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 892cf2cc5..7752cd38c 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -4564,4 +4564,9 @@ int virDomainSetVcpu(virDomainPtr domain, int state, unsigned int flags); +int virDomainSetBlockThreshold(virDomainPtr domain, + const char *dev, + unsigned long long threshold, + unsigned int flags); + #endif /* __VIR_LIBVIRT_DOMAIN_H__ */ diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h index b81420aef..3053d7ae8 100644 --- a/src/driver-hypervisor.h +++ b/src/driver-hypervisor.h @@ -1257,6 +1257,13 @@ typedef int int state, unsigned int flags); +typedef int +(*virDrvDomainSetBlockThreshold)(virDomainPtr domain, + const char *dev, + unsigned long long threshold, + unsigned int flags); + + typedef struct _virHypervisorDriver virHypervisorDriver; typedef virHypervisorDriver *virHypervisorDriverPtr; @@ -1496,6 +1503,7 @@ struct _virHypervisorDriver { virDrvDomainGetGuestVcpus domainGetGuestVcpus; virDrvDomainSetGuestVcpus domainSetGuestVcpus; virDrvDomainSetVcpu domainSetVcpu; + virDrvDomainSetBlockThreshold domainSetBlockThreshold; }; diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 619a9fccb..93ebe1e86 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -11797,3 +11797,54 @@ virDomainSetVcpu(virDomainPtr domain, virDispatchError(domain->conn); return -1; } + + +/** + * virDomainSetBlockThreshold: + * @domain: pointer to domain object + * @dev: string specifying the block device or backing chain element + * @threshold: threshold in bytes when to fire the event + * @flags: currently unused, callers should pass 0 + * + * Set the threshold level for delivering the + * VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD if the device or backing chain elem= ent + * described by @dev is written beyond the set threshold level. The thresh= old + * level is unset once the event fired. The event may not be delivered at = all if + * libvirtd was not running at the moment when the threshold was reached. + * + * This event allows to use thin-provisioned storage which needs management + * tools to grow it without the need for polling of the data. + * + * Returns 0 if the operation has started, -1 on failure. + */ +int +virDomainSetBlockThreshold(virDomainPtr domain, + const char *dev, + unsigned long long threshold, + unsigned int flags) +{ + VIR_DOMAIN_DEBUG(domain, "dev=3D'%s' threshold=3D%llu flags=3D%x", + NULLSTR(dev), threshold, flags); + + virResetLastError(); + + virCheckDomainReturn(domain, -1); + virCheckReadOnlyGoto(domain->conn->flags, error); + + virCheckNonNullArgGoto(dev, error); + + if (domain->conn->driver->domainSetBlockThreshold) { + int ret; + ret =3D domain->conn->driver->domainSetBlockThreshold(domain, dev, + threshold, fla= gs); + if (ret < 0) + goto error; + return ret; + } + + virReportUnsupportedError(); + + error: + virDispatchError(domain->conn); + return -1; +} diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 04ef58021..428cf2e19 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -755,6 +755,7 @@ LIBVIRT_3.0.0 { LIBVIRT_3.1.0 { global: + virDomainSetBlockThreshold; virDomainSetVcpu; } LIBVIRT_3.0.0; diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index efa47beaf..baa5cbab3 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -8436,6 +8436,7 @@ static virHypervisorDriver hypervisor_driver =3D { .domainGetGuestVcpus =3D remoteDomainGetGuestVcpus, /* 2.0.0 */ .domainSetGuestVcpus =3D remoteDomainSetGuestVcpus, /* 2.0.0 */ .domainSetVcpu =3D remoteDomainSetVcpu, /* 3.1.0 */ + .domainSetBlockThreshold =3D remoteDomainSetBlockThreshold, /* 3.1.0 */ }; static virNetworkDriver network_driver =3D { diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index 39dd2b728..87b2bd365 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -3402,6 +3402,14 @@ struct remote_secret_event_value_changed_msg { remote_nonnull_secret secret; }; +struct remote_domain_set_block_threshold_args { + remote_nonnull_domain dom; + remote_nonnull_string dev; + unsigned hyper threshold; + unsigned int flags; +}; + + /*----- Protocol. -----*/ /* Define the program number, protocol version and procedure numbers here.= */ @@ -6048,6 +6056,13 @@ enum remote_procedure { * @generate: both * @acl: none */ - REMOTE_PROC_DOMAIN_EVENT_BLOCK_THRESHOLD =3D 385 + REMOTE_PROC_DOMAIN_EVENT_BLOCK_THRESHOLD =3D 385, + + /** + * @generate: both + * @acl: domain:write + */ + REMOTE_PROC_DOMAIN_SET_BLOCK_THRESHOLD =3D 386 + }; diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index 67e43a4ac..a46fe37bf 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -2840,6 +2840,12 @@ struct remote_secret_event_value_changed_msg { int callbackID; remote_nonnull_secret secret; }; +struct remote_domain_set_block_threshold_args { + remote_nonnull_domain dom; + remote_nonnull_string dev; + uint64_t threshold; + u_int flags; +}; enum remote_procedure { REMOTE_PROC_CONNECT_OPEN =3D 1, REMOTE_PROC_CONNECT_CLOSE =3D 2, @@ -3226,4 +3232,5 @@ enum remote_procedure { REMOTE_PROC_SECRET_EVENT_VALUE_CHANGED =3D 383, REMOTE_PROC_DOMAIN_SET_VCPU =3D 384, REMOTE_PROC_DOMAIN_EVENT_BLOCK_THRESHOLD =3D 385, + REMOTE_PROC_DOMAIN_SET_BLOCK_THRESHOLD =3D 386, }; --=20 2.11.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 20:19:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) client-ip=209.132.183.37; envelope-from=libvir-list-bounces@redhat.com; helo=mx5-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) by mx.zohomail.com with SMTPS id 1487877998524386.01799581792716; Thu, 23 Feb 2017 11:26:38 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1NJNC4m047052; Thu, 23 Feb 2017 14:23:12 -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 v1NJLKUm001351 for ; Thu, 23 Feb 2017 14:21:20 -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 v1NJL8uc028635; Thu, 23 Feb 2017 14:21:19 -0500 From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 23 Feb 2017 20:22:02 +0100 Message-Id: <597b878dc9dc5749ffbf68248b8889ca827e729c.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 09/12] virsh: Implement 'blockthreshold' command to call virDomainSetBlockThreshold 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 a simple wrapper which will allow to set the threshold for delivering the event. --- tools/virsh-domain.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++= ++++ tools/virsh.pod | 8 +++++++ 2 files changed, 71 insertions(+) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index ee702f3c4..f70f61b72 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -7097,6 +7097,63 @@ cmdSetvcpu(vshControl *ctl, const vshCmd *cmd) /* + * "blockthreshold" command + */ +static const vshCmdInfo info_blockthreshold[] =3D { + {.name =3D "help", + .data =3D N_("attach/detach vcpu or groups of threads") + }, + {.name =3D "desc", + .data =3D N_("Add or remove vcpus") + }, + {.name =3D NULL} +}; + +static const vshCmdOptDef opts_blockthreshold[] =3D { + VIRSH_COMMON_OPT_DOMAIN_FULL, + {.name =3D "dev", + .type =3D VSH_OT_DATA, + .flags =3D VSH_OFLAG_REQ, + .help =3D N_("device to set threshold for") + }, + {.name =3D "threshold", + .type =3D VSH_OT_INT, + .flags =3D VSH_OFLAG_REQ, + .help =3D N_("threshold as a scaled number (by default bytes)") + }, + {.name =3D NULL} +}; + +static bool +cmdBlockThreshold(vshControl *ctl, const vshCmd *cmd) +{ + unsigned long long threshold; + const char *dev =3D NULL; + virDomainPtr dom; + bool ret =3D false; + + if (vshCommandOptStringReq(ctl, cmd, "dev", &dev)) + return false; + + if (vshCommandOptScaledInt(ctl, cmd, "threshold", + &threshold, 1, ULLONG_MAX) < 0) + return false; + + if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + return false; + + if (virDomainSetBlockThreshold(dom, dev, threshold, 0) < 0) + goto cleanup; + + ret =3D true; + + cleanup: + virDomainFree(dom); + return ret; +} + + +/* * "iothreadinfo" command */ static const vshCmdInfo info_iothreadinfo[] =3D { @@ -14060,5 +14117,11 @@ const vshCmdDef domManagementCmds[] =3D { .info =3D info_setvcpu, .flags =3D 0 }, + {.name =3D "blockthreshold", + .handler =3D cmdBlockThreshold, + .opts =3D opts_blockthreshold, + .info =3D info_blockthreshold, + .flags =3D 0 + }, {.name =3D NULL} }; diff --git a/tools/virsh.pod b/tools/virsh.pod index 6c06ee029..102aefc0c 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -1265,6 +1265,14 @@ I<--bytes> with a scaled value allows to use finer g= ranularity. A scaled value used without I<--bytes> will be rounded down to MiB/s. Note that the I<--bytes> may be unsupported by the hypervisor. + +=3Ditem B I I I + +Set the threshold value for delivering the block-threshold event. I +specifies the disk device target or backing chain element of given device = using +the 'target[1]' syntax. I is a scaled value of the offset. If t= he +block device should write beyond that offset the event will be delivered. + =3Ditem B I I I Resize a block device of domain while the domain is running, I --=20 2.11.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 20:19:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) client-ip=209.132.183.39; envelope-from=libvir-list-bounces@redhat.com; helo=mx6-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) by mx.zohomail.com with SMTPS id 1487878046986831.9050570855538; Thu, 23 Feb 2017 11:27:26 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1NJNolK057240; Thu, 23 Feb 2017 14:23:50 -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 v1NJLLIs001367 for ; Thu, 23 Feb 2017 14:21:21 -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 v1NJL8ud028635; Thu, 23 Feb 2017 14:21:20 -0500 From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 23 Feb 2017 20:22:03 +0100 Message-Id: <81636f6328feb10d2703dcf4e9c53f233cc50b59.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 10/12] qemu: domain: Add helper to look up disk soruce by the backing store string 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" --- src/qemu/qemu_domain.c | 37 +++++++++++++++++++++++++++++++++++++ src/qemu/qemu_domain.h | 3 +++ 2 files changed, 40 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index b8a65cfd5..1740a9d80 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8341,3 +8341,40 @@ qemuDomainDiskBackingStoreGetName(virDomainDiskDefPt= r disk, return ret; } + + +virStorageSourcePtr +qemuDomainGetStorageSourceByDevstr(const char *devstr, + virDomainDefPtr def) +{ + virDomainDiskDefPtr disk =3D NULL; + virStorageSourcePtr src =3D NULL; + char *target =3D NULL; + unsigned int idx; + size_t i; + + if (virStorageFileParseBackingStoreStr(devstr, &target, &idx) < 0) { + virReportError(VIR_ERR_INVALID_ARG, + _("failed to parse block device '%s'"), devstr); + return NULL; + } + + for (i =3D 0; i < def->ndisks; i++) { + if (STREQ(target, def->disks[i]->dst)) { + disk =3D def->disks[i]; + break; + } + } + + if (!disk) { + virReportError(VIR_ERR_INVALID_ARG, + _("failed to find disk '%s"), target); + goto cleanup; + } + + src =3D virStorageFileChainLookup(disk->src, NULL, NULL, idx, NULL); + + cleanup: + VIR_FREE(target); + return src; +} diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 6e847c7ae..705a3ad59 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -859,4 +859,7 @@ char *qemuDomainDiskBackingStoreGetName(virDomainDiskDe= fPtr disk, virStorageSourcePtr src, unsigned int idx); +virStorageSourcePtr qemuDomainGetStorageSourceByDevstr(const char *devstr, + virDomainDefPtr def= ); + #endif /* __QEMU_DOMAIN_H__ */ --=20 2.11.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 26 20:19:13 2024 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 From nobody Fri Apr 26 20:19:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) client-ip=209.132.183.25; envelope-from=libvir-list-bounces@redhat.com; helo=mx4-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by mx.zohomail.com with SMTPS id 1487878130129836.3493771350105; Thu, 23 Feb 2017 11:28:50 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1NJPAP4008496; Thu, 23 Feb 2017 14:25:10 -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 v1NJLOVR001383 for ; Thu, 23 Feb 2017 14:21:24 -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 v1NJL8uf028635; Thu, 23 Feb 2017 14:21:23 -0500 From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 23 Feb 2017 20:22:05 +0100 Message-Id: <940b017b7bed1fdf7709931846f9ed7ecce8adee.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 12/12] qemu: WIP: lookup nodenames 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" --- src/qemu/qemu_domain.h | 1 + src/qemu/qemu_monitor.c | 11 ++++++++++- src/qemu/qemu_monitor_json.c | 8 +++++++- src/qemu/qemu_process.c | 1 + 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 705a3ad59..db6e9a75f 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -356,6 +356,7 @@ struct qemuDomainDiskInfo { bool tray_open; bool empty; int io_status; + char *nodename; }; typedef struct _qemuDomainHostdevPrivate qemuDomainHostdevPrivate; diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 7caced7fe..42c32bc64 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -2147,6 +2147,15 @@ qemuMonitorBlockIOStatusToError(const char *status) return -1; } +static void +qemuDomainDiskInfoFree(void *value, const void *name ATTRIBUTE_UNUSED) +{ + struct qemuDomainDiskInfo *info =3D value; + + VIR_FREE(info->nodename); + VIR_FREE(info); +} + virHashTablePtr qemuMonitorGetBlockInfo(qemuMonitorPtr mon) @@ -2156,7 +2165,7 @@ qemuMonitorGetBlockInfo(qemuMonitorPtr mon) QEMU_CHECK_MONITOR_NULL(mon); - if (!(table =3D virHashCreate(32, virHashValueFree))) + if (!(table =3D virHashCreate(32, qemuDomainDiskInfoFree))) return NULL; if (mon->json) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 4b8103195..6e65b26d3 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -1868,9 +1868,11 @@ int qemuMonitorJSONGetBlockInfo(qemuMonitorPtr mon, for (i =3D 0; i < virJSONValueArraySize(devices); i++) { virJSONValuePtr dev; + virJSONValuePtr image; struct qemuDomainDiskInfo *info; const char *thisdev; const char *status; + const char *nodename; if (!(dev =3D qemuMonitorJSONGetBlockDev(devices, i))) goto cleanup; @@ -1907,8 +1909,12 @@ int qemuMonitorJSONGetBlockInfo(qemuMonitorPtr mon, info->tray =3D true; /* presence of 'inserted' notifies that a medium is in the device = */ - if (!virJSONValueObjectGetObject(dev, "inserted")) + if ((image =3D virJSONValueObjectGetObject(dev, "inserted"))) { + if ((nodename =3D virJSONValueObjectGetString(image, "node-nam= e"))) + ignore_value(VIR_STRDUP(info->nodename, nodename)); + } else { info->empty =3D true; + } /* Missing io-status indicates no error */ if ((status =3D virJSONValueObjectGetString(dev, "io-status"))) { diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index cfe4073de..74409f88a 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6735,6 +6735,7 @@ qemuProcessRefreshDisks(virQEMUDriverPtr driver, /* fill in additional data */ diskpriv->removable =3D info->removable; diskpriv->tray =3D info->tray; + VIR_STEAL_PTR(disk->src->nodeName, info->nodename); } ret =3D 0; --=20 2.11.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list