RFC: do we want/need the "Ptr" typedefs for internal code ?
by Daniel P. Berrangé
One of the conventions we have had since the early days of libvirt is
that every struct typedef, has a corresponding "Ptr" typedef too.
For example
typedef struct _virDomainDef virDomainDef;
typedef virDomainDef *virDomainDefPtr;
Periodically someone has questioned what the purpose of these Ptr
typedefs is, and we've not had an compelling answer, other than
that's what we've always done.
There are a few things that make me question the status quo
- If we want a const pointer, we can't use
const virDomainDefPtr def
because that expands to "struct _virDomainDef * const", which
is not what we need semantically. Instead we must write
const virDomainDef *def
It is not at all obvious why these two are different, but
none the less they are, which is confusing to contributors
To me this a compelling reason to consider the "Ptr" typedefs
a waste of time, if not actively harmful.
Please don't suggest adding virDomainDefConstPtr too !
- Writing 'virDomainDefPtr' is actually two characters more
typing than 'virDomainDef *'.
IOW these "Ptr" typedefs aren't saving us time when writing
code.
- This convention of having "Ptr" typedefs is atypical among
C projects I've worked on.
Anything that is peculiar to libvirt is another item that
new contributors need to learn, so has a cost to the
project that must be weighed against its benefit.
We can't do anything about the use "Ptr" in the include/ files because
that is public ABI. We can potentially eliminate "Ptr" types everywhere
else in the codebase, even the src/libvirt*.c files corresponding to
the public includes.
Does anyone have suggestions for how these "Ptr" typedefs are
benefiting libvirt ? Would anyone miss them ?
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
4 years, 1 month
[PATCH 0/2] fix crash on invalid construction of a gvariant
by Peter Krempa
Peter Krempa (2):
virSystemdCreateMachine: Use proper format string for uint64_t when
constructing gvariant
virsystemdtest: Call at least one virSystemdCreateMachine with
'maxthreads' > 0
src/util/virsystemd.c | 5 +++--
tests/virsystemdtest.c | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)
--
2.29.2
4 years, 1 month
Libvirt has been accepted into GSoC 2021
by Michal Privoznik
Dear list,
let me share great news: just like in the past years, libvirt is going
to be part of Google Summer of Code also this year [1]. We can expect
interested students to show up and discuss possible projects to work on.
However, there are some changes made to this year's run [2]:
1) Smaller projects - with everything going on one can hardly expect
students to commit to 350 hours of coding over three months. This is now
reduced to 175 hours over 10 weeks,
2) More elligible students - now even PhD students and licensed coding
school students can apply,
2) Halved stipends - since the amount of work is halved, so are the
stipends,
3) Two evaluations - again, shorted time period requires less evaluations.
Happy hacking,
Michal
1: https://summerofcode.withgoogle.com/organizations/5771368592834560/
2:
https://opensource.googleblog.com/2020/10/google-summer-of-code-2021-is-b...
4 years, 1 month
[PULL 05/17] utils: Deprecate hex-with-suffix sizes
by Eric Blake
Supporting '0x20M' looks odd, particularly since we have a 'B' suffix
that is ambiguous for bytes, as well as a less-frequently-used 'E'
suffix for extremely large exibytes. In practice, people using hex
inputs are specifying values in bytes (and would have written
0x2000000, or possibly relied on default_suffix in the case of
qemu_strtosz_MiB), and the use of scaling suffixes makes the most
sense for inputs in decimal (where the user would write 32M). But
rather than outright dropping support for hex-with-suffix, let's
follow our deprecation policy. Sadly, since qemu_strtosz() does not
have an Err** parameter, and plumbing that in would be a much larger
task, we instead go with just directly emitting the deprecation
warning to stderr.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
Message-Id: <20210211204438.1184395-4-eblake(a)redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
docs/system/deprecated.rst | 8 ++++++++
util/cutils.c | 10 +++++++++-
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
index cfabe6984677..ecff6bf8c633 100644
--- a/docs/system/deprecated.rst
+++ b/docs/system/deprecated.rst
@@ -166,6 +166,14 @@ Using ``-M kernel-irqchip=off`` with x86 machine types that include a local
APIC is deprecated. The ``split`` setting is supported, as is using
``-M kernel-irqchip=off`` with the ISA PC machine type.
+hexadecimal sizes with scaling multipliers (since 6.0)
+''''''''''''''''''''''''''''''''''''''''''''''''''''''
+
+Input parameters that take a size value should only use a size suffix
+(such as 'k' or 'M') when the base is written in decimal, and not when
+the value is hexadecimal. That is, '0x20M' is deprecated, and should
+be written either as '32M' or as '0x2000000'.
+
QEMU Machine Protocol (QMP) commands
------------------------------------
diff --git a/util/cutils.c b/util/cutils.c
index 189a184859c0..d89a40a8c325 100644
--- a/util/cutils.c
+++ b/util/cutils.c
@@ -250,6 +250,9 @@ static int64_t suffix_mul(char suffix, int64_t unit)
* fractional portion is truncated to byte
* - 0x7fEE - hexadecimal, unit determined by @default_suffix
*
+ * The following cause a deprecation warning, and may be removed in the future
+ * - 0xabc{kKmMgGtTpP} - hex with scaling suffix
+ *
* The following are intentionally not supported
* - octal, such as 08
* - fractional hex, such as 0x1.8
@@ -272,7 +275,7 @@ static int do_strtosz(const char *nptr, const char **end,
int retval;
const char *endptr, *f;
unsigned char c;
- bool mul_required = false;
+ bool mul_required = false, hex = false;
uint64_t val;
int64_t mul;
double fraction = 0.0;
@@ -298,6 +301,7 @@ static int do_strtosz(const char *nptr, const char **end,
retval = -EINVAL;
goto out;
}
+ hex = true;
} else if (*endptr == '.') {
/*
* Input looks like a fraction. Make sure even 1.k works
@@ -320,6 +324,10 @@ static int do_strtosz(const char *nptr, const char **end,
c = *endptr;
mul = suffix_mul(c, unit);
if (mul > 0) {
+ if (hex) {
+ warn_report("Using a multiplier suffix on hex numbers "
+ "is deprecated: %s", nptr);
+ }
endptr++;
} else {
mul = suffix_mul(default_suffix, unit);
--
2.30.1
4 years, 1 month
[PATCH v4 0/1] qemu: add per-vcpu delay stats
by Aleksei Zakharov
Fixed since v3:
- Report error if cannot read stats.
- Don't fail if cannot read stats.
- Add documentation.
- Drop unnecessary checks.
- Don't delete unrelated whitespace.
- Make sure schedstat file is closed before returning.
Fixed since v2:
- Close schedstat file after use.
Fixes since v1:
- Collect per-vcpu stats.
- Coding style errors
- Use glib functions.
Aleksei Zakharov (1):
qemu: add per-vcpu delay stats
docs/manpages/virsh.rst | 4 ++++
src/libvirt-domain.c | 4 ++++
src/qemu/qemu_driver.c | 44 +++++++++++++++++++++++++++++++++++++++--
3 files changed, 50 insertions(+), 2 deletions(-)
--
2.17.1
4 years, 1 month
[libvirt PATCH 00/17] qemu: Implement external limit manager feature
by Andrea Bolognani
This feature has been requested by KubeVirt developers and will make
it possible for them to make some VFIO-related features, such as
migration and hotplug, work correctly.
https://bugzilla.redhat.com/show_bug.cgi?id=1916346
The first part of the series, especially the first 9 patches, is
preparation work: it addresses a few annoying issues with our APIs
that deal with process limits, and makes them all nice, consistent
and easy to reason about while moving policy code from the generic
code to the QEMU driver where it belongs.
Andrea Bolognani (17):
util: Document limit-related functions
util: Simplify stubs
util: Always pass a pid to virProcessSetMax*()
util: Introduce virProcess{Get,Set}Limit()
qemu: Make some minor tweaks
qemu: Set all limits at the same time
util: Have virCommand remember whether limits are set
qemu: Set limits only when explicitly asked to do so
util: Don't special-case setting a limit to zero
conf: Rename original_memlock -> originalMemlock
tests: Mock virProcessGetMaxMemLock()
util: Try to get limits from /proc
qemu: Don't ignore virProcessGetMaxMemLock() errors
qemu: Refactor qemuDomainAdjustMaxMemLock()
qemu: Add external_limit_manager config knob
qemu: Wire up external limit manager
news: Document external limit manager feature
NEWS.rst | 10 +
src/conf/domain_conf.h | 5 +-
src/qemu/libvirtd_qemu.aug | 1 +
src/qemu/qemu.conf | 12 +
src/qemu/qemu_command.c | 4 -
src/qemu/qemu_conf.c | 4 +
src/qemu/qemu_conf.h | 1 +
src/qemu/qemu_domain.c | 47 ++--
src/qemu/qemu_migration.c | 2 +
src/qemu/qemu_process.c | 30 ++-
src/qemu/test_libvirtd_qemu.aug.in | 1 +
src/util/vircommand.c | 21 +-
src/util/virprocess.c | 340 ++++++++++++++++++++---------
src/util/virprocess.h | 2 +-
tests/virprocessmock.c | 7 +
15 files changed, 354 insertions(+), 133 deletions(-)
--
2.26.2
4 years, 1 month
[PATCH] domaincapstest: Return EXIT_SUCCESS / EXIT_FAILURE instead of -1
by Peter Krempa
The value is used as return value for the process itself.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
tests/domaincapstest.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c
index 7a082705c6..65d9f4c635 100644
--- a/tests/domaincapstest.c
+++ b/tests/domaincapstest.c
@@ -475,7 +475,7 @@ mymain(void)
DO_TEST_BHYVE("fbuf", "/usr/sbin/bhyve", &bhyve_caps, VIR_DOMAIN_VIRT_BHYVE);
#endif /* WITH_BHYVE */
- return ret;
+ return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
#if WITH_QEMU
--
2.29.2
4 years, 1 month
[PATCH] qemuMigrationSrcRun: Don't jump to 'exit_monitor' from outside of the monitor
by Peter Krempa
Failure of 'qemuMigrationSetDBusVMState' would jump to 'exit_monitor'
but the function isn't called inside of the monitor context.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_migration.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index e44931dcfa..79dcb4a15d 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -4156,7 +4156,7 @@ qemuMigrationSrcRun(virQEMUDriverPtr driver,
}
if (qemuMigrationSetDBusVMState(driver, vm) < 0)
- goto exit_monitor;
+ goto error;
/* Before EnterMonitor, since already qemuProcessStopCPUs does that */
if (!(flags & VIR_MIGRATE_LIVE) &&
--
2.29.2
4 years, 1 month
[PATCH] meson: Add documentation installation directory option
by Chris Mayo
Allow the directory to be chosen at installation time, to support local
conventions e.g. versioning.
Signed-off-by: Chris Mayo <aklhfex(a)gmail.com>
---
meson.build | 6 +++++-
meson_options.txt | 1 +
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/meson.build b/meson.build
index 369548f127..5c7a335947 100644
--- a/meson.build
+++ b/meson.build
@@ -83,8 +83,12 @@ mandir = prefix / get_option('mandir')
sbindir = prefix / get_option('sbindir')
sharedstatedir = prefix / get_option('sharedstatedir')
+docdir = get_option('docdir')
+if docdir == ''
+ docdir = datadir / 'doc' / meson.project_name()
+endif
+
confdir = sysconfdir / meson.project_name()
-docdir = datadir / 'doc' / meson.project_name()
pkgdatadir = datadir / meson.project_name()
diff --git a/meson_options.txt b/meson_options.txt
index e5d79c2b6b..2606648b64 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -7,6 +7,7 @@ option('expensive_tests', type: 'feature', value: 'auto', description: 'set the
option('test_coverage', type: 'boolean', value: false, description: 'turn on code coverage instrumentation')
option('git_werror', type: 'feature', value: 'auto', description: 'use -Werror if building from GIT')
option('rpath', type: 'feature', value: 'auto', description: 'whether to include rpath information in installed binaries and libraries')
+option('docdir', type: 'string', value: '', description: 'documentation installation directory')
option('docs', type: 'feature', value: 'auto', description: 'whether to generate documentation')
option('tests', type: 'feature', value: 'auto', description: 'whether to build tests')
--
2.28.0
4 years, 1 month
[libvirt PATCH] util: Fix error reporting in virnetlink
by Andrea Bolognani
The preprocessor macro we use to check whether we're on Linux
has not been spelled properly, and so we will always report the
error message intended for other platforms.
Fixes: 879bcee08ce0f91f556fddfe452c3fbed5318468
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
src/util/virnetlink.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c
index a06195bd00..cfb86550a5 100644
--- a/src/util/virnetlink.c
+++ b/src/util/virnetlink.c
@@ -1231,7 +1231,7 @@ virNetlinkEventRemoveClient(int watch, const virMacAddr *macaddr,
#else
-# if defined(__linux)
+# if defined(__linux__)
static const char *unsupported = N_("libnl was not available at build time");
# else
static const char *unsupported = N_("not supported on non-linux platforms");
--
2.26.2
4 years, 1 month