[libvirt] [PATCH for 5.3.0] storage_backend_rbd: Don't fail iterating over snapshots
by Michal Privoznik
When cloning an RBD volume we try to find a snapshot which is
not different to the image we're trying to clone. This boils down
to calling rbd_diff_iterate() or rbd_diff_iterate2() on systems
with newer ceph. These two are passed a callback -
virStorageBackendRBDIterateCb() which mistakenly states that if
a negative value is returned from the callback, the iteration is
stopped but no error is reported. Well, that is not the case.
I've looked into librbd sources and found that a negative value
does mean stop of iteration but it also means an error. That's
why any attempt to clone an RBD image results in the following
error:
virsh # vol-clone --pool rbd_image_root coreos_2023 coreos00.disk
error: Failed to clone vol from coreos_2023
error: failed to iterate RBD snapshot coreos_2023@base: Operation not
permitted
Reported on libvirt-users list:
https://www.redhat.com/archives/libvirt-users/2019-April/msg00060.html
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/storage/storage_backend_rbd.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c
index f8c968e682..3fe188551c 100644
--- a/src/storage/storage_backend_rbd.c
+++ b/src/storage/storage_backend_rbd.c
@@ -1031,14 +1031,9 @@ virStorageBackendRBDIterateCb(uint64_t offset ATTRIBUTE_UNUSED,
{
/*
* Just set that there is a diff for this snapshot, we do not care where
- *
- * When it returns a negative number the rbd_diff_iterate() function will stop
- *
- * That's why we return -1, meaning that there is a difference and we can stop
- * searching any further.
*/
*(int*) arg = 1;
- return -1;
+ return 0;
}
static int
--
2.21.0
5 years, 7 months
[libvirt] [python PATCH] Allow virConnect.getDomainCapabilities() to have no arguments
by Michal Privoznik
Our C API allows no values to be passed (well, it accepts all
NULLs). There's no reason that python binding should require all
arguments.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
libvirt-override-api.xml | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/libvirt-override-api.xml b/libvirt-override-api.xml
index 7f578e0..53b15c5 100644
--- a/libvirt-override-api.xml
+++ b/libvirt-override-api.xml
@@ -754,5 +754,15 @@
<arg name='conn' type='virConnectPtr' info='pointer to hypervisor connection'/>
<arg name='flags' type='int' info='unused, always pass 0'/>
</function>
+ <function name='virConnectGetDomainCapabilities' file='libvirt-domain' module='libvirt-domain'>
+ <info>Query domain capabilities</info>
+ <return type='char *' info='NULL in case of error or an XML string defining the capabilities.'/>
+ <arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
+ <arg name='emulatorbin' type='const char *' info='optional path to emulator'/>
+ <arg name='arch' type='const char *' info='optional domain architecture'/>
+ <arg name='machine' type='const char *' info='optional machine type'/>
+ <arg name='virttype' type='const char *' info='optional virtualization type'/>
+ <arg name='flags' type='int' info='unused, always pass 0'/>
+ </function>
</symbols>
</api>
--
2.21.0
5 years, 7 months
[libvirt] [PATCH] CONF: bug, release 'alloc' object in cleanup
by Wang Huaqiang
In case error happens before 'alloc' is transferred to 'resctrl',
the 'alloc' object should be released.
Signed-off-by: Wang Huaqiang <huaqiang.wang(a)intel.com>
---
src/conf/domain_conf.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 6331424..7d20276 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -19396,6 +19396,7 @@ virDomainCachetuneDefParse(virDomainDefPtr def,
ret = 0;
cleanup:
+ virObjectUnref(alloc);
virDomainResctrlDefFree(resctrl);
return ret;
}
@@ -19597,6 +19598,7 @@ virDomainMemorytuneDefParse(virDomainDefPtr def,
ret = 0;
cleanup:
+ virObjectUnref(alloc);
virDomainResctrlDefFree(resctrl);
return ret;
}
--
2.7.4
5 years, 7 months
[libvirt] [PATCH 0/4] Couple of almost trivial disk cold-/hot-plug fixes
by Michal Privoznik
*** BLURB HERE ***
Michal Prívozník (4):
src: Check for virDomainDiskInsert() retval properly
qemuDomainAttachDeviceLiveAndConfig: Don't overwrite @ret
qemu: On attach to live XML check for user alias collision only live
XML
qemu: Check for user alias collisions in coldplug
src/libxl/libxl_driver.c | 2 +-
src/lxc/lxc_driver.c | 2 +-
src/qemu/qemu_driver.c | 32 ++++++++++++++++++--------------
3 files changed, 20 insertions(+), 16 deletions(-)
--
2.21.0
5 years, 7 months
[libvirt] [PATCH] qemu: Add entry for balloon stats stat-htlb-pgalloc and stat-htlb-pgfail
by Han Han
Qemu added reporting of virtio balloon new statistics stat-htlb-pgalloc and
stat-htlb-pgfail since qemu-3.0 commit b7b12644297. The value of
stat-htlb-pgalloc represents the number of successful hugetlb page allocations
while stat-htlb-pgfail represents the number of failed ones. Add this
statistics reporting to libvirt.
Signed-off-by: Han Han <hhan(a)redhat.com>
---
include/libvirt/libvirt-domain.h | 14 +++++++++++++-
src/libvirt-domain.c | 5 ++++-
src/qemu/qemu_driver.c | 2 ++
src/qemu/qemu_monitor_json.c | 5 +++++
tools/virsh-domain-monitor.c | 4 ++++
tools/virsh.pod | 2 ++
6 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index 7d36820b5a..192d25c1db 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -636,11 +636,23 @@ typedef enum {
*/
VIR_DOMAIN_MEMORY_STAT_DISK_CACHES = 10,
+ /*
+ * The amount of successful hugetlb(Huge Page Tables) allocations via
+ * virtio balloon.
+ */
+ VIR_DOMAIN_MEMORY_STAT_HUGETLB_PGALLOC = 11,
+
+ /*
+ * The amount of failed hugetlb(Huge Page Tables) allocations via
+ * virtio balloon.
+ */
+ VIR_DOMAIN_MEMORY_STAT_HUGETLB_PGFAIL = 12,
+
/*
* The number of statistics supported by this version of the interface.
* To add new statistics, add them to the enum and increase this value.
*/
- VIR_DOMAIN_MEMORY_STAT_NR = 11,
+ VIR_DOMAIN_MEMORY_STAT_NR = 13,
# ifdef VIR_ENUM_SENTINELS
VIR_DOMAIN_MEMORY_STAT_LAST = VIR_DOMAIN_MEMORY_STAT_NR
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 80284a99f0..a95690e8a4 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -5734,7 +5734,10 @@ virDomainGetInterfaceParameters(virDomainPtr domain,
* VIR_DOMAIN_MEMORY_STAT_DISK_CACHES
* Memory that can be reclaimed without additional I/O, typically disk
* caches (in kb).
- *
+ * VIR_DOMAIN_MEMORY_STAT_HUGETLB_PGALLOC
+ * The amount of successful hugetlb(Huge Page Tables) allocations
+ * VIR_DOMAIN_MEMORY_STAT_HUGETLB_PGFAIL
+ * The amount of failed hugetlb(Huge Page Tables) allocations
* Returns: The number of stats provided or -1 in case of failure.
*/
int
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index f48d9256e4..2d849beac8 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -20245,6 +20245,8 @@ qemuDomainGetStatsBalloon(virQEMUDriverPtr driver,
STORE_MEM_RECORD(LAST_UPDATE, "last-update")
STORE_MEM_RECORD(USABLE, "usable")
STORE_MEM_RECORD(DISK_CACHES, "disk_caches")
+ STORE_MEM_RECORD(HUGETLB_PGALLOC, "hugetlb_pgalloc")
+ STORE_MEM_RECORD(HUGETLB_PGFAIL, "hugetlb_pgfail")
}
#undef STORE_MEM_RECORD
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 908967f46c..5e3df5e759 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -2150,6 +2150,11 @@ int qemuMonitorJSONGetMemoryStats(qemuMonitorPtr mon,
VIR_DOMAIN_MEMORY_STAT_LAST_UPDATE, 1);
GET_BALLOON_STATS(statsdata, "stat-disk-caches",
VIR_DOMAIN_MEMORY_STAT_DISK_CACHES, 1024);
+ GET_BALLOON_STATS(statsdata, "stat-htlb-pgalloc",
+ VIR_DOMAIN_MEMORY_STAT_HUGETLB_PGALLOC, 1);
+ GET_BALLOON_STATS(statsdata, "stat-htlb-pgfail",
+ VIR_DOMAIN_MEMORY_STAT_HUGETLB_PGFAIL, 1);
+
ret = got;
cleanup:
virJSONValueFree(cmd);
diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
index d87475f6f6..0092a9786e 100644
--- a/tools/virsh-domain-monitor.c
+++ b/tools/virsh-domain-monitor.c
@@ -376,6 +376,10 @@ cmdDomMemStat(vshControl *ctl, const vshCmd *cmd)
vshPrint(ctl, "last_update %llu\n", stats[i].val);
if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_DISK_CACHES)
vshPrint(ctl, "disk_caches %llu\n", stats[i].val);
+ if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_HUGETLB_PGALLOC)
+ vshPrint(ctl, "hugetlb_pgalloc %llu\n", stats[i].val);
+ if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_HUGETLB_PGFAIL)
+ vshPrint(ctl, "hugetlb_pgfail %llu\n", stats[i].val);
}
ret = true;
diff --git a/tools/virsh.pod b/tools/virsh.pod
index afc1684db0..ef27c527d6 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -938,6 +938,8 @@ without causing host swapping (in KiB)
last-update - Timestamp of the last update of statistics (in seconds)
disk_caches - The amount of memory that can be reclaimed without
additional I/O, typically disk caches (in KiB)
+ hugetlb_pgalloc - The number of successful huge page table allocations
+ hugetlb_pgfail - The number of failed huge page table allocations
For QEMU/KVM with a memory balloon, setting the optional I<--period> to a
value larger than 0 in seconds will allow the balloon driver to return
--
2.20.1
5 years, 7 months
[libvirt] [PATCH] storage: escape ipv6 for ceph mon hosts to librados
by Yi Li
Hosts for rbd are ceph monitor daemons. These have fixed IP addresses,
so they are often referenced by IP rather than hostname for
convenience, or to avoid relying on DNS. Using IPv4 addresses as the
host name works already, but IPv6 addresses require rbd-specific
escaping because the colon is used as an option separator in the
string passed to librados.
Escape these colons, and enclose the IPv6 address in square brackets
so it is distinguished from the port, which is currently mandatory.
Signed-off-by: Yi Li <yili(a)winhong.com>
---
docs/schemas/storagepool.rng | 5 ++++-
src/storage/storage_backend_rbd.c | 13 ++++++++++---
tests/storagepoolxml2xmlin/pool-rbd-ipv6.xml | 13 +++++++++++++
tests/storagepoolxml2xmlout/pool-rbd-ipv6.xml | 16 ++++++++++++++++
tests/storagepoolxml2xmltest.c | 1 +
5 files changed, 44 insertions(+), 4 deletions(-)
create mode 100644 tests/storagepoolxml2xmlin/pool-rbd-ipv6.xml
create mode 100644 tests/storagepoolxml2xmlout/pool-rbd-ipv6.xml
diff --git a/docs/schemas/storagepool.rng b/docs/schemas/storagepool.rng
index 3ca8e79..976a02b 100644
--- a/docs/schemas/storagepool.rng
+++ b/docs/schemas/storagepool.rng
@@ -305,7 +305,10 @@
<oneOrMore>
<element name='host'>
<attribute name='name'>
- <text/>
+ <choice>
+ <ref name="dnsName"/>
+ <ref name="ipAddr"/>
+ </choice>
</attribute>
<optional>
<attribute name='port'>
diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c
index f8c968e..3056563 100644
--- a/src/storage/storage_backend_rbd.c
+++ b/src/storage/storage_backend_rbd.c
@@ -268,9 +268,16 @@ virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDStatePtr ptr,
source->hosts[i].name);
} else if (source->hosts[i].name != NULL &&
source->hosts[i].port) {
- virBufferAsprintf(&mon_host, "%s:%d,",
- source->hosts[i].name,
- source->hosts[i].port);
+ /* assume host containing : is ipv6 */
+ if (strchr(source->hosts[i].name, ':')) {
+ virBufferAsprintf(&mon_host, "[%s]:%d,",
+ source->hosts[i].name,
+ source->hosts[i].port);
+ } else {
+ virBufferAsprintf(&mon_host, "%s:%d,",
+ source->hosts[i].name,
+ source->hosts[i].port);
+ }
} else {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("received malformed monitor, check the XML definition"));
diff --git a/tests/storagepoolxml2xmlin/pool-rbd-ipv6.xml b/tests/storagepoolxml2xmlin/pool-rbd-ipv6.xml
new file mode 100644
index 0000000..0744b33
--- /dev/null
+++ b/tests/storagepoolxml2xmlin/pool-rbd-ipv6.xml
@@ -0,0 +1,13 @@
+<pool type='rbd'>
+ <name>ceph</name>
+ <uuid>47c1faee-0207-e741-f5ae-d9b019b98fe2</uuid>
+ <source>
+ <name>rbd</name>
+ <host name='localhost' port='6789'/>
+ <host name='localhost' port='6790'/>
+ <host name='2205::192:168:205:141' port='6789'/>
+ <auth username='admin' type='ceph'>
+ <secret uuid='2ec115d7-3a88-3ceb-bc12-0ac909a6fd87'/>
+ </auth>
+ </source>
+</pool>
diff --git a/tests/storagepoolxml2xmlout/pool-rbd-ipv6.xml b/tests/storagepoolxml2xmlout/pool-rbd-ipv6.xml
new file mode 100644
index 0000000..cc2a379
--- /dev/null
+++ b/tests/storagepoolxml2xmlout/pool-rbd-ipv6.xml
@@ -0,0 +1,16 @@
+<pool type='rbd'>
+ <name>ceph</name>
+ <uuid>47c1faee-0207-e741-f5ae-d9b019b98fe2</uuid>
+ <capacity unit='bytes'>0</capacity>
+ <allocation unit='bytes'>0</allocation>
+ <available unit='bytes'>0</available>
+ <source>
+ <host name='localhost' port='6789'/>
+ <host name='localhost' port='6790'/>
+ <host name='2205::192:168:205:141' port='6789'/>
+ <name>rbd</name>
+ <auth type='ceph' username='admin'>
+ <secret uuid='2ec115d7-3a88-3ceb-bc12-0ac909a6fd87'/>
+ </auth>
+ </source>
+</pool>
diff --git a/tests/storagepoolxml2xmltest.c b/tests/storagepoolxml2xmltest.c
index 2ae514f..b6f4cb4 100644
--- a/tests/storagepoolxml2xmltest.c
+++ b/tests/storagepoolxml2xmltest.c
@@ -95,6 +95,7 @@ mymain(void)
DO_TEST("pool-zfs-sourcedev");
DO_TEST("pool-rbd");
#ifdef WITH_STORAGE_RBD
+ DO_TEST("pool-rbd-ipv6");
DO_TEST("pool-rbd-refresh-volume-allocation");
DO_TEST("pool-rbd-ns-configopts");
#endif
--
2.7.5
5 years, 8 months
[libvirt] [PATCH] virsh: Put a new line char after <alias/> in attach-disk
by Michal Privoznik
Each attribute is on its own line. We forgot to add new line
character for <alias/>
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
Pushed under trivial rule.
tools/virsh-domain.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index da57d96d1a..82140feb57 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -683,7 +683,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
virBufferAsprintf(&buf, "<serial>%s</serial>\n", serial);
if (alias)
- virBufferAsprintf(&buf, "<alias name='%s'/>", alias);
+ virBufferAsprintf(&buf, "<alias name='%s'/>\n", alias);
if (wwn)
virBufferAsprintf(&buf, "<wwn>%s</wwn>\n", wwn);
--
2.21.0
5 years, 8 months
[libvirt] [PATCH 0/2] Couple of interface type fixes
by Michal Privoznik
See the following link for more info:
https://www.redhat.com/archives/libvir-list/2019-April/msg01412.html
Be aware that these are very hackish and I don't like them.
There's still one problem - virsh domiftune still doesn't work, as in it
doesn't set floor on the network bridge because the code expects
interface type of network but it sees type bridge.
Michal Prívozník (2):
conf: Parse bandwidth.floor for interface type='bridge' too
qemu: Relax interface type change check when changing an interface
src/conf/domain_conf.c | 7 ++++---
src/qemu/qemu_hotplug.c | 2 +-
2 files changed, 5 insertions(+), 4 deletions(-)
--
2.21.0
5 years, 8 months
[libvirt] RFC: Introducing Memory Bandwidth Monitoring (MBM)
by Huaqiang,Wang
RFC: Introducing Memory Bandwidth Monitoring (MBM)
==================================================
Kernel has removed the interfaces of getting memory bandwidth utilization
interfaces from `perf` sub-module, refer to
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?....
Afterwards, kernel implements the `resctrl` sub-module and provides the
alternative interfaces to allocate/monitor resource of cache/memory
bandwidth.
The cache monitoring based on `resctr` interface is already implemented,
this
RFC is to raise discussion on implement the memory bandwidth monitoring
functionality.
Very similar to the way of implementing 'cache monitoring', to support
memory
bandwidth monitoring, it could be considered in three aspects:
* Identifying the host capability for MBM
* Creating MBM groups
* Reporting the result of the monitoring
Identify the host capability of MBM
-----------------------------------
Host MBM feature coud be identified through the standard way of enumerating
host capability, such as command `virsh capability <domain>`.
A host with MBM, the result of command above may contain following lines::
<capabilities>
<host>
…
<cache>
<bank id='0' level='3' type='both' size='15' unit='MiB' cpus='0-5'>
<control granularity='768' min='1536' unit='KiB' type='both'
maxAllocs='4'/>
</bank>
<monitor level='3' reuseThreshold='270336' maxMonitors='176'>
<feature name='llc_occupancy'/>
</monitor>
</cache>
<memory_bandwidth>
<node id='0' cpus='0-5'>
<control granularity='10' min ='10' maxAllocs='4'/>
</node>
<node id='1' cpus='6-11'>
<control granularity='10' min ='10' maxAllocs='4'/>
</node>
+ <monitor maxMonitors='176'>
+ <feature name='mbm_total_bytes'/>
+ <feature name='mbm_local_bytes'/>
+ </monitor>
</memory_bandwidth>
</host>
</capabilities>
The <monitor> element under <memory_bandwidth> indicates a memory bandwidth
monitor exists, and the property 'maxMonitors' tells how many monitors
could be
generated, which is shared with cache monitor.
The feature list inside the <monitor> element indicates MBM feature set.
Create the MBM group
--------------------
It is supported to create multiple monitors to a vm instance and each
monitor
is capable to track the memory bandwidth utilization accumulatively in bytes
for specific vCPUs.
To create a memory bandwidth monitor for specific vCPUs, for example
create 2
memory bandwidth monitors, one is tracking the memory BW usage for vCPU0 and
another is for vCPU 0-4, then you can set the request for two monitors in
following way by editing the domain XML file::
<cputune>
<memorytune vcpus='0-4'>
<node id='0' bandwidth='20'/>
<node id='1' bandwidth='30'/>
+ <monitor vcpus='0-4'/>
+ <monitor vcpus='0'/>
</memorytune>
</cputune>
Report the result of monitor
----------------------------
The statistical results of memory bandwidth monitors could be demonstrated
through command `virsh domstat <doman>` in following arrangement.
virsh domstats <domain>::
...
memory.bw.monitor.count=<total number of MBM monitors>
memory.bw.monitor.<monitor index>.name=<resctrl group name for this
monitor>
memory.bw.monitor.<monitor index>.vcpus=<vcpu set list monitored by
this monitor>
memory.bw.monitor.<monitor index>.controller.count=<memory controller
number>
memory.bw.monitor.<monitor index>.controller.<index>.local.bytes=<bytes>
memory.bw.monitor.<monitor index>.controller.<index>.total.bytes=<bytes>
...
5 years, 8 months