[GSoC][PATCH 0/7] Making `qemu_domainjob` hypervisor-agnostic
by Prathamesh Chavan
Following are a series of patches aimed to make qemu_domainjob
hypervisor agnostic, and create a virdomainjob file in the future
which handles domain-jobs.
Prathamesh Chavan (7):
qemu_domain: Added `qemuDomainJobInfo` to domainJob's `privateData`
qemu_domainjob: added maxQueuedJobs and jobs_queued to `qemuDomainJob`
qemu_domainjob: add `saveDomainStatus` as a callback function to jobs
qemu_domain: funciton declarations moved to correct file
qemu_domainjob: added `getDomainXMLOptionPtr` callback function
qemu_domainjob: removed reference to `qemuDomainObjPrivatePtr`
virmigraiton: `qemuMigrationJobPhase` transformed for more generic use
src/hypervisor/meson.build | 1 +
src/hypervisor/virmigration.c | 41 ++
src/hypervisor/virmigration.h | 38 +
src/libvirt_private.syms | 4 +
src/qemu/MIGRATION.txt | 8 +-
src/qemu/qemu_backup.c | 72 +-
src/qemu/qemu_backup.h | 3 +-
src/qemu/qemu_block.c | 45 +-
src/qemu/qemu_block.h | 6 +-
src/qemu/qemu_blockjob.c | 45 +-
src/qemu/qemu_blockjob.h | 3 +-
src/qemu/qemu_checkpoint.c | 29 +-
src/qemu/qemu_domain.c | 595 ++++++++++++++--
src/qemu/qemu_domain.h | 106 ++-
src/qemu/qemu_domainjob.c | 845 +++++-----------------
src/qemu/qemu_domainjob.h | 152 ++--
src/qemu/qemu_driver.c | 1127 ++++++++++++++++--------------
src/qemu/qemu_hotplug.c | 319 ++++-----
src/qemu/qemu_hotplug.h | 30 +-
src/qemu/qemu_migration.c | 438 ++++++------
src/qemu/qemu_migration.h | 29 +-
src/qemu/qemu_migration_cookie.c | 15 +-
src/qemu/qemu_migration_params.c | 48 +-
src/qemu/qemu_migration_params.h | 15 +-
src/qemu/qemu_process.c | 364 +++++-----
src/qemu/qemu_process.h | 15 +-
tests/qemuhotplugtest.c | 2 +-
27 files changed, 2211 insertions(+), 2184 deletions(-)
create mode 100644 src/hypervisor/virmigration.c
create mode 100644 src/hypervisor/virmigration.h
--
2.25.1
4 years, 2 months
[PATCH] tools: fix libvirt-guests.sh text assignments
by Christian Ehrhardt
In libvirt 6.6 stopping guests with libvirt-guests.sh is broken.
As soon as there is more than one guest one can see
`systemctl stop libvirt-guests` faiing and in the log we see:
libvirt-guests.sh[2455]: Running guests on default URI:
libvirt-guests.sh[2457]: /usr/lib/libvirt/libvirt-guests.sh: 120:
local: 2a49cb0f-1ff8-44b5-a61d-806b9e52dae2: bad variable name
libvirt-guests.sh[2462]: no running guests.
That is due do mutliple guests becoming a list of UUIDs. Without
recognizing this as one single string the assignment breaks when using 'local'
(which was recently added in 6.3.0). This is because local is defined as
local [option] [name[=value] ... | - ]
which makes the shell trying handle the further part of the string as
variable names. In the error above that string isn't a valid variable
name triggering the issue that is seen.
To resolve that 'textify' all assignments that are strings or potentially
can become such lists (even if they are not using the local qualifier).
Fixes: 08071ec0 "tools: variables clean-up in libvirt-guests script"
Signed-off-by: Christian Ehrhardt <christian.ehrhardt(a)canonical.com>
---
tools/libvirt-guests.sh.in | 136 ++++++++++++++++++-------------------
1 file changed, 68 insertions(+), 68 deletions(-)
diff --git a/tools/libvirt-guests.sh.in b/tools/libvirt-guests.sh.in
index 534c4d5e0f..d69df908d2 100644
--- a/tools/libvirt-guests.sh.in
+++ b/tools/libvirt-guests.sh.in
@@ -30,9 +30,9 @@ test ! -r "$sysconfdir"/rc.d/init.d/functions ||
export TEXTDOMAIN="@PACKAGE@" TEXTDOMAINDIR="@localedir@"
-URIS=default
-ON_BOOT=start
-ON_SHUTDOWN=suspend
+URIS="default"
+ON_BOOT="start"
+ON_SHUTDOWN="suspend"
SHUTDOWN_TIMEOUT=300
PARALLEL_SHUTDOWN=0
START_DELAY=0
@@ -65,7 +65,7 @@ retval() {
# If URI is "default" virsh is called without the "-c" argument
# (using libvirt's default connection)
run_virsh() {
- local uri=$1
+ local uri="$1"
shift
if [ "x$uri" = xdefault ]; then
@@ -86,7 +86,7 @@ run_virsh_c() {
# check if URI is reachable
test_connect()
{
- local uri=$1
+ local uri="$1"
if run_virsh "$uri" connect 2>/dev/null; then
return 0;
@@ -103,9 +103,9 @@ test_connect()
# --transient: list only transient guests
# [none]: list both persistent and transient guests
list_guests() {
- local uri=$1
- local persistent=$2
- local list=$(run_virsh_c "$uri" list --uuid $persistent)
+ local uri="$1"
+ local persistent="$2"
+ local list="$(run_virsh_c "$uri" list --uuid $persistent)"
if [ $? -ne 0 ]; then
RETVAL=1
@@ -118,8 +118,8 @@ list_guests() {
# guest_name URI UUID
# return name of guest UUID on URI
guest_name() {
- local uri=$1
- local uuid=$2
+ local uri="$1"
+ local uuid="$2"
run_virsh "$uri" domname "$uuid" 2>/dev/null
}
@@ -128,17 +128,17 @@ guest_name() {
# check if guest UUID on URI is running
# Result is returned by variable "guest_running"
guest_is_on() {
- local uri=$1
- local uuid=$2
- local id=$(run_virsh "$uri" domid "$uuid")
+ local uri="$1"
+ local uuid="$2"
+ local id="$(run_virsh "$uri" domid "$uuid")"
- guest_running=false
+ guest_running="false"
if [ $? -ne 0 ]; then
RETVAL=1
return 1
fi
- [ -n "$id" ] && [ "x$id" != x- ] && guest_running=true
+ [ -n "$id" ] && [ "x$id" != x- ] && guest_running="true"
return 0
}
@@ -151,9 +151,9 @@ started() {
# start
# Start or resume the guests
start() {
- local isfirst=true
+ local isfirst="true"
local bypass=
- local sync_time=false
+ local sync_time="false"
local uri=
local list=
@@ -167,10 +167,10 @@ start() {
return 0
fi
- test "x$BYPASS_CACHE" = x0 || bypass=--bypass-cache
- test "x$SYNC_TIME" = x0 || sync_time=true
+ test "x$BYPASS_CACHE" = x0 || bypass="--bypass-cache"
+ test "x$SYNC_TIME" = x0 || sync_time="true"
while read uri list; do
- local configured=false
+ local configured="false"
local confuri=
local guest=
@@ -178,7 +178,7 @@ start() {
for confuri in $URIS; do
set +f
if [ "x$confuri" = "x$uri" ]; then
- configured=true
+ configured="true"
break
fi
done
@@ -192,14 +192,14 @@ start() {
eval_gettext "Resuming guests on \$uri URI..."; echo
for guest in $list; do
- local name=$(guest_name "$uri" "$guest")
+ local name="$(guest_name "$uri" "$guest")"
eval_gettext "Resuming guest \$name: "
if guest_is_on "$uri" "$guest"; then
if "$guest_running"; then
gettext "already active"; echo
else
if "$isfirst"; then
- isfirst=false
+ isfirst="false"
else
sleep $START_DELAY
fi
@@ -223,25 +223,25 @@ start() {
# was saved.
suspend_guest()
{
- local uri=$1
- local guest=$2
- local name=$(guest_name "$uri" "$guest")
- local label=$(eval_gettext "Suspending \$name: ")
+ local uri="$1"
+ local guest="$2"
+ local name="$(guest_name "$uri" "$guest")"
+ local label="$(eval_gettext "Suspending \$name: ")"
local bypass=
local slept=0
- test "x$BYPASS_CACHE" = x0 || bypass=--bypass-cache
+ test "x$BYPASS_CACHE" = x0 || bypass="--bypass-cache"
printf '%s...\n' "$label"
run_virsh "$uri" managedsave $bypass "$guest" >/dev/null &
- local virsh_pid=$!
+ local virsh_pid="$!"
while true; do
sleep 1
kill -0 "$virsh_pid" >/dev/null 2>&1 || break
slept=$(($slept + 1))
if [ $(($slept % 5)) -eq 0 ]; then
- local progress=$(run_virsh_c "$uri" domjobinfo "$guest" 2>/dev/null | \
- awk '/^Data processed:/{print $3, $4}')
+ local progress="$(run_virsh_c "$uri" domjobinfo "$guest" 2>/dev/null | \
+ awk '/^Data processed:/{print $3, $4}')"
if [ -n "$progress" ]; then
printf '%s%s\n' "$label" "$progress"
else
@@ -257,11 +257,11 @@ suspend_guest()
# was successfully shutdown or the timeout defined by $SHUTDOWN_TIMEOUT expired.
shutdown_guest()
{
- local uri=$1
- local guest=$2
- local name=$(guest_name "$uri" "$guest")
- local timeout=$SHUTDOWN_TIMEOUT
- local check_timeout=false
+ local uri="$1"
+ local guest="$2"
+ local name="$(guest_name "$uri" "$guest")"
+ local timeout="$SHUTDOWN_TIMEOUT"
+ local check_timeout="false"
local format=
local slept=
@@ -270,11 +270,11 @@ shutdown_guest()
retval run_virsh "$uri" shutdown "$guest" >/dev/null || return
if [ $timeout -gt 0 ]; then
- check_timeout=true
- format=$(eval_gettext "Waiting for guest %s to shut down, %d seconds left\n")
+ check_timeout="true"
+ format="$(eval_gettext "Waiting for guest %s to shut down, %d seconds left\n")"
else
slept=0
- format=$(eval_gettext "Waiting for guest %s to shut down\n")
+ format="$(eval_gettext "Waiting for guest %s to shut down\n")"
fi
while ! $check_timeout || [ "$timeout" -gt 0 ]; do
sleep 1
@@ -309,9 +309,9 @@ shutdown_guest()
# was issued to libvirt to allow parallel shutdown.
shutdown_guest_async()
{
- local uri=$1
- local guest=$2
- local name=$(guest_name "$uri" "$guest")
+ local uri="$1"
+ local guest="$2"
+ local name="$(guest_name "$uri" "$guest")"
eval_gettext "Starting shutdown on guest: \$name"
echo
@@ -332,8 +332,8 @@ guest_count()
# Result is returned in "guests_shutting_down"
check_guests_shutdown()
{
- local uri=$1
- local guests_to_check=$2
+ local uri="$1"
+ local guests_to_check="$2"
local guest=
guests_shutting_down=
@@ -354,9 +354,9 @@ check_guests_shutdown()
# a shutdown complete notice for guests that have finished
print_guests_shutdown()
{
- local uri=$1
- local before=$2
- local after=$3
+ local uri="$1"
+ local before="$2"
+ local after="$3"
local guest=
for guest in $before; do
@@ -364,7 +364,7 @@ print_guests_shutdown()
*" $guest "*) continue;;
esac
- local name=$(guest_name "$uri" "$guest")
+ local name="$(guest_name "$uri" "$guest")"
if [ -n "$name" ]; then
eval_gettext "Shutdown of guest \$name complete."
echo
@@ -376,28 +376,28 @@ print_guests_shutdown()
# Shutdown guests GUESTS on machine URI in parallel
shutdown_guests_parallel()
{
- local uri=$1
- local guests=$2
+ local uri="$1"
+ local guests="$2"
local on_shutdown=
- local check_timeout=false
- local timeout=$SHUTDOWN_TIMEOUT
+ local check_timeout="false"
+ local timeout="$SHUTDOWN_TIMEOUT"
local slept=
local format=
if [ $timeout -gt 0 ]; then
- check_timeout=true
- format=$(eval_gettext "Waiting for %d guests to shut down, %d seconds left\n")
+ check_timeout="true"
+ format="$(eval_gettext "Waiting for %d guests to shut down, %d seconds left\n")"
else
slept=0
- format=$(eval_gettext "Waiting for %d guests to shut down\n")
+ format="$(eval_gettext "Waiting for %d guests to shut down\n")"
fi
while [ -n "$on_shutdown" ] || [ -n "$guests" ]; do
while [ -n "$guests" ] &&
[ $(guest_count "$on_shutdown") -lt "$PARALLEL_SHUTDOWN" ]; do
set -- $guests
- local guest=$1
+ local guest="$1"
shift
- guests=$*
+ guests="$*"
if [ -z "$(echo $on_shutdown | grep $guest)" ] &&
[ -n "$(guest_name "$uri" "$guest")" ]; then
shutdown_guest_async "$uri" "$guest"
@@ -428,7 +428,7 @@ shutdown_guests_parallel()
fi
fi
- local on_shutdown_prev=$on_shutdown
+ local on_shutdown_prev="$on_shutdown"
check_guests_shutdown "$uri" "$on_shutdown"
on_shutdown="$guests_shutting_down"
print_guests_shutdown "$uri" "$on_shutdown_prev" "$on_shutdown"
@@ -438,14 +438,14 @@ shutdown_guests_parallel()
# stop
# Shutdown or save guests on the configured uris
stop() {
- local suspending=true
+ local suspending="true"
local uri=
# last stop was not followed by start
[ -f "$LISTFILE" ] && return 0
if [ "x$ON_SHUTDOWN" = xshutdown ]; then
- suspending=false
+ suspending="false"
if [ $SHUTDOWN_TIMEOUT -lt 0 ]; then
gettext "SHUTDOWN_TIMEOUT must be equal or greater than 0"
echo
@@ -463,13 +463,13 @@ stop() {
eval_gettext "Running guests on \$uri URI: "
- local list=$(list_guests "$uri")
+ local list="$(list_guests "$uri")"
if [ $? -eq 0 ]; then
local empty=true
for uuid in $list; do
"$empty" || printf ", "
printf %s "$(guest_name "$uri" "$uuid")"
- empty=false
+ empty="false"
done
if "$empty"; then
@@ -479,15 +479,15 @@ stop() {
fi
if "$suspending"; then
- local transient=$(list_guests "$uri" "--transient")
+ local transient="$(list_guests "$uri" "--transient")"
if [ $? -eq 0 ]; then
- local empty=true
+ local empty="true"
local uuid=
for uuid in $transient; do
if "$empty"; then
eval_gettext "Not suspending transient guests on URI: \$uri: "
- empty=false
+ empty="false"
else
printf ", "
fi
@@ -495,7 +495,7 @@ stop() {
done
echo
# reload domain list to contain only persistent guests
- list=$(list_guests "$uri" "--persistent")
+ list="$(list_guests "$uri" "--persistent")"
if [ $? -ne 0 ]; then
eval_gettext "Failed to list persistent guests on \$uri"
echo
@@ -582,7 +582,7 @@ rh_status() {
# usage [val]
# Display usage string, then exit with VAL (defaults to 2).
usage() {
- local program_name=$0
+ local program_name="$0"
eval_gettext "Usage: \$program_name {start|stop|status|restart|"\
"condrestart|try-restart|reload|force-reload|gueststatus|shutdown}"; echo
exit ${1-2}
@@ -612,7 +612,7 @@ case "$1" in
rh_status
;;
shutdown)
- ON_SHUTDOWN=shutdown
+ ON_SHUTDOWN="shutdown"
stop
;;
*)
--
2.28.0
4 years, 2 months
[PATCH] virnuma: Don't work around numa_node_to_cpus() for non-existent nodes
by Michal Privoznik
In a very distant past, we came around machines that has not
continuous node IDs. This made us error out when constructing
capabilities XML. We resolved it by utilizing strange behaviour
of numa_node_to_cpus() in which it returned a mask with all bits
set for a non-existent node. However, this is not the only case
when it returns all ones mask - if the node exists and has enough
CPUs to fill the mask up (e.g. 128 CPUs).
The fix consists of using nodemask_isset(&numa_all_nodes, ..)
prior to calling numa_node_to_cpus() to determine if the node
exists.
Fixes: 628c93574758abb59e71160042524d321a33543f
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1860231
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/util/virnuma.c | 18 +++++-------------
1 file changed, 5 insertions(+), 13 deletions(-)
diff --git a/src/util/virnuma.c b/src/util/virnuma.c
index eeca438f25..75d5628cff 100644
--- a/src/util/virnuma.c
+++ b/src/util/virnuma.c
@@ -256,31 +256,23 @@ virNumaGetNodeCPUs(int node,
int mask_n_bytes = max_n_cpus / 8;
size_t i;
g_autofree unsigned long *mask = NULL;
- g_autofree unsigned long *allonesmask = NULL;
g_autoptr(virBitmap) cpumap = NULL;
*cpus = NULL;
+ if (!nodemask_isset(&numa_all_nodes, node)) {
+ VIR_DEBUG("NUMA topology for cell %d is not available, ignoring", node);
+ return -2;
+ }
+
if (VIR_ALLOC_N(mask, mask_n_bytes / sizeof(*mask)) < 0)
return -1;
- if (VIR_ALLOC_N(allonesmask, mask_n_bytes / sizeof(*mask)) < 0)
- return -1;
-
- memset(allonesmask, 0xff, mask_n_bytes);
-
- /* The first time this returns -1, ENOENT if node doesn't exist... */
if (numa_node_to_cpus(node, mask, mask_n_bytes) < 0) {
VIR_WARN("NUMA topology for cell %d is not available, ignoring", node);
return -2;
}
- /* second, third... times it returns an all-1's mask */
- if (memcmp(mask, allonesmask, mask_n_bytes) == 0) {
- VIR_DEBUG("NUMA topology for cell %d is invalid, ignoring", node);
- return -2;
- }
-
if (!(cpumap = virBitmapNew(max_n_cpus)))
return -1;
--
2.26.2
4 years, 2 months
[PATCH v3 0/6] bhyve: implement sound device support
by Roman Bogorodskiy
Changes since v2:
- Add 'ich7' sound device model,
- Convert audio id from string to integer,
- Use 'union' to store audio backend specific configuration,
- Document changes in formatdomain,
- Don't use hash for sound<->audio mapping lookups.
Roman Bogorodskiy (6):
conf: add 'ich7' sound model
bhyve: implement sound device support
conf: allow to map sound device to host device
bhyve: allow to specify host sound device
tests: schema: test bhyvexml2xmloutdata schemas
docs: formatdomain: document <audio> element
docs/formatdomain.rst | 49 +++++
docs/schemas/domaincommon.rng | 37 ++++
src/bhyve/bhyve_capabilities.c | 14 ++
src/bhyve/bhyve_capabilities.h | 1 +
src/bhyve/bhyve_command.c | 53 +++++
src/bhyve/bhyve_device.c | 9 +
src/conf/domain_capabilities.c | 4 +
src/conf/domain_conf.c | 190 +++++++++++++++++-
src/conf/domain_conf.h | 33 +++
src/conf/virconftypes.h | 3 +
src/libvirt_private.syms | 3 +
src/qemu/qemu_command.c | 2 +
src/qemu/qemu_domain.c | 1 +
src/qemu/qemu_domain_address.c | 3 +
src/qemu/qemu_driver.c | 5 +
src/qemu/qemu_hotplug.c | 3 +
src/qemu/qemu_validate.c | 2 +
.../bhyvexml2argv-sound.args | 10 +
.../bhyvexml2argv-sound.ldargs | 3 +
.../bhyvexml2argvdata/bhyvexml2argv-sound.xml | 30 +++
tests/bhyvexml2argvtest.c | 6 +-
.../bhyvexml2xmlout-sound.xml | 41 ++++
tests/bhyvexml2xmltest.c | 1 +
tests/virschematest.c | 3 +-
24 files changed, 502 insertions(+), 4 deletions(-)
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-sound.args
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-sound.ldargs
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-sound.xml
create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-sound.xml
--
2.27.0
4 years, 2 months
Conflicting parameters on qemu call
by Jan Walzer
Hi Lists,
I currently have the issue of wanting to use emu-system-x86_64 on a ppc64le platform.
It is imperative to pass the "-accel tcg,thread=multi” parameter to qemu when starting an instance, as without that, it will only use one thread and hence of limited/no use.
The problem is, that libvirt itself, passes “-machine q35,accel=tcg” to qemu, which is a different parameter, that conflicts with the other one.
Can we discuss, if I either have overlooked something, or is there a workaround, or is this a bug?
I’m running:
# uname -a
Linux tiger-v4 5.7.0-1-powerpc64le #1 SMP Debian 5.7.6-1 (2020-06-24) ppc64le GNU/Linux
# apt-cache policy libvirt-daemon
libvirt-daemon:
Installed: 6.5.0-1
Candidate: 6.5.0-1
Version table:
*** 6.5.0-1 500
500 http://deb.debian.org/debian testing/main ppc64el Packages
# apt-cache policy qemu-system-x86
qemu-system-x86:
Installed: 1:5.0-14
Candidate: 1:5.0-14
Version table:
*** 1:5.0-14 500
500 http://deb.debian.org/debian testing/main ppc64el Packages
Do you need any more information?
Feel free to only continue on the list that matters.
Greetings, Jan
4 years, 2 months
[PATCH v2] examples: Use GLib event loop impl in events.stp
by Han Han
Update the events stap example because the event loop impl is replaced by
GLib based event loop impl after commit 55fe8110.
Signed-off-by: Han Han <hhan(a)redhat.com>
---
examples/systemtap/events.stp | 26 ++++++++------------------
1 file changed, 8 insertions(+), 18 deletions(-)
diff --git a/examples/systemtap/events.stp b/examples/systemtap/events.stp
index fd4fe4664d..016e2ca048 100644
--- a/examples/systemtap/events.stp
+++ b/examples/systemtap/events.stp
@@ -89,44 +89,34 @@ probe begin {
print_ts("begin");
}
-probe libvirt.event_poll.add_handle {
+probe libvirt.event_glib.add_handle {
print_ts(sprintf("%d + handle %d %d %d", pid(), watch, fd, events));
}
-probe libvirt.event_poll.remove_handle {
+probe libvirt.event_glib.remove_handle {
print_ts(sprintf("%d - handle %d", pid(), watch));
}
-probe libvirt.event_poll.update_handle {
+probe libvirt.event_glib.update_handle {
if (showUpdates)
print_ts(sprintf("%d * handle %d %d", pid(), watch, events));
}
-probe libvirt.event_poll.purge_handle {
- print_ts(sprintf("%d ! handle %d", pid(), watch));
-}
-probe libvirt.event_poll.dispatch_handle {
+probe libvirt.event_glib.dispatch_handle {
if (showDispatch)
print_ts(sprintf("%d > handle %d %d", pid(), watch, events));
}
-probe libvirt.event_poll.add_timeout {
+probe libvirt.event_glib.add_timeout {
print_ts(sprintf("%d + timeout %d %d", pid(), timer, frequency));
}
-probe libvirt.event_poll.remove_timeout {
+probe libvirt.event_glib.remove_timeout {
print_ts(sprintf("%d - timeout %d", pid(), timer));
}
-probe libvirt.event_poll.update_timeout {
+probe libvirt.event_glib.update_timeout {
if (showUpdates)
print_ts(sprintf("%d * timeout %d %d", pid(), timer, frequency));
}
-probe libvirt.event_poll.purge_timeout {
- print_ts(sprintf("%d ! timeout %d", pid(), timer));
-}
-probe libvirt.event_poll.dispatch_timeout {
+probe libvirt.event_glib.dispatch_timeout {
if (showDispatch)
print_ts(sprintf("%d > timeout %d", pid(), timer));
}
-probe libvirt.event_poll.run {
- if (showIter)
- print_ts(sprintf("%d ~ %d %d", pid(), nfds, timeout));
-}
--
2.27.0
4 years, 2 months
[PATCH] kbase: Add knowledge base for libvirt systemtap
by Han Han
Signed-off-by: Han Han <hhan(a)redhat.com>
---
docs/kbase.rst | 3 ++
docs/kbase/meson.build | 1 +
docs/kbase/systemtap.rst | 113 +++++++++++++++++++++++++++++++++++++++
3 files changed, 117 insertions(+)
create mode 100644 docs/kbase/systemtap.rst
diff --git a/docs/kbase.rst b/docs/kbase.rst
index 78daaa5989..d8bff5d41e 100644
--- a/docs/kbase.rst
+++ b/docs/kbase.rst
@@ -36,6 +36,9 @@ Knowledge base
Examination of the security protections used for QEMU and how they need
configuring to allow use of QEMU passthrough with host files/devices.
+ `Systemtap <kbase/systemtap.html>`__
+ Explanation of how to use systemtap for libvirt tracing.
+
`Virtio-FS <kbase/virtiofs.html>`__
Share a filesystem between the guest and the host
diff --git a/docs/kbase/meson.build b/docs/kbase/meson.build
index d7f254e163..ca032a4b9b 100644
--- a/docs/kbase/meson.build
+++ b/docs/kbase/meson.build
@@ -13,6 +13,7 @@ docs_kbase_files = [
'rpm-deployment',
's390_protected_virt',
'secureusage',
+ 'systemtap',
'virtiofs',
]
diff --git a/docs/kbase/systemtap.rst b/docs/kbase/systemtap.rst
new file mode 100644
index 0000000000..34420efbb2
--- /dev/null
+++ b/docs/kbase/systemtap.rst
@@ -0,0 +1,113 @@
+=======================
+Systemtap of Libvirt
+=======================
+
+.. contents::
+
+`Systemtap <https://sourceware.org/systemtap/>`__ is a scripting
+language and tool for dynamically probing or tracing in Linux kernel
+space or user space. This page is about the usage of systemtap
+in libvirt tracing.
+
+Preparation
+===================
+
+Libvirt
+-------------------------
+
+Libvirt should be configured with the systemtap option to support libvirt
+probing events in systemtap.
+
+For libvirt before **6.7.0**, it can be configured by:
+
+::
+
+ mkdir build
+ cd build
+ ../configure --with-dtrace
+
+For libvirt **6.7.0** or later, configure it by the ``meson`` (seeing
+`libvirt compiling <https://libvirt.org/compiling.html>`__):
+
+::
+
+ meson build -Ddtrace=enabled
+
+For the libvirt binaries installed by the package manager like ``dnf`` or
+``apt``, if libvirt systemtap tapset ``/usr/share/systemtap/tapset/libvirt_*``
+exists, it means the libvirt enables the systemtap feature.
+
+Systemtap
+------------------------
+
+For most of linux distributions, execute ``stap-prep`` by root to prepare the
+environment for systemtap after installing the systemtap. If your distribution
+doesn't have ``stap-prep``, install the ``kernel debuginfo`` packages manually.
+
+After these above, run this test command to confirm the systemtap works well:
+
+::
+
+ stap -e 'probe oneshot{ printf("hello world\n")}'
+
+
+Tracing events
+=======================
+
+The libvirt systemtap tracing events are defined in tapset
+``/usr/share/systemtap/tapset/libvirt_*``. Libvirt support these type of tracing
+events: ``dbus``, ``event_glib``, ``object``, ``qemu``, ``rpc``.
+
+List all tracing events in libvirt:
+
+::
+
+ grep 'probe libvirt.[a-z_0-9.]*' /usr/share/systemtap/tapset/libvirt_* -o|cut -f 2 -d :
+
+
+Tracing examples
+==================
+
+Here is an example of the systemtap script to trace the QMP messages sent from libvirtd
+daemon to the qemu process.
+``qmp.stp``:
+
+::
+
+ probe begin
+ {
+ printf("Start tracing\n")
+ }
+ probe libvirt.qemu.monitor_send_msg
+ {
+ printf("QMPs: %s", msg);
+ }
+
+Then run the systemtap script attaching to the libvirtd process:
+
+::
+
+ stap qmp.stp -x `pidof libvirtd`
+
+
+To trace a libvirtd started from command line, use the option ``-c``
+
+::
+
+ stap qmp.stp -c "/usr/sbin/libvirtd"
+
+
+Then after seeing the welcome message "Start tracing" from systemtap, then execute a virsh
+command associated with QMP, for example ``virsh domstats``. Then get the QMP tracing logs
+from systemtap. For example, the result from ``virsh domstats``
+
+::
+
+ QMPs: {"execute":"query-balloon","id":"libvirt-393"}
+ QMPs: {"execute":"qom-get","arguments":{"path":"/machine/peripheral/balloon0","property":"guest-stats"},"id":"libvirt-394"}
+ QMPs: {"execute":"query-blockstats","id":"libvirt-395"}
+ QMPs: {"execute":"query-named-block-nodes","id":"libvirt-396"}
+ QMPs: {"execute":"query-iothreads","id":"libvirt-397"}
+
+For more examples of libvirt systemtap scripts, see the scripts in ``/usr/share/doc/libvirt-docs/examples/systemtap``
+For more details of systemtap language, see `document of systemtap <https://sourceware.org/systemtap/documentation.html>`__
--
2.27.0
4 years, 2 months
[PATCH 1/2] logging: Replace virMutex with GMutex
by Han Han
Signed-off-by: Han Han <hhan(a)redhat.com>
---
src/logging/log_daemon.c | 26 ++++++--------------------
src/logging/log_daemon.h | 4 ++--
2 files changed, 8 insertions(+), 22 deletions(-)
diff --git a/src/logging/log_daemon.c b/src/logging/log_daemon.c
index 028f771f14..0649a70c9d 100644
--- a/src/logging/log_daemon.c
+++ b/src/logging/log_daemon.c
@@ -56,7 +56,7 @@
VIR_LOG_INIT("logging.log_daemon");
struct _virLogDaemon {
- virMutex lock;
+ GMutex lock;
virNetDaemonPtr dmn;
virLogHandlerPtr handler;
};
@@ -86,7 +86,7 @@ virLogDaemonFree(virLogDaemonPtr logd)
return;
virObjectUnref(logd->handler);
- virMutexDestroy(&logd->lock);
+ g_mutex_clear(&logd->lock);
virObjectUnref(logd->dmn);
VIR_FREE(logd);
@@ -119,12 +119,7 @@ virLogDaemonNew(virLogDaemonConfigPtr config, bool privileged)
if (VIR_ALLOC(logd) < 0)
return NULL;
- if (virMutexInit(&logd->lock) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Unable to initialize mutex"));
- VIR_FREE(logd);
- return NULL;
- }
+ g_mutex_init(&logd->lock);
if (!(logd->dmn = virNetDaemonNew()))
goto error;
@@ -222,12 +217,7 @@ virLogDaemonNewPostExecRestart(virJSONValuePtr object, bool privileged,
if (VIR_ALLOC(logd) < 0)
return NULL;
- if (virMutexInit(&logd->lock) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Unable to initialize mutex"));
- VIR_FREE(logd);
- return NULL;
- }
+ g_mutex_init(&logd->lock);
if (!(child = virJSONValueObjectGet(object, "daemon"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -325,7 +315,7 @@ virLogDaemonClientFree(void *opaque)
priv,
(unsigned long long)priv->clientPid);
- virMutexDestroy(&priv->lock);
+ g_mutex_clear(&priv->lock);
VIR_FREE(priv);
}
@@ -343,11 +333,7 @@ virLogDaemonClientNew(virNetServerClientPtr client,
if (VIR_ALLOC(priv) < 0)
return NULL;
- if (virMutexInit(&priv->lock) < 0) {
- VIR_FREE(priv);
- virReportSystemError(errno, "%s", _("unable to init mutex"));
- return NULL;
- }
+ g_mutex_init(&priv->lock);
if (virNetServerClientGetUNIXIdentity(client,
&clientuid,
diff --git a/src/logging/log_daemon.h b/src/logging/log_daemon.h
index fa661e1793..6979bdcd5a 100644
--- a/src/logging/log_daemon.h
+++ b/src/logging/log_daemon.h
@@ -20,7 +20,7 @@
#pragma once
-#include "virthread.h"
+#include <glib.h>
#include "log_handler.h"
typedef struct _virLogDaemon virLogDaemon;
@@ -30,7 +30,7 @@ typedef struct _virLogDaemonClient virLogDaemonClient;
typedef virLogDaemonClient *virLogDaemonClientPtr;
struct _virLogDaemonClient {
- virMutex lock;
+ GMutex lock;
pid_t clientPid;
};
--
2.27.0
4 years, 2 months
[PATCH] Xen: Improve parsing of PCI addresses in config converter
by Jim Fehlig
There was a report on libvirt-users [1] about the domxml to/from
native converter in the Xen driver not handling PCI addresses
without a domain specification. This patch improves parsing of PCI
addresses in the converter and allows PCI addresses with only
bb:ss.f. xl.cfg(5) also allows either the dddd:bb:ss.f or bb:ss.f
format. A test has been added to check the conversion from xl.cfg
to domXML.
[1] https://www.redhat.com/archives/libvirt-users/2020-August/msg00040.html
Signed-off-by: Jim Fehlig <jfehlig(a)suse.com>
---
src/libxl/xen_common.c | 81 +++++++++-------------
tests/xmconfigdata/test-pci-dev-syntax.cfg | 26 +++++++
tests/xmconfigdata/test-pci-dev-syntax.xml | 71 +++++++++++++++++++
tests/xmconfigtest.c | 1 +
4 files changed, 129 insertions(+), 50 deletions(-)
diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c
index 75fe7e0644..73ce412fe7 100644
--- a/src/libxl/xen_common.c
+++ b/src/libxl/xen_common.c
@@ -372,63 +372,44 @@ static virDomainHostdevDefPtr
xenParsePCI(char *entry)
{
virDomainHostdevDefPtr hostdev = NULL;
- char domain[5];
- char bus[3];
- char slot[3];
- char func[2];
- char *key, *nextkey;
- int domainID;
- int busID;
- int slotID;
- int funcID;
+ VIR_AUTOSTRINGLIST tokens = NULL;
+ size_t ntokens = 0;
+ size_t nexttoken = 0;
+ char *slotstr;
+ char *funcstr;
+ int domain = 0x0;
+ int bus;
+ int slot;
+ int func;
- domain[0] = bus[0] = slot[0] = func[0] = '\0';
-
- /* pci=['0000:00:1b.0','0000:00:13.0'] */
- if (!(key = entry))
- return NULL;
- if (!(nextkey = strchr(key, ':')))
- return NULL;
- if (virStrncpy(domain, key, (nextkey - key), sizeof(domain)) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Domain %s too big for destination"), key);
+ /* pci=['00:1b.0','0000:00:13.0'] */
+ if (!(tokens = virStringSplitCount(entry, ":", 3, &ntokens)))
return NULL;
- }
- key = nextkey + 1;
- if (!(nextkey = strchr(key, ':')))
- return NULL;
- if (virStrncpy(bus, key, (nextkey - key), sizeof(bus)) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Bus %s too big for destination"), key);
- return NULL;
+ /* domain */
+ if (ntokens == 3) {
+ if (virStrToLong_i(tokens[nexttoken], NULL, 16, &domain) < 0)
+ return NULL;
+ nexttoken++;
}
- key = nextkey + 1;
- if (!(nextkey = strchr(key, '.')))
+ /* bus */
+ if (virStrToLong_i(tokens[nexttoken], NULL, 16, &bus) < 0)
return NULL;
- if (virStrncpy(slot, key, (nextkey - key), sizeof(slot)) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Slot %s too big for destination"), key);
- return NULL;
- }
+ nexttoken++;
- key = nextkey + 1;
- if (strlen(key) != 1)
- return NULL;
- if (virStrncpy(func, key, 1, sizeof(func)) < 0) {
+ /* slot and function */
+ slotstr = tokens[nexttoken];
+ if (!(funcstr = strchr(slotstr, '.'))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Function %s too big for destination"), key);
+ _("Malformed PCI address %s"), slotstr);
return NULL;
}
-
- if (virStrToLong_i(domain, NULL, 16, &domainID) < 0)
- return NULL;
- if (virStrToLong_i(bus, NULL, 16, &busID) < 0)
- return NULL;
- if (virStrToLong_i(slot, NULL, 16, &slotID) < 0)
+ *funcstr = '\0';
+ funcstr++;
+ if (virStrToLong_i(slotstr, NULL, 16, &slot) < 0)
return NULL;
- if (virStrToLong_i(func, NULL, 16, &funcID) < 0)
+ if (virStrToLong_i(funcstr, NULL, 16, &func) < 0)
return NULL;
if (!(hostdev = virDomainHostdevDefNew()))
@@ -436,10 +417,10 @@ xenParsePCI(char *entry)
hostdev->managed = false;
hostdev->source.subsys.type = VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI;
- hostdev->source.subsys.u.pci.addr.domain = domainID;
- hostdev->source.subsys.u.pci.addr.bus = busID;
- hostdev->source.subsys.u.pci.addr.slot = slotID;
- hostdev->source.subsys.u.pci.addr.function = funcID;
+ hostdev->source.subsys.u.pci.addr.domain = domain;
+ hostdev->source.subsys.u.pci.addr.bus = bus;
+ hostdev->source.subsys.u.pci.addr.slot = slot;
+ hostdev->source.subsys.u.pci.addr.function = func;
return hostdev;
}
diff --git a/tests/xmconfigdata/test-pci-dev-syntax.cfg b/tests/xmconfigdata/test-pci-dev-syntax.cfg
new file mode 100644
index 0000000000..e0f00d9bd7
--- /dev/null
+++ b/tests/xmconfigdata/test-pci-dev-syntax.cfg
@@ -0,0 +1,26 @@
+name = "test"
+uuid = "cc2315e7-d26a-307a-438c-6d188ec4c09c"
+maxmem = 382
+memory = 350
+vcpus = 1
+pae = 1
+acpi = 1
+apic = 1
+viridian = 0
+rtc_timeoffset = 0
+localtime = 0
+on_poweroff = "destroy"
+on_reboot = "destroy"
+on_crash = "destroy"
+device_model = "/usr/lib/xen/bin/qemu-system-i386"
+sdl = 0
+vnc = 1
+vncunused = 1
+vif = [ "mac=00:16:3e:0a:7b:39,bridge=xenbr0,script=vif-bridge,model=e1000" ]
+pci = [ "0001:0c:1b.2", "01:13.0" ]
+parallel = "none"
+serial = "pty"
+builder = "hvm"
+kernel = "/usr/lib/xen/boot/hvmloader"
+boot = "c"
+disk = [ "phy:/dev/sda8,hda,w", ",hdc:cdrom,r" ]
diff --git a/tests/xmconfigdata/test-pci-dev-syntax.xml b/tests/xmconfigdata/test-pci-dev-syntax.xml
new file mode 100644
index 0000000000..5d5d29c61c
--- /dev/null
+++ b/tests/xmconfigdata/test-pci-dev-syntax.xml
@@ -0,0 +1,71 @@
+<domain type='xen'>
+ <name>test</name>
+ <uuid>cc2315e7-d26a-307a-438c-6d188ec4c09c</uuid>
+ <memory unit='KiB'>391168</memory>
+ <currentMemory unit='KiB'>358400</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64' machine='xenfv'>hvm</type>
+ <loader type='rom'>/usr/lib/xen/boot/hvmloader</loader>
+ <boot dev='hd'/>
+ </os>
+ <features>
+ <acpi/>
+ <apic/>
+ <pae/>
+ </features>
+ <clock offset='variable' adjustment='0' basis='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>destroy</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/lib/xen/bin/qemu-system-i386</emulator>
+ <disk type='block' device='disk'>
+ <driver name='phy' type='raw'/>
+ <source dev='/dev/sda8'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <disk type='block' device='cdrom'>
+ <driver name='phy' type='raw'/>
+ <target dev='hdc' bus='ide'/>
+ <readonly/>
+ <address type='drive' controller='0' bus='1' target='0' unit='0'/>
+ </disk>
+ <controller type='xenbus' index='0'/>
+ <controller type='ide' index='0'/>
+ <interface type='bridge'>
+ <mac address='00:16:3e:0a:7b:39'/>
+ <source bridge='xenbr0'/>
+ <script path='vif-bridge'/>
+ <model type='e1000'/>
+ </interface>
+ <serial type='pty'>
+ <target port='0'/>
+ </serial>
+ <console type='pty'>
+ <target type='serial' port='0'/>
+ </console>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <graphics type='vnc' port='-1' autoport='yes'>
+ <listen type='address'/>
+ </graphics>
+ <video>
+ <model type='cirrus' vram='8192' heads='1' primary='yes'/>
+ </video>
+ <hostdev mode='subsystem' type='pci' managed='no'>
+ <driver name='xen'/>
+ <source>
+ <address domain='0x0001' bus='0x0c' slot='0x1b' function='0x2'/>
+ </source>
+ </hostdev>
+ <hostdev mode='subsystem' type='pci' managed='no'>
+ <driver name='xen'/>
+ <source>
+ <address domain='0x0000' bus='0x01' slot='0x13' function='0x0'/>
+ </source>
+ </hostdev>
+ <memballoon model='xen'/>
+ </devices>
+</domain>
diff --git a/tests/xmconfigtest.c b/tests/xmconfigtest.c
index e4a2b39384..43949fe3b5 100644
--- a/tests/xmconfigtest.c
+++ b/tests/xmconfigtest.c
@@ -216,6 +216,7 @@ mymain(void)
DO_TEST("escape-paths");
DO_TEST("no-source-cdrom");
DO_TEST("pci-devs");
+ DO_TEST_FORMAT("pci-dev-syntax");
DO_TEST("disk-drv-blktap-raw");
DO_TEST("disk-drv-blktap2-raw");
--
2.28.0
4 years, 2 months