|
|
898951 |
From 9c171ebceeed9cf28f0e86e0de604805e3669bdf Mon Sep 17 00:00:00 2001
|
|
|
898951 |
Message-Id: <9c171ebceeed9cf28f0e86e0de604805e3669bdf@dist-git>
|
|
|
898951 |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
898951 |
Date: Thu, 22 Jan 2015 15:53:48 +0100
|
|
|
898951 |
Subject: [PATCH] lxc: Add metadata modification APIs
|
|
|
898951 |
|
|
|
898951 |
https://bugzilla.redhat.com/show_bug.cgi?id=1184929
|
|
|
898951 |
|
|
|
898951 |
(cherry picked from commit f9c7b32e5de3fb0ccf2e0858716886bdb35a9913)
|
|
|
898951 |
|
|
|
898951 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
898951 |
---
|
|
|
898951 |
src/lxc/lxc_driver.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
898951 |
1 file changed, 70 insertions(+)
|
|
|
898951 |
|
|
|
898951 |
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
|
|
|
898951 |
index 1aaa6e7..e9f2f51 100644
|
|
|
898951 |
--- a/src/lxc/lxc_driver.c
|
|
|
898951 |
+++ b/src/lxc/lxc_driver.c
|
|
|
898951 |
@@ -4702,6 +4702,74 @@ lxcNodeSuspendForDuration(virConnectPtr conn,
|
|
|
898951 |
}
|
|
|
898951 |
|
|
|
898951 |
|
|
|
898951 |
+static int
|
|
|
898951 |
+lxcDomainSetMetadata(virDomainPtr dom,
|
|
|
898951 |
+ int type,
|
|
|
898951 |
+ const char *metadata,
|
|
|
898951 |
+ const char *key,
|
|
|
898951 |
+ const char *uri,
|
|
|
898951 |
+ unsigned int flags)
|
|
|
898951 |
+{
|
|
|
898951 |
+ virLXCDriverPtr driver = dom->conn->privateData;
|
|
|
898951 |
+ virDomainObjPtr vm;
|
|
|
898951 |
+ virLXCDriverConfigPtr cfg = NULL;
|
|
|
898951 |
+ virCapsPtr caps = NULL;
|
|
|
898951 |
+ int ret = -1;
|
|
|
898951 |
+
|
|
|
898951 |
+ virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
|
|
|
898951 |
+ VIR_DOMAIN_AFFECT_CONFIG, -1);
|
|
|
898951 |
+
|
|
|
898951 |
+ if (!(vm = lxcDomObjFromDomain(dom)))
|
|
|
898951 |
+ return -1;
|
|
|
898951 |
+
|
|
|
898951 |
+ cfg = virLXCDriverGetConfig(driver);
|
|
|
898951 |
+
|
|
|
898951 |
+ if (virDomainSetMetadataEnsureACL(dom->conn, vm->def, flags) < 0)
|
|
|
898951 |
+ goto cleanup;
|
|
|
898951 |
+
|
|
|
898951 |
+ if (!(caps = virLXCDriverGetCapabilities(driver, false)))
|
|
|
898951 |
+ goto cleanup;
|
|
|
898951 |
+
|
|
|
898951 |
+ ret = virDomainObjSetMetadata(vm, type, metadata, key, uri, caps,
|
|
|
898951 |
+ driver->xmlopt, cfg->configDir, flags);
|
|
|
898951 |
+
|
|
|
898951 |
+cleanup:
|
|
|
898951 |
+ virObjectUnlock(vm);
|
|
|
898951 |
+ virObjectUnref(caps);
|
|
|
898951 |
+ virObjectUnref(cfg);
|
|
|
898951 |
+ return ret;
|
|
|
898951 |
+}
|
|
|
898951 |
+
|
|
|
898951 |
+
|
|
|
898951 |
+static char *
|
|
|
898951 |
+lxcDomainGetMetadata(virDomainPtr dom,
|
|
|
898951 |
+ int type,
|
|
|
898951 |
+ const char *uri,
|
|
|
898951 |
+ unsigned int flags)
|
|
|
898951 |
+{
|
|
|
898951 |
+ virLXCDriverPtr driver = dom->conn->privateData;
|
|
|
898951 |
+ virCapsPtr caps = NULL;
|
|
|
898951 |
+ virDomainObjPtr vm;
|
|
|
898951 |
+ char *ret = NULL;
|
|
|
898951 |
+
|
|
|
898951 |
+ if (!(vm = lxcDomObjFromDomain(dom)))
|
|
|
898951 |
+ return NULL;
|
|
|
898951 |
+
|
|
|
898951 |
+ if (virDomainGetMetadataEnsureACL(dom->conn, vm->def) < 0)
|
|
|
898951 |
+ goto cleanup;
|
|
|
898951 |
+
|
|
|
898951 |
+ if (!(caps = virLXCDriverGetCapabilities(driver, false)))
|
|
|
898951 |
+ goto cleanup;
|
|
|
898951 |
+
|
|
|
898951 |
+ ret = virDomainObjGetMetadata(vm, type, uri, caps, driver->xmlopt, flags);
|
|
|
898951 |
+
|
|
|
898951 |
+cleanup:
|
|
|
898951 |
+ virObjectUnlock(vm);
|
|
|
898951 |
+ virObjectUnref(caps);
|
|
|
898951 |
+ return ret;
|
|
|
898951 |
+}
|
|
|
898951 |
+
|
|
|
898951 |
+
|
|
|
898951 |
/* Function Tables */
|
|
|
898951 |
static virDriver lxcDriver = {
|
|
|
898951 |
.no = VIR_DRV_LXC,
|
|
|
898951 |
@@ -4776,6 +4844,8 @@ static virDriver lxcDriver = {
|
|
|
898951 |
.domainOpenConsole = lxcDomainOpenConsole, /* 0.8.6 */
|
|
|
898951 |
.connectIsAlive = lxcConnectIsAlive, /* 0.9.8 */
|
|
|
898951 |
.nodeSuspendForDuration = lxcNodeSuspendForDuration, /* 0.9.8 */
|
|
|
898951 |
+ .domainSetMetadata = lxcDomainSetMetadata, /* 1.1.3 */
|
|
|
898951 |
+ .domainGetMetadata = lxcDomainGetMetadata, /* 1.1.3 */
|
|
|
898951 |
.nodeGetMemoryParameters = lxcNodeGetMemoryParameters, /* 0.10.2 */
|
|
|
898951 |
.nodeSetMemoryParameters = lxcNodeSetMemoryParameters, /* 0.10.2 */
|
|
|
898951 |
.domainSendProcessSignal = lxcDomainSendProcessSignal, /* 1.0.1 */
|
|
|
898951 |
--
|
|
|
898951 |
2.2.1
|
|
|
898951 |
|