[PATCH 2/2] bhyve: implement connectDomainXMLToNative

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

 



The only accepted format for now is 'bhyve-argv' which
prints out a bhyve command corresponding to the given
domain definition.
---
 src/bhyve/bhyve_command.h |  2 ++
 src/bhyve/bhyve_driver.c  | 45 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+)

diff --git a/src/bhyve/bhyve_command.h b/src/bhyve/bhyve_command.h
index 7a38353..31de97a 100644
--- a/src/bhyve/bhyve_command.h
+++ b/src/bhyve/bhyve_command.h
@@ -27,6 +27,8 @@
 # include "domain_conf.h"
 # include "vircommand.h"
 
+# define BHYVE_CONFIG_FORMAT_ARGV "bhyve-argv"
+
 virCommandPtr virBhyveProcessBuildBhyveCmd(bhyveConnPtr,
                              virDomainDefPtr def, bool dryRun);
 
diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index fd8c248..b68421b 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -53,6 +53,7 @@
 #include "nodeinfo.h"
 
 #include "bhyve_driver.h"
+#include "bhyve_command.h"
 #include "bhyve_process.h"
 #include "bhyve_utils.h"
 #include "bhyve_capabilities.h"
@@ -587,6 +588,49 @@ bhyveConnectNumOfDefinedDomains(virConnectPtr conn)
     return count;
 }
 
+static char *
+bhyveConnectDomainXMLToNative(virConnectPtr conn,
+                              const char *format,
+                              const char *xmlData,
+                              unsigned int flags)
+{
+    bhyveConnPtr privconn = conn->privateData;
+    virDomainDefPtr def = NULL;
+    virCommandPtr cmd = NULL;
+    virCapsPtr caps = NULL;
+    char *ret = NULL;
+
+    virCheckFlags(0, NULL);
+
+    if (virConnectDomainXMLToNativeEnsureACL(conn) < 0)
+        goto cleanup;
+
+    if (STRNEQ(format, BHYVE_CONFIG_FORMAT_ARGV)) {
+        virReportError(VIR_ERR_INVALID_ARG,
+                       _("Unsupported config type %s"), format);
+        goto cleanup;
+    }
+
+    if (!(caps = bhyveDriverGetCapabilities(privconn)))
+        goto cleanup;
+
+    if (!(def = virDomainDefParseString(xmlData, caps, privconn->xmlopt,
+                                  1 << VIR_DOMAIN_VIRT_BHYVE,
+                                  VIR_DOMAIN_XML_INACTIVE)))
+        goto cleanup;
+
+    if (!(cmd = virBhyveProcessBuildBhyveCmd(privconn, def, true)))
+        goto cleanup;
+
+    ret = virCommandToString(cmd);
+
+ cleanup:
+    virCommandFree(cmd);
+    virDomainDefFree(def);
+    virObjectUnref(caps);
+    return ret;
+}
+
 static int
 bhyveConnectListAllDomains(virConnectPtr conn,
                            virDomainPtr **domains,
@@ -1122,6 +1166,7 @@ static virDriver bhyveDriver = {
     .connectListAllDomains = bhyveConnectListAllDomains, /* 1.2.2 */
     .connectListDefinedDomains = bhyveConnectListDefinedDomains, /* 1.2.2 */
     .connectNumOfDefinedDomains = bhyveConnectNumOfDefinedDomains, /* 1.2.2 */
+    .connectDomainXMLToNative = bhyveConnectDomainXMLToNative, /* 1.2.4 */
     .domainCreate = bhyveDomainCreate, /* 1.2.2 */
     .domainCreateWithFlags = bhyveDomainCreateWithFlags, /* 1.2.3 */
     .domainDestroy = bhyveDomainDestroy, /* 1.2.2 */
-- 
1.9.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]