[libvirt] [PATCH] virhostuptime: Add linux stub for musl
by Michal Privoznik
When we want to know the boot timestamp of the host, we can call
virHostGetBootTime(). Under the hood, it uses getutxid() which is
defined by POSIX and properly check for in configure. However,
musl took a path where it declares the function but instead of
providing any useful implementation it returns NULL meaning "no
record found". If that's the case, use our second best option -
/proc/uptime and a bit of maths.
https://bugzilla.redhat.com/show_bug.cgi?id=1760885
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/util/virhostuptime.c | 64 ++++++++++++++++++++++++++++++++++++++--
1 file changed, 61 insertions(+), 3 deletions(-)
diff --git a/src/util/virhostuptime.c b/src/util/virhostuptime.c
index 62b781acd5..3189074d3d 100644
--- a/src/util/virhostuptime.c
+++ b/src/util/virhostuptime.c
@@ -25,16 +25,68 @@
#endif
#include "virhostuptime.h"
+#include "viralloc.h"
+#include "virfile.h"
+#include "virlog.h"
+#include "virstring.h"
+#include "virtime.h"
#include "virthread.h"
+#define VIR_FROM_THIS VIR_FROM_NONE
+
+VIR_LOG_INIT("util.virhostuptime");
+
static unsigned long long bootTime;
static int bootTimeErrno;
static virOnceControl virHostGetBootTimeOnce = VIR_ONCE_CONTROL_INITIALIZER;
-#ifdef HAVE_GETUTXID
+#if defined(__linux__)
+# define UPTIME_FILE "/proc/uptime"
+static int
+virHostGetBootTimeProcfs(unsigned long long *btime)
+{
+ unsigned long long now;
+ double up;
+ g_autofree char *buf = NULL;
+ char *tmp;
+
+ if (virTimeMillisNow(&now) < 0)
+ return -errno;
+
+ /* 1KiB limit is more than enough. */
+ if (virFileReadAll(UPTIME_FILE, 1024, &buf) < 0)
+ return -errno;
+
+ /* buf contains two doubles now:
+ * $uptime $idle_time
+ * We're interested only in the first one */
+ if (!(tmp = strchr(buf, ' '))) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("uptime file has unexpected format '%s'"),
+ buf);
+ return -EINVAL;
+ }
+
+ *tmp = '\0';
+
+ if (virStrToDouble(buf, NULL, &up) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unable to parse sched info value '%s'"),
+ buf);
+ return -EINVAL;
+ }
+
+ *btime = now / 1000 - up + 0.5;
+
+ return 0;
+}
+#endif /* defined(__linux__) */
+
+#if defined(HAVE_GETUTXID) || defined(__linux__)
static void
virHostGetBootTimeOnceInit(void)
{
+# ifdef HAVE_GETUTXID
struct utmpx id = {.ut_type = BOOT_TIME};
struct utmpx *res = NULL;
@@ -45,16 +97,22 @@ virHostGetBootTimeOnceInit(void)
}
endutxent();
+# endif /* HAVE_GETUTXID */
+
+ if (bootTimeErrno == ENODATA ||
+ (bootTime == 0 && bootTimeErrno == 0)) {
+ bootTimeErrno = -virHostGetBootTimeProcfs(&bootTime);
+ }
}
-#else /* !HAVE_GETUTXID */
+#else /* !defined(HAVE_GETUTXID) && !defined(__linux__) */
static void
virHostGetBootTimeOnceInit(void)
{
bootTimeErrno = ENOSYS;
}
-#endif /* HAVE_GETUTXID */
+#endif /* !defined(HAVE_GETUTXID) && !defined(__linux__) */
/**
* virHostGetBootTime:
--
2.21.0
5 years, 5 months
[libvirt] [PATCH v2 0/2] qemu: fix type of default video device
by Pavel Mores
This new version mostly integrates Cole's comments about the first version.
Pavel Mores (2):
qemu: fix type of default video device
qemu: add tests of the default video type selection algorithm
src/qemu/qemu_domain.c | 39 +++++++++++------
.../default-video-type-aarch64.xml | 16 +++++++
.../default-video-type-ppc64.xml | 16 +++++++
.../default-video-type-riscv64.xml | 16 +++++++
.../default-video-type-s390x.xml | 16 +++++++
.../default-video-type-x86_64-caps-test-0.xml | 17 ++++++++
.../default-video-type-x86_64-caps-test-1.xml | 17 ++++++++
tests/qemuxml2argvtest.c | 1 +
...ault-video-type-aarch64.aarch64-latest.xml | 42 +++++++++++++++++++
.../default-video-type-ppc64.ppc64-latest.xml | 31 ++++++++++++++
...ault-video-type-riscv64.riscv64-latest.xml | 39 +++++++++++++++++
.../default-video-type-s390x.s390x-latest.xml | 32 ++++++++++++++
.../default-video-type-x86_64-caps-test-0.xml | 31 ++++++++++++++
.../default-video-type-x86_64-caps-test-1.xml | 31 ++++++++++++++
tests/qemuxml2xmltest.c | 10 ++++-
15 files changed, 341 insertions(+), 13 deletions(-)
create mode 100644 tests/qemuxml2argvdata/default-video-type-aarch64.xml
create mode 100644 tests/qemuxml2argvdata/default-video-type-ppc64.xml
create mode 100644 tests/qemuxml2argvdata/default-video-type-riscv64.xml
create mode 100644 tests/qemuxml2argvdata/default-video-type-s390x.xml
create mode 100644 tests/qemuxml2argvdata/default-video-type-x86_64-caps-test-0.xml
create mode 100644 tests/qemuxml2argvdata/default-video-type-x86_64-caps-test-1.xml
create mode 100644 tests/qemuxml2xmloutdata/default-video-type-aarch64.aarch64-latest.xml
create mode 100644 tests/qemuxml2xmloutdata/default-video-type-ppc64.ppc64-latest.xml
create mode 100644 tests/qemuxml2xmloutdata/default-video-type-riscv64.riscv64-latest.xml
create mode 100644 tests/qemuxml2xmloutdata/default-video-type-s390x.s390x-latest.xml
create mode 100644 tests/qemuxml2xmloutdata/default-video-type-x86_64-caps-test-0.xml
create mode 100644 tests/qemuxml2xmloutdata/default-video-type-x86_64-caps-test-1.xml
--
2.21.0
5 years, 5 months
[libvirt] [PATCH 0/2] Eliminate two more gnulib modules (glib chronicles)
by Ján Tomko
Remove the need to use:
byteswap
vsnprintf
by using the GLib counterparts
Ján Tomko (2):
util: use g_vsnprintf
qemu: use GUINT32_SWAP_LE_BE
src/qemu/qemu_driver.c | 10 +++++-----
src/util/virerror.c | 4 ++--
src/util/virtypedparam.c | 2 +-
3 files changed, 8 insertions(+), 8 deletions(-)
--
2.21.0
5 years, 5 months
[libvirt] [PATCH 0/2] replace snprintf by g_snprintf (kill-a-gnulib-module-a-day initiative)
by Pavel Hrdina
Pavel Hrdina (2):
replace use of gnulib snprintf by g_snprintf
bootstrap.conf: remove usage of snprintf gnulib module
bootstrap.conf | 1 -
src/hyperv/hyperv_driver.c | 4 +-
src/libxl/libxl_conf.c | 22 +++++------
src/libxl/libxl_migration.c | 4 +-
src/lxc/lxc_process.c | 6 +--
src/nwfilter/nwfilter_ebiptables_driver.c | 36 +++++++++---------
src/nwfilter/nwfilter_learnipaddr.c | 2 +-
src/openvz/openvz_driver.c | 6 +--
src/qemu/qemu_agent.c | 46 +++++++++++------------
src/qemu/qemu_driver.c | 8 ++--
src/security/security_dac.c | 8 ++--
src/security/virt-aa-helper.c | 2 +-
src/storage/storage_util.c | 2 +-
src/util/virhostcpu.c | 2 +-
src/util/viriptables.c | 6 +--
src/util/virmacaddr.c | 8 ++--
src/util/virnetdevbridge.c | 4 +-
src/util/virnetdevmacvlan.c | 12 +++---
src/util/virpci.c | 4 +-
src/util/virpidfile.c | 4 +-
src/util/virtime.c | 10 ++---
src/util/virusb.c | 8 ++--
src/util/viruuid.c | 12 +++---
src/vbox/vbox_common.c | 24 ++++++------
src/vbox/vbox_tmpl.c | 2 +-
src/vmx/vmx.c | 18 ++++-----
src/vz/vz_driver.c | 22 +++++------
src/vz/vz_sdk.c | 8 ++--
tests/libxlmock.c | 2 +-
tests/qemuagenttest.c | 12 +++---
tests/testutils.c | 2 +-
tests/virnetsockettest.c | 2 +-
tests/virpcimock.c | 28 +++++++-------
tests/virsystemdtest.c | 4 +-
tools/virsh-domain-monitor.c | 2 +-
tools/virsh-domain.c | 2 +-
tools/virt-host-validate-common.c | 2 +-
tools/virt-login-shell.c | 4 +-
tools/vsh-table.c | 6 +--
tools/vsh.c | 22 +++++------
tools/wireshark/src/packet-libvirt.c | 2 +-
41 files changed, 190 insertions(+), 191 deletions(-)
--
2.23.0
5 years, 5 months
[libvirt] [PATCH 0/6] docs: some refactoring and new docs about RPM deployment
by Daniel P. Berrangé
This refactors existing docs related to the remote driver/daemon and
URIs. It then also adds a kbase page about RPM package options.
This introduces the use of RST for docs as a replacement for HTML.
The intent is that all new docs should use RST from this point.
Existing HTML docs are candidates for conversion to RST by anyone
interested.
Daniel P. Berrangé (6):
docs: split TLS certificate setup into its own file
docs: move docs about remote driver URIs into URI docs
build: introduce rst2html as a mandatory build tool
docs: adapt filling of <head> section for rst2html output
docs: add a kbase page about RPM packaging options
docs: add page describing the libvirt daemons
.gitignore | 1 +
docs/Makefile.am | 21 +-
docs/daemons.rst | 209 +++++++++++
docs/docs.html.in | 6 +
docs/kbase.html.in | 4 +
docs/kbase/rpm-deployment.rst | 410 ++++++++++++++++++++
docs/page.xsl | 4 +-
docs/remote.html.in | 684 +---------------------------------
docs/tlscerts.html.in | 413 ++++++++++++++++++++
docs/uri.html.in | 263 +++++++++++--
libvirt.spec.in | 2 +
m4/virt-external-programs.m4 | 5 +
mingw-libvirt.spec.in | 1 +
13 files changed, 1309 insertions(+), 714 deletions(-)
create mode 100644 docs/daemons.rst
create mode 100644 docs/kbase/rpm-deployment.rst
create mode 100644 docs/tlscerts.html.in
--
2.23.0
5 years, 5 months
[libvirt] [PATCH 0/9] Remove remaining usage of VIR_STR(N)DUP (glib chronicles)
by Ján Tomko
Almost.
Patch 8/9 depends on Jirka removing VIR_STRNDUP in
[PATCH v3 04/52] conf: Drop nameLen parameter from virDomainCapsCPUModelsAdd
https://www.redhat.com/archives/libvir-list/2019-November/msg00068.html
Ján Tomko (9):
Remove VIR_STRDUP usage that snuck in
Remove VIR_STRNDUP usage that passes -1
Remove VIR_STRNDUP usage that subtracts from a non-NULL pointer
Remove VIR_STRNDUP usage with checked pointers
Remove VIR_STRNDUP usage with subtraction
Remove the rest of VIR_STRNDUP
tests: delete tests for VIR_STR(N)DUP
util: remove VIR_STRDUP and VIR_STRNDUP
docs: hacking: document removal of VIR_STR(N)DUP
docs/hacking.html.in | 10 +-
src/bhyve/bhyve_parse_command.c | 44 +++--
src/conf/nwfilter_conf.c | 4 +-
src/conf/nwfilter_params.c | 6 +-
src/interface/interface_backend_udev.c | 8 +-
src/libvirt_private.syms | 2 -
src/libxl/xen_common.c | 44 +++--
src/libxl/xen_xl.c | 6 +-
src/libxl/xen_xm.c | 9 +-
src/lxc/lxc_driver.c | 3 +-
src/qemu/qemu_domain.c | 9 +-
src/qemu/qemu_driver.c | 3 +-
src/qemu/qemu_monitor_json.c | 11 +-
src/remote/remote_driver.c | 6 +-
src/rpc/virnetlibsshsession.c | 7 +-
src/storage/storage_backend_logical.c | 7 +-
src/util/vircgroupv1.c | 5 +-
src/util/vircommand.c | 5 +-
src/util/virconf.c | 24 +--
src/util/viriscsi.c | 3 +-
src/util/virjson.c | 11 +-
src/util/virkeyfile.c | 9 +-
src/util/virsocketaddr.c | 5 +-
src/util/virstoragefile.c | 6 +-
src/util/virstring.c | 56 +-----
src/util/virstring.h | 69 -------
src/util/virsysinfo.c | 244 ++++++++++++-------------
src/vmware/vmware_conf.c | 6 +-
tests/virstringtest.c | 136 --------------
tools/vsh.c | 5 +-
30 files changed, 218 insertions(+), 545 deletions(-)
--
2.21.0
5 years, 5 months
[libvirt] [rust PATCH] api_tests.py: Fix all issues reported by flake8
by Andrea Bolognani
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
tools/api_tests.py | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/tools/api_tests.py b/tools/api_tests.py
index 9e66c92..7f0e3cb 100644
--- a/tools/api_tests.py
+++ b/tools/api_tests.py
@@ -6,36 +6,39 @@ import xml.etree.ElementTree
import sys
-LIBVIRT_API_FILE="/usr/share/libvirt/api/libvirt-api.xml"
+LIBVIRT_API_FILE = "/usr/share/libvirt/api/libvirt-api.xml"
MY_PATH = os.path.dirname(os.path.realpath(__file__))
SRC_PATH = MY_PATH + "/../src"
+
def get_api_symbols(doc):
funcs = doc.iter('function')
macros = doc.iter('macro')
enums = doc.iter('enum')
return funcs, macros, enums
+
def get_sources():
return glob.glob(SRC_PATH + "/*.rs")
+
def match(el, content):
return content.find(el) >= 0
+
def main():
filter_by = ""
if len(sys.argv) > 1:
filter_by = sys.argv[1]
-
+
doc = xml.etree.ElementTree.parse(LIBVIRT_API_FILE).getroot()
implemented = set([])
missing = set([])
for el in doc.iter('function'):
-
- if el.get('name').startswith(filter_by): # What i'm looking for?
-
+ if el.get('name').startswith(filter_by): # What I'm looking for
+
status = False
for source in get_sources():
f = open(source)
@@ -51,13 +54,10 @@ def main():
print("missing:")
for x in missing:
print(x.attrib)
- #print "implemented:"
- #for x in implemented:
- # print x.attrib
-
+ # print "implemented:"
+ # for x in implemented:
+ # print x.attrib
+
if __name__ == '__main__':
main()
-
-
-
--
2.23.0
5 years, 5 months
[libvirt] [rust PATCH] gitpublish: Fix subject prefix
by Andrea Bolognani
All libvirt-related projects, including language bindings,
follow a certain convention for subject prefix, and there's no
reason libvirt-rust should be any different.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
.gitpublish | 2 +-
README.md | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/.gitpublish b/.gitpublish
index b42ee56..35191be 100644
--- a/.gitpublish
+++ b/.gitpublish
@@ -2,4 +2,4 @@
base = master
to = libvir-list(a)redhat.com
cc = sahid.ferdjaoui(a)canonical.com
-prefix = PATCH Rust
+prefix = rust PATCH
diff --git a/README.md b/README.md
index 93cd461..76acef5 100644
--- a/README.md
+++ b/README.md
@@ -78,14 +78,14 @@ send a single patch
```
git send-email --to libvir-list(a)redhat.com --cc sahid.ferdjaoui(a)canonical.com \
- --subject-prefix "PATCH Rust" --smtp-server=$HOSTNAME -1
+ --subject-prefix "rust PATCH" --smtp-server=$HOSTNAME -1
```
Or to send all patches on the current branch, against master
```
git send-email --to libvir-list(a)redhat.com --cc sahid.ferdjaoui(a)canonical.com \
- --subject-prefix "PATCH Rust" --smtp-server=$HOSTNAME --no-chain-reply-to \
+ --subject-prefix "rust PATCH" --smtp-server=$HOSTNAME --no-chain-reply-to \
--cover-letter --annotate master..
```
--
2.23.0
5 years, 5 months
[libvirt] [PATCH Rust v2] api_tests.py: update to use Python 3
by Zixing Liu
Signed-off-by: Zixing Liu <liushuyu(a)aosc.io>
---
tools/api_tests.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/api_tests.py b/tools/api_tests.py
index b26ec34..9e66c92 100644
--- a/tools/api_tests.py
+++ b/tools/api_tests.py
@@ -47,10 +47,10 @@ def main():
else:
missing.add(el)
- print "missing: %s, implemented: %s" % (len(missing), len(implemented))
- print "missing:"
+ print("missing: %s, implemented: %s" % (len(missing), len(implemented)))
+ print("missing:")
for x in missing:
- print x.attrib
+ print(x.attrib)
#print "implemented:"
#for x in implemented:
# print x.attrib
--
2.24.0
5 years, 5 months