shares => {
optional => 1,
type => 'integer',
- description => "Amount of memory shares for auto-ballooning. The larger the number is, the more memory this VM gets. Number is relative to weights of all other running VMs. Using zero disables auto-ballooning",
+ description => "Amount of memory shares for auto-ballooning. The larger the number is, the more memory this VM gets. Number is relative to weights of all other running VMs. Using zero disables auto-ballooning. Auto-ballooning is done by pvestatd.",
minimum => 0,
maximum => 50000,
default => 1000,
keyboard => {
optional => 1,
type => 'string',
- description => "Keybord layout for vnc server. Default is read from the '/etc/pve/datacenter.conf' configuration file.".
+ description => "Keybord layout for vnc server. Default is read from the '/etc/pve/datacenter.cfg' configuration file.".
"It should not be necessary to set it.",
enum => PVE::Tools::kvmkeymaplist(),
default => undef,
$device .= ",bootindex=$drive->{bootindex}" if $drive->{bootindex};
+ if (my $serial = $drive->{serial}) {
+ $serial = URI::Escape::uri_unescape($serial);
+ $device .= ",serial=$serial";
+ }
+
+
return $device;
}
}
}
- if (my $serial = $drive->{serial}) {
- $serial = URI::Escape::uri_unescape($serial);
- $opts .= ",serial=$serial";
- }
-
$opts .= ",format=$format" if $format && !$drive->{format};
my $cache_direct = 0;
my ($vmid) = @_;
my $res = vm_mon_cmd($vmid, 'query-pci');
+ my $devices_to_check = [];
my $devices = {};
foreach my $pcibus (@$res) {
- foreach my $device (@{$pcibus->{devices}}) {
- next if !$device->{'qdev_id'};
- if ($device->{'pci_bridge'}) {
- $devices->{$device->{'qdev_id'}} = 1;
- foreach my $bridge_device (@{$device->{'pci_bridge'}->{devices}}) {
- next if !$bridge_device->{'qdev_id'};
- $devices->{$bridge_device->{'qdev_id'}} = 1;
- $devices->{$device->{'qdev_id'}}++;
- }
- } else {
- $devices->{$device->{'qdev_id'}} = 1;
- }
+ push @$devices_to_check, @{$pcibus->{devices}},
+ }
+
+ while (@$devices_to_check) {
+ my $to_check = [];
+ for my $d (@$devices_to_check) {
+ $devices->{$d->{'qdev_id'}} = 1 if $d->{'qdev_id'};
+ next if !$d->{'pci_bridge'};
+
+ $devices->{$d->{'qdev_id'}} += scalar(@{$d->{'pci_bridge'}->{devices}});
+ push @$to_check, @{$d->{'pci_bridge'}->{devices}};
}
+ $devices_to_check = $to_check;
}
my $resblock = vm_mon_cmd($vmid, 'query-block');
qemu_cpu_hotplug($vmid, $conf, undef);
} elsif ($opt eq 'balloon') {
# enable balloon device is not hotpluggable
- die "skip\n" if !defined($conf->{balloon}) || $conf->{balloon};
+ die "skip\n" if defined($conf->{balloon}) && $conf->{balloon} == 0;
+ # here we reset the ballooning value to memory
+ my $balloon = $conf->{memory} || $defaults->{memory};
+ vm_mon_cmd($vmid, "balloon", value => $balloon*1024*1024);
} elsif ($fast_plug_option->{$opt}) {
# do nothing
} elsif ($opt =~ m/^net(\d+)$/) {
}
$properties{timeout} = 10 if $statefile; # setting up the scope shoul be quick
+ my $run_qemu = sub {
+ PVE::Tools::run_fork sub {
+ PVE::Tools::enter_systemd_scope($vmid, "Proxmox VE VM $vmid", %properties);
+ run_command($cmd, %run_params);
+ };
+ };
+
if ($conf->{hugepages}) {
my $code = sub {
PVE::QemuServer::Memory::hugepages_mount();
PVE::QemuServer::Memory::hugepages_allocate($hugepages_topology, $hugepages_host_topology);
- eval {
- PVE::Tools::enter_systemd_scope($vmid, "Proxmox VE VM $vmid", %properties);
- run_command($cmd, %run_params);
- };
-
+ eval { $run_qemu->() };
if (my $err = $@) {
PVE::QemuServer::Memory::hugepages_reset($hugepages_host_topology);
die $err;
eval { PVE::QemuServer::Memory::hugepages_update_locked($code); };
} else {
- eval {
- PVE::Tools::enter_systemd_scope($vmid, "Proxmox VE VM $vmid", %properties);
- run_command($cmd, %run_params);
- };
+ eval { $run_qemu->() };
}
if (my $err = $@) {
}
} else {
- if (!$statefile && (!defined($conf->{balloon}) || $conf->{balloon})) {
- vm_mon_cmd_nocheck($vmid, "balloon", value => $conf->{balloon}*1024*1024)
- if $conf->{balloon};
- }
+ vm_mon_cmd_nocheck($vmid, "balloon", value => $conf->{balloon}*1024*1024)
+ if !$statefile && $conf->{balloon};
foreach my $opt (keys %$conf) {
next if $opt !~ m/^net\d+$/;
$machine = PVE::QemuServer::get_current_qemu_machine($vmid) if !$machine;
- foreach my $opt (keys %$conf) {
- next if $opt !~ m/^net(\d+)$/;
- my $net = PVE::QemuServer::parse_net($conf->{$opt});
- next if !$net;
- my $romfile = PVE::QemuServer::vm_mon_cmd_nocheck($vmid, 'qom-get', path => $opt, property => 'romfile');
- return $machine.".pxe" if $romfile =~ m/pxe/;
- last;
+ if ($conf->{machine} && $conf->{machine} =~ m/\.pxe$/) {
+ $machine .= '.pxe';
}
return $machine;
return $res;
}
+sub nbd_stop {
+ my ($vmid) = @_;
+
+ vm_mon_cmd($vmid, 'nbd-server-stop');
+}
+
1;