[libvirt] [PATCH] Handle copying bitmaps to larger data buffers
by Allen, John
If a bitmap of a shorter length than the data buffer is passed to
virBitmapToDataBuf, it will read off the end of the bitmap and copy junk
into the returned buffer. Add a check to only copy the length of the
bitmap to the buffer.
The problem can be observed after setting a vcpu affinity using the vcpupin
command on a system with a large number of cores:
# virsh vcpupin example_domain 0 0
# virsh vcpupin example_domain 0
VCPU CPU Affinity
---------------------------
0 0,192,197-198,202
Signed-off-by: John Allen <john.allen(a)amd.com>
---
diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
index d074f29e54..021174cbb3 100644
--- a/src/util/virbitmap.c
+++ b/src/util/virbitmap.c
@@ -824,11 +824,15 @@ virBitmapToDataBuf(virBitmapPtr bitmap,
unsigned char *bytes,
size_t len)
{
+ size_t nbytes = bitmap->map_len * (VIR_BITMAP_BITS_PER_UNIT / CHAR_BIT);
unsigned long *l;
size_t i, j;
memset(bytes, 0, len);
+ /* If bitmap and buffer differ in size, only fill to the smaller length */
+ len = MIN(len, nbytes);
+
/* htole64 is not provided by gnulib, so we do the conversion by hand */
l = bitmap->map;
for (i = j = 0; i < len; i++, j++) {
5 years, 7 months
[libvirt] [PATCH] cpu_map: Add support for cldemote CPU feature
by Jiri Denemark
Added in QEMU by v2.12.0-481-g0da0fb0628 (released in 3.0).
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/cpu_map/x86_features.xml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/cpu_map/x86_features.xml b/src/cpu_map/x86_features.xml
index 02431bea29..efcc10b1ae 100644
--- a/src/cpu_map/x86_features.xml
+++ b/src/cpu_map/x86_features.xml
@@ -310,6 +310,9 @@
<feature name='la57'>
<cpuid eax_in='0x07' ecx_in='0x00' ecx='0x00010000'/>
</feature>
+ <feature name='cldemote'>
+ <cpuid eax_in='0x07' ecx_in='0x00' ecx='0x02000000'/>
+ </feature>
<feature name='avx512-4vnniw'>
<cpuid eax_in='0x07' ecx_in='0x00' edx='0x00000004'/>
--
2.21.0
5 years, 7 months
[libvirt] [PATCH v4 0/3] Don't pm suspend guest if it's unable to wake up
by Daniel Henrique Barboza
changes from v3:
- patch 3 removed. We no longer consider PM_WAKEUP_SUPPORT a
cap. It is confusing to have a 'runtime cap' that can't be resolved
inside qemu_capabilities.c. The suspend operation isn't time
critical per se, and a call to QMP each time 'virsh dompmsuspend'
is executed is not dreadful to the user experience. More information
and discussion can be found at [1].
- due to the change above, patch 4 now executes the
query-current-machine QMP call (if the running QEMU instance supports
it) during qemuDomainPMSuspendForDuration to check if the guest
has wakeup support.
- previous patch link:
[1] https://www.redhat.com/archives/libvir-list/2019-April/msg00767.html
Daniel Henrique Barboza (2):
qemu_capabilities: Add QEMU_CAPS_QUERY_CURRENT_MACHINE
qemuDomainPMSuspendForDuration: check for wake-up support
Michal Prívozník (1):
qemu_monitor: Introduce handler for 'query-current-machine' command
src/qemu/qemu_capabilities.c | 2 +
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_driver.c | 54 +++++++++++++++++++
src/qemu/qemu_monitor.c | 10 ++++
src/qemu/qemu_monitor.h | 9 ++++
src/qemu/qemu_monitor_json.c | 50 +++++++++++++++++
src/qemu/qemu_monitor_json.h | 5 ++
.../caps_4.0.0.riscv32.xml | 1 +
.../caps_4.0.0.riscv64.xml | 1 +
.../caps_4.0.0.x86_64.xml | 1 +
10 files changed, 134 insertions(+)
--
2.20.1
5 years, 7 months
[libvirt] [PATCH] vircgroup: no need to ifdef virCgroupFree
by Pavel Hrdina
virCgroup struct is always defined and the free function is not calling
anything that would require OS supporting cgroups.
This fixes an issue if we try to start a VM with QEMU binary that
doesn't support QXL. The start operation will fail in
qemuProcessStartValidateVideo() which will set correct error message,
but later in one of the cleanup paths we will call
qemuDomainObjPrivateDataClear() which always calls virCgroupFree()
and that will fail on OS that doesn't support cgroups and it will
set a new error which will be eventually reported to user.
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
src/util/vircgroup.c | 62 +++++++++++++++++++-------------------------
1 file changed, 27 insertions(+), 35 deletions(-)
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 4238d7014b..f58e336404 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -1279,33 +1279,6 @@ virCgroupNewIgnoreError(void)
}
-/**
- * virCgroupFree:
- *
- * @group: The group structure to free
- */
-void
-virCgroupFree(virCgroupPtr *group)
-{
- size_t i;
-
- if (*group == NULL)
- return;
-
- for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
- VIR_FREE((*group)->legacy[i].mountPoint);
- VIR_FREE((*group)->legacy[i].linkPoint);
- VIR_FREE((*group)->legacy[i].placement);
- }
-
- VIR_FREE((*group)->unified.mountPoint);
- VIR_FREE((*group)->unified.placement);
-
- VIR_FREE((*group)->path);
- VIR_FREE(*group);
-}
-
-
/**
* virCgroupHasController: query whether a cgroup controller is present
*
@@ -2917,14 +2890,6 @@ virCgroupNewIgnoreError(void)
}
-void
-virCgroupFree(virCgroupPtr *group ATTRIBUTE_UNUSED)
-{
- virReportSystemError(ENXIO, "%s",
- _("Control groups not supported on this platform"));
-}
-
-
bool
virCgroupHasController(virCgroupPtr cgroup ATTRIBUTE_UNUSED,
int controller ATTRIBUTE_UNUSED)
@@ -3565,6 +3530,33 @@ virCgroupControllerAvailable(int controller ATTRIBUTE_UNUSED)
#endif /* !__linux__ */
+/**
+ * virCgroupFree:
+ *
+ * @group: The group structure to free
+ */
+void
+virCgroupFree(virCgroupPtr *group)
+{
+ size_t i;
+
+ if (*group == NULL)
+ return;
+
+ for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
+ VIR_FREE((*group)->legacy[i].mountPoint);
+ VIR_FREE((*group)->legacy[i].linkPoint);
+ VIR_FREE((*group)->legacy[i].placement);
+ }
+
+ VIR_FREE((*group)->unified.mountPoint);
+ VIR_FREE((*group)->unified.placement);
+
+ VIR_FREE((*group)->path);
+ VIR_FREE(*group);
+}
+
+
int
virCgroupDelThread(virCgroupPtr cgroup,
virCgroupThreadName nameval,
--
2.20.1
5 years, 7 months
[libvirt] [PATCH] storage: escape ipv6 for ceph mon hosts to librados
by winhong-yili
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, 7 months
[libvirt] [PATCH] conf: add cpu check attribute to ABI check
by Nikolay Shirokovskiy
Different check values is not ABI compatible. For example
if on migration we change 'full' to 'partial' then guest cpu
on destination can be different.
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy(a)virtuozzo.com>
---
src/conf/cpu_conf.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
index 33c8b99..bd2beab 100644
--- a/src/conf/cpu_conf.c
+++ b/src/conf/cpu_conf.c
@@ -894,6 +894,13 @@ virCPUDefIsEqual(virCPUDefPtr src,
goto cleanup;
}
+ if (src->check != dst->check) {
+ MISMATCH(_("Target CPU check %s does not match source %s"),
+ virCPUCheckTypeToString(dst->check),
+ virCPUCheckTypeToString(src->check));
+ goto cleanup;
+ }
+
if (src->arch != dst->arch) {
MISMATCH(_("Target CPU arch %s does not match source %s"),
virArchToString(dst->arch),
--
1.8.3.1
5 years, 7 months
[libvirt] JVM crashes during GC
by Sachin Soman
Hi,
Could you tell me if the following is some known issue?
While performing the following simple test, I see my JVM crashing
(consistently):
1. Open a connection to an ESXi driver/host (passing ConnectAuthDefault
instance).
2. Close the connection.
3. Invoke GC
When GC is triggered, at some point, some unallocated native memory is
being tried to release. That's failing.
The error thrown is:
java(78745,0x70000241e000) malloc: *** error for object 0x7fd5df561390:
pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Frames from core dump:
frame #0: 0x00007fff5b274b66 libsystem_kernel.dylib`__pthread_kill + 10
frame #1: 0x00007fff5b43f080 libsystem_pthread.dylib`pthread_kill + 333
frame #2: 0x00007fff5b1d01ae libsystem_c.dylib`abort + 127
frame #3: 0x00007fff5b2ce8a6 libsystem_malloc.dylib`free + 521
frame #4: 0x00000001127f43a7
frame #5: 0x00000001127e3ffd
frame #6: 0x00000001127e3ffd
frame #7: 0x00000001127e3ffd
frame #8: 0x00000001127e3ffd
frame #9: 0x00000001127e4042
frame #10: 0x00000001127e3ffd
frame #11: 0x00000001127e3ffd
frame #12: 0x00000001127dc4e7
frame #13: 0x000000010c0e235e
libjvm.dylib`JavaCalls::call_helper(JavaValue*, methodHandle*,
JavaCallArguments*, Thread*) + 1710
frame #14: 0x000000010c0e2b02
libjvm.dylib`JavaCalls::call_virtual(JavaValue*, KlassHandle, Symbol*,
Symbol*, JavaCallArguments*, Thread*) + 356
frame #15: 0x000000010c0e2cae
libjvm.dylib`JavaCalls::call_virtual(JavaValue*, Handle, KlassHandle,
Symbol*, Symbol*, Thread*) + 74
frame #16: 0x000000010c1208ee libjvm.dylib`thread_entry(JavaThread*,
Thread*) + 124
frame #17: 0x000000010c33e84d
libjvm.dylib`JavaThread::thread_main_inner() + 155
frame #18: 0x000000010c33ff12 libjvm.dylib`JavaThread::run() + 448
frame #19: 0x000000010c26058a libjvm.dylib`java_start(Thread*) + 246
frame #20: 0x00007fff5b43c661 libsystem_pthread.dylib`_pthread_body +
340
frame #21: 0x00007fff5b43c50d libsystem_pthread.dylib`_pthread_start +
377
frame #22: 0x00007fff5b43bbf9 libsystem_pthread.dylib`thread_start + 13
I have installed Libvirt 5.2.0.
Java bindings libvirt-java 0.5.1
JNA 4.0.0
Tested Java environments: Oracle Java 8 and OpenJDK 8 on MAC, OpenJDK 11 on
Ubuntu 16
Thanks & Regards
Sachin Soman
5 years, 7 months
[libvirt] [PATCH] networkStartNetworkVirtual: Don't overwrite error in 'err5'
by Michal Privoznik
If there's an error when setting up QoS on a bridge the control
jumps over to 'err5' label. Here, the virNetDevBandwidthClear()
is called to clear out any partially set QoS. This function can
also report an error which would overwrite the actual error that
caused us jumping here. 🤦 Use virErrorPreserveLast() to preserve
the original error.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/network/bridge_driver.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index ce4f4890f1..77206b4584 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -2493,6 +2493,7 @@ networkStartNetworkVirtual(virNetworkDriverStatePtr driver,
return 0;
err5:
+ virErrorPreserveLast(&save_err);
if (def->bandwidth)
virNetDevBandwidthClear(def->bridge);
--
2.21.0
5 years, 7 months
[libvirt] [PATCH 0/3] Emit event on lease attach/detach
by Michal Privoznik
Unfortunately, we can't emit VIR_DOMAIN_EVENT_ID_DEVICE_ADDED or
VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED event because that carries device
alias within itself and leases don't have one.
Michal Prívozník (3):
qemuDomainAttachDeviceLive: Rework event emitting
Introduce VIR_DOMAIN_EVENT_ID_LEASE_CHANGE
qemu: Emit event on lease attach/detach
examples/object-events/event-test.c | 34 +++++++++++
include/libvirt/libvirt-domain.h | 33 +++++++++++
src/conf/domain_event.c | 89 +++++++++++++++++++++++++++++
src/conf/domain_event.h | 12 ++++
src/libvirt_private.syms | 2 +
src/qemu/qemu_driver.c | 43 +++++++-------
src/qemu/qemu_hotplug.c | 7 +++
src/remote/remote_daemon_dispatch.c | 40 +++++++++++++
src/remote/remote_driver.c | 32 +++++++++++
src/remote/remote_protocol.x | 16 +++++-
src/remote_protocol-structs | 8 +++
tools/virsh-domain.c | 31 ++++++++++
12 files changed, 325 insertions(+), 22 deletions(-)
--
2.21.0
5 years, 7 months
[libvirt] [PATCH v1] network: Convert to virErrorRestore/virErrorPreserveLast
by Syed Humaid
Replaced usage of virSaveLastError and virSetError/virFreeError with
virErrorPreserveLast and virErrorRestore respectively.
Signed-off-by: Syed Humaid <syedhumaidbinharoon(a)gmail.com>
---
src/network/bridge_driver.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index f824b8b4f3..dc21ac642c 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -2495,7 +2495,7 @@ networkStartNetworkVirtual(virNetworkDriverStatePtr driver,
err4:
if (!save_err)
- save_err = virSaveLastError();
+ virErrorPreserveLast(&save_err);
dnsmasqPid = virNetworkObjGetDnsmasqPid(obj);
if (dnsmasqPid > 0) {
@@ -2505,18 +2505,18 @@ networkStartNetworkVirtual(virNetworkDriverStatePtr driver,
err3:
if (!save_err)
- save_err = virSaveLastError();
+ virErrorPreserveLast(&save_err);
ignore_value(virNetDevSetOnline(def->bridge, 0));
err2:
if (!save_err)
- save_err = virSaveLastError();
+ virErrorPreserveLast(&save_err);
if (def->forward.type != VIR_NETWORK_FORWARD_OPEN)
networkRemoveFirewallRules(def);
err1:
if (!save_err)
- save_err = virSaveLastError();
+ virErrorPreserveLast(&save_err);
if (macTapIfName) {
VIR_FORCE_CLOSE(tapfd);
@@ -2528,13 +2528,10 @@ networkStartNetworkVirtual(virNetworkDriverStatePtr driver,
err0:
if (!save_err)
- save_err = virSaveLastError();
+ virErrorPreserveLast(&save_err);
ignore_value(virNetDevBridgeDelete(def->bridge));
- if (save_err) {
- virSetError(save_err);
- virFreeError(save_err);
- }
+ virErrorRestore(&save_err);
/* coverity[leaked_handle] - 'tapfd' is not leaked */
return -1;
}
--
2.20.1
5 years, 7 months