Commit Graph

286 Commits

Author SHA1 Message Date
Fabian Grünbichler
dcce9b468d add lock check for move_disk API call
this API call changes the config quite drastically, and as
such should not be possible while an operation that holds a
lock is ongoing (e.g., migration, backup, snapshot).
2016-07-26 11:31:32 +02:00
Fabian Grünbichler
32acc380d3 deactivate new volumes after clone to other node
this might otherwise lead to volumes activated on the
source and target node, which is problematic for at least
LVM and Ceph.
2016-07-14 12:31:36 +02:00
Wolfgang Bumiller
b5b9979081 pass datacenter.cfg's mac_prefix to random_ether_addr 2016-07-14 09:02:24 +02:00
Wolfgang Bumiller
84b31f488c Fix #1051: typo: vpcus -> vcpus
Otherwise only root can change this setting.
2016-07-11 14:47:04 +02:00
Fabian Grünbichler
a3d0bafba5 remove old move disk snapshot check
this is no longer needed, if the moved disk was referenced
by a snapshot we have already died early, and the config is
locked.
2016-07-04 08:29:16 +02:00
Fabian Grünbichler
9dbf9b5417 fix #1040: warn early about moving a snapshotted disk
die if "delete source disk" is enabled, because a disk that
is referenced by snapshots must not be deleted.
2016-07-04 08:29:16 +02:00
Dominik Csapak
63d269d79e fix unnecessary root check for unused disks
we needed root@pam rights to remove an unused disk
from a vm (instead of the correct Storage rights)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2016-06-10 10:36:34 +02:00
Dominik Csapak
6bcacc21b3 fix serial/parallel/numa permissions
moved numa\d+ persmission to VM.Config.CPU
and serial/parallel to root since it accesses the host hardware

also renamed remainingoptions to generaloptions to
reduce confusion, since the real remaining options
(those that we do not specify) require root

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2016-06-01 12:56:54 +02:00
Dominik Csapak
58cb690b06 fix #1010: whitelist options for permissions
instead of defaulting to VM.Config.Options for
all options not checked seperately, we
now have lists for the different config permissions
and check them accordingly.

for everything not given, we require root access
this is important especially for usbN and hostpciN
since they can change the host configuration

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2016-06-01 12:19:37 +02:00
Wolfgang Bumiller
b572a6065a Fix #643: activate volumes before resizing
The volume_size_info() call was what actually failed, but
the error reported to the gui came from afterwards trying to
resize the disk to a garabge size.
2016-04-21 10:33:36 +02:00
Thomas Lamprecht
4d2a734e1b vm_status: return more verbose HA state
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2016-04-19 09:01:02 +02:00
Wolfgang Bumiller
2e953867ad Fix #848: deactivate old volume after clone before deletion
Otherwise some move operations will fail to delete the old
disk (eg. when moving from ceph to local storage).

Note that in order for the deactivation to succeed we need
to make sure qemu has closed its file descriptors, so we
need to wait for the job to disappear the same way we do in
$cancel_job().
Factored the waiting out into $finish_job().
2016-04-13 08:24:13 +02:00
Dominik Csapak
8989736707 change shutdown behaviour on suspended vm
previously, when shutting down a suspended vm,
we successfully send the shutdown command to it,
but it will not shutdown (because it is suspended)

there we will run into the timeout and either
bail out with an error, or kill the process

when we not kill the process and resume the vm,
it will instantly shutdown, because of the previous
command

this patch checks the status of the vm beforehand,
and either bails out with an error that you cannot
shutdown a suspended vm, or stops the vm with the
correct qmp command (depending of forceStop)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2016-04-12 17:18:55 +02:00
Fabian Grünbichler
8793d4950e Refactor add_unused_volume
Drop add_unused_volume from PVE::QemuServer in favor of
(identical) implementation in PVE::AbstractConfig
2016-03-08 11:42:51 +01:00
Fabian Grünbichler
b2c9558da8 Rework snapshot code, has_feature
Drop snapshot_create, snapshot_delete and snapshot_rollback
in favour of PVE::AbstractConfig. Qemu-specific parts are
implemented in __snapshot_XX methods in PVE::QemuConfig.

has_feature is made an implementation of the abstract
has_feature, and thus moves to PVE::QemuConfig.

Note: a new hook method needed to be introduced to be called
before creating a volume snapshot, after creating a volume
snapshot, and after unfreezing the guestfs after creating a
volume snapshot. The base method in PVE::AbstractConfig is a
noop, the implemention in PVE::QemuConfig runs the necessary
Qemu monitor commands.
2016-03-08 11:42:37 +01:00
Fabian Grünbichler
ffda963f46 Refactor basic config-related methods
Drop load_config, write_config, lock_config[_xx],
check_lock, check_protection, is_template and config_file
in favour of implementions in PVE::AbstractConfig.

Implement guest_type, __config_max_unused_disks,
config_file_lock and cfs_config_path from
PVE::AbstractConfig in PVE::QemuConfig.
2016-03-08 11:41:59 +01:00
Fabian Grünbichler
74479ee9bb Make foreach_drive order deterministic
Previously, foreach_drive iterated over all configuration
keys (in a random order) and checked whether the current key
is a valid drive name. Instead, we now iterate over a list
of valid drive names (with deterministic order) and check
whether a drive with such a name exists in the
configuration.

Also rename the two involved methods from valid_drive_name
to is_valid_drive_name (for the check) and from disknames
to valid_drive_names (for the list of valid keys), for
consistency. These two were only used in the qemu-server
code base.
2016-03-04 06:25:48 +01:00
Dietmar Maurer
346130b2ba fix typo 2016-03-04 06:22:22 +01:00
Emmanuel Kasper
d6c747ff12 document for end users the differences between shutdown and stop 2016-03-04 06:16:16 +01:00
Wolfgang Bumiller
12612b09ae Close #880: ability to show paused state via the CLI
qm list and qm status both show suspended VMs as 'running'
while the GUI's status summary shows them as 'paused'.

This patch makes 'qm status' always request the full status
and adds an optional '-full' parameter for 'qm list' to
use a full status query to include the 'paused' state. (This
is optional as it causes qmp requests to all running VMs.)
2016-03-01 11:59:44 +01:00
Alexandre Derumier
51eefb7e11 clone_vm : only deactivate sources volume if source vm if offline
We can clone online a running vm, we don't have to deactive source vm volume
if the source vm is running

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2016-02-25 08:48:12 +01:00
Fabian Grünbichler
8317c759bf Drop skiplock from write_config
Since write_config was always called with skiplock=1 except
once, it makes sense to drop this parameter like in
PVE::LXC::write_config . If needed in the future, the
caller can use check_lock before write_config anyway.
2016-02-12 12:16:57 +01:00
Fabian Grünbichler
63be43a947 Refactor update_config_nolock -> write_config
The method update_config wrapped update_config_nolock
using lock_config, but to prevent update races the whole
"read config", "do something", "write config" flow was
always protected by lock_config anyway, and update_config
was never called.

Thus, we can safely drop update_config and rename
update_config_nolock to write_config like in PVE::LXC .
2016-02-12 12:14:52 +01:00
Thomas Lamprecht
0dbcc8c9a1 fix PVE::HA use clause so HA resources get registered
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2016-01-27 17:08:21 +01:00
Dietmar Maurer
eb15b9f074 clone: correctly activate volumes (consider snapshots) 2016-01-22 11:54:34 +01:00
Wolfgang Bumiller
98cbd0f47e check for qorum when starting a VM 2016-01-10 14:55:25 +01:00
Wolfgang Bumiller
77019edfe0 fix bug #841: replace get_used_paths with is_volume_in_use
get_used_paths returned a hash of used paths for all the
volumes in a VM's config, which is not enough to figure out
whether there are snapshots, as snapshots often have
different paths.  Eg. on ZFS it is not enough to check for
/dev/zvol/tank/vm-123-disk-1 because the snapshot's path is
/dev/zvol/tank/vm-123-disk-1@snap1 and thus we allowed
deleting the drive. Then when trying to delete the snapshot
later you get:
  zfs error: cannot open 'tank/vm-751-disk-1': dataset does not exist
and it refuses to delete the snapshot.

Since its only use was to check whether or not a drive is
still in use it is now renamed to is_volume_in_use and
beside checking paths now also checks volume-ids as those
should stay the same.
2015-12-10 12:13:12 +01:00
Thomas Lamprecht
ab5904f7e0 qm: Add VMID auto completion to some commands
Add the respective completion function for the:
*) start
*) stop
*) shutdown
*) suspend
*) resume
*) sendkey
qm commands. The destroy command was left out on purpose for now.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2015-12-09 12:21:09 +01:00
Dietmar Maurer
db593da26c destroy VM: test for running VM before starting background task 2015-11-07 12:09:01 +01:00
Wolfgang Bumiller
34456bf02e clone: use a fullclone hash instead of $drive->{full}
'full' is not a valid drive property which are now being
checked in print_property_string. Since it's only a
temporary value and passed to clone_disk as parameter it
can be stored separately.
2015-10-30 07:06:10 +01:00
Dietmar Maurer
c13e17d0d4 Revert "fix bug 790: encode description before writing to syslog"
This reverts commit 9ac5db408d.

This is now fixed by a change in PVE::Cluster::log_msg().
2015-10-29 17:44:17 +01:00
Dietmar Maurer
9ac5db408d fix bug 790: encode description before writing to syslog 2015-10-29 10:49:08 +01:00
Alexandre Derumier
289e0b8564 migrate : add nocheck for resume
Users have reported resume bug when HA is used.

They seem to have a little race (bench show >0s < 1s) between the vm conf file move on source node and replication to,
and resume on target node.

I don't known why this is only with HA, maybe this occur will standard migration too.

Anyway, we don't need to read the vm config file to resume the vm on target host,
as we are sure that the vm is migrated, and config file move action is correct in the cluster.

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2015-10-15 12:41:13 +02:00
Dietmar Maurer
5f20325f61 create: add better check for unused IDs 2015-10-05 12:43:07 +02:00
Alen Grizonic
ea2106258b boot order permissions change
to change to boot order it is needed to assign a user the
VM.Config.Disk privilege set with the add/modify/delete disk
permissions -> now the patch allows the boot order to be (re)defined
with the VM.Config.Options set - the modify any other VM configuration
2015-09-26 11:06:05 +02:00
Alen Grizonic
284fa4c728 VM protection mode
[PATCH v2] changes:

- changed call also for remove VM
2015-09-21 06:36:01 +02:00
Dietmar Maurer
0152058a03 code cleanups 2015-09-17 13:10:19 +02:00
Alen Grizonic
4d8d55f155 VM protection mode
changes:

- added common check_protection subroutine
- disk removal prevention
- restore over protected VM prevention
- changed man page message
2015-09-17 13:05:37 +02:00
Dietmar Maurer
65605ff730 avoid warning about undefined value 2015-09-10 09:37:55 +02:00
Dietmar Maurer
335af808a4 improve bash completion 2015-09-07 08:13:07 +02:00
Dietmar Maurer
65e866e5da implement a few bash completion helpers 2015-09-06 16:01:59 +02:00
Alen Grizonic
cb0e4540f7 VM protection mode added
used to prevent an unintended virtual machine remove operation

v3 changes:

- changed man page message
- removed protection parameter (where not needed)
2015-09-06 11:31:05 +02:00
Dietmar Maurer
952e3ac30f cleanup previous patch 2015-08-28 18:16:08 +02:00
Alen Grizonic
e9f2f8e5f9 HA resources check before destroying vm 2015-08-28 15:32:44 +02:00
Thomas Lamprecht
7f9e28e45c fix 'uninitialized value in concat' due to unnamed VM
This is an minor fix which let's you start the spice console on an
unnamed VM without getting the 'Use of uninitialized value in
concatenation' error.
Also changes the trailing comma from the $conf definition lineto an
semicolon.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2015-08-28 10:36:51 +02:00
Alen Grizonic
457010cc48 clone vm firewall config file
Signed-off-by: Alen Grizonic <a.grizonic@proxmox.com>
2015-08-25 06:49:26 +02:00
Wolfgang Link
a78ea5dfe9 fix bug #688: prevent copy unused disks in the config. 2015-08-20 12:28:05 +02:00
Alen Grizonic
e9abcde681 fix bug #603: vmid.fw file not deleted
Signed-off-by: Alen Grizonic <a.grizonic@proxmox.com>
2015-08-19 15:30:00 +02:00
Wolfgang Link
d662790a14 fix bug #517: improve error message
Get a understandble message,
if someone try to increase a qcow2 image where one or more snapshots reside
2015-08-18 16:35:00 +02:00
Wolfgang Bumiller
1bc483f6bc adapt /config and /pending API calls to force-delete 2015-08-18 16:29:10 +02:00