[libvirt] [PATCH] libvirt-guests: emit most messages to stderr
by Michael Chapman
Some of the shell functions in this script (e.g. check_guests_shutdown)
produce output that is captured and processed by other parts of the
script. Any error messages from these shell functions must go to stderr,
not stdout.
Rather than trying to determine which messages are safe for stdout and
which are not (and maintaining this safety as the script is refactored),
simplify things by emitting all messages to stderr, except for the
output from gueststatus(), rh_status() and usage().
Signed-off-by: Michael Chapman <mike(a)very.puzzling.org>
---
tools/libvirt-guests.sh.in | 94 +++++++++++++++++++++++-----------------------
1 file changed, 47 insertions(+), 47 deletions(-)
diff --git a/tools/libvirt-guests.sh.in b/tools/libvirt-guests.sh.in
index 7f74b85..80b1ec7 100644
--- a/tools/libvirt-guests.sh.in
+++ b/tools/libvirt-guests.sh.in
@@ -92,16 +92,16 @@ test_connect()
i=${CONNECT_RETRIES}
while [ $i -gt 0 ]; do
- run_virsh "$uri" connect 2>/dev/null
+ run_virsh "$uri" connect >/dev/null 2>/dev/null
if [ $? -eq 0 ]; then
return 0;
fi
sleep ${RETRIES_SLEEP}
- eval_gettext "Unable to connect to libvirt currently. Retrying .. \$i"
+ eval_gettext "Unable to connect to libvirt currently. Retrying .. \$i" >&2
i=$(($i-1))
done
- eval_gettext "Can't connect to \$uri. Skipping."
- echo
+ eval_gettext "Can't connect to \$uri. Skipping." >&2
+ echo >&2
return 1
}
@@ -163,8 +163,8 @@ start() {
[ -f "$LISTFILE" ] || { started; return 0; }
if [ "x$ON_BOOT" != xstart ]; then
- gettext "libvirt-guests is configured not to start any guests on boot"
- echo
+ gettext "libvirt-guests is configured not to start any guests on boot" >&2
+ echo >&2
rm -f "$LISTFILE"
started
return 0
@@ -187,19 +187,19 @@ start() {
done
set +f
if ! "$configured"; then
- eval_gettext "Ignoring guests on \$uri URI"; echo
+ eval_gettext "Ignoring guests on \$uri URI" >&2; echo >&2
continue
fi
test_connect "$uri" || continue
- eval_gettext "Resuming guests on \$uri URI..."; echo
+ eval_gettext "Resuming guests on \$uri URI..." >&2; echo >&2
for guest in $list; do
name=$(guest_name "$uri" "$guest")
- eval_gettext "Resuming guest \$name: "
+ eval_gettext "Resuming guest \$name: " >&2
if guest_is_on "$uri" "$guest"; then
if "$guest_running"; then
- gettext "already active"; echo
+ gettext "already active" >&2; echo >&2
else
if "$isfirst"; then
isfirst=false
@@ -208,7 +208,7 @@ start() {
fi
retval run_virsh "$uri" start $bypass "$name" \
>/dev/null && \
- gettext "done"; echo
+ gettext "done" >&2; echo >&2
if "$sync_time"; then
run_virsh "$uri" domtime --sync "$name" >/dev/null
fi
@@ -234,7 +234,7 @@ suspend_guest()
bypass=
slept=0
test "x$BYPASS_CACHE" = x0 || bypass=--bypass-cache
- printf '%s...\n' "$label"
+ printf '%s...\n' "$label" >&2
run_virsh "$uri" managedsave $bypass "$guest" >/dev/null &
virsh_pid=$!
while true; do
@@ -246,9 +246,9 @@ suspend_guest()
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"
+ printf '%s%s\n' "$label" "$progress" >&2
else
- printf '%s%s\n' "$label" "..."
+ printf '%s%s\n' "$label" "..." >&2
fi
fi
done
@@ -264,8 +264,8 @@ shutdown_guest()
guest=$2
name=$(guest_name "$uri" "$guest")
- eval_gettext "Starting shutdown on guest: \$name"
- echo
+ eval_gettext "Starting shutdown on guest: \$name" >&2
+ echo >&2
retval run_virsh "$uri" shutdown "$guest" >/dev/null || return
timeout=$SHUTDOWN_TIMEOUT
check_timeout=false
@@ -283,24 +283,24 @@ shutdown_guest()
if $check_timeout; then
if [ $(($timeout % 5)) -eq 0 ]; then
- printf "$format" "$name" "$timeout"
+ printf "$format" "$name" "$timeout" >&2
fi
timeout=$(($timeout - 1))
else
slept=$(($slept + 1))
if [ $(($slept % 5)) -eq 0 ]; then
- printf "$format" "$name"
+ printf "$format" "$name" >&2
fi
fi
done
if guest_is_on "$uri" "$guest"; then
if "$guest_running"; then
- eval_gettext "Shutdown of guest \$name failed to complete in time."
+ eval_gettext "Shutdown of guest \$name failed to complete in time." >&2
else
- eval_gettext "Shutdown of guest \$name complete."
+ eval_gettext "Shutdown of guest \$name complete." >&2
fi
- echo
+ echo >&2
fi
}
@@ -313,8 +313,8 @@ shutdown_guest_async()
guest=$2
name=$(guest_name "$uri" "$guest")
- eval_gettext "Starting shutdown on guest: \$name"
- echo
+ eval_gettext "Starting shutdown on guest: \$name" >&2
+ echo >&2
retval run_virsh "$uri" shutdown "$guest" > /dev/null
}
@@ -337,8 +337,8 @@ check_guests_shutdown()
guests_up=
for guest in $guests; do
if ! guest_is_on "$uri" "$guest" >/dev/null 2>&1; then
- eval_gettext "Failed to determine state of guest: \$guest. Not tracking it anymore."
- echo
+ eval_gettext "Failed to determine state of guest: \$guest. Not tracking it anymore." >&2
+ echo >&2
continue
fi
if "$guest_running"; then
@@ -363,8 +363,8 @@ print_guests_shutdown()
esac
name=$(guest_name "$uri" "$guest")
- eval_gettext "Shutdown of guest \$name complete."
- echo
+ eval_gettext "Shutdown of guest \$name complete." >&2
+ echo >&2
done
}
@@ -404,18 +404,18 @@ shutdown_guests_parallel()
if $check_timeout; then
if [ $(($timeout % 5)) -eq 0 ]; then
- printf "$format" $(($guestcount + $shutdowncount)) "$timeout"
+ printf "$format" $(($guestcount + $shutdowncount)) "$timeout" >&2
fi
timeout=$(($timeout - 1))
if [ $timeout -le 0 ]; then
- eval_gettext "Timeout expired while shutting down domains"; echo
+ eval_gettext "Timeout expired while shutting down domains" >&2; echo >&2
RETVAL=1
return
fi
else
slept=$(($slept + 1))
if [ $(($slept % 5)) -eq 0 ]; then
- printf "$format" $(($guestcount + $shutdowncount))
+ printf "$format" $(($guestcount + $shutdowncount)) >&2
fi
fi
@@ -435,8 +435,8 @@ stop() {
if [ "x$ON_SHUTDOWN" = xshutdown ]; then
suspending=false
if [ $SHUTDOWN_TIMEOUT -lt 0 ]; then
- gettext "SHUTDOWN_TIMEOUT must be equal or greater than 0"
- echo
+ gettext "SHUTDOWN_TIMEOUT must be equal or greater than 0" >&2
+ echo >&2
RETVAL=6
return
fi
@@ -449,21 +449,21 @@ stop() {
test_connect "$uri" || continue
- eval_gettext "Running guests on \$uri URI: "
+ eval_gettext "Running guests on \$uri URI: " >&2
list=$(list_guests "$uri")
if [ $? -eq 0 ]; then
empty=true
for uuid in $list; do
- "$empty" || printf ", "
- printf %s "$(guest_name "$uri" "$uuid")"
+ "$empty" || printf ", " >&2
+ printf %s "$(guest_name "$uri" "$uuid")" >&2
empty=false
done
if "$empty"; then
- gettext "no running guests."
+ gettext "no running guests." >&2
fi
- echo
+ echo >&2
fi
if "$suspending"; then
@@ -472,26 +472,26 @@ stop() {
empty=true
for uuid in $transient; do
if "$empty"; then
- eval_gettext "Not suspending transient guests on URI: \$uri: "
+ eval_gettext "Not suspending transient guests on URI: \$uri: " >&2
empty=false
else
- printf ", "
+ printf ", " >&2
fi
- printf %s "$(guest_name "$uri" "$uuid")"
+ printf %s "$(guest_name "$uri" "$uuid")" >&2
done
- echo
+ echo >&2
# reload domain list to contain only persistent guests
list=$(list_guests "$uri" "--persistent")
if [ $? -ne 0 ]; then
- eval_gettext "Failed to list persistent guests on \$uri"
- echo
+ eval_gettext "Failed to list persistent guests on \$uri" >&2
+ echo >&2
RETVAL=1
set +f
return
fi
else
- gettext "Failed to list transient guests"
- echo
+ gettext "Failed to list transient guests" >&2
+ echo >&2
RETVAL=1
set +f
return
@@ -507,9 +507,9 @@ stop() {
if [ -s "$LISTFILE" ]; then
while read uri list; do
if "$suspending"; then
- eval_gettext "Suspending guests on \$uri URI..."; echo
+ eval_gettext "Suspending guests on \$uri URI..." >&2; echo >&2
else
- eval_gettext "Shutting down guests on \$uri URI..."; echo
+ eval_gettext "Shutting down guests on \$uri URI..." >&2; echo >&2
fi
if [ "$PARALLEL_SHUTDOWN" -gt 1 ] &&
--
2.4.3
8 years, 10 months
[libvirt] [PATCH 0/6] NSS module for libvirt
by Michal Privoznik
Are you tired of remembering IP addresses for your domains? Do
you have enough of configuring static IPs so that you can add
them to your hosts file? Then libvirt NSS module is exactly what
you need!
NSS does a lot in a Linux host. These patches aim at translating
domain names into IP addresses. All you need to do, is install
libnss_libvirt.so.2 (e.g. via 'make install' ran from source
dir), enable the module in nsswitch.conf:
$ grep libvirt /etc/nsswitch.conf
hosts: files dns libvirt
and you're all set. Now you can just:
$ ping $mydomain
$ ssh user@$mydomain
or anything you'd like. The only limitation is that it has to be
libvirt who has assigned the domain IP address. The limitation
comes from implementation in which
'/var/lib/libvirt/dnsmasq/*.status' files are parsed when looking
up a hostname.
What's beautiful on this feature is that it helps any users
regardless of their systemd attitude. On systemd hosts there
already exists a similar module 'mymachines' which takes its data
from machined. And libvirt does communicate with machined when
creating a domain. But unfortunately at that time we know nothing
about guest's IPs and therefore do not tell them to machined,
which in turn can't tell anything to mymachines module. To make
things worse, machined seems to be lacking an API to tell it the
addresses later on when libvirt finds out. Therefore even systemd
distros will benefit from this feature.
If the feature makes its way in, I'll describe all the steps in a
wiki (hence, no documentation in this patch set - although, if
you have a bright idea where should I put it, I'm all ears).
Enjoy!
Michal Privoznik (6):
Export virLease* functions for leases file handling
virjson: Resolve const correctness
Initial support for NSS plugin skeleton
nss: Implement _nss_libvirt_gethostbyname3_r
Implement _nss_libvirt_gethostbyname4_r
nss: Introduce a test
cfg.mk | 2 +-
configure.ac | 2 +
m4/virt-nss.m4 | 51 ++++++
po/POTFILES.in | 1 +
src/Makefile.am | 1 +
src/libvirt_private.syms | 6 +
src/network/leaseshelper.c | 271 +--------------------------
src/util/virjson.c | 58 +++---
src/util/virjson.h | 54 +++---
src/util/virlease.c | 304 ++++++++++++++++++++++++++++++
src/util/virlease.h | 44 +++++
tests/Makefile.am | 18 ++
tests/nssdata/virbr0.status | 14 ++
tests/nssmock.c | 140 ++++++++++++++
tests/nsstest.c | 184 +++++++++++++++++++
tools/Makefile.am | 45 +++++
tools/nss/libvirt_nss.c | 436 ++++++++++++++++++++++++++++++++++++++++++++
tools/nss/libvirt_nss.h | 52 ++++++
tools/nss/libvirt_nss.syms | 12 ++
19 files changed, 1368 insertions(+), 327 deletions(-)
create mode 100644 m4/virt-nss.m4
create mode 100644 src/util/virlease.c
create mode 100644 src/util/virlease.h
create mode 100644 tests/nssdata/virbr0.status
create mode 100644 tests/nssmock.c
create mode 100644 tests/nsstest.c
create mode 100644 tools/nss/libvirt_nss.c
create mode 100644 tools/nss/libvirt_nss.h
create mode 100644 tools/nss/libvirt_nss.syms
--
2.4.10
8 years, 10 months
[libvirt] devAlias correct parsing
by Alexander Burluka
Hello,
I would be grateful if you help me with next thing:
I've successfully subscribed on VIR_DOMAIN_EVENT_ID_TRAY_CHANGE event in
my application (QEMU based).
It perfectly works and returns to me an device alias (e.g.
"drive-scsi0-0-1-0").
Of course I can split this string by delimiter '-'. However, I've found
private virDomainDefFindDevice function within libvirt and
seems that its make correct parsing. How can I use it in my code?
Thank you!
--
Regards,
Alexander Burluka
8 years, 10 months
[libvirt] [PATCH] vircgroup: Update virCgroupDenyDevicePath stub
by Michal Privoznik
In cf113e8d we changed the declaration of
virCgroupAllowDevicePath() and virCgroupDenyDevicePath().
However, while updating the stub for non-cgroup platforms for the
former we forgot to update the latter too causing a build
failure.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
Pushed under trivial and build-breaker rules.
src/util/vircgroup.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index d032c60..38398fd 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -4689,7 +4689,8 @@ virCgroupDenyDevice(virCgroupPtr group ATTRIBUTE_UNUSED,
int
virCgroupDenyDevicePath(virCgroupPtr group ATTRIBUTE_UNUSED,
const char *path ATTRIBUTE_UNUSED,
- int perms ATTRIBUTE_UNUSED)
+ int perms ATTRIBUTE_UNUSED,
+ bool ignoreEacces ATTRIBUTE_UNUSED)
{
virReportSystemError(ENOSYS, "%s",
_("Control groups not supported on this platform"));
--
2.4.10
8 years, 10 months
[libvirt] [PATCH 0/2] Clean up rest of migration code
by Peter Krempa
As requested in review.
Peter Krempa (2):
qemu: monitor: Remove unused qemuMonitorMigrateToFile
qemu: Remove unnecessary calculations in qemuDomainSaveMemory
src/qemu/qemu_driver.c | 30 ++----------------------
src/qemu/qemu_monitor.c | 61 -------------------------------------------------
src/qemu/qemu_monitor.h | 17 --------------
3 files changed, 2 insertions(+), 106 deletions(-)
--
2.6.2
8 years, 10 months
[libvirt] [PATCH 00/10] Reorganizing qemu_command.c continued
by John Ferlan
Figure I'll do these in smaller chunks - it's a large module. Suffice
to say there's a lot of "movement" and patches for each is tedius, but
I hope in the end it will be easier to deal with.
For the most part all patches are primarily code motion, although
git diff may have you believe otherwise.
Essentially, I'm starting at the top of qemuBuildCommandLine and
working my way through either moving functions in a top down order
from the beginning of the module or more usually creating a
qemuBuildXXXXCommandLine function and calling it from the main
processing code.
I did not "manage" any of the QEMU_CAPS_DEVICE changes (e.g, remove
code), but I could while I'm at if that's desired.
Hopefully not many people are touching this module right now ;-)!
John Ferlan (10):
qemu: Move qemuDeviceDriveHostAlias
qemu: Remove local emulator
qemu: Make basic upfront checks before creating command
qemu: Reorganize -machine arguments
qemu: Reorganize -cpu arguments
qemu: Reorganize qemuBuildDomainLoaderCommandLine call
qemu: Reorganize -m arguments
qemu: Reorganize -smp argument
qemu: Reorganize IOThread -object arguments
qemu: Reorganize -numa arguments
src/qemu/qemu_alias.c | 16 +
src/qemu/qemu_alias.h | 4 +
src/qemu/qemu_command.c | 9010 ++++++++++++++++++++++++-----------------------
src/qemu/qemu_command.h | 3 -
src/qemu/qemu_hotplug.c | 6 +-
5 files changed, 4583 insertions(+), 4456 deletions(-)
--
2.5.0
8 years, 10 months
[libvirt] [PATCH] syms: add forgotten virAdmConnectClass symbol
by Erik Skultety
Although it currently doesn't cause any linking issues, the symbol should be
exported correctly according to our conventions.
---
Pushed under trivial rule.
src/libvirt_admin_private.syms | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/libvirt_admin_private.syms b/src/libvirt_admin_private.syms
index ffaf4f3..f22137b 100644
--- a/src/libvirt_admin_private.syms
+++ b/src/libvirt_admin_private.syms
@@ -12,6 +12,7 @@ xdr_admin_connect_list_servers_ret;
xdr_admin_connect_open_args;
# datatypes.h
+virAdmConnectClass;
virAdmGetServer;
virAdmServerClass;
--
2.4.3
8 years, 10 months
[libvirt] [PATCH v4 0/7] admin: Introduce server listing API
by Erik Skultety
Since v3:
- refactors to virHashForEach and hash iterators
- servers are now stored in a hash table instead of an array
- added forgotten virObjectLock in remoteAdminConnectListServers
Erik Skultety (7):
util: Add a return value to void hash iterators
util: Refactor virHashForEach so it returns as soon as an iterator
fails
virnetdaemon: Store servers in a hash table
admin: Move admin_server.{h,c} to admin.{h,c}
admin: Introduce virAdmServer structure
admin: Introduce adminDaemonConnectListServers API
virt-admin: Introduce cmdSrvList
daemon/Makefile.am | 5 +-
daemon/admin.c | 181 +++++++++++++++
daemon/admin.h | 36 +++
daemon/admin_server.c | 111 +++-------
daemon/admin_server.h | 26 +--
daemon/libvirtd.c | 6 +-
include/libvirt/libvirt-admin.h | 25 ++-
po/POTFILES.in | 3 +-
src/admin/admin_protocol.x | 26 ++-
src/admin/admin_remote.c | 71 ++++++
src/admin_protocol-structs | 15 ++
src/conf/network_conf.c | 15 +-
src/conf/nwfilter_params.c | 8 +-
src/conf/snapshot_conf.c | 31 +--
src/conf/virchrdev.c | 7 +-
src/conf/virdomainobjlist.c | 17 +-
src/datatypes.c | 35 +++
src/datatypes.h | 38 ++++
src/libvirt-admin.c | 79 +++++++
src/libvirt_admin_private.syms | 5 +
src/libvirt_admin_public.syms | 3 +
src/locking/lock_daemon.c | 10 +-
src/logging/log_daemon.c | 3 +-
src/lxc/lxc_controller.c | 2 +-
src/nwfilter/nwfilter_dhcpsnoop.c | 3 +-
src/nwfilter/nwfilter_gentech_driver.c | 5 +-
src/qemu/qemu_domain.c | 7 +-
src/qemu/qemu_domain.h | 6 +-
src/qemu/qemu_driver.c | 13 +-
src/rpc/virnetdaemon.c | 225 +++++++++++++------
src/rpc/virnetdaemon.h | 8 +-
src/test/test_driver.c | 14 +-
src/uml/uml_driver.c | 13 +-
src/util/virclosecallbacks.c | 9 +-
src/util/virhash.c | 28 ++-
src/util/virhash.h | 6 +-
src/xen/xm_internal.c | 7 +-
tests/virhashtest.c | 54 +++--
.../input-data-admin-server-names.json | 129 +++++++++++
.../virnetdaemondata/output-data-admin-nomdns.json | 8 +-
.../output-data-admin-server-names.json | 126 +++++++++++
.../virnetdaemondata/output-data-anon-clients.json | 6 +-
.../output-data-initial-nomdns.json | 6 +-
tests/virnetdaemondata/output-data-initial.json | 6 +-
.../output-data-no-keepalive-required.json | 242 +++++++++++----------
tests/virnetdaemontest.c | 63 +++---
tools/virt-admin.c | 61 ++++++
47 files changed, 1361 insertions(+), 442 deletions(-)
create mode 100644 daemon/admin.c
create mode 100644 daemon/admin.h
create mode 100644 tests/virnetdaemondata/input-data-admin-server-names.json
create mode 100644 tests/virnetdaemondata/output-data-admin-server-names.json
--
2.4.3
8 years, 10 months
[libvirt] [PATCH 00/10] Setup cgroups for firmware devices and related refactors
by Peter Krempa
Peter Krempa (10):
qemu: cgroup: Remove abandoned function qemuAddToCgroup
qemu: migration: Refactor code now that we assume support for fd
migration
util: cgroup: Instrument virCgroupDenyDevice to handle -1 device
number as *
util: cgroup: Drop virCgroup(Allow|Deny)DeviceMajor
util: cgroup: Allow ignoring EACCES in virCgroup(Allow|Deny)DevicePath
qemu: cgroup: Avoid reporting errors from inaccessible NFS volumes
qemu: cgroup: Switch to qemu(Setup|Teardown)ImageCgroup
qemu: cgroup: Split up qemuSetImageCgroupInternal
qemu: cgroup: Extract guts of qemuSetupImageCgroupInternal
qemu: cgroup: Setup cgroups for bios/firmware images
src/libvirt_private.syms | 2 -
src/lxc/lxc_cgroup.c | 16 ++---
src/lxc/lxc_driver.c | 9 ++-
src/qemu/qemu_cgroup.c | 151 +++++++++++++++++++++++++++-------------------
src/qemu/qemu_cgroup.h | 8 +--
src/qemu/qemu_driver.c | 8 +--
src/qemu/qemu_migration.c | 114 ++++++++++++----------------------
src/qemu/qemu_migration.h | 2 +-
src/util/vircgroup.c | 142 ++++++++++++++-----------------------------
src/util/vircgroup.h | 14 ++---
10 files changed, 199 insertions(+), 267 deletions(-)
--
2.6.2
8 years, 10 months
[libvirt] [PATCH] Revert "storageVolCreateXMLFrom: Check if backend knows how to createVol"
by Ján Tomko
This reverts commit 611a278fa46d3136b7fe5c6ab05e660ca3c8fdf4.
According to the original commit message, this is dead code:
It is highly unlikely that a backend will know how to create a
volume from a different volume (buildVolFrom) and not know how to
create an empty volume (createVol).
---
src/storage/storage_driver.c | 7 -------
1 file changed, 7 deletions(-)
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index 81b1584..e0ded01 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -2037,13 +2037,6 @@ storageVolCreateXMLFrom(virStoragePoolPtr obj,
if (newvol->target.capacity < origvol->target.capacity)
newvol->target.capacity = origvol->target.capacity;
- if (!backend->createVol) {
- virReportError(VIR_ERR_NO_SUPPORT,
- "%s", _("storage pool does not support volume "
- "creation"));
- goto cleanup;
- }
-
if (!backend->buildVolFrom) {
virReportError(VIR_ERR_NO_SUPPORT,
"%s", _("storage pool does not support"
--
2.4.10
8 years, 10 months