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

1746 Commits

Author SHA1 Message Date
Thomas Lamprecht
c75bf16117 qm importdisk: tell user to what VM disk we actually imported
as else one has no idea what the imported disk is, especially if
multiple unused disks are already present..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-10-29 19:11:21 +01:00
Thomas Lamprecht
5600c5b22f cleanup do_import, s/optional/params/ and move skiplock into params
mixed with indentation changes a whole lot of other changes which
should normally not mixed to much together, but this is all a bit
tangled and I'm not sure if splitting it into two or three parts
would help anybody.. just use "-w" (ignore whitespace changes) when
looking at the diff..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-10-29 19:11:21 +01:00
Dominic Jäger
439390e868 Import OVF: Lock config with "lock" property
Previously a VMID conflict was possible when creating a VM on another node
between locking the config with lock_config_full and writing to it for the
first time with write_config.

Using create_and_lock_config eliminates this possibility. This means that now
the "lock" property is set in the config instead of using flock only.

$param was empty when it was assigned the three values "name", "memory" and
"cores" before being assigned to $conf later on. Assigning those values
directly to $conf avoids confusion about what the two variables contain.

Signed-off-by: Dominic Jäger <d.jaeger@proxmox.com>
2019-10-29 19:11:21 +01:00
Dominic Jäger
7f384190de Add skiplock to do_import
Functions like qm importovf can now set the "lock" property in a config file
before calling do_import.

Signed-off-by: Dominic Jäger <d.jaeger@proxmox.com>
2019-10-29 19:11:21 +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
Thomas Lamprecht
93981fa799 refactor hugepages_size conf
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-10-29 17:58:53 +01:00
Thomas Lamprecht
71aba4eac3 refactor hugepages_size
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-10-29 17:49:37 +01:00
Stefan Reiter
062a7ea714 hugepages: fix memory size checking
The codepath for "any" hugepages did not check if memory size was even,
leading to the code below trying to allocate half a hugepage (e.g. VM
with 2049MiB RAM would lead to 1024.5 2kB hugepages).

Also improve error message for systems with only 1GB hugepages enabled.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
2019-10-29 16:52:54 +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
7c2d9b4089 [no-change] sort and group module use
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-10-29 15:59:10 +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
Fabian Ebner
9270672e67 fix typo in migration cleanup error message
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-10-28 11:30:10 +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
7167d3bde2 QMPClient is no executable
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-10-23 15:41:36 +02:00
Dominik Csapak
6aa43f9238 fix reverting for non-existing configs
reverting a nonexisting option did not work with the latest changes
in pve-guest-common, because we do not delete the pending option
in 'add_to_pending_delete' anymore

this had the effect that we had following in the config:
[pending]
option: pendingvalue
delete: option

which would do the deletion code and the pending add code
(e.g. delete the pending cloud init drive and creating it again)

to avoid that situation, we need to remove the option from the pending hash
in the 'delete loop'

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2019-10-23 11:47:52 +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
Thomas Lamprecht
19e9b30895 introduce version_cmp helper for qemu_machine_feature_enabled
will be reused for a "running KVM/QEMU version is at least" helper in
a next patch

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-10-23 10:38:16 +02:00
Thomas Lamprecht
d610b14591 [no-change] sort and group module use
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-10-23 10:36:46 +02:00
Thomas Lamprecht
8266bc59db Revert "fix #1071: VMs with IOThread enabled disks can now be backed up"
This reverts commit 6b4b369fe35eb43ac08cf5609b488088c537926d.
2019-10-23 09:31:51 +02:00
Thomas Lamprecht
24d1f93a84 fixup: vmstate: pass volid not resolved path to vollist
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-10-22 16:31:16 +02:00
Thomas Lamprecht
d321c4a921 followup: iterate over pending changes sorted
for a more deterministic behavior, should not change things in
practice

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-10-22 12:47:19 +02:00
Oguz Bektas
fb4d1ba27e pending apply/hotplug: don't hard code force to true
Each pending options has a hash value which has the 'force'
information encoded as entry. But, this can be { force => 1 } or
{ force => 0 }, so we actually need to check the value and not just
set force to the hash directly, as else we have force always truthy..

fixes a bug where 'detach' caused disks to be destroyed immediately,
because $force parameter was always true since hash is true.

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-10-22 12:45:51 +02:00
Thomas Lamprecht
6b4b369fe3 fix #1071: VMs with IOThread enabled disks can now be backed up
Thanks to Dietmars patch[0] those VMs can now be backed up
successfully, so remove this aborting check.

[0]: https://git.proxmox.com/?p=pve-qemu.git;a=commit;h=69cb18950a705b54f438f4659b603b3f52901c2f

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Tested-By: Dominik Csapak <d.csapak@proxmox.com>
2019-10-22 11:53:58 +02:00
Thomas Lamprecht
edcbf953ab fixup: VM statefile: pass volid not resolved path to vollist
We cannot activate a path, only volume IDs with activate_volumes
(duh)

fixes commit 5c1d42b7f825fa124ff3701b32f9ecc011bece95

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-10-22 11:53:58 +02:00
Mira Limbeck
9a13f0fed3 cloudinit: fix vm start hanging with disk on ZFS
With the changes to pve-storage in commit 56362cf the startup hangs for
5 minutes on ZFS if the cloudinit disk does not exist. Instead of
calling activate_volume followed by file_size_info we now call
volume_size_info. This should work reliably on all storages that support
cloudinit disks.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
2019-10-18 21:40:34 +02:00
Mira Limbeck
21e1ee7b32 fix #2344: ignore cloudinit in replication check
When adding a cloudinit disk it does not contain media=cdrom until it is
actually created. This means the check in check_replication fails to
detect cloudinit and it is recognized as normal disk. Then parse_volname
fails because it does not match the vm-$vmid-XYZ format. To fix this we
now check explicitly if the volname matches cloudinit and if so, return
early.

Additionally 2 small cleanups replacing cloudinit regexes with the
same check for volname matches cloudinit.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
2019-10-18 21:39:05 +02:00
Christian Ebner
d9123ef5b9 fix #1291: add option purge for vm_destroy api call
When destroying a VM, we intentionally did not remove all related
configs such as backup or replication jobs.
The intention of this flag is to allow the removal of references to
the VM being removed from such configs on destroy.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-10-18 21:22:51 +02:00
Thomas Lamprecht
69f2907c79 fixup: renamed conf_table_with_pending to config_with_pending_array
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-10-18 21:00:27 +02:00
Oguz Bektas
59ef70033c api: use guesthelper method for vm_pending path
we can use the shared conf_table_with_pending guesthelper to produce the
config table with the extra delete and pending columns.

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
2019-10-18 18:45:27 +02:00
Oguz Bektas
5c39708eb3 cli: use guesthelper for pending
use the shared format_pending method from guesthelpers

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
2019-10-18 18:45:27 +02:00
Oguz Bektas
98bc3aeb92 use new config helpers from guest-common for pending changes
most of the pending changes related code has been moved into
AbstractConfig, so we have to call them as class methods from QemuConfig instead.

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
2019-10-18 18:45:27 +02:00
Oguz Bektas
d3179e1c36 api: use shared methods in config GET
in config GET call, we can now use the new shared methods from
guest-common, namely load_current_config and load_snapshot_config.

the correct method is called depending on the parameters 'current' or
'snapshot'

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
2019-10-18 18:45:27 +02:00
Thomas Lamprecht
f73ed6d10f fixup: QemuConfig->write_config doesn't takes the raw config
Thanks to Fabian for the quick notice

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-10-18 11:44:15 +02:00
Oguz Bektas
90ec74eac1 use print_snapshot_tree guest helper for qm listsnapshot
moved code to GuestHelpers for feature parity with pct

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
2019-10-18 11:30:41 +02:00
Thomas Lamprecht
5da072fb84 QemuServer: sort and group used perl modules
group by:
* external
* pve, other package
* pve, same package

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-10-18 11:24:26 +02:00
Thomas Lamprecht
3361d09901 destroy_vm: use write_config from our Config module to set an "empty" config
brings us more in line with what we do in pve-container, also it's
good to not use file_set_contents directly if we have all those nice
wrapper interface methods to do things in a safe and guaranteed way.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-10-18 11:22:07 +02:00
Thomas Lamprecht
5172770df7 followup: use new base config provided destroy_config method
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-10-18 11:20:52 +02:00
Dominic Jäger
3e8e214d73 Fix #2412: Missing VMs in pools
Between calling vm_destroy and removing the ID from user.cfg (remove_vm_access)
creating a new VM with this ID was possible. VMs could go missing from pools as
a consequence.

Adding a lock solves this for clones from the same node. Additionally,
unlinking must happen at the very end of the deletion process to avoid that
other nodes use the ID in the meanwhile.

Co-developed-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Dominic Jäger <d.jaeger@proxmox.com>
2019-10-17 19:23:49 +02:00
Thomas Lamprecht
5c1d42b7f8 Fix #2171: vm_start: volid based statefiles were not activated
So, while we could just make this a special case before the
config_to_command call and set the $conf->{vmstate} to the statefile
for the case were it's a valid volumeid, the special case handling
get's much easier when we do this outside of that method.

So it's basically a trade-off, and after looking far to long at all
nice revisions Alwin made for me and Fabians request, and even trying
out different approaches, it was never perfect.

But having slight code duplication over the movement mess I proposed
(as I did not had the full picture then, sorry Alwin) felt like the
slightly nicer trade off, as all worked I just use this one now, it
has very clear semantics, easy to understand and that now three lines
are duplicated is IMO irrelevant.

Co-developed-by: Alwin Antreich <a.antreich@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-10-17 19:20:32 +02:00
Thomas Lamprecht
8f899d734e cfg2cmd: push vmstate to volid list to ensure it gets also deactivated
the volume id list is only used to activate before real start and
deactivate later, so use it for the vmstate file too.

This not only makes config_to_command have less side effects, it also
ensures that the vmstate is deactivated again

Co-developed-by: Alwin Antreich <a.antreich@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-10-17 19:10:52 +02:00
Dominik Csapak
af1f1ec038 fix #2395: refactor qemu_img_convert to accept files as source
and use it also for efidisk creation and importdisk
this way we correctly handle zfs-over-iscsi options for those cases

also write tests for it

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2019-10-17 13:57:21 +02:00
Thomas Lamprecht
a447e92c09 vm_start: don't reuse migrate_port variable for storage migration
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-10-14 13:49:30 +02:00