qemu-ga: Fix unchecked strdup() by converting to g_strdup()
I figure it's freed somewhere deep down in QAPI, with g_free().
Signed-off-by: Markus Armbruster <armbru@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>...
qemu-ga: Plug leaks on qmp_guest_network_get_interfaces() error paths
Spotted by Coverity.
Signed-off-by: Markus Armbruster <armbru@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
qemu-ga: Plug memory leak in guest_fsfreeze_cleanup()
Neglects to free errors allocated by qmp_guest_fsfreeze_thaw().Spotted by Coverity.
While there, drop the test whether return value is negative (it'snever true), and improve logging.
Signed-off-by: Markus Armbruster <armbru@redhat.com>...
Replace non-portable asprintf by g_strdup_printf
g_strdup_printf already handles OOM errors, so some error handling inQEMU code can be removed.
Signed-off-by: Stefan Weil <sw@weilnetz.de>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Merge remote-tracking branch 'mdroth/qga-pull-1-14-2013-2' into staging
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
qga: add missing commas in json docs
Signed-off-by: Eric Blake <eblake@redhat.com>Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
qemu-ga: Handle errors uniformely in ga_channel_open()
We detect errors in several places. One reports with g_error(), whichcalls abort(), the others report with g_critical(). Three of themexit(), three return false.
Always report with g_critical(), and return false....
qemu-ga: Plug fd leak on ga_channel_open() error paths
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>...
qemu-ga: Plug fd leak on ga_channel_listen_accept() error path
qemu-ga: Plug file descriptor leak on ga_open_pidfile() error path
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>...
qemu-ga: Drop pointless lseek() from ga_open_pidfile()
After open(), the file offset is already zero, and neither lockf() norftruncate() change it.
qemu-ga: Document intentional fall through in channel_event_cb()
For clarity, and to hush up Coverity.
qemu-ga: add ga_open_logfile()
This function sets O_CLOEXEC on the log file fd so that it isn'tleaked 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>...
qemu-ga: ga_open_pidfile(): use qemu_open()
This ensures that O_CLOEXEC is passed to open(), this way thepid file fd is not leaked to executed processes.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>...
Merge remote-tracking branch 'stefanha/trivial-patches' into staging
qga/channel-posix.c: Explicitly include string.h
Explicitly include string.h to avoid warnings under MacOS X/clangabout implicit declarations of strerror() and strlen().
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>Reviewed-by: Stefan Weil <sw@weilnetz.de>...
qemu-ga: bios_supports_mode(): improve error reporting
Most errors are QERR_UNDEFINED_ERROR today.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
qemu-ga: guest_suspend(): improve error reporting
qemu-ga: execute hook to quiesce the guest on fsfreeze-freeze/thaw
To use the online disk snapshot for online-backup, application-levelconsistency of the snapshot image is required. However, currently theguest agent can provide only filesystem-level consistency, and the...
qemu-ga: qmp_guest_file_*: improve error reporting
Use error_setg_errno() when possible with an improved error description.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
qemu-ga: qmp_guest_shutdown(): improve error reporting
Most errors are QERR_UNDEFINED_ERROR. Also, adds ga_wait_child() asa future commit will use it too.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>...
qemu-ga: build_fs_mount_list(): take an Error argument
qemu-ga: qmp_guest_fsfreeze_*(): get rid of sprintf() + error_set()
Convert them to error_setg_errno().
qemu-ga: qmp_guest_fstrim(): get rid of sprintf() + error_set()
qemu-ga: qmp_guest_network_get_interfaces(): get rid of snprintf() + error_set()
qemu-ga: guest_file_handle_find(): take an Error argument
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
*Fixed missing space character in error message
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
qemu-ga: qmp_guest_file_close(): fix fclose() error check
fclose() returns EOF on error.
misc: move include files to include/qemu/
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
qapi: move include files to include/qobject/
qemu-ga: move qemu-ga files to qga/
qga/channel-posix.c: Include headers it needs
Include: - <errno.h> for errno - <unistd.h> & <fcntl.h> for fcntl() - <stdlib.h> for exit() - "osdep.h" for qemu_open()
Some of those headers were probably being included by accident becausesome other headers were including qemu-common.h, but those headers...
qemu-ga: ask and print error information from qemu-sockets
Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
qemu-sockets: add Error ** to all functions
This lets me adjust the clients to do proper error propagation first,thus avoiding temporary regressions in the quality of the error messages.
Merge branch 'trivial-patches' of git://github.com/stefanha/qemu
cleanup useless return sentence
This patch cleans up return sentences in the end of void functions.
Reported-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Amos Kong <akong@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
qemu-ga: prefer pstrcpy: consistently NUL-terminate ifreq.ifr_name
NUL-termination of the .ifr_name field is not required, but is fine(and preferable to using strncpy and leaving the reader to wonder),since the first thing the linux kernel does is to clear the last byte....
build: Fix linking failure for qemu-ga
This patch will fix the following linking failed:
LINK qemu-gagcc: error: qga/../qapi-generated/qga-qapi-types.o: No such file or directorygcc: error: qga/../qapi-generated/qga-qapi-visit.o: No such file or directory...
build: include qapi-generated/ files in qga/Makefile.objs
No reason to leave them out, and it will ensure that the dependenciesare picked up. Later we can perhaps move the files to anotherdirectory to avoid ../ usage.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>...
qemu-ga: add guest-fstrim command
FITRIM is a mounted filesystem feature to discard (or "trim") blocks whichare not in use by the filesystem. This is useful for solid-state drives(SSDs) and thinly-provisioned storage. Provide access to the featurefrom the host so that filesystems can be trimmed periodically or before...
qemu-ga: make names more generic for mount list functions
We will use these functions and types for more than FSFREEZE, so rename them.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>Reviewed-by: Michal Privoznik <mprivozn@redhat.com>...
build: move qga/ objects to nested Makefile.objs
qemu-ga: avoid blocking on atime update when reading /etc/mtab
Currently we re-read/re-process /etc/mtab to get an updated list ofmounts when guest-fsfreeze-thaw is called. This can cause an atimeupdate on /etc/mtab, which will block if we're in a frozen state....
qemu-ga: Fix use of environ on Darwin
Use _NSGetEnviron() helper to access the environment.
Signed-off-by: Andreas Färber <andreas.faerber@web.de>Cc: Charlie Somerville <charlie@charliesomerville.com>Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
qemu-ga: Fix missing environ declaration
Commit 3674838cd05268954bb6473239cd7f700a79bf0f uses the environ globalvariable, but is relying on environ to be declared somewhere else.
This worked for me because on F16 environ is declared in <unistd.h>, butthat doesn't happen in OpenBSD for example, causing a build failure....
qemu-ga: align versioning with QEMU_VERSION
Previously qemu-ga version was defined seperately. Since it is alignedwith QEMU releases, use QEMU_VERSION instead. This also implies theversion bump for 1.1[-rcN] release of qemu-ga.
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>...
qemu-ga: make reopen_fd_to_null() public
The next commit wants to use it.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
qemu-ga: guest-suspend: make the API synchronous
Currently, qemu-ga has a SIGCHLD handler that automatically reaps terminatedchildren processes. The idea is to avoid having qemu-ga commands blockedwaiting for children to terminate.
That approach has two problems:...
qemu-ga: guest-shutdown: become synchronous
Last commit dropped qemu-ga's SIGCHLD handler, used to automaticallyreap terminated children processes. This introduced a bug toqmp_guest_shutdown(): it will generate zombies.
This problem probably doesn't matter in the success case, as the VM...
qemu-ga: guest-shutdown: use only async-signal-safe functions
POSIX mandates1 that a child process of a multi-thread program usesonly async-signal-safe functions before exec(). We consider qemu-gato be multi-thread, because it uses glib.
However, qmp_guest_shutdown() uses functions that are not...
fix some common typos
These were identified using: http://github.com/lyda/misspell-checkand run like this to create a bourne shell script using GNU sed's-i option:
git ls-files|grep -vF .bin | misspellings -f - |grep -v '^ERROR:' |perl \-pe 's/^(.*?)\[(\d+)\]: (\w+) -> "(.*?)"$/sed -i '\''${2}s!$3!$4!'\'' $1/'...
Merge remote-tracking branch 'mdroth/qga-pull-4-27-12' into staging
qemu-ga: Implement alternative to O_ASYNC
ga_channel_open() was using open flag O_ASYNC for SIGIO-driven I/O.This breaks on illumos, so fall back to POSIX I_SETSIG ioctl (SIGPOLL).
Signed-off-by: Lee Essen <lee.essen@nowonline.co.uk>Signed-off-by: Andreas Färber <andreas.faerber@web.de>...
qemu-ga: add a whitelist for fsfreeze-safe commands
Currently we rely on fsfreeze/thaw commands disabling/enabling loggingthen having other commands check whether logging is disabled to avoidexecuting if they aren't safe for running while a filesystem is frozen....
qemu-ga: improve recovery options for fsfreeze
guest-fsfreeze-thaw relies on state information obtained fromguest-fsfreeze-freeze to determine what filesystems to unfreeze.This is unreliable due to the fact that that state does not accountfor FIFREEZE being issued by other processes, or previous instances...
qemu-ga: generate missing stubs for fsfreeze
When linux-specific commands (including guest-fsfreeze-*) were consolidatedunder defined(linux), we forgot to account for the case wheredefined(linux) && !defined(FIFREEZE). As a result stubs are no longer...
qemu-ga: fix bsd build, and re-org linux-specific implementations
qemu-ga: for w32, fix leaked handle ov.hEvent in ga_channel_write()
In the function ga_channel_write(), the handle ov.hEvent is createdby the call to CreateEvent(). However, the handle is not closedprior to the function return.
This patch closes the handle before the return of the function....
qemu-ga: add guest-sync-delimited
guest-sync leaves it as an exercise to the user as to how to reliablyobtain the response to guest-sync if the client had previously read in apartial response (due qemu-ga previously being restarted mid-"sentence" due to reboot, forced restart, etc)....
qemu-ga: add guest-suspend-disk
As the command name implies, this command suspends the guest to disk.
The suspend operation is implemented by two functions: bios_supports_mode()and guest_suspend(). Both functions are generic enough to be used byother suspend modes (introduced by next commits)....
qemu-ga: add guest-suspend-ram
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
qemu-ga: add guest-suspend-hybrid
qemu-ga: add win32 guest-suspend-disk command.
Implement guest-suspend-disk RPC for Windows. Functionally this should beequivalent to the posix implementation.
Signed-off-by: Gal Hammer <ghammer@redhat.com>
qemu-ga: add win32 guest-suspend-ram command
S3 sleep implementation for windows.
qemu-ga: add guest-network-get-interfaces command
This command returns an array of:
[ifname, hwaddr, [ipaddr, ipaddr_family, prefix] ]
for each interface in the system.Currently, only IPv4 and IPv6 are supported.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
qemu-ga: add Windows service integration
This allows qemu-ga to function as a Windows service:
- to install the service (will auto-start on boot): qemu-ga --service install - to start the service: net start qemu-ga - to stop the service: net stop qemu-ga...
qemu-ga: add win32 guest-shutdown command
Implement guest-shutdown RPC for Windows. Functionally this should beequivalent to the posix implementation.
Original patch by Gal Hammer <ghammer@redhat.com>
qemu-ga: add initial win32 support
This adds a win32 channel implementation that makes qemu-ga functionalon Windows using virtio-serial (unix-listen/isa-serial not currentlyimplemented). Unlike with the posix implementation, we do not useGIOChannel for the following reasons:...
qemu-ga: move channel/transport functionality into wrapper class
This is mostly in preparation for the win32 port, which won't useGIO channels for reasons that will be made clearer later. Here theGAChannel class is just a loose wrapper around GIOChannel...
qemu-ga: separate out common commands from posix-specific ones
Many of the current RPC implementations are very much POSIX-specificand require complete re-writes for Windows. There are however a smallset of core guest agent commands that are common to both, and other...
qemu-ga: rename guest-agent-commands.c -> commands-posix.c
qemu-ga: fixes for win32 build of qemu-ga
Various stubs and #ifdefs to compile for Windows using mingwcross-build. Still has 1 linker error due to a dependency on theforthcoming win32 versions of the GAChannel/transport class.
guest agent: add supported command list to guest-info RPC
Not that there is blacklisting functionality we can no longer inferthe agent's capabilities via version. This patch extends the currentguest-info RPC to also return a list of dictionaries containing the name...
Use glib memory allocation and free functions
qemu_malloc/qemu_free no longer exist after this commit.
guest-agent: only enable FSFREEZE when it's supported by the kernel
guest agent: use QERR_UNSUPPORTED for disabled RPCs
guest-agent: fix build with OpenBSD
FS-Freeze only works with Linux.
guest agent: command state class
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>Signed-off-by: Luiz Capitulino <lcapitulino@gmail.com>
guest agent: qemu-ga daemon
This is the actual guest daemon, it listens for requests over avirtio-serial/isa-serial/unix socket channel and routes them throughto dispatch routines, and writes the results back to the channel ina manner similar to QMP....
guest agent: add guest agent RPCs/commands
This adds the initial set of QMP/QAPI commands provided by the guestagent:
guest-syncguest-pingguest-infoguest-shutdownguest-file-openguest-file-readguest-file-writeguest-file-seekguest-file-flushguest-file-close...