libvirt/src/lxc
Eric Blake b9dd878ff8 util: make it easier to grab only regular command exit
Auditing all callers of virCommandRun and virCommandWait that
passed a non-NULL pointer for exit status turned up some
interesting observations.  Many callers were merely passing
a pointer to avoid the overall command dying, but without
caring what the exit status was - but these callers would
be better off treating a child death by signal as an abnormal
exit.  Other callers were actually acting on the status, but
not all of them remembered to filter by WIFEXITED and convert
with WEXITSTATUS; depending on the platform, this can result
in a status being reported as 256 times too big.  And among
those that correctly parse the output, it gets rather verbose.
Finally, there were the callers that explicitly checked that
the status was 0, and gave their own message, but with fewer
details than what virCommand gives for free.

So the best idea is to move the complexity out of callers and
into virCommand - by default, we return the actual exit status
already cleaned through WEXITSTATUS and treat signals as a
failed command; but the few callers that care can ask for raw
status and act on it themselves.

* src/util/vircommand.h (virCommandRawStatus): New prototype.
* src/libvirt_private.syms (util/command.h): Export it.
* docs/internals/command.html.in: Document it.
* src/util/vircommand.c (virCommandRawStatus): New function.
(virCommandWait): Adjust semantics.
* tests/commandtest.c (test1): Test it.
* daemon/remote.c (remoteDispatchAuthPolkit): Adjust callers.
* src/access/viraccessdriverpolkit.c (virAccessDriverPolkitCheck):
Likewise.
* src/fdstream.c (virFDStreamCloseInt): Likewise.
* src/lxc/lxc_process.c (virLXCProcessStart): Likewise.
* src/qemu/qemu_command.c (qemuCreateInBridgePortWithHelper):
Likewise.
* src/xen/xen_driver.c (xenUnifiedXendProbe): Simplify.
* tests/reconnect.c (mymain): Likewise.
* tests/statstest.c (mymain): Likewise.
* src/bhyve/bhyve_process.c (virBhyveProcessStart)
(virBhyveProcessStop): Don't overwrite virCommand error.
* src/libvirt.c (virConnectAuthGainPolkit): Likewise.
* src/openvz/openvz_driver.c (openvzDomainGetBarrierLimit)
(openvzDomainSetBarrierLimit): Likewise.
* src/util/virebtables.c (virEbTablesOnceInit): Likewise.
* src/util/viriptables.c (virIpTablesOnceInit): Likewise.
* src/util/virnetdevveth.c (virNetDevVethCreate): Fix debug
message.
* src/qemu/qemu_capabilities.c (virQEMUCapsInitQMP): Add comment.
* src/storage/storage_backend_iscsi.c
(virStorageBackendISCSINodeUpdate): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-03-03 12:40:32 -07:00
..
libvirtd_lxc.aug
lxc_cgroup.c Ensure systemd cgroup ownership is delegated to container with userns 2014-02-24 15:35:47 +00:00
lxc_cgroup.h Auto-detect existing cgroup placement 2013-07-23 22:46:31 +01:00
lxc_conf.c capabilities: add baselabel per sec driver/virt type to secmodel 2013-10-29 07:06:04 -06:00
lxc_conf.h maint: Fix messy include of libvirt_internal.h 2014-01-07 10:03:14 +01:00
lxc_container.c util: make it easier to grab only regular process exit 2014-03-03 12:40:31 -07:00
lxc_container.h LXC from native: migrate fstab and lxc.mount.entry 2014-02-12 17:52:46 +00:00
lxc_controller.c LXC: create monitor socket under selinux context of domain 2014-01-08 11:10:03 +01:00
lxc_domain.c maint: avoid 'const fooPtr' in domain_conf 2013-10-14 14:34:38 -06:00
lxc_domain.h Store a virCgroupPtr instance in virLXCDomainObjPrivatePtr 2013-04-15 17:35:31 +01:00
lxc_driver.c Fix multiple bugs in LXC domainMemoryStats driver 2014-02-20 15:32:49 +00:00
lxc_driver.h maint: don't use config.h in .h files 2013-06-05 05:53:25 -06:00
lxc_fuse.c Add missing 'return 0;' in stub lxcStartFuse() method impl. 2013-11-18 16:12:39 +00:00
lxc_fuse.h Avoid async signal safety problem in glibc's setxid 2013-11-18 15:36:23 +00:00
lxc_hostdev.c lxc: Make activeUsbHostdevs use locks 2013-07-18 14:16:54 +02:00
lxc_hostdev.h
lxc_monitor_protocol.x
lxc_monitor.c virLXCMonitorClose: Unlock domain while closing monitor 2013-07-24 17:53:00 +02:00
lxc_monitor.h
lxc_native.c lxc: Don't shadow global symbol "link" 2014-02-14 14:01:45 +01:00
lxc_native.h LXC driver: started implementing connectDomainXMLFromNative 2014-02-12 17:52:46 +00:00
lxc_process.c util: make it easier to grab only regular command exit 2014-03-03 12:40:32 -07:00
lxc_process.h lxc: switch to virCloseCallbacks API 2013-07-18 14:16:54 +02:00
lxc.conf
test_libvirtd_lxc.aug.in