[libvirt] [PATCH] tools: avoid accidentally using files from gnulib
by Daniel P. Berrangé
The AM_CPPFLAGS setting includes the gnulib headers, which
means we can get some replacement functions defined. Since
virt-login-shell and the NSS module intentionally don't link
to gnulib, these replacement functions causes link failures.
This was seen cross-compiling on Debian for example:
virt-login-shell.o: In function `main':
/builds/libvirt/libvirt/build/tools/../../tools/virt-login-shell.c:81: undefined reference to `rpl_strerror'
/builds/libvirt/libvirt/build/tools/../../tools/virt-login-shell.c:66: undefined reference to `rpl_strerror'
/builds/libvirt/libvirt/build/tools/../../tools/virt-login-shell.c:75: undefined reference to `rpl_strerror'
The only way to avoid these replacement gnulib headers is
to drop the -Ignulib/lib flags. We do still want to use
gnulib for configmake.h and intprops.h, but those can be
included via their full path.
We must also stop using internal.h, since that expects
-Ignulib/lib to be on the include path in order to resolve
the verify.h header.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
Technically a CI build fix, but waiting for review before
pushing since it is larger than most build fixes.
cfg.mk | 3 +++
tools/Makefile.am | 10 ++++++++++
tools/nss/libvirt_nss.c | 13 ++++++++++---
tools/nss/libvirt_nss_leases.c | 15 ++++++++-------
tools/nss/libvirt_nss_leases.h | 2 +-
tools/nss/libvirt_nss_macs.c | 6 +++---
tools/nss/libvirt_nss_macs.h | 2 +-
tools/virt-login-shell.c | 8 ++++++--
8 files changed, 42 insertions(+), 17 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index cc1f79a051..f082448293 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -1345,3 +1345,6 @@ exclude_file_name_regexp--sc_prohibit_cross_inclusion = \
exclude_file_name_regexp--sc_prohibit_dirent_d_type = \
^(src/util/vircgroup.c)$
+
+exclude_file_name_regexp--sc_prohibit_strcmp = \
+ ^(tools/nss/libvirt_nss.*\.c)
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 09cada949b..df3d628bab 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -23,6 +23,12 @@ AM_CPPFLAGS = \
-I$(top_srcdir) \
$(NULL)
+# We do not want to accidentally include stuff from gnulib
+# or the main src/ dir or public API dir. Specific files can
+# still be included via their path relative to the root if
+# needed
+STANDALONE_CPPFLAGS = -I$(top_srcdir)
+
WARN_CFLAGS += $(STRICT_FRAME_LIMIT_CFLAGS)
AM_CFLAGS = \
@@ -199,6 +205,8 @@ virt_host_validate_CFLAGS = \
virt_login_shell_SOURCES = \
virt-login-shell.c
+virt_login_shell_CPPFLAGS = $(STANDALONE_CPPFLAGS)
+
virt_login_shell_helper_SOURCES = \
virt-login-shell-helper.c
@@ -486,6 +494,7 @@ noinst_LTLIBRARIES += nss/libnss_libvirt_impl.la
nss_libnss_libvirt_impl_la_SOURCES = \
$(LIBVIRT_NSS_SOURCES)
+nss_libnss_libvirt_impl_la_CPPFLAGS = $(STANDALONE_CPPFLAGS)
nss_libnss_libvirt_impl_la_CFLAGS = \
-DLIBVIRT_NSS \
$(YAJL_CFLAGS) \
@@ -516,6 +525,7 @@ nss_libnss_libvirt_guest_impl_la_SOURCES = \
nss/libvirt_nss_macs.c \
$(NULL)
+nss_libnss_libvirt_guest_impl_la_CPPFLAGS = $(STANDALONE_CPPFLAGS)
nss_libnss_libvirt_guest_impl_la_CFLAGS = \
-DLIBVIRT_NSS \
-DLIBVIRT_NSS_GUEST \
diff --git a/tools/nss/libvirt_nss.c b/tools/nss/libvirt_nss.c
index 7122065b28..b75f51c560 100644
--- a/tools/nss/libvirt_nss.c
+++ b/tools/nss/libvirt_nss.c
@@ -32,6 +32,8 @@
#include <dirent.h>
#include <arpa/inet.h>
#include <stdlib.h>
+#include <stdbool.h>
+#include <errno.h>
#include <string.h>
#include <time.h>
@@ -40,7 +42,12 @@
# include <nsswitch.h>
#endif
-#include "configmake.h"
+/*
+ * This gnulib files is used for its macros only,
+ * so doesn't introduce a link time dep, which we
+ * must avoid
+ */
+#include "gnulib/lib/configmake.h"
#include "libvirt_nss_leases.h"
@@ -131,7 +138,7 @@ findLease(const char *name,
char *path;
size_t dlen = strlen(entry->d_name);
- if (dlen >= 7 && STREQ(entry->d_name + dlen - 7, ".status")) {
+ if (dlen >= 7 && !strcmp(entry->d_name + dlen - 7, ".status")) {
char **tmpLease;
if (asprintf(&path, "%s/%s", leaseDir, entry->d_name) < 0)
goto cleanup;
@@ -142,7 +149,7 @@ findLease(const char *name,
leaseFiles = tmpLease;
leaseFiles[nleaseFiles++] = path;
#if defined(LIBVIRT_NSS_GUEST)
- } else if (dlen >= 5 && STREQ(entry->d_name + dlen - 5, ".macs")) {
+ } else if (dlen >= 5 && !strcmp(entry->d_name + dlen - 5, ".macs")) {
if (asprintf(&path, "%s/%s", leaseDir, entry->d_name) < 0)
goto cleanup;
diff --git a/tools/nss/libvirt_nss_leases.c b/tools/nss/libvirt_nss_leases.c
index 48a54d5841..86881641a9 100644
--- a/tools/nss/libvirt_nss_leases.c
+++ b/tools/nss/libvirt_nss_leases.c
@@ -23,6 +23,7 @@
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
+#include <stdbool.h>
#include <fcntl.h>
#include <yajl/yajl_gen.h>
@@ -60,7 +61,7 @@ typedef struct {
static int
-appendAddr(const char *name ATTRIBUTE_UNUSED,
+appendAddr(const char *name __attribute__((unused)),
leaseAddress **tmpAddress,
size_t *ntmpAddress,
const char *ipAddr,
@@ -165,7 +166,7 @@ findLeasesParserInteger(void *ctx,
return 0;
if (parser->state == FIND_LEASES_STATE_ENTRY) {
- if (STRNEQ(parser->key, "expiry-time"))
+ if (strcmp(parser->key, "expiry-time"))
return 0;
parser->entry.expiry = val;
@@ -190,13 +191,13 @@ findLeasesParserString(void *ctx,
return 0;
if (parser->state == FIND_LEASES_STATE_ENTRY) {
- if (STREQ(parser->key, "ip-address")) {
+ if (!strcmp(parser->key, "ip-address")) {
if (!(parser->entry.ipaddr = strndup((char *)stringVal, stringLen)))
return 0;
- } else if (STREQ(parser->key, "mac-address")) {
+ } else if (!strcmp(parser->key, "mac-address")) {
if (!(parser->entry.macaddr = strndup((char *)stringVal, stringLen)))
return 0;
- } else if (STREQ(parser->key, "hostname")) {
+ } else if (!strcmp(parser->key, "hostname")) {
if (!(parser->entry.hostname = strndup((char *)stringVal, stringLen)))
return 0;
} else {
@@ -264,12 +265,12 @@ findLeasesParserEndMap(void *ctx)
DEBUG("Check %zu macs", parser->nmacs);
for (i = 0; i < parser->nmacs && !found; i++) {
DEBUG("Check mac '%s' vs '%s'", parser->macs[i], NULLSTR(parser->entry.macaddr));
- if (STREQ_NULLABLE(parser->macs[i], parser->entry.macaddr))
+ if (parser->entry.macaddr && !strcmp(parser->macs[i], parser->entry.macaddr))
found = true;
}
} else {
DEBUG("Check name '%s' vs '%s'", parser->name, NULLSTR(parser->entry.hostname));
- if (STREQ_NULLABLE(parser->name, parser->entry.hostname))
+ if (parser->entry.hostname && !strcmp(parser->name, parser->entry.hostname))
found = true;
}
DEBUG("Found %d", found);
diff --git a/tools/nss/libvirt_nss_leases.h b/tools/nss/libvirt_nss_leases.h
index e213681e46..c451742152 100644
--- a/tools/nss/libvirt_nss_leases.h
+++ b/tools/nss/libvirt_nss_leases.h
@@ -20,7 +20,7 @@
#pragma once
-#include "internal.h"
+#include <sys/types.h>
typedef struct {
unsigned char addr[16];
diff --git a/tools/nss/libvirt_nss_macs.c b/tools/nss/libvirt_nss_macs.c
index fb5526bd7b..26ba4bf515 100644
--- a/tools/nss/libvirt_nss_macs.c
+++ b/tools/nss/libvirt_nss_macs.c
@@ -67,7 +67,7 @@ findMACsParserString(void *ctx,
return 0;
if (parser->state == FIND_MACS_STATE_ENTRY) {
- if (STRNEQ(parser->key, "domain"))
+ if (strcmp(parser->key, "domain"))
return 0;
free(parser->entry.name);
@@ -75,7 +75,7 @@ findMACsParserString(void *ctx,
return 0;
} else if (parser->state == FIND_MACS_STATE_ENTRY_MACS) {
char **macs;
- if (STRNEQ(parser->key, "macs"))
+ if (strcmp(parser->key, "macs"))
return 0;
if (!(macs = realloc(parser->entry.macs,
@@ -142,7 +142,7 @@ findMACsParserEndMap(void *ctx)
if (parser->state != FIND_MACS_STATE_ENTRY)
return 0;
- if (STREQ(parser->entry.name, parser->name)) {
+ if (!strcmp(parser->entry.name, parser->name)) {
char **macs = realloc(*parser->macs,
sizeof(char *) * ((*parser->nmacs) + parser->entry.nmacs));
if (!macs)
diff --git a/tools/nss/libvirt_nss_macs.h b/tools/nss/libvirt_nss_macs.h
index 64e291f549..2774f3a9f2 100644
--- a/tools/nss/libvirt_nss_macs.h
+++ b/tools/nss/libvirt_nss_macs.h
@@ -20,7 +20,7 @@
#pragma once
-#include "internal.h"
+#include <sys/types.h>
int
findMACs(const char *file,
diff --git a/tools/virt-login-shell.c b/tools/virt-login-shell.c
index 41d0b349aa..f92cc0a749 100644
--- a/tools/virt-login-shell.c
+++ b/tools/virt-login-shell.c
@@ -28,8 +28,12 @@
#include <errno.h>
#include <string.h>
-#include "configmake.h"
-#include "intprops.h"
+/*
+ * These gnulib files are used for their macros only,
+ * so don't introduce a link time dep, which we must avoid
+ */
+#include "gnulib/lib/configmake.h"
+#include "gnulib/lib/intprops.h"
int main(int argc, char **argv) {
char uidstr[INT_BUFSIZE_BOUND(uid_t)];
--
2.21.0
5 years, 8 months
[libvirt] [PATCH] build: Solve mingw build clash with DATADIR
by Eric Blake
Commit fed58d83 was a hack to fix a mingw build failure due to header
inclusion order resulting in a clash over the use of DATADIR, by
repeating a trick made several other times in the past of tweaking
inclusion order until it goes away. Better is to revert that, and
instead use pragmas to avoid the clash in the first place, regardless
of header ordering, solving it for everyone in the future.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
I tested that both gcc and clang on F29 support this; but it will take
a full CI run to see if everywhere else is okay with it. Thus, it is
not 5.6 material.
src/util/viratomic.h | 3 +++
src/conf/checkpoint_conf.c | 2 --
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/util/viratomic.h b/src/util/viratomic.h
index 35800dafcd..c6e7668324 100644
--- a/src/util/viratomic.h
+++ b/src/util/viratomic.h
@@ -218,7 +218,10 @@ VIR_STATIC unsigned int virAtomicIntXor(volatile unsigned int *atomic,
# ifdef VIR_ATOMIC_OPS_WIN32
+# pragma push_macro("DATADIR") /* If "configmake.h" was included first */
+# undef DATADIR
# include <winsock2.h>
+# pragma pop_macro("DATADIR")
# include <windows.h>
# include <intrin.h>
# if !defined(_M_AMD64) && !defined (_M_IA64) && !defined(_M_X64)
diff --git a/src/conf/checkpoint_conf.c b/src/conf/checkpoint_conf.c
index 5ce4cc4853..5f4c275dd8 100644
--- a/src/conf/checkpoint_conf.c
+++ b/src/conf/checkpoint_conf.c
@@ -21,8 +21,6 @@
#include <config.h>
-#include <unistd.h>
-
#include "configmake.h"
#include "internal.h"
#include "virbitmap.h"
--
2.20.1
5 years, 8 months
[libvirt] [PATCH 0/2] Couple of Coverity fixes
by John Ferlan
Both from recent changes, it was just as easy for me to post the patches
as write the annoying email that someone else needs to generate them ;-).
John Ferlan (2):
qemu: Fix possible NULL deref in qemuDomainGetResctrlMonData
tests: Fix memory leak in mymain
src/qemu/qemu_driver.c | 3 ++-
tests/virhostdevtest.c | 4 +---
2 files changed, 3 insertions(+), 4 deletions(-)
--
2.20.1
5 years, 8 months
[libvirt] [PATCH 00/17] Refactor virt-login-shell and nss module
by Daniel P. Berrangé
As previously discussed, it is desirable to move libvirt to a model
where we abort-on-OOM, possibly making use of glib2.
This would be good for libvirt in general, but it is bad for a
couple of libvirt addons.
The virt-login-shell setuid program would be ok with abort-on-OOM,
but absolutely can never link to glib2 in a setuid setup.
The NSS module cannot tolerate abort-on-OOM as it is dyn loaded in
to every process on the host, some of which wish to be robust on
OOM.
It is not practical to restrict abort-on-OOM to only the pieces of
code not used by NSS, nor is it practical to conditionally build
with & without abort-on-OOM.
The solution to both these problems is to refactor the code such
that it does not use any common libvirt code. Only direct libc
APIs are permitted, and for the NSS module the yajl library.
For virt-login-shell this refactoring actually makes the entire
solution more pleasant to deal with, so is a win regardless.
For the NSS module, the code is a little less attractive by
using the lower level libc APIs. The need to use the yajl APIs
directly also makes parsing MACs/leases much more verbose. This
is still tolerable though, given the benefit of switching the
other libvirt code to abort-on-OOM.
Daniel P. Berrangé (17):
tools: fix crash in virt-login-shell if config doesn't exist
tools: fix double error reporting in virt-login-shell
tools: rename source for virt-login-shell
tools: split virt-login-shell into two binaries
build: drop libvirt setuid library build
util: get rid of virIsSUID method
util: simplify virCommand APIs for env passthrough.
util: get rid of virGetEnv{Allow,Block}SUID functions
nss: remove use for virDir helper APIs
nss: remove use for virString helper APIs
nss: remove use for virFile helper APIs
nss: refactor code for processing mac addresses
nss: custom parser for loading .macs file
nss: custom parser for loading .leases file
nss: directly use getnameinfo/getaddrinfo
nss: remove last usages of libvirt headers
nss: only link to yajl library and nothing else
.gitignore | 1 +
cfg.mk | 25 +-
config-post.h | 54 ----
configure.ac | 3 -
libvirt.spec.in | 1 +
src/Makefile.am | 174 -------------
src/libvirt-admin.c | 2 +-
src/libvirt.c | 47 ++--
src/libvirt_private.syms | 6 +-
src/lxc/lxc_process.c | 2 +-
src/network/leaseshelper.c | 14 +-
src/qemu/qemu_command.c | 8 +-
src/qemu/qemu_firmware.c | 2 +-
src/remote/remote_driver.c | 25 +-
src/rpc/virnetlibsshsession.c | 2 +-
src/rpc/virnetsocket.c | 16 +-
src/rpc/virnettlscontext.c | 2 +-
src/util/virauth.c | 2 +-
src/util/vircommand.c | 48 +---
src/util/vircommand.h | 8 +-
src/util/virfile.c | 7 +-
src/util/virlease.c | 4 +-
src/util/virlog.c | 15 +-
src/util/virsystemd.c | 8 +-
src/util/virutil.c | 48 +---
src/util/virutil.h | 4 -
src/vbox/vbox_XPCOMCGlue.c | 2 +-
src/vbox/vbox_common.c | 2 +-
tests/commandtest.c | 8 +-
tools/Makefile.am | 43 ++--
tools/nss/libvirt_nss.c | 343 ++++++++-----------------
tools/nss/libvirt_nss.h | 24 ++
tools/nss/libvirt_nss_leases.c | 429 +++++++++++++++++++++++++++++++
tools/nss/libvirt_nss_leases.h | 40 +++
tools/nss/libvirt_nss_macs.c | 287 +++++++++++++++++++++
tools/nss/libvirt_nss_macs.h | 29 +++
tools/virsh.c | 2 +-
tools/virt-login-shell-helper.c | 439 ++++++++++++++++++++++++++++++++
tools/virt-login-shell.c | 421 ++++--------------------------
tools/vsh.c | 12 +-
40 files changed, 1521 insertions(+), 1088 deletions(-)
create mode 100644 tools/nss/libvirt_nss_leases.c
create mode 100644 tools/nss/libvirt_nss_leases.h
create mode 100644 tools/nss/libvirt_nss_macs.c
create mode 100644 tools/nss/libvirt_nss_macs.h
create mode 100644 tools/virt-login-shell-helper.c
--
2.21.0
5 years, 8 months
[libvirt] [PATCH] src: security: Replace bitwise OR with logical OR
by Erik Skultety
Typo introduced by commit d73f3f58360.
https://bugzilla.redhat.com/show_bug.cgi?id=1738483
Signed-off-by: Erik Skultety <eskultet(a)redhat.com>
---
Pushed as trivial.
src/security/security_util.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/security/security_util.c b/src/security/security_util.c
index ad265b0bc5..9d3f483f6b 100644
--- a/src/security/security_util.c
+++ b/src/security/security_util.c
@@ -268,7 +268,7 @@ virSecurityMoveRememberedLabel(const char *name,
VIR_AUTOFREE(char *) attr_name = NULL;
VIR_AUTOFREE(char *) attr_value = NULL;
- if (!(ref_name = virSecurityGetRefCountAttrName(name)) |
+ if (!(ref_name = virSecurityGetRefCountAttrName(name)) ||
!(attr_name = virSecurityGetAttrName(name)))
return -1;
--
2.20.1
5 years, 8 months
[libvirt] [PATCH] test_driver: implement virDomainReset
by Ilias Stamatis
The qemu and vz implementations don't emit any signals when this API is
called, so we can do the same here for now and succeed by doing nothing.
Signed-off-by: Ilias Stamatis <stamatis.iliass(a)gmail.com>
---
src/test/test_driver.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index d9a7f815d5..6bca4e277f 100755
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -2004,6 +2004,28 @@ static int testDomainReboot(virDomainPtr domain,
}
+static int
+testDomainReset(virDomainPtr dom,
+ unsigned int flags)
+{
+ virDomainObjPtr vm;
+ int ret = -1;
+
+ virCheckFlags(0, -1);
+
+ if (!(vm = testDomObjFromDomain(dom)))
+ return -1;
+
+ if (virDomainObjCheckActive(vm) < 0)
+ goto cleanup;
+
+ ret = 0;
+ cleanup:
+ virDomainObjEndAPI(&vm);
+ return ret;
+}
+
+
static char *
testDomainGetHostname(virDomainPtr domain,
unsigned int flags)
@@ -8878,6 +8900,7 @@ static virHypervisorDriver testHypervisorDriver = {
.domainShutdown = testDomainShutdown, /* 0.1.1 */
.domainShutdownFlags = testDomainShutdownFlags, /* 0.9.10 */
.domainReboot = testDomainReboot, /* 0.1.1 */
+ .domainReset = testDomainReset, /* 5.7.0 */
.domainDestroy = testDomainDestroy, /* 0.1.1 */
.domainDestroyFlags = testDomainDestroyFlags, /* 4.2.0 */
.domainGetOSType = testDomainGetOSType, /* 0.1.9 */
--
2.22.0
5 years, 8 months
[libvirt] [PATCH] test_driver: implement virDomainSetTime and update virDomainGetTime
by Ilias Stamatis
Until now, testDomainGetTime would always return the same fixed value
everytime it was called. By using domain-private data we can make this
API return the values previously set with testDomainSetTime, or use the
same old fixed value in case testDomainSetTime hasn't been called at all.
---
src/test/test_driver.c | 45 ++++++++++++++++++++++++++++++++++++++++--
1 file changed, 43 insertions(+), 2 deletions(-)
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index d9a7f815d5..6a75e63429 100755
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -392,6 +392,11 @@ struct _testDomainObjPrivate {
testDriverPtr driver;
bool frozen[2]; /* used by file system related calls */
+
+
+ /* used by get/set time APIs */
+ long long seconds;
+ unsigned int nseconds;
};
@@ -406,6 +411,9 @@ testDomainObjPrivateAlloc(void *opaque)
priv->driver = opaque;
priv->frozen[0] = priv->frozen[1] = false;
+ priv->seconds = 627319920;
+ priv->nseconds = 0;
+
return priv;
}
@@ -2082,6 +2090,7 @@ testDomainGetTime(virDomainPtr dom,
unsigned int flags)
{
virDomainObjPtr vm = NULL;
+ testDomainObjPrivatePtr priv;
int ret = -1;
virCheckFlags(0, -1);
@@ -2095,8 +2104,39 @@ testDomainGetTime(virDomainPtr dom,
goto cleanup;
}
- *seconds = 627319920;
- *nseconds = 0;
+ priv = vm->privateData;
+
+ *seconds = priv->seconds;
+ *nseconds = priv->nseconds;
+
+ ret = 0;
+ cleanup:
+ virDomainObjEndAPI(&vm);
+ return ret;
+}
+
+
+static int
+testDomainSetTime(virDomainPtr dom,
+ long long seconds,
+ unsigned int nseconds,
+ unsigned int flags)
+{
+ virDomainObjPtr vm = NULL;
+ testDomainObjPrivatePtr priv;
+ int ret = -1;
+
+ virCheckFlags(VIR_DOMAIN_TIME_SYNC, ret);
+
+ if (!(vm = testDomObjFromDomain(dom)))
+ return -1;
+
+ if (virDomainObjCheckActive(vm) < 0)
+ goto cleanup;
+
+ priv = vm->privateData;
+ priv->seconds = seconds;
+ priv->nseconds = nseconds;
ret = 0;
cleanup:
@@ -8891,6 +8931,7 @@ static virHypervisorDriver testHypervisorDriver = {
.domainGetInfo = testDomainGetInfo, /* 0.1.1 */
.domainGetState = testDomainGetState, /* 0.9.2 */
.domainGetTime = testDomainGetTime, /* 5.4.0 */
+ .domainSetTime = testDomainSetTime, /* 5.7.0 */
.domainSave = testDomainSave, /* 0.3.2 */
.domainSaveFlags = testDomainSaveFlags, /* 0.9.4 */
.domainRestore = testDomainRestore, /* 0.3.2 */
--
2.22.0
5 years, 8 months
[libvirt] [PATCH 0/7] qemu: use domCaps for validation
by Cole Robinson
I'm trying to remove some hurdles and pitfalls WRT extending
domaincapabilities data. One issue is that it's too easy to add
invalid data to it, or let the data become out of date.
For example the first two patches of this series add <rng model=X>
domcaps reporting. The logic to fill in the domcaps data from qemuCaps
is nearly identical to the logic we use to validate rng->model in
qemuDomainRNGDefValidate. If just those patches are added, and later
a new qemu rng model was introduced, a future patch could easily
miss updated domaincapabilities output.
This series aims to set up a pattern to prevent these types of issues
from sneaking in. A function virDomainCapsDeviceDefValidate is added
which will use domcaps data to perform validation against a devicedef.
The existing qemu <rng> model validation is moved there. This ensures
that any future <rng> model additions, if they want to work in the
qemu driver, effectively need to extend domaincapabilities as well.
It's also theoretically useful for other drivers too.
One issue is that at DomainDefValidate time we don't have domCaps
handy, or any cache layer for domCaps assembling. Patch #4 adds
a domCapsCache hashtable to the virQEMUCaps class for caching domCaps
builds based on the full tuple of emulator+machine+arch+virttype.
If qemuCaps need to be regenerated, the domCaps cache is wiped out
for us so we don't need to worry about the data being stale, it's
tied to the lifetime of a qemuCaps instance.
Cole Robinson (7):
conf: domcaps: Report device <rng>
qemu: capabilities: fill in domcaps <rng>
qemu: conf: add virQEMUDriverGetDomainCapabilities
qemu: conf: Cache domCaps in qemuCaps
conf: domcaps: Add virDomainCapsDeviceDefValidate
qemu: domain: Call virDomainCapsDeviceDefValidate
qemu: Move rng model validation to domcaps
docs/formatdomaincaps.html.in | 35 ++++++++
docs/schemas/domaincaps.rng | 10 +++
src/conf/domain_capabilities.c | 83 ++++++++++++++++++
src/conf/domain_capabilities.h | 14 ++++
src/libvirt_private.syms | 1 +
src/qemu/qemu_capabilities.c | 41 +++++++++
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_conf.c | 84 +++++++++++++++++++
src/qemu/qemu_conf.h | 7 ++
src/qemu/qemu_domain.c | 38 +++------
src/qemu/qemu_driver.c | 18 +---
.../qemu_1.7.0.x86_64.xml | 9 ++
.../qemu_2.12.0-virt.aarch64.xml | 11 +++
.../qemu_2.12.0.ppc64.xml | 11 +++
.../qemu_2.12.0.s390x.xml | 11 +++
.../qemu_2.12.0.x86_64.xml | 11 +++
.../qemu_2.6.0-virt.aarch64.xml | 11 +++
.../qemu_2.6.0.aarch64.xml | 11 +++
.../domaincapsschemadata/qemu_2.6.0.ppc64.xml | 11 +++
.../qemu_2.6.0.x86_64.xml | 11 +++
.../domaincapsschemadata/qemu_2.7.0.s390x.xml | 11 +++
.../qemu_2.8.0-tcg.x86_64.xml | 11 +++
.../domaincapsschemadata/qemu_2.8.0.s390x.xml | 11 +++
.../qemu_2.8.0.x86_64.xml | 11 +++
.../qemu_2.9.0-q35.x86_64.xml | 11 +++
.../qemu_2.9.0-tcg.x86_64.xml | 11 +++
.../qemu_2.9.0.x86_64.xml | 11 +++
.../domaincapsschemadata/qemu_3.0.0.s390x.xml | 11 +++
.../qemu_4.0.0.x86_64.xml | 11 +++
29 files changed, 488 insertions(+), 40 deletions(-)
--
2.21.0
5 years, 8 months