mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
bhyve: implement virConnectGetDomainCapabilities
This commit is contained in:
parent
9bbb36764f
commit
32916b1699
@ -3,6 +3,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (C) 2014 Roman Bogorodskiy
|
* Copyright (C) 2014 Roman Bogorodskiy
|
||||||
* Copyright (C) 2014 Semihalf
|
* Copyright (C) 2014 Semihalf
|
||||||
|
* Copyright (C) 2016 Fabian Freyer
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -106,6 +107,31 @@ virBhyveCapsBuild(void)
|
|||||||
return NULL;
|
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
|
int
|
||||||
virBhyveProbeGrubCaps(virBhyveGrubCapsFlags *caps)
|
virBhyveProbeGrubCaps(virBhyveGrubCapsFlags *caps)
|
||||||
{
|
{
|
||||||
|
@ -23,8 +23,13 @@
|
|||||||
# define _BHYVE_CAPABILITIES
|
# define _BHYVE_CAPABILITIES
|
||||||
|
|
||||||
# include "capabilities.h"
|
# include "capabilities.h"
|
||||||
|
# include "conf/domain_capabilities.h"
|
||||||
|
|
||||||
virCapsPtr virBhyveCapsBuild(void);
|
virCapsPtr virBhyveCapsBuild(void);
|
||||||
|
virDomainCapsPtr virBhyveDomainCapsBuild(const char *emulatorbin,
|
||||||
|
const char *machine,
|
||||||
|
virArch arch,
|
||||||
|
virDomainVirtType virttype);
|
||||||
|
|
||||||
/* These are bit flags: */
|
/* These are bit flags: */
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -53,6 +53,7 @@
|
|||||||
#include "nodeinfo.h"
|
#include "nodeinfo.h"
|
||||||
#include "virhostcpu.h"
|
#include "virhostcpu.h"
|
||||||
#include "virhostmem.h"
|
#include "virhostmem.h"
|
||||||
|
#include "conf/domain_capabilities.h"
|
||||||
|
|
||||||
#include "bhyve_device.h"
|
#include "bhyve_device.h"
|
||||||
#include "bhyve_driver.h"
|
#include "bhyve_driver.h"
|
||||||
@ -1572,6 +1573,72 @@ bhyveConnectDomainXMLFromNative(virConnectPtr conn,
|
|||||||
return xml;
|
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 = {
|
static virHypervisorDriver bhyveHypervisorDriver = {
|
||||||
.name = "bhyve",
|
.name = "bhyve",
|
||||||
.connectOpen = bhyveConnectOpen, /* 1.2.2 */
|
.connectOpen = bhyveConnectOpen, /* 1.2.2 */
|
||||||
@ -1626,6 +1693,7 @@ static virHypervisorDriver bhyveHypervisorDriver = {
|
|||||||
.connectIsSecure = bhyveConnectIsSecure, /* 1.3.5 */
|
.connectIsSecure = bhyveConnectIsSecure, /* 1.3.5 */
|
||||||
.connectIsEncrypted = bhyveConnectIsEncrypted, /* 1.3.5 */
|
.connectIsEncrypted = bhyveConnectIsEncrypted, /* 1.3.5 */
|
||||||
.connectDomainXMLFromNative = bhyveConnectDomainXMLFromNative, /* 2.1.0 */
|
.connectDomainXMLFromNative = bhyveConnectDomainXMLFromNative, /* 2.1.0 */
|
||||||
|
.connectGetDomainCapabilities = bhyveConnectGetDomainCapabilities, /* 2.1.0 */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user