On 01/13/2012 11:17 AM, Peter Krempa wrote:
The <description> element was accessible only throught the XML,
that
s/throught/through/
makes it hard to work with. Atomic operations and modification of
the
live domain are impossible. This patch adds a function to the public API
to set arbitrary descriptions for live and persistent domains.
Do we want a counterpart getter function, or is dumpxml and XPath
filtering good enough?
+++ b/include/libvirt/libvirt.h.in
@@ -1405,6 +1405,21 @@ int virDomainGetMaxVcpus (virDomainPtr
domain);
int virDomainGetSecurityLabel (virDomainPtr domain,
virSecurityLabelPtr seclabel);
+typedef enum {
+ /* See virDomainModificationImpact for these flags. */
+ VIR_DOMAIN_DESCRIPTION_CURRENT = VIR_DOMAIN_AFFECT_CURRENT,
+ VIR_DOMAIN_DESCRIPTION_LIVE = VIR_DOMAIN_AFFECT_LIVE,
+ VIR_DOMAIN_DESCRIPTION_CONFIG = VIR_DOMAIN_AFFECT_CONFIG,
I'm not sure whether we need to create these new aliases, or just state
that @flags is a mix of virDomainModificationImpact and
virDomainDescriptionFlags, and leave a comment here stating why bits 0
and 1 are reserved.
+ /* Additionaly, these flags may be bitwise-OR'd in. */
s/Additionaly/Additionally/
+++ b/src/libvirt.c
@@ -8746,6 +8746,53 @@ error:
}
/**
+ * virDomainSetDescription:
+ * @domain: a domain object
+ * @description: new description text
+ * @flags: bitwise-OR of virDomainDescriptionFlags
+ *
+ * Sets the domain description field or note field depending on the flags
+ * parameter.
+ *
+ * Returns 0 on success, -1 in case of failure;
Looks reasonable.
+ */
+int
+virDomainSetDescription(virDomainPtr domain,
+ const char *description,
+ unsigned int flags)
+{
+ virConnectPtr conn;
+
+ VIR_DOMAIN_DEBUG(domain, "description=%p, flags=%x", description, flags);
+
+ if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
+ virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ goto error;
+ }
You need to reject this operation on a read-only connection.
--
Eric Blake eblake(a)redhat.com +1-919-301-3266
Libvirt virtualization library
http://libvirt.org