Commit Graph

540 Commits

Author SHA1 Message Date
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
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
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
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
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
Mira Limbeck
7d6c99f0a0 fix #2217: don't copy cloudinit disk on clone
This removes the cloudinit disk from the list of drives to clone. As the
cloudinit disk is recreated on every VM start, it's not necessary to
clone it.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
2019-09-26 18:13:26 +02:00
Thomas Lamprecht
ed94b2adaa followup: reorder error so that $volid is last (potential long)
and add "current" as keyword, further remove the parenthesis for the
post-if, to adapt to Proxmox general perl code style

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-09-23 18:26:27 +02:00
Tim Marx
f8b829aaba add check to resize disk if current size could not be determined
This check ensures that disks aren't unintentionally shrunken, if the
size is zero due to an underlying problem.
2019-09-23 18:25:01 +02:00
Thomas Lamprecht
fda7291362 followup: add newline in warn to avoid extra perl-internal info
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-09-23 13:15:30 +02:00
Fabian Ebner
1373938627 Improve handling and description of migrate with --online
Thanks to Stefan and Thomas for the suggestions.

Changes from v1:
* update parameter description
* warn instead of die

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2019-09-23 13:12:08 +02:00
Thomas Lamprecht
f70a6ea97d api: config deletion: avoid regex on undefined values
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-09-23 12:53:04 +02:00
Dominik Csapak
4c1f3929ea api: deletion: check also pending values for serial/usb
otherwise a user with only VM.Config.HWType cannot
delete a 'pending' usbX: spice or serial: socket option

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2019-09-23 11:24:57 +02:00
Dominik Csapak
165411f0c2 api: add reboot api call
this creates a reboot request file (inspired by pve-container)
and relies on the 'qm cleanup' call by the qmeventd to detect
and restart the vm afterwards

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2019-09-11 14:13:35 +02:00
Dominik Csapak
58f9db6ada api: add missing index child links
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2019-09-10 14:55:28 +02:00
Christian Ebner
de0119f57f Newline cleanup
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-09-04 16:28:31 +02:00
Dominik Csapak
ccab68c22c fix remote viewer live migration
for some reason not setting port results in a port of '65535' which
triggers an execption in http-server anyevent, so we set the port to 0

also, we have to read the ticket from stdin even for 'unix' type secure
migration

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2019-08-20 11:49:24 +02:00
Aaron Lauterer
b2dd61a045 Add audio device to HW permissions
Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
2019-07-18 08:24:39 +02:00
Thomas Lamprecht
32075a2cb8 check_local_storage_availability: only count each unavailable storage once
and some general cleanup

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-06-28 17:39:16 +02:00
Tim Marx
f25852c27e migrate: handle storage not selected manually in storage config
e.g. local storage was considered not allowed for offline migration
even if it is available on all nodes, this should now be fixed as it
is now considered available on all nodes if a local storage isn't
restricted to a specific subset of the available nodes. The user is
responseable to make sure that the datacenter storage config reflects
the actual setup, so there is no additional check for local storages
which aren't available on all nodes if they are not explicitly marked
at datacenter level.

Signed-off-by: Tim Marx <t.marx@proxmox.com>
2019-06-28 15:22:33 +02:00
Tim Marx
71fc647ff9 add migration precondition api endpoint
Signed-off-by: Tim Marx <t.marx@proxmox.com>
2019-06-15 11:13:14 +02:00
Mira Limbeck
7370974930 add new API for dumping cloudinit config
Adds the path '{vmid}/cloudinit/dump' and requires the parameter 'type'
that's either 'user', 'network' or 'meta'. Returns the generated config as
string.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
2019-06-06 14:34:11 +02:00
Thomas Lamprecht
736c92f6d1 api/qemu: start: add helper for root-only param extraction
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-06-06 09:43:49 +02:00
Thomas Lamprecht
a4262553de api/qemu: extra line cleanup
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-06-06 09:41:52 +02:00
Tim Marx
c2ed338eff whitespace cleanup
Signed-off-by: Tim Marx <t.marx@proxmox.com>
2019-05-27 13:59:08 +02:00
Mira Limbeck
7d761a016d introduce one global CLOUDINIT_DISK_SIZE constant
The variable is used instead of the literal value so we have one single
place to change the actual value of every use.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
2019-05-16 16:29:02 +02:00
Christian Ebner
5294c110bb fix: #1075: Restore VM template to VM and try to convert to template.
The restore of a backup from a VM template will first restore the VM and then
convert the restored VM back into a template.
This automatically performes the steps of the current behaviour, where the user
has to manually convert the restored VM back to a template.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2019-04-24 17:35:32 +00:00
Thomas Lamprecht
4fdc1d3dfc create ci disk: long line cleanup
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-04-24 13:33:32 +00:00
Thomas Lamprecht
c152600b93 followup: keep raw as default for non-path based stores
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-04-24 13:27:16 +00:00
Wolfgang Link
64d1a6aedf fix #1829: Cloudinit ignore format parameter
When a Cloudinit image is created, we allow choosing
the format as parameter.
So, the parameter should also be taken into account.

The default for Cloudinit will stay qcow2 on directory storages.
2019-04-16 08:14:22 +00:00
Thomas Lamprecht
9741526189 followup: expand check_vm_modify_config_perm comment
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-04-12 16:19:45 +02:00
Dominik Csapak
165be267eb allow non root users to add spice usb port
using the same logic like serialX: socket
users need VM.Config.HWType for usbX: spice
but only root can add/remove real devices

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2019-04-12 16:13:52 +02:00
Dominik Csapak
e30f75c571 move check for serialX: socket
since we do not want the user to change a device which has a real
devices already set, we have to check it later when we have the config

so we do not have to give the params to vm_check_modify_config_perm anymore

also improve the regex to \d+

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2019-04-12 16:13:46 +02:00
Dominik Csapak
e545304343 fix #1811: allow non root user to edit serialX: socket entries
use VM.Config.HWType for 'socket' and root@pam for real serial devices

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2019-04-11 14:06:48 +02:00
Thomas Lamprecht
f0dbdb6896 code cleanup
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-04-05 17:37:18 +02:00
Alwin Antreich
ee43cd487c fix creating clone if target storage is same as source storage
the clone API calls (target) 'storage' parameter is optional as we
simply use the source storage in this case, but we did not handle
this case when we added the bandwidth_limit abillity, address that.

This patch only pushes the storage parameter into the storage_list array
if it is defined.

Signed-off-by: Alwin Antreich <a.antreich@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-04-05 14:46:53 +02:00
Thomas Lamprecht
41756a3b8a followup: reword bwlimit default wording
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-04-02 11:01:35 +02:00
Stoiko Ivanov
0aab5a16b3 bwlimit: add parameter to API2 calls
for migrate_vm, clone_vm and move_vm_disk and extract it. The 'migrate_vm' call
passes it to PVE::QemuMigrate->migrate for handling.

Additionally the bwlimit option's description of the 'create_vm' call gets
consistent capitalization of I/O.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2019-04-02 11:01:35 +02:00
Dominik Csapak
f17fb184c6 change task name for suspend with and without disk
so that we can differentiate in the gui

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2019-03-30 14:36:50 +01:00
Mira Limbeck
7e8ab2a9ab cloudinit: create disk if it does not exist on start
create a fixed size cloudinit disk if it is referenced in config and
does not exist. the size of the disk created when first added to the
config is reduced to 4MiB to match the one created in
commit_cloudinit_disk.
maximum file size per snippet file (network, user, meta) is increased to 1MiB.
preparation for offline migration without the cloudinit disk (that is
always regenerated on start).

also fixes #1807, although a further patch is required to change the
vmid on restore

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
Tested-by: Dominik Csapak <d.csapak@proxmox.com>
2019-03-29 18:11:33 +01:00
Thomas Lamprecht
cd9a035b56 api/resume: allow to resume 'to-disk suspended' VMs
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Cc: Dominik Csapak <d.csapak@proxmox.com>
Reviewed-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-by: Dominik CSapak <d.csapak@proxmox.com>
2019-03-19 13:24:06 +01:00
Dominik Csapak
48b4cdc210 add statestorage parameter to suspend API
this makes it possible to give a storage for state saving, if one
wants to use a different storage than for snapshots or does not
want to save this info into the config

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2019-03-19 08:53:14 +01:00
Dominik Csapak
22371fe00e add ability to suspend a vm to disk from the api
this enables the use of the suspend to disk code

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2019-03-19 08:53:14 +01:00
David Limbeck
cb702ebe0f cloud-init: allow custom network/user data files via snippets
Adds the 'cicustom' option to specify either or both network and user
options as property strings. Their parameters are files in a snippets
storage (e.g. local:snippets/network.yaml). If one or both are specified
they are used instead of their respective generated configuration.
This allows the use of completely custom configurations and is also a
possible solution for bug #2068 by specifying a custom user file that
contains package_upgrade: false.

Tested with Ubuntu 18.10 and cloud-init 18.4.7

Signed-off-by: David Limbeck <d.limbeck@proxmox.com>
2019-03-07 09:02:33 +01:00
Dominik Csapak
9e784b1154 add pre- start/stop hookscripts to VMs
this adds a new config option for it, and executes it on four
points in time:

'pre-start'
'post-start'
'pre-stop'
'post-stop'

on pre-start we abort if the script fails
and pre-stop will not be called if the vm crashes or if
the vm gets powered off from inside the guest

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2019-02-01 12:58:37 +01:00
Thomas Lamprecht
87d92707b6 followup code cleanup
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-01-30 15:08:15 +01:00
Thomas Lamprecht
2a68ec7893 fix some indentaion errors
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-01-30 15:08:00 +01:00
Rhonda D'Vine
b14477e718 Fix #1924: add snapshot parameter
The qm CLI command offer the config and showcmd functions. Both of those
outputs may vary with respect to a given snapshot. This adds a switch
that shows the corresponding snapshot's config and command line.

The code needs a newer libpve-guest-common-perl, thus bumping the
dependency.

Signed-off-by: Rhonda D'Vine <rhonda@proxmox.com>
2019-01-30 14:56:43 +01:00
Thomas Lamprecht
f1e277cd88 api/create: print correct error message if cleanup fails
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-01-26 14:39:38 +01:00
Dominik Csapak
8fef2bdb95 fix #2003: give 'qm terminal' a terminal over ssh
this prevents a connection loop when using novnc on a vm with
vga: serialX
when proxying via ssh

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2019-01-03 09:07:54 +01:00
Dominik Csapak
414b42d8ef vnc/termproxy: use ssh_info_to_command for ssh tunnel
this way we have two places less where we define a ssh cmd

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2019-01-03 09:07:54 +01:00
Wolfgang Bumiller
96ed3574d4 use AAVMF for arm
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2018-11-13 14:44:28 +01:00
Wolfgang Bumiller
40c3bcf876 create_vm: don't add vmgenid for ARM machines by default
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2018-11-13 14:44:28 +01:00
Dominik Csapak
6ee499fff8 fix #1908: add vmgenid config/device
this adds a VM Generation ID device uses by Windows (Server) to determine
some specific actions that may have happened with the vm
such as rollback, restore, etc.

see:

https://docs.microsoft.com/en-us/windows/desktop/hyperv_v2/virtual-machine-generation-identifier

for details on how it works and when it should change

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2018-09-19 12:23:24 +02:00
Dominik Csapak
c725dd5f92 improve 'pending changes' message for clone
$newconf->{pending} is a reference to an empty hash, which is not falsy,
thus we always printed the warning

so check if there are actual values there and if yes,
give the names of the properties for which pending changes are found

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2018-09-12 10:54:27 +02:00
Stoiko Ivanov
ca6621315e Fix #1242 : clone_disk : call qga fstrim after clone
Some storage like rbd or lvm can't keep thin-provising after a qemu-mirror.

Call qga guest-fstrim if qga is available and fstrim_cloned_disks is enabled
after move_disk and migrate.

Co-Authored-By: Alexandre Derumier <aderumier@odiso.com>
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2018-08-02 11:35:50 +02:00
Stoiko Ivanov
9d66b39769 Make agent a property string, add fstrim_cloned_disks
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2018-08-02 11:35:50 +02:00
Dietmar Maurer
b1a70cab3d vmstatus: define return propertries
We can use the same properties in vmlist and vmstatus.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-08-01 12:58:21 +02:00
Dietmar Maurer
03f879fd85 vmlist: document 'uptime' and 'cpus' returmn value 2018-07-31 13:31:49 +02:00
Dietmar Maurer
ce9b0a3807 qm: add more return schema definitions
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2018-07-11 10:19:49 +02:00
Wolfgang Bumiller
5bf9618308 api create: cleanup the new config log on error
Otherwise cases like trying to restore a protected VM would
leave a lock in the config.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2018-06-12 10:53:56 +02:00
Thomas Lamprecht
e33f774d00 api create: allow auto vm start after create finished
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2018-06-12 09:44:39 +02:00
Thomas Lamprecht
4fedc13b45 reserve config with create lock early
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2018-06-12 09:44:39 +02:00
Thomas Lamprecht
8ba8418ca1 API/create: move locking inside worker
Move the locking inside worker, so that the process doing the actual
work (create or restore) holds the lock, and can call functions which
do locking without deadlocking.

This mirrors the behaviour we use for containers, and allows to add
an 'autostart' parameter which starts the VM after successful
creation. vm_start needs the lock and as not the worker but it's
parents held it, it couldn't know that it was actually save to
continue...

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2018-06-12 09:44:39 +02:00
Dietmar Maurer
7ee990cd30 implement permission checks for cloud-init related options
Most cloud-init options are network related, so we simply check
for VM.Config.Network priviledge.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-05-14 11:16:40 +02:00
Dominik Csapak
68e46b8452 fix #1749: do not copy pending changes when cloning a vm
cloning a vm means copying the current state, not the
state of 'some time in the future, when the vm is started again'
we should not copy the pending changes, which also fixes the
issue that we got a wrong pending change on the disks,net,smbios,etc.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2018-05-04 08:26:26 +02:00
Thomas Lamprecht
eb84566b49 sync bwlimit description with the container one 2018-03-21 11:15:35 +01:00
Wolfgang Bumiller
7c536e11c4 restore: implement rate limiting
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2018-03-21 11:15:35 +01:00
Dietmar Maurer
1ae43f8c11 clone: add command line completion for newid
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-03-20 11:09:45 +01:00
Dietmar Maurer
fd13b1d0e1 clone: use better default for parameter 'full'
template => linked clone
normal VM => full clone

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-03-20 11:09:45 +01:00
Dominik Csapak
2254ffcf87 cloudinit: hide password on the api
since password is easily decrypted, hide it on the api
if someone needs it, they can get it directly from the
config

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2018-03-16 10:03:57 +01:00
Wolfgang Bumiller
cefb41fa76 cloud-init: replace password parameter in log messages
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2018-03-12 12:43:44 +01:00
Wolfgang Bumiller
230406dc52 cloud-init: pre-hash passwords
We don't leave this up to cloud-init as we don't want
un-hashed values at all in our configs.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2018-03-08 14:59:27 +01:00
Wolfgang Bumiller
231f824b1a whitespace fixup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2018-03-08 14:58:34 +01:00
Wolfgang Bumiller
931432bd2d cloud-init: clone/move support
move: don't error out with "you can't move a cdrom"
clone: always full-clone cloud-init images
  They get completely replaced anyway at the next start, so
  there's no point in keeping them.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2018-03-07 09:11:31 +01:00
Wolfgang Bumiller
9ed7a77c6e cloud-init: hotplug support
*) always replace old cloudinit images
*) apply pending cloudinit changes when generating a new
image

For cloudinit we now always use vdisk_free before
vdisk_alloc in order to always replace old images, this
allows us to hotplug a new drive by setting it to
`none,media=cdrom` first (to eject the disk), then setting
it back to 'storage:cloudinit' to have a new image generated
after applying the currently pending changes.
2018-03-07 09:11:31 +01:00
Alexandre Derumier
0c9a7596f6 implement cloudinit
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
Co-developed-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2018-03-07 09:11:31 +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
Dominik Csapak
c9a074b8bf add agent flag to vm status api call
so that we can check in the gui if we have the agent set without
having to load the whole config

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2018-02-20 09:55:15 +01:00
Thomas Lamprecht
e5caa02e05 avoid harmful '<>' pattern, explicitly read from STDIN
Fixes problems in CLIHandler using the code pattern:

while (my $line = <>) {
    ...
}

For why this causes only _now_ problems lets first look how <>
behaves:

"The null filehandle <> is special: [...] Input from <> comes either
from standard input, or from each file listed on the command line.
Here's how it works: the first time <> is evaluated, the @ARGV array
is checked, and if it is empty, $ARGV[0] is set to "-" , which when
opened gives you standard input.  The @ARGV array is then processed
as a list of filenames." - 'perldoc perlop'

Recent changes in the CLIHandler code changed how we modfiied @ARGV
Earlier we assumed that the first argument must be the command and
thus shifted it out of @ARGV, now we can have multiple levels of
(sub)commands. This change also changed how we handle @ARGV, we do
not unshift anything but go through the arguments until we got to
the final command and copy the rest of @ARGV as we know that this
must be the commandos arguments.

For '<>' this means that ARGV was still fully populated and perl
tried to open element as a file, which naturally failed.
Thus the change in pve-common only exposed this 'dangerous' code
pattern.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2018-01-22 14:56:27 +01:00
Wolfgang Bumiller
ccb88f4578 termproxy, vncproxy: use -escape 0 for qm terminal
There's no reason to have Ctrl+O terminate these sessions.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Reviewed-by: Dominik Csapak <d.csapak@proxmox.com>
2017-12-13 14:52:28 +01:00
Dominik Csapak
9e6d6e97c4 enable vncproxy with vncterm for serial ports
this enables the output via vncterm when the vm has
configured a serial port

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2017-12-12 08:34:03 +01:00
Dominik Csapak
8730200273 add termproxy api call
for xtermjs web client

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2017-12-12 08:34:03 +01:00
Dominik Csapak
6a567ae731 make ssh connection transparent
do not use an escape character for vncproxy

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2017-11-17 10:38:26 +01:00
Emmanuel Kasper
ae2fcb3be6 Refactor defaut bootdisk and smbios1 uuid generation in own subs
This will allow code reuse for qm importovf
2017-09-25 13:31:55 +02:00
Fabian Grünbichler
253624c76f config: add vmstatestorage option
and permission checks

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2017-09-22 10:02:54 +02:00
Matthias Urban
c268337d93 VM.Snapshot.Rollback privilege added
VM.Snapshot.Rollback privilege added

Signed-off-by: Matthias Urban <matthias.urban@pure-systems.com>
2017-09-22 09:26:55 +02:00
Emmanuel Kasper
6cb0144ae3 do not overwrite global signal handlers
perls 'local' must be either used in front of each $SIG{...}
assignments or they must be put in a list, else it affects only the
first variable and the rest are *not* in local context.

In all cases the global signal handlers we overwrote were in cli programs or
forked workers, not in daemons.
2017-09-14 15:25:28 +02:00
Thomas Lamprecht
3e1f112286 create_disks: refactor out and improve efidisk creation
factor out code in a new create_efidisk submethod, as else this code
is hardly readable as the efidisk0 case is a special case. Refer from
putting all this specialised handling directly to the much shorter
code for all other cases.

Also the disk was created with a specific format and then a format
detection on the newly created disk was done, which is pretty
useless, clear that up.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2017-09-11 10:04:46 +02:00
Thomas Lamprecht
a1d8c038c5 efidisk: do not hard code efivar base image size
The size of this image is not fixed, it increased to 528k in more
recent build of OVMF and could increase further (not likely, but
possible).

Instead of changing the hardcoded value move to a more generic
approach and read the size from the base image at creation time.

Use the new convert_size method and generalise the assignment of
size and volid between the efidisk and the normal case, as a part of
this change.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2017-09-11 10:04:46 +02:00
Thomas Lamprecht
eaae66be9f API/clone: do not overwrite global signal handlers
perls 'local' must be either used in front of each $SIG{...}
assignments or they must be put in a list, else it affects only the
first variable and the rest are *not* in local context.

This may cause weird behaviour where daemons seemingly do not get
terminating signals delivered correctly and thus may not shutdown
gracefully anymore.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2017-09-07 10:39:28 +02:00
Fabian Grünbichler
edd48c325a update_vm: sort logged parameters
otherwise the (log) output looks really strange when mass-updating VMs, e.g.:
update VM 400001: -scsi1 somestore:64 -scsi0 somestore:64 -ide2 isostore:iso/somefile.iso,media=cdrom
update VM 400002: -ide2 isostore:iso/somefile.iso,media=cdrom -scsi1 somestore:64 -scsi0 somestore:64
update VM 400003: -scsi0 somestore:64 -ide2 isostore:iso/somefile.iso,media=cdrom -scsi1 somestore:64

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2017-09-07 10:21:47 +02:00
Wolfgang Bumiller
bf1312d811 cleanup: more the new-disk regex deduplication 2017-06-30 09:31:29 +02:00
Dominik Csapak
c46366fd49 fix #1417: check if storage has 'images' set in content
otherwise, qm and the api ignore this setting completely when creating
a vm

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2017-06-30 09:26:53 +02:00
Wolfgang Link
223e032b74 Remove guest states to ensure no old states are exists 2017-06-27 15:31:41 +02:00
Wolfgang Bumiller
9b1396edd2 allow disks on shared storages on replicated VMs 2017-06-27 15:22:08 +02:00
Wolfgang Bumiller
17677004cc refuse to add non-replicatable disks to replicating VMs
Unless replication is explicitly disabled for them.
2017-06-27 10:37:07 +02:00
Thomas Lamprecht
0276584456 API HA tasks: we request states not execute them
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2017-06-27 07:59:12 +02:00
Dietmar Maurer
7c876ec165 PVE/API2/Qemu.pm: cleanup - remove unused $upid parameter 2017-06-12 11:09:47 +02:00
Dietmar Maurer
f53c6ad8b9 PVE/API2/Qemu.pm: aquire guest_migration_lock inside worker 2017-06-12 11:05:46 +02:00
Wolfgang Link
c068c1c3a9 Add a migration lock to avoid a replication on rollback-time. 2017-06-12 10:58:49 +02:00
Dominik Csapak
af6d2db4b3 check also pending changes when reverting/deleting
otherwise we are not able to revert/delete pending changes which
introduce a new config line

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2017-05-31 11:40:14 +02:00
Dietmar Maurer
95f42d61fa migrate: aquire guest_migration_lock during migration
To block replication jobs.
2017-05-31 07:57:03 +02:00
Dietmar Maurer
628bb7f231 do not allow destroy if there are replication jobs 2017-05-31 07:53:58 +02:00
Dietmar Maurer
3ab7663a91 remove 'replicate' configuration - we will store that in another file 2017-05-31 07:53:57 +02:00
Thomas Lamprecht
6318daca96 improve error on '{full, linked} clone not available' error
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2017-05-24 11:29:26 +02:00
Dominik Csapak
dd32a4664f use ReuseAddr for vncproxy
to avoid "Socket already in use" errors, when quickly opening/closing
console sessions on the webinterface

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2017-05-17 13:38:54 +02:00
Wolfgang Bumiller
175b51fdb5 Fix #1361: create disk: stricter parsing of storage:size
This fixes paths such as
/dev/disk/by-id/some-ID:0.5
being interpreted as a request to create a 0.5G-sized disk
in the storage named '/dev/disk/by-id/some-ID'.
2017-05-10 10:31:25 +02:00
Dietmar Maurer
3aa44d3b57 move get_replicatable_volumes from QemuServer.pm to QemuConfig.pm 2017-05-06 17:13:31 +02:00
Dietmar Maurer
64932aebff PVE::QemuServer::create_disks - run code inside eval
So that we can free allocated volumes ins something fails.

Thi bug was introduced with commit ae57f6b352
2017-05-06 17:00:20 +02:00
Dietmar Maurer
0342b45bee get_replicatable_volumes: replacemnet for PVE::ReplicationTools::get_syncable_guestdisks()
correctly scan for volumes inside snapshots.

This will also solve the cyclic package dependency propblem.
2017-05-06 15:11:46 +02:00
Dietmar Maurer
2286cb8c23 use a single replicate property (format pve-replicate) 2017-05-06 10:35:08 +02:00
Dominik Csapak
2c7fc94783 start vncproxy worker in the background
this allows it to use the vncproxy api call to use from pvesh,
because before we waited until the task finished to get the vncticket
which was too late

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2017-05-03 08:35:03 +02:00
Wolfgang Bumiller
6d449202ba api: replica: safer config update
Configuration updates should only happen if and after their
change has successfully taken effect.
2017-04-28 10:40:22 +02:00
Wolfgang Link
9b49ba658f Destroy all remote and local replication datasets when a VM will destroyed. 2017-04-28 10:11:33 +02:00
Wolfgang Link
9edac22f5f Insert new properties in the Qemu config for the PVE Replica.
This patch will include all necessary properties for the replication.
Also will it enable and disable a replication job
when appointed flags are set or deleted.
2017-04-28 10:11:33 +02:00
Alexandre Derumier
d80ad67f9d live storage migration : fix check of target storage availability
if we define a different target storeid for remote node,
and that storage is not available on source node

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2017-04-21 12:05:36 +02:00
Dominik Csapak
058ff55b39 turn off alarm timer after accepting a vnc connection
else we always get a failed task when the vnc connection is
running longer than $timeout

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2017-04-18 14:14:07 +02:00
Fabian Grünbichler
d2c6bf93ae update_vm: check whether opt is set before deleting
otherwise we get lots uninitialized warnings:

update VM 600: -delete unused7
Use of uninitialized value $data in split at /usr/share/perl5/PVE/JSONSchema.pm line 533.
Use of uninitialized value in concatenation (.) or string at /usr/share/perl5/PVE/API2/Qemu.pm line 1012.
Use of uninitialized value $volid in pattern match (m//) at /usr/share/perl5/PVE/QemuServer.pm line 1824.
Use of uninitialized value $volid in pattern match (m//) at /usr/share/perl5/PVE/Storage/Plugin.pm line 201.
Use of uninitialized value $volid in concatenation (.) or string at /usr/share/perl5/PVE/Storage/Plugin.pm line 205.

vs:

update VM 600: -delete unused7
cannot delete 'unused7' - not set in current configuration!

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2017-03-23 11:41:12 +01:00
Emmanuel Kasper
e248477e92 Use backticks instead of single quotes in qm resize description
Single quoted text in asciidoc is rendered in man pages
with underlines, which makes the '+' symbol very similar to '+/-'

Backticks are rendered with monospace text in HTML, normal text
in man pages, and still readable in raw format.
2017-03-02 10:38:19 +01:00
Wolfgang Bumiller
655d746212 remove netcat6 dependency
By simply using a socket.
2017-02-28 12:23:42 +01:00
Emmanuel Kasper
9a478b17c0 Improve error message when trying to shrink a volume, fix typo 2017-02-17 09:09:49 +01:00
Wolfgang Bumiller
9f11fc5fa2 don't pull HA modules for doc-generation 2017-02-06 16:13:30 +01:00
Fabian Grünbichler
fbd7dcce4d fix #1260: convert moved template disk to base
this was already possible manually via "qm template", but
doing it automatically when moving a disk of a template
makes more sense.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2017-01-26 10:03:20 +01:00
Dietmar Maurer
9bb3acf155 use new PVE::Storage::check_volume_access() 2017-01-18 17:23:03 +01:00
Alexandre Derumier
56af714629 add with-local-disks option for live storage migration
As Fabian as required,
add an extra flag "with-local-disks"  to enable live storage migration with localdisk.

default target storage is same sid than source, this can be overrided with
"targetstorage" option.

I will try improve this later, with optionnal mapping, disk by disk.

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2017-01-06 12:10:25 +01:00
Wolfgang Bumiller
bd2d5fe6ff cleanup: error messages 2017-01-05 10:03:16 +01:00
Wolfgang Bumiller
3b4cf0f0fc cleanup: whitespaces & style 2017-01-05 10:03:10 +01:00
Alexandre Derumier
5619e74aed live clone_vm : suspend or freezefs before block-job-cancel
if qga is enabled, we try to freeze the fs before cancelling block job.
if not , we pause the vm.

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2017-01-05 09:09:46 +01:00
Alexandre Derumier
b74cad8ae3 add live storage migration with vm migration
This allow to migrate disks on local storage  to a remote node storage.

When the target node start, a new volumes are created and exposed through qemu embedded nbd server.

qemu drive-mirror is launch on source vm for each disk with nbd server as target.

when drive-mirror reach 100% of 1 disk, we don't complete the block jobs and begin mirror of next disk.
(mirroring are parralel, but we try to mirroring them 1 by 1 to avoid storage && network overload)

Then we live migrate the vm to destination node. (drive-mirror still occur at the same time).

We the vm is livemigrate (source vm paused, target vm pause), we complete the block jobs mirror.

When is done we stop the source vm and resume the target vm

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2017-01-05 09:09:46 +01:00
Alexandre Derumier
2189246c5c add targetstorage to vm_start
This will create a new drive for each local drive found,
and start the vm with this new drives.

if targetstorage == 1, we use same sid than original vm disk

a nbd server is started in qemu and expose local volumes to network port

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2017-01-05 09:09:46 +01:00
Alexandre Derumier
c6fdd002b2 clone live vm : add support for multiple jobs
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2017-01-05 09:09:46 +01:00
Dietmar Maurer
249d8fedd8 qm agent: remove 'guest-' prefix from commands 2016-12-01 07:57:26 +01:00
Dietmar Maurer
57bdd45943 qm agent: directly return result
This is required for correct error handling. The previous
code simply cought all exceptions.
2016-12-01 07:23:16 +01:00
Dietmar Maurer
a5d5341cb2 qm agent: enumerate possible guest commands 2016-12-01 07:18:31 +01:00
Dietmar Maurer
c07a9e3d64 cleanup: reorder code so that emacs font-lock-mode works again
This is just a work around for emacs bugs.
2016-11-30 13:07:52 +01:00
Dietmar Maurer
f38c5e270f qm agent: add command line completion for vmid 2016-11-30 12:47:03 +01:00
Wolfgang Link
d1a474273b Add qm agent.
This command makes it possible to run commnads on the Qemu-Guest-Agent if it is installed and running.
2016-11-30 12:30:31 +01:00
Fabian Grünbichler
a8f2f42714 restrict monitor API to Sys.Modify for most commands
because these allow adding arbitrary devices to VMs (and
other potentially dangerous things).

whitelist 'info *' and 'help' as usable with just
VM.Monitor, if more are desired and requested they can be
added later.
2016-11-23 10:02:06 +01:00
Dietmar Maurer
ae849692d9 vm_shutdown: request 'stopped' state for HA enabled VMs 2016-11-23 08:03:08 +01:00
Dietmar Maurer
29ddbe702b combine option 'format' with previous line (avoid emacs confusion) 2016-11-23 06:40:33 +01:00
Dietmar Maurer
e0feef86ee use ha-manager 'stopped' state instead of 'disabled' 2016-11-23 06:23:21 +01:00
Thomas Lamprecht
2a7e2b82bb switch to 'ha-manager set'
ha-manager enabled/disabled will get removed

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2016-11-19 10:02:45 +01:00
Wolfgang Bumiller
f90912016a fix a perl warning when failing to parse a new drive string 2016-11-03 09:57:40 +01:00
Thomas Lamprecht
2de2d6f74e allow dedicated migration network, bug #1177
Without this patch we use the network were the cluster traffic runs
for sending migration traffic. This is not ideal as it may hinder
cluster traffic. Further some users have a powerful network which
would be perfect for migrations, with this patch they can run the
migration traffic over such a network without having the corosync
traffic on the same network.

The network is configurable through /etc/pve/datacenter.cfg which
got a new property, namely migration. migration has two
subproperties: type (replaces the old migration_unsecure property)
and network.

For the case of a network failure or that a VM has to be moved over
another network for arbitrary other reasons I added the
migration_type and migration_network parameters to qm migrate (and
respectively vm_start as this gets used on migration).
They allow overwriting the datacenter.cfg settings.

Fixes bug #1177

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2016-11-03 09:51:23 +01:00
Dietmar Maurer
e261de405e snapshot_list: add bash completion for vmid 2016-10-19 11:57:53 +02:00