[libvirt PATCH] meson: add -Wall and -Wextra explicitly for buildtype=plain
by Pavel Hrdina
If someone runs `meson setup --buildtype plain` meson ignores
warning_level=2 that is in our meson.build file. The implication is
that Meson will not automatically add -Wall which enables -Wformat.
This breaks building libvirt from git with the buildtype set to plain.
There is an issue reported [1] to not ignore warning_level silently
and the change to ignore it was done by upstream commit [2].
[1] <https://github.com/mesonbuild/meson/issues/7399>
[2] <https://github.com/mesonbuild/meson/commit/8ee1c9a07a3a35e3ed262fbc358fd8...>
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
meson.build | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/meson.build b/meson.build
index e193166a9b..f38785eeae 100644
--- a/meson.build
+++ b/meson.build
@@ -503,10 +503,6 @@ cc_flags_disabled = [
# In meson this is specified using 'c_std=gnu99' in project() function.
'-std=gnu99',
- # In meson this is specified using 'warning_level=2' in project() function.
- '-Wall',
- '-Wextra',
-
# don't care about C++ compiler compat
'-Wc++-compat',
'-Wabi',
@@ -573,6 +569,21 @@ cc_flags_disabled = [
'-Wsuggest-attribute=malloc',
]
+# In meson this is specified using 'warning_level=2' in project() function.
+# However, meson silently ignores 'warning_level' option with 'buildtype=plain'
+# so we have to enable them explicitly.
+if get_option('buildtype') == 'plain'
+ cc_flags += [
+ '-Wall',
+ '-Wextra',
+ ]
+else
+ cc_flags_disabled += [
+ '-Wall',
+ '-Wextra',
+ ]
+endif
+
foreach flag : cc_flags_disabled
if cc_flags.contains(flag)
error('@0@ is disabled but listed in cc_flags'.format(flag))
--
2.26.2
4 years, 2 months
[libvirt PATCH] util: virnetdevtap: stats: fix txdrop on FreeBSD
by Ján Tomko
For older FreeBSD, we needed an ifdef guard to use
if_data.ifi_oqdrops, which was introduced by:
commit 61bbdbb94ce3e2f5e969c9bddb443427db07bf61
Implement interface stats for BSD
But when we dropped the check because we deprecated
building on FreeBSD-10 in:
commit 83131d9714db7ee77ab220186b6b0d8b6c22b09e
configure: drop check for unsupported FreeBSD
We started building the wrong side of the ifdef.
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
Fixes: 83131d9714db7ee77ab220186b6b0d8b6c22b09e
---
src/util/virnetdevtap.c | 8 --------
1 file changed, 8 deletions(-)
diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c
index 9f5e535180..cab5ef0ced 100644
--- a/src/util/virnetdevtap.c
+++ b/src/util/virnetdevtap.c
@@ -974,20 +974,12 @@ virNetDevTapInterfaceStats(const char *ifname,
stats->rx_bytes = ifd->ifi_obytes;
stats->rx_packets = ifd->ifi_opackets;
stats->rx_errs = ifd->ifi_oerrors;
-# ifdef HAVE_STRUCT_IF_DATA_IFI_OQDROPS
stats->rx_drop = ifd->ifi_oqdrops;
-# else
- stats->rx_drop = 0;
-# endif
} else {
stats->tx_bytes = ifd->ifi_obytes;
stats->tx_packets = ifd->ifi_opackets;
stats->tx_errs = ifd->ifi_oerrors;
-# ifdef HAVE_STRUCT_IF_DATA_IFI_OQDROPS
stats->tx_drop = ifd->ifi_oqdrops;
-# else
- stats->tx_drop = 0;
-# endif
stats->rx_bytes = ifd->ifi_ibytes;
stats->rx_packets = ifd->ifi_ipackets;
stats->rx_errs = ifd->ifi_ierrors;
--
2.26.2
4 years, 2 months
[libvirt PATCH v2] Adds e1000e/vmxnet3 Vnet_hdr suuport
by Patrick Magauran
Changes from Original:
Moved Comparison to qemuInterfaceIsVnetCompatModel in qemu_interface.c per the recommendation of Daniel Berrangé
-----
Libvirt bases its decision about whether to apply the vnet_hdr flag to the tap interface on whether or not the selected model is VirtIO. Originally, VirtIO was the only model to support the vnet_hdr in QEMU; however, the e1000e & vmxnet3 adapters also support it(seemingly from introduction based on commits). This passes the whole packet to the host, reducing emulation overhead and improving performance.
Signed-off-by: Patrick Magauran <patmagauran.j(a)gmail.com>
---
src/qemu/qemu_interface.c | 15 +++++++++++----
src/qemu/qemu_interface.h | 1 +
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_interface.c b/src/qemu/qemu_interface.c
index ffec992596..229bb299aa 100644
--- a/src/qemu/qemu_interface.c
+++ b/src/qemu/qemu_interface.c
@@ -230,6 +230,13 @@ qemuInterfaceStopDevices(virDomainDefPtr def)
return 0;
}
+bool qemuInterfaceIsVnetCompatModel(const virDomainNetDef *net)
+{
+ return (virDomainNetIsVirtioModel(net) ||
+ net->model == VIR_DOMAIN_NET_MODEL_E1000E ||
+ net->model == VIR_DOMAIN_NET_MODEL_VMXNET3);
+}
+
/**
* qemuInterfaceDirectConnect:
@@ -255,7 +262,7 @@ qemuInterfaceDirectConnect(virDomainDefPtr def,
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
unsigned int macvlan_create_flags = VIR_NETDEV_MACVLAN_CREATE_WITH_TAP;
- if (virDomainNetIsVirtioModel(net))
+ if (qemuInterfaceIsVnetCompatModel(net))
macvlan_create_flags |= VIR_NETDEV_MACVLAN_VNET_HDR;
if (virNetDevMacVLanCreateWithVPortProfile(net->ifname,
@@ -417,7 +424,7 @@ qemuInterfaceEthernetConnect(virDomainDefPtr def,
}
}
- if (virDomainNetIsVirtioModel(net))
+ if (qemuInterfaceIsVnetCompatModel(net))
tap_create_flags |= VIR_NETDEV_TAP_CREATE_VNET_HDR;
if (net->managed_tap == VIR_TRISTATE_BOOL_NO) {
@@ -436,7 +443,7 @@ qemuInterfaceEthernetConnect(virDomainDefPtr def,
if (virNetDevMacVLanTapOpen(net->ifname, tapfd, tapfdSize) < 0)
goto cleanup;
if (virNetDevMacVLanTapSetup(tapfd, tapfdSize,
- virDomainNetIsVirtioModel(net)) < 0) {
+ qemuInterfaceIsVnetCompatModel(net)) < 0) {
goto cleanup;
}
} else {
@@ -559,7 +566,7 @@ qemuInterfaceBridgeConnect(virDomainDefPtr def,
template_ifname = true;
}
- if (virDomainNetIsVirtioModel(net))
+ if (qemuInterfaceIsVnetCompatModel(net))
tap_create_flags |= VIR_NETDEV_TAP_CREATE_VNET_HDR;
if (driver->privileged) {
diff --git a/src/qemu/qemu_interface.h b/src/qemu/qemu_interface.h
index 0464b903d7..9e3f61e8e0 100644
--- a/src/qemu/qemu_interface.h
+++ b/src/qemu/qemu_interface.h
@@ -58,3 +58,4 @@ int qemuInterfaceOpenVhostNet(virDomainDefPtr def,
qemuSlirpPtr qemuInterfacePrepareSlirp(virQEMUDriverPtr driver,
virDomainNetDefPtr net);
+bool qemuInterfaceIsVnetCompatModel(const virDomainNetDef *net);
--
2.26.2
4 years, 2 months
[PATCH] conf: Don't check virTristateBool < 0
by Jim Fehlig
Commit 9d15647dcb introduced a check of virtTristateBool < 0, which
causes a build failure in some environments
../dist-unpack/libvirt-6.8.0/src/conf/domain_conf.c:8144:78: error:
result of comparison of unsigned enum expression < 0 is always false
[-Werror,-Wtautological-unsigned-enum-zero-compare]
if ((def->writeFiltering = virTristateBoolTypeFromString(filtering)) < 0) {
Fix it by assigning the return value of virTristateBoolTypeFromString
to a temp int variable, which allows checking for unknown values before
assigning to the virtTristateBool variable.
Signed-off-by: Jim Fehlig <jfehlig(a)suse.com>
---
Perhaps considered trivial and could be pushed under the build-breaker
rule, but I'd prefer a review since I've botched trivial patches in the
past :-).
src/conf/domain_conf.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 7d177a5562..5b224ccd78 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -8141,12 +8141,15 @@ virDomainHostdevSubsysPCIDefParseXML(xmlNodePtr node,
xmlNodePtr cur;
if ((filtering = virXMLPropString(node, "writeFiltering"))) {
- if ((def->writeFiltering = virTristateBoolTypeFromString(filtering)) < 0) {
+ int filterval;
+
+ if ((filterval = virTristateBoolTypeFromString(filtering)) < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("unknown pci writeFiltering setting '%s'"),
filtering);
return -1;
}
+ def->writeFiltering = filterval;
}
cur = node->children;
--
2.28.0
4 years, 2 months
[libvirt PATCH] conf: fix enum conversion
by Ján Tomko
../src/conf/domain_conf.c:8144:78: error: result of comparison of unsigned enum expression < 0 is always false [-Werror,-Wtautological-unsigned-enum-zero-compare]
if ((def->writeFiltering = virTristateBoolTypeFromString(filtering)) < 0) {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
Fixes: 9d15647dcb96831c93ac8c1d67c47265b5ed9072
---
Pushed as a build-breaker fix.
src/conf/domain_conf.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 7d177a5562..72ac4f4191 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -8141,12 +8141,14 @@ virDomainHostdevSubsysPCIDefParseXML(xmlNodePtr node,
xmlNodePtr cur;
if ((filtering = virXMLPropString(node, "writeFiltering"))) {
- if ((def->writeFiltering = virTristateBoolTypeFromString(filtering)) < 0) {
+ int val;
+ if ((val = virTristateBoolTypeFromString(filtering)) < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("unknown pci writeFiltering setting '%s'"),
filtering);
return -1;
}
+ def->writeFiltering = val;
}
cur = node->children;
--
2.26.2
4 years, 2 months
[GSoC PATCH 3/9] Jailhouse driver: Implementation of ConnectGetType
by Prakhar Bansal
---
src/jailhouse/jailhouse_driver.c | 28 ++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)
diff --git a/src/jailhouse/jailhouse_driver.c b/src/jailhouse/jailhouse_driver.c
index ac9da4c85d..75bf41fc11 100644
--- a/src/jailhouse/jailhouse_driver.c
+++ b/src/jailhouse/jailhouse_driver.c
@@ -32,8 +32,10 @@
#include "viralloc.h"
#include "virfile.h"
#include "virlog.h"
+#include "virutil.h"
#include "vircommand.h"
#include "virpidfile.h"
+#include "access/viraccessapicheck.h"
#define VIR_FROM_THIS VIR_FROM_JAILHOUSE
@@ -241,16 +243,19 @@ jailhouseStateInitialize(bool privileged G_GNUC_UNUSED,
static const char *
jailhouseConnectGetType(virConnectPtr conn)
{
- UNUSED(conn);
- return NULL;
+ if (virConnectGetTypeEnsureACL(conn) < 0)
+ return NULL;
+ return "JAILHOUSE";
}
static char *
jailhouseConnectGetHostname(virConnectPtr conn)
{
- UNUSED(conn);
- return NULL;
+ if (virConnectGetHostnameEnsureACL(conn) < 0)
+ return NULL;
+
+ return virGetHostname();
}
static int
@@ -263,7 +268,7 @@ jailhouseNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info)
static int
jailhouseConnectListAllDomains(virConnectPtr conn,
- virDomainPtr ** domain, unsigned int flags)
+ virDomainPtr **domain, unsigned int flags)
{
UNUSED(conn);
UNUSED(domain);
@@ -300,7 +305,6 @@ jailhouseDomainCreate(virDomainPtr domain)
{
UNUSED(domain);
return -1;
-
}
static int
@@ -350,18 +354,18 @@ static virHypervisorDriver jailhouseHypervisorDriver = {
.connectOpen = jailhouseConnectOpen, /* 6.3.0 */
.connectClose = jailhouseConnectClose, /* 6.3.0 */
.connectListAllDomains = jailhouseConnectListAllDomains, /* 6.3.0 */
- .domainLookupByID = jailhouseDomainLookupByID, /* 6.3.0 */
- .domainLookupByUUID = jailhouseDomainLookupByUUID, /* 6.3.0 */
- .domainLookupByName = jailhouseDomainLookupByName, /* 6.3.0 */
- .domainGetXMLDesc = jailhouseDomainGetXMLDesc, /* 6.3.0 */
- .domainCreate = jailhouseDomainCreate, /* 6.3.0 */
.connectGetType = jailhouseConnectGetType, /* 6.3.0 */
.connectGetHostname = jailhouseConnectGetHostname, /* 6.3.0 */
- .nodeGetInfo = jailhouseNodeGetInfo, /* 6.3.0 */
+ .domainCreate = jailhouseDomainCreate, /* 6.3.0 */
.domainShutdown = jailhouseDomainShutdown, /* 6.3.0 */
.domainDestroy = jailhouseDomainDestroy, /* 6.3.0 */
.domainGetInfo = jailhouseDomainGetInfo, /* 6.3.0 */
.domainGetState = jailhouseDomainGetState, /* 6.3.0 */
+ .domainLookupByID = jailhouseDomainLookupByID, /* 6.3.0 */
+ .domainLookupByUUID = jailhouseDomainLookupByUUID, /* 6.3.0 */
+ .domainLookupByName = jailhouseDomainLookupByName, /* 6.3.0 */
+ .domainGetXMLDesc = jailhouseDomainGetXMLDesc, /* 6.3.0 */
+ .nodeGetInfo = jailhouseNodeGetInfo, /* 6.3.0 */
};
--
2.17.1
4 years, 2 months
[GSoC PATCH 2/9] Jailhouse driver: Implementation of ConnectOpen
by Prakhar Bansal
---
include/libvirt/virterror.h | 1 +
po/POTFILES.in | 2 +
src/jailhouse/Makefile.inc.am | 34 ++-
src/jailhouse/jailhouse.conf | 10 +
src/jailhouse/jailhouse_api.c | 372 ++++++++++++++++++++++++++++
src/jailhouse/jailhouse_api.h | 74 ++++++
src/jailhouse/jailhouse_driver.c | 302 +++++++++++++++++-----
src/jailhouse/jailhouse_driver.h | 51 ++++
src/jailhouse/meson.build | 1 +
src/libvirt.c | 10 -
src/remote/remote_daemon.c | 4 +
src/remote/remote_daemon_dispatch.c | 3 +-
12 files changed, 783 insertions(+), 81 deletions(-)
create mode 100644 src/jailhouse/jailhouse.conf
create mode 100644 src/jailhouse/jailhouse_api.c
create mode 100644 src/jailhouse/jailhouse_api.h
diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h
index 97f2ac16d8..9f1bca2684 100644
--- a/include/libvirt/virterror.h
+++ b/include/libvirt/virterror.h
@@ -137,6 +137,7 @@ typedef enum {
VIR_FROM_TPM = 70, /* Error from TPM */
VIR_FROM_BPF = 71, /* Error from BPF code */
VIR_FROM_JAILHOUSE = 72, /* Error from Jailhouse driver */
+
# ifdef VIR_ENUM_SENTINELS
VIR_ERR_DOMAIN_LAST
# endif
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 3d6c20c55f..a94285817f 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -85,6 +85,8 @@
@SRCDIR(a)src/interface/interface_backend_netcf.c
@SRCDIR(a)src/interface/interface_backend_udev.c
@SRCDIR(a)src/internal.h
+@SRCDIR(a)src/jailhouse/jailhouse_api.c
+@SRCDIR(a)src/jailhouse/jailhouse_driver.c
@SRCDIR(a)src/libvirt-domain-checkpoint.c
@SRCDIR(a)src/libvirt-domain-snapshot.c
@SRCDIR(a)src/libvirt-domain.c
diff --git a/src/jailhouse/Makefile.inc.am b/src/jailhouse/Makefile.inc.am
index 02822b2ea1..324c3b1b16 100644
--- a/src/jailhouse/Makefile.inc.am
+++ b/src/jailhouse/Makefile.inc.am
@@ -1,8 +1,11 @@
# vim: filetype=automake
+
JAILHOUSE_DRIVER_SOURCES = \
jailhouse/jailhouse_driver.c \
jailhouse/jailhouse_driver.h \
+ jailhouse/jailhouse_api.c \
+ jailhouse/jailhouse_api.h \
$(NULL)
@@ -11,11 +14,34 @@ DRIVER_SOURCE_FILES += $(addprefix
$(srcdir)/,$(JAILHOUSE_DRIVER_SOURCES))
EXTRA_DIST += $(JAILHOUSE_DRIVER_SOURCES)
if WITH_JAILHOUSE
-noinst_LTLIBRARIES += libvirt_driver_jailhouse.la
-libvirt_la_BUILT_LIBADD += libvirt_driver_jailhouse.la
-libvirt_driver_jailhouse_la_CFLAGS = \
+
+noinst_LTLIBRARIES += libvirt_driver_jailhouse_impl.la
+libvirt_driver_jailhouse_la_SOURCES =
+libvirt_driver_jailhouse_la_LIBADD = \
+ libvirt_driver_jailhouse_impl.la \
+ libvirt.la \
+ $(GLIB_LIBS) \
+ $(NULL)
+mod_LTLIBRARIES += libvirt_driver_jailhouse.la
+libvirt_driver_jailhouse_la_LDFLAGS = $(AM_LDFLAGS_MOD_NOUNDEF)
+
+libvirt_driver_jailhouse_impl_la_CFLAGS = \
-I$(srcdir)/conf \
$(AM_CFLAGS) \
$(NULL)
-libvirt_driver_jailhouse_la_SOURCES = $(JAILHOUSE_DRIVER_SOURCES)
+libvirt_driver_jailhouse_impl_la_SOURCES = \
+ $(JAILHOUSE_DRIVER_SOURCES)
+
+sbin_PROGRAMS += virtjailhoused
+
+virtjailhoused_SOURCES = $(REMOTE_DAEMON_SOURCES)
+nodist_virtjailhoused_SOURCES = $(REMOTE_DAEMON_GENERATED)
+virtjailhoused_CFLAGS = \
+ $(REMOTE_DAEMON_CFLAGS) \
+ -DDAEMON_NAME="\"virtjailhoused\"" \
+ -DMODULE_NAME="\"jailhouse\"" \
+ $(NULL)
+virtjailhoused_LDFLAGS = $(REMOTE_DAEMON_LD_FLAGS)
+virtjailhoused_LDADD = $(REMOTE_DAEMON_LD_ADD)
+
endif WITH_JAILHOUSE
diff --git a/src/jailhouse/jailhouse.conf b/src/jailhouse/jailhouse.conf
new file mode 100644
index 0000000000..587068b9d0
--- /dev/null
+++ b/src/jailhouse/jailhouse.conf
@@ -0,0 +1,10 @@
+# Configuration for the Jailhouse driver.
+
+# Jailhouse system configuration file to enable the Jailhouse hypervisor
on the
+# system. This is a required configuration parameter for the driver.
+#system_config = "/etc/libvirt/jailhouse/qemu-x86.cell"
+
+# Specify a directory which contains all the non-root cell configurations
which
+# should be created by the driver at the startup. This is optional. Default
+# value of "/etc/libvirt/jailhouse/cells/" will be used if left empty.
+#non_root_cells_dir = "/etc/libvirt/jailhouse/cells/"
diff --git a/src/jailhouse/jailhouse_api.c b/src/jailhouse/jailhouse_api.c
new file mode 100644
index 0000000000..cda00b50e7
--- /dev/null
+++ b/src/jailhouse/jailhouse_api.c
@@ -0,0 +1,372 @@
+/*
+ * jailhouse_api.c: Jailhouse API
+ *
+ * Copyright (C) 2020 Prakhar Bansal
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <linux/types.h>
+
+#include "viralloc.h"
+#include "virerror.h"
+#include "virfile.h"
+#include "virlog.h"
+#include "virstring.h"
+#include "jailhouse_api.h"
+
+#define JAILHOUSE_DEVICE "/dev/jailhouse"
+#define JAILHOUSE_CELLS
"/sys/devices/jailhouse/cells"
+#define MAX_JAILHOUSE_SYS_CONFIG_FILE_SIZE 1024*1024
+#define MAX_JAILHOUSE_CELL_CONFIG_FILE_SIZE 1024
+
+
+#define JAILHOUSE_ENABLE _IOW(0, 0, void *)
+#define JAILHOUSE_DISABLE _IO(0, 1)
+#define JAILHOUSE_CELL_CREATE _IOW(0, 2, virJailhouseCellCreate)
+#define JAILHOUSE_CELL_DESTROY _IOW(0, 5, virJailhouseCellId)
+
+#define VIR_FROM_THIS VIR_FROM_JAILHOUSE
+
+VIR_LOG_INIT("jailhouse.jailhouse_api");
+
+#define JAILHOUSE_CELL_FILE_EXTENSION ".cell"
+
+/* Forward declarations */
+
+/* Open the Jailhouse device for ioctl APIs */
+int openDev(void);
+
+/* Reads cell's property given by 'entry' using sysfs API */
+char *readSysfsCellString(const unsigned int id, const char *entry);
+
+int cell_match(const struct dirent *dirent);
+
+int createCell(const char *conf_file);
+
+int destroyCell(virJailhouseCellId cell_id);
+
+int getCellInfo(const unsigned int id,
+ virJailhouseCellInfoPtr * cell_info);
+
+int
+jailhouseEnable(const char *sys_conf_file_path)
+{
+ int err = -1, len;
+ g_autofree char *buffer = NULL;
+ VIR_AUTOCLOSE fd = -1;
+
+ if (!virFileExists(sys_conf_file_path))
+ return 0;
+
+ len = virFileReadAll(sys_conf_file_path,
MAX_JAILHOUSE_SYS_CONFIG_FILE_SIZE, &buffer);
+ if (len < 0 || !buffer) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ "%s", _("Failed to read the system configuration
file"));
+ return -1;
+ }
+
+ fd = openDev();
+
+ err = ioctl(fd, JAILHOUSE_ENABLE, buffer);
+ if (err) {
+ virReportSystemError(errno, "%s", _("Failed to enable jailhouse"));
+ return err;
+ }
+
+ VIR_DEBUG("Jailhouse hypervisor is enabled");
+
+ return 1;
+}
+
+int
+jailhouseDisable(void)
+{
+ int err = -1;
+ VIR_AUTOCLOSE fd = -1;
+
+ fd = openDev();
+
+ err = ioctl(fd, JAILHOUSE_DISABLE);
+ if (err)
+ virReportSystemError(errno,
+ "%s",
+ _("Failed to disable jailhouse: %s"));
+
+ VIR_DEBUG("Jailhouse hypervisor is disabled");
+
+ return err;
+}
+
+int
+cell_match(const struct dirent *dirent)
+{
+ char *ext = strrchr(dirent->d_name, '.');
+
+ return dirent->d_name[0] != '.'
+ && (STREQ(ext, JAILHOUSE_CELL_FILE_EXTENSION) == 0);
+}
+
+int
+createJailhouseCells(const char *dir_path)
+{
+
+ struct dirent **namelist;
+ int num_entries, ret = -1;
+ size_t i;
+
+ if (strlen(dir_path) == 0)
+ return ret;
+
+ num_entries = scandir(dir_path, &namelist, cell_match, alphasort);
+ if (num_entries == -1) {
+ if (errno == ENOENT) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("No cells found in %s, scandir failed."),
+ dir_path);
+ goto fail;
+ }
+
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Error reading cell configurations in %s."),
+ dir_path);
+ goto fail;
+ }
+
+
+ for (i = 0; i < num_entries; i++) {
+ g_autofree char *file_path = g_strdup_printf("%s/%s", dir_path,
namelist[i]->d_name);
+
+ if (createCell(file_path) != 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Cell creation failed with conf found in
%s."),
+ namelist[i]->d_name);
+ goto fail;
+ }
+ }
+
+ ret = 0;
+
+ fail:
+ VIR_FREE(namelist);
+ return ret;
+}
+
+int
+openDev(void)
+{
+ int fd;
+
+ fd = open(JAILHOUSE_DEVICE, O_RDWR);
+ if (fd < 0) {
+ virReportSystemError(errno,
+ _("Error opening jailhouse device %s"),
+ JAILHOUSE_DEVICE);
+ }
+ return fd;
+}
+
+int
+createCell(const char *conf_file)
+{
+ virJailhouseCellCreate cell_create;
+ int err = -1, len;
+ g_autofree char *buffer = NULL;
+ VIR_AUTOCLOSE fd = -1;
+
+ if (strlen(conf_file) == 0)
+ return err;
+
+ len = virFileReadAll(conf_file, MAX_JAILHOUSE_CELL_CONFIG_FILE_SIZE,
&buffer);
+ if (len < 0 || !buffer) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ "%s", _("Failed to read the system configuration
file"));
+ return err;
+ }
+
+ cell_create.config_address = (unsigned long) buffer;
+ cell_create.config_size = len;
+
+ fd = openDev();
+
+ err = ioctl(fd, JAILHOUSE_CELL_CREATE, &cell_create);
+ if (err)
+ virReportSystemError(errno,
+ "%s",
+ _("Cell creation failed: %s"));
+
+ return err;
+}
+
+void
+cellInfoFree(virJailhouseCellInfoPtr cell_info)
+{
+ VIR_FREE(cell_info->state);
+ VIR_FREE(cell_info->cpus_assigned_list);
+ VIR_FREE(cell_info->cpus_failed_list);
+ VIR_FREE(cell_info);
+}
+
+char *
+readSysfsCellString(const unsigned int id, const char *entry)
+{
+ g_autofree char *buffer = NULL;
+ g_autofree char *file_path = NULL;
+ int len = -1;
+
+ file_path = g_strdup_printf(JAILHOUSE_CELLS "%u/%s", id, entry);
+
+ len = virFileReadAll(file_path, 1024, &buffer);
+ if (len < 0 || !buffer) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Error reading cell(%u) %s from %s failed"),
+ id, entry, file_path);
+ return NULL;
+ }
+
+ virTrimSpaces(buffer, NULL);
+
+ return buffer;
+}
+
+int
+getCellInfo(const unsigned int id, virJailhouseCellInfoPtr * cell_info_ptr)
+{
+ char *tmp;
+
+ if (VIR_ALLOC(*cell_info_ptr) < 0)
+ return -1;
+
+ virJailhouseCellInfoPtr cell_info = *cell_info_ptr;
+
+ /* set cell id */
+ cell_info->id.id = id;
+
+ /* get cell name */
+ tmp = readSysfsCellString(id, "name");
+ if (virStrncpy(cell_info->id.name, tmp, JAILHOUSE_CELL_ID_NAMELEN,
JAILHOUSE_CELL_ID_NAMELEN) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Cell ID %s too long to be copied to the cell
info"),
+ tmp);
+ return -1;
+ }
+
+ cell_info->id.name[JAILHOUSE_CELL_ID_NAMELEN] = 0;
+ VIR_FREE(tmp);
+
+ /* get cell state */
+ cell_info->state = readSysfsCellString(id, "state");
+
+ /* get assigned cpu list */
+ cell_info->cpus_assigned_list =
+ readSysfsCellString(id, "cpus_assigned_list");
+
+ /* get failed cpu list */
+ cell_info->cpus_failed_list =
+ readSysfsCellString(id, "cpus_failed_list");
+
+ return 0;
+}
+
+virJailhouseCellInfoPtr *
+getJailhouseCellsInfo(void)
+{
+ struct dirent **namelist;
+ virJailhouseCellInfoPtr *cell_info_list;
+ unsigned int id;
+ int num_entries;
+ size_t i;
+
+ num_entries =
+ scandir(JAILHOUSE_CELLS, &namelist, cell_match, alphasort);
+ if (num_entries == -1) {
+ if (errno == ENOENT) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("No cells found in %s, scandir failed."),
+ JAILHOUSE_CELLS);
+ return NULL;
+ }
+
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Error reading cell IDs in %s."),
+ JAILHOUSE_CELLS);
+ return NULL;
+ }
+
+ /* Allocate memory for 1 more than num_entries and make the last entry
NULL. */
+ if (VIR_ALLOC_N(cell_info_list, num_entries + 1) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ "%s",
+ _("Insufficient memory for cells info list"));
+ }
+
+ /* Set the last entry to NULL. */
+ cell_info_list[num_entries] = NULL;
+
+ for (i = 0; i < num_entries; i++) {
+ if (virStrToLong_ui(namelist[i]->d_name, NULL, 10, &id) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Cell ID %s could not be converted to a
long"),
+ namelist[i]->d_name);
+ continue;
+ }
+
+ /* get the cell's information(name, state etc.) using sysfs */
+ getCellInfo(id, &cell_info_list[i]);
+ VIR_FREE(namelist[i]);
+ }
+
+ VIR_FREE(namelist);
+ return cell_info_list;
+}
+
+int
+destroyCell(virJailhouseCellId cell_id)
+{
+ int err = -1;
+ VIR_AUTOCLOSE fd = -1;
+
+ fd = openDev();
+
+ err = ioctl(fd, JAILHOUSE_CELL_DESTROY, &cell_id);
+ if (err)
+ virReportSystemError(errno,
+ _("Destroying cell %d failed"),
+ cell_id.id);
+
+ return err;
+}
+
+int
+destroyJailhouseCells(virJailhouseCellInfoPtr *cell_info_list
G_GNUC_UNUSED)
+{
+
+ /* Iterate over all cells in cell_info_list and destroy each cell */
+ // TODO: Not implemented yet.
+
+ return 0;
+}
diff --git a/src/jailhouse/jailhouse_api.h b/src/jailhouse/jailhouse_api.h
new file mode 100644
index 0000000000..8362cb3d0f
--- /dev/null
+++ b/src/jailhouse/jailhouse_api.h
@@ -0,0 +1,74 @@
+/*
+ * jailhouse_api.h: Jailhouse hypervisor API implementation
+ *
+ * Copyright (C) 2020 Prakhar Bansal
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#define JAILHOUSE_CELL_ID_NAMELEN 31
+
+typedef struct _virJailhouseCellId virJailhouseCellId;
+
+struct _virJailhouseCellId {
+ __s32 id;
+ __u32 padding;
+ char name[JAILHOUSE_CELL_ID_NAMELEN + 1];
+};
+
+typedef struct _virJailhouseCellInfo virJailhouseCellInfo;
+typedef virJailhouseCellInfo *virJailhouseCellInfoPtr;
+
+struct _virJailhouseCellInfo {
+ struct _virJailhouseCellId id;
+ char *state;
+ char *cpus_assigned_list;
+ char *cpus_failed_list;
+};
+
+typedef struct _virJailhouseCellCreate virJailhouseCellCreate;
+
+struct _virJailhouseCellCreate {
+ __u64 config_address;
+ __u32 config_size;
+ __u32 padding;
+};
+
+// Enables the Jailhouse hypervisor by reading the hypervisor system
+// configuration from the given file and calls the ioctl API to
+// enable the hypervisor.
+int jailhouseEnable(const char *sys_conf_file_path);
+
+// Disables the Jailhouse hypervisor.
+int jailhouseDisable(void);
+
+/* Cell API methods */
+
+// Creates Jailhouse cells using the cells configurations
+// provided in the dir_name.
+int createJailhouseCells(const char *dir_path);
+
+// Destroys Jailhouse cells using the cell IDs provided in
+// the cell_info_list.
+int destroyJailhouseCells(virJailhouseCellInfoPtr *cell_info_list);
+
+// Returns cell's information in a null-terminated array of
+// virJailhouseCellInfoPtr for all the Jailhouse cells.
+virJailhouseCellInfoPtr *getJailhouseCellsInfo(void);
+
+// Free the cell info object.
+void cellInfoFree(virJailhouseCellInfoPtr cell_info);
diff --git a/src/jailhouse/jailhouse_driver.c
b/src/jailhouse/jailhouse_driver.c
index 0175ba771b..ac9da4c85d 100644
--- a/src/jailhouse/jailhouse_driver.c
+++ b/src/jailhouse/jailhouse_driver.c
@@ -16,43 +16,228 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
+ *
*/
#include <config.h>
+#include <string.h>
+#include "configmake.h"
+#include "datatypes.h"
+#include "domain_conf.h"
#include "jailhouse_driver.h"
#include "virtypedparam.h"
#include "virerror.h"
#include "virstring.h"
#include "viralloc.h"
-#include "domain_conf.h"
#include "virfile.h"
-#include "datatypes.h"
+#include "virlog.h"
#include "vircommand.h"
-#include <string.h>
+#include "virpidfile.h"
-#define UNUSED(x) (void)(x)
+#define VIR_FROM_THIS VIR_FROM_JAILHOUSE
+
+VIR_LOG_INIT("jailhouse.jailhouse_driver");
+
+static virClassPtr virJailhouseDriverConfigClass;
+static void virJailhouseDriverConfigDispose(void *obj);
+
+static virJailhouseDriverPtr jailhouse_driver;
+
+static int virJailhouseConfigOnceInit(void)
+{
+ if (!VIR_CLASS_NEW(virJailhouseDriverConfig, virClassForObject()))
+ return -1;
+
+ return 0;
+}
+
+VIR_ONCE_GLOBAL_INIT(virJailhouseConfig);
+
+
+static virJailhouseDriverConfigPtr
+virJailhouseDriverConfigNew(void)
+{
+ virJailhouseDriverConfigPtr cfg;
+
+ // TODO: Check if the following has to be uncommented.
+ if (virJailhouseConfigInitialize() < 0)
+ return NULL;
+
+ if (!(cfg = virObjectNew(virJailhouseDriverConfigClass)))
+ return NULL;
+
+ cfg->stateDir = g_strdup(JAILHOUSE_STATE_DIR);
+
+ cfg->sys_config_file_path = g_strdup(DATADIR "/jailhouse/system.cell");
+
+ cfg->cell_config_dir = g_strdup(DATADIR "/jailhouse/cells");
+
+ return cfg;
+}
+
+static void virJailhouseDriverConfigDispose(void *obj)
+{
+
+ virJailhouseDriverConfigPtr cfg = obj;
+
+ VIR_FREE(cfg->stateDir);
+ VIR_FREE(cfg->sys_config_file_path);
+ VIR_FREE(cfg->cell_config_dir);
+}
+
+static int
+jailhouseLoadConf(virJailhouseDriverConfigPtr config)
+{
+ g_autoptr(virConf) conf = NULL;
+
+ if (!virFileExists(JAILHOUSE_CONFIG_FILE))
+ return 0;
+
+ if (!(conf = virConfReadFile(JAILHOUSE_CONFIG_FILE, 0)))
+ return -1;
+
+ if (virConfGetValueString(conf, "system_config",
+ &config->sys_config_file_path) < 0)
+ return -1;
+
+ if (virConfGetValueString(conf, "non_root_cells_dir",
+ &config->cell_config_dir) < 0)
+ return -1;
+
+ return 1;
+}
+
+static int
+jailhouseCreateAndLoadCells(virJailhouseDriverPtr driver)
+{
+ if (!driver->config ||
+ !driver->config->cell_config_dir ||
+ strlen(driver->config->cell_config_dir) == 0)
+ return -1;
+
+ // Create all cells in the hypervisor.
+ if (createJailhouseCells(driver->config->cell_config_dir) < 0)
+ return -1;
+
+ // Get all cells created above.
+ driver->cell_info_list = getJailhouseCellsInfo();
+
+ return 0;
+}
+
+static void
+jailhouseFreeDriver(virJailhouseDriverPtr driver)
+{
+ if (!driver)
+ return;
+
+ virMutexDestroy(&driver->lock);
+ virObjectUnref(driver->config);
+ VIR_FREE(driver);
+}
static virDrvOpenStatus
jailhouseConnectOpen(virConnectPtr conn,
- virConnectAuthPtr auth,
- virConfPtr conf,
- unsigned int flags)
+ virConnectAuthPtr auth G_GNUC_UNUSED,
+ virConfPtr conf G_GNUC_UNUSED, unsigned int flags)
{
- UNUSED(conn);
- UNUSED(auth);
- UNUSED(conf);
- UNUSED(flags);
- return 0;
+ uid_t uid = geteuid();
+
+ virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
+
+ if (!virConnectValidateURIPath(conn->uri->path, "jailhouse", uid == 0))
+ return VIR_DRV_OPEN_ERROR;
+
+ if (!jailhouse_driver) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Jailhouse driver state is not initialized."));
+ return VIR_DRV_OPEN_ERROR;
+ }
+
+ conn->privateData = jailhouse_driver;
+
+ return VIR_DRV_OPEN_SUCCESS;
}
+#define UNUSED(x) (void)(x)
+
static int
jailhouseConnectClose(virConnectPtr conn)
{
- UNUSED(conn);
+ conn->privateData = NULL;
+
+ return 0;
+}
+
+static int
+jailhouseStateCleanup(void)
+{
+ if (!jailhouse_driver)
+ return -1;
+
+ if (jailhouse_driver->lockFD != -1)
+ virPidFileRelease(jailhouse_driver->config->stateDir,
+ "driver", jailhouse_driver->lockFD);
+
+ virMutexDestroy(&jailhouse_driver->lock);
+
+ jailhouseFreeDriver(jailhouse_driver);
return 0;
}
+static int
+jailhouseStateInitialize(bool privileged G_GNUC_UNUSED,
+ const char *root G_GNUC_UNUSED,
+ virStateInhibitCallback callback G_GNUC_UNUSED,
+ void *opaque G_GNUC_UNUSED)
+{
+ virJailhouseDriverConfigPtr cfg = NULL;
+ int rc;
+
+ jailhouse_driver = g_new0(virJailhouseDriver, 1);
+ jailhouse_driver->lockFD = -1;
+
+ if (virMutexInit(&jailhouse_driver->lock) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("cannot initialize mutex"));
+ VIR_FREE(jailhouse_driver);
+ return VIR_DRV_STATE_INIT_ERROR;
+ }
+
+ if (!(cfg = virJailhouseDriverConfigNew()))
+ goto error;
+
+ jailhouse_driver->config = cfg;
+
+ if (jailhouseLoadConf(cfg) < 0)
+ goto error;
+
+ if (virFileMakePath(cfg->stateDir) < 0) {
+ virReportSystemError(errno, _("Failed to create state dir %s"),
+ cfg->stateDir);
+ goto error;
+ }
+
+ if ((jailhouse_driver->lockFD = virPidFileAcquire(cfg->stateDir,
+ "driver", false,
getpid())) < 0)
+ goto error;
+
+ if ((rc = jailhouseEnable(cfg->sys_config_file_path)) < 0)
+ goto error;
+ else if (rc == 0)
+ return VIR_DRV_STATE_INIT_SKIPPED;
+
+ if (jailhouseCreateAndLoadCells(jailhouse_driver) < 0)
+ goto error;
+
+ return VIR_DRV_STATE_INIT_COMPLETE;
+
+ error:
+ jailhouseStateCleanup();
+ return VIR_DRV_STATE_INIT_ERROR;
+
+}
static const char *
jailhouseConnectGetType(virConnectPtr conn)
{
@@ -69,36 +254,16 @@ jailhouseConnectGetHostname(virConnectPtr conn)
}
static int
-jailhouseNodeGetInfo(virConnectPtr conn,
- virNodeInfoPtr info)
+jailhouseNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info)
{
UNUSED(conn);
UNUSED(info);
return -1;
}
-static int
-jailhouseConnectListDomains(virConnectPtr conn,
- int *ids,
- int maxids)
-{
- UNUSED(conn);
- UNUSED(ids);
- UNUSED(maxids);
- return -1;
-}
-
-static int
-jailhouseConnectNumOfDomains(virConnectPtr conn)
-{
- UNUSED(conn);
- return -1;
-}
-
static int
jailhouseConnectListAllDomains(virConnectPtr conn,
- virDomainPtr **domain,
- unsigned int flags)
+ virDomainPtr ** domain, unsigned int flags)
{
UNUSED(conn);
UNUSED(domain);
@@ -107,8 +272,7 @@ jailhouseConnectListAllDomains(virConnectPtr conn,
}
static virDomainPtr
-jailhouseDomainLookupByID(virConnectPtr conn,
- int id)
+jailhouseDomainLookupByID(virConnectPtr conn, int id)
{
UNUSED(conn);
UNUSED(id);
@@ -116,8 +280,7 @@ jailhouseDomainLookupByID(virConnectPtr conn,
}
static virDomainPtr
-jailhouseDomainLookupByName(virConnectPtr conn,
- const char *name)
+jailhouseDomainLookupByName(virConnectPtr conn, const char *name)
{
UNUSED(conn);
UNUSED(name);
@@ -125,8 +288,7 @@ jailhouseDomainLookupByName(virConnectPtr conn,
}
static virDomainPtr
-jailhouseDomainLookupByUUID(virConnectPtr conn,
- const unsigned char *uuid)
+jailhouseDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
{
UNUSED(conn);
UNUSED(uuid);
@@ -157,8 +319,7 @@ jailhouseDomainDestroy(virDomainPtr domain)
}
static int
-jailhouseDomainGetInfo(virDomainPtr domain,
- virDomainInfoPtr info)
+jailhouseDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
{
UNUSED(domain);
UNUSED(info);
@@ -167,9 +328,7 @@ jailhouseDomainGetInfo(virDomainPtr domain,
static int
jailhouseDomainGetState(virDomainPtr domain,
- int *state,
- int *reason,
- unsigned int flags)
+ int *state, int *reason, unsigned int flags)
{
UNUSED(domain);
UNUSED(state);
@@ -179,8 +338,7 @@ jailhouseDomainGetState(virDomainPtr domain,
}
static char *
-jailhouseDomainGetXMLDesc(virDomainPtr domain,
- unsigned int flags)
+jailhouseDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
{
UNUSED(domain);
UNUSED(flags);
@@ -189,31 +347,43 @@ jailhouseDomainGetXMLDesc(virDomainPtr domain,
static virHypervisorDriver jailhouseHypervisorDriver = {
.name = "JAILHOUSE",
- .connectOpen = jailhouseConnectOpen, /* 6.3.0 */
- .connectClose = jailhouseConnectClose, /* 6.3.0 */
- .connectListDomains = jailhouseConnectListDomains, /* 6.3.0 */
- .connectNumOfDomains = jailhouseConnectNumOfDomains, /* 6.3.0 */
- .connectListAllDomains = jailhouseConnectListAllDomains, /* 6.3.0 */
- .domainLookupByID = jailhouseDomainLookupByID, /* 6.3.0 */
- .domainLookupByUUID = jailhouseDomainLookupByUUID, /* 6.3.0 */
- .domainLookupByName = jailhouseDomainLookupByName, /* 6.3.0 */
- .domainGetXMLDesc = jailhouseDomainGetXMLDesc, /* 6.3.0 */
- .domainCreate = jailhouseDomainCreate, /* 6.3.0 */
- .connectGetType = jailhouseConnectGetType, /* 6.3.0 */
- .connectGetHostname = jailhouseConnectGetHostname, /* 6.3.0 */
- .nodeGetInfo = jailhouseNodeGetInfo, /* 6.3.0 */
- .domainShutdown = jailhouseDomainShutdown, /* 6.3.0 */
- .domainDestroy = jailhouseDomainDestroy, /* 6.3.0 */
- .domainGetInfo = jailhouseDomainGetInfo, /* 6.3.0 */
- .domainGetState = jailhouseDomainGetState, /* 6.3.0 */
+ .connectOpen = jailhouseConnectOpen, /* 6.3.0 */
+ .connectClose = jailhouseConnectClose, /* 6.3.0 */
+ .connectListAllDomains = jailhouseConnectListAllDomains, /* 6.3.0 */
+ .domainLookupByID = jailhouseDomainLookupByID, /* 6.3.0 */
+ .domainLookupByUUID = jailhouseDomainLookupByUUID, /* 6.3.0 */
+ .domainLookupByName = jailhouseDomainLookupByName, /* 6.3.0 */
+ .domainGetXMLDesc = jailhouseDomainGetXMLDesc, /* 6.3.0 */
+ .domainCreate = jailhouseDomainCreate, /* 6.3.0 */
+ .connectGetType = jailhouseConnectGetType, /* 6.3.0 */
+ .connectGetHostname = jailhouseConnectGetHostname, /* 6.3.0 */
+ .nodeGetInfo = jailhouseNodeGetInfo, /* 6.3.0 */
+ .domainShutdown = jailhouseDomainShutdown, /* 6.3.0 */
+ .domainDestroy = jailhouseDomainDestroy, /* 6.3.0 */
+ .domainGetInfo = jailhouseDomainGetInfo, /* 6.3.0 */
+ .domainGetState = jailhouseDomainGetState, /* 6.3.0 */
};
+
static virConnectDriver jailhouseConnectDriver = {
+ .localOnly = true,
+ .uriSchemes = (const char *[]){ "jailhouse", NULL },
.hypervisorDriver = &jailhouseHypervisorDriver,
};
+
+static virStateDriver jailhouseStateDriver = {
+ .name = "JAILHOUSE",
+ .stateInitialize = jailhouseStateInitialize,
+ .stateCleanup = jailhouseStateCleanup,
+};
+
int
jailhouseRegister(void)
{
- return virRegisterConnectDriver(&jailhouseConnectDriver, false);
+ if (virRegisterConnectDriver(&jailhouseConnectDriver, false) < 0)
+ return -1;
+ if (virRegisterStateDriver(&jailhouseStateDriver) < 0)
+ return -1;
+ return 0;
}
diff --git a/src/jailhouse/jailhouse_driver.h
b/src/jailhouse/jailhouse_driver.h
index b0dbc8d033..8a0e111676 100644
--- a/src/jailhouse/jailhouse_driver.h
+++ b/src/jailhouse/jailhouse_driver.h
@@ -20,4 +20,55 @@
#pragma once
+#include <linux/types.h>
+
+#include "jailhouse_api.h"
+
int jailhouseRegister(void);
+
+#define JAILHOUSE_CONFIG_FILE SYSCONFDIR
"/libvirt/jailhouse/jailhouse.conf"
+#define JAILHOUSE_STATE_DIR RUNSTATEDIR "/libvirt/jailhouse"
+
+#define JAILHOUSE_DEV "/dev/jailhouse"
+
+#define JAILHOUSE_SYSFS_DEV "/sys/devices/jailhouse/"
+
+typedef struct _virJailhouseDriver virJailhouseDriver;
+typedef virJailhouseDriver *virJailhouseDriverPtr;
+
+typedef struct _virJailhouseDriverConfig virJailhouseDriverConfig;
+typedef virJailhouseDriverConfig *virJailhouseDriverConfigPtr;
+
+struct _virJailhouseDriverConfig {
+ virObject parent;
+
+ char *stateDir;
+
+ // File path of the jailhouse system configuration
+ // for jailhouse enable/disable.
+ char *sys_config_file_path;
+
+ // Config directory where all jailhouse cell configurations
+ // are stored.
+ char *cell_config_dir;
+};
+
+struct _virJailhouseDriver {
+ virMutex lock;
+
+ // Jailhouse configuration read from the jailhouse.conf
+ virJailhouseDriverConfigPtr config;
+
+ /* pid file FD, ensures two copies of the driver can't use the same
root */
+ int lockFD;
+
+ // All the cells created during connect open on the hypervisor.
+ virJailhouseCellInfoPtr *cell_info_list;
+};
+
+struct _jailhouseCell {
+ __s32 id;
+ char *state;
+ char *cpus_assigned_list;
+ char *cpus_failed_list;
+};
diff --git a/src/jailhouse/meson.build b/src/jailhouse/meson.build
index 45ceeecca3..a706985169 100644
--- a/src/jailhouse/meson.build
+++ b/src/jailhouse/meson.build
@@ -1,5 +1,6 @@
jailhouse_sources = files(
'jailhouse_driver.c',
+ 'jailhouse_api.c',
)
driver_source_files += jailhouse_sources
diff --git a/src/libvirt.c b/src/libvirt.c
index 59b75c6f7b..b2d0ba3d23 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -75,9 +75,6 @@
#ifdef WITH_BHYVE
# include "bhyve/bhyve_driver.h"
#endif
-#ifdef WITH_JAILHOUSE
-# include "jailhouse/jailhouse_driver.h"
-#endif
#include "access/viraccessmanager.h"
#define VIR_FROM_THIS VIR_FROM_NONE
@@ -274,10 +271,6 @@ virGlobalInit(void)
if (hypervRegister() == -1)
goto error;
#endif
-#ifdef WITH_JAILHOUSE
- if (jailhouseRegister() == -1)
- goto error;
-#endif
#ifdef WITH_REMOTE
if (remoteRegister() == -1)
goto error;
@@ -1010,9 +1003,6 @@ virConnectOpenInternal(const char *name,
#endif
#ifndef WITH_VZ
STRCASEEQ(ret->uri->scheme, "parallels") ||
-#endif
-#ifndef WITH_JAILHOUSE
- STRCASEEQ(ret->uri->scheme, "jailhouse") ||
#endif
false)) {
virReportErrorHelper(VIR_FROM_NONE, VIR_ERR_CONFIG_UNSUPPORTED,
diff --git a/src/remote/remote_daemon.c b/src/remote/remote_daemon.c
index 1aa9bfc0d2..9d1b208a38 100644
--- a/src/remote/remote_daemon.c
+++ b/src/remote/remote_daemon.c
@@ -145,6 +145,10 @@ static int daemonInitialize(void)
if (virDriverLoadModule("interface", "interfaceRegister", false) < 0)
return -1;
# endif
+# ifdef WITH_JAILHOUSE
+ if (virDriverLoadModule("jailhouse", "jailhouseRegister", false) < 0)
+ return -1;
+# endif
# ifdef WITH_SECRETS
if (virDriverLoadModule("secret", "secretRegister", false) < 0)
return -1;
diff --git a/src/remote/remote_daemon_dispatch.c
b/src/remote/remote_daemon_dispatch.c
index 53d17a8f4a..06d8fe6098 100644
--- a/src/remote/remote_daemon_dispatch.c
+++ b/src/remote/remote_daemon_dispatch.c
@@ -2115,7 +2115,8 @@ remoteDispatchConnectOpen(virNetServerPtr server
G_GNUC_UNUSED,
STREQ(type, "VBOX") ||
STREQ(type, "bhyve") ||
STREQ(type, "vz") ||
- STREQ(type, "Parallels")) {
+ STREQ(type, "Parallels") ||
+ STREQ(type, "JAILHOUSE")) {
VIR_DEBUG("Hypervisor driver found, setting URIs for secondary
drivers");
if (getuid() == 0) {
priv->interfaceURI = "interface:///system";
--
2.17.1
4 years, 2 months
[GSoC PATCH 1/9] Jailhouse driver: first commit with skeleton code
by Prakhar Bansal
---
include/libvirt/virterror.h | 2 +-
libvirt.spec.in | 7 +
m4/virt-driver-jailhouse.m4 | 42 +++++
meson.build | 4 +
meson_options.txt | 1 +
src/conf/domain_conf.c | 1 +
src/conf/domain_conf.h | 1 +
src/jailhouse/Makefile.inc.am | 21 +++
src/jailhouse/jailhouse_driver.c | 219 +++++++++++++++++++++++++++
src/jailhouse/jailhouse_driver.h | 23 +++
src/jailhouse/libvirtd_jailhouse.aug | 43 ++++++
src/jailhouse/meson.build | 48 ++++++
src/libvirt.c | 10 ++
src/meson.build | 1 +
src/qemu/qemu_command.c | 1 +
src/util/virerror.c | 1 +
16 files changed, 424 insertions(+), 1 deletion(-)
create mode 100644 m4/virt-driver-jailhouse.m4
create mode 100644 src/jailhouse/Makefile.inc.am
create mode 100644 src/jailhouse/jailhouse_driver.c
create mode 100644 src/jailhouse/jailhouse_driver.h
create mode 100644 src/jailhouse/libvirtd_jailhouse.aug
create mode 100644 src/jailhouse/meson.build
diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h
index 0f1c32283d..97f2ac16d8 100644
--- a/include/libvirt/virterror.h
+++ b/include/libvirt/virterror.h
@@ -136,7 +136,7 @@ typedef enum {
VIR_FROM_TPM = 70, /* Error from TPM */
VIR_FROM_BPF = 71, /* Error from BPF code */
-
+ VIR_FROM_JAILHOUSE = 72, /* Error from Jailhouse driver */
# ifdef VIR_ENUM_SENTINELS
VIR_ERR_DOMAIN_LAST
# endif
diff --git a/libvirt.spec.in b/libvirt.spec.in
index bb74443484..074410eaa1 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -17,6 +17,7 @@
%define with_lxc 0%{!?_without_lxc:1}
%define with_libxl 0%{!?_without_libxl:1}
%define with_vbox 0%{!?_without_vbox:1}
+%define with_jailhouse 0%{!?_without_jailhouse:1}
%define with_qemu_tcg %{with_qemu}
@@ -1045,6 +1046,12 @@ exit 1
%define arg_vmware -Ddriver_vmware=disabled
%endif
+%if %{with_jailhouse}
+ %define arg_jailhouse --with-jailhouse
+%else
+ %define arg_jailhouse --without-jailhouse
+%endif
+
%if %{with_storage_rbd}
%define arg_storage_rbd -Dstorage_rbd=enabled
%else
diff --git a/m4/virt-driver-jailhouse.m4 b/m4/virt-driver-jailhouse.m4
new file mode 100644
index 0000000000..9008c6ce30
--- /dev/null
+++ b/m4/virt-driver-jailhouse.m4
@@ -0,0 +1,42 @@
+dnl The Jailhouse driver
+dnl
+dnl Copyright (C) 2016 Red Hat, Inc.
+dnl
+dnl This library is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU Lesser General Public
+dnl License as published by the Free Software Foundation; either
+dnl version 2.1 of the License, or (at your option) any later version.
+dnl
+dnl This library is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+dnl Lesser General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU Lesser General Public
+dnl License along with this library. If not, see
+dnl <http://www.gnu.org/licenses/>.
+dnl
+
+AC_DEFUN([LIBVIRT_DRIVER_ARG_JAILHOUSE], [
+ LIBVIRT_ARG_WITH_FEATURE([JAILHOUSE], [Jailhouse], [check])
+])
+
+AC_DEFUN([LIBVIRT_DRIVER_CHECK_JAILHOUSE], [
+ if test "$with_jailhouse" = "check"; then
+ with_jailhouse=$with_linux
+ fi
+
+ if test "$with_jailhouse" = "yes" && test "$with_linux" = "no"; then
+ AC_MSG_ERROR([The Jailhouse driver can be enabled on Linux only.])
+ fi
+
+ if test "$with_jailhouse" = "yes"; then
+ AC_DEFINE_UNQUOTED([WITH_JAILHOUSE], 1, [whether Jailhouse driver is
enabled])
+ fi
+
+ AM_CONDITIONAL([WITH_JAILHOUSE], [test "$with_jailhouse" = "yes"])
+])
+
+AC_DEFUN([LIBVIRT_DRIVER_RESULT_JAILHOUSE], [
+ LIBVIRT_RESULT([Jailhouse], [$with_jailhouse])
+])
diff --git a/meson.build b/meson.build
index dabd4196e6..d0f31f916b 100644
--- a/meson.build
+++ b/meson.build
@@ -1889,6 +1889,10 @@ elif get_option('secdriver_selinux').enabled()
error('You must install the libselinux development package in order to
compile libvirt.')
endif
+if get_option('driver_jailhouse').enabled()
+ conf.set('WITH_JAILHOUSE', 1)
+endif
+
if conf.has('WITH_QEMU') or conf.has('WITH_LXC') or
conf.has('WITH_NETWORK')
conf.set('WITH_BRIDGE', 1)
endif
diff --git a/meson_options.txt b/meson_options.txt
index 79554c3186..c1f2b51427 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -68,6 +68,7 @@ option('driver_vbox', type: 'feature', value: 'enabled',
description: 'VirtualBo
option('vbox_xpcomc_dir', type: 'string', value: '', description:
'Location of directory containing VirtualBox XPCOMC library')
option('driver_vmware', type: 'feature', value: 'enabled', description:
'VMware driver')
option('driver_vz', type: 'feature', value: 'auto', description:
'Virtuozzo driver')
+option('driver_jailhouse', type: 'feature', value: 'auto', description:
'Jailhouse driver')
option('secdriver_apparmor', type: 'feature', value: 'auto', description:
'use AppArmor security driver')
option('apparmor_profiles', type: 'boolean', value: false, description:
'install apparmor profiles')
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 5d3ae8bb28..cb946d5e87 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -130,6 +130,7 @@ VIR_ENUM_IMPL(virDomainVirt,
"parallels",
"bhyve",
"vz",
+ "jailhouse",
);
VIR_ENUM_IMPL(virDomainOS,
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 8a0f26f5c0..cc51547bc2 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -139,6 +139,7 @@ typedef enum {
VIR_DOMAIN_VIRT_PARALLELS,
VIR_DOMAIN_VIRT_BHYVE,
VIR_DOMAIN_VIRT_VZ,
+ VIR_DOMAIN_VIRT_JAILHOUSE,
VIR_DOMAIN_VIRT_LAST
} virDomainVirtType;
diff --git a/src/jailhouse/Makefile.inc.am b/src/jailhouse/Makefile.inc.am
new file mode 100644
index 0000000000..02822b2ea1
--- /dev/null
+++ b/src/jailhouse/Makefile.inc.am
@@ -0,0 +1,21 @@
+# vim: filetype=automake
+
+JAILHOUSE_DRIVER_SOURCES = \
+ jailhouse/jailhouse_driver.c \
+ jailhouse/jailhouse_driver.h \
+ $(NULL)
+
+
+DRIVER_SOURCE_FILES += $(addprefix $(srcdir)/,$(JAILHOUSE_DRIVER_SOURCES))
+
+EXTRA_DIST += $(JAILHOUSE_DRIVER_SOURCES)
+
+if WITH_JAILHOUSE
+noinst_LTLIBRARIES += libvirt_driver_jailhouse.la
+libvirt_la_BUILT_LIBADD += libvirt_driver_jailhouse.la
+libvirt_driver_jailhouse_la_CFLAGS = \
+ -I$(srcdir)/conf \
+ $(AM_CFLAGS) \
+ $(NULL)
+libvirt_driver_jailhouse_la_SOURCES = $(JAILHOUSE_DRIVER_SOURCES)
+endif WITH_JAILHOUSE
diff --git a/src/jailhouse/jailhouse_driver.c
b/src/jailhouse/jailhouse_driver.c
new file mode 100644
index 0000000000..0175ba771b
--- /dev/null
+++ b/src/jailhouse/jailhouse_driver.c
@@ -0,0 +1,219 @@
+/*
+ * jailhouse_driver.c: Implementation of driver for Jailhouse hypervisor
+ *
+ * Copyright (C) 2020 Prakhar Bansal
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+
+#include "jailhouse_driver.h"
+#include "virtypedparam.h"
+#include "virerror.h"
+#include "virstring.h"
+#include "viralloc.h"
+#include "domain_conf.h"
+#include "virfile.h"
+#include "datatypes.h"
+#include "vircommand.h"
+#include <string.h>
+
+#define UNUSED(x) (void)(x)
+
+static virDrvOpenStatus
+jailhouseConnectOpen(virConnectPtr conn,
+ virConnectAuthPtr auth,
+ virConfPtr conf,
+ unsigned int flags)
+{
+ UNUSED(conn);
+ UNUSED(auth);
+ UNUSED(conf);
+ UNUSED(flags);
+ return 0;
+}
+
+static int
+jailhouseConnectClose(virConnectPtr conn)
+{
+ UNUSED(conn);
+ return 0;
+}
+
+static const char *
+jailhouseConnectGetType(virConnectPtr conn)
+{
+ UNUSED(conn);
+ return NULL;
+
+}
+
+static char *
+jailhouseConnectGetHostname(virConnectPtr conn)
+{
+ UNUSED(conn);
+ return NULL;
+}
+
+static int
+jailhouseNodeGetInfo(virConnectPtr conn,
+ virNodeInfoPtr info)
+{
+ UNUSED(conn);
+ UNUSED(info);
+ return -1;
+}
+
+static int
+jailhouseConnectListDomains(virConnectPtr conn,
+ int *ids,
+ int maxids)
+{
+ UNUSED(conn);
+ UNUSED(ids);
+ UNUSED(maxids);
+ return -1;
+}
+
+static int
+jailhouseConnectNumOfDomains(virConnectPtr conn)
+{
+ UNUSED(conn);
+ return -1;
+}
+
+static int
+jailhouseConnectListAllDomains(virConnectPtr conn,
+ virDomainPtr **domain,
+ unsigned int flags)
+{
+ UNUSED(conn);
+ UNUSED(domain);
+ UNUSED(flags);
+ return -1;
+}
+
+static virDomainPtr
+jailhouseDomainLookupByID(virConnectPtr conn,
+ int id)
+{
+ UNUSED(conn);
+ UNUSED(id);
+ return NULL;
+}
+
+static virDomainPtr
+jailhouseDomainLookupByName(virConnectPtr conn,
+ const char *name)
+{
+ UNUSED(conn);
+ UNUSED(name);
+ return NULL;
+}
+
+static virDomainPtr
+jailhouseDomainLookupByUUID(virConnectPtr conn,
+ const unsigned char *uuid)
+{
+ UNUSED(conn);
+ UNUSED(uuid);
+ return NULL;
+}
+
+static int
+jailhouseDomainCreate(virDomainPtr domain)
+{
+ UNUSED(domain);
+ return -1;
+
+}
+
+static int
+jailhouseDomainShutdown(virDomainPtr domain)
+{
+ UNUSED(domain);
+ return -1;
+}
+
+
+static int
+jailhouseDomainDestroy(virDomainPtr domain)
+{
+ UNUSED(domain);
+ return -1;
+}
+
+static int
+jailhouseDomainGetInfo(virDomainPtr domain,
+ virDomainInfoPtr info)
+{
+ UNUSED(domain);
+ UNUSED(info);
+ return -1;
+}
+
+static int
+jailhouseDomainGetState(virDomainPtr domain,
+ int *state,
+ int *reason,
+ unsigned int flags)
+{
+ UNUSED(domain);
+ UNUSED(state);
+ UNUSED(reason);
+ UNUSED(flags);
+ return -1;
+}
+
+static char *
+jailhouseDomainGetXMLDesc(virDomainPtr domain,
+ unsigned int flags)
+{
+ UNUSED(domain);
+ UNUSED(flags);
+ return NULL;
+}
+
+static virHypervisorDriver jailhouseHypervisorDriver = {
+ .name = "JAILHOUSE",
+ .connectOpen = jailhouseConnectOpen, /* 6.3.0 */
+ .connectClose = jailhouseConnectClose, /* 6.3.0 */
+ .connectListDomains = jailhouseConnectListDomains, /* 6.3.0 */
+ .connectNumOfDomains = jailhouseConnectNumOfDomains, /* 6.3.0 */
+ .connectListAllDomains = jailhouseConnectListAllDomains, /* 6.3.0 */
+ .domainLookupByID = jailhouseDomainLookupByID, /* 6.3.0 */
+ .domainLookupByUUID = jailhouseDomainLookupByUUID, /* 6.3.0 */
+ .domainLookupByName = jailhouseDomainLookupByName, /* 6.3.0 */
+ .domainGetXMLDesc = jailhouseDomainGetXMLDesc, /* 6.3.0 */
+ .domainCreate = jailhouseDomainCreate, /* 6.3.0 */
+ .connectGetType = jailhouseConnectGetType, /* 6.3.0 */
+ .connectGetHostname = jailhouseConnectGetHostname, /* 6.3.0 */
+ .nodeGetInfo = jailhouseNodeGetInfo, /* 6.3.0 */
+ .domainShutdown = jailhouseDomainShutdown, /* 6.3.0 */
+ .domainDestroy = jailhouseDomainDestroy, /* 6.3.0 */
+ .domainGetInfo = jailhouseDomainGetInfo, /* 6.3.0 */
+ .domainGetState = jailhouseDomainGetState, /* 6.3.0 */
+};
+
+static virConnectDriver jailhouseConnectDriver = {
+ .hypervisorDriver = &jailhouseHypervisorDriver,
+};
+
+int
+jailhouseRegister(void)
+{
+ return virRegisterConnectDriver(&jailhouseConnectDriver, false);
+}
diff --git a/src/jailhouse/jailhouse_driver.h
b/src/jailhouse/jailhouse_driver.h
new file mode 100644
index 0000000000..b0dbc8d033
--- /dev/null
+++ b/src/jailhouse/jailhouse_driver.h
@@ -0,0 +1,23 @@
+/*
+ * jailhouse_driver.h: Libvirt driver for Jailhouse hypervisor
+ *
+ * Copyright (C) 2020 Prakhar Bansal
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+int jailhouseRegister(void);
diff --git a/src/jailhouse/libvirtd_jailhouse.aug
b/src/jailhouse/libvirtd_jailhouse.aug
new file mode 100644
index 0000000000..96a186eae2
--- /dev/null
+++ b/src/jailhouse/libvirtd_jailhouse.aug
@@ -0,0 +1,43 @@
+(* /etc/libvirt/jailhouse.conf *)
+
+module Libvirtd_jailhouse =
+ autoload xfm
+
+ let eol = del /[ \t]*\n/ "\n"
+ let value_sep = del /[ \t]*=[ \t]*/ " = "
+ let indent = del /[ \t]*/ ""
+
+ let array_sep = del /,[ \t\n]*/ ", "
+ let array_start = del /\[[ \t\n]*/ "[ "
+ let array_end = del /\]/ "]"
+
+ let str_val = del /\"/ "\"" . store /[^\"]*/ . del /\"/ "\""
+ let bool_val = store /0|1/
+ let int_val = store /[0-9]+/
+ let str_array_element = [ seq "el" . str_val ] . del /[ \t\n]*/ ""
+ let str_array_val = counter "el" . array_start . ( str_array_element .
( array_sep . str_array_element ) * ) ? . array_end
+
+ let str_entry (kw:string) = [ key kw . value_sep . str_val ]
+ let bool_entry (kw:string) = [ key kw . value_sep . bool_val ]
+ let int_entry (kw:string) = [ key kw . value_sep . int_val ]
+ let str_array_entry (kw:string) = [ key kw . value_sep . str_array_val ]
+
+ (* Config entry grouped by function - same order as example config *)
+ let log_entry = bool_entry "log_with_libvirtd"
+ | str_entry "security_driver"
+ | bool_entry "security_default_confined"
+ | bool_entry "security_require_confined"
+
+ (* Each entry in the config is one of the following three ... *)
+ let entry = log_entry
+ let comment = [ label "#comment" . del /#[ \t]*/ "# " . store /([^
\t\n][^\n]*)?/ . del /\n/ "\n" ]
+ let empty = [ label "#empty" . eol ]
+
+ let record = indent . entry . eol
+
+ let lns = ( record | comment | empty ) *
+
+ let filter = incl "/etc/libvirt/jailhouse.conf"
+ . Util.stdexcl
+
+ let xfm = transform lns filter
diff --git a/src/jailhouse/meson.build b/src/jailhouse/meson.build
new file mode 100644
index 0000000000..45ceeecca3
--- /dev/null
+++ b/src/jailhouse/meson.build
@@ -0,0 +1,48 @@
+jailhouse_sources = files(
+ 'jailhouse_driver.c',
+)
+
+driver_source_files += jailhouse_sources
+stateful_driver_source_files += jailhouse_sources
+
+if conf.has('WITH_JAILHOUSE')
+ jailhouse_driver_impl = static_library(
+ 'virt_driver_jailhouse_impl',
+ [
+ jailhouse_sources,
+ ],
+ dependencies: [
+ access_dep,
+ src_dep,
+ ],
+ include_directories: [
+ conf_inc_dir,
+ hypervisor_inc_dir,
+ ],
+ )
+
+ virt_modules += {
+ 'name': 'virt_driver_jailhouse',
+ 'link_whole': [
+ jailhouse_driver_impl,
+ ],
+ 'link_args': [
+ libvirt_no_undefined,
+ ],
+ }
+
+ virt_daemons += {
+ 'name': 'virtjailhoused',
+ 'c_args': [
+ '-DDAEMON_NAME="virtjailhoused"',
+ '-DMODULE_NAME="jailhouse"'
+ ],
+ }
+
+ virt_conf_files += files('jailhouse.conf')
+ virt_aug_files += files('libvirtd_jailhouse.aug')
+
+ virt_daemon_confs += {
+ 'name': 'virtjailhoused',
+ }
+endif
diff --git a/src/libvirt.c b/src/libvirt.c
index b2d0ba3d23..59b75c6f7b 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -75,6 +75,9 @@
#ifdef WITH_BHYVE
# include "bhyve/bhyve_driver.h"
#endif
+#ifdef WITH_JAILHOUSE
+# include "jailhouse/jailhouse_driver.h"
+#endif
#include "access/viraccessmanager.h"
#define VIR_FROM_THIS VIR_FROM_NONE
@@ -271,6 +274,10 @@ virGlobalInit(void)
if (hypervRegister() == -1)
goto error;
#endif
+#ifdef WITH_JAILHOUSE
+ if (jailhouseRegister() == -1)
+ goto error;
+#endif
#ifdef WITH_REMOTE
if (remoteRegister() == -1)
goto error;
@@ -1003,6 +1010,9 @@ virConnectOpenInternal(const char *name,
#endif
#ifndef WITH_VZ
STRCASEEQ(ret->uri->scheme, "parallels") ||
+#endif
+#ifndef WITH_JAILHOUSE
+ STRCASEEQ(ret->uri->scheme, "jailhouse") ||
#endif
false)) {
virReportErrorHelper(VIR_FROM_NONE, VIR_ERR_CONFIG_UNSUPPORTED,
diff --git a/src/meson.build b/src/meson.build
index 5d8deaf548..7188dc623e 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -268,6 +268,7 @@ subdir('security')
subdir('storage')
subdir('bhyve')
+subdir('jailhouse')
subdir('esx')
subdir('hyperv')
subdir('libxl')
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 6798febf8d..f750270230 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6819,6 +6819,7 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
case VIR_DOMAIN_VIRT_PHYP:
case VIR_DOMAIN_VIRT_PARALLELS:
case VIR_DOMAIN_VIRT_BHYVE:
+ case VIR_DOMAIN_VIRT_JAILHOUSE:
case VIR_DOMAIN_VIRT_VZ:
case VIR_DOMAIN_VIRT_NONE:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
diff --git a/src/util/virerror.c b/src/util/virerror.c
index 507a29f50f..8caf24a5f2 100644
--- a/src/util/virerror.c
+++ b/src/util/virerror.c
@@ -134,6 +134,7 @@ VIR_ENUM_IMPL(virErrorDomain,
"Thread jobs",
"Admin Interface",
"Log Manager",
+ "Jailhouse Driver",
"Xen XL Config",
"Perf", /* 65 */
--
2.17.1
4 years, 2 months
[question] cpumap: why 'mpx' removed from Cooperlake model?
by Wangxin (Alexander)
Hi, Jiri
I just compared the cpu features between the 'x86_Cooperlake.xml ' and 'x86_Cascadelake-Server.xml',
the feature 'mpx' seems removed from the Cooperlake model. Is there a reason?
And what rules do we follow to add or remove CPU features?
Regards,
Xin
4 years, 2 months