[libvirt] [PATCH v2] spec: drop anything older than Fedora 13
by Eric Blake
RHEL 5 is based on libvirt 0.8.2, as was Fedora 13. RHEL 5 also
happens to be the oldest box that we actively support with a
buildbot, so it is time to clean up some crufty conditionals in
the spec file that no longer are necessary for modern Fedora.
Although it is probably okay to make further simplifications to
a newer minimum Fedora version, that can be done as a later patch.
This patch just focuses on cleaning any comparison of %{?fedora}
that will always be true or false once we assume a minimum of F13.
* libvirt.spec.in: Make with_audit default to on. Move other
conditionals to a single RHEL-5 block. Simplify any fedora
comparison older than 13. Document our assumptions.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
v2: rebase to latest libvirt.git
libvirt.spec.in | 69 ++++++++++++++++++++-------------------------------------
1 file changed, 24 insertions(+), 45 deletions(-)
diff --git a/libvirt.spec.in b/libvirt.spec.in
index 3932313..9126277 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -1,5 +1,7 @@
# -*- rpm-spec -*-
+# This spec file assumes you are building for Fedora 13 or newer,
+# or for RHEL 5 or newer. It may need some tweaks for other distros.
# If neither fedora nor rhel was defined, try to guess them from %{dist}
%if !0%{?rhel} && !0%{?fedora}
%{expand:%(echo "%{?dist}" | \
@@ -139,7 +141,6 @@
%define with_libpcap 0%{!?_without_libpcap:0}
%define with_macvtap 0%{!?_without_macvtap:0}
%define with_libnl 0%{!?_without_libnl:0}
-%define with_audit 0%{!?_without_audit:0}
%define with_dtrace 0%{!?_without_dtrace:0}
%define with_cgconfig 0%{!?_without_cgconfig:0}
%define with_sanlock 0%{!?_without_sanlock:0}
@@ -153,6 +154,7 @@
# Non-server/HV driver defaults which are always enabled
%define with_sasl 0%{!?_without_sasl:1}
+%define with_audit 0%{!?_without_audit:1}
# Finally set the OS / architecture specific special cases
@@ -223,31 +225,21 @@
%define with_libxl 0
%endif
-# PolicyKit was introduced in Fedora 8 / RHEL-6 or newer
-%if 0%{?fedora} >= 8 || 0%{?rhel} >= 6
- %define with_polkit 0%{!?_without_polkit:1}
-%endif
-
-# libcapng is used to manage capabilities in Fedora 12 / RHEL-6 or newer
-%if 0%{?fedora} >= 12 || 0%{?rhel} >= 6
- %define with_capng 0%{!?_without_capng:1}
-%endif
-
# fuse is used to provide virtualized /proc for LXC
%if 0%{?fedora} >= 17 || 0%{?rhel} >= 7
%define with_fuse 0%{!?_without_fuse:1}
%endif
-# netcf is used to manage network interfaces in Fedora 12 / RHEL-6 or newer
-%if 0%{?fedora} >= 12 || 0%{?rhel} >= 6
- %define with_netcf 0%{!?_without_netcf:%{server_drivers}}
-%endif
-
-# udev is used to manage host devices in Fedora 12 / RHEL-6 or newer
-%if 0%{?fedora} >= 12 || 0%{?rhel} >= 6
- %define with_udev 0%{!?_without_udev:%{server_drivers}}
-%else
+# RHEL 5 lacks newer tools
+%if 0%{?rhel} == 5
%define with_hal 0%{!?_without_hal:%{server_drivers}}
+%else
+ %define with_polkit 0%{!?_without_polkit:1}
+ %define with_capng 0%{!?_without_capng:1}
+ %define with_netcf 0%{!?_without_netcf:%{server_drivers}}
+ %define with_udev 0%{!?_without_udev:%{server_drivers}}
+ %define with_yajl 0%{!?_without_yajl:%{server_drivers}}
+ %define with_dtrace 1
%endif
# interface requires netcf
@@ -255,11 +247,6 @@
%define with_interface 0
%endif
-# Enable yajl library for JSON mode with QEMU
-%if 0%{?fedora} >= 13 || 0%{?rhel} >= 6
- %define with_yajl 0%{!?_without_yajl:%{server_drivers}}
-%endif
-
# Enable sanlock library for lock management with QEMU
# Sanlock is available only on arches where kvm is available for RHEL
%if 0%{?fedora} >= 16
@@ -320,16 +307,8 @@
%define with_libnl 1
%endif
-%if 0%{?fedora} >= 11 || 0%{?rhel} >= 5
- %define with_audit 0%{!?_without_audit:1}
-%endif
-
-%if 0%{?fedora} >= 13 || 0%{?rhel} >= 6
- %define with_dtrace 1
-%endif
-
# Pull in cgroups config system
-%if 0%{?fedora} >= 12 || 0%{?rhel} >= 6
+%if 0%{?fedora} || 0%{?rhel} >= 6
%if %{with_qemu} || %{with_lxc}
%define with_cgconfig 0%{!?_without_cgconfig:1}
%endif
@@ -349,7 +328,7 @@
# Force QEMU to run as non-root
-%if 0%{?fedora} >= 12 || 0%{?rhel} >= 6
+%if 0%{?fedora} || 0%{?rhel} >= 6
%define qemu_user qemu
%define qemu_group qemu
%else
@@ -473,7 +452,7 @@ BuildRequires: libattr-devel
# For pool-build probing for existing pools
BuildRequires: libblkid-devel >= 2.17
%endif
-%if 0%{?fedora} >= 12 || 0%{?rhel} >= 6
+%if 0%{?fedora} || 0%{?rhel} >= 6
# for augparse, optionally used in testing
BuildRequires: augeas
%endif
@@ -538,7 +517,7 @@ BuildRequires: cyrus-sasl-devel
%if 0%{?fedora} >= 20 || 0%{?rhel} >= 7
BuildRequires: polkit-devel >= 0.112
%else
- %if 0%{?fedora} >= 12 || 0%{?rhel} >= 6
+ %if 0%{?fedora} || 0%{?rhel} >= 6
BuildRequires: polkit-devel >= 0.93
%else
BuildRequires: PolicyKit-devel >= 0.6
@@ -621,7 +600,7 @@ BuildRequires: netcf-devel >= 0.1.4
%endif
%endif
%if %{with_esx}
- %if 0%{?fedora} >= 9 || 0%{?rhel} >= 6
+ %if 0%{?fedora} || 0%{?rhel} >= 6
BuildRequires: libcurl-devel
%else
BuildRequires: curl-devel
@@ -705,7 +684,7 @@ Requires: avahi-libs
%if 0%{?fedora} >= 20 || 0%{?rhel} >= 7
Requires: polkit >= 0.112
%else
- %if 0%{?fedora} >= 12 || 0%{?rhel} >=6
+ %if 0%{?fedora} || 0%{?rhel} >=6
Requires: polkit >= 0.93
%else
Requires: PolicyKit >= 0.6
@@ -865,7 +844,7 @@ Requires: nfs-utils
# For mkfs
Requires: util-linux
# For glusterfs
- %if 0%{?fedora} >= 11
+ %if 0%{?fedora}
Requires: glusterfs-client >= 2.0.1
%endif
%endif
@@ -1579,7 +1558,7 @@ mv $RPM_BUILD_ROOT%{_datadir}/systemtap/tapset/libvirt_qemu_probes.stp \
%endif
%endif
-%if 0%{?fedora} < 14 && 0%{?rhel} < 6
+%if 0%{?rhel} == 5
rm -f $RPM_BUILD_ROOT%{_prefix}/lib/sysctl.d/libvirtd.conf
%endif
@@ -1607,7 +1586,7 @@ fi
%if ! %{with_driver_modules}
%if %{with_qemu}
%pre daemon
- %if 0%{?fedora} >= 12 || 0%{?rhel} >= 6
+ %if 0%{?fedora} || 0%{?rhel} >= 6
# We want soft static allocation of well-known ids, as disk images
# are commonly shared across NFS mounts by id rather than name; see
# https://fedoraproject.org/wiki/Packaging:UsersAndGroups
@@ -1776,7 +1755,7 @@ fi
%if %{with_driver_modules}
%if %{with_qemu}
%pre daemon-driver-qemu
- %if 0%{?fedora} >= 12 || 0%{?rhel} >= 6
+ %if 0%{?fedora} || 0%{?rhel} >= 6
# We want soft static allocation of well-known ids, as disk images
# are commonly shared across NFS mounts by id rather than name; see
# https://fedoraproject.org/wiki/Packaging:UsersAndGroups
@@ -1884,7 +1863,7 @@ exit 0
%config(noreplace) %{_sysconfdir}/sysconfig/virtlockd
%config(noreplace) %{_sysconfdir}/libvirt/libvirtd.conf
%config(noreplace) %{_sysconfdir}/libvirt/virtlockd.conf
- %if 0%{?fedora} >= 14 || 0%{?rhel} >= 6
+ %if 0%{?fedora} || 0%{?rhel} >= 6
%config(noreplace) %{_prefix}/lib/sysctl.d/libvirtd.conf
%endif
@@ -1912,7 +1891,7 @@ exit 0
%endif
%if %{with_polkit}
- %if 0%{?fedora} >= 12 || 0%{?rhel} >= 6
+ %if 0%{?fedora} || 0%{?rhel} >= 6
%{_datadir}/polkit-1/actions/org.libvirt.unix.policy
%{_datadir}/polkit-1/actions/org.libvirt.api.policy
%else
--
1.9.3
10 years, 3 months
[libvirt] [RFC PATCH 0/5] add virDomainBlockCopy API
by Eric Blake
Patch series is not complete yet, but I'm posting the front end
now to get feedback on whether it has a chance of being included
in 1.2.8.
Still to go: patch 6 will actually implement the new function in
qemu driver, by parsing a <disk> XML snippet into a virStorageSource;
patch 7 will add monitor support for the qemu 1.4 parameters of
granularity and buffer size. Individual commit messages should give
more hints on where I'm taking this series. Ultimately, I'm hoping
that Peter's work on gluster backends for block commit can be
expanded into also covering gluster backends for the copy destination.
Eric Blake (5):
blockcopy: virDomainBlockCopy with XML destination, typed params
blockcopy: split out virsh implementation
blockcopy: expose new API in virsh
blockcopy: remote implementation for new API
blockcopy: tweak how rebase calls into copy
include/libvirt/libvirt.h.in | 57 ++++++++++++++--
src/driver.h | 11 +++-
src/libvirt.c | 118 ++++++++++++++++++++++++++++++++-
src/libvirt_public.syms | 5 ++
src/qemu/qemu_driver.c | 104 ++++++++++++++++++-----------
src/remote/remote_driver.c | 1 +
src/remote/remote_protocol.x | 18 ++++-
tools/virsh-domain.c | 153 ++++++++++++++++++++++++++++++++++++-------
tools/virsh.pod | 35 ++++++----
9 files changed, 422 insertions(+), 80 deletions(-)
--
1.9.3
10 years, 3 months
[libvirt] [PATCH] docs: fix bootmenu timeout description
by Martin Kletzander
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
Notes:
Pushed as 'trivial'.
docs/formatdomain.html.in | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 9b8802d..59127bb 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -160,9 +160,8 @@
Since 0.8.3</span>
Additional attribute <code>timeout</code> takes the number of milliseconds
the boot menu should wait until it times out. Allowed values are numbers
- in range [0, 65535] inclusive and it is valid if and only if the previous
- <code>enable</code> is set to "yes".
- <span class="since"> Since 1.2.8</span>
+ in range [0, 65535] inclusive and it is ignored unless <code>enable</code>
+ is set to "yes". <span class="since">Since 1.2.8</span>
</dd>
<dt><code>smbios</code></dt>
<dd>How to populate SMBIOS information visible in the guest.
--
2.0.4
10 years, 3 months
[libvirt] [PATCH 0/3] Add support for boot menu timeout
by Martin Kletzander
This is basically just for qemu's '-boot splash-time' parameter.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1021703
Martin Kletzander (3):
docs, conf: add support for bootmenu timeout
qemu: add capability probing for splash-timeout
qemu: add support for splash-timeout
docs/formatdomain.html.in | 7 +++++-
docs/schemas/domaincommon.rng | 5 ++++
src/conf/domain_conf.c | 21 ++++++++++++++--
src/conf/domain_conf.h | 2 ++
src/qemu/qemu_capabilities.c | 5 ++++
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 15 +++++++++++
tests/qemucapabilitiesdata/caps_1.5.3-1.caps | 1 +
tests/qemucapabilitiesdata/caps_1.6.0-1.caps | 1 +
tests/qemucapabilitiesdata/caps_1.6.50-1.caps | 1 +
tests/qemuhelptest.c | 12 ++++++---
...qemuxml2argv-boot-menu-disable-with-timeout.xml | 29 ++++++++++++++++++++++
...2argv-boot-menu-enable-with-timeout-invalid.xml | 29 ++++++++++++++++++++++
...qemuxml2argv-boot-menu-enable-with-timeout.args | 15 +++++++++++
.../qemuxml2argv-boot-menu-enable-with-timeout.xml | 29 ++++++++++++++++++++++
tests/qemuxml2argvtest.c | 5 ++++
...muxml2xmlout-boot-menu-disable-with-timeout.xml | 29 ++++++++++++++++++++++
tests/qemuxml2xmltest.c | 2 ++
18 files changed, 202 insertions(+), 7 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-boot-menu-disable-with-timeout.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-boot-menu-enable-with-timeout-invalid.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-boot-menu-enable-with-timeout.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-boot-menu-enable-with-timeout.xml
create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-boot-menu-disable-with-timeout.xml
--
2.0.4
10 years, 3 months
[libvirt] [PATCH] daemon: Fix option -v missing info priority log
by Wang Rui
From: Zhou Yimin <zhouyimin(a)huawei.com>
Introduce by 63fbcc692.
When start libvirtd with commandline "/usr/sbin/libvirtd -d -l -v",
we expect verbose(info level) log if neither environment variable
nor config file about logging controls is set. But in fact we can't
get any info priority log in the default output file.
The log priority of default output is VIR_LOG_DEFAULT(VIR_LOG_WARN),
so the info log is filtered out.
To record info priority log we must parse option -v before setting the
default output.
After this patch, we get all verbose log in the default output file.
Signed-off-by: Zhou Yimin <zhouyimin(a)huawei.com>
---
daemon/libvirtd.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 4cf78e6..87af903 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -683,6 +683,12 @@ daemonSetupLogging(struct daemonConfig *config,
virLogParseOutputs(config->log_outputs);
/*
+ * Command line override for --verbose
+ */
+ if ((verbose) && (virLogGetDefaultPriority() > VIR_LOG_INFO))
+ virLogSetDefaultPriority(VIR_LOG_INFO);
+
+ /*
* If no defined outputs, and either running
* as daemon or not on a tty, then first try
* to direct it to the systemd journal
@@ -748,12 +754,6 @@ daemonSetupLogging(struct daemonConfig *config,
VIR_FREE(tmp);
}
- /*
- * Command line override for --verbose
- */
- if ((verbose) && (virLogGetDefaultPriority() > VIR_LOG_INFO))
- virLogSetDefaultPriority(VIR_LOG_INFO);
-
return 0;
error:
--
1.7.12.4
10 years, 3 months
[libvirt] [PATCH] libvirt: lxc: Add Get/Set vcpus for lxc
by Li Yang
1.Add function to get vcpu count for lxc(vcpucount)
2.Add function to set vcpu count for lxc(setvcpus)
Signed-off-by: Li Yang <liyang.fnst(a)cn.fujitsu.com>
---
src/lxc/lxc_driver.c | 159 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 159 insertions(+), 0 deletions(-)
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 4741632..4df0738 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -5617,6 +5617,162 @@ lxcDomainGetMetadata(virDomainPtr dom,
return ret;
}
+static int
+lxcDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
+ unsigned int flags)
+{
+ virLXCDriverPtr driver = dom->conn->privateData;
+ virDomainObjPtr vm = NULL;
+ virDomainDefPtr persistentDef;
+ int ret = -1;
+ bool maximum;
+ unsigned int maxvcpus = 0;
+ virLXCDriverConfigPtr cfg = NULL;
+ virCapsPtr caps = NULL;
+
+ virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
+ VIR_DOMAIN_AFFECT_CONFIG |
+ VIR_DOMAIN_VCPU_MAXIMUM |
+ VIR_DOMAIN_VCPU_GUEST, -1);
+
+ if (!nvcpus || (unsigned short) nvcpus != nvcpus) {
+ virReportError(VIR_ERR_INVALID_ARG,
+ _("argument out of range: %d"), nvcpus);
+ return -1;
+ }
+
+ if (!(vm = lxcDomObjFromDomain(dom)))
+ goto cleanup;
+
+ cfg = virLXCDriverGetConfig(driver);
+
+ if (virDomainSetVcpusFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
+ goto cleanup;
+
+ if (!(caps = virLXCDriverGetCapabilities(driver, false)))
+ goto cleanup;
+
+ maximum = (flags & VIR_DOMAIN_VCPU_MAXIMUM) != 0;
+ flags &= ~VIR_DOMAIN_VCPU_MAXIMUM;
+
+ if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags,
+ &persistentDef) < 0)
+ goto cleanup;
+
+ /* MAXIMUM cannot be mixed with LIVE. */
+ if (maximum && (flags & VIR_DOMAIN_AFFECT_LIVE)) {
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
+ _("cannot adjust maximum on running domain"));
+ goto cleanup;
+ }
+
+ if (flags & VIR_DOMAIN_AFFECT_LIVE)
+ maxvcpus = vm->def->maxvcpus;
+ if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
+ if (!maxvcpus || maxvcpus > persistentDef->maxvcpus)
+ maxvcpus = persistentDef->maxvcpus;
+ }
+ if (!maximum && nvcpus > maxvcpus) {
+ virReportError(VIR_ERR_INVALID_ARG,
+ _("requested vcpus is greater than max allowable"
+ " vcpus for the domain: %d > %d"),
+ nvcpus, maxvcpus);
+ goto cleanup;
+ }
+
+ if (flags & VIR_DOMAIN_VCPU_GUEST) {
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
+ _("changing of vCPU count isn't supported "
+ "via guest agent"));
+ goto cleanup;
+ } else {
+ if (flags & VIR_DOMAIN_AFFECT_LIVE) {
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
+ _("Cannot hotplug vCPUS for LXC hypervisor"));
+ goto cleanup;
+ }
+
+ if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
+ if (maximum) {
+ persistentDef->maxvcpus = nvcpus;
+ if (nvcpus < persistentDef->vcpus)
+ persistentDef->vcpus = nvcpus;
+ } else {
+ persistentDef->vcpus = nvcpus;
+ }
+
+ if (virDomainSaveConfig(cfg->configDir, persistentDef) < 0)
+ goto cleanup;
+ }
+ }
+
+ ret = 0;
+
+ cleanup:
+ if (vm)
+ virObjectUnlock(vm);
+ virObjectUnref(caps);
+ virObjectUnref(cfg);
+ return ret;
+}
+
+
+static int
+lxcDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus)
+{
+ return lxcDomainSetVcpusFlags(dom, nvcpus, VIR_DOMAIN_AFFECT_LIVE);
+}
+
+
+static int
+lxcDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)
+{
+ virLXCDriverPtr driver = dom->conn->privateData;
+ virDomainObjPtr vm;
+ virDomainDefPtr def;
+ int ret = -1;
+ virCapsPtr caps = NULL;
+
+ virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
+ VIR_DOMAIN_AFFECT_CONFIG |
+ VIR_DOMAIN_VCPU_MAXIMUM |
+ VIR_DOMAIN_VCPU_GUEST, -1);
+
+ if (!(vm = lxcDomObjFromDomain(dom)))
+ return -1;
+
+ if (virDomainGetVcpusFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
+ goto cleanup;
+
+ if (!(caps = virLXCDriverGetCapabilities(driver, false)))
+ goto cleanup;
+
+ if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt,
+ vm, &flags, &def) < 0)
+ goto cleanup;
+
+ if (flags & VIR_DOMAIN_AFFECT_LIVE)
+ def = vm->def;
+
+ if (flags & VIR_DOMAIN_VCPU_GUEST) {
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
+ _("vCPU count cannot be provided by the guest agent"
+ " for LXC hypervisor"));
+ goto cleanup;
+ } else {
+ if (flags & VIR_DOMAIN_VCPU_MAXIMUM)
+ ret = def->maxvcpus;
+ else
+ ret = def->vcpus;
+ }
+
+ cleanup:
+ if (vm)
+ virObjectUnlock(vm);
+ virObjectUnref(caps);
+ return ret;
+}
+
static int
lxcDomainGetCPUStats(virDomainPtr dom,
@@ -5746,6 +5902,9 @@ static virDriver lxcDriver = {
.domainBlockStatsFlags = lxcDomainBlockStatsFlags, /* 1.2.2 */
.domainInterfaceStats = lxcDomainInterfaceStats, /* 0.7.3 */
.domainMemoryStats = lxcDomainMemoryStats, /* 1.2.2 */
+ .domainSetVcpus = lxcDomainSetVcpus, /* 1.2.8 */
+ .domainSetVcpusFlags = lxcDomainSetVcpusFlags, /* 1.2.8 */
+ .domainGetVcpusFlags = lxcDomainGetVcpusFlags, /* 1.2.8 */
.nodeGetCPUStats = lxcNodeGetCPUStats, /* 0.9.3 */
.nodeGetMemoryStats = lxcNodeGetMemoryStats, /* 0.9.3 */
.nodeGetCellsFreeMemory = lxcNodeGetCellsFreeMemory, /* 0.6.5 */
--
1.7.1
10 years, 3 months
[libvirt] [RFCv2] Introduce API for retrieving bulk domain stats v2
by Peter Krempa
I'd like to propose a (hopefully) fairly future-proof API to retrieve
various statistics for domains.
The motivation is that management layers that use libvirt usually poll
libvirt for statistics using various split up APIs we currently provide.
To get all the necessary stuff, the mgmt app need to issue Ndomains *
Napis calls and cope with the various returned formats. The APIs I'm
wanting to introduce here will:
1) Return data in a format that we can expand in the future and is
hierarchical. This version returns the data as typed parameters where
the fields are constructed as dot-separated strings containing names and
other stuff in a list of typed params.
2) Stats for multiple (all) domains can be queried at once and are
returned in one call. This will allow to decrease the overhead necessary
to issue multiple calls per domain multiplied by the count of domains.
3) Selectable (bit mask) fields in the returned format. This will allow
to retrieve only specific stats according to the APPs need.
Initially the implementation will introduce the option to retrieve
block, interface and cpu stats with the possibility to add more in the
future.
The stats groups will be enabled using a bit field @stats passed as the
function argument. A few groups for inspiration:
VIR_DOMAIN_STATS_STATE
VIR_DOMAIN_STATS_CPU
VIR_DOMAIN_STATS_BLOCK
VIR_DOMAIN_STATS_INTERFACE
the returned typed params will use the following scheme
state.state = running
state.reason = started
cpu.count = 8
cpu.0.state = running
cpu.0.time = 1234
...
I'm also thinking of doing an async version of this, where the user
would provide a callback that would be called for each returned domain
but I'm not quite sure if that would play nicely with our RPC so that
requires a bit more investigation first.
Peter
---
include/libvirt/libvirt.h.in | 26 +++++++
src/driver.h | 9 +++
src/libvirt.c | 178 +++++++++++++++++++++++++++++++++++++++++++
src/libvirt_public.syms | 7 ++
4 files changed, 220 insertions(+)
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 47ea695..962f740 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -2501,6 +2501,32 @@ int virDomainDetachDeviceFlags(virDomainPtr domain,
int virDomainUpdateDeviceFlags(virDomainPtr domain,
const char *xml, unsigned int flags);
+typedef struct _virDomainStatsRecord virDomainStatsRecord;
+typedef virDomainStatsRecord *virDomainStatsRecordPtr;
+struct _virDomainStatsRecord {
+ virDomainPtr dom;
+ unsigned int nparams;
+ virTypedParameterPtr params;
+};
+
+typedef enum {
+ VIR_DOMAIN_STATS_ALL = (1 << 0), /* return all stats fields
+ implemented in the daemon */
+ VIR_DOMAIN_STATS_STATE = (1 << 1), /* return domain state */
+} virDomainStatsTypes;
+
+int virConnectGetAllDomainStats(virConnectPtr conn,
+ unsigned int stats,
+ virDomainStatsRecordPtr **retStats,
+ unsigned int flags);
+
+int virDomainListGetStats(virDomainPtr *doms,
+ unsigned int stats,
+ virDomainStatsRecordPtr **retStats,
+ unsigned int flags);
+
+void virDomainStatsRecordListFree(virDomainStatsRecordPtr *stats);
+
/*
* BlockJob API
*/
diff --git a/src/driver.h b/src/driver.h
index 158df79..eab794d 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -1191,6 +1191,14 @@ typedef int
unsigned int flags);
+typedef int
+(*virDrvDomainListGetStats)(virConnectPtr conn,
+ virDomainPtr *doms,
+ unsigned int ndoms,
+ unsigned int stats,
+ virDomainStatsRecordPtr **retStats,
+ unsigned int flags);
+
typedef struct _virDriver virDriver;
typedef virDriver *virDriverPtr;
@@ -1411,6 +1419,7 @@ struct _virDriver {
virDrvDomainSetTime domainSetTime;
virDrvNodeGetFreePages nodeGetFreePages;
virDrvConnectGetDomainCapabilities connectGetDomainCapabilities;
+ virDrvDomainListGetStats domainListGetStats;
};
diff --git a/src/libvirt.c b/src/libvirt.c
index 8349261..c2244d0 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -21341,3 +21341,181 @@ virConnectGetDomainCapabilities(virConnectPtr conn,
virDispatchError(conn);
return NULL;
}
+
+
+/**
+ * virConnectGetAllDomainStats:
+ * @conn: pointer to the hypervisor connection
+ * @stats: stats to return, binary-OR of virDomainStatsTypes
+ * @retStats: Pointer that will be filled with the array of returned stats.
+ * @flags: extra flags; not used yet, so callers should always pass 0
+ *
+ * Query statistics for all domains on a given connection.
+ *
+ * Report statistics of various parameters for a running VM according to @stats
+ * field. The statistics are returned as an array of structures for each queried
+ * domain. The structure contains an array of typed parameters containing the
+ * individual statistics. The typed parameter name for each statistic field
+ * consists of a dot-separated string containing name of the requested group
+ * followed by a group specific description of the statistic value.
+ *
+ * The statistic groups are enabled using the @stats parameter which is a
+ * binary-OR of enum virDomainStatsTypes. The following groups are available
+ * (although not necessarily implemented for each storage driver):
+ *
+ * VIR_DOMAIN_STATS_ALL: Return all statistics supported by the hypervisor
+ * driver. This allows to query everything the driver supports without getting
+ * an error.
+ *
+ * VIR_DOMAIN_STATS_STATE: Return domain state and reason for entering that
+ * state. The typed parameter keys are in format:
+ * "state.state" - state of the VM, returned as int from virDomainState enum
+ * "state.reason" - reason for entering given state, returned as in from
+ * virDomain*Reason enmum corresponding to given state.
+ *
+ * Returns the count of returned statistics strucutres on success, -1 on error.
+ * The requested data are returned in the @retStats parameter. The returned
+ * array should be freed by the caller. See virDomainStatsRecordListFree.
+ */
+int
+virConnectGetAllDomainStats(virConnectPtr conn,
+ unsigned int stats,
+ virDomainStatsRecordPtr **retStats,
+ unsigned int flags)
+{
+ int ret = -1;
+
+ VIR_DEBUG("conn=%p, stats=0x%x, retStats=%p, flags=0x%x",
+ conn, stats, retStats, flags);
+
+ virResetLastError();
+
+ virCheckConnectReturn(conn, -1);
+
+ if (!conn->driver->domainListGetStats) {
+ virReportUnsupportedError();
+ goto cleanup;
+ }
+
+ ret = conn->driver->domainListGetStats(conn, NULL, 0, stats,
+ retStats, flags);
+
+ cleanup:
+ if (ret < 0)
+ virDispatchError(conn);
+
+ return ret;
+}
+
+
+/**
+ * virDomainListGetStats:
+ * @doms: NULL terminated array of domains
+ * @stats: stats to return, binary-OR of virDomainStatsTypes
+ * @retStats: Pointer that will be filled with the array of returned stats.
+ * @flags: extra flags; not used yet, so callers should always pass 0
+ *
+ * Query statistics for domains provided by @doms. Note that all domains in
+ * @doms must share the same connection.
+ *
+ * Report statistics of various parameters for a running VM according to @stats
+ * field. The statistics are returned as an array of structures for each queried
+ * domain. The structure contains an array of typed parameters containing the
+ * individual statistics. The typed parameter name for each statistic field
+ * consists of a dot-separated string containing name of the requested group
+ * followed by a group specific description of the statistic value.
+ *
+ * The statistic groups are enabled using the @stats parameter which is a
+ * binary-OR of enum virDomainStatsTypes. The following groups are available
+ * (although not necessarily implemented for each storage driver):
+ *
+ * VIR_DOMAIN_STATS_ALL: Return all statistics supported by the hypervisor
+ * driver. This allows to query everything the driver supports without getting
+ * an error.
+ *
+ * VIR_DOMAIN_STATS_STATE: Return domain state and reason for entering that
+ * state. The typed parameter keys are in format:
+ * "state.state" - state of the VM, returned as int from virDomainState enum
+ * "state.reason" - reason for entering given state, returned as in from
+ * virDomain*Reason enmum corresponding to given state.
+ *
+ * Returns the count of returned statistics strucutres on success, -1 on error.
+ * The requested data are returned in the @retStats parameter. The returned
+ * array should be freed by the caller. See virDomainStatsRecordListFree.
+ */
+int
+virDomainListGetStats(virDomainPtr *doms,
+ unsigned int stats,
+ virDomainStatsRecordPtr **retStats,
+ unsigned int flags)
+{
+ virConnectPtr conn = NULL;
+ virDomainPtr *nextdom = doms;
+ unsigned int ndoms = 0;
+ int ret = -1;
+
+ VIR_DEBUG("doms=%p, stats=0x%x, retStats=%p, flags=0x%x",
+ doms, stats, retStats, flags);
+
+ virResetLastError();
+
+ if (!*doms) {
+ virReportError(VIR_ERR_INVALID_ARG,
+ _("doms array in %s must contain at leas one domain"),
+ __FUNCTION__);
+ goto cleanup;
+ }
+
+ conn = doms[0]->conn;
+
+ if (!conn->driver->domainListGetStats) {
+ virReportUnsupportedError();
+ goto cleanup;
+ }
+
+ while (*(++nextdom)) {
+ virDomainPtr dom = *nextdom;
+
+ virCheckDomainGoto(dom, cleanup);
+
+ if (dom->conn != conn) {
+ virReportError(VIR_ERR_INVALID_ARG,
+ _("domains in 'doms' array must belong to a "
+ "single connection in %s"), __FUNCTION__);
+ goto cleanup;
+ }
+
+ ndoms++;
+ }
+
+ ret = conn->driver->domainListGetStats(conn, doms, ndoms, stats, retStats,
+ flags);
+
+ cleanup:
+ if (ret < 0)
+ virDispatchError(conn);
+ return ret;
+}
+
+
+/**
+ * virDomainStatsRecordListFree:
+ * @stats: NULL terminated array of virDomainStatsRecords to free
+ *
+ * Convenience function to free a list of domain stats returned by
+ * virDomainListGetStats and virConnectGetAllDomainStats.
+ */
+void
+virDomainStatsRecordListFree(virDomainStatsRecordPtr *stats)
+{
+ virDomainStatsRecordPtr *next = stats;
+
+ while (*next) {
+ virTypedParamsFree((*next)->params, (*next)->nparams);
+ virDomainFree((*next)->dom);
+ VIR_FREE((*next));
+ next++;
+ }
+
+ VIR_FREE(stats);
+}
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index 9f4016a..3714159 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -670,4 +670,11 @@ LIBVIRT_1.2.7 {
virConnectGetDomainCapabilities;
} LIBVIRT_1.2.6;
+LIBVIRT_1.2.8 {
+ global:
+ virDomainListGetStats;
+ virConnectGetAllDomainStats;
+ virDomainStatsRecordListFree;
+} LIBVIRT_1.2.7;
+
# .... define new API here using predicted next version number ....
--
2.0.2
10 years, 3 months
[libvirt] [PATCH] fix mingw build
by Pavel Hrdina
The commit "f5b4c141" introduced new "force" parameter
for "virFDStreamOpenFileInternal" but forget to update
one call of that function.
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
Pushed as build breaker.
src/fdstream.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/fdstream.c b/src/fdstream.c
index 4cf152a..9ff7e2a 100644
--- a/src/fdstream.c
+++ b/src/fdstream.c
@@ -769,7 +769,8 @@ int virFDStreamOpenPTY(virStreamPtr st,
{
return virFDStreamOpenFileInternal(st, path,
offset, length,
- oflags | O_CREAT, 0);
+ oflags | O_CREAT, 0,
+ false);
}
#endif /* !HAVE_CFMAKERAW */
--
1.8.5.5
10 years, 3 months
[libvirt] [PATCH 0/3] storage: zfs: implement download and upload
by Roman Bogorodskiy
Roman Bogorodskiy (3):
fdstream: report error if virSetNonBlock fails
fdstream: introduce virFDStreamOpenBlockDevice
storage: zfs: implement download and upload
src/fdstream.c | 30 +++++++++++++++++++++++-------
src/fdstream.h | 5 +++++
src/libvirt_private.syms | 1 +
src/storage/storage_backend.c | 6 ++++--
src/storage/storage_backend_zfs.c | 2 ++
5 files changed, 35 insertions(+), 9 deletions(-)
--
1.9.0
10 years, 3 months
[libvirt] [PATCH] maint: fix comment typo
by Eric Blake
* src/util/virbuffer.h: s/occured/occurred/
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
Pushing under the trivial rule.
src/util/virbuffer.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/util/virbuffer.h b/src/util/virbuffer.h
index bdfff5e..90e248d 100644
--- a/src/util/virbuffer.h
+++ b/src/util/virbuffer.h
@@ -1,7 +1,7 @@
/*
* virbuffer.h: buffers for libvirt
*
- * Copyright (C) 2005-2008, 2011-2013 Red Hat, Inc.
+ * Copyright (C) 2005-2008, 2011-2014 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
@@ -64,7 +64,7 @@ int virBufferCheckErrorInternal(const virBuffer *buf,
*
* Checks if the buffer is in error state and reports an error.
*
- * Returns 0 if no error has occured, otherwise an error is reported
+ * Returns 0 if no error has occurred, otherwise an error is reported
* and -1 is returned.
*/
# define virBufferCheckError(buf) \
--
1.9.3
10 years, 3 months