]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
lib: Add API for setting the threshold size for VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD
authorPeter Krempa <pkrempa@redhat.com>
Thu, 23 Feb 2017 12:09:12 +0000 (13:09 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 27 Mar 2017 08:09:49 +0000 (10:09 +0200)
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
src/driver-hypervisor.h
src/libvirt-domain.c
src/libvirt_public.syms
src/remote/remote_driver.c
src/remote/remote_protocol.x
src/remote_protocol-structs

index 355bbd5151f900b8954443485bb9b6901ac4e34a..501996bc84f1829324e6f996a611ec86d3b26f61 100644 (file)
@@ -4664,4 +4664,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__ */
index b81420aefeff65b95eda1e23b6a661199d4c6fb5..3053d7ae8c61a7dd5baefb79aaa6dc8af1ff892c 100644 (file)
@@ -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;
 };
 
 
index d8c88e06c476268098b46232473470dcc8aee7ae..0cd80a609541fac7639f8bfa03d05f8d999de431 100644 (file)
@@ -11822,3 +11822,59 @@ 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 element
+ * described by @dev is written beyond the set threshold level. The threshold
+ * level is unset once the event fires. The event might not be delivered at all
+ * if libvirtd was not running at the moment when the threshold was reached.
+ *
+ * Hypervisors report the last written sector of an image in the bulk stats API
+ * (virConnectGetAllDomainStats/virDomainListGetStats) as
+ * "block.<num>.allocation" in the VIR_DOMAIN_STATS_BLOCK group. The current
+ * threshold value is reported as "block.<num>.threshold".
+ *
+ * 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='%s' threshold=%llu flags=%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 = domain->conn->driver->domainSetBlockThreshold(domain, dev,
+                                                            threshold, flags);
+        if (ret < 0)
+            goto error;
+        return ret;
+    }
+
+    virReportUnsupportedError();
+
+ error:
+    virDispatchError(domain->conn);
+    return -1;
+}
index 04ef58021bc149bf10b841b0b55e425dde0c8675..428cf2e19473c225568c90e178d3a40f88f31a6f 100644 (file)
@@ -755,6 +755,7 @@ LIBVIRT_3.0.0 {
 
 LIBVIRT_3.1.0 {
     global:
+        virDomainSetBlockThreshold;
         virDomainSetVcpu;
 } LIBVIRT_3.0.0;
 
index efa47beafbe33187d229e577d7a6c9dfd77a18dd..27bcc9b925c141cad3ce354dd716b8c386776f8e 100644 (file)
@@ -8436,6 +8436,7 @@ static virHypervisorDriver hypervisor_driver = {
     .domainGetGuestVcpus = remoteDomainGetGuestVcpus, /* 2.0.0 */
     .domainSetGuestVcpus = remoteDomainSetGuestVcpus, /* 2.0.0 */
     .domainSetVcpu = remoteDomainSetVcpu, /* 3.1.0 */
+    .domainSetBlockThreshold = remoteDomainSetBlockThreshold, /* 3.2.0 */
 };
 
 static virNetworkDriver network_driver = {
index 39dd2b728ea0a1df025656c3c759d7d0115a5d1e..87b2bd365a0b27280d4480937a82ce9a312c4e57 100644 (file)
@@ -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 = 385
+    REMOTE_PROC_DOMAIN_EVENT_BLOCK_THRESHOLD = 385,
+
+    /**
+     * @generate: both
+     * @acl: domain:write
+     */
+    REMOTE_PROC_DOMAIN_SET_BLOCK_THRESHOLD = 386
+
 
 };
index 67e43a4acd28a3bfdcb4b2782cb313556f45bbeb..a46fe37bfb00897d101f113085566e796b812e8c 100644 (file)
@@ -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 = 1,
         REMOTE_PROC_CONNECT_CLOSE = 2,
@@ -3226,4 +3232,5 @@ enum remote_procedure {
         REMOTE_PROC_SECRET_EVENT_VALUE_CHANGED = 383,
         REMOTE_PROC_DOMAIN_SET_VCPU = 384,
         REMOTE_PROC_DOMAIN_EVENT_BLOCK_THRESHOLD = 385,
+        REMOTE_PROC_DOMAIN_SET_BLOCK_THRESHOLD = 386,
 };