render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
Blob Blame History Raw
From 5b8a0bcaacd16703b069ba1cf70e8259534eaf69 Mon Sep 17 00:00:00 2001
Message-Id: <5b8a0bcaacd16703b069ba1cf70e8259534eaf69@dist-git>
From: Peter Krempa <pkrempa@redhat.com>
Date: Thu, 22 Jan 2015 15:53:49 +0100
Subject: [PATCH] test: Add <metadata> support into the test driver

https://bugzilla.redhat.com/show_bug.cgi?id=1184929

(cherry picked from commit f616fbf2a4a31a2f944aae0b75d6e2ab3bef3573)

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/test/test_driver.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)

diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index f7eaf06..4d23738 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -2528,6 +2528,72 @@ cleanup:
     return ret;
 }
 
+static char *testDomainGetMetadata(virDomainPtr dom,
+                                   int type,
+                                   const char *uri,
+                                   unsigned int flags)
+{
+    testConnPtr privconn = dom->conn->privateData;
+    virDomainObjPtr privdom;
+    char *ret = NULL;
+
+    virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
+                  VIR_DOMAIN_AFFECT_CONFIG, NULL);
+
+    testDriverLock(privconn);
+    privdom = virDomainObjListFindByName(privconn->domains,
+                                         dom->name);
+    testDriverUnlock(privconn);
+
+    if (privdom == NULL) {
+        virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
+        goto cleanup;
+    }
+
+    ret = virDomainObjGetMetadata(privdom, type, uri, privconn->caps,
+                                  privconn->xmlopt, flags);
+
+cleanup:
+    if (privdom)
+        virObjectUnlock(privdom);
+    return ret;
+}
+
+static int testDomainSetMetadata(virDomainPtr dom,
+                                 int type,
+                                 const char *metadata,
+                                 const char *key,
+                                 const char *uri,
+                                 unsigned int flags)
+{
+    testConnPtr privconn = dom->conn->privateData;
+    virDomainObjPtr privdom;
+    int ret = -1;
+
+    virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
+                  VIR_DOMAIN_AFFECT_CONFIG, -1);
+
+    testDriverLock(privconn);
+    privdom = virDomainObjListFindByName(privconn->domains,
+                                         dom->name);
+    testDriverUnlock(privconn);
+
+    if (privdom == NULL) {
+        virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
+        goto cleanup;
+    }
+
+    ret = virDomainObjSetMetadata(privdom, type, metadata, key, uri,
+                                  privconn->caps, privconn->xmlopt,
+                                  NULL, flags);
+
+cleanup:
+    if (privdom)
+        virObjectUnlock(privdom);
+    return ret;
+}
+
+
 static int testNodeGetCellsFreeMemory(virConnectPtr conn,
                                       unsigned long long *freemems,
                                       int startCell, int maxCells) {
@@ -5815,6 +5881,8 @@ static virDriver testDriver = {
     .connectIsAlive = testConnectIsAlive, /* 0.9.8 */
     .nodeGetCPUMap = testNodeGetCPUMap, /* 1.0.0 */
     .domainScreenshot = testDomainScreenshot, /* 1.0.5 */
+    .domainGetMetadata = testDomainGetMetadata, /* 1.1.3 */
+    .domainSetMetadata = testDomainSetMetadata, /* 1.1.3 */
 };
 
 static virNetworkDriver testNetworkDriver = {
-- 
2.2.1