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 | 59 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 61 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..0a849ca 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,63 @@ bhyveConnectNumOfDefinedDomains(virConnectPtr conn)
return count;
}
+static char *
+bhyveConnectDomainXMLToNative(virConnectPtr conn,
+ const char *format,
+ const char *xmlData,
+ unsigned int flags)
+{
+ virBuffer buf = VIR_BUFFER_INITIALIZER;
+ bhyveConnPtr privconn = conn->privateData;
+ virDomainDefPtr def = NULL;
+ virCommandPtr cmd = NULL, loadcmd = 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 (!(loadcmd = virBhyveProcessBuildLoadCmd(privconn, def)))
+ goto cleanup;
+
+ if (!(cmd = virBhyveProcessBuildBhyveCmd(privconn, def, true)))
+ goto cleanup;
+
+ virBufferAdd(&buf, virCommandToString(loadcmd), -1);
+ virBufferAddChar(&buf, '\n');
+ virBufferAdd(&buf, virCommandToString(cmd), -1);
+
+ if (virBufferError(&buf)) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ ret = virBufferContentAndReset(&buf);
+
+ cleanup:
+ virCommandFree(loadcmd);
+ virCommandFree(cmd);
+ virDomainDefFree(def);
+ virObjectUnref(caps);
+ return ret;
+}
+
static int
bhyveConnectListAllDomains(virConnectPtr conn,
virDomainPtr **domains,
@@ -1122,6 +1180,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