mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
bhyve: implement connectDomainXMLToNative
The only accepted format for now is 'bhyve-argv' which prints out a bhyve command corresponding to the given domain definition.
This commit is contained in:
parent
07e371fc36
commit
747ed3e657
@ -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);
|
||||
|
||||
|
@ -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"
|
||||
@ -593,6 +594,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,
|
||||
@ -1187,6 +1245,7 @@ static virDriver bhyveDriver = {
|
||||
.connectListAllDomains = bhyveConnectListAllDomains, /* 1.2.2 */
|
||||
.connectListDefinedDomains = bhyveConnectListDefinedDomains, /* 1.2.2 */
|
||||
.connectNumOfDefinedDomains = bhyveConnectNumOfDefinedDomains, /* 1.2.2 */
|
||||
.connectDomainXMLToNative = bhyveConnectDomainXMLToNative, /* 1.2.5 */
|
||||
.domainCreate = bhyveDomainCreate, /* 1.2.2 */
|
||||
.domainCreateWithFlags = bhyveDomainCreateWithFlags, /* 1.2.3 */
|
||||
.domainCreateXML = bhyveDomainCreateXML, /* 1.2.4 */
|
||||
|
Loading…
x
Reference in New Issue
Block a user