提交 32916b16 编写于 作者: F Fabian Freyer 提交者: Roman Bogorodskiy

bhyve: implement virConnectGetDomainCapabilities

上级 9bbb3676
......@@ -3,6 +3,7 @@
*
* Copyright (C) 2014 Roman Bogorodskiy
* Copyright (C) 2014 Semihalf
* Copyright (C) 2016 Fabian Freyer
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -106,6 +107,31 @@ virBhyveCapsBuild(void)
return NULL;
}
virDomainCapsPtr
virBhyveDomainCapsBuild(const char *emulatorbin,
const char *machine,
virArch arch,
virDomainVirtType virttype)
{
virDomainCapsPtr caps = NULL;
if (!(caps = virDomainCapsNew(emulatorbin, machine, arch, virttype)))
goto cleanup;
caps->os.supported = true;
caps->disk.supported = true;
VIR_DOMAIN_CAPS_ENUM_SET(caps->disk.diskDevice,
VIR_DOMAIN_DISK_DEVICE_DISK,
VIR_DOMAIN_DISK_DEVICE_CDROM);
VIR_DOMAIN_CAPS_ENUM_SET(caps->disk.bus,
VIR_DOMAIN_DISK_BUS_SATA,
VIR_DOMAIN_DISK_BUS_VIRTIO);
cleanup:
return caps;
}
int
virBhyveProbeGrubCaps(virBhyveGrubCapsFlags *caps)
{
......
......@@ -23,8 +23,13 @@
# define _BHYVE_CAPABILITIES
# include "capabilities.h"
# include "conf/domain_capabilities.h"
virCapsPtr virBhyveCapsBuild(void);
virDomainCapsPtr virBhyveDomainCapsBuild(const char *emulatorbin,
const char *machine,
virArch arch,
virDomainVirtType virttype);
/* These are bit flags: */
typedef enum {
......
......@@ -53,6 +53,7 @@
#include "nodeinfo.h"
#include "virhostcpu.h"
#include "virhostmem.h"
#include "conf/domain_capabilities.h"
#include "bhyve_device.h"
#include "bhyve_driver.h"
......@@ -1572,6 +1573,72 @@ bhyveConnectDomainXMLFromNative(virConnectPtr conn,
return xml;
}
static char *
bhyveConnectGetDomainCapabilities(virConnectPtr conn,
const char *emulatorbin,
const char *arch_str,
const char *machine,
const char *virttype_str,
unsigned int flags)
{
virDomainCapsPtr caps = NULL;
char *ret = NULL;
int virttype = VIR_DOMAIN_VIRT_BHYVE;
int arch = virArchFromHost(); /* virArch */
virCheckFlags(0, ret);
if (virConnectGetDomainCapabilitiesEnsureACL(conn) < 0)
return ret;
if (virttype_str &&
(virttype = virDomainVirtTypeFromString(virttype_str)) < 0) {
virReportError(VIR_ERR_INVALID_ARG,
_("unknown virttype: %s"),
virttype_str);
goto cleanup;
}
if (virttype != VIR_DOMAIN_VIRT_BHYVE) {
virReportError(VIR_ERR_INVALID_ARG,
_("unknown virttype: %s"),
virttype_str);
goto cleanup;
}
if (arch_str && (arch = virArchFromString(arch_str)) == VIR_ARCH_NONE) {
virReportError(VIR_ERR_INVALID_ARG,
_("unknown architecture: %s"),
arch_str);
goto cleanup;
}
if (!ARCH_IS_X86(arch)) {
virReportError(VIR_ERR_NO_SUPPORT,
_("unsupported architecture: %s"),
virArchToString(arch));
goto cleanup;
}
if (emulatorbin == NULL) {
emulatorbin = "/usr/sbin/bhyve";
} else if (STRNEQ(emulatorbin, "/usr/sbin/bhyve")) {
virReportError(VIR_ERR_INVALID_ARG,
_("unknown emulator binary: %s"),
emulatorbin);
goto cleanup;
}
if (!(caps = virBhyveDomainCapsBuild(emulatorbin, machine, arch, virttype)))
goto cleanup;
ret = virDomainCapsFormat(caps);
cleanup:
virObjectUnref(caps);
return ret;
}
static virHypervisorDriver bhyveHypervisorDriver = {
.name = "bhyve",
.connectOpen = bhyveConnectOpen, /* 1.2.2 */
......@@ -1626,6 +1693,7 @@ static virHypervisorDriver bhyveHypervisorDriver = {
.connectIsSecure = bhyveConnectIsSecure, /* 1.3.5 */
.connectIsEncrypted = bhyveConnectIsEncrypted, /* 1.3.5 */
.connectDomainXMLFromNative = bhyveConnectDomainXMLFromNative, /* 2.1.0 */
.connectGetDomainCapabilities = bhyveConnectGetDomainCapabilities, /* 2.1.0 */
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册