[libvirt] [PATCH v2 00/10] Re-enable memballoon driver statistics reporting
by John Ferlan
This patchset replaces:
https://www.redhat.com/archives/libvir-list/2013-July/msg00108.html
Changes since V1:
* Remove the external (eg, qemu_monitor.{c,h}) API's to the qom-list,
qom-get, qom-set interfaces
* Handle errors in virXPathInt() return checking domain_conf.c
* Move the 'period' from _qemuDomainObjPrivate into _qemuMonitor
* Move/rename qemuProcessFindBalloonObjectPath from qemu_process.c
into qemu_monitor.c as qemuMonitorFindBalloonObjectPath()
* Create qemuMonitorJSONSetMemoryStatsPeriod() in qemu_monitor_json.c from
parts of prior change to add qemuProcessUpdateBalloonStatsPeriod()
in qemu_process.c and hav
* Add qemuMonitorSetMemoryStatsPeriod() in qemu_monitor.c to set
the collection period. Adjust the code to take parts of prior change
and make check for balloon path in this path (set if necessary).
* Adjust code in qemuProcessReconnect(), qemuProcessStart(), and
qemuProcessAttach() to call qemuMonitorSetMemoryStatsPeriod()
* Adjust qemuMonitorJSONGetMemoryStats() to get the balloon stats once
the "actual" stat is collected from qemuMonitorJSONGetBalloonInfo().
Reviewer note: The prior code to get "actual" was a duplicate of the
BalloonInfo code. Since "balloon-info" is where the actual memory is
still stored it still must be called as that data is not present in
the balloon stats qom-get "stats" fetch implemented as the new API
qemuMonitorJSONGetBalloonStats().
* Avoid overloading virDomainSetMemoryFlags()...
* Create/use virDomainSetMemoryStatsPeriodFlags() to set the collection
period dynamically from "virsh dommemstats" using the --period qualifier.
John Ferlan (10):
Add qemuMonitorJSONGetObjectListPaths() method for QMP qom-list
command
Add qemuMonitorJSONGetObjectProperty() method for QMP qom-get command
Add qemuMonitorJSONSetObjectProperty() method for QMP qom-set command
Add 'period' for Memballoon statistics gathering capability
Determine whether to start balloon memory stats gathering.
Add capability to fetch balloon stats
Add new public API virDomainSetMemoryStatsPeriodFlags
Specify remote protocol for virDomainSetMemoryStatsPeriodFlags
Implement the virDomainSetMemoryStatsPeriodFlags for QEMU driver
Allow balloon driver collection to be adjusted dynamically
docs/formatdomain.html.in | 19 ++
docs/schemas/domaincommon.rng | 7 +
include/libvirt/libvirt.h.in | 3 +
src/conf/domain_conf.c | 44 +++-
src/conf/domain_conf.h | 1 +
src/driver.h | 6 +
src/libvirt.c | 65 ++++++
src/libvirt_public.syms | 5 +
src/qemu/qemu_driver.c | 66 ++++++
src/qemu/qemu_monitor.c | 133 ++++++++++-
src/qemu/qemu_monitor.h | 2 +
src/qemu/qemu_monitor_json.c | 498 ++++++++++++++++++++++++++++++++----------
src/qemu/qemu_monitor_json.h | 64 ++++++
src/qemu/qemu_process.c | 21 +-
src/remote/remote_driver.c | 1 +
src/remote/remote_protocol.x | 15 +-
src/remote_protocol-structs | 6 +
tests/qemumonitorjsontest.c | 186 ++++++++++++++++
tools/virsh-domain-monitor.c | 66 +++++-
19 files changed, 1085 insertions(+), 123 deletions(-)
--
1.8.1.4
11 years, 4 months
[libvirt] [PATCH 0/7] Resolve Coverity issues
by John Ferlan
The recent changes to change 'int i' to 'size_t i' seem to have uncovered
a few new Coverity issues - resolve those. Also add a [dead_error_code]
tag to a Coverity issue that's been there for a bit.
After these patches the result is just back to 1 Coverity error in
'virLXCProcessReboot' regarding the usage of 'conn' which still needs
to be eventually resolved, see:
https://www.redhat.com/archives/libvir-list/2013-May/msg01218.html
and subsequent followups
John Ferlan (7):
hellolibvirt: Resolve Coverity issues
testutils: Resolve Coverity issues
virsh-domain-monitor: Resolve Coverity issues
virsh-interface: Resolve Coverity issues
virsh-nodedev: Resolve Coverity issues
storage_backend: Resolve Coverity issue
qemu_hostdev: Resolve Coverity issue
examples/hellolibvirt/hellolibvirt.c | 7 +++++++
src/qemu/qemu_hostdev.c | 12 +++++++-----
src/storage/storage_backend.c | 1 +
tests/testutils.c | 3 +++
tools/virsh-domain-monitor.c | 10 ++++++----
tools/virsh-interface.c | 24 +++++++++++++-----------
tools/virsh-nodedev.c | 12 +++++++-----
7 files changed, 44 insertions(+), 25 deletions(-)
--
1.8.1.4
11 years, 4 months
[libvirt] [PATCH RFC]:tolerate numa_node_size64 < 0 because nodeid might start from 1 instead of 0
by hejia hejia
In nodeGetFreeMemory/nodeGetCellsFreeMemory, they will calculate the free
memory of every nodes. They assumed that nodeid of NUMA machine must be
continuous and start from 0.
But here is a counter-example:
# numactl -H
available: 1 nodes (1)
node 1 cpus: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
node 1 size: 16340 MB
node 1 free: 11065 MB
test results before this patch:
#virsh freecell
error: internal error Failed to query NUMA free memory
#virsh freecell 0
error: internal error Failed to query NUMA free memory for node: 0
after this patch:
# virsh freecell
Total: 15772580 KiB
# virsh freecell 0
0: 0 KiB
--- libvirt/src/nodeinfo.c.orig 2013-07-08 04:25:11.970351101 -0500
+++ libvirt/src/nodeinfo.c 2013-07-08 09:00:30.834471495 -0500
@@ -1717,10 +1717,6 @@ nodeGetCellsFreeMemory(unsigned long lon
for (numCells = 0, n = startCell; n <= lastCell; n++) {
long long mem;
if (numa_node_size64(n, &mem) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Failed to query NUMA free memory for node: %d"),
- n);
- goto cleanup;
}
freeMems[numCells++] = mem;
}
@@ -1743,9 +1739,6 @@ nodeGetFreeMemory(void)
for (n = 0; n <= numa_max_node(); n++) {
long long mem;
if (numa_node_size64(n, &mem) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("Failed to query NUMA free memory"));
- goto cleanup;
}
freeMem += mem;
}
11 years, 4 months
[libvirt] [PATCH 1/2] LXC: hostdev: introduce lxcContainerSetupHostdevCapsMakePath
by Gao feng
This helper function is used to create parent directroy for
the hostdev which will be added to the container. if the
parent directory of this hostdev doesn't exist, the mknod of
the hostdev will fail.
Signed-off-by: Gao feng <gaofeng(a)cn.fujitsu.com>
---
src/lxc/lxc_container.c | 17 +++++++++++++++++
src/lxc/lxc_container.h | 2 ++
2 files changed, 19 insertions(+)
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index c8420db..b954107 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -1544,6 +1544,23 @@ cleanup:
}
+int lxcContainerSetupHostdevCapsMakePath(char *dev)
+{
+ int ret = 0;
+ char *dir = NULL;
+
+ if ((dir = strrchr(dev, '/'))) {
+ *dir = '\0';
+ if ((virFileMakePath(dev) < 0) && (errno != EEXIST))
+ ret = -1;
+
+ *dir = '/';
+ }
+
+ return ret;
+}
+
+
static int lxcContainerSetupHostdevCapsStorage(virDomainDefPtr vmDef ATTRIBUTE_UNUSED,
virDomainHostdevDefPtr def ATTRIBUTE_UNUSED,
virSecurityManagerPtr securityDriver ATTRIBUTE_UNUSED)
diff --git a/src/lxc/lxc_container.h b/src/lxc/lxc_container.h
index ada72f7..f168703 100644
--- a/src/lxc/lxc_container.h
+++ b/src/lxc/lxc_container.h
@@ -63,6 +63,8 @@ int lxcContainerStart(virDomainDefPtr def,
int lxcContainerAvailable(int features);
+int lxcContainerSetupHostdevCapsMakePath(char *dev);
+
virArch lxcContainerGetAlt32bitArch(virArch arch);
#endif /* LXC_CONTAINER_H */
--
1.8.3.1
11 years, 4 months
[libvirt] [PATCH 0/3] Fix hotplug error messages
by Michal Privoznik
https://bugzilla.redhat.com/show_bug.cgi?id=982304
The problem is virDomainDeviceDefParse's incompleteness. When doing a
hot(un-)plug or update, the passed XML snippet is parsed. However, if
virDomainDeviceDefParse doesn't recognize the device (due its implementation
incompleteness) an error is returned:
error: XML error: unknown device type
and the control doesn't even reach the check for supported devices for current
operation, where much more correct error message would be printed out:
error: Operation not supported: persistent detach
of device 'memballoon' is not supported
Michar Privoznik (3):
conf: Extend virDomainDeviceDefParse handled types
conf: Rework virDomainDeviceDefParse
qemu: Fix hot (un-)plug error codes and messages
src/conf/domain_conf.c | 111 ++++++++++++++++++++++++++++++++++---------------
src/qemu/qemu_driver.c | 42 ++++++++++---------
2 files changed, 101 insertions(+), 52 deletions(-)
--
1.8.1.5
11 years, 4 months
[libvirt] [PATCH] Reject duplicate disk targets
by Martin Kletzander
We never check for disks with duplicate targets connected to the same
controller/bus/etc. That means we go ahead, create the same IDs for
them and pass them to qemu, which subsequently fails to start.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=968899
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
src/conf/domain_conf.c | 42 +++++++++++++++++++++++++++++++++++++++++-
1 file changed, 41 insertions(+), 1 deletion(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 3398d8b..01720e1 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2629,6 +2629,45 @@ virDomainDeviceInfoIterate(virDomainDefPtr def,
static int
+virDomainDefRejectDuplicateDiskTargets(virDomainDefPtr def)
+{
+ char *disk_id = NULL;
+ int ret = -1;
+ size_t i = 0;
+ virHashTablePtr targets = NULL;
+
+ if (!(targets = virHashCreate(def->ndisks, NULL)))
+ goto cleanup;
+
+ for (i = 0; i < def->ndisks; i++) {
+ virDomainDiskDefPtr disk = def->disks[i];
+
+ if (virAsprintf(&disk_id, "%d%s%d%d%d%d",
+ disk->bus,
+ NULLSTR(disk->dst),
+ disk->info.addr.drive.controller,
+ disk->info.addr.drive.bus,
+ disk->info.addr.drive.target,
+ disk->info.addr.drive.unit) < 0)
+ goto cleanup;
+
+ if (virHashAddEntry(targets, disk_id, NULL) < 0) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("Multiple disks with same address and target ('%s')"),
+ def->disks[i]->dst);
+ VIR_FREE(disk_id);
+ goto cleanup;
+ }
+ VIR_FREE(disk_id);
+ }
+
+ ret = 0;
+ cleanup:
+ virHashFree(targets);
+ return ret;
+}
+
+static int
virDomainDefRejectDuplicateControllers(virDomainDefPtr def)
{
int max_idx[VIR_DOMAIN_CONTROLLER_TYPE_LAST];
@@ -2762,7 +2801,8 @@ virDomainDefPostParseInternal(virDomainDefPtr def,
}
}
- if (virDomainDefRejectDuplicateControllers(def) < 0)
+ if (virDomainDefRejectDuplicateControllers(def) < 0 ||
+ virDomainDefRejectDuplicateDiskTargets(def) < 0)
return -1;
return 0;
}
--
1.8.3.2
11 years, 4 months
[libvirt] [PATCH] LXC: remove some incorrect setting ATTRIBUTE_UNUSED
by Gao feng
these parameters shouldn't be marked as ATTRIBUTE_UNUSED.
Signed-off-by: Gao feng <gaofeng(a)cn.fujitsu.com>
---
src/lxc/lxc_container.c | 28 ++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 257cf93..543e0d1 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -1449,9 +1449,9 @@ static int lxcContainerSetupAllDisks(virDomainDefPtr vmDef,
}
-static int lxcContainerSetupHostdevSubsysUSB(virDomainDefPtr vmDef ATTRIBUTE_UNUSED,
- virDomainHostdevDefPtr def ATTRIBUTE_UNUSED,
- virSecurityManagerPtr securityDriver ATTRIBUTE_UNUSED)
+static int lxcContainerSetupHostdevSubsysUSB(virDomainDefPtr vmDef,
+ virDomainHostdevDefPtr def,
+ virSecurityManagerPtr securityDriver)
{
int ret = -1;
char *src = NULL;
@@ -1541,9 +1541,9 @@ cleanup:
}
-static int lxcContainerSetupHostdevCapsStorage(virDomainDefPtr vmDef ATTRIBUTE_UNUSED,
- virDomainHostdevDefPtr def ATTRIBUTE_UNUSED,
- virSecurityManagerPtr securityDriver ATTRIBUTE_UNUSED)
+static int lxcContainerSetupHostdevCapsStorage(virDomainDefPtr vmDef,
+ virDomainHostdevDefPtr def,
+ virSecurityManagerPtr securityDriver)
{
char *src = NULL;
int ret = -1;
@@ -1603,9 +1603,9 @@ cleanup:
}
-static int lxcContainerSetupHostdevCapsMisc(virDomainDefPtr vmDef ATTRIBUTE_UNUSED,
- virDomainHostdevDefPtr def ATTRIBUTE_UNUSED,
- virSecurityManagerPtr securityDriver ATTRIBUTE_UNUSED)
+static int lxcContainerSetupHostdevCapsMisc(virDomainDefPtr vmDef,
+ virDomainHostdevDefPtr def,
+ virSecurityManagerPtr securityDriver)
{
char *src = NULL;
int ret = -1;
@@ -1873,9 +1873,9 @@ static int lxcContainerResolveSymlinks(virDomainDefPtr vmDef)
* It removes some capabilities that could be dangerous to
* host system, since they are not currently "containerized"
*/
-static int lxcContainerDropCapabilities(bool keepReboot ATTRIBUTE_UNUSED)
-{
#if WITH_CAPNG
+static int lxcContainerDropCapabilities(bool keepReboot)
+{
int ret;
capng_get_caps_process();
@@ -1907,11 +1907,15 @@ static int lxcContainerDropCapabilities(bool keepReboot ATTRIBUTE_UNUSED)
* container it is fine for SECURE_NOROOT / SECURE_NO_SETUID_FIXUP to
* be unmasked - they can never escape the bounding set. */
+ return 0;
+}
#else
+static int lxcContainerDropCapabilities(bool keepReboot ATTRIBUTE_UNUSED)
+{
VIR_WARN("libcap-ng support not compiled in, unable to clear capabilities");
-#endif
return 0;
}
+#endif
/**
--
1.8.3.1
11 years, 4 months
[libvirt] [PATCH] storage: return -1 when fs pool can't be mounted
by Ján Tomko
Don't reuse the return value of virStorageBackendFileSystemIsMounted.
If it's 0, we'd return it even if the mount command failed.
Also, don't report another error if it's -1, since one has already
been reported.
Introduced by 258e06c.
https://bugzilla.redhat.com/show_bug.cgi?id=981251
---
src/storage/storage_backend_fs.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index 8b40f55..d305b06 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -355,6 +355,7 @@ virStorageBackendFileSystemMount(virStoragePoolObjPtr pool) {
pool->def->source.format == VIR_STORAGE_POOL_NETFS_GLUSTERFS);
virCommandPtr cmd = NULL;
int ret = -1;
+ int rc;
if (pool->def->type == VIR_STORAGE_POOL_NETFS) {
if (pool->def->source.nhost != 1) {
@@ -381,10 +382,12 @@ virStorageBackendFileSystemMount(virStoragePoolObjPtr pool) {
}
/* Short-circuit if already mounted */
- if ((ret = virStorageBackendFileSystemIsMounted(pool)) != 0) {
- virReportError(VIR_ERR_OPERATION_INVALID,
- _("Target '%s' is already mounted"),
- pool->def->target.path);
+ if ((rc = virStorageBackendFileSystemIsMounted(pool)) != 0) {
+ if (rc == 1) {
+ virReportError(VIR_ERR_OPERATION_INVALID,
+ _("Target '%s' is already mounted"),
+ pool->def->target.path);
+ }
return -1;
}
--
1.8.1.5
11 years, 4 months
[libvirt] [PATCH] qemu: Slightly increase memory limit
by Jiri Denemark
For low-memory domains (roughly under 400MB) our automatic memory limit
computation comes up with a limit that's too low. This is because the
0.5 multiplication does not add enough for such small values. Let's
increase the constant part of the computation to fix this.
---
src/qemu/qemu_domain.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 28b8ee4..c38c86e 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2197,7 +2197,7 @@ qemuDomainMemoryLimit(virDomainDefPtr def)
* limit' has been chosen:
* (1 + k) * (domain memory + total video memory) + (32MB for
* cache per each disk) + F
- * where k = 0.5 and F = 200MB. The cache for disks is important as
+ * where k = 0.5 and F = 400MB. The cache for disks is important as
* kernel cache on the host side counts into the RSS limit.
* Moreover, VFIO requires some amount for IO space. Alex Williamson
* suggested adding 1GiB for IO space just to be safe (some finer
@@ -2212,7 +2212,7 @@ qemuDomainMemoryLimit(virDomainDefPtr def)
mem += def->videos[i]->vram;
mem *= 1.5;
mem += def->ndisks * 32768;
- mem += 204800;
+ mem += 409600;
for (i = 0; i < def->nhostdevs; i++) {
virDomainHostdevDefPtr hostdev = def->hostdevs[i];
--
1.8.2.1
11 years, 4 months
[libvirt] [PATCH] util: use VIR_(APPEND|DELETE)_ELEMENT for pci/usb device lists
by Laine Stump
Eliminate memmove() by using VIR_*_ELEMENT API instead.
In both pci and usb cases, the count that held the size of the list
was unsigned int so it had to be changed to size_t.
---
This is an alternate fix to the same problem fixed by
https://www.redhat.com/archives/libvir-list/2013-July/msg00324.html
(an off by one bug in the conditional in virUSBDeviceListSteal()).
This version fixes it by converting from open coded memmoves to using
VIR_(INSERT|DELETE)_ELEMENT.
src/util/virpci.c | 18 +++---------------
src/util/virusb.c | 26 +++++++-------------------
2 files changed, 10 insertions(+), 34 deletions(-)
diff --git a/src/util/virpci.c b/src/util/virpci.c
index e42f6fa..b715122 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -80,7 +80,7 @@ struct _virPCIDevice {
struct _virPCIDeviceList {
virObjectLockable parent;
- unsigned int count;
+ size_t count;
virPCIDevicePtr *devs;
};
@@ -1670,11 +1670,9 @@ virPCIDeviceListAdd(virPCIDeviceListPtr list,
return -1;
}
- if (VIR_REALLOC_N(list->devs, list->count+1) < 0)
+ if (VIR_APPEND_ELEMENT(list->devs, list->count, dev, true) < 0)
return -1;
- list->devs[list->count++] = dev;
-
return 0;
}
@@ -1723,17 +1721,7 @@ virPCIDeviceListStealIndex(virPCIDeviceListPtr list,
return NULL;
ret = list->devs[idx];
-
- if (idx != --list->count) {
- memmove(&list->devs[idx],
- &list->devs[idx + 1],
- sizeof(*list->devs) * (list->count - idx));
- }
-
- if (VIR_REALLOC_N(list->devs, list->count) < 0) {
- ; /* not fatal */
- }
-
+ VIR_DELETE_ELEMENT(list->devs, idx, list->count);
return ret;
}
diff --git a/src/util/virusb.c b/src/util/virusb.c
index 3bcb07c..103c301 100644
--- a/src/util/virusb.c
+++ b/src/util/virusb.c
@@ -60,7 +60,7 @@ struct _virUSBDevice {
struct _virUSBDeviceList {
virObjectLockable parent;
- unsigned int count;
+ size_t count;
virUSBDevicePtr *devs;
};
@@ -451,11 +451,9 @@ virUSBDeviceListAdd(virUSBDeviceListPtr list,
return -1;
}
- if (VIR_REALLOC_N(list->devs, list->count+1) < 0)
+ if (VIR_APPEND_ELEMENT(list->devs, list->count, dev, true) < 0)
return -1;
- list->devs[list->count++] = dev;
-
return 0;
}
@@ -484,22 +482,12 @@ virUSBDeviceListSteal(virUSBDeviceListPtr list,
int i;
for (i = 0; i < list->count; i++) {
- if (list->devs[i]->bus != dev->bus ||
- list->devs[i]->dev != dev->dev)
- continue;
-
- ret = list->devs[i];
-
- if (i != list->count--)
- memmove(&list->devs[i],
- &list->devs[i+1],
- sizeof(*list->devs) * (list->count - i));
-
- if (VIR_REALLOC_N(list->devs, list->count) < 0) {
- ; /* not fatal */
+ if (list->devs[i]->bus == dev->bus &&
+ list->devs[i]->dev == dev->dev) {
+ ret = list->devs[i];
+ VIR_DELETE_ELEMENT(list->devs, i, list->count);
+ break;
}
-
- break;
}
return ret;
}
--
1.7.11.7
11 years, 4 months