b785d25e91
* Support for 32768 CPUs on x86 without IOMMU (David) * PDEP/PEXT fix and testcase (myself) * Remove bios_name and ram_size globals (myself) * qemu_init rationalization (myself) * Update kernel-doc (myself + upstream patches) * Propagate MemTxResult across DMA and PCI functions (Philippe) * Remove master/slave when applicable (Philippe) * WHPX support for in-kernel irqchip (Sunil) -----BEGIN PGP SIGNATURE----- iQFIBAABCAAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAl/SWS4UHHBib256aW5p QHJlZGhhdC5jb20ACgkQv/vSX3jHroMHLAf8Cr1nOn1ou2S2H9vePeoqRAVGdQBv tbQ/nZs+2NZMyhLF7mBj7y6Ym0wNyXzkyiFnN1wR04V5e0tF+q1Y0OOZtihJ+Ntk esjzHAzdqS22xI2dNnNDBo69eQQKDq3C0Ug5x6z63tO81AoTNKP+vq+QbZqe7v7K 2TScroAnhX9zE5Hz1+qJ35w13EMCNFnUPHNcOwxVSGHj4HNoEpIjjcE6rme46jX+ REsEGKJKIJ88aV2hzOLSrdJ0/mNuWsjfOvcfgtoIYUPbb55hHMykqD+LapoyEp8K gjnco6JT6wWFN1+tVxTjY4TaERVw+NGomd2QyHSbanDoRd8igFhxu2gBnQ== =yeQi -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/bonzini-gitlab/tags/for-upstream' into staging * Fix for NULL segments (Bin Meng) * Support for 32768 CPUs on x86 without IOMMU (David) * PDEP/PEXT fix and testcase (myself) * Remove bios_name and ram_size globals (myself) * qemu_init rationalization (myself) * Update kernel-doc (myself + upstream patches) * Propagate MemTxResult across DMA and PCI functions (Philippe) * Remove master/slave when applicable (Philippe) * WHPX support for in-kernel irqchip (Sunil) # gpg: Signature made Thu 10 Dec 2020 17:21:50 GMT # gpg: using RSA key F13338574B662389866C7682BFFBD25F78C7AE83 # gpg: issuer "pbonzini@redhat.com" # gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" [full] # gpg: aka "Paolo Bonzini <pbonzini@redhat.com>" [full] # Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4 E2F7 7E15 100C CD36 69B1 # Subkey fingerprint: F133 3857 4B66 2389 866C 7682 BFFB D25F 78C7 AE83 * remotes/bonzini-gitlab/tags/for-upstream: (113 commits) scripts: kernel-doc: remove unnecessary change wrt Linux Revert "docs: temporarily disable the kernel-doc extension" scripts: kernel-doc: use :c:union when needed scripts: kernel-doc: split typedef complex regex scripts: kernel-doc: fix typedef parsing Revert "kernel-doc: Handle function typedefs that return pointers" Revert "kernel-doc: Handle function typedefs without asterisks" scripts: kernel-doc: try to use c:function if possible scripts: kernel-doc: fix line number handling scripts: kernel-doc: allow passing desired Sphinx C domain dialect scripts: kernel-doc: don't mangle with parameter list scripts: kernel-doc: fix typedef identification scripts: kernel-doc: reimplement -nofunction argument scripts: kernel-doc: fix troubles with line counts scripts: kernel-doc: use a less pedantic markup for funcs on Sphinx 3.x scripts: kernel-doc: make it more compatible with Sphinx 3.x Revert "kernel-doc: Use c:struct for Sphinx 3.0 and later" Revert "scripts/kerneldoc: For Sphinx 3 use c:macro for macros with arguments" scripts: kernel-doc: add support for typedef enum kernel-doc: add support for ____cacheline_aligned attribute ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
397 lines
10 KiB
C
397 lines
10 KiB
C
/*
|
|
* QEMU Management Protocol commands
|
|
*
|
|
* Copyright IBM, Corp. 2011
|
|
*
|
|
* Authors:
|
|
* Anthony Liguori <aliguori@us.ibm.com>
|
|
*
|
|
* This work is licensed under the terms of the GNU GPL, version 2. See
|
|
* the COPYING file in the top-level directory.
|
|
*
|
|
* Contributions after 2012-01-13 are licensed under the terms of the
|
|
* GNU GPL, version 2 or (at your option) any later version.
|
|
*/
|
|
|
|
#include "qemu/osdep.h"
|
|
#include "qemu-common.h"
|
|
#include "qemu/cutils.h"
|
|
#include "qemu/option.h"
|
|
#include "monitor/monitor.h"
|
|
#include "sysemu/sysemu.h"
|
|
#include "qemu/config-file.h"
|
|
#include "qemu/uuid.h"
|
|
#include "chardev/char.h"
|
|
#include "ui/qemu-spice.h"
|
|
#include "ui/vnc.h"
|
|
#include "sysemu/kvm.h"
|
|
#include "sysemu/runstate.h"
|
|
#include "sysemu/arch_init.h"
|
|
#include "sysemu/blockdev.h"
|
|
#include "sysemu/block-backend.h"
|
|
#include "qapi/error.h"
|
|
#include "qapi/qapi-commands-acpi.h"
|
|
#include "qapi/qapi-commands-block.h"
|
|
#include "qapi/qapi-commands-control.h"
|
|
#include "qapi/qapi-commands-machine.h"
|
|
#include "qapi/qapi-commands-misc.h"
|
|
#include "qapi/qapi-commands-ui.h"
|
|
#include "qapi/qmp/qerror.h"
|
|
#include "hw/mem/memory-device.h"
|
|
#include "hw/acpi/acpi_dev_interface.h"
|
|
|
|
NameInfo *qmp_query_name(Error **errp)
|
|
{
|
|
NameInfo *info = g_malloc0(sizeof(*info));
|
|
|
|
if (qemu_name) {
|
|
info->has_name = true;
|
|
info->name = g_strdup(qemu_name);
|
|
}
|
|
|
|
return info;
|
|
}
|
|
|
|
KvmInfo *qmp_query_kvm(Error **errp)
|
|
{
|
|
KvmInfo *info = g_malloc0(sizeof(*info));
|
|
|
|
info->enabled = kvm_enabled();
|
|
info->present = kvm_available();
|
|
|
|
return info;
|
|
}
|
|
|
|
UuidInfo *qmp_query_uuid(Error **errp)
|
|
{
|
|
UuidInfo *info = g_malloc0(sizeof(*info));
|
|
|
|
info->UUID = qemu_uuid_unparse_strdup(&qemu_uuid);
|
|
return info;
|
|
}
|
|
|
|
void qmp_quit(Error **errp)
|
|
{
|
|
no_shutdown = 0;
|
|
qemu_system_shutdown_request(SHUTDOWN_CAUSE_HOST_QMP_QUIT);
|
|
}
|
|
|
|
void qmp_stop(Error **errp)
|
|
{
|
|
/* if there is a dump in background, we should wait until the dump
|
|
* finished */
|
|
if (dump_in_progress()) {
|
|
error_setg(errp, "There is a dump in process, please wait.");
|
|
return;
|
|
}
|
|
|
|
if (runstate_check(RUN_STATE_INMIGRATE)) {
|
|
autostart = 0;
|
|
} else {
|
|
vm_stop(RUN_STATE_PAUSED);
|
|
}
|
|
}
|
|
|
|
void qmp_system_reset(Error **errp)
|
|
{
|
|
qemu_system_reset_request(SHUTDOWN_CAUSE_HOST_QMP_SYSTEM_RESET);
|
|
}
|
|
|
|
void qmp_system_powerdown(Error **errp)
|
|
{
|
|
qemu_system_powerdown_request();
|
|
}
|
|
|
|
void qmp_x_exit_preconfig(Error **errp)
|
|
{
|
|
if (!runstate_check(RUN_STATE_PRECONFIG)) {
|
|
error_setg(errp, "The command is permitted only in '%s' state",
|
|
RunState_str(RUN_STATE_PRECONFIG));
|
|
return;
|
|
}
|
|
qemu_exit_preconfig_request();
|
|
}
|
|
|
|
void qmp_cont(Error **errp)
|
|
{
|
|
BlockBackend *blk;
|
|
BlockJob *job;
|
|
Error *local_err = NULL;
|
|
|
|
/* if there is a dump in background, we should wait until the dump
|
|
* finished */
|
|
if (dump_in_progress()) {
|
|
error_setg(errp, "There is a dump in process, please wait.");
|
|
return;
|
|
}
|
|
|
|
if (runstate_needs_reset()) {
|
|
error_setg(errp, "Resetting the Virtual Machine is required");
|
|
return;
|
|
} else if (runstate_check(RUN_STATE_SUSPENDED)) {
|
|
return;
|
|
} else if (runstate_check(RUN_STATE_FINISH_MIGRATE)) {
|
|
error_setg(errp, "Migration is not finalized yet");
|
|
return;
|
|
}
|
|
|
|
for (blk = blk_next(NULL); blk; blk = blk_next(blk)) {
|
|
blk_iostatus_reset(blk);
|
|
}
|
|
|
|
for (job = block_job_next(NULL); job; job = block_job_next(job)) {
|
|
block_job_iostatus_reset(job);
|
|
}
|
|
|
|
/* Continuing after completed migration. Images have been inactivated to
|
|
* allow the destination to take control. Need to get control back now.
|
|
*
|
|
* If there are no inactive block nodes (e.g. because the VM was just
|
|
* paused rather than completing a migration), bdrv_inactivate_all() simply
|
|
* doesn't do anything. */
|
|
bdrv_invalidate_cache_all(&local_err);
|
|
if (local_err) {
|
|
error_propagate(errp, local_err);
|
|
return;
|
|
}
|
|
|
|
if (runstate_check(RUN_STATE_INMIGRATE)) {
|
|
autostart = 1;
|
|
} else {
|
|
vm_start();
|
|
}
|
|
}
|
|
|
|
void qmp_system_wakeup(Error **errp)
|
|
{
|
|
if (!qemu_wakeup_suspend_enabled()) {
|
|
error_setg(errp,
|
|
"wake-up from suspend is not supported by this guest");
|
|
return;
|
|
}
|
|
|
|
qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, errp);
|
|
}
|
|
|
|
void qmp_set_password(const char *protocol, const char *password,
|
|
bool has_connected, const char *connected, Error **errp)
|
|
{
|
|
int disconnect_if_connected = 0;
|
|
int fail_if_connected = 0;
|
|
int rc;
|
|
|
|
if (has_connected) {
|
|
if (strcmp(connected, "fail") == 0) {
|
|
fail_if_connected = 1;
|
|
} else if (strcmp(connected, "disconnect") == 0) {
|
|
disconnect_if_connected = 1;
|
|
} else if (strcmp(connected, "keep") == 0) {
|
|
/* nothing */
|
|
} else {
|
|
error_setg(errp, QERR_INVALID_PARAMETER, "connected");
|
|
return;
|
|
}
|
|
}
|
|
|
|
if (strcmp(protocol, "spice") == 0) {
|
|
if (!qemu_using_spice(errp)) {
|
|
return;
|
|
}
|
|
rc = qemu_spice.set_passwd(password, fail_if_connected,
|
|
disconnect_if_connected);
|
|
} else if (strcmp(protocol, "vnc") == 0) {
|
|
if (fail_if_connected || disconnect_if_connected) {
|
|
/* vnc supports "connected=keep" only */
|
|
error_setg(errp, QERR_INVALID_PARAMETER, "connected");
|
|
return;
|
|
}
|
|
/* Note that setting an empty password will not disable login through
|
|
* this interface. */
|
|
rc = vnc_display_password(NULL, password);
|
|
} else {
|
|
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "protocol",
|
|
"'vnc' or 'spice'");
|
|
return;
|
|
}
|
|
|
|
if (rc != 0) {
|
|
error_setg(errp, "Could not set password");
|
|
}
|
|
}
|
|
|
|
void qmp_expire_password(const char *protocol, const char *whenstr,
|
|
Error **errp)
|
|
{
|
|
time_t when;
|
|
int rc;
|
|
|
|
if (strcmp(whenstr, "now") == 0) {
|
|
when = 0;
|
|
} else if (strcmp(whenstr, "never") == 0) {
|
|
when = TIME_MAX;
|
|
} else if (whenstr[0] == '+') {
|
|
when = time(NULL) + strtoull(whenstr+1, NULL, 10);
|
|
} else {
|
|
when = strtoull(whenstr, NULL, 10);
|
|
}
|
|
|
|
if (strcmp(protocol, "spice") == 0) {
|
|
if (!qemu_using_spice(errp)) {
|
|
return;
|
|
}
|
|
rc = qemu_spice.set_pw_expire(when);
|
|
} else if (strcmp(protocol, "vnc") == 0) {
|
|
rc = vnc_display_pw_expire(NULL, when);
|
|
} else {
|
|
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "protocol",
|
|
"'vnc' or 'spice'");
|
|
return;
|
|
}
|
|
|
|
if (rc != 0) {
|
|
error_setg(errp, "Could not set password expire time");
|
|
}
|
|
}
|
|
|
|
#ifdef CONFIG_VNC
|
|
void qmp_change_vnc_password(const char *password, Error **errp)
|
|
{
|
|
if (vnc_display_password(NULL, password) < 0) {
|
|
error_setg(errp, "Could not set password");
|
|
}
|
|
}
|
|
|
|
static void qmp_change_vnc_listen(const char *target, Error **errp)
|
|
{
|
|
QemuOptsList *olist = qemu_find_opts("vnc");
|
|
QemuOpts *opts;
|
|
|
|
if (strstr(target, "id=")) {
|
|
error_setg(errp, "id not supported");
|
|
return;
|
|
}
|
|
|
|
opts = qemu_opts_find(olist, "default");
|
|
if (opts) {
|
|
qemu_opts_del(opts);
|
|
}
|
|
opts = vnc_parse(target, errp);
|
|
if (!opts) {
|
|
return;
|
|
}
|
|
|
|
vnc_display_open("default", errp);
|
|
}
|
|
|
|
static void qmp_change_vnc(const char *target, bool has_arg, const char *arg,
|
|
Error **errp)
|
|
{
|
|
if (strcmp(target, "passwd") == 0 || strcmp(target, "password") == 0) {
|
|
if (!has_arg) {
|
|
error_setg(errp, QERR_MISSING_PARAMETER, "password");
|
|
} else {
|
|
qmp_change_vnc_password(arg, errp);
|
|
}
|
|
} else {
|
|
qmp_change_vnc_listen(target, errp);
|
|
}
|
|
}
|
|
#endif /* !CONFIG_VNC */
|
|
|
|
void qmp_change(const char *device, const char *target,
|
|
bool has_arg, const char *arg, Error **errp)
|
|
{
|
|
if (strcmp(device, "vnc") == 0) {
|
|
#ifdef CONFIG_VNC
|
|
qmp_change_vnc(target, has_arg, arg, errp);
|
|
#else
|
|
error_setg(errp, QERR_FEATURE_DISABLED, "vnc");
|
|
#endif
|
|
} else {
|
|
qmp_blockdev_change_medium(true, device, false, NULL, target,
|
|
has_arg, arg, false, 0, errp);
|
|
}
|
|
}
|
|
|
|
void qmp_add_client(const char *protocol, const char *fdname,
|
|
bool has_skipauth, bool skipauth, bool has_tls, bool tls,
|
|
Error **errp)
|
|
{
|
|
Chardev *s;
|
|
int fd;
|
|
|
|
fd = monitor_get_fd(monitor_cur(), fdname, errp);
|
|
if (fd < 0) {
|
|
return;
|
|
}
|
|
|
|
if (strcmp(protocol, "spice") == 0) {
|
|
if (!qemu_using_spice(errp)) {
|
|
close(fd);
|
|
return;
|
|
}
|
|
skipauth = has_skipauth ? skipauth : false;
|
|
tls = has_tls ? tls : false;
|
|
if (qemu_spice.display_add_client(fd, skipauth, tls) < 0) {
|
|
error_setg(errp, "spice failed to add client");
|
|
close(fd);
|
|
}
|
|
return;
|
|
#ifdef CONFIG_VNC
|
|
} else if (strcmp(protocol, "vnc") == 0) {
|
|
skipauth = has_skipauth ? skipauth : false;
|
|
vnc_display_add_client(NULL, fd, skipauth);
|
|
return;
|
|
#endif
|
|
} else if ((s = qemu_chr_find(protocol)) != NULL) {
|
|
if (qemu_chr_add_client(s, fd) < 0) {
|
|
error_setg(errp, "failed to add client");
|
|
close(fd);
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
|
|
error_setg(errp, "protocol '%s' is invalid", protocol);
|
|
close(fd);
|
|
}
|
|
|
|
|
|
MemoryDeviceInfoList *qmp_query_memory_devices(Error **errp)
|
|
{
|
|
return qmp_memory_device_list();
|
|
}
|
|
|
|
ACPIOSTInfoList *qmp_query_acpi_ospm_status(Error **errp)
|
|
{
|
|
bool ambig;
|
|
ACPIOSTInfoList *head = NULL;
|
|
ACPIOSTInfoList **prev = &head;
|
|
Object *obj = object_resolve_path_type("", TYPE_ACPI_DEVICE_IF, &ambig);
|
|
|
|
if (obj) {
|
|
AcpiDeviceIfClass *adevc = ACPI_DEVICE_IF_GET_CLASS(obj);
|
|
AcpiDeviceIf *adev = ACPI_DEVICE_IF(obj);
|
|
|
|
adevc->ospm_status(adev, &prev);
|
|
} else {
|
|
error_setg(errp, "command is not supported, missing ACPI device");
|
|
}
|
|
|
|
return head;
|
|
}
|
|
|
|
MemoryInfo *qmp_query_memory_size_summary(Error **errp)
|
|
{
|
|
MemoryInfo *mem_info = g_malloc0(sizeof(MemoryInfo));
|
|
MachineState *ms = MACHINE(qdev_get_machine());
|
|
|
|
mem_info->base_memory = ms->ram_size;
|
|
|
|
mem_info->plugged_memory = get_plugged_memory_size();
|
|
mem_info->has_plugged_memory =
|
|
mem_info->plugged_memory != (uint64_t)-1;
|
|
|
|
return mem_info;
|
|
}
|