5
0
mirror of git://git.proxmox.com/git/qemu-server.git synced 2025-01-10 01:18:01 +03:00
Commit Graph

970 Commits

Author SHA1 Message Date
Fabian Grünbichler
e2414e73ce 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>
2019-11-25 13:45:46 +01:00
Fabian Grünbichler
d184401e9f 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>
2019-11-25 10:38:15 +01:00
Oguz Bektas
15c6e277a4 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>
2019-11-25 10:01:41 +01:00
Thomas Lamprecht
045749f2fc split get_basic_machine_info into get_vm_arch and get_vm_machine
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-11-25 08:56:58 +01:00
Thomas Lamprecht
eec4f394f9 really fallback to PCI standard domain "0000" again
fixes commit 70740c1a4d

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-11-23 09:50:54 +01:00
Dominik Csapak
b8e7068a11 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>
2019-11-20 20:24:49 +01:00
Dominik Csapak
70740c1a4d 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>
2019-11-20 19:07:46 +01:00
Thomas Lamprecht
6c9f59c122 cleanup: improve locallity of variable declaration/use
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-11-20 19:06:15 +01:00
Stefan Reiter
2ea5fb7ecf 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>
2019-11-20 18:32:35 +01:00
Stefan Reiter
3392d6cacf 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>
2019-11-20 16:29:23 +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
Stefan Reiter
babf613a08 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>
2019-11-20 16:29:23 +01:00
Stefan Reiter
24622ebed4 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>
2019-11-20 16:29:23 +01:00
Stefan Reiter
d036e418a8 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>
2019-11-20 16:29:23 +01:00
Stefan Reiter
60f03a1168 Fix 'uninitialized value' warning about guest agent type
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2019-11-20 16:11:44 +01:00
Stefan Reiter
092868c4d1 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>
2019-11-20 16:11:44 +01:00
Thomas Lamprecht
5084a85941 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>
2019-11-20 15:37:01 +01:00
Thomas Lamprecht
9e8976ea4e 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>
2019-11-20 15:33:48 +01:00
Thomas Lamprecht
c5a4c92cd9 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>
2019-11-20 15:29:12 +01:00
Aaron Lauterer
6021c7a5ed 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>
2019-11-20 15:05:43 +01:00
Thomas Lamprecht
9a9ba5f857 get_cpu_options: reuse ostype variable
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-11-20 15:05:43 +01:00
Thomas Lamprecht
a52692609c ostype: update verbose description
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-11-20 15:05:43 +01:00
Thomas Lamprecht
7fe8b44c54 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 7d6c99f0a0.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-11-19 10:29:58 +01:00
Wolfgang Bumiller
e5a66e48ba avoid cyclic reference
this otherwise leaks memory

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-11-19 09:26:45 +01:00
Matt Dunwoodie
4865715861 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>
2019-11-18 16:04:28 +01:00
Aaron Lauterer
255e9c546c 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>
2019-11-18 15:42:18 +01:00
Fabian Grünbichler
b24e1ac224 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>
2019-11-18 12:10:25 +01:00
Fabian Grünbichler
48cf040f75 use PVE::DataCenterConfig
to make sure that the corresponding cfs_read_file works() works.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2019-11-18 12:10:25 +01:00
Dominik Csapak
8baf8bc77e 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>
2019-11-14 10:04:35 +01:00
Thomas Lamprecht
3c1c3fe6a1 followup: what vs. why comment
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-11-11 18:05:20 +01:00
Oguz Bektas
66026117b0 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>
2019-11-11 18:03:44 +01:00
Thomas Lamprecht
b04ea58453 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>
2019-11-08 17:03:30 +01:00
Thomas Lamprecht
7dc7f315f3 restore_tar_archive: cleanup
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-11-08 15:43:22 +01:00
Thomas Lamprecht
a2f50f0172 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>
2019-11-08 15:38:23 +01:00
Thomas Lamprecht
4b0269379b followup: make comment a bit shorter/more concise
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-11-08 15:02:50 +01:00
Dominic Jäger
9b4e53889b restore_tar_archive: Add skiplock to destroy_vm
When calling qmrestore a config file is created and locked with a lock
property. The following destroy_vm has been impossible as skiplock has not
been set.

Signed-off-by: Dominic Jäger <d.jaeger@proxmox.com>
2019-11-08 14:51:49 +01:00
Fabian Grünbichler
425441e6fa move 'use UUID' statement to correct file
and add the libuuid-perl package to build-depends as well.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2019-11-08 11:22:51 +01:00
Dominic Jäger
b406ab6342 replace remaining vm_destroy call-sites with destroy_vm
This function has been used in one place only into which we inlined its
functionality. Removing it avoids confusion between vm_destroy and vm_destroy.

The whole $importfn is executed in a lock_config_full.
As a consequence, for the inlined code:
1. lock_config is redundant
2. it is not possible that the VM has been started (check_running) in the
    meanwhile
Additionally, it is not possible that the "lock" property has been written into
the VM's config file (check_lock) in the meanwhile

Add warning after eval so that it does not go unnoticed if it ever comes into
action.

Signed-off-by: Dominic Jäger <d.jaeger@proxmox.com>
2019-10-29 19:11:02 +01:00
Stefan Reiter
cc111f2ab5 Use get_host_arch from PVE::Tools
...now that it no longer does LXC-specific stuff. Removes a FIXME.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2019-10-29 16:05:37 +01:00
Thomas Lamprecht
0600c3bf07 runs_at_least_qemu_version: propagate QMP errors
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-10-29 15:58:42 +01:00
Dominik Csapak
84a50d6ef0 fix #2434: extend machine regex
with qemu 4.0.1, there is now a machine type pc-q35-4.0.1 which does not fit
into our regex

this broke live migration of q35, as we give the machine type (incl version
info) to 'qm start' on the target node, which checks it against the
JSONSchema

to fix this, extend the regex to allow any number of version levels,
for q35, i440fx and virt (to be more future proof)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2019-10-25 15:03:32 +02:00
Dominic Jäger
dfda979e61 destroy_vm: remove VM config *after* unused disk removal
As mentioned on the mailing list [0] disks owned by the VM and unused
disks should be removed before the config file is removed.

[0] https://pve.proxmox.com/pipermail/pve-devel/2019-October/039593.html

Signed-off-by: Dominic Jäger <d.jaeger@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-10-25 11:41:37 +02:00
Thomas Lamprecht
20faf21e87 cleanup: no need to prefix module for call to module-local method
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-10-24 10:49:19 +02:00
Thomas Lamprecht
e08553ba57 qmp_socket: remove unused "name" parameter
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-10-23 16:10:04 +02:00
Thomas Lamprecht
9f78b695a7 vmstatus: code cleanup: directly use load_config helper
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-10-23 16:09:36 +02:00
Thomas Lamprecht
dfac373fa6 remove unused method "touch_config"
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-10-23 15:41:59 +02:00
Thomas Lamprecht
a034e3d624 followup: code cleanup and some comments
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-10-23 11:39:03 +02:00
Stefan Reiter
d1cbb1a93b fix #2408, #2355, #2380: use scsi-hd backend for iSCSI as well
As mentioned in #2408, live-migrating a VM between storages that use
different scsi backends (scsi-hd, scsi-generic, scsi-block) breaks.

To fix, from QEMU 4.1 machine types onward (to not break current
behaviour any more), only use scsi-hd, as in recent versions, there is
almost no difference between the two anyway.

scsi-block (which potentially also breaks) requires a flag to be
manually set on the disk, so we can assume the user knows what they're
doing.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
Suggested-by: Daniel Berteaud <daniel@firewall-services.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-10-23 11:31:23 +02:00
Thomas Lamprecht
317c55c2d1 backup: is IOThread comaptible: only check running VMs
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-10-23 11:28:51 +02:00
Thomas Lamprecht
48343b3f1d add runs_at_least_qemu_version to check if we can backup IOThread disks
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-10-23 10:47:45 +02:00