[libvirt] [PATCH] tests: viriscsitest: make it work on big endian archs
by Pino Toscano
viriscsitest tries to ensure the interface IQN used is a specific one,
checking later on that it is the same all during the whole test. Since
the IQN generation involves random bytes, viriscsitest got a fake
virRandomBytes from the virrandommock helper library, setting static
values. virRandomBits(), called by virStorageBackendCreateIfaceIQN(),
always requests 8 random bytes, chopping off the ones not requested by
the caller -- this meant that on big endian machines it would chop bytes
from the wrong size of the data buffer, and thus not returning the
expected numbers.
As a fix, do not rely on the mock virRandomBytes, but provide an own
version of it: this version will fill the values in the expected order,
depending on the endianness of the system. This way, the result of
virStorageBackendCreateIfaceIQN() will be what the test actually
expects.
Signed-off-by: Pino Toscano <ptoscano(a)redhat.com>
---
tests/viriscsitest.c | 30 ++++++++++++++++++++++++++++--
1 file changed, 28 insertions(+), 2 deletions(-)
diff --git a/tests/viriscsitest.c b/tests/viriscsitest.c
index 4fd7ff6e19..d43c0115d3 100644
--- a/tests/viriscsitest.c
+++ b/tests/viriscsitest.c
@@ -21,6 +21,7 @@
#include <config.h>
#include "testutils.h"
+#include "virrandom.h"
#ifdef WIN32
int
@@ -36,6 +37,32 @@ main(void)
# define VIR_FROM_THIS VIR_FROM_NONE
+bool isLittleEndian(void);
+bool isLittleEndian(void)
+{
+ static int cache = -1;
+ if (cache < 0) {
+ int val = 1;
+ char *ptr = (char *)&val;
+ cache = *ptr ? 1 : 0;
+ }
+ return cache > 0;
+}
+
+
+int
+virRandomBytes(unsigned char *buf,
+ size_t buflen)
+{
+ size_t i;
+ const bool isLE = isLittleEndian();
+
+ for (i = 0; i < buflen; i++)
+ buf[i] = isLE ? i : buflen - i - 1;
+
+ return 0;
+}
+
static const char *iscsiadmSessionOutput =
"tcp: [1] 10.20.30.40:3260,1 iqn.2004-06.example:example1:iscsi.test\n"
"tcp: [2] 10.20.30.41:3260,1 iqn.2005-05.example:example1:iscsi.hello\n"
@@ -368,6 +395,5 @@ mymain(void)
return EXIT_SUCCESS;
}
-VIR_TEST_MAIN_PRELOAD(mymain,
- abs_builddir "/.libs/virrandommock.so")
+VIR_TEST_MAIN(mymain)
#endif /* WIN32 */
--
2.17.1
6 years, 4 months
Re: [libvirt] [PATCH v2] conf: virDomainDefValidateInternal prohibit some characters in shmem name
by skobyda@redhat.com
On Fri, 2018-07-27 at 13:19 -0400, John Ferlan wrote:
> You shouldn't drop libvir-list when you reply...
Sorry, I dropped it by mistake.
>
> On 07/27/2018 06:35 AM, skobyda(a)redhat.com wrote:
> > On Mon, 2018-07-23 at 17:32 -0400, John Ferlan wrote:
> > >
> > > On 07/12/2018 09:10 AM, Simon Kobyda wrote:
> > > > XML shmem name will not include character '/', and will not be
> > > > equal to strings
> > > > "." or "..", as shmem name is used in a path.
> > >
> > > Validate that the provided XML shmem name is not directory
> > > specific
> > > "."
> > > or ".." names as well as ensuring that there is no path separator
> > > '/'
> > > in
> > > the name.
> > > > https://bugzilla.redhat.com/show_bug.cgi?id=1192400
> > > > ---
> > > >
> > > > Changes in V2
> > > > - Added error reports
> > > > - Error situation will happen only if shmem name is
> > > > equal to
> > > > "." or "..", however their occurence in a name
> > > > compromised of
> > > > more
> > > > characters is allowed.
> > > >
> > > > src/conf/domain_conf.c | 22 ++++++++++++++++++++++
> > > > 1 file changed, 22 insertions(+)
> > > >
> > >
> > > I believe this actually belongs in
> > > virDomainDeviceDefValidateInternal
> > > for case VIR_DOMAIN_DEVICE_SHMEM.
> > > Also, should the docs/schemas/domaincommon.rng be modified?
> > > Currently
> > > it
> > > has:
> > >
> > > <define name="shmem">
> > > <element name="shmem">
> > > <attribute name="name">
> > > <data type="string">
> > > <param name="pattern">[^/]*</param>
> > > </data>
> > >
> >
> > Is it a good idea? To create such regular expression, I believe it
> > would make it unreadable for another person, ergo useless. I don't
> > want
> > it to end up as IPv6. I've benn told that actual parser can be, and
> > sometimes is stricter than scheme.
> >
>
> Well this is what I was hoping others would be able to chime in on.
> Hence why you ask on list. I don't disagree that being stricter in
> Parse
> is fine. Doing regexes is like reading a foreign language to me at
> times. Some just don't make sense.
Yeah, that's why I don't want to try to insert complicated regex in
docs/schemas/domaincommon.rng.
>
> I think that regex is indicating - any character except '/', but I'm
> not
> sure. If it is, it's ironic that we have to check for '/'
> specifically
> since it shouldn't be passing the xml validation test - OK at least
> if
> one was editing via virsh.
>
> John
>
You are right about what that regex does. But from what I heard, that
functionality is rather new to libvirt, so users have option to bypass
that verification. So I would like to also leave it in code in case
users try to bypass that regex verification.
Simon.
> > > Consider how other names are limited in their scope. The
> > > basictypes.rng
> > > has a number of examples.
> > >
> > > Naturally, the problem with changing it is that someone somewhere
> > > will
> > > complain, but libvirt used to accept this other format. Right now
> > > I
> > > would think the scope a bit too broad.
> >
> > But then we cannot fix most of the bugs, since there could always
> > be
> > some user which relies on bug behavior.
> > >
> > > If we are to limit the name we should also document in
> > > docs/formatdomain.html.in that the shmem name is "limited" in
> > > name to
> > > avoid the '/' character, ".", and "..".
> > >
> > > BTW: My regex isn't that good, but it would seem '/' is an
> > > invalid
> > > character by XML standards even though the code never checked for
> > > it.
> > > Using virt-xml-validate <file> <schema> would "validate" whether
> > > someone
> > > provides valid XML.
> > >
> > >
> > > John
> > >
> > > > diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> > > > index 7ab2953d83..6b34c17de4 100644
> > > > --- a/src/conf/domain_conf.c
> > > > +++ b/src/conf/domain_conf.c
> > > > @@ -6107,6 +6107,8 @@ virDomainDefLifecycleActionValidate(const
> > > > virDomainDef *def)
> > > > static int
> > > > virDomainDefValidateInternal(const virDomainDef *def)
> > > > {
> > > > + size_t i;
> > > > +
> > > > if (virDomainDefCheckDuplicateDiskInfo(def) < 0)
> > > > return -1;
> > > >
> > > > @@ -6136,6 +6138,26 @@ virDomainDefValidateInternal(const
> > > > virDomainDef *def)
> > > > return -1;
> > > > }
> > > >
> > > > + for (i = 0; i < def->nshmems; i++) {
> > > > + if (strchr(def->shmems[i]->name, '/')) {
> > > > + virReportError(VIR_ERR_XML_ERROR, "%s",
> > > > + _("shmem name cannot include '/'
> > > > character"));
> > > > + return -1;
> > > > + }
> > > > +
> > > > + if (STREQ(def->shmems[i]->name, ".")) {
> > > > + virReportError(VIR_ERR_XML_ERROR, "%s",
> > > > + _("shmem name cannot be equal to
> > > > '.'"));
> > > > + return -1;
> > > > + }
> > > > +
> > > > + if (STREQ(def->shmems[i]->name, "..")) {
> > > > + virReportError(VIR_ERR_XML_ERROR, "%s",
> > > > + _("shmem name cannot be equal to
> > > > '..'"));
> > > > + return -1;
> > > > + }
> > > > + }
> > > > +
> > > > if (virDomainDefLifecycleActionValidate(def) < 0)
> > > > return -1;
> > > >
> > > >
6 years, 4 months
[libvirt] [PATCH for 4.6.0] tests: qemucapsprobe: Fix output after swithching to jansson
by Peter Krempa
Jansson does not put a newline at the end of formatted JSON strings.
This breaks the qemucapsprobe utility as we need to keep the spacing so
that tests work. Add an explicit newline.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
tests/qemucapsprobemock.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tests/qemucapsprobemock.c b/tests/qemucapsprobemock.c
index 5936975505..049b16273a 100644
--- a/tests/qemucapsprobemock.c
+++ b/tests/qemucapsprobemock.c
@@ -76,6 +76,7 @@ qemuMonitorSend(qemuMonitorPtr mon,
printLineSkipEmpty("\n", stdout);
printLineSkipEmpty(reformatted, stdout);
+ printLineSkipEmpty("\n", stdout);
VIR_FREE(reformatted);
return realQemuMonitorSend(mon, msg);
@@ -116,6 +117,7 @@ qemuMonitorJSONIOProcessLine(qemuMonitorPtr mon,
printLineSkipEmpty("\n", stdout);
printLineSkipEmpty(json, stdout);
+ printLineSkipEmpty("\n", stdout);
}
cleanup:
--
2.16.2
6 years, 4 months
[libvirt] [dockerfiles PATCH] Update OS when building images
by Andrea Bolognani
The corresponding libvirt-jenkins-ci commit is dcbad35f45fe.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
Pushed under the Dockerfile refresh rule.
buildenv-centos-7.Dockerfile | 3 ++-
buildenv-debian-8.Dockerfile | 1 +
buildenv-debian-9.Dockerfile | 1 +
buildenv-debian-sid.Dockerfile | 1 +
buildenv-fedora-27.Dockerfile | 3 ++-
buildenv-fedora-28.Dockerfile | 3 ++-
buildenv-fedora-rawhide.Dockerfile | 3 ++-
buildenv-ubuntu-16.Dockerfile | 1 +
buildenv-ubuntu-18.Dockerfile | 1 +
9 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/buildenv-centos-7.Dockerfile b/buildenv-centos-7.Dockerfile
index 2c4c26d..896bf68 100644
--- a/buildenv-centos-7.Dockerfile
+++ b/buildenv-centos-7.Dockerfile
@@ -65,6 +65,7 @@ ENV PACKAGES audit-libs-devel \
sudo \
systemtap-sdt-devel \
vim
-RUN yum install -y ${PACKAGES} && \
+RUN yum update -y && \
+ yum install -y ${PACKAGES} && \
yum autoremove -y && \
yum clean all -y
diff --git a/buildenv-debian-8.Dockerfile b/buildenv-debian-8.Dockerfile
index 8a8c3b0..8877528 100644
--- a/buildenv-debian-8.Dockerfile
+++ b/buildenv-debian-8.Dockerfile
@@ -71,6 +71,7 @@ ENV PACKAGES augeas-tools \
xsltproc \
zfs-fuse
RUN apt-get update && \
+ apt-get dist-upgrade -y && \
apt-get install -y ${PACKAGES} && \
apt-get autoremove -y && \
apt-get autoclean -y
diff --git a/buildenv-debian-9.Dockerfile b/buildenv-debian-9.Dockerfile
index c3af421..0592c97 100644
--- a/buildenv-debian-9.Dockerfile
+++ b/buildenv-debian-9.Dockerfile
@@ -73,6 +73,7 @@ ENV PACKAGES augeas-tools \
xsltproc \
zfs-fuse
RUN apt-get update && \
+ apt-get dist-upgrade -y && \
apt-get install -y ${PACKAGES} && \
apt-get autoremove -y && \
apt-get autoclean -y
diff --git a/buildenv-debian-sid.Dockerfile b/buildenv-debian-sid.Dockerfile
index a922457..2d0310d 100644
--- a/buildenv-debian-sid.Dockerfile
+++ b/buildenv-debian-sid.Dockerfile
@@ -73,6 +73,7 @@ ENV PACKAGES augeas-tools \
xsltproc \
zfs-fuse
RUN apt-get update && \
+ apt-get dist-upgrade -y && \
apt-get install -y ${PACKAGES} && \
apt-get autoremove -y && \
apt-get autoclean -y
diff --git a/buildenv-fedora-27.Dockerfile b/buildenv-fedora-27.Dockerfile
index 2f35a2e..09ec721 100644
--- a/buildenv-fedora-27.Dockerfile
+++ b/buildenv-fedora-27.Dockerfile
@@ -73,6 +73,7 @@ ENV PACKAGES audit-libs-devel \
wireshark-devel \
xen-devel \
zfs-fuse
-RUN yum install -y ${PACKAGES} && \
+RUN yum update -y && \
+ yum install -y ${PACKAGES} && \
yum autoremove -y && \
yum clean all -y
diff --git a/buildenv-fedora-28.Dockerfile b/buildenv-fedora-28.Dockerfile
index f4f7198..60afba5 100644
--- a/buildenv-fedora-28.Dockerfile
+++ b/buildenv-fedora-28.Dockerfile
@@ -73,6 +73,7 @@ ENV PACKAGES audit-libs-devel \
wireshark-devel \
xen-devel \
zfs-fuse
-RUN yum install -y ${PACKAGES} && \
+RUN yum update -y && \
+ yum install -y ${PACKAGES} && \
yum autoremove -y && \
yum clean all -y
diff --git a/buildenv-fedora-rawhide.Dockerfile b/buildenv-fedora-rawhide.Dockerfile
index 189ea59..33b47e1 100644
--- a/buildenv-fedora-rawhide.Dockerfile
+++ b/buildenv-fedora-rawhide.Dockerfile
@@ -97,6 +97,7 @@ ENV PACKAGES audit-libs-devel \
wireshark-devel \
xen-devel \
zfs-fuse
-RUN yum install -y ${PACKAGES} && \
+RUN yum update -y && \
+ yum install -y ${PACKAGES} && \
yum autoremove -y && \
yum clean all -y
diff --git a/buildenv-ubuntu-16.Dockerfile b/buildenv-ubuntu-16.Dockerfile
index bc387a1..c904c6e 100644
--- a/buildenv-ubuntu-16.Dockerfile
+++ b/buildenv-ubuntu-16.Dockerfile
@@ -74,6 +74,7 @@ ENV PACKAGES augeas-tools \
xsltproc \
zfs-fuse
RUN apt-get update && \
+ apt-get dist-upgrade -y && \
apt-get install -y ${PACKAGES} && \
apt-get autoremove -y && \
apt-get autoclean -y
diff --git a/buildenv-ubuntu-18.Dockerfile b/buildenv-ubuntu-18.Dockerfile
index 2a15f14..bbd32c1 100644
--- a/buildenv-ubuntu-18.Dockerfile
+++ b/buildenv-ubuntu-18.Dockerfile
@@ -74,6 +74,7 @@ ENV PACKAGES augeas-tools \
xsltproc \
zfs-fuse
RUN apt-get update && \
+ apt-get dist-upgrade -y && \
apt-get install -y ${PACKAGES} && \
apt-get autoremove -y && \
apt-get autoclean -y
--
2.17.1
6 years, 4 months
[libvirt] [jenkins-ci PATCH] lcitool: Update OS when building Docker images
by Andrea Bolognani
The last build of the Fedora Rawhide Docker image failed
with
Transaction check error:
file /usr/lib64/libgdbm_compat.so.4.0.0 from install
of gdbm-libs-1:1.16-1.fc29.x86_64 conflicts with file
from package gdbm-1:1.14.1-3.fc28.x86_64
caused by the gdbm package having recently been split.
Especially with fast-moving distribution such as Fedora
Rawhide and Debian Sid, we can't rely on the base OS not
changing over time, so merely installing the packages we
need on top of that is not enough.
Additionally, updating the OS brings the Docker images
closer to the guests running on CentOS CI, which are
updated daily.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
guests/lcitool | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/guests/lcitool b/guests/lcitool
index 22b08dd..33c1afe 100755
--- a/guests/lcitool
+++ b/guests/lcitool
@@ -478,13 +478,15 @@ class Application:
if package_format == "deb":
sys.stdout.write(textwrap.dedent("""
RUN apt-get update && \\
+ apt-get dist-upgrade -y && \\
apt-get install -y ${PACKAGES} && \\
apt-get autoremove -y && \\
apt-get autoclean -y
"""))
elif package_format == "rpm":
sys.stdout.write(textwrap.dedent("""
- RUN yum install -y ${PACKAGES} && \\
+ RUN yum update -y && \\
+ yum install -y ${PACKAGES} && \\
yum autoremove -y && \\
yum clean all -y
"""))
--
2.17.1
6 years, 4 months
[libvirt] [dbus PATCH] Install daemon under @sbindir@
by Andrea Bolognani
The libvirt-dbus daemon is not supposed to be invoked
explicitly by the user, but rather to be spawned on-demand
by the D-Bus daemon: as such, @sbindir@ is a more suitable
location in which to install it.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
data/Makefile.am | 4 ++--
data/session/org.libvirt.service.in | 2 +-
data/system/org.libvirt.service.in | 2 +-
libvirt-dbus.spec.in | 2 +-
src/Makefile.am | 2 +-
5 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/data/Makefile.am b/data/Makefile.am
index 7b523da..660a100 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -62,12 +62,12 @@ CLEANFILES = \
session/org.libvirt.service: session/org.libvirt.service.in
$(AM_V_GEN)$(MKDIR_P) session && \
- sed -e 's|[@]bindir[@]|$(bindir)|g' < $< > $@-t && \
+ sed -e 's|[@]sbindir[@]|$(sbindir)|g' < $< > $@-t && \
mv $@-t $@
system/org.libvirt.service: system/org.libvirt.service.in
$(AM_V_GEN)$(MKDIR_P) system && \
- sed -e 's|[@]bindir[@]|$(bindir)|g' \
+ sed -e 's|[@]sbindir[@]|$(sbindir)|g' \
-e 's|[@]SYSTEM_USER[@]|$(SYSTEM_USER)|' \
< $< > $@-t && mv $@-t $@
diff --git a/data/session/org.libvirt.service.in b/data/session/org.libvirt.service.in
index a8cb6a9..8a56b95 100644
--- a/data/session/org.libvirt.service.in
+++ b/data/session/org.libvirt.service.in
@@ -1,3 +1,3 @@
[D-BUS Service]
Name=org.libvirt
-Exec=@bindir@/libvirt-dbus --session
+Exec=@sbindir@/libvirt-dbus --session
diff --git a/data/system/org.libvirt.service.in b/data/system/org.libvirt.service.in
index 0d3abdd..781a503 100644
--- a/data/system/org.libvirt.service.in
+++ b/data/system/org.libvirt.service.in
@@ -1,4 +1,4 @@
[D-BUS Service]
Name=org.libvirt
-Exec=@bindir@/libvirt-dbus --system
+Exec=@sbindir@/libvirt-dbus --system
User=@SYSTEM_USER@
diff --git a/libvirt-dbus.spec.in b/libvirt-dbus.spec.in
index f99e041..626e2da 100644
--- a/libvirt-dbus.spec.in
+++ b/libvirt-dbus.spec.in
@@ -51,7 +51,7 @@ exit 0
%files
%doc README.md HACKING.md AUTHORS NEWS
%license COPYING
-%{_bindir}/libvirt-dbus
+%{_sbindir}/libvirt-dbus
%{_datadir}/dbus-1/services/org.libvirt.service
%{_datadir}/dbus-1/system-services/org.libvirt.service
%{_datadir}/dbus-1/system.d/org.libvirt.conf
diff --git a/src/Makefile.am b/src/Makefile.am
index b5bf129..bc13feb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -28,7 +28,7 @@ libutil_la_SOURCES = \
util.h \
$(NULL)
-bin_PROGRAMS = \
+sbin_PROGRAMS = \
libvirt-dbus \
$(NULL)
--
2.17.1
6 years, 4 months
[libvirt] [PATCH] qemu: qemuDomainChangeNet: don't overwrite device info when pci addr is missing
by Katerina Koukiou
When trying to update an interface's rom settings with an device XML
that is missing the PCI addr element, all new rom settings where not applied.
https://bugzilla.redhat.com/show_bug.cgi?id=1599513
Signed-off-by: Katerina Koukiou <kkoukiou(a)redhat.com>
---
Not sure why we chose to overwrite the whole info before though, I hope
that this doesn't cause side problems.
src/qemu/qemu_hotplug.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 1488f0a7c2..f45192b1d3 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -3445,17 +3445,14 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
goto cleanup;
}
- /* info: if newdev->info is empty, fill it in from olddev,
- * otherwise verify that it matches - nothing is allowed to
- * change. (There is no helper function to do this, so
- * individually check the few feidls of virDomainDeviceInfo that
- * are relevant in this case).
+ /* info: if newdev->info.addr.pci is empty, fill it in from olddev,
+ * otherwise verify that it matches.
*/
if (!virDomainDeviceAddressIsValid(&newdev->info,
- VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) &&
- virDomainDeviceInfoCopy(&newdev->info, &olddev->info) < 0) {
- goto cleanup;
+ VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)) {
+ newdev->info.addr.pci = olddev->info.addr.pci;
}
+
if (!virPCIDeviceAddressEqual(&olddev->info.addr.pci,
&newdev->info.addr.pci)) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
--
2.17.1
6 years, 4 months
[libvirt] [PATCH RFC 0/2] ESX: Fixing SetAutoStart
by Marcos Paulo de Souza
Hi guys,
while doing some random tests using the ESX driver, I faced a crash, and these
two patches are trying to solve. I don't know if there is a better way to solve
it, since ESX driver *generated* code to alloc and free some *generated*
structs, but, please let me know if you have a better idea.
Thanks,
Marcos Paulo de Souza (2):
esx: Do not crash SetAutoStart by double free
esx: Fix SetAutoStart invalid pointer free
src/esx/esx_driver.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
--
2.17.1
6 years, 4 months
[libvirt] [PATCH] util: avoid symbol clash between json libraries
by Daniel P. Berrangé
The jansson and json-glib libraries both export symbols with a json_
name prefix and json_object_iter_next() clashes between them.
Unfortunately json_glib is linked in by GTK, so any app using GTK and
libvirt will get a clash, resulting in SEGV. This also affects the NSS
module provided by libvirt
Instead of directly linking to jansson, use dlopen() with the RTLD_LOCAL
flag which allows us to hide the symbols from the application that loads
libvirt or the NSS module.
Some preprocessor black magic and wrapper functions are used to redirect
calls into the dlopen resolved symbols.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
libvirt.spec.in | 2 +
src/Makefile.am | 3 +
src/util/Makefile.inc.am | 3 +-
src/util/virjson.c | 9 +-
src/util/virjsoncompat.c | 253 +++++++++++++++++++++++++++++++++++++++
src/util/virjsoncompat.h | 86 +++++++++++++
6 files changed, 354 insertions(+), 2 deletions(-)
create mode 100644 src/util/virjsoncompat.c
create mode 100644 src/util/virjsoncompat.h
diff --git a/libvirt.spec.in b/libvirt.spec.in
index 4113579e47..cfe7ab8a09 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -898,6 +898,8 @@ Requires: ncurses
Requires: gettext
# Needed by virt-pki-validate script.
Requires: gnutls-utils
+# We dlopen() it so need an explicit dep
+Requires: libjansson.so.4()(64bit)
%if %{with_bash_completion}
Requires: %{name}-bash-completion = %{version}-%{release}
%endif
diff --git a/src/Makefile.am b/src/Makefile.am
index 83263e69e5..59ae7a2e79 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -690,6 +690,7 @@ libvirt_setuid_rpc_client_la_SOURCES = \
util/virhashcode.c \
util/virhostcpu.c \
util/virjson.c \
+ util/virjsoncompat.c \
util/virlog.c \
util/virobject.c \
util/virpidfile.c \
@@ -961,6 +962,8 @@ libvirt_nss_la_SOURCES = \
util/virhashcode.h \
util/virjson.c \
util/virjson.h \
+ util/virjsoncompat.c \
+ util/virjsoncompat.h \
util/virkmod.c \
util/virkmod.h \
util/virlease.c \
diff --git a/src/util/Makefile.inc.am b/src/util/Makefile.inc.am
index 71b2b93c2d..8ef9ee1dfa 100644
--- a/src/util/Makefile.inc.am
+++ b/src/util/Makefile.inc.am
@@ -86,6 +86,8 @@ UTIL_SOURCES = \
util/viriscsi.h \
util/virjson.c \
util/virjson.h \
+ util/virjsoncompat.c \
+ util/virjsoncompat.h \
util/virkeycode.c \
util/virkeycode.h \
util/virkeyfile.c \
@@ -264,7 +266,6 @@ libvirt_util_la_CFLAGS = \
$(NULL)
libvirt_util_la_LIBADD = \
$(CAPNG_LIBS) \
- $(JANSSON_LIBS) \
$(LIBNL_LIBS) \
$(THREAD_LIBS) \
$(AUDIT_LIBS) \
diff --git a/src/util/virjson.c b/src/util/virjson.c
index 01a387b2f7..5bab662cd3 100644
--- a/src/util/virjson.c
+++ b/src/util/virjson.c
@@ -1437,7 +1437,8 @@ virJSONValueCopy(const virJSONValue *in)
#if WITH_JANSSON
-# include <jansson.h>
+
+# include "virjsoncompat.h"
static virJSONValuePtr
virJSONValueFromJansson(json_t *json)
@@ -1524,6 +1525,9 @@ virJSONValueFromString(const char *jsonstring)
size_t flags = JSON_REJECT_DUPLICATES |
JSON_DECODE_ANY;
+ if (virJSONInitialize() < 0)
+ return NULL;
+
if (!(json = json_loads(jsonstring, flags, &error))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("failed to parse JSON %d:%d: %s"),
@@ -1630,6 +1634,9 @@ virJSONValueToString(virJSONValuePtr object,
json_t *json;
char *str = NULL;
+ if (virJSONInitialize() < 0)
+ return NULL;
+
if (pretty)
flags |= JSON_INDENT(2);
else
diff --git a/src/util/virjsoncompat.c b/src/util/virjsoncompat.c
new file mode 100644
index 0000000000..c317e50c32
--- /dev/null
+++ b/src/util/virjsoncompat.c
@@ -0,0 +1,253 @@
+/*
+ * virjsoncompat.c: JSON object parsing/formatting
+ *
+ * Copyright (C) 2018 Red Hat, Inc.
+ *
+ * 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 "virthread.h"
+#include "virerror.h"
+#define VIR_JSON_COMPAT_IMPL
+#include "virjsoncompat.h"
+
+#define VIR_FROM_THIS VIR_FROM_NONE
+
+#if WITH_JANSSON
+
+#include <dlfcn.h>
+
+json_t *(*json_array_ptr)(void);
+int (*json_array_append_new_ptr)(json_t *array, json_t *value);
+json_t *(*json_array_get_ptr)(const json_t *array, size_t index);
+size_t (*json_array_size_ptr)(const json_t *array);
+void (*json_delete_ptr)(json_t *json);
+char *(*json_dumps_ptr)(const json_t *json, size_t flags);
+json_t *(*json_false_ptr)(void);
+json_t *(*json_integer_ptr)(json_int_t value);
+json_int_t (*json_integer_value_ptr)(const json_t *integer);
+json_t *(*json_loads_ptr)(const char *input, size_t flags, json_error_t *error);
+json_t *(*json_null_ptr)(void);
+json_t *(*json_object_ptr)(void);
+void *(*json_object_iter_ptr)(json_t *object);
+const char *(*json_object_iter_key_ptr)(void *iter);
+void *(*json_object_iter_next_ptr)(json_t *object, void *iter);
+json_t *(*json_object_iter_value_ptr)(void *iter);
+void *(*json_object_key_to_iter_ptr)(const char *key);
+int (*json_object_set_new_ptr)(json_t *object, const char *key, json_t *value);
+json_t *(*json_real_ptr)(double value);
+double (*json_real_value_ptr)(const json_t *real);
+json_t *(*json_string_ptr)(const char *value);
+const char *(*json_string_value_ptr)(const json_t *string);
+json_t *(*json_true_ptr)(void);
+
+
+static int virJSONJanssonOnceInit(void)
+{
+ void *handle = dlopen("libjansson.so.4", RTLD_LAZY|RTLD_LOCAL|RTLD_DEEPBIND|RTLD_NODELETE);
+ if (!handle) {
+ virReportError(VIR_ERR_NO_SUPPORT,
+ _("libjansson.so.4 JSON library not available: %s"), dlerror());
+ return -1;
+ }
+
+#define LOAD(name) \
+ do { \
+ if (!(name ## _ptr = dlsym(handle, #name))) { \
+ virReportError(VIR_ERR_NO_SUPPORT, \
+ _("missing symbol '%s' in libjansson.so.4: %s"), #name, dlerror()); \
+ goto error; \
+ } \
+ fprintf(stderr, "Resolve %s to %p\n", #name, name ## _ptr); \
+ } while (0)
+
+ LOAD(json_array);
+ LOAD(json_array_append_new);
+ LOAD(json_array_get);
+ LOAD(json_array_size);
+ LOAD(json_delete);
+ LOAD(json_dumps);
+ LOAD(json_false);
+ LOAD(json_integer);
+ LOAD(json_integer_value);
+ LOAD(json_loads);
+ LOAD(json_null);
+ LOAD(json_object);
+ LOAD(json_object_iter);
+ LOAD(json_object_iter_key);
+ LOAD(json_object_iter_next);
+ LOAD(json_object_iter_value);
+ LOAD(json_object_key_to_iter);
+ LOAD(json_object_set_new);
+ LOAD(json_real);
+ LOAD(json_real_value);
+ LOAD(json_string);
+ LOAD(json_string_value);
+ LOAD(json_true);
+
+ return 0;
+
+ error:
+ return -1;
+}
+
+VIR_ONCE_GLOBAL_INIT(virJSONJansson);
+
+int virJSONInitialize(void) {
+ return virJSONJanssonInitialize();
+}
+
+json_t *json_array_impl(void)
+{
+ return json_array_ptr();
+}
+
+
+int json_array_append_new_impl(json_t *array, json_t *value)
+{
+ return json_array_append_new_ptr(array, value);
+}
+
+
+json_t *json_array_get_impl(const json_t *array, size_t index)
+{
+ return json_array_get_ptr(array, index);
+}
+
+
+size_t json_array_size_impl(const json_t *array)
+{
+ return json_array_size_ptr(array);
+}
+
+
+void json_delete_impl(json_t *json)
+{
+ return json_delete_ptr(json);
+}
+
+
+char *json_dumps_impl(const json_t *json, size_t flags)
+{
+ return json_dumps_ptr(json, flags);
+}
+
+
+json_t *json_false_impl(void)
+{
+ return json_false_ptr();
+}
+
+
+json_t *json_integer_impl(json_int_t value)
+{
+ return json_integer_ptr(value);
+}
+
+
+json_int_t json_integer_value_impl(const json_t *integer)
+{
+ return json_integer_value_ptr(integer);
+}
+
+
+json_t *json_loads_impl(const char *input, size_t flags, json_error_t *error)
+{
+ return json_loads_ptr(input, flags, error);
+}
+
+
+json_t *json_null_impl(void)
+{
+ return json_null_ptr();
+}
+
+
+json_t *json_object_impl(void)
+{
+ return json_object_ptr();
+}
+
+
+void *json_object_iter_impl(json_t *object)
+{
+ return json_object_iter_ptr(object);
+}
+
+
+const char *json_object_iter_key_impl(void *iter)
+{
+ return json_object_iter_key_ptr(iter);
+}
+
+
+void *json_object_iter_next_impl(json_t *object, void *iter)
+{
+ return json_object_iter_next_ptr(object, iter);
+}
+
+
+json_t *json_object_iter_value_impl(void *iter)
+{
+ return json_object_iter_value_ptr(iter);
+}
+
+
+void *json_object_key_to_iter_impl(const char *key)
+{
+ return json_object_key_to_iter_ptr(key);
+}
+
+
+int json_object_set_new_impl(json_t *object, const char *key, json_t *value)
+{
+ return json_object_set_new_ptr(object, key, value);
+}
+
+
+json_t *json_real_impl(double value)
+{
+ return json_real_ptr(value);
+}
+
+
+double json_real_value_impl(const json_t *real)
+{
+ return json_real_value_ptr(real);
+}
+
+
+json_t *json_string_impl(const char *value)
+{
+ return json_string_ptr(value);
+}
+
+
+const char *json_string_value_impl(const json_t *string)
+{
+ return json_string_value_ptr(string);
+}
+
+
+json_t *json_true_impl(void)
+{
+ return json_true_ptr();
+}
+
+#endif
+
diff --git a/src/util/virjsoncompat.h b/src/util/virjsoncompat.h
new file mode 100644
index 0000000000..c3963a5259
--- /dev/null
+++ b/src/util/virjsoncompat.h
@@ -0,0 +1,86 @@
+/*
+ * virjson.h: JSON object parsing/formatting
+ *
+ * Copyright (C) 2018 Red Hat, Inc.
+ *
+ * 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/>.
+ *
+ */
+
+
+#ifndef __VIR_JSON_COMPAT_H_
+# define __VIR_JSON_COMPAT_H_
+
+#ifndef VIR_JSON_COMPAT_IMPL
+
+#define json_array json_array_impl
+#define json_array_append_new json_array_append_new_impl
+#define json_array_get json_array_get_impl
+#define json_array_size json_array_size_impl
+#define json_delete json_delete_impl
+#define json_dumps json_dumps_impl
+#define json_false json_false_impl
+#define json_integer json_integer_impl
+#define json_integer_value json_integer_value_impl
+#define json_loads json_loads_impl
+#define json_null json_null_impl
+#define json_object json_object_impl
+#define json_object_iter json_object_iter_impl
+#define json_object_iter_key json_object_iter_key_impl
+#define json_object_iter_next json_object_iter_next_impl
+#define json_object_iter_value json_object_iter_value_impl
+#define json_object_key_to_iter json_object_key_to_iter_impl
+#define json_object_set_new json_object_set_new_impl
+#define json_real json_real_impl
+#define json_real_value json_real_value_impl
+#define json_string json_string_impl
+#define json_string_value json_string_value_impl
+#define json_true json_true_impl
+
+#include <jansson.h>
+
+#else
+
+#include <jansson.h>
+
+json_t *json_array_impl(void);
+int json_array_append_new_impl(json_t *array, json_t *value);
+json_t *json_array_get_impl(const json_t *array, size_t index);
+size_t json_array_size_impl(const json_t *array);
+void json_delete_impl(json_t *json);
+char *json_dumps_impl(const json_t *json, size_t flags);
+json_t *json_false_impl(void);
+json_t *json_integer_impl(json_int_t value);
+json_int_t json_integer_value_impl(const json_t *integer);
+json_t *json_loads_impl(const char *input, size_t flags, json_error_t *error);
+json_t *json_null_impl(void);
+json_t *json_object_impl(void);
+void *json_object_iter_impl(json_t *object);
+const char *json_object_iter_key_impl(void *iter);
+void *json_object_iter_next_impl(json_t *object, void *iter);
+json_t *json_object_iter_value_impl(void *iter);
+void *json_object_key_to_iter_impl(const char *key);
+int json_object_set_new_impl(json_t *object, const char *key, json_t *value);
+json_t *json_real_impl(double value);
+double json_real_value_impl(const json_t *real);
+json_t *json_string_impl(const char *value);
+const char *json_string_value_impl(const json_t *string);
+json_t *json_true_impl(void);
+
+#endif
+
+int virJSONInitialize(void);
+
+#endif
--
2.17.1
6 years, 4 months
[libvirt] [PATCH v2 RESEND 00/12] PCI passthrough support on s390
by Yi Min Zhao
Abstract
========
The PCI representation in QEMU has recently been extended for S390
allowing configuration of zPCI attributes like uid (user-defined
identifier) and fid (PCI function identifier).
The details can be found here:
https://lists.gnu.org/archive/html/qemu-devel/2016-06/msg07262.html
To support the new zPCI feature of the S390 platform, two new XML
attributes, @uid and @fid, are introduced for device addresses of type
'pci', i.e.:
<hostdev mode='subsystem' type='pci'>
<driver name='vfio'/>
<source>
<address domain='0x0001' bus='0x00' slot='0x00' function='0x0'/>
</source>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'
uid='0x0003' fid='0x00000027'/>
</hostdev>
uid and fid are optional attributes. If they are defined by the user,
unique values within the guest domain must be used. If they are not
specified and the architecture requires them, they are automatically
generated with non-conflicting values.
Current implementation is the most seamless one for the user as it
unites the address specific data of a PCI device on one XML element.
It could accommodate both specifying our special parameters (uid and fid)
and re-using standard statements (domain, bus, slot and function) for
PCI devices. User can still specify bus/slot/function for the virtualized
PCI devices in the XML.
Thus uid/fid act as an extension to the PCI address and are stored in
a new structure 'virZPCIDeviceAddress' which is a member of common PCI
Address structure. Additionally, two hashtables are used for assignment
and reservation of uid/fid.
In support of extending the PCI address, a new PCI address extension flag is
introduced. This extension flag allows is not only dedicated for the S390
platform but also other architectures needing certain extensions to PCI
address space.
Code Base
=========
commit in master:
767f9e1449b1a36111532847f0c62dc758263c42
qemu: validate: Enforce compile time switch type checking for videos
Change Log
==========
v1->v2:
1. Separate test commit and merge testcases into corresponding commits that
introduce the functionalities firstly.
2. Spare some checks for zpci device.
3. Add vsock and controller support.
4. Add uin32 type schema.
5. Rename zpciuid and zpcifid to zpci_uid and zpci_fid.
6. Always return multibus support on S390.
Yi Min Zhao (12):
conf: Add definitions for 'uid' and 'fid' PCI address attributes
qemu: Introduce zPCI capability
conf: Introduce a new PCI address extension flag
qemu: Enable PCI multi bus for S390 guests
qemu: Auto add pci-root for s390/s390x guests
conf: Introduce address caching for PCI extensions
conf: Introduce parser, formatter for uid and fid
conf: Allocate/release 'uid' and 'fid' in PCI address
qemu: Generate and use zPCI device in QEMU command line
qemu: Add hotpluging support for PCI devices on S390 guests
docs: Add 'uid' and 'fid' information
news: Update news for PCI address extension attributes
docs/formatdomain.html.in | 9 +-
docs/news.xml | 11 +
docs/schemas/basictypes.rng | 31 ++
docs/schemas/domaincommon.rng | 1 +
src/conf/device_conf.c | 73 +++++
src/conf/device_conf.h | 1 +
src/conf/domain_addr.c | 346 +++++++++++++++++++++
src/conf/domain_addr.h | 29 ++
src/conf/domain_conf.c | 6 +
src/libvirt_private.syms | 4 +
src/qemu/qemu_capabilities.c | 6 +
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 115 +++++++
src/qemu/qemu_command.h | 4 +
src/qemu/qemu_domain.c | 1 +
src/qemu/qemu_domain_address.c | 181 ++++++++++-
src/qemu/qemu_hotplug.c | 182 ++++++++++-
src/util/virpci.h | 13 +
tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml | 1 +
tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml | 1 +
tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml | 1 +
tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml | 1 +
tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml | 1 +
tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml | 1 +
tests/qemuxml2argvdata/disk-virtio-s390-zpci.args | 27 ++
tests/qemuxml2argvdata/disk-virtio-s390-zpci.xml | 17 +
.../hostdev-vfio-zpci-autogenerate.args | 26 ++
.../hostdev-vfio-zpci-autogenerate.xml | 18 ++
.../hostdev-vfio-zpci-boundaries.args | 30 ++
.../hostdev-vfio-zpci-boundaries.xml | 26 ++
.../hostdev-vfio-zpci-multidomain-many.args | 40 +++
.../hostdev-vfio-zpci-multidomain-many.xml | 67 ++++
tests/qemuxml2argvdata/hostdev-vfio-zpci.args | 26 ++
tests/qemuxml2argvdata/hostdev-vfio-zpci.xml | 19 ++
tests/qemuxml2argvtest.c | 14 +
tests/qemuxml2xmloutdata/disk-virtio-s390-zpci.xml | 29 ++
tests/qemuxml2xmloutdata/hostdev-vfio-zpci.xml | 30 ++
tests/qemuxml2xmltest.c | 3 +
38 files changed, 1377 insertions(+), 15 deletions(-)
create mode 100644 tests/qemuxml2argvdata/disk-virtio-s390-zpci.args
create mode 100644 tests/qemuxml2argvdata/disk-virtio-s390-zpci.xml
create mode 100644 tests/qemuxml2argvdata/hostdev-vfio-zpci-autogenerate.args
create mode 100644 tests/qemuxml2argvdata/hostdev-vfio-zpci-autogenerate.xml
create mode 100644 tests/qemuxml2argvdata/hostdev-vfio-zpci-boundaries.args
create mode 100644 tests/qemuxml2argvdata/hostdev-vfio-zpci-boundaries.xml
create mode 100644 tests/qemuxml2argvdata/hostdev-vfio-zpci-multidomain-many.args
create mode 100644 tests/qemuxml2argvdata/hostdev-vfio-zpci-multidomain-many.xml
create mode 100644 tests/qemuxml2argvdata/hostdev-vfio-zpci.args
create mode 100644 tests/qemuxml2argvdata/hostdev-vfio-zpci.xml
create mode 100644 tests/qemuxml2xmloutdata/disk-virtio-s390-zpci.xml
create mode 100644 tests/qemuxml2xmloutdata/hostdev-vfio-zpci.xml
--
Yi Min
6 years, 4 months