[PATCH 2/2] test_driver: implement virConnectDomainXMLFromNative

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Since this is the test driver, we can pretend that the native hypervisor
representation is the same as libvirt's domain XML.

Signed-off-by: Ilias Stamatis <stamatis.iliass@xxxxxxxxx>
---
 src/test/test_driver.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index ec1d3cacbc..6bf25d0c4a 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -1596,6 +1596,35 @@ static char *testConnectDomainXMLToNative(virConnectPtr conn,
 }


+static char *testConnectDomainXMLFromNative(virConnectPtr conn,
+                                            const char *format,
+                                            const char *config,
+                                            unsigned int flags)
+{
+    char *ret = NULL;
+    virDomainDefPtr def = NULL;
+    testDriverPtr privconn = conn->privateData;
+
+    virCheckFlags(0, NULL);
+
+    if (STRNEQ(format, TEST_CONFIG_FORMAT_ARGV)) {
+        virReportError(VIR_ERR_INVALID_ARG,
+                       _("Unsupported config format '%s'"), format);
+        return NULL;
+    }
+
+    if ((def = virDomainDefParseString(config, privconn->caps, privconn->xmlopt, NULL,
+                                       VIR_DOMAIN_DEF_PARSE_INACTIVE)) == NULL)
+        goto cleanup;
+
+    ret = virDomainDefFormat(def, privconn->caps, 0);
+
+ cleanup:
+    virDomainDefFree(def);
+    return ret;
+}
+
+
 static int testDomainIsActive(virDomainPtr dom)
 {
     virDomainObjPtr obj;
@@ -7032,6 +7061,7 @@ static virHypervisorDriver testHypervisorDriver = {
     .connectListDomains = testConnectListDomains, /* 0.1.1 */
     .connectNumOfDomains = testConnectNumOfDomains, /* 0.1.1 */
     .connectDomainXMLToNative = testConnectDomainXMLToNative, /* 5.5.0 */
+    .connectDomainXMLFromNative = testConnectDomainXMLFromNative, /* 5.5.0 */
     .connectListAllDomains = testConnectListAllDomains, /* 0.9.13 */
     .domainCreateXML = testDomainCreateXML, /* 0.1.4 */
     .domainLookupByID = testDomainLookupByID, /* 0.1.1 */
--
2.21.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux