int state,
unsigned int flags);
+int virDomainSetBlockThreshold(virDomainPtr domain,
+ const char *dev,
+ unsigned long long threshold,
+ unsigned int flags);
+
#endif /* __VIR_LIBVIRT_DOMAIN_H__ */
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;
virDrvDomainGetGuestVcpus domainGetGuestVcpus;
virDrvDomainSetGuestVcpus domainSetGuestVcpus;
virDrvDomainSetVcpu domainSetVcpu;
+ virDrvDomainSetBlockThreshold domainSetBlockThreshold;
};
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;
+}
LIBVIRT_3.1.0 {
global:
+ virDomainSetBlockThreshold;
virDomainSetVcpu;
} LIBVIRT_3.0.0;
.domainGetGuestVcpus = remoteDomainGetGuestVcpus, /* 2.0.0 */
.domainSetGuestVcpus = remoteDomainSetGuestVcpus, /* 2.0.0 */
.domainSetVcpu = remoteDomainSetVcpu, /* 3.1.0 */
+ .domainSetBlockThreshold = remoteDomainSetBlockThreshold, /* 3.2.0 */
};
static virNetworkDriver network_driver = {
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. */
* @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
+
};
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,
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,
};