summaryrefslogtreecommitdiffstats
path: root/qga/main.c
Commit message (Collapse)AuthorAgeFilesLines
* qdict: Make conversion from QObject * accept nullMarkus Armbruster2015-10-291-8/+3
| | | | | | | | | | qobject_to_qdict() crashes on null, which is a trap for the unwary. Return null instead, and simplify a few callers. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <1444918537-18107-4-git-send-email-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
* qga: handle possible SIGPIPE in guest-file-writeDenis V. Lunev2015-10-191-0/+6
| | | | | | | | | | | | | qemu-ga should not exit on guest-file-write to pipe without read end but proper error code should be returned. The behavior of the spawned process should be default thus SIGPIPE processing should be reset to default after fork() but before exec(). Signed-off-by: Denis V. Lunev <den@openvz.org> Signed-off-by: Yuri Pudgorodskiy <yur@virtuozzo.com> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Denis V. Lunev <den@openvz.org> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
* qga: do not override configuration verbosityMarc-André Lureau2015-10-191-2/+2
| | | | | | | | | Move the default verbosity settings before loading the configuration file, or it will overwrite it. Found thanks to writing qga tests :) Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
* qga: add QGA_CONF environment variableMarc-André Lureau2015-10-191-1/+2
| | | | | | | | | | Having a environment variable allows to override default configuration path, useful for testing. Note that this can't easily be an argument, since loading config is done before parsing the arguments. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
* qga: add --dump-conf optionMarc-André Lureau2015-09-011-0/+64
| | | | | | | | | | | | This new option allows to review the agent configuration, and ease the task of writing a configuration file. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> Reviewed-by: Denis V. Lunev <den@openvz.org> * removed unecessary keyfile != NULL prior to free * documented --dump-conf is qemu-ga --help output Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
* qga: add an optional qemu-ga.conf system configurationMarc-André Lureau2015-09-011-7/+77
| | | | | | | | | | | | | | | | Learn to configure the agent with a system configuration. This may simplify command-line handling, especially when the blacklist is long. Among the other benefits, this may standardize the configuration of an init service (instead of distro-specific init keys/files) Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> Reviewed-by: Denis V. Lunev <den@openvz.org> * removed unecessary keyfile != NULL prior to free Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
* qga: free a bit moreMarc-André Lureau2015-09-011-2/+4
| | | | | | | | | Now that main() has a single exit point, we can free a few more allocations. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Denis V. Lunev <den@openvz.org> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
* qga: move agent run in a separate functionMarc-André Lureau2015-09-011-76/+95
| | | | | | | | | | | | | Once the options are populated, move the running state to a run_agent() function. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> Reviewed-by: Denis V. Lunev <den@openvz.org> * fixed up an s/ga_state/s/ artifact causing segfault * replaced g_list_free_full with g_list_foreach to maintain glib 2.22 compatibility Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
* qga: fill default options in main()Marc-André Lureau2015-09-011-17/+17
| | | | | | | | | | Fill all default options during main(). This is a preparation patch to allow to dump the configuration. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> Reviewed-by: Denis V. Lunev <den@openvz.org> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
* qga: move option parsing to separate functionMarc-André Lureau2015-09-011-69/+96
| | | | | | | | | Move option parsing out of giant main(). Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> Reviewed-by: Denis V. Lunev <den@openvz.org> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
* qga: copy argument stringsMarc-André Lureau2015-09-011-26/+31
| | | | | | | | | | | | | Following patch will return allocated strings, so we must correctly initialize alloc & free them. The nice side effect is that we no longer have to check for "fixed_state_dir" to call ga_install_service() with a NULL state dir. The default values are set after parsing the command line options. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> Reviewed-by: Denis V. Lunev <den@openvz.org> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
* qga: rename 'path' to 'channel_path'Marc-André Lureau2015-09-011-4/+5
| | | | | | | | | | 'path' is already a global function, rename the variable since it's going to be in global scope in a later patch. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> Reviewed-by: Denis V. Lunev <den@openvz.org> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
* qga: make split_list() return allocated stringsMarc-André Lureau2015-09-011-13/+9
| | | | | | | | | In order to avoid any confusion, let's allocate new strings when splitting. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Denis V. Lunev <den@openvz.org> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
* qga: move string split in separate functionMarc-André Lureau2015-09-011-11/+22
| | | | | | | | | The function is going to be reused in a later patch. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> Reviewed-by: Denis V. Lunev <den@openvz.org> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
* qga: use exit() when parsing optionsMarc-André Lureau2015-09-011-12/+12
| | | | | | | | | | | The option parsing is going to be moved to a separate function, use exit() consistently. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Denis V. Lunev <den@openvz.org> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
* Revert "guest agent: remove g_strcmp0 usage"Markus Armbruster2015-07-071-1/+1
| | | | | | | | | | | | | | Since we now require GLib 2.22+ (commit f40685c), we don't have to work around lack of g_strcmp0() anymore. This reverts commit 8f4774789947bc4bc4c8d026a289fe980d3d2ee1. Conflicts: qemu-ga.c Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
* qerror: Clean up QERR_ macros to expand into a single stringMarkus Armbruster2015-06-221-2/+2
| | | | | | | | | | | | | | | | | | | | | These macros expand into error class enumeration constant, comma, string. Unclean. Has been that way since commit 13f59ae. The error class is always ERROR_CLASS_GENERIC_ERROR since the previous commit. Clean up as follows: * Prepend every use of a QERR_ macro by ERROR_CLASS_GENERIC_ERROR, and delete it from the QERR_ macro. No change after preprocessing. * Rewrite error_set(ERROR_CLASS_GENERIC_ERROR, ...) into error_setg(...). Again, no change after preprocessing. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
* qemu-ga: adding vss-[un]install optionsYossi Hindin2015-06-171-1/+9
| | | | | | | | | | | | | | | | | Existing command line options include '-s install' and '-s uninstall'. These options install/uninstall both Windows QEMU GA service and optional VSS COM server. The QEMU GA Windows service allows always-on serving guest agent's QMP commands and VSS COM server enables guest agent integration with Volume Shadow Service. This commit introdices new options '-s vss-install' and '-s vss-uninstall', affecting only GA VSS COM server registration. The new options are useful for registering and unregistering the COM server during MSI installation, upgrade and uninstallation. Signed-off-by: Yossi Hindin <yhindin@redhat.com> Message-Id: <1430913460-13174-2-git-send-email-yhindin@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qga: fix false negative argument passingGonglei2014-11-171-2/+2
| | | | | | | | | | Function send_response(s, &qdict->base) returns a negative number when any failures occured. But strerror()'s parameter cannot be negative. Let's change the testing condition and pass '-ret' to strerr(). Signed-off-by: Gonglei <arei.gonglei@huawei.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qga: Disable unsupported commands by defaultTomoki Sekiyama2014-08-071-0/+1
| | | | | | | | | | | Currently management softwares cannot know whether a qemu-ga command is supported or not on the running platform until they actually execute it. This patch disables unsupported commands at launch time of qemu-ga, so that management softwares can check whether they are supported from 'enabled' property of the result from 'guest-info' command. Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
* qga: Use return values instead of error_is_set(errp)Markus Armbruster2014-05-091-0/+1
| | | | | | | | | | | | | | Using error_is_set(errp) to check whether a function call failed is fragile: it breaks when errp is null. ga_get_fd_handle() and guest_file_handle_add() don't return a useful value when they fail, but that's just stupid. Fix that, and check them instead. As far as I can tell, errp can't be null there, but this is more robust and more obviously correct. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* qga: Fix typo (plural) in commentStefan Weil2014-05-071-1/+1
| | | | | Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
* qga: Remove unneeded include fileStefan Weil2014-03-031-1/+0
| | | | | | | | | This file does not depend on windows.h. Signed-off-by: Stefan Weil <sw@weilnetz.de> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
* qemu-ga: isa-serial support on WindowsMiki Mishael2014-02-231-4/+13
| | | | | | | | | | | | | Add support for isa-serial method for qemu-ga on Windows, Added -p command line parameter for serial port name specification, e.g. "-p COM15". Signed-off-by: Miki Mishael <mmishael@redhat.com> Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com> *added default isa-serial path to help output Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
* qemu-ga: Add interface to traverse the qmp command list by QmpCommandMark Wu2013-10-101-45/+30
| | | | | | | | | | | | | | | | In the original code, qmp_get_command_list is used to construct a list of all commands' name. To get the information of all qga commands, it traverses the name list and search the command info with its name. So it can cause O(n^2) in the number of commands. This patch adds an interface to traverse the qmp command list by QmpCommand to replace qmp_get_command_list. It can decrease the complexity from O(n^2) to O(n). Signed-off-by: Mark Wu <wudxw@linux.vnet.ibm.com> Reviewed-by: Eric Blake <eblake@redhat.com> *fix up commit subject Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
* qemu-ga: Install Windows VSS provider on `qemu-ga -s install'Tomoki Sekiyama2013-09-091-1/+9
| | | | | | | | | | Register QGA VSS provider library into Windows when qemu-ga is installed as Windows service ('-s install' option). It is deregistered when the service is uninstalled ('-s uninstall' option). Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
* qga: save state directory in ga_install_service()Laszlo Ersek2013-05-301-1/+10
| | | | | | | | If the user selects a non-default state directory at service installation time, we should remember it in the registered service. Signed-off-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
* qga: create state directory on win32Laszlo Ersek2013-05-301-0/+14
| | | | | | | | On Win32 the local state directory is application specific and users might expect qemu-ga to create it automatically. Signed-off-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
* qga: determine default state dir and pidfile dynamicallyLaszlo Ersek2013-05-301-6/+26
| | | | | | | | | | | | | | | No effective change on POSIX, but on Win32 the defaults come from the environment / session. Since commit 39097daf ("qemu-ga: use key-value store to avoid recycling fd handles after restart") we've relied on the state directory for the fd handles' key-value store. Even though we don't support the guest-file-* commands on win32 yet, the key-value store is written, and it's the first use of the state directory on win32. We should have a sensible default for its location. Signed-off-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
* qga: set umask 0077 when daemonizing (CVE-2013-2007)Laszlo Ersek2013-05-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | The qemu guest agent creates a bunch of files with insecure permissions when started in daemon mode. For example: -rw-rw-rw- 1 root root /var/log/qemu-ga.log -rw-rw-rw- 1 root root /var/run/qga.state -rw-rw-rw- 1 root root /var/log/qga-fsfreeze-hook.log In addition, at least all files created with the "guest-file-open" QMP command, and all files created with shell output redirection (or otherwise) by utilities invoked by the fsfreeze hook script are affected. For now mask all file mode bits for "group" and "others" in become_daemon(). Temporarily, for compatibility reasons, stick with the 0666 file-mode in case of files newly created by the "guest-file-open" QMP call. Do so without changing the umask temporarily. Signed-off-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qemu-ga: ga_get_fd_handle(): abort if fd_counter overflowsLuiz Capitulino2013-04-021-2/+6
| | | | | | | | | | | | Today we reset fd_counter if it wraps, but it's better to abort() instead, as fd_counter should never reach INT64_MAX. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> *fixed typo: s/resonable/reasonable/ Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
* qga/main.c: Don't use g_key_file_get/set_int64Peter Crosthwaite2013-03-151-2/+2
| | | | | | | | | | | | | | | These functions don't exist until glib version 2.26. QEMU is currently only mandating glib 2.12. This patch replaces the functions with g_key_file_get/set_integer. Unbreaks the build on Ubuntu 10.04 and RHEL 5.6. Regression was introduced by 39097daf15c42243742667607d2cad2c9dc4f764 Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Message-id: 1363323879-682-1-git-send-email-peter.crosthwaite@xilinx.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qemu-ga: use key-value store to avoid recycling fd handles after restartMichael Roth2013-03-111-0/+184
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Hosts hold on to handles provided by guest-file-open for periods that can span beyond the life of the qemu-ga process that issued them. Since these are issued starting from 0 on every restart, we run the risk of issuing duplicate handles after restarts/reboots. As a result, users with a stale copy of these handles may end up reading/writing corrupted data due to their existing handles effectively being re-assigned to an unexpected file or offset. We unfortunately do not issue handles as strings, but as integers, so a solution such as using UUIDs can't be implemented without introducing a new interface. As a workaround, we fix this by implementing a persistent key-value store that will be used to track the value of the last handle that was issued across restarts/reboots to avoid issuing duplicates. The store is automatically written to the same directory we currently set via --statedir to track fsfreeze state, and so should be applicable for stable releases where this flag is supported. A follow-up can use this same store for handling fsfreeze state, but that change is cosmetic and left out for now. Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com> Cc: qemu-stable@nongnu.org * fixed guest_file_handle_add() return value from uint64_t to int64_t
* qemu-ga: make guest-sync-delimited available during fsfreezeMichael Roth2013-03-111-0/+1
| | | | | | | | | | | | | | We currently maintain a whitelist of commands that are safe during fsfreeze. During fsfreeze, we disable all commands that aren't part of that whitelist. guest-sync-delimited meets the criteria for being whitelisted, and is also required for qemu-ga clients that rely on guest-sync-delimited for re-syncing the channel after a timeout. Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com> Cc: qemu-stable@nongnu.org Reviewed-by: Eric Blake <eblake@redhat.com>
* qemu-ga: Plug file descriptor leak on ga_open_pidfile() error pathMarkus Armbruster2013-01-141-0/+2
| | | | | | | | | | Spotted by Coverity. Also document why we keep it open on success. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
* qemu-ga: Drop pointless lseek() from ga_open_pidfile()Markus Armbruster2013-01-141-1/+1
| | | | | | | | | | | After open(), the file offset is already zero, and neither lockf() nor ftruncate() change it. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
* qemu-ga: Document intentional fall through in channel_event_cb()Markus Armbruster2013-01-141-0/+1
| | | | | | | | | | For clarity, and to hush up Coverity. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
* qemu-ga: add ga_open_logfile()Luiz Capitulino2013-01-141-2/+15
| | | | | | | | | | | This function sets O_CLOEXEC on the log file fd so that it isn't leaked to executed processes. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Acked-by: Amos Kong <akong@redhat.com> Tested-by: Amos Kong <akong@redhat.com> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
* qemu-ga: ga_open_pidfile(): use qemu_open()Luiz Capitulino2013-01-141-1/+1
| | | | | | | | | | | This ensures that O_CLOEXEC is passed to open(), this way the pid file fd is not leaked to executed processes. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Acked-by: Amos Kong <akong@redhat.com> Tested-by: Amos Kong <akong@redhat.com> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
* qemu-ga: execute hook to quiesce the guest on fsfreeze-freeze/thawTomoki Sekiyama2013-01-081-1/+47
| | | | | | | | | | | | | | | | | | | | | | | | To use the online disk snapshot for online-backup, application-level consistency of the snapshot image is required. However, currently the guest agent can provide only filesystem-level consistency, and the snapshot may contain dirty data, for example, incomplete transactions. This patch provides the opportunity to quiesce applications before snapshot is taken. If --fsfreeze-hook option is specified, the hook is executed with "freeze" argument before the filesystem is frozen by fsfreeze-freeze command. As for fsfreeze-thaw command, the hook is executed with "thaw" argument after the filesystem is thawed. This patch depends on patchset to improve error reporting by Luiz Capitulino: http://lists.gnu.org/archive/html/qemu-devel/2012-11/msg03016.html Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama.qu@hitachi.com> Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com> *clarified usage in help output Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
* misc: move include files to include/qemu/Paolo Bonzini2012-12-191-1/+1
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qapi: move include files to include/qobject/Paolo Bonzini2012-12-191-6/+6
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-ga: move qemu-ga files to qga/Paolo Bonzini2012-12-191-0/+901
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
OpenPOWER on IntegriCloud