]> git.proxmox.com Git - qemu-server.git/log
qemu-server.git
4 years agovmconfig_apply_pending: add error handling
Oguz Bektas [Tue, 7 Jan 2020 15:55:18 +0000 (16:55 +0100)]
vmconfig_apply_pending: add error handling

wrap around code which can possibly fail in evals to handle them
gracefully, and log errors.

note: this results in a change of behavior in the API. since errors
are handled gracefully instead of "die"ing, when there is a pending
change which cannot be applied for some reason, it will get logged in
the tasklog but the vm will continue booting regardless. the
non-applied change will stay in the pending section of the
configuration.

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoRemove unused 'sharedvm' variable
Fabian Ebner [Thu, 9 Jan 2020 09:23:07 +0000 (10:23 +0100)]
Remove unused 'sharedvm' variable

AFAICT this one hasn't been in use since commit
'4530494bf9f3d45c4a405c53ef3688e641f6bd8e'

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
4 years agohotplug_pending: remove redundant write/load config calls
Oguz Bektas [Fri, 13 Dec 2019 11:41:51 +0000 (12:41 +0100)]
hotplug_pending: remove redundant write/load config calls

instead of writing the config after every change, we can do it once for
all the changes in the end to avoid redundant i/o.

we also don't need to load_config after writing fastplug changes.

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
4 years agobump version to 6.1-4
Thomas Lamprecht [Mon, 16 Dec 2019 15:03:30 +0000 (16:03 +0100)]
bump version to 6.1-4

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoapi/restore: do not trigger autostart task from locked context
Thomas Lamprecht [Mon, 16 Dec 2019 14:56:46 +0000 (15:56 +0100)]
api/restore: do not trigger autostart task from locked context

Do the same as for the "create" case, only trigger the "start after
create/restore" task after the locked "realcmd" was done. Else, the
start can never succeed, it also acquires a lock, but restore only
release it once outside of realcmd.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agogrammar fix: s/does not exists/does not exist/g
Thomas Lamprecht [Fri, 13 Dec 2019 11:11:58 +0000 (12:11 +0100)]
grammar fix: s/does not exists/does not exist/g

bump versioned build-dependency, as qemu-server has tests checking
for errors, and we fixed an grammar error in pve-storage, so we need
the newer version to ensure our test go through

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agofollowup: simplify log callback
Thomas Lamprecht [Thu, 12 Dec 2019 12:38:55 +0000 (13:38 +0100)]
followup: simplify log callback

run_command only passes defined and chomped strings to the callback,
so no need to do that twice.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agofix #2493: show QEMU errors in migration log
Stefan Reiter [Mon, 9 Dec 2019 15:14:09 +0000 (16:14 +0100)]
fix #2493: show QEMU errors in migration log

QEMU usually only prints warnings and errors and stays silent otherwise,
so it makes sense to just log all of it's output.

Prefix it with '[<target_hostname>]' to indicate that the output is
coming from the remote node, so users know where to search for the
error.

Side effect is that the 'VM start' task created by the migration will
now show the "QEMU:" prefix, but it's still very readable IMHO.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agohide long commandline on vm_start/migrate failure
Stefan Reiter [Mon, 9 Dec 2019 15:14:08 +0000 (16:14 +0100)]
hide long commandline on vm_start/migrate failure

By default run_command prints the entire commandline executed when an
error occurs, but QEMU and our migrate command are not only
uninteresting to the user[*] but also annoyingly long. Hide them and only
print the exit code.

[*] Especially our migrate command, since it can't be manually executed
anyway. QEMU's commandline *might* contain something interesting, but is
so long that it's tricky to parse anyway, any a user can always call 'qm
showcmd --pretty'.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agoupdate disk size before local disk migration
Stefan Reiter [Mon, 9 Dec 2019 13:08:09 +0000 (14:08 +0100)]
update disk size before local disk migration

Split out 'update_disksize' from the renamed 'update_disk_config' to
allow code reuse in QemuMigrate.

Remove dots after messages to keep style consistent for migration log.

After updating in sync_disks (phase1) of migration, write out updated
config. This means that even if migration fails or is aborted in later
stages, we keep the fixed config - this is not an issue, as it would
have been fixed on the next attempt anyway, and it can't hurt to have
the correct size instead of a wrong one either way.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agomove vmstate check to check_vm_modify_config_perm
Dominik Csapak [Mon, 9 Dec 2019 14:27:00 +0000 (15:27 +0100)]
move vmstate check to check_vm_modify_config_perm

so that it gets checked before the special case of removing the vmstate

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
4 years agosuspend to disk: check more permissions
Dominik Csapak [Mon, 9 Dec 2019 14:26:59 +0000 (15:26 +0100)]
suspend to disk: check more permissions

only VM.PowerMgmt is not enough, since we allocate space on a storage,
so we need VM.Config.Disk on the vm and Datastore.AllocateSpace on the storage

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
4 years agorefactor finding of vmstate storage
Dominik Csapak [Mon, 9 Dec 2019 14:26:58 +0000 (15:26 +0100)]
refactor finding of vmstate storage

we need that on another place, so refactor in its own sub

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
4 years agofix wrong punctuation in error msg
Stefan Reiter [Mon, 9 Dec 2019 15:14:07 +0000 (16:14 +0100)]
fix wrong punctuation in error msg

...leading to ugly line info being printed.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agocfg2cmd: allow to test for expected error messages
Thomas Lamprecht [Tue, 10 Dec 2019 10:07:00 +0000 (11:07 +0100)]
cfg2cmd: allow to test for expected error messages

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoqemu-server: make nodename mock-able for tests
Thomas Lamprecht [Tue, 10 Dec 2019 10:05:39 +0000 (11:05 +0100)]
qemu-server: make nodename mock-able for tests

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agofollowup: improve error message for outdated QEMU version
Thomas Lamprecht [Tue, 10 Dec 2019 10:06:17 +0000 (11:06 +0100)]
followup: improve error message for outdated QEMU version

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agocheck if QEMU version is recent enough for machine type
Stefan Reiter [Mon, 9 Dec 2019 15:14:10 +0000 (16:14 +0100)]
check if QEMU version is recent enough for machine type

...and show the user a more meaningful error otherwise.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agobump version to 6.1-3
Thomas Lamprecht [Mon, 9 Dec 2019 09:34:43 +0000 (10:34 +0100)]
bump version to 6.1-3

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoremove $vmid param from print_drive
Stefan Reiter [Thu, 5 Dec 2019 15:11:01 +0000 (16:11 +0100)]
remove $vmid param from print_drive

It isn't used in the sub, but suggest it is needed. No users outside
qemu-server found.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agocfg2cmd: test runs_at_least_qemu_version and version_cmp explicitly
Stefan Reiter [Wed, 4 Dec 2019 12:15:51 +0000 (13:15 +0100)]
cfg2cmd: test runs_at_least_qemu_version and version_cmp explicitly

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agocfg2cmd: minor cleanup
Stefan Reiter [Wed, 4 Dec 2019 12:15:50 +0000 (13:15 +0100)]
cfg2cmd: minor cleanup

We never shipped a 4.1.0 QEMU, so it makes more sense to test as 4.1.1

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agofollowup: minor cleanup/error message spelling
Thomas Lamprecht [Mon, 9 Dec 2019 10:29:26 +0000 (11:29 +0100)]
followup: minor cleanup/error message spelling

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agofix #2510: hostpci: always check if device exists
Dominik Csapak [Mon, 9 Dec 2019 09:10:04 +0000 (10:10 +0100)]
fix #2510: hostpci: always check if device exists

if the user set a device as hostpci with the 'shorthand' syntax:

hostpciX: 00:12

we ignored it on starting and showcmd and continued.
Since the user explicitly wanted to passthrough a device, we now check
if there is actually a device with that id

for explicitly configured devices (00:12.1), we did not check if it exists,
but the kvm call failed with a non-obvious error message

now we always call 'lspci' from SysFSTools to check if it actually exists,
and fail if not. With this, we can drop the workaround for adding
'0000' if no domain was given, since lspci does it already for us

this fixes #2510, an issue with using mediated devices where the users did not have
the domain in the config, since we forgot to add the default domain there

the only issue with this patch is that it changes the behaviour of
'showcmd' slightly, as in now, we die if the device was explicitly
given, but did not exists (we showed the commandline, now we fail)

this also slightly changes the commandline for qemu (adding always
the domain), which is not a problem since we cannot live migrate
or snapshot such vms, but we have to adapt the tests

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
4 years agocfg2cmd test: add tests for multifunction devices
Dominik Csapak [Mon, 9 Dec 2019 09:10:03 +0000 (10:10 +0100)]
cfg2cmd test: add tests for multifunction devices

by mocking the lspci call

the mocked lspci code is basically the same as the real one,
only difference is the source of the devices and
there is no verbose flag

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
4 years agoRevert "fix #2478: record python3-minimal as build dependency"
Thomas Lamprecht [Mon, 9 Dec 2019 09:32:46 +0000 (10:32 +0100)]
Revert "fix #2478: record python3-minimal as build dependency"

This reverts commit 951b1783cdd328990b46b47a60a457e5acc33cb0.

4 years agofix #2469: fix qemu-img convert src_format detection
Thomas Lamprecht [Mon, 9 Dec 2019 09:31:33 +0000 (10:31 +0100)]
fix #2469: fix qemu-img convert src_format detection

This reverts commit c5151cb8bb5f919c9e621065224c3d455b60f833 which is
a revert of the wrongly done revert of
commit e2414e73ce75893a143dc32cf6a4e58159cc25ff.

4 years agocreate_efidisk: poll the real size after volume creation
Thomas Lamprecht [Wed, 4 Dec 2019 17:40:31 +0000 (18:40 +0100)]
create_efidisk: poll the real size after volume creation

some storage backends have bigger granularity than the default 128k
size from the EFIVARS template file, so we actually need to poll the
real created disk size, as it will be used to create the target
volume for local storage migration on running VMs, if it's to small
the target will be to small and migration will fail.

Just a fix for newly created EFIDISKS, for others we need to rescan
the size after we've got the migrate lock and write the updated info
out, so that the target node has the correct one (protected from
migrate lock).

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agorefactor storage whitelist in sync_disks to regex
Thomas Lamprecht [Wed, 4 Dec 2019 17:40:03 +0000 (18:40 +0100)]
refactor storage whitelist in sync_disks to regex

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agobump version to 6.1-2
Thomas Lamprecht [Sat, 30 Nov 2019 17:38:50 +0000 (18:38 +0100)]
bump version to 6.1-2

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoapi: allow to clear vmstate actively
Thomas Lamprecht [Sat, 30 Nov 2019 17:17:17 +0000 (18:17 +0100)]
api: allow to clear vmstate actively

Sometimes, a user wants to remove the 'suspended' state without
resuming the vm from that state. Since the vm is locked with
'suspended', this was not possible without help from root@pam

This patch allows to delete the vmstate and the suspended lock and
related config entries with it. The user still has to have the right
priviliges and the vm cannot be 'protected' for this to work

Inspired-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoimplement removal of vmstate via api
Dominik Csapak [Fri, 29 Nov 2019 10:06:48 +0000 (11:06 +0100)]
implement removal of vmstate via api

we did not actually delete the state if we deleted the 'vmstate' config,
leaving stray vmstates on the disks

actually implement the removal, requiring 'VM.Config.Disk' and
'VM.PowerMgmt' privs

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
4 years agodelete suspended lock when we have no vmstate
Dominik Csapak [Fri, 29 Nov 2019 10:06:47 +0000 (11:06 +0100)]
delete suspended lock when we have no vmstate

if a user removed the vmstate from the config for whatever reason,
a vmstart did not remove the 'suspended' lock
so always delete it and delete the vmstate only if it really was there

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
4 years agologging vmstate into Resume/Start Task
Dominik Csapak [Fri, 29 Nov 2019 10:06:46 +0000 (11:06 +0100)]
logging vmstate into Resume/Start Task

so that the user knows what got loaded as vmstate

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
4 years agomigrate phase 3 cleanup: add error into error propagation message
Thomas Lamprecht [Sat, 30 Nov 2019 16:27:14 +0000 (17:27 +0100)]
migrate phase 3 cleanup: add error into error propagation message

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agomon_cmd: add explicit return
Thomas Lamprecht [Sat, 30 Nov 2019 16:24:55 +0000 (17:24 +0100)]
mon_cmd: add explicit return

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agovzdump: log QGA FS freeze/thaw try in task log
Thomas Lamprecht [Wed, 27 Nov 2019 19:18:15 +0000 (20:18 +0100)]
vzdump: log QGA FS freeze/thaw try in task log

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoskip efidisk0 in hotplug
Oguz Bektas [Tue, 26 Nov 2019 16:07:49 +0000 (17:07 +0100)]
skip efidisk0 in hotplug

while it's a disk from our storage POV, in QEMU it's a pflash, and
those cannot be hot-plugged

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agocleanup build artificats before doc clean
Thomas Lamprecht [Tue, 26 Nov 2019 12:53:18 +0000 (13:53 +0100)]
cleanup build artificats before doc clean

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agobump version to 6.1-1
Thomas Lamprecht [Tue, 26 Nov 2019 12:04:59 +0000 (13:04 +0100)]
bump version to 6.1-1

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoRevert "fix #2469: fix qemu-img convert src_format detection"
Thomas Lamprecht [Tue, 26 Nov 2019 12:05:54 +0000 (13:05 +0100)]
Revert "fix #2469: fix qemu-img convert src_format detection"

This reverts commit e2414e73ce75893a143dc32cf6a4e58159cc25ff.

4 years agofix #2478: record python3-minimal as build dependency
Thomas Lamprecht [Tue, 26 Nov 2019 10:37:18 +0000 (11:37 +0100)]
fix #2478: record python3-minimal as build dependency

Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoimplement PVE Version addition for QEMU machine
Thomas Lamprecht [Mon, 25 Nov 2019 10:18:13 +0000 (11:18 +0100)]
implement PVE Version addition for QEMU machine

With our QEMU 4.1.1 package we can pass a additional internal version
to QEMU's machine, it will be split out there and ignored, but
returned on a QMP 'query-machines' call.

This allows us to use it for increasing the granularity with which we
can roll-out HW layout changes/additions for VMs. Until now we
required a machine version bump, happening normally every major
release of QEMU, with seldom, for us irrelevant, exceptions.
This often delays rolling out a feature, which would break
live-migration, by several months. That can now be avoided, the new
"pve-version" component of the machine can be bumped at will, and
thus we are much more flexible.

That versions orders after the ($major, $minor) version components
from an stable release - it can thus also be reset on the next
release.

The implementation extends the qemu-machine REGEX, remembers
"pve-version" when doing a "query-machines" and integrates support
into the min_version and extract_version helpers.

We start out with a version of 1.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Reviewed-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agofix #2469: fix qemu-img convert src_format detection
Fabian Grünbichler [Mon, 25 Nov 2019 11:03:28 +0000 (12:03 +0100)]
fix #2469: fix qemu-img convert src_format detection

if we don't know which format the source volume/file has, let qemu-img
decide.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoversion_cmp: give info about caller on error
Thomas Lamprecht [Mon, 25 Nov 2019 10:16:38 +0000 (11:16 +0100)]
version_cmp: give info about caller on error

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoapi: use get_vm_arch instead of depreacted basic_machine_info
Thomas Lamprecht [Mon, 25 Nov 2019 09:51:32 +0000 (10:51 +0100)]
api: use get_vm_arch instead of depreacted basic_machine_info

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoremove wrong comment
Fabian Grünbichler [Mon, 25 Nov 2019 09:38:13 +0000 (10:38 +0100)]
remove wrong comment

the change to encode pending changes differently is not yet included in
qemu-server.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agoapi: catch 'pending' as snapshot name early
Fabian Grünbichler [Mon, 25 Nov 2019 09:02:46 +0000 (10:02 +0100)]
api: catch 'pending' as snapshot name early

instead of only at write_config time.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agofix #2367: do not allow snapshot with name PENDING
Oguz Bektas [Thu, 24 Oct 2019 11:53:09 +0000 (13:53 +0200)]
fix #2367: do not allow snapshot with name PENDING

or any other variant of the word 'pending'.

note that we can actually allow this snapshot after PVE 7.0, since
pending section and snapshots will be properly namespaced.
([pve:pending] and [snap:$snapname] or similar).

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
4 years agosplit get_basic_machine_info into get_vm_arch and get_vm_machine
Thomas Lamprecht [Mon, 25 Nov 2019 07:56:58 +0000 (08:56 +0100)]
split get_basic_machine_info into get_vm_arch and get_vm_machine

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agovm start use new pve-qemu-machine standard option
Thomas Lamprecht [Mon, 25 Nov 2019 07:54:07 +0000 (08:54 +0100)]
vm start use new pve-qemu-machine standard option

'pve-qm-machine' is auto-registered, but for re-use for a new
runningmachine we added the newer pve-qemu-machine standard option.
Use that one to avoid confusion.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agocfg2cmd test: fix spice enhancement test
Thomas Lamprecht [Mon, 25 Nov 2019 06:45:44 +0000 (07:45 +0100)]
cfg2cmd test: fix spice enhancement test

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agobump version to 6.0-17
Thomas Lamprecht [Sat, 23 Nov 2019 08:52:17 +0000 (09:52 +0100)]
bump version to 6.0-17

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoreally fallback to PCI standard domain "0000" again
Thomas Lamprecht [Sat, 23 Nov 2019 08:47:56 +0000 (09:47 +0100)]
really fallback to PCI standard domain "0000" again

fixes commit 70740c1a4d60b002249a648cc6588ecddb44ec70

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agobump version to 6.0-16
Thomas Lamprecht [Fri, 22 Nov 2019 13:19:01 +0000 (14:19 +0100)]
bump version to 6.0-16

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agofixup: use correct version_cmp
Thomas Lamprecht [Fri, 22 Nov 2019 13:18:02 +0000 (14:18 +0100)]
fixup: use correct version_cmp

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agofix #2473: use of unitialized value
Mira Limbeck [Thu, 21 Nov 2019 10:04:25 +0000 (11:04 +0100)]
fix #2473: use of unitialized value

With the noerr flag set in parse_volume_id we have to check if
$volname is defined before comparing it to 'cloudinit'.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
4 years agobump version to 6.0-15
Thomas Lamprecht [Wed, 20 Nov 2019 18:41:05 +0000 (19:41 +0100)]
bump version to 6.0-15

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoadd 'tags' option
Dominik Csapak [Thu, 31 Oct 2019 12:36:25 +0000 (13:36 +0100)]
add 'tags' option

this is useful as meta information for e.g., provisioning or config
management systems

adding the info also to the 'status' api call to make it easier to show
it in the gui

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
4 years agod/control: bump versioned dependency on pve-common
Thomas Lamprecht [Wed, 20 Nov 2019 18:08:33 +0000 (19:08 +0100)]
d/control: bump versioned dependency on pve-common

to ensure the sysfs PCI tools can cope with our new more flexible PCI
addr (domain != 0000) fix

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agofix #2436: pci: do not hardcode pci domain to 0000
Dominik Csapak [Tue, 12 Nov 2019 13:23:03 +0000 (14:23 +0100)]
fix #2436: pci: do not hardcode pci domain to 0000

relax the regex for hostpci to allow different pci domains than 0000

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
4 years agod/control: break old ha-manager, pve-manager
Thomas Lamprecht [Wed, 20 Nov 2019 18:06:57 +0000 (19:06 +0100)]
d/control: break old ha-manager, pve-manager

due to the refactoring file/module movements we made

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agocleanup: improve locallity of variable declaration/use
Thomas Lamprecht [Wed, 20 Nov 2019 18:06:15 +0000 (19:06 +0100)]
cleanup: improve locallity of variable declaration/use

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agofollowup snapshot-test: pass class to cfs_config_path
Thomas Lamprecht [Wed, 20 Nov 2019 18:05:14 +0000 (19:05 +0100)]
followup snapshot-test: pass class to cfs_config_path

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agorefactor: split qemu_machine_feature_enabled
Stefan Reiter [Tue, 19 Nov 2019 11:23:49 +0000 (12:23 +0100)]
refactor: split qemu_machine_feature_enabled

...into:

* PVE::QemuServer::Helpers::min_version: check a major.minor version
  string with a given major/minor version (this is equivalent to calling
  the old qemu_machine_feature_enabled with only $kvmver)
* PVE::QemuServer::Machine::extract_version: get major.minor version
  string from arbitrary machine type (e.g. pc-q35-4.0, ...)
* PVE::QemuServer::Machine::machine_version: helper to call
  extract_version automatically before min_version

Includes a cfg2cmd test case with pinned machine version.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agorefactor: extract QEMU machine related helpers to package
Stefan Reiter [Tue, 19 Nov 2019 11:23:48 +0000 (12:23 +0100)]
refactor: extract QEMU machine related helpers to package

...PVE::QemuServer::Machine.

qemu_machine_feature_enabled is exported since it has a *lot* of users
in PVE::QemuServer and a long enough name as it is.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agorefactor: create QemuServer::Monitor for high-level QMP access
Stefan Reiter [Tue, 19 Nov 2019 11:23:47 +0000 (12:23 +0100)]
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>
4 years agorefactor: split check_running into _exists_ and _running_
Stefan Reiter [Tue, 19 Nov 2019 11:23:46 +0000 (12:23 +0100)]
refactor: split check_running into _exists_ and _running_

vm_exists_on_node in PVE::QemuConfig checks if a config file for a vmid
exists

vm_running_locally in PVE::QemuServer::Helpers checks if a VM is running
on the local machine by probing its pidfile and checking /proc/.../cmdline

check_running is left in QemuServer for compatibility, but changed to
simply call the two new helper functions.

Both methods are also correctly mocked for testing snapshots.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agoChange check_cmdline to parse_cmdline
Stefan Reiter [Tue, 19 Nov 2019 11:23:45 +0000 (12:23 +0100)]
Change check_cmdline to parse_cmdline

parse_cmdline is required for upcoming changes related to custom CPU
types and live migration, and this way we can re-use existing code.

Provides the necessary infrastructure to parse QEMU /proc/.../cmdline.
Changing the single user (check_running) is trivial too.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agorefactor: create QemuServer::Helpers and move file/dir code
Stefan Reiter [Tue, 19 Nov 2019 11:23:44 +0000 (12:23 +0100)]
refactor: create QemuServer::Helpers and move file/dir code

Also remove unused $confdir variable in QemuConfig, but leave it and
$lock_dir there, since those paths should only be used with
cfs_config_path anyway.

nodename() is still called in multiple places, but since it's cached by
INotify it doesn't really matter.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agoFix 'uninitialized value' warning about guest agent type
Stefan Reiter [Wed, 20 Nov 2019 12:24:57 +0000 (13:24 +0100)]
Fix 'uninitialized value' warning about guest agent type

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agoAdd 'runningmachine' support to vm_commandline
Stefan Reiter [Wed, 20 Nov 2019 12:24:56 +0000 (13:24 +0100)]
Add 'runningmachine' support to vm_commandline

to allow 'qm showcmd --snapshot ...' to show the correct machine type.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agomigration: fix false-positive log for copying local images
Thomas Lamprecht [Wed, 20 Nov 2019 15:01:33 +0000 (16:01 +0100)]
migration: fix false-positive log for copying local images

Only log that if we actually have local disks.
Add also an explicit log for replication.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoqemu: remove unused methods
Thomas Lamprecht [Wed, 20 Nov 2019 14:35:18 +0000 (15:35 +0100)]
qemu: remove unused methods

found no use with tree-wide search, so remove:
* nic_models
* os_list_description

Both were introduced before the import to SVN happened.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agofollowup: adding qxl max_outputs breaks live-migration/restore
Thomas Lamprecht [Wed, 20 Nov 2019 14:31:16 +0000 (15:31 +0100)]
followup: adding qxl max_outputs breaks live-migration/restore

enforce QEMU 4.1.x for that change

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoqxl max_outputs: ostype can be undefined, assume linux
Thomas Lamprecht [Wed, 20 Nov 2019 14:10:16 +0000 (15:10 +0100)]
qxl max_outputs: ostype can be undefined, assume linux

Out code behaves like either l26 or other when the ostype is
undefined, both are not common as our webinterface _always_ sets the
ostype.

If one configured QXL with a VM as output device but does not has an
ostype set, and that works without "max_outputs=4" it really should
work with none too.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoprint_vga_device: fix qxl displays on Linux guests
Aaron Lauterer [Tue, 19 Nov 2019 15:18:19 +0000 (16:18 +0100)]
print_vga_device: fix qxl displays on Linux guests

with pve-qemu-4.0.1-3 or higher it was not possible in a spice remote
session to enable more displays on the fly in linux guests.

Adding the `max_outputs` parameter to the qxl device manually restores
the functionality.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
4 years agoget_cpu_options: reuse ostype variable
Thomas Lamprecht [Wed, 20 Nov 2019 14:05:20 +0000 (15:05 +0100)]
get_cpu_options: reuse ostype variable

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoostype: update verbose description
Thomas Lamprecht [Wed, 20 Nov 2019 14:03:10 +0000 (15:03 +0100)]
ostype: update verbose description

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agocfg2cmd: add win10 spice test
Thomas Lamprecht [Tue, 19 Nov 2019 15:10:29 +0000 (16:10 +0100)]
cfg2cmd: add win10 spice test

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoclone: pre-create cloud-init disk for destination
Thomas Lamprecht [Tue, 19 Nov 2019 08:25:54 +0000 (09:25 +0100)]
clone: pre-create cloud-init disk for destination

While we may not want to copy the cloudinit disk/drive, we still need
to create+allocate the volume, else the next start complains about a
missing CI drive..

fixes commit 7d6c99f0a0026ce07fa0eb858db7b6b7756ae021.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoavoid cyclic reference
Wolfgang Bumiller [Tue, 19 Nov 2019 08:26:44 +0000 (09:26 +0100)]
avoid cyclic reference

this otherwise leaks memory

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 years agoAdd 'type' to agent_fmt
Matt Dunwoodie [Mon, 18 Nov 2019 06:46:12 +0000 (17:46 +1100)]
Add 'type' to agent_fmt

This adds an extra field to agent_fmt that specifes the type of guest
agent connection to use. Currently there is no choice, and defaults to
virtio-serial. Since qemu-ga also runs over isa-serial, this allows OSes
such as NetBSD and OpenBSD, which do not have support for virtio-serial,
to run a qemu-ga.

This is an optional field, which leaves the default as virtio-serial. As
it doesn't change the default, it will require no change to older
configuration files.

Signed-off-by: Matt Dunwoodie <ncon@noconroy.net>
4 years agoapi/migration: fix autocomplete for targetstorage
Aaron Lauterer [Mon, 18 Nov 2019 14:23:18 +0000 (15:23 +0100)]
api/migration: fix autocomplete for targetstorage

Show storages configured for the target node and not for the current one
because they can be different.

Duplicated the `complete_storage` sub and extended it to extract the
targetnode from the parameters to pass it into the storage_check_enabled
function.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
4 years agobump version to 6.0-14
Fabian Grünbichler [Mon, 11 Nov 2019 10:28:32 +0000 (11:28 +0100)]
bump version to 6.0-14

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agod/control: add (build-)depends on libpve-cluster-perl
Fabian Grünbichler [Mon, 11 Nov 2019 10:28:31 +0000 (11:28 +0100)]
d/control: add (build-)depends on libpve-cluster-perl

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agorefactor migration IP retrieval
Fabian Grünbichler [Mon, 11 Nov 2019 10:28:30 +0000 (11:28 +0100)]
refactor migration IP retrieval

since PVE::Cluster::get_local_migration_ip does not exist anymore. this
is basically an inlined version, since this is the only remaining caller
that we actually want to keep.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agouse PVE::RRD for RRD data
Fabian Grünbichler [Mon, 11 Nov 2019 10:28:29 +0000 (11:28 +0100)]
use PVE::RRD for RRD data

refactored from PVE::Cluster. same code, same semantics, different file.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agouse PVE::SSHInfo
Fabian Grünbichler [Mon, 11 Nov 2019 10:28:28 +0000 (11:28 +0100)]
use PVE::SSHInfo

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agouse PVE::DataCenterConfig
Fabian Grünbichler [Mon, 11 Nov 2019 10:28:27 +0000 (11:28 +0100)]
use PVE::DataCenterConfig

to make sure that the corresponding cfs_read_file works() works.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agod/control: bump version dependency to ha-manager
Thomas Lamprecht [Thu, 14 Nov 2019 13:44:11 +0000 (14:44 +0100)]
d/control: bump version dependency to ha-manager

so that we have the new "ha-manager crm-command" available

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoUse crm-command stop to allow shutdown with timeout and hard stop for HA
Fabian Ebner [Thu, 14 Nov 2019 11:23:56 +0000 (12:23 +0100)]
Use crm-command stop to allow shutdown with timeout and hard stop for HA

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
4 years agofix destroy_vm by using correct Config package
Dominik Csapak [Thu, 14 Nov 2019 08:49:26 +0000 (09:49 +0100)]
fix destroy_vm by using correct Config package

We are in the QemuServer package not in LXC, so use the correct
package for the Config, namely QemuConfig

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
4 years agofollowup: what vs. why comment
Thomas Lamprecht [Mon, 11 Nov 2019 17:05:20 +0000 (18:05 +0100)]
followup: what vs. why comment

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoqmreboot: clear reboot request if reboot fails
Oguz Bektas [Mon, 11 Nov 2019 16:29:23 +0000 (17:29 +0100)]
qmreboot: clear reboot request if reboot fails

the reboot request is only cleaned in the vm_start path, so if reboot
fails for some reason, the request still exists. this causes an
unintentional reboot when a shutdown/stop/hibernate is called.

to mitigate, we can just clear the reboot request in case of an error.

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
4 years agofix #2457: ga: set-user-password: increase maxLength of password
Dominik Csapak [Mon, 11 Nov 2019 15:18:45 +0000 (16:18 +0100)]
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>
4 years agoapi/create: remove some empty lines and sort
Thomas Lamprecht [Fri, 8 Nov 2019 16:05:53 +0000 (17:05 +0100)]
api/create: remove some empty lines and sort

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agodestroy_vm: allow to pass new config and lock instead
Thomas Lamprecht [Fri, 8 Nov 2019 16:03:28 +0000 (17:03 +0100)]
destroy_vm: allow to pass new config and lock instead

This brings qemu more in line with containers, and it's nicer to
allow passing the replacement config if we want to keep it, instead
of setting a "memory: 128" config.

Use that to lock it on removal before final deletion, and on legacy
tar archive restore, in between old VM destruction and new
restoration.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agorestore_tar_archive: cleanup
Thomas Lamprecht [Fri, 8 Nov 2019 14:43:14 +0000 (15:43 +0100)]
restore_tar_archive: cleanup

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agodestroy_vm: refactor+cleanup and continue on unused disk removal errors
Thomas Lamprecht [Fri, 8 Nov 2019 14:35:32 +0000 (15:35 +0100)]
destroy_vm: refactor+cleanup and continue on unused disk removal errors

it has some potential semantic change too, i.e., the Storage
vdisk_list call is not wrapped by eval anymore, put as
we did some (unguarded) storage things before that call I'd say that
that does not matters much..

We try to clean all unused disks too, even if one deletion fails

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>