aboutsummaryrefslogtreecommitdiff
path: root/qga/commands-posix.c
AgeCommit message (Collapse)AuthorFilesLines
2024-05-03qga/commands-posix: fix typo in qmp_guest_set_user_passwordPaolo Bonzini1-1/+1
qga/commands-posix.c does not compile on FreeBSD due to a confusion between "chpasswdata" (wrong) and "chpasswddata" (used in the #else branch). Fixes: 0e5b75a390 ("qga/commands-posix: qmp_guest_set_user_password: use ga_run_command helper") Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2024-05-01qga/commands-posix: qmp_guest_set_user_password: use ga_run_command helperAndrey Drobyshev1-83/+13
There's no need to check for the existence of the "chpasswd", "pw" executables, as the exec() call will do that for us. Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Konstantin Kostiuk <kkostiuk@redhat.com> Link: https://lore.kernel.org/r/20240320161648.158226-8-andrey.drobyshev@virtuozzo.com Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
2024-05-01qga/commands-posix: don't do fork()/exec() when suspending via sysfsAndrey Drobyshev1-36/+5
Since commit 246d76eba ("qga: guest_suspend: decoupling pm-utils and sys logic") pm-utils logic is running in a separate child from the sysfs logic. Now when suspending via sysfs we don't really need to do that in a separate process as we only need to perform one write to /sys/power/state. Let's just use g_file_set_contents() to simplify things here. Suggested-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Konstantin Kostiuk <kkostiuk@redhat.com> Link: https://lore.kernel.org/r/20240320161648.158226-7-andrey.drobyshev@virtuozzo.com Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
2024-05-01qga/commands-posix: execute_fsfreeze_hook: use ga_run_command helperAndrey Drobyshev1-32/+3
There's no need to check for the existence of the hook executable, as the exec() call will do that for us. Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Konstantin Kostiuk <kkostiuk@redhat.com> Link: https://lore.kernel.org/r/20240320161648.158226-6-andrey.drobyshev@virtuozzo.com Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
2024-05-01qga/commands-posix: qmp_guest_set_time: use ga_run_command helperAndrey Drobyshev1-40/+3
There's no need to check for the existence of "/sbin/hwclock", the exec() call will do that for us. Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Konstantin Kostiuk <kkostiuk@redhat.com> Link: https://lore.kernel.org/r/20240320161648.158226-5-andrey.drobyshev@virtuozzo.com Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
2024-05-01qga/commands-posix: qmp_guest_shutdown: use ga_run_command helperAndrey Drobyshev1-33/+6
Also remove the G_GNUC_UNUSED attribute added in the previous commit from the helper. Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Konstantin Kostiuk <kkostiuk@redhat.com> Link: https://lore.kernel.org/r/20240320161648.158226-4-andrey.drobyshev@virtuozzo.com Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
2024-05-01qga: introduce ga_run_command() helper for guest cmd executionAndrey Drobyshev1-0/+150
When executing guest commands in *nix environment, we repeat the same fork/exec pattern multiple times. Let's just separate it into a single helper which would also be able to feed input data into the launched process' stdin. This way we can avoid code duplication. To keep the history more bisectable, let's replace qmp commands implementations one by one. Also add G_GNUC_UNUSED attribute to the helper and remove it in the next commit. Originally-by: Yuri Pudgorodskiy <yur@virtuozzo.com> Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Konstantin Kostiuk <kkostiuk@redhat.com> Link: https://lore.kernel.org/r/20240320161648.158226-3-andrey.drobyshev@virtuozzo.com Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
2024-05-01qga: guest-get-fsinfo: add optional 'total-bytes-privileged' fieldAndrey Drobyshev1-0/+2
Since the commit 25b5ff1a86 ("qga: add mountpoint usage info to GuestFilesystemInfo") we have 2 values reported in guest-get-fsinfo: used = (f_blocks - f_bfree), total = (f_blocks - f_bfree + f_bavail) as returned by statvfs(3). While on Windows guests that's all we can get with GetDiskFreeSpaceExA(), on POSIX guests we might also be interested in total file system size, as it's visible for root user. Let's add an optional field 'total-bytes-privileged' to GuestFilesystemInfo struct, which'd only be reported on POSIX and represent f_blocks value as returned by statvfs(3). While here, also tweak the docs to reflect better where those values come from. Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Konstantin Kostiuk <kkostiuk@redhat.com> Link: https://lore.kernel.org/r/20240320161648.158226-2-andrey.drobyshev@virtuozzo.com Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
2024-01-30qga: Solaris has net/if_arp.h and netinet/if_ether.h but not ETHER_ADDR_LENNick Briggs1-1/+4
Solaris has net/if_arp.h and netinet/if_ether.h rather than net/ethernet.h, but does not define ETHER_ADDR_LEN, instead providing ETHERADDRL. Signed-off-by: Nick Briggs <nicholas.h.briggs@gmail.com> Reviewed-by: Konstantin Kostiuk <kkostiuk@redhat.com> Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
2023-09-08qga/: spelling fixesMichael Tokarev1-1/+1
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> Reviewed-by: Eric Blake <eblake@redhat.com>
2023-05-04qga: Fix suspend on Linux guests without systemdMark Somerville1-6/+6
Allow the Linux guest agent to attempt each of the suspend methods (systemctl, pm-* and writing to /sys) in turn. Prior to this guests without systemd failed to suspend due to `guest_suspend` returning early regardless of the return value of `systemd_supports_mode`. Signed-off-by: Mark Somerville <mark@qpok.net> Reviewed-by: Konstantin Kostiuk <kkostiuk@redhat.com> Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
2023-05-04qga/linux: add usb support to guest-get-fsinfoKfir Manor1-1/+5
Signed-off-by: Kfir Manor <kfir@daynix.com> Reviewed-by: Konstantin Kostiuk <kkostiuk@redhat.com> Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
2023-02-08qga: Clean up includesMarkus Armbruster1-1/+0
This commit was created with scripts/clean-includes. All .c should include qemu/osdep.h first. The script performs three related cleanups: * Ensure .c files include qemu/osdep.h first. * Including it in a .h is redundant, since the .c already includes it. Drop such inclusions. * Likewise, including headers qemu/osdep.h includes is redundant. Drop these, too. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Konstantin Kostiuk <kkostiuk@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Message-Id: <20230202133830.2152150-11-armbru@redhat.com>
2023-01-09error handling: Use RETRY_ON_EINTR() macro where applicableNikita Ivanov1-3/+1
There is a defined RETRY_ON_EINTR() macro in qemu/osdep.h which handles the same while loop. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/415 Signed-off-by: Nikita Ivanov <nivanov@cloudlinux.com> Message-Id: <20221023090422.242617-3-nivanov@cloudlinux.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> [thuth: Dropped the hunk that changed socket_accept() in libqtest.c] Signed-off-by: Thomas Huth <thuth@redhat.com>
2022-12-20qga: Add initial OpenBSD and NetBSD supportBrad Smith1-2/+7
qga: Add initial OpenBSD and NetBSD support Signed-off-by: Brad Smith <brad@comstyle.com> Reviewed-by: Konstantin Kostiuk <kkostiuk@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
2022-12-14qapi qga: Elide redundant has_FOO in generated CMarkus Armbruster1-24/+8
The has_FOO for pointer-valued FOO are redundant, except for arrays. They are also a nuisance to work with. Recent commit "qapi: Start to elide redundant has_FOO in generated C" provided the means to elide them step by step. This is the step for qga/qapi-schema.json. Said commit explains the transformation in more detail. The invariant violations mentioned there do not occur here. Cc: Michael Roth <michael.roth@amd.com> Cc: Konstantin Kostiuk <kkostiuk@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20221104160712.3005652-30-armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
2022-10-26qga: Move HW address getting to a separate functionAlexander Ivanov1-42/+56
In the next patch FreeBSD support for guest-network-get-interfaces will be added. Previously move Linux-specific code of HW address getting to a separate functions and add a dumb function to commands-bsd.c. Reviewed-by: Konstantin Kostiuk <kkostiuk@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com> Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
2022-10-26qga: Add support for user password setting in FreeBSDAlexander Ivanov1-10/+25
Move qmp_guest_set_user_password() from __linux__ condition to (__linux__ || __FreeBSD__) condition. Add command and arguments for password setting in FreeBSD. Reviewed-by: Konstantin Kostiuk <kkostiuk@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com> Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
2022-10-26qga: Add shutdown/halt/reboot support for FreeBSDAlexander Ivanov1-0/+7
Add appropriate shutdown command arguments to qmp_guest_shutdown() for FreeBSD. Reviewed-by: Konstantin Kostiuk <kkostiuk@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com> Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
2022-10-26qga: Add UFS freeze/thaw support for FreeBSDAlexander Ivanov1-158/+150
UFS supports FS freezing through ioctl UFSSUSPEND on /dev/ufssuspend. Frozen FS can be thawed by closing /dev/ufssuspend file descriptior. Use getmntinfo to get a list of mounted FS. Reviewed-by: Konstantin Kostiuk <kkostiuk@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com> Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
2022-10-26qga: Move Linux-specific FS freeze/thaw code to a separate fileAlexander Ivanov1-272/+15
In the next patches we are going to add FreeBSD support for QEMU Guest Agent. In the result, code in commands-posix.c will be too cumbersome. Move Linux-specific FS freeze/thaw code to a separate file commands-linux.c keeping common POSIX code in commands-posix.c. Reviewed-by: Konstantin Kostiuk <kkostiuk@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com> Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
2022-10-26qga: Add initial FreeBSD supportAlexander Ivanov1-0/+8
- Fix device path. - Fix virtio-serial channel initialization. - Make the code buildable in FreeBSD. Reviewed-by: Konstantin Kostiuk <kkostiuk@redhat.com> Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com> Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
2022-09-20qga: Replace 'blacklist' and 'whitelist' in the guest agent sourcesThomas Huth1-8/+8
Let's use better, more inclusive wording here. Message-Id: <20220727092135.302915-3-thuth@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Konstantin Kostiuk <kkostiuk@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
2022-07-18qga: treat get-guest-fsinfo as "best effort"John Snow1-1/+9
In some container environments, there may be references to block devices witnessable from a container through /proc/self/mountinfo that reference devices we simply don't have access to in the container, and cannot provide information about. Instead of failing the entire fsinfo command, return stub information for these failed lookups. This allows test-qga to pass under docker tests, which are in turn used by the CentOS VM tests. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20220708153503.18864-2-jsnow@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
2022-07-13qga: add command 'guest-get-cpustats'zhenwei pi1-0/+89
A vCPU thread always reaches 100% utilization when: - guest uses idle=poll - disable HLT vm-exit - enable MWAIT Add new guest agent command 'guest-get-cpustats' to get guest CPU statistics, we can know the guest workload and how busy the CPU is. Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: zhenwei pi <pizhenwei@bytedance.com> Message-Id: <20220707005602.696557-3-pizhenwei@bytedance.com> Reviewed-by: Konstantin Kostiuk <kkostiuk@redhat.com> Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
2022-05-28qga: make build_fs_mount_list() return a boolMarc-André Lureau1-15/+10
Change build_fs_mount_list() to return bool, in accordance with the guidance under = Rules = in include/qapi/error.h Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Suggested-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20220525144140.591926-10-marcandre.lureau@redhat.com>
2022-05-28qga: replace qemu_open_old() with qga_open_cloexec()Marc-André Lureau1-4/+4
qemu_open_old() uses qemu_open_internal() which handles special "/dev/fdset/" path for monitor fd sets, set CLOEXEC, and uses Error reporting (and some O_DIRECT special error casing). The monitor fdset handling is unnecessary for qga, use qga_open_cloexec() instead. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Konstantin Kostiuk <kkostiuk@redhat.com> Message-Id: <20220525144140.591926-9-marcandre.lureau@redhat.com>
2022-05-28qga: use qga_open_cloexec() for safe_open_or_create()Marc-André Lureau1-4/+3
The function takes care of setting CLOEXEC. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20220525144140.591926-7-marcandre.lureau@redhat.com>
2022-05-28qga: flatten safe_open_or_create()Marc-André Lureau1-60/+60
There is a bit too much nesting in the function, this can be simplified a bit to improve readability. This also helps with the following error handling changes. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20220525144140.591926-5-marcandre.lureau@redhat.com>
2022-05-25qga: add guest-get-diskstats command for Linux guestsluzhipeng1-0/+123
Add a new 'guest-get-diskstats' command for report disk io statistics for Linux guests. This can be useful for getting io flow or handling IO fault, no need to enter guests. Signed-off-by: luzhipeng <luzhipeng@cestc.cn> Message-Id: <20220520021935.676-1-luzhipeng@cestc.cn> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Konstantin Kostiuk <kkostiuk@redhat.com> Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
2022-05-04qga: Introduce disk smartzhenwei pi1-0/+73
After assigning a NVMe/SCSI controller to guest by VFIO, we lose everything on the host side. A guest uses these devices exclusively, we usually don't care the actions on these devices. But there is a low probability that hitting physical hardware warning, we need a chance to get the basic smart log info. Introduce disk smart, and implement NVMe smart on linux. Thanks to Keith and Marc-André. CC: Keith Busch <kbusch@kernel.org> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: zhenwei pi <pizhenwei@bytedance.com> Message-Id: <20220420022610.418052-3-pizhenwei@bytedance.com>
2022-05-04qga: Introduce NVMe disk bus typezhenwei pi1-1/+4
Assigning a NVMe disk by VFIO or emulating a NVMe controller by QEMU, a NVMe disk get exposed in guest side. Support NVMe disk bus type and implement posix version. Test PCI passthrough case: ~#virsh qemu-agent-command buster '{"execute":"guest-get-disks"}' | jq ... { "name": "/dev/nvme0n1", "dependencies": [], "partition": false, "address": { "serial": "SAMSUNG MZQL23T8HCLS-00A07_S64HNE0N500076", "bus-type": "nvme", "bus": 0, "unit": 0, "pci-controller": { "bus": 0, "slot": 22, "domain": 0, "function": 0 }, "dev": "/dev/nvme0n1", "target": 0 } ... Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: zhenwei pi <pizhenwei@bytedance.com> Message-Id: <20220420022610.418052-2-pizhenwei@bytedance.com>
2022-05-04qga/commands-posix: 'guest-shutdown' for SolarisAndrew Deason1-3/+18
On Solaris, instead of the -P, -H, and -r flags, we need to provide the target init state to the 'shutdown' command: state 5 is poweroff, 0 is halt, and 6 is reboot. We also need to pass -g0 to avoid the default 60-second delay, and -y to avoid a confirmation prompt. Implement this logic under an #ifdef CONFIG_SOLARIS, so the 'guest-shutdown' command works properly on Solaris. Signed-off-by: Andrew Deason <adeason@sinenomine.net> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20220426195526.7699-6-adeason@sinenomine.net>
2022-05-04qga/commands-posix: Log all net stats failuresAndrew Deason1-1/+5
guest_get_network_stats can silently fail in a couple of ways. Add debug messages to these cases, so we're never completely silent on failure. Signed-off-by: Andrew Deason <adeason@sinenomine.net> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20220426195526.7699-5-adeason@sinenomine.net>
2022-05-04qga/commands-posix: Fix listing ifaces for SolarisAndrew Deason1-1/+6
The code for guest-network-get-interfaces needs a couple of small adjustments for Solaris: - The results from SIOCGIFHWADDR are documented as being in ifr_addr, not ifr_hwaddr (ifr_hwaddr doesn't exist on Solaris). - The implementation of guest_get_network_stats is Linux-specific, so hide it under #ifdef CONFIG_LINUX. On non-Linux, we just won't provide network interface stats. Signed-off-by: Andrew Deason <adeason@sinenomine.net> Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Message-Id: <20220426195526.7699-4-adeason@sinenomine.net>
2022-05-04qga/commands-posix: Fix iface hw address detectionAndrew Deason1-15/+24
Since its introduction in commit 3424fc9f16a1 ("qemu-ga: add guest-network-get-interfaces command"), guest-network-get-interfaces seems to check if a given interface has a hardware address by checking 'ifa->ifa_flags & SIOCGIFHWADDR'. But ifa_flags is a field for IFF_* flags (IFF_UP, IFF_LOOPBACK, etc), and comparing it to an ioctl like SIOCGIFHWADDR doesn't make sense. On Linux, this isn't a big deal, since SIOCGIFHWADDR has so many bits set (0x8927), 'ifa->ifa_flags & SIOCGIFHWADDR' will usually have a nonzero result for any 'normal'-looking interfaces: anything with IFF_UP (0x1) or IFF_BROADCAST (0x2) set, as well as several less-common flags. This means we'll try to get the hardware address for most/all interfaces, even those that don't really have one (like the loopback device). For those interfaces, Linux just returns a hardware address of all zeroes. On Solaris, however, trying to get the hardware address for a loopback device returns an EADDRNOTAVAIL error. This causes us to return an error and the entire guest-network-get-interfaces call fails. Change this logic to always try to get the hardware address for each interface, and don't return an error if we fail to get it. Instead, just don't include the 'hardware-address' field in the result if we can't get the hardware address. Signed-off-by: Andrew Deason <adeason@sinenomine.net> Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Message-Id: <20220426195526.7699-3-adeason@sinenomine.net>
2022-05-04qga/commands-posix: Use getifaddrs when availableAndrew Deason1-229/+245
Currently, commands-posix.c assumes that getifaddrs() is only available on Linux, and so the related guest agent command guest-network-get-interfaces is only implemented for #ifdef __linux__. This function does exist on other platforms, though, such as Solaris. So, add a meson check for getifaddrs(), and move the code for guest-network-get-interfaces to be built whenever getifaddrs() is available. The implementation for guest-network-get-interfaces still has some Linux-specific code, which is not fixed in this commit. This commit moves the relevant big chunks of code around without changing them, so a future commit can change the code in place. Signed-off-by: Andrew Deason <adeason@sinenomine.net> Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Message-Id: <20220426195526.7699-2-adeason@sinenomine.net>
2022-05-03qga: replace qemu_set_nonblock()Marc-André Lureau1-1/+5
The call is POSIX-specific. Use the dedicated GLib API. (this is a preliminary patch before renaming qemu_set_nonblock()) Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2022-05-03qga: replace pipe() with g_unix_open_pipe(CLOEXEC)Marc-André Lureau1-1/+1
Suggested-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2022-04-21qga: move qga_get_host_name()Marc-André Lureau1-0/+35
The function is specific to qemu-ga, no need to share it in QEMU. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Konstantin Kostiuk <kkostiuk@redhat.com> Message-Id: <20220420132624.2439741-32-marcandre.lureau@redhat.com>
2022-04-06Remove qemu-common.h include from most unitsMarc-André Lureau1-1/+0
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20220323155743.1585078-33-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2022-04-06qga: remove explicit environ argument from exec/spawnMarc-André Lureau1-17/+7
Environment is implicitly inherited from the current process "environ" variable for execl() or g_spawn_sync(), no need to be explicit about it. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220323155743.1585078-31-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2022-04-06qga: replace qemu_gettimeofday() with g_get_real_time()Marc-André Lureau1-14/+0
GLib g_get_real_time() is an alternative to gettimeofday() which allows to simplify our code. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Reviewed-by: Thomas Huth <thuth@redhat.com> Message-Id: <20220307070401.171986-4-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2021-04-20qga: fix guest-get-disks regressionMarc-André Lureau1-0/+1
Commit 54aa3de72 ("qapi: Use QAPI_LIST_PREPEND() where possible") inadvertently removed the has_dependencies from the partition disk info, resulting in empty list being returned. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1950833 Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Message-id: 20210420125831.233092-1-marcandre.lureau@redhat.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2021-03-16qga: Add spaces around operatorAlexChen1-2/+2
Reported-by: Euler Robot <euler.robot@huawei.com> Signed-off-by: AlexChen <alex.chen@huawei.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> *fix 80+ char violation while we're here *fix w32 build breakage from changing INVALID_SET_FILE_POINTER definition from a cast to a subtraction Signed-off-by: Michael Roth <michael.roth@amd.com>
2021-03-16qga: Correct loop count in qmp_guest_get_vcpus()Lin Ma1-29/+14
The guest-get-vcpus returns incorrect vcpu info in case we hotunplug vcpus(not the last one). e.g.: A VM has 4 VCPUs: cpu0 + 3 hotunpluggable online vcpus(cpu1, cpu2 and cpu3). Hotunplug cpu2, Now only cpu0, cpu1 and cpu3 are present & online. ./qmp-shell /tmp/qmp-monitor.sock (QEMU) query-hotpluggable-cpus {"return": [ {"props": {"core-id": 0, "thread-id": 0, "socket-id": 3}, "vcpus-count": 1, "qom-path": "/machine/peripheral/cpu3", "type": "host-x86_64-cpu"}, {"props": {"core-id": 0, "thread-id": 0, "socket-id": 2}, "vcpus-count": 1, "qom-path": "/machine/peripheral/cpu2", "type": "host-x86_64-cpu"}, {"props": {"core-id": 0, "thread-id": 0, "socket-id": 1}, "vcpus-count": 1, "qom-path": "/machine/peripheral/cpu1", "type": "host-x86_64-cpu"}, {"props": {"core-id": 0, "thread-id": 0, "socket-id": 0}, "vcpus-count": 1, "qom-path": "/machine/unattached/device[0]", "type": "host-x86_64-cpu"} ]} (QEMU) device_del id=cpu2 {"return": {}} (QEMU) query-hotpluggable-cpus {"return": [ {"props": {"core-id": 0, "thread-id": 0, "socket-id": 3}, "vcpus-count": 1, "qom-path": "/machine/peripheral/cpu3", "type": "host-x86_64-cpu"}, {"props": {"core-id": 0, "thread-id": 0, "socket-id": 2}, "vcpus-count": 1, "type": "host-x86_64-cpu"}, {"props": {"core-id": 0, "thread-id": 0, "socket-id": 1}, "vcpus-count": 1, "qom-path": "/machine/peripheral/cpu1", "type": "host-x86_64-cpu"}, {"props": {"core-id": 0, "thread-id": 0, "socket-id": 0}, "vcpus-count": 1, "qom-path": "/machine/unattached/device[0]", "type": "host-x86_64-cpu"} ]} Before: ./qmp-shell -N /tmp/qmp-ga.sock Welcome to the QMP low-level shell! Connected (QEMU) guest-get-vcpus {"return": [ {"online": true, "can-offline": false, "logical-id": 0}, {"online": true, "can-offline": true, "logical-id": 1}]} After: ./qmp-shell -N /tmp/qmp-ga.sock Welcome to the QMP low-level shell! Connected (QEMU) guest-get-vcpus {"return": [ {"online": true, "can-offline": false, "logical-id": 0}, {"online": true, "can-offline": true, "logical-id": 1}, {"online": true, "can-offline": true, "logical-id": 3}]} Signed-off-by: Lin Ma <lma@suse.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> *fix build breakage by using PRId64 for sscanf Signed-off-by: Michael Roth <michael.roth@amd.com>
2021-03-05qga: Utilize QAPI_LIST_APPEND in qmp_guest_network_get_interfacesEric Blake1-45/+30
I found another spot that can benefit from using our macros instead of open-coding qapi list creation. Signed-off-by: Eric Blake <eblake@redhat.com> Message-Id: <20210205171634.1491258-1-eblake@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
2021-01-28qapi: More complex uses of QAPI_LIST_APPENDEric Blake1-13/+6
These cases require a bit more thought to review; in each case, the code was appending to a list, but not with a FOOList **tail variable. Signed-off-by: Eric Blake <eblake@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Message-Id: <20210113221013.390592-6-eblake@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> [Flawed change to qmp_guest_network_get_interfaces() dropped] Signed-off-by: Markus Armbruster <armbru@redhat.com>
2021-01-28qapi: Use QAPI_LIST_APPEND in trivial casesEric Blake1-22/+9
The easiest spots to use QAPI_LIST_APPEND are where we already have an obvious pointer to the tail of a list. While at it, consistently use the variable name 'tail' for that purpose. Signed-off-by: Eric Blake <eblake@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20210113221013.390592-5-eblake@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
2021-01-01Merge remote-tracking branch 'remotes/cohuck-gitlab/tags/s390x-20201222' ↵Peter Maydell1-0/+34
into staging Further s390x updates: - enhance the s390 devices acceptance test - tcg: improve carry computation - qga: send the ccw address with the fsinfo data - fixes for protected virtualisation and zpci # gpg: Signature made Tue 22 Dec 2020 10:37:34 GMT # gpg: using RSA key C3D0D66DC3624FF6A8C018CEDECF6B93C6F02FAF # gpg: issuer "cohuck@redhat.com" # gpg: Good signature from "Cornelia Huck <conny@cornelia-huck.de>" [unknown] # gpg: aka "Cornelia Huck <huckc@linux.vnet.ibm.com>" [full] # gpg: aka "Cornelia Huck <cornelia.huck@de.ibm.com>" [full] # gpg: aka "Cornelia Huck <cohuck@kernel.org>" [unknown] # gpg: aka "Cornelia Huck <cohuck@redhat.com>" [unknown] # Primary key fingerprint: C3D0 D66D C362 4FF6 A8C0 18CE DECF 6B93 C6F0 2FAF * remotes/cohuck-gitlab/tags/s390x-20201222: tests/acceptance: Add a test with the Fedora 31 kernel and initrd s390x/pci: Fix memory_region_access_valid call s390x/pci: fix pcistb length tests/acceptance: Test the virtio-balloon device on s390x tests/acceptance: Test virtio-rng on s390 via /dev/hwrng tests/acceptance: Extract the code to clear dmesg and wait for CRW reports tests/acceptance: test hot(un)plug of ccw devices target/s390x: Improve SUB LOGICAL WITH BORROW target/s390x: Improve cc computation for SUBTRACT LOGICAL target/s390x: Improve ADD LOGICAL WITH CARRY target/s390x: Improve cc computation for ADD LOGICAL qga/commands-posix: Send CCW address on s390x with the fsinfo data MAINTAINERS: move my git tree to gitlab s390x: pv: Fence additional unavailable SCLP facilities for PV guests Signed-off-by: Peter Maydell <peter.maydell@linaro.org>