use PVE::Storage;
use PVE::SysFSTools;
use PVE::Systemd;
-use PVE::Tools qw(run_command lock_file lock_file_full file_read_firstline dir_glob_foreach $IPV6RE);
+use PVE::Tools qw(run_command lock_file lock_file_full file_read_firstline dir_glob_foreach get_host_arch $IPV6RE);
use PVE::QMPClient;
use PVE::QemuConfig;
PVE::JSONSchema::register_standard_option('pve-qemu-machine', {
description => "Specifies the Qemu machine type.",
type => 'string',
- pattern => '(pc|pc(-i440fx)?-\d+\.\d+(\.pxe)?|q35|pc-q35-\d+\.\d+(\.pxe)?|virt(?:-\d+\.\d+)?)',
+ pattern => '(pc|pc(-i440fx)?-\d+(\.\d+)+(\.pxe)?|q35|pc-q35-\d+(\.\d+)+(\.pxe)?|virt(?:-\d+(\.\d+)+)?)',
maxLength => 40,
optional => 1,
});
});
- if ($keep_empty_config) {
- PVE::QemuConfig->write_config($vmid, { memory => 128 });
- } else {
- PVE::QemuConfig->destroy_config($vmid);
- }
-
# also remove unused disk
eval {
my $dl = PVE::Storage::vdisk_list($storecfg, undef, $vmid);
};
warn $@ if $@;
+
+ if ($keep_empty_config) {
+ PVE::QemuConfig->write_config($vmid, { memory => 128 });
+ } else {
+ PVE::QemuConfig->destroy_config($vmid);
+ }
}
sub parse_vm_config {
return $1 || 1;
}
-my $host_arch; # FIXME: fix PVE::Tools::get_host_arch
-sub get_host_arch() {
- $host_arch = (POSIX::uname())[4] if !$host_arch;
- return $host_arch;
-}
-
sub is_native($) {
my ($arch) = @_;
return get_host_arch() eq $arch;
});
}
-sub vm_destroy {
- my ($storecfg, $vmid, $skiplock) = @_;
-
- PVE::QemuConfig->lock_config($vmid, sub {
-
- my $conf = PVE::QemuConfig->load_config($vmid);
-
- if (!check_running($vmid)) {
- destroy_vm($storecfg, $vmid, undef, $skiplock);
- } else {
- die "VM $vmid is running - destroy failed\n";
- }
- });
-}
-
# vzdump restore implementaion
sub tar_archive_read_firstfile {
return 0;
}
+# dies if a) VM not running or not exisiting b) Version query failed
+# So, any defined return value is valid, any invalid state can be caught by eval
sub runs_at_least_qemu_version {
my ($vmid, $major, $minor, $extra) = @_;
- my $v = eval { vm_qmp_command($vmid, { execute => 'query-version' }) } // {};
+ my $v = vm_qmp_command($vmid, { execute => 'query-version' });
+ die "could not query currently running version for VM $vmid\n" if !defined($v);
$v = $v->{qemu};
return version_cmp($v->{major}, $major, $v->{minor}, $minor, $v->{micro}, $extra) >= 0;