[libvirt] [appdev-guide] [PATCH] fix minor bug in code example
by Ilias Stamatis
---
en-US/Guest_Domains.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/en-US/Guest_Domains.xml b/en-US/Guest_Domains.xml
index c15bbb8..2a4ef7c 100644
--- a/en-US/Guest_Domains.xml
+++ b/en-US/Guest_Domains.xml
@@ -88,7 +88,7 @@ dom = virDomainLookupByID(conn, domainID);
<example>
<title>Fetching a domain object from an name</title>
<programlisting>
-int domainName = "someguest";
+char *domainName = "someguest";
virDomainPtr dom;
dom = virDomainLookupByName(conn, domainName);
--
2.21.0
5 years, 7 months
[libvirt] [appdev-guide] [PATCH v2] Guest Domains: fix code example
by Ilias Stamatis
Signed-off-by: Ilias Stamatis <stamatis.iliass(a)gmail.com>
---
en-US/Guest_Domains.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/en-US/Guest_Domains.xml b/en-US/Guest_Domains.xml
index c15bbb8..2a4ef7c 100644
--- a/en-US/Guest_Domains.xml
+++ b/en-US/Guest_Domains.xml
@@ -88,7 +88,7 @@ dom = virDomainLookupByID(conn, domainID);
<example>
<title>Fetching a domain object from an name</title>
<programlisting>
-int domainName = "someguest";
+char *domainName = "someguest";
virDomainPtr dom;
dom = virDomainLookupByName(conn, domainName);
--
2.21.0
5 years, 7 months
[libvirt] [PATCH for 5.2.0] docs: Add virt-lightning app
by Michal Privoznik
There was this introduction made on the users list:
https://www.redhat.com/archives/libvirt-users/2019-March/msg00046.html
Add the application onto the list of apps known to use libvirt.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
docs/apps.html.in | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/docs/apps.html.in b/docs/apps.html.in
index 209854b6ac..62914b575a 100644
--- a/docs/apps.html.in
+++ b/docs/apps.html.in
@@ -99,6 +99,12 @@
machines. It is a command line tool for developers that makes it very
fast and easy to deploy and re-deploy an environment of vm's.
</dd>
+ <dt><a href="https://github.com/virt-lightning/virt-lightning">virt-lightning</a></dt>
+ <dd>
+ Virt-Lightning uses libvirt, cloud-init and libguestfs to allow anyone
+ to quickly start new VM. Very much like a container CLI interface, but
+ locally.
+ </dd>
</dl>
<h2><a id="configmgmt">Configuration Management</a></h2>
--
2.19.2
5 years, 7 months
[libvirt] [PATCH 0/3] qemuGetDomainHupageMemPath cleanups
by Ján Tomko
Ján Tomko (3):
qemu: rename function for getting the default hugepage size
qemu: do not fill in default pagesize in qemuGetDomainHupageMemPath
qemu: remove qemuGetDomainDefaultHugepath
src/qemu/qemu_command.c | 14 +++++-----
src/qemu/qemu_conf.c | 59 +++++++++--------------------------------
src/qemu/qemu_conf.h | 3 ---
3 files changed, 21 insertions(+), 55 deletions(-)
--
2.19.2
5 years, 7 months
[libvirt] CFP: KVM Forum 2019
by Paolo Bonzini
================================================================
KVM Forum 2019: Call For Participation
October 30-November 1, 2019 - Lyon Convention Center - Lyon, France
(All submissions must be received before June 15, 2019 at 23:59 PST)
=================================================================
KVM Forum is an annual event that presents a rare opportunity
for developers and users to meet, discuss the state of Linux
virtualization technology, and plan for the challenges ahead.
We invite you to lead part of the discussion by submitting a speaking
proposal for KVM Forum 2019.
At this highly technical conference, developers driving innovation
in the KVM virtualization stack (Linux, KVM, QEMU, libvirt) can
meet users who depend on KVM as part of their offerings, or to
power their data centers and clouds.
KVM Forum will include sessions on the state of the KVM
virtualization stack, planning for the future, and many
opportunities for attendees to collaborate. As we celebrate ten years
of KVM development in the Linux kernel, KVM continues to be a
critical part of the FOSS cloud infrastructure.
This year, KVM Forum is joining Open Source Summit in Lyon,
France. Selected talks from KVM Forum will be presented on
Wednesday October 30 to the full audience of the Open Source Summit.
Also, attendees of KVM Forum will have access to all of the talks from
Open Source Summit on Wednesday.
https://events.linuxfoundation.org/events/kvm-forum-2019/program/call-for...
Suggested topics:
* Scaling, latency optimizations, performance tuning, real-time guests
* Hardening and security
* New features
* Testing
KVM and the Linux kernel:
* Nested virtualization
* Resource management (CPU, I/O, memory) and scheduling
* VFIO: IOMMU, SR-IOV, virtual GPU, etc.
* Networking: Open vSwitch, XDP, etc.
* virtio and vhost
* Architecture ports and new processor features
QEMU:
* Management interfaces: QOM and QMP
* New devices, new boards, new architectures
* Graphics, desktop virtualization and virtual GPU
* New storage features
* High availability, live migration and fault tolerance
* Emulation and TCG
* Firmware: ACPI, UEFI, coreboot, U-Boot, etc.
Management and infrastructure
* Managing KVM: Libvirt, OpenStack, oVirt, etc.
* Storage: Ceph, Gluster, SPDK, etc.r
* Network Function Virtualization: DPDK, OPNFV, OVN, etc.
* Provisioning
========================
SUBMITTING YOUR PROPOSAL
========================
Abstracts due: June 15, 2019
Please submit a short abstract (~150 words) describing your presentation
proposal. Slots vary in length up to 45 minutes.
Submit your proposal here:
https://events.linuxfoundation.org/events/kvm-forum-2019/program/call-for...
Please only use the categories "presentation" and "panel discussion"
You will receive a notification whether or not your presentation proposal
was accepted by August 12, 2019.
Speakers will receive a complimentary pass for the event. In case
your submission has multiple presenters, only the primary speaker for a
proposal will receive a complimentary event pass. For panel discussions, all
panelists will receive a complimentary event pass.
TECHNICAL TALKS
A good technical talk should not just report on what has happened over
the last year; it should present a concrete problem and how it impacts
the user and/or developer community. Whenever applicable, focus on
work that needs to be done, difficulties that haven't yet been solved,
and on decisions that other developers should be aware of. Summarizing
recent developments is okay but it should not be more than a small
portion of the overall talk.
END-USER TALKS
One of the big challenges as developers is to know what, where and how
people actually use our software. We will reserve a few slots for end
users talking about their deployment challenges and achievements.
If you are using KVM in production you are encouraged submit a speaking
proposal. Simply mark it as an end-user talk. As an end user, this is a
unique opportunity to get your input to developers.
HANDS-ON / BOF SESSIONS
We will reserve some time for people to get together and discuss
strategic decisions as well as other topics that are best solved within
smaller groups.
These sessions will be announced during the event. If you are interested
in organizing such a session, please add it to the list at
http://www.linux-kvm.org/page/KVM_Forum_2019_BOF
Let people you think who might be interested know about your BOF, and
encourage them to add their names to the wiki page as well. Please add
your ideas to the list before KVM Forum starts.
PANEL DISCUSSIONS
If you are proposing a panel discussion, please make sure that you list
all of your potential panelists in your the abstract. We will request full
biographies if a panel is accepted.
==============
HOTEL / TRAVEL
==============
This year's event will take place at the Lyon Conference Center.
For information on hotels close to the conference, please visit
https://events.linuxfoundation.org/events/kvm-forum-2019/attend/venue-tra....
Information on conference hotel blocks will be available later in
Spring 2019.
=================
DATES TO REMEMBER
=================
Submission deadline: Saturday, June 15 at 23:59 PST
Notification: Monday, August 12
Schedule announced: Friday, August 16
Slides due date: Wednesday, October 23
Event dates: Wednesday, October 30 - Friday, November 1
Thank you for your interest in KVM. We're looking forward to your
submissions and seeing you at the KVM Forum 2019 in October!
-your KVM Forum 2019 Program Committee
Please contact us with any questions or comments at
kvm-forum-2019-pc(a)redhat.com
5 years, 7 months
[libvirt] [PATCH 0/2] Fix permissions checks for virDomainGetTime/Hostname
by Daniel P. Berrangé
These two APIs mistakenly allowed access to read-only users. This was
was reported publically in a bug tracker, so I'm sending these patches
without applying any embargo time.
Daniel P. Berrangé (2):
api: disallow virDomainGetHostname for read-only connections
remote: enforce ACL write permission for getting guest time & hostname
src/libvirt-domain.c | 2 ++
src/remote/remote_protocol.x | 4 ++--
2 files changed, 4 insertions(+), 2 deletions(-)
--
2.20.1
5 years, 7 months
[libvirt] [PATCH] tests: fix mocking of stat() / lstat() functions
by Daniel P. Berrangé
Quite a few of the tests have a need to mock the stat() / lstat()
functions and they are taking somewhat different & inconsistent
approaches none of which are actually fully correct. This is shown
by fact that 'make check' fails on 32-bit hosts. Investigation
revealed that the code was calling into the native C library impl,
not getting intercepted by our mocks.
The POSIX stat() function might resolve to any number of different
symbols in the C library.
The may be an additional stat64() function exposed by the headers
too.
On 64-bit hosts the stat & stat64 functions are identical, always
refering to the 64-bit ABI.
On 32-bit hosts they refer to the 32-bit & 64-bit ABIs respectively.
Libvirt uses _FILE_OFFSET_BITS=64 on 32-bit hosts, which causes the
C library to transparently rewrite stat() calls to be stat64() calls.
Libvirt will never see the 32-bit ABI from the traditional stat()
call. We cannot assume this rewriting is done using a macro. It might
be, but on GLibC it is done with a magic __asm__ statement to apply
the rewrite at link time instead of at preprocessing.
In GLibC there may be two additional functions exposed by the headers,
__xstat() and __xstat64(). When these exist, stat() and stat64() are
transparently rewritten to call __xstat() and __xstat64() respectively.
The former symbols will not actally exist in the library at all, only
the header. The leading "__" indicates the symbols are a private impl
detail of the C library that applications should not care about.
Unfortunately, because we are trying to mock replace the C library,
we need to know about this internal impl detail.
With all this in mind the list of functions we have to mock will depend
on several factors
- If _FILE_OFFSET_BITS is set, then we are on a 32-bit host, and we
only need to mock stat64 and __xstat64. The other stat / __xstat
functions exist, but we'll never call them so they can be ignored
for mocking.
- If _FILE_OFFSET_BITS is not set, then we are on a 64-bit host and
we should mock stat, stat64, __xstat & __xstat64. Either may be
called by app code.
- If __xstat & __xstat64 exist, then stat & stat64 will not exist
as symbols in the library, so the latter should not be mocked.
The same all applies to lstat()
These rules are complex enough that we don't want to duplicate them
across every mock file, so this centralizes all the logic in a helper
file virmockstathelper.c that should be #included when needed. The
code merely need to provide a filename rewriting callback called
virMockStatRedirect(). Optionally VIR_MOCK_STAT_HOOK can be defined
as a macro if further processing is needed inline.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
build-aux/mock-noinline.pl | 3 +
cfg.mk | 4 +-
tests/qemusecuritymock.c | 131 +++++-----------
tests/vircgroupmock.c | 146 +++--------------
tests/virfilewrapper.c | 85 ++--------
tests/virmock.h | 11 --
tests/virmockstathelpers.c | 310 +++++++++++++++++++++++++++++++++++++
tests/virpcimock.c | 93 +----------
tests/virtestmock.c | 140 +----------------
9 files changed, 396 insertions(+), 527 deletions(-)
create mode 100644 tests/virmockstathelpers.c
NB I have tested on Fedora 32-bit and 64-bit but have not yet
tested on other platforms, so they may break. This is to be
investigated before pushing so we don't break other platforms
more than they are already broken wrt mocking :-)
diff --git a/build-aux/mock-noinline.pl b/build-aux/mock-noinline.pl
index c6b40001c5..958e133885 100644
--- a/build-aux/mock-noinline.pl
+++ b/build-aux/mock-noinline.pl
@@ -6,6 +6,9 @@ my %mocked;
# Functions in public header don't get the noinline annotation
# so whitelist them here
$noninlined{"virEventAddTimeout"} = 1;
+# This one confuses the script as its defined in the mock file
+# but is actually just a local helper
+$noninlined{"virMockStatRedirect"} = 1;
foreach my $arg (@ARGV) {
if ($arg =~ /\.h$/) {
diff --git a/cfg.mk b/cfg.mk
index a62d4db13b..2c473121a4 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -1272,10 +1272,10 @@ exclude_file_name_regexp--sc_prohibit_xmlURI = ^src/util/viruri\.c$$
exclude_file_name_regexp--sc_prohibit_return_as_function = \.py$$
exclude_file_name_regexp--sc_require_config_h = \
- ^(examples/|tools/virsh-edit\.c$$)
+ ^(examples/|tools/virsh-edit\.c$$|tests/virmockstathelpers.c)
exclude_file_name_regexp--sc_require_config_h_first = \
- ^(examples/|tools/virsh-edit\.c$$)
+ ^(examples/|tools/virsh-edit\.c$$|tests/virmockstathelpers.c)
exclude_file_name_regexp--sc_trailing_blank = \
/sysinfodata/.*\.data|/virhostcpudata/.*\.cpuinfo|^gnulib/local/.*/.*diff$$
diff --git a/tests/qemusecuritymock.c b/tests/qemusecuritymock.c
index d1b17d8aa4..3fdc165fb1 100644
--- a/tests/qemusecuritymock.c
+++ b/tests/qemusecuritymock.c
@@ -50,10 +50,6 @@
static int (*real_chown)(const char *path, uid_t uid, gid_t gid);
-static int (*real_lstat)(const char *path, struct stat *sb);
-static int (*real___lxstat)(int ver, const char *path, struct stat *sb);
-static int (*real_stat)(const char *path, struct stat *sb);
-static int (*real___xstat)(int ver, const char *path, struct stat *sb);
static int (*real_open)(const char *path, int flags, ...);
static int (*real_close)(int fd);
@@ -106,8 +102,6 @@ init_syms(void)
return;
VIR_MOCK_REAL_INIT(chown);
- VIR_MOCK_REAL_INIT_ALT(lstat, __lxstat);
- VIR_MOCK_REAL_INIT_ALT(stat, __xstat);
VIR_MOCK_REAL_INIT(open);
VIR_MOCK_REAL_INIT(close);
@@ -211,36 +205,35 @@ int virFileRemoveXAttr(const char *path,
}
-static int
-mock_stat(const char *path,
- struct stat *sb)
-{
- uint32_t *val;
-
- virMutexLock(&m);
- init_hash();
-
- memset(sb, 0, sizeof(*sb));
-
- sb->st_mode = S_IFREG | 0666;
- sb->st_size = 123456;
- sb->st_ino = 1;
-
- if (!(val = virHashLookup(chown_paths, path))) {
- /* New path. Set the defaults */
- sb->st_uid = DEFAULT_UID;
- sb->st_gid = DEFAULT_GID;
- } else {
- /* Known path. Set values passed to chown() earlier */
- sb->st_uid = *val % 16;
- sb->st_gid = *val >> 16;
- }
-
- virMutexUnlock(&m);
-
- return 0;
-}
-
+#define VIR_MOCK_STAT_HOOK \
+ do { \
+ if (getenv(ENVVAR)) { \
+ uint32_t *val; \
+\
+ virMutexLock(&m); \
+ init_hash(); \
+\
+ memset(sb, 0, sizeof(*sb)); \
+\
+ sb->st_mode = S_IFREG | 0666; \
+ sb->st_size = 123456; \
+ sb->st_ino = 1; \
+\
+ if (!(val = virHashLookup(chown_paths, path))) { \
+ /* New path. Set the defaults */ \
+ sb->st_uid = DEFAULT_UID; \
+ sb->st_gid = DEFAULT_GID; \
+ } else { \
+ /* Known path. Set values passed to chown() earlier */ \
+ sb->st_uid = *val % 16; \
+ sb->st_gid = *val >> 16; \
+ } \
+\
+ virMutexUnlock(&m); \
+\
+ return 0; \
+ } \
+ } while (0)
static int
mock_chown(const char *path,
@@ -276,68 +269,12 @@ mock_chown(const char *path,
}
-#ifdef HAVE___LXSTAT
-int
-__lxstat(int ver, const char *path, struct stat *sb)
-{
- int ret;
-
- init_syms();
-
- if (getenv(ENVVAR))
- ret = mock_stat(path, sb);
- else
- ret = real___lxstat(ver, path, sb);
-
- return ret;
-}
-#endif /* HAVE___LXSTAT */
-
-int
-lstat(const char *path, struct stat *sb)
-{
- int ret;
-
- init_syms();
-
- if (getenv(ENVVAR))
- ret = mock_stat(path, sb);
- else
- ret = real_lstat(path, sb);
-
- return ret;
-}
-
-#ifdef HAVE___XSTAT
-int
-__xstat(int ver, const char *path, struct stat *sb)
-{
- int ret;
-
- init_syms();
-
- if (getenv(ENVVAR))
- ret = mock_stat(path, sb);
- else
- ret = real___xstat(ver, path, sb);
-
- return ret;
-}
-#endif /* HAVE___XSTAT */
+#include "virmockstathelpers.c"
-int
-stat(const char *path, struct stat *sb)
+static int
+virMockStatRedirect(const char *path ATTRIBUTE_UNUSED, char **newpath ATTRIBUTE_UNUSED)
{
- int ret;
-
- init_syms();
-
- if (getenv(ENVVAR))
- ret = mock_stat(path, sb);
- else
- ret = real_stat(path, sb);
-
- return ret;
+ return 0;
}
@@ -386,6 +323,8 @@ close(int fd)
{
int ret;
+ init_syms();
+
if (fd == 42 && getenv(ENVVAR))
ret = 0;
else
diff --git a/tests/vircgroupmock.c b/tests/vircgroupmock.c
index 9c67a44b0d..11a24035aa 100644
--- a/tests/vircgroupmock.c
+++ b/tests/vircgroupmock.c
@@ -38,10 +38,6 @@
static int (*real_open)(const char *path, int flags, ...);
static FILE *(*real_fopen)(const char *path, const char *mode);
static int (*real_access)(const char *path, int mode);
-static int (*real_stat)(const char *path, struct stat *sb);
-static int (*real___xstat)(int ver, const char *path, struct stat *sb);
-static int (*real_lstat)(const char *path, struct stat *sb);
-static int (*real___lxstat)(int ver, const char *path, struct stat *sb);
static int (*real_mkdir)(const char *path, mode_t mode);
/* Don't make static, since it causes problems with clang
@@ -317,8 +313,6 @@ static void init_syms(void)
VIR_MOCK_REAL_INIT(fopen);
VIR_MOCK_REAL_INIT(access);
- VIR_MOCK_REAL_INIT_ALT(lstat, __lxstat);
- VIR_MOCK_REAL_INIT_ALT(stat, __xstat);
VIR_MOCK_REAL_INIT(mkdir);
VIR_MOCK_REAL_INIT(open);
}
@@ -508,139 +502,41 @@ int access(const char *path, int mode)
return ret;
}
-int __lxstat(int ver, const char *path, struct stat *sb)
-{
- int ret;
-
- init_syms();
-
- if (STRPREFIX(path, SYSFS_CGROUP_PREFIX)) {
- init_sysfs();
- char *newpath;
- if (asprintf(&newpath, "%s%s",
- fakesysfscgroupdir,
- path + strlen(SYSFS_CGROUP_PREFIX)) < 0) {
- errno = ENOMEM;
- return -1;
- }
- ret = real___lxstat(ver, newpath, sb);
- free(newpath);
- } else if (STRPREFIX(path, fakedevicedir0)) {
- sb->st_mode = S_IFBLK;
- sb->st_rdev = makedev(8, 0);
- return 0;
- } else if (STRPREFIX(path, fakedevicedir1)) {
- sb->st_mode = S_IFBLK;
- sb->st_rdev = makedev(9, 0);
- return 0;
- } else {
- ret = real___lxstat(ver, path, sb);
- }
- return ret;
-}
-
-int lstat(const char *path, struct stat *sb)
-{
- int ret;
-
- init_syms();
-
- if (STRPREFIX(path, SYSFS_CGROUP_PREFIX)) {
- init_sysfs();
- char *newpath;
- if (asprintf(&newpath, "%s%s",
- fakesysfscgroupdir,
- path + strlen(SYSFS_CGROUP_PREFIX)) < 0) {
- errno = ENOMEM;
- return -1;
- }
- ret = real_lstat(newpath, sb);
- free(newpath);
- } else if (STRPREFIX(path, fakedevicedir0)) {
- sb->st_mode = S_IFBLK;
- sb->st_rdev = makedev(8, 0);
- return 0;
- } else if (STRPREFIX(path, fakedevicedir1)) {
- sb->st_mode = S_IFBLK;
- sb->st_rdev = makedev(9, 0);
- return 0;
- } else {
- ret = real_lstat(path, sb);
- }
- return ret;
-}
-
-int __xstat(int ver, const char *path, struct stat *sb)
-{
- int ret;
-
- init_syms();
+# define VIR_MOCK_STAT_HOOK \
+ do { \
+ if (STRPREFIX(path, fakedevicedir0)) { \
+ sb->st_mode = S_IFBLK; \
+ sb->st_rdev = makedev(8, 0); \
+ return 0; \
+ } else if (STRPREFIX(path, fakedevicedir1)) { \
+ sb->st_mode = S_IFBLK; \
+ sb->st_rdev = makedev(9, 0); \
+ return 0; \
+ } \
+ } while (0)
- if (STRPREFIX(path, SYSFS_CGROUP_PREFIX)) {
- init_sysfs();
- char *newpath;
- if (asprintf(&newpath, "%s%s",
- fakesysfscgroupdir,
- path + strlen(SYSFS_CGROUP_PREFIX)) < 0) {
- errno = ENOMEM;
- return -1;
- }
- ret = real___xstat(ver, newpath, sb);
- free(newpath);
- } else if (STRPREFIX(path, fakedevicedir0)) {
- sb->st_mode = S_IFBLK;
- sb->st_rdev = makedev(8, 0);
- return 0;
- } else if (STRPREFIX(path, fakedevicedir1)) {
- sb->st_mode = S_IFBLK;
- sb->st_rdev = makedev(9, 0);
- return 0;
- } else {
- ret = real___xstat(ver, path, sb);
- }
- return ret;
-}
+# include "virmockstathelpers.c"
-int stat(const char *path, struct stat *sb)
+static int
+virMockStatRedirect(const char *path, char **newpath)
{
- char *newpath = NULL;
- int ret;
-
- init_syms();
-
if (STREQ(path, SYSFS_CPU_PRESENT)) {
init_sysfs();
- if (asprintf(&newpath, "%s/%s",
+ if (asprintf(newpath, "%s/%s",
fakesysfscgroupdir,
- SYSFS_CPU_PRESENT_MOCKED) < 0) {
- errno = ENOMEM;
+ SYSFS_CPU_PRESENT_MOCKED) < 0)
return -1;
- }
} else if (STRPREFIX(path, SYSFS_CGROUP_PREFIX)) {
init_sysfs();
- if (asprintf(&newpath, "%s%s",
+ if (asprintf(newpath, "%s%s",
fakesysfscgroupdir,
- path + strlen(SYSFS_CGROUP_PREFIX)) < 0) {
- errno = ENOMEM;
- return -1;
- }
- } else if (STRPREFIX(path, fakedevicedir0)) {
- sb->st_mode = S_IFBLK;
- sb->st_rdev = makedev(8, 0);
- return 0;
- } else if (STRPREFIX(path, fakedevicedir1)) {
- sb->st_mode = S_IFBLK;
- sb->st_rdev = makedev(9, 0);
- return 0;
- } else {
- if (!(newpath = strdup(path)))
+ path + strlen(SYSFS_CGROUP_PREFIX)) < 0)
return -1;
}
- ret = real_stat(newpath, sb);
- free(newpath);
- return ret;
+ return 0;
}
+
int mkdir(const char *path, mode_t mode)
{
int ret;
diff --git a/tests/virfilewrapper.c b/tests/virfilewrapper.c
index 88441331ce..067cb30657 100644
--- a/tests/virfilewrapper.c
+++ b/tests/virfilewrapper.c
@@ -39,15 +39,9 @@ static size_t nprefixes;
static const char **prefixes;
/* TODO: callbacks */
-
-
static int (*real_open)(const char *path, int flags, ...);
static FILE *(*real_fopen)(const char *path, const char *mode);
static int (*real_access)(const char *path, int mode);
-static int (*real_stat)(const char *path, struct stat *sb);
-static int (*real___xstat)(int ver, const char *path, struct stat *sb);
-static int (*real_lstat)(const char *path, struct stat *sb);
-static int (*real___lxstat)(int ver, const char *path, struct stat *sb);
static int (*real_mkdir)(const char *path, mode_t mode);
static DIR *(*real_opendir)(const char *path);
@@ -58,8 +52,6 @@ static void init_syms(void)
VIR_MOCK_REAL_INIT(fopen);
VIR_MOCK_REAL_INIT(access);
- VIR_MOCK_REAL_INIT_ALT(lstat, __lxstat);
- VIR_MOCK_REAL_INIT_ALT(stat, __xstat);
VIR_MOCK_REAL_INIT(mkdir);
VIR_MOCK_REAL_INIT(open);
VIR_MOCK_REAL_INIT(opendir);
@@ -115,10 +107,11 @@ virFileWrapperClearPrefixes(void)
VIR_FREE(overrides);
}
-static char *
-virFileWrapperOverridePrefix(const char *path)
+# include "virmockstathelpers.c"
+
+int
+virMockStatRedirect(const char *path, char **newpath)
{
- char *ret = NULL;
size_t i = 0;
for (i = 0; i < noverrides; i++) {
@@ -127,16 +120,13 @@ virFileWrapperOverridePrefix(const char *path)
if (!tmp)
continue;
- if (virAsprintfQuiet(&ret, "%s%s", overrides[i], tmp) < 0)
- return NULL;
+ if (virAsprintfQuiet(newpath, "%s%s", overrides[i], tmp) < 0)
+ return -1;
break;
}
- if (!ret)
- ignore_value(VIR_STRDUP_QUIET(ret, path));
-
- return ret;
+ return 0;
}
@@ -144,8 +134,7 @@ virFileWrapperOverridePrefix(const char *path)
do { \
init_syms(); \
\
- newpath = virFileWrapperOverridePrefix(path); \
- if (!newpath) \
+ if (virMockStatRedirect(path, &newpath) < 0) \
abort(); \
} while (0)
@@ -156,7 +145,7 @@ FILE *fopen(const char *path, const char *mode)
PATH_OVERRIDE(newpath, path);
- return real_fopen(newpath, mode);
+ return real_fopen(newpath ? newpath : path, mode);
}
int access(const char *path, int mode)
@@ -165,56 +154,7 @@ int access(const char *path, int mode)
PATH_OVERRIDE(newpath, path);
- return real_access(newpath, mode);
-}
-
-# ifdef HAVE___LXSTAT
-int __lxstat(int ver, const char *path, struct stat *sb)
-{
- VIR_AUTOFREE(char *) newpath = NULL;
-
- PATH_OVERRIDE(newpath, path);
-
- return real___lxstat(ver, newpath, sb);
-}
-# endif /* HAVE___LXSTAT */
-
-int lstat(const char *path, struct stat *sb)
-{
- VIR_AUTOFREE(char *) newpath = NULL;
-
- PATH_OVERRIDE(newpath, path);
-
- return real_lstat(newpath, sb);
-}
-
-# ifdef HAVE___XSTAT
-int __xstat(int ver, const char *path, struct stat *sb)
-{
- VIR_AUTOFREE(char *) newpath = NULL;
-
- PATH_OVERRIDE(newpath, path);
-
- return real___xstat(ver, newpath, sb);
-}
-# endif /* HAVE___XSTAT */
-
-int stat(const char *path, struct stat *sb)
-{
- VIR_AUTOFREE(char *) newpath = NULL;
-
- PATH_OVERRIDE(newpath, path);
-
- return real_stat(newpath, sb);
-}
-
-int mkdir(const char *path, mode_t mode)
-{
- VIR_AUTOFREE(char *) newpath = NULL;
-
- PATH_OVERRIDE(newpath, path);
-
- return real_mkdir(newpath, mode);
+ return real_access(newpath ? newpath : path, mode);
}
int open(const char *path, int flags, ...)
@@ -234,7 +174,7 @@ int open(const char *path, int flags, ...)
va_end(ap);
}
- return real_open(newpath, flags, mode);
+ return real_open(newpath ? newpath : path, flags, mode);
}
DIR *opendir(const char *path)
@@ -243,6 +183,7 @@ DIR *opendir(const char *path)
PATH_OVERRIDE(newpath, path);
- return real_opendir(newpath);
+ return real_opendir(newpath ? newpath : path);
}
+
#endif
diff --git a/tests/virmock.h b/tests/virmock.h
index 9c7ecf60ce..46631433c7 100644
--- a/tests/virmock.h
+++ b/tests/virmock.h
@@ -290,15 +290,4 @@
} \
} while (0)
-# define VIR_MOCK_REAL_INIT_ALT(name1, name2) \
- do { \
- real_ ## name1 = dlsym(RTLD_NEXT, #name1); \
- real_ ## name2 = dlsym(RTLD_NEXT, #name2); \
- if (!real_##name1 && !real_##name2) { \
- fprintf(stderr, "Cannot find real '%s' or '%s' symbol\n", \
- #name1, #name2); \
- abort(); \
- } \
- } while (0)
-
#endif /* LIBVIRT_VIRMOCK_H */
diff --git a/tests/virmockstathelpers.c b/tests/virmockstathelpers.c
new file mode 100644
index 0000000000..745937113b
--- /dev/null
+++ b/tests/virmockstathelpers.c
@@ -0,0 +1,310 @@
+/*
+ * Copyright (C) 2019 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/>.
+ *
+ * Helpers for dealing with the many variants of stat(). This
+ * C file should be included from any file that wants to mock
+ * stat() correctly.
+ */
+
+#include "virmock.h"
+#include "viralloc.h"
+
+#include <sys/stat.h>
+#include <unistd.h>
+
+/*
+ * The POSIX stat() function might resolve to any number of different
+ * symbols in the C library.
+ *
+ * The may be an additional stat64() function exposed by the headers
+ * too.
+ *
+ * On 64-bit hosts the stat & stat64 functions are identical, always
+ * refering to the 64-bit ABI.
+ *
+ * On 32-bit hosts they refer to the 32-bit & 64-bit ABIs respectively.
+ *
+ * Libvirt uses _FILE_OFFSET_BITS=64 on 32-bit hosts, which causes the
+ * C library to transparently rewrite stat() calls to be stat64() calls.
+ * Libvirt will never see the 32-bit ABI from the traditional stat()
+ * call. We cannot assume this rewriting is done using a macro. It might
+ * be, but on GLibC it is done with a magic __asm__ statement to apply
+ * the rewrite at link time instead of at preprocessing.
+ *
+ * In GLibC there may be two additional functions exposed by the headers,
+ * __xstat() and __xstat64(). When these exist, stat() and stat64() are
+ * transparently rewritten to call __xstat() and __xstat64() respectively.
+ * The former symbols will not actally exist in the library at all, only
+ * the header. The leading "__" indicates the symbols are a private impl
+ * detail of the C library that applications should not care about.
+ * Unfortunately, because we are trying to mock replace the C library,
+ * we need to know about this internal impl detail.
+ *
+ * With all this in mind the list of functions we have to mock will depend
+ * on several factors
+ *
+ * - If _FILE_OFFSET_BITS is set, then we are on a 32-bit host, and we
+ * only need to mock stat64 and __xstat64. The other stat / __xstat
+ * functions exist, but we'll never call them so they can be ignored
+ * for mocking.
+ *
+ * - If _FILE_OFFSET_BITS is not set, then we are on a 64-bit host and
+ * we should mock stat, stat64, __xstat & __xstat64. Either may be
+ * called by app code.
+ *
+ * - If __xstat & __xstat64 exist, then stat & stat64 will not exist
+ * as symbols in the library, so the latter should not be mocked.
+ *
+ * The same all applies to lstat()
+ */
+
+
+
+#if defined(HAVE_STAT) && !defined(HAVE___XSTAT) && !defined(_FILE_OFFSET_BITS)
+# define MOCK_STAT
+#endif
+#if defined(HAVE_STAT64) && !defined(HAVE___XSTAT64)
+# define MOCK_STAT64
+#endif
+#if defined(HAVE___XSTAT) && !defined(_FILE_OFFSET_BITS)
+# define MOCK___XSTAT
+#endif
+#if defined(HAVE___XSTAT64)
+# define MOCK___XSTAT64
+#endif
+#if defined(HAVE_LSTAT) && !defined(HAVE___LXSTAT) && !defined(_FILE_OFFSET_BITS)
+# define MOCK_LSTAT
+#endif
+#if defined(HAVE_LSTAT64) && !defined(HAVE___LXSTAT64)
+# define MOCK_LSTAT64
+#endif
+#if defined(HAVE___LXSTAT) && !defined(_FILE_OFFSET_BITS)
+# define MOCK___LXSTAT
+#endif
+#if defined(HAVE___LXSTAT64)
+# define MOCK___LXSTAT64
+#endif
+
+#ifdef MOCK_STAT
+static int (*real_stat)(const char *path, struct stat *sb);
+#endif
+#ifdef MOCK_STAT64
+static int (*real_stat64)(const char *path, struct stat64 *sb);
+#endif
+#ifdef MOCK___XSTAT
+static int (*real___xstat)(int ver, const char *path, struct stat *sb);
+#endif
+#ifdef MOCK___XSTAT64
+static int (*real___xstat64)(int ver, const char *path, struct stat64 *sb);
+#endif
+#ifdef MOCK_LSTAT
+static int (*real_lstat)(const char *path, struct stat *sb);
+#endif
+#ifdef MOCK_LSTAT64
+static int (*real_lstat64)(const char *path, struct stat64 *sb);
+#endif
+#ifdef MOCK___LXSTAT
+static int (*real___lxstat)(int ver, const char *path, struct stat *sb);
+#endif
+#ifdef MOCK___LXSTAT64
+static int (*real___lxstat64)(int ver, const char *path, struct stat64 *sb);
+#endif
+
+
+static void virMockStatInit(void)
+{
+#ifdef MOCK_STAT
+ VIR_MOCK_REAL_INIT(stat);
+#endif
+#ifdef MOCK_STAT64
+ VIR_MOCK_REAL_INIT(stat64);
+#endif
+#ifdef MOCK___XSTAT
+ VIR_MOCK_REAL_INIT(__xstat);
+#endif
+#ifdef MOCK___XSTAT64
+ VIR_MOCK_REAL_INIT(__xstat64);
+#endif
+#ifdef MOCK_LSTAT
+ VIR_MOCK_REAL_INIT(lstat);
+#endif
+#ifdef MOCK_LSTAT64
+ VIR_MOCK_REAL_INIT(lstat64);
+#endif
+#ifdef MOCK___LXSTAT
+ VIR_MOCK_REAL_INIT(__lxstat);
+#endif
+#ifdef MOCK___LXSTAT64
+ VIR_MOCK_REAL_INIT(__lxstat64);
+#endif
+}
+
+/*
+ * @stat: the path being queried
+ * @newpath: fill with redirected path, or leave NULL to use orig path
+ *
+ * Return 0 on success, -1 on allocation error
+ */
+static int virMockStatRedirect(const char *path, char **newpath);
+
+#define fdebug(msg, ...) do { if (getenv("VIR_STAT_MOCK_DEBUG")) fprintf(stderr, msg, __VA_ARGS__); } while (0)
+
+#ifndef VIR_MOCK_STAT_HOOK
+# define VIR_MOCK_STAT_HOOK do { } while (0)
+#endif
+
+#ifdef MOCK_STAT
+int stat(const char *path, struct stat *sb)
+{
+ VIR_AUTOFREE(char *) newpath = NULL;
+
+ virMockStatInit();
+
+ if (virMockStatRedirect(path, &newpath) < 0)
+ abort();
+ fdebug("stat redirect %s to %s sb=%p\n", path, newpath ? newpath : path, sb);
+
+ VIR_MOCK_STAT_HOOK;
+
+ return real_stat(newpath ? newpath : path, sb);
+}
+#endif
+
+#ifdef MOCK_STAT64
+int stat64(const char *path, struct stat64 *sb)
+{
+ VIR_AUTOFREE(char *) newpath = NULL;
+
+ virMockStatInit();
+
+ if (virMockStatRedirect(path, &newpath) < 0)
+ abort();
+ fdebug("stat64 redirect %s to %s sb=%p\n", path, newpath ? newpath : path, sb);
+
+ VIR_MOCK_STAT_HOOK;
+
+ return real_stat64(newpath ? newpath : path, sb);
+}
+#endif
+
+#ifdef MOCK___XSTAT
+int
+__xstat(int ver, const char *path, struct stat *sb)
+{
+ VIR_AUTOFREE(char *) newpath = NULL;
+
+ virMockStatInit();
+
+ if (virMockStatRedirect(path, &newpath) < 0)
+ abort();
+ fdebug("__xstat redirect %s to %s sb=%p\n", path, newpath ? newpath : path, sb);
+
+ VIR_MOCK_STAT_HOOK;
+
+ return real___xstat(ver, newpath ? newpath : path, sb);
+}
+#endif
+
+#ifdef MOCK___XSTAT64
+int
+__xstat64(int ver, const char *path, struct stat64 *sb)
+{
+ VIR_AUTOFREE(char *) newpath = NULL;
+
+ virMockStatInit();
+
+ if (virMockStatRedirect(path, &newpath) < 0)
+ abort();
+ fdebug("__xstat64 redirect %s to %s sb=%p\n", path, newpath ? newpath : path, sb);
+
+ VIR_MOCK_STAT_HOOK;
+
+ return real___xstat64(ver, newpath ? newpath : path, sb);
+}
+#endif
+
+#ifdef MOCK_LSTAT
+int
+lstat(const char *path, struct stat *sb)
+{
+ VIR_AUTOFREE(char *) newpath = NULL;
+
+ virMockStatInit();
+
+ if (virMockStatRedirect(path, &newpath) < 0)
+ abort();
+ fdebug("lstat redirect %s to %s sb=%p\n", path, newpath ? newpath : path, sb);
+
+ VIR_MOCK_STAT_HOOK;
+
+ return real_lstat(newpath ? newpath : path, sb);
+}
+#endif
+
+#ifdef MOCK_LSTAT64
+int
+lstat64(const char *path, struct stat64 *sb)
+{
+ VIR_AUTOFREE(char *) newpath = NULL;
+
+ virMockStatInit();
+
+ if (virMockStatRedirect(path, &newpath) < 0)
+ abort();
+ fdebug("lstat64 redirect %s to %s sb=%p\n", path, newpath ? newpath : path, sb);
+
+ VIR_MOCK_STAT_HOOK;
+
+ return real_lstat64(newpath ? newpath : path, sb);
+}
+#endif
+
+#ifdef MOCK___LXSTAT
+int
+__lxstat(int ver, const char *path, struct stat *sb)
+{
+ VIR_AUTOFREE(char *) newpath = NULL;
+
+ virMockStatInit();
+
+ if (virMockStatRedirect(path, &newpath) < 0)
+ abort();
+ fdebug("__lxstat redirect %s to %s sb=%p\n", path, newpath ? newpath : path, sb);
+
+ VIR_MOCK_STAT_HOOK;
+
+ return real___lxstat(ver, newpath ? newpath : path, sb);
+}
+#endif
+
+#ifdef MOCK___LXSTAT64
+int
+__lxstat64(int ver, const char *path, struct stat64 *sb)
+{
+ VIR_AUTOFREE(char *) newpath = NULL;
+
+ virMockStatInit();
+
+ if (virMockStatRedirect(path, &newpath) < 0)
+ abort();
+ fdebug("__lxstat64 redirect %s to %s sb=%p\n", path, newpath ? newpath : path, sb);
+
+ VIR_MOCK_STAT_HOOK;
+
+ return real___lxstat64(ver, newpath ? newpath : path, sb);
+}
+#endif
diff --git a/tests/virpcimock.c b/tests/virpcimock.c
index ce8176cbec..7f9cdaa9b8 100644
--- a/tests/virpcimock.c
+++ b/tests/virpcimock.c
@@ -31,10 +31,6 @@
# include "dirname.h"
static int (*real_access)(const char *path, int mode);
-static int (*real_lstat)(const char *path, struct stat *sb);
-static int (*real___lxstat)(int ver, const char *path, struct stat *sb);
-static int (*real_stat)(const char *path, struct stat *sb);
-static int (*real___xstat)(int ver, const char *path, struct stat *sb);
static int (*real_open)(const char *path, int flags, ...);
static int (*real_close)(int fd);
static DIR * (*real_opendir)(const char *name);
@@ -365,15 +361,9 @@ pci_device_new_from_stub(const struct pciDevice *data)
if (virFileMakePath(devpath) < 0)
ABORT("Unable to create: %s", devpath);
- if (real_stat && real_stat(configSrc, &sb) == 0)
+ if (stat(configSrc, &sb) == 0)
configSrcExists = true;
-# ifdef HAVE___XSTAT
- if (!configSrcExists &&
- real___xstat && real___xstat(_STAT_VER, configSrc, &sb) == 0)
- configSrcExists = true;
-# endif
-
/* If there is a config file for the device within virpcitestdata dir,
* symlink it. Otherwise create a dummy config file. */
if (configSrcExists) {
@@ -813,8 +803,6 @@ init_syms(void)
return;
VIR_MOCK_REAL_INIT(access);
- VIR_MOCK_REAL_INIT_ALT(lstat, __lxstat);
- VIR_MOCK_REAL_INIT_ALT(stat, __xstat);
VIR_MOCK_REAL_INIT(open);
VIR_MOCK_REAL_INIT(close);
VIR_MOCK_REAL_INIT(opendir);
@@ -896,85 +884,17 @@ access(const char *path, int mode)
return ret;
}
-# ifdef HAVE___LXSTAT
-int
-__lxstat(int ver, const char *path, struct stat *sb)
-{
- int ret;
-
- init_syms();
-
- if (STRPREFIX(path, SYSFS_PCI_PREFIX)) {
- char *newpath;
- if (getrealpath(&newpath, path) < 0)
- return -1;
- ret = real___lxstat(ver, newpath, sb);
- VIR_FREE(newpath);
- } else {
- ret = real___lxstat(ver, path, sb);
- }
- return ret;
-}
-# endif /* HAVE___LXSTAT */
-
-int
-lstat(const char *path, struct stat *sb)
-{
- int ret;
-
- init_syms();
-
- if (STRPREFIX(path, SYSFS_PCI_PREFIX)) {
- char *newpath;
- if (getrealpath(&newpath, path) < 0)
- return -1;
- ret = real_lstat(newpath, sb);
- VIR_FREE(newpath);
- } else {
- ret = real_lstat(path, sb);
- }
- return ret;
-}
-# ifdef HAVE___XSTAT
-int
-__xstat(int ver, const char *path, struct stat *sb)
+static int
+virMockStatRedirect(const char *path, char **newpath)
{
- int ret;
-
- init_syms();
-
if (STRPREFIX(path, SYSFS_PCI_PREFIX)) {
- char *newpath;
- if (getrealpath(&newpath, path) < 0)
+ if (getrealpath(newpath, path) < 0)
return -1;
- ret = real___xstat(ver, newpath, sb);
- VIR_FREE(newpath);
- } else {
- ret = real___xstat(ver, path, sb);
}
- return ret;
+ return 0;
}
-# endif /* HAVE___XSTAT */
-int
-stat(const char *path, struct stat *sb)
-{
- int ret;
-
- init_syms();
-
- if (STRPREFIX(path, SYSFS_PCI_PREFIX)) {
- char *newpath;
- if (getrealpath(&newpath, path) < 0)
- return -1;
- ret = real_stat(newpath, sb);
- VIR_FREE(newpath);
- } else {
- ret = real_stat(path, sb);
- }
- return ret;
-}
int
open(const char *path, int flags, ...)
@@ -1058,6 +978,9 @@ virFileCanonicalizePath(const char *path)
return ret;
}
+
+# include "virmockstathelpers.c"
+
#else
/* Nothing to override on this platform */
#endif
diff --git a/tests/virtestmock.c b/tests/virtestmock.c
index 3049c90789..bc62312444 100644
--- a/tests/virtestmock.c
+++ b/tests/virtestmock.c
@@ -36,33 +36,9 @@
#include "viralloc.h"
#include "virfile.h"
-/* stat can be a macro as follows:
- *
- * #define stat stat64
- *
- * This wouldn't fly with our mock. Make sure that the macro (and
- * all its friends) are undefined. We don't want anybody mangling
- * our code. */
-#undef stat
-#undef stat64
-#undef __xstat
-#undef __xstat64
-#undef lstat
-#undef lstat64
-#undef __lxstat
-#undef __lxstat64
-
static int (*real_open)(const char *path, int flags, ...);
static FILE *(*real_fopen)(const char *path, const char *mode);
static int (*real_access)(const char *path, int mode);
-static int (*real_stat)(const char *path, struct stat *sb);
-static int (*real_stat64)(const char *path, void *sb);
-static int (*real___xstat)(int ver, const char *path, struct stat *sb);
-static int (*real___xstat64)(int ver, const char *path, void *sb);
-static int (*real_lstat)(const char *path, struct stat *sb);
-static int (*real_lstat64)(const char *path, void *sb);
-static int (*real___lxstat)(int ver, const char *path, struct stat *sb);
-static int (*real___lxstat64)(int ver, const char *path, void *sb);
static int (*real_connect)(int fd, const struct sockaddr *addr, socklen_t addrlen);
static const char *progname;
@@ -78,10 +54,6 @@ static void init_syms(void)
VIR_MOCK_REAL_INIT(open);
VIR_MOCK_REAL_INIT(fopen);
VIR_MOCK_REAL_INIT(access);
- VIR_MOCK_REAL_INIT_ALT(stat, __xstat);
- VIR_MOCK_REAL_INIT_ALT(stat64, __xstat64);
- VIR_MOCK_REAL_INIT_ALT(lstat, __lxstat);
- VIR_MOCK_REAL_INIT_ALT(lstat64, __lxstat64);
VIR_MOCK_REAL_INIT(connect);
}
@@ -217,119 +189,15 @@ int access(const char *path, int mode)
return real_access(path, mode);
}
-/* Okay, the following ifdef rain forest may look messy at a
- * first glance. But here's the thing: during run time linking of
- * a binary, stat() may not be actually needing symbol stat. It
- * might as well not had been stat() in the first place (see the
- * reasoning at the beginning of this file). However, if we would
- * expose stat symbol here, we will poison the well and trick
- * dynamic linker into thinking we are some old binary that still
- * uses the symbol. So whenever code from upper layers calls
- * stat(), the control would get here, but real_stat can actually
- * be a NULL pointer because newer glibc have __xstat instead.
- * Worse, it can have __xstat64 instead __xstat.
- *
- * Anyway, these ifdefs are there to implement the following
- * preference function:
- *
- * stat < stat64 < __xstat < __xstat64
- *
- * It's the same story with lstat.
- * Also, I feel sorry for you that you had to read this.
- */
-#if defined(HAVE_STAT) && !defined(HAVE___XSTAT)
-int stat(const char *path, struct stat *sb)
-{
- init_syms();
- checkPath(path, "stat");
+#define VIR_MOCK_STAT_HOOK CHECK_PATH(path)
- return real_stat(path, sb);
-}
-#endif
+#include "virmockstathelpers.c"
-#if defined(HAVE_STAT64) && !defined(HAVE___XSTAT64)
-int stat64(const char *path, struct stat64 *sb)
+static int virMockStatRedirect(const char *path ATTRIBUTE_UNUSED, char **newpath ATTRIBUTE_UNUSED)
{
- init_syms();
-
- checkPath(path, "stat");
-
- return real_stat64(path, sb);
+ return 0;
}
-#endif
-
-#if defined(HAVE___XSTAT) && !defined(HAVE___XSTAT64)
-int
-__xstat(int ver, const char *path, struct stat *sb)
-{
- init_syms();
-
- checkPath(path, "stat");
-
- return real___xstat(ver, path, sb);
-}
-#endif
-
-#if defined(HAVE___XSTAT64)
-int
-__xstat64(int ver, const char *path, struct stat64 *sb)
-{
- init_syms();
-
- checkPath(path, "stat");
-
- return real___xstat64(ver, path, sb);
-}
-#endif
-
-#if defined(HAVE_LSTAT) && !defined(HAVE___LXSTAT)
-int
-lstat(const char *path, struct stat *sb)
-{
- init_syms();
-
- checkPath(path, "lstat");
-
- return real_lstat(path, sb);
-}
-#endif
-
-#if defined(HAVE_LSTAT64) && !defined(HAVE___LXSTAT64)
-int
-lstat64(const char *path, struct stat64 *sb)
-{
- init_syms();
-
- checkPath(path, "lstat");
-
- return real_lstat64(path, sb);
-}
-#endif
-
-#if defined(HAVE___LXSTAT) && !defined(HAVE___LXSTAT64)
-int
-__lxstat(int ver, const char *path, struct stat *sb)
-{
- init_syms();
-
- checkPath(path, "lstat");
-
- return real___lxstat(ver, path, sb);
-}
-#endif
-
-#if defined(HAVE___LXSTAT64)
-int
-__lxstat64(int ver, const char *path, struct stat64 *sb)
-{
- init_syms();
-
- checkPath(path, "lstat");
-
- return real___lxstat64(ver, path, sb);
-}
-#endif
int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen)
--
2.20.1
5 years, 7 months
[libvirt] [PATCH 0/2] docs: add advanced search capability
by Daniel P. Berrangé
Andrea suggested it would be nice to redirect the search box to a local
search page which then let the user submit a site-restricted search to
google for website vs wiki vs mailing lists.
I took a slightly different approach here, and instead simply popup an
extra set of radio buttons below the main search field. This lets the
user select the site to search straightaway without the intermediate
page.
Daniel P. Berrangé (2):
docs: move javascript logic into a standalone file
docs: add advanced search capabilities
docs/libvirt.css | 40 ++++++++++++++++++++++++++++
docs/main.js | 69 ++++++++++++++++++++++++++++++++++++++++++++++++
docs/mobile.css | 7 +++++
docs/page.xsl | 50 ++++++++++-------------------------
4 files changed, 130 insertions(+), 36 deletions(-)
create mode 100644 docs/main.js
--
2.20.1
5 years, 7 months
[libvirt] [PATCH 0/5] examples: enforce compiler warning flags
by Daniel P. Berrangé
The example programs emitted a number of warnings even without having
the WARN_CFLAGS set. Once they were set a bunch more flaws came to
light. Fix them all and enforce warnings so that the example programs
are higher quality code.
Daniel P. Berrangé (5):
examples: fix 64-bit integer formatting on Windows
examples: avoid goto jump over initialization of variable
domtop: remove unused domain name parameter
dominfo: make example more useful
examples: enable all compiler warnings
examples/Makefile.am | 3 ++-
examples/admin/client_info.c | 7 ++++---
examples/admin/client_limits.c | 2 +-
examples/admin/list_clients.c | 3 ++-
examples/admin/threadpool_params.c | 2 +-
examples/dominfo/info1.c | 25 ++++++++++++++-----------
examples/domtop/domtop.c | 13 ++++++++-----
7 files changed, 32 insertions(+), 23 deletions(-)
--
2.20.1
5 years, 7 months
[libvirt] [PATCH] virErrorPreserveLast conversions
by Syed Humaid
From: Humaid <syedhumaidbinharoon(a)gmail.com>
Converted few instances of virSaveLastError() to virErrorPreserveLast() as per the newer internal APIs for saving and restoring error reports.
Signed-off-by: Syed Humaid <syedhumaidbinharoon(a)gmail.com>
---
src/libvirt-domain.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index be5b1f6740..fba4d98994 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -2894,7 +2894,7 @@ virDomainMigrateVersion2(virDomainPtr domain,
_("domainMigratePrepare2 did not set uri"));
cancelled = 1;
/* Make sure Finish doesn't overwrite the error */
- orig_err = virSaveLastError();
+ virErrorPreserveLast(&orig_err);
goto finish;
}
if (uri_out)
@@ -2909,7 +2909,7 @@ virDomainMigrateVersion2(virDomainPtr domain,
/* Perform failed. Make sure Finish doesn't overwrite the error */
if (ret < 0)
- orig_err = virSaveLastError();
+ virErrorPreserveLast(&orig_err);
/* If Perform returns < 0, then we need to cancel the VM
* startup on the destination
@@ -3100,7 +3100,7 @@ virDomainMigrateVersion3Full(virDomainPtr domain,
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("domainMigratePrepare3 did not set uri"));
cancelled = 1;
- orig_err = virSaveLastError();
+ virErrorPreserveLast(&orig_err);
goto finish;
}
--
2.20.1
5 years, 7 months