Commit Graph

25 Commits

Author SHA1 Message Date
Fiona Ebner
7bd9abd243 tree-wide: switch to official spelling of QEMU in descriptions/messages
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2022-12-20 10:26:41 +01:00
Thomas Lamprecht
4d47a9f510 api: qga file-write: drop the check for base64
it's potentially expensive to check and the user already needs to
explicitly turn auto-encoding off, besides QEMU/QGA should handle
that and just error out gracefully on bogus base64 values.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-02-10 16:27:57 +01:00
Thomas Lamprecht
2b607ad1ab api: qga file-write: code/style cleanups/refactoring
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-02-10 16:26:53 +01:00
Dominik Csapak
0cb151937f fix #3683: agent file-write: enable user to encode the content themselves
by adding an optional parameter 'encode' (enabled by default). When it
is disabled, the content must be base64 encoded already. This
way, users can send a binary file to the vm by base64 encoding it
themselves

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2022-02-10 16:18:20 +01:00
Thomas Lamprecht
c0acd873f5 agent: code style fix
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-02-09 18:45:14 +01:00
Thomas Lamprecht
d1c1af4b02 tree wide cleanup of s/return undef/return/
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-10-16 16:20:05 +02:00
Thomas Lamprecht
109a095068 QGA exec: note limits explicit in CLI and API
The http-server has a 64KB payload limit for post requests, so note
that explicit even if it's a theoretical maximum as the reamainig
params also need some space in the request

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-03-06 17:57:46 +01:00
Stefan Reiter
d8f61794f6 fix #2612: allow input-data in guest exec and make command optional
'input-data' can be used to pass arbitrary data to a guest when running
an agent command with 'guest-exec'. Most guest-agent implementations
treat this as STDIN to the command given by "path"/"arg", but some go as
far as relying solely on this parameter, and even fail if "path" or
"arg" are set (e.g. Mikrotik Cloud Hosted Router) - thus "command" needs
to be made optional.

Via the API, an arbitrary string can be passed, on the command line ('qm
guest exec'), an additional '--pass-stdin' flag allows to forward STDIN
of the qm process to 'input-data', with a size limitation of 1 MiB to
not overwhelm QMP.

Without 'input-data' (API) or '--pass-stdin' (CLI) behaviour is unchanged.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2020-03-03 14:34:02 +01:00
Stefan Reiter
0a13e08ec2 refactor: create QemuServer::Monitor for high-level QMP access
QMP and monitor helpers are moved from QemuServer.pm.

By using only vm_running_locally instead of check_running, a cyclic
dependency to QemuConfig is avoided. This also means that the $nocheck
parameter serves no more purpose, and has thus been removed along with
vm_mon_cmd_nocheck.

Care has been taken to avoid errors resulting from this, and
occasionally a manual check for a VM's existance inserted on the
callsite.

Methods have been renamed to avoid redundant naming:
* vm_qmp_command -> qmp_cmd
* vm_mon_cmd -> mon_cmd
* vm_human_monitor_command -> hmp_cmd

mon_cmd is exported since it has many users. This patch also changes all
non-package users of vm_qmp_command to use the mon_cmd helper. Includes
mocking for tests.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2019-11-20 16:29:23 +01:00
Dominik Csapak
ba728fb535 fix #2457: ga: set-user-password: increase maxLength of password
SHA-512 crypted passwords are longer than 64 byte, and it also does
not make sense to limit passwords to such a short length.  Increase
to 1024, that should be enough for a while, but still limits maximal
password payload to avoid DOS or the like.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2019-11-11 16:28:44 +01:00
Thomas Lamprecht
ccd166381b agent: import used check_agent_error method
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2018-07-30 11:01:30 +02:00
Thomas Lamprecht
50ecb1ba58 api/agent: do not dereference params hash before passing to agent_cmd
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2018-07-30 10:41:48 +02:00
Dominik Csapak
332ff39abe add missing import of 'agent_cmd'
see https://pve.proxmox.com/pipermail/pve-user/2018-July/169712.html

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2018-07-30 08:56:39 +02:00
Dominik Csapak
735821a4fe implement file-write via guest-agent in the api
writes the given content to the file

the size is at the moment limited by the max post size of the
pveproxy/daemon, so we set the maxLength to 60k

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2018-07-11 10:29:45 +02:00
Dominik Csapak
bb14060a1c implement file-read api call via guest-agent
this api call reads a file via the guest agent,
(in 1MB chunks) but is limited to 16MiB (for now)

if the file is bigger, the output gets truncated and a
'truncated' flag is set in the return object

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2018-07-11 10:29:45 +02:00
Dominik Csapak
8efdf41820 implement agent exec api call
this imitates the qemu-guest-agent interface
with an 'exec' api call which returns a pid
and an 'exec-status' api call which takes a pid

the command for the exec call is given as an 'alist'
which means that when using we have to give the 'command'
parameter multiple times e.g.

pvesh create <...>/exec --command ls --command '-lha' --command '/home/user'

so that we avoid having to deal with shell escaping etc.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2018-07-11 10:29:45 +02:00
Dominik Csapak
b428fb63fa implement set-user-password guest agent api call
this executes the guest agent command 'set-user-password'
with which one can change the password of an existing user in the vm

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2018-07-11 10:29:45 +02:00
Dominik Csapak
3824765e64 add Agent helper package
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2018-07-11 10:29:45 +02:00
Thomas Lamprecht
a4938c7217 add nowarn to qga_check_running
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2018-05-30 09:01:11 +02:00
Alexandre Derumier
87f5df81a7 qm agent : check if qga service is running 2018-05-30 07:23:39 +02:00
Dominik Csapak
5667cc55fe add new guest-agent commands
between qemu 2.9 and 2.11 there were added some new commands,
the guest agent inside the vm has to support these

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2018-02-20 09:56:53 +01:00
Dominik Csapak
e6bd703b4e change some guest agent commands to GET api calls
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2018-02-20 09:56:50 +01:00
Dominik Csapak
ad1f73b9e4 add an guest agent index call
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2018-02-20 09:56:46 +01:00
Dominik Csapak
ea2bceaf19 make an api call for each guest agent command
with a 'register_command' sub, which generates an api call
we call it for each command in the list, and one time for
the old general {vmid}/agent endpoint (for compatibility)

permissions/methods are the same as previously, but can
be overriden

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2018-02-20 09:56:36 +01:00
Dominik Csapak
b8158701aa move guest agent api call to its own file
so we do not pollute the Qemu.pm too much

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2018-02-20 09:55:15 +01:00