summaryrefslogtreecommitdiff
path: root/examples
Commit message (Collapse)AuthorAgeFilesLines
* examples: Try harder to uninstall nwfilterMichal Privoznik2016-04-201-1/+1
| | | | | | | | | | | | | We have this code in our Makefile that tries to remove /etc/libvirt/nwfilter if directory is left empty after all our example nwfilters were uninstalled. However, the check for that is missing quotation marks thus rendering the test useless: test -z allow-arp.xml allow-dhcp-server.xml .. qemu-announce-self.xml || \ rmdir "/some/path/libvirt.git/_install/etc/libvirt/nwfilter" /bin/sh: line 0: test: too many arguments Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* event-test: Enforce domain event syncPeter Krempa2016-04-181-0/+5
| | | | Use verify to force adding new events by means of static assertions.
* event-test: Add VIR_DOMAIN_EVENT_ID_IO_ERROR_REASONPeter Krempa2016-04-181-0/+19
| | | | | When adding the static check I've noticed that one other event is missing.
* event-test: Add VIR_DOMAIN_EVENT_ID_DEVICE_REMOVAL_FAILEDPeter Krempa2016-04-181-1/+14
|
* event-test: Add VIR_DOMAIN_EVENT_ID_JOB_COMPLETEDPeter Krempa2016-04-181-11/+34
|
* event-test: Add VIR_DOMAIN_EVENT_ID_MIGRATION_ITERATION callbackPeter Krempa2016-04-181-1/+13
|
* event-test: Add VIR_DOMAIN_EVENT_ID_BLOCK_JOB and ↵Peter Krempa2016-04-181-2/+69
| | | | VIR_DOMAIN_EVENT_ID_BLOCK_JOB_2
* event-test: make domain event registration declarativePeter Krempa2016-04-181-138/+62
| | | | | Rather than copying loads of ugly code, let's help out by a few C tricks.
* event-test: warn on unhandled enum valuesPeter Krempa2016-04-182-0/+59
| | | | | Avoid forgetting to add the correct fields to the switches in event-test.
* event-test: make few switch statements future proofPeter Krempa2016-04-181-118/+108
| | | | | Make them return "uknown" for invalid values without breaking compiler checks to add new values.
* event-test: Use switch instead of if/else if chains for lifecycle event ↵Peter Krempa2016-04-181-6/+16
| | | | translation
* event-test: Use typecasted enum to convert graphics event phasePeter Krempa2016-04-181-11/+19
|
* event-test: Force compiler check in switch for connectClose callbackPeter Krempa2016-04-181-9/+12
|
* event-test: Use functions with typecasted switch to convert enumsPeter Krempa2016-04-181-9/+28
| | | | | | Arrays would induce crash if a new value was introduced without adding it here. This could happen for VIR_DOMAIN_EVENT_DISK_DROP_MISSING_ON_START
* event-test: touch up coding stylePeter Krempa2016-04-181-90/+137
| | | | Break long lines and format headers correctly.
* event-test: Remove unnecessary 'usage' functionPeter Krempa2016-04-181-7/+1
|
* event-test: Get rid of useless and ambiguous VIR_DEBUG macroPeter Krempa2016-04-181-5/+4
| | | | | | | | The event test does not try to include libvirt internals. Using a macro named VIR_DEBUG might hint to such usage. Additionally it's useless since it's used only in the main() function. Modernize the message strings while touching them.
* event-test: Remove forward declarationsPeter Krempa2016-04-181-21/+0
| | | | | Most of the functions are no longer in this file. 'usage' does not need a declaration.
* event-test: Check for virConnectRegisterCloseCallback return valueMichal Privoznik2016-03-241-2/+5
| | | | | | | | In an unlikely event of virConnectRegisterCloseCallback failing, the error is ignored. This is an example file and we shouldn't get a bad example. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* event-test: Use goto cleanup instead of if else jungleMichal Privoznik2016-03-241-62/+69
| | | | | | | Like in the rest of our code we tend to prefer 'goto' and 'cleanup' over 'if else' code structure. Do the same here. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* Add event and state details for post-copyJiri Denemark2016-03-211-0/+9
| | | | | | | | | | | | | | | | VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY and VIR_DOMAIN_PAUSED_POSTCOPY are used on the source host once migration enters post-copy mode (which means the domain gets paused on the source. After the destination host takes over the execution of the domain, its virtual CPUs are resumed and the domain enters VIR_DOMAIN_RUNNING_POSTCOPY state and VIR_DOMAIN_EVENT_RESUMED_POSTCOPY event is emitted. In case migration fails during post-copy mode and none of the hosts have complete state of the domain, both domains will remain paused with VIR_DOMAIN_PAUSED_POSTCOPY_FAILED reason and an upper layer may decide what to do. Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
* Introduce new VIR_DOMAIN_EVENT_DEFINED_FROM_SNAPSHOT sub-eventDmitry Andreev2016-03-151-0/+2
| | | | | VIR_DOMAIN_EVENT_DEFINED_FROM_SNAPSHOT event should be emitted when domain configuration was changed on revert to snapshot.
* domsuspend: Fix warning on mingw buildAndrea Bolognani2016-02-121-0/+15
| | | | | | | | | | Commit d82170d introduced a workaround for domtop: in that example program, we define a symbol called ERROR for our own use, but since a symbol with the same name is already defined in one of mingw's header files, we get a warning when using that compiler. domsuspend defines the same problematic symbol, so the workaround has been copied over.
* Expand $(wildcard) correctlyMichal Privoznik2016-01-121-3/+3
| | | | | | | | | | So after da176bf6b756 and friend we have switched to $(wildcard some/path/*.xml) instead of enumerating the files explicitly. This is nice, however it makes distcheck build from VPATH fail. The reason is that it's is not obvious to what does the wildcard refer to: srcdir or builddir? Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* examples: Use one top level makefileCole Robinson2016-01-0915-327/+91
| | | | | | | | | | | | | | Using one Makefile per example subdirectory essentially serializes 'make' calls. Convert to one example/Makefile that builds and distributes all the subdir files. This reduces example/ rebuild time from about 5.8 seconds to 1.5 seconds on my machine. One slight difference is that we no longer ship Makefile.am with the examples in the rpm. This was virtually useless anyways since the Makefile was very specific to libvirt infrastructure, so wasn't generically reusable anyways. Tested with 'make distcheck' and 'make rpm'
* apparmor: add missing qemu binariesGuido Günther2015-11-251-1/+20
| | | | | This adds the qemu binaries as of 1.2.4 in Debian. It also removes a duplicate sparc64 entry.
* Add example that renames domain there and backMartin Kletzander2015-09-042-0/+97
| | | | | | | And in the middle it prints out its name to demonstrate changes in later patch(es). Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
* examples: Add example polkit ACL rulesJiri Denemark2015-09-042-0/+147
| | | | | | | | | | Creating ACL rules is not exactly easy and existing examples are pretty simple. This patch adds a somewhat complex example which defines several roles. Admins can do everything, operators can do basic operations on any domain and several groups of users who act as operators but only on a limited set of domains. Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
* Introduce new VIR_DOMAIN_EVENT_DEFINED_RENAMED eventTomas Meszaros2015-08-141-0/+4
| | | | | | This should be emitted whenever a domain is renamed. Signed-off-by: Tomas Meszaros <exo@tty.sk>
* Apparmor: allow reading block-rbd.soCédric Bosdonnat2015-04-241-0/+1
|
* domtop: Properly free cpu statusMichal Privoznik2015-04-211-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | So, in the example the cpu stats are collected within a function called do_top. At the beginning of the function we ask the daemon for how much vCPUs can we get stats, and how many stats for a vCPU can we get. This is because it's how our API works - users are required to preallocate a chunk of memory for the results. Now, at the end, we try to free the allocated array, but we are not doing it correctly. There's this virTypedParamsFree() function which gets a pointer to the array and the length of the array. However, if there was an error in getting vCPU stats we pass a negative number instead of the originally computed value. This flaw results in SIGSEGV: libvirt: QEMU Driver error : Requested operation is not valid: domain is not running ERROR do_top:333 : Unable to get cpu stats ==29201== Invalid read of size 4 ==29201== at 0x4F1DF8B: virTypedParamsClear (virtypedparam.c:1145) ==29201== by 0x4F1DFEB: virTypedParamsFree (virtypedparam.c:1165) ==29201== by 0x4023C3: do_top (domtop.c:349) ==29201== by 0x40260B: main (domtop.c:386) ==29201== Address 0x131cd7c0 is 16 bytes after a block of size 768 alloc'd ==29201== at 0x4C2C070: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==29201== by 0x401FF1: do_top (domtop.c:295) ==29201== by 0x40260B: main (domtop.c:386) Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* Apparmor: removed duplicate nscd rulesCédric Bosdonnat2015-04-201-4/+0
|
* Add an example for EVENT_ID_DEVICE_ADDEDJán Tomko2015-04-151-1/+20
|
* Apparmor qemu abstraction fixes for SLESCédric Bosdonnat2015-04-091-0/+9
| | | | | SLES 11 has legacy qemu-kvm package, /usr/bin/qemu-kvm and /usr/share/qemu-kvm need to be accessed to domains.
* Fix common misspellingsMartin Kletzander2015-03-231-1/+1
| | | | | | | | | | | | | Wikipedia's list of common misspellings [1] has a machine-readable version. This patch fixes those misspellings mentioned in the list which don't have multiple right variants (as e.g. "accension", which can be both "accession" and "ascension"), such misspellings are left untouched. The list of changes was manually re-checked for false positives. [1] https://en.wikipedia.org/wiki/Wikipedia:Lists_of_common_misspellings/For_machines Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
* Grant access to helpersMike Latimer2015-01-231-0/+2
| | | | | | | | Apparmor must not prevent access to required helper programs. The following helpers should be allowed to run in unconfined execution mode: - libvirt_parthelper - libvirt_iohelper
* Fix apparmor issues for tckMike Latimer2015-01-231-0/+1
| | | | | | | | | The network and nwfilter tests contained in the libvirt-TCK testkit can fail unless access to raw network packets is granted. Without this access, the following apparmor error can be seen while running the tests: apparmor="DENIED" operation="create" parent=1 profile="/usr/sbin/libvirtd" pid=94731 comm="libvirtd" family="packet" sock_type="raw" protocol=768
* Fix apparmor issues for XenMike Latimer2015-01-231-0/+3
| | | | | | | | | | | | | | | | | | | | In order for apparmor to work properly in Xen environments, the following access rights need to be allowed: - Allow CAP_SYS_PACCT, which is required when resetting some multi-port Broadcom cards by writting to the PCI config space - Allow CAP_IPC_LOCK, which is required to lock/unlock memory. Without this setting, an error 'Resource temporarily unavailable' can be seen while attempting to mmap memory. At the same time, the following apparmor message is seen: apparmor="DENIED" operation="capable" parent=1 profile="/usr/sbin/libvirtd" pid=2097 comm="libvirtd" pid=2097 comm="libvirtd" capability=14 capname="ipc_lock" - Allow access to distribution specific directories: /usr/{lib,lib64}/xen/bin
* Teach AppArmor, that /usr/lib64 may exist.Cedric Bosdonnat2015-01-053-5/+5
| | | | | The apparmor profiles forgot about /usr/lib64 folders, just add lib64 as a possible alternative to lib in the paths
* examples: Add support for the guest agent lifecycle eventPeter Krempa2014-11-241-1/+66
| | | | Add code to support the event in the object-event example.
* Remove unnecessary curly brackets in daemon/ and examples/Martin Kletzander2014-11-142-8/+4
| | | | Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
* examples: add systemtap script to ease lock debuggingMartin Kletzander2014-11-031-0/+118
| | | | | | | | | As discussed before, this simple script should help with debugging deadlocks, although there are still some caveats. RWLocks are not handled by this and if your deadlock if very racy, it may not lock up when running with this script due to the slowdown. Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
* event_example: cleanup example code for tunable eventPavel Hrdina2014-09-261-11/+4
| | | | Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
* Fix MinGW buildPavel Hrdina2014-09-241-2/+11
| | | | | | | When building on mingw the format string for long long/unsigned long long have to be I64d/I64u instead of lld/llu. Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
* add an example how to use tunable eventPavel Hrdina2014-09-231-1/+51
| | | | Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
* apparmor: allow reading cap_last_capFelix Geyer2014-09-041-1/+2
| | | | | | | | | libcap-ng >= 0.7.4 fails when it can't read /sys/kernel/cap_last_cap and thus running a qemu guest fails. Allow reading cap_last_cap in the libvirt-qemu apparmor abstraction. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* Fix spacing around commasMichal Privoznik2014-08-221-1/+1
| | | | | | | | | | | | | | On some places in the libvirt code we have: f(a,z) instead of f(a, z) This trivial patch fixes couple of such occurrences. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* examples: test: Kill unsupported maxMemory elementPeter Krempa2014-08-202-2/+0
| | | | | | The "maxMemory" element was never supported by libvirt. Remove it from the test XMLs. (Found while actually trying to add support for a identically named element).
* domtop: Remove unused variableMichal Privoznik2014-08-041-1/+1
| | | | | | | The variable 'k' in the print_cpu_usage function is not used anywhere and can fire a warning on some compilers. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
* domtop: Turn parse_argv into voidMichal Privoznik2014-08-041-8/+2
| | | | | | | | | | | | | | | | | Currently, the function follows the usual pattern used in our code: int ret = -1; ... ret = 0; cleanup: return ret; However, the function always call exit() on error, so the cleanup label is never jumped onto. Therefore, it doesn't make any sense to have the parse_argv function return an integer value, if it effectively can return only value of zero. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>