Compare commits

..

4 commits

Author SHA1 Message Date
Tiago Sousa
be6264ebbf first functional version of extend lv 2025-10-10 18:07:06 +01:00
Tiago Sousa
7fe84f2902 blockdev: add query-blockstats qmp command 2025-10-10 18:07:06 +01:00
Tiago Sousa
88d7de0720 blockdev: add set write threshold
blockdev: set write threshold
2025-10-10 18:07:06 +01:00
Tiago Sousa
1d1e4aa3a7 qmeventd: add block write threshold event handling 2025-10-10 18:07:06 +01:00
8 changed files with 20 additions and 182 deletions

View file

@ -5830,16 +5830,16 @@ sub vm_start_nolock {
return if PVE::QemuServer::drive_is_cdrom($drive, 1);
my $volid = $drive->{file};
if ( $volid ne 'none') {
my $extra_blockdev_options = {};
# $extra_blockdev_options->{'live-restore'} = $live_restore if $live_restore;
# extra protection for templates, but SATA and IDE don't support it..
$extra_blockdev_options->{'read-only'} = 1
if drive_is_read_only($conf, $drive);
my $drive_id = PVE::QemuServer::Drive::get_drive_id($drive);
PVE::QemuServer::Blockdev::set_write_threshold(
$storecfg, $vmid, $drive_id, $volid, $extra_blockdev_options,
);
my $snapshots = PVE::Storage::volume_snapshot_info($storecfg, $volid);
my $parentid = $snapshots->{'current'}->{parent};
# for now only set write_threshold for volumes that have snapshots
# FIX: Change to only thin drives
if ($parentid) {
PVE::QemuServer::Blockdev::set_write_threshold(
$storecfg, $vmid, $drive_id, $volid
);
}
}
},
);

View file

@ -17,7 +17,6 @@ use PVE::QemuServer::Drive qw(drive_is_cdrom);
use PVE::QemuServer::Helpers;
use PVE::QemuServer::Machine;
use PVE::QemuServer::Monitor qw(mon_cmd);
use PVE::SafeSyslog;
# gives ($host, $port, $export)
my $NBD_TCP_PATH_RE_3 = qr/nbd:(\S+):(\d+):exportname=(\S+)/;
@ -721,8 +720,10 @@ sub underlay_resize {
my $running = PVE::QemuServer::Helpers::vm_running_locally($vmid);
my $size = PVE::Storage::volume_underlay_resize($storecfg, $volid);
syslog("info", "got size $size KiB\n");
# get backing_snap
my $snapshots = PVE::Storage::volume_snapshot_info($storecfg, $volid);
my $backing_snap = $snapshots->{current}->{parent};
my $size = PVE::Storage::volume_underlay_resize($storecfg, $volid, $backing_snap);
return if !$running;
my $block_info = get_block_info($vmid);
@ -866,15 +867,11 @@ sub block_set_write_threshold {
}
sub compute_write_threshold {
my ($storecfg, $volid) = @_;
my ($storecfg, $scfg, $volid) = @_;
my $lv_size = PVE::Storage::volume_underlay_size_info($storecfg, $volid, 5);
# FIX: change these vars to config inputs
my $chunksize = 1024 * 1024 * 1024; # 1 GiB
my $alert_chunk_percentage = 0.5; # alert when percetage of chunk used
my $write_threshold = $lv_size - $chunksize * (1 - $alert_chunk_percentage);
my $write_threshold = $lv_size - $scfg->{chunksize} * (1 - $scfg->{'chunk-percentage'});
return $write_threshold;
}
@ -892,17 +889,11 @@ sub set_write_threshold {
# return if drive is not set as thin
# return if !$drive->{thin};
my $nodename = get_node_name('file', $drive_id, $volid, $options);
my $write_threshold = compute_write_threshold($storecfg, $scfg, $volid);
print "setting threshold for $volid from $storeid\n";
my $snapshots = PVE::Storage::volume_snapshot_info($storecfg, $volid);
my $parentid = $snapshots->{'current'}->{parent};
# for now only set write_threshold for volumes that have snapshots
if ($parentid) {
my $nodename = get_node_name('file', $drive_id, $volid, $options);
my $write_threshold = compute_write_threshold($storecfg, $volid);
block_set_write_threshold($vmid, $nodename, $write_threshold);
}
block_set_write_threshold($vmid, $nodename, $write_threshold);
}
sub blockdev_external_snapshot {
@ -954,6 +945,7 @@ sub blockdev_external_snapshot {
overlay => $new_fmt_blockdev->{'node-name'},
);
# FIX: only if thin
my $drive_id = PVE::QemuServer::Drive::get_drive_id($drive);
set_write_threshold($storecfg, $vmid, $drive_id, $volid);
}

View file

@ -1,8 +0,0 @@
<!-- DocBook document information file for Proxmox VE asciidoc docs -->
<authorgroup>
<corpauthor>Proxmox Server Solutions Gmbh
<ulink url="https://www.proxmox.com/"><citetitle>www.proxmox.com</citetitle></ulink>
</corpauthor>
</authorgroup>

View file

@ -1,18 +0,0 @@
Copyright and Disclaimer
------------------------
Copyright (C) 2007-2022 Proxmox Server Solutions GmbH
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public
License along with this program. If not, see
https://www.gnu.org/licenses/

Binary file not shown.

View file

@ -1,80 +0,0 @@
'\" t
.\" Title: qmeventd
.\" Author: Proxmox Server Solutions Gmbh \m[blue]\fBwww.proxmox.com\fR\m[]
.\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
.\" Date: Fri Aug 15 05:33:35 PM WEST 2025
.\" Manual: Proxmox VE Documentation
.\" Source: \ \& 9.0.8
.\" Language: English
.\"
.TH "QMEVENTD" "8" "Fri Aug 15 05:33:35 PM WEST 2025" "\ \& 9\&.0\&.8" "Proxmox VE Documentation"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
qmeventd \- PVE QEMU Eventd Daemon
.SH "SYNOPSIS"
.sp
\fBqmeventd\fR [\-f] [\-v] PATH
.PP
\-v
.RS 4
Turn on verbose messages
.RE
.PP
\-f
.RS 4
Do not daemonize server
.RE
.PP
PATH
.RS 4
The path to listen on
.RE
.sp
This service is usually started and managed using systemd toolset\&. The service is called \fIqmeventd\fR\&.
.sp
.nf
systemctl start qmeventd
.fi
.sp
.nf
systemctl stop qmeventd
.fi
.sp
.nf
systemctl status qmeventd
.fi
.SH "DESCRIPTION"
.sp
qmeventd is a daemon that listens on PATH for incoming connections from a qemu qmp socket, and waits for SHUTDOWN events\&. When a client then disconnects, it executes /usr/sbin/qm cleanup\&. This makes it easy to clean up leftover tap devices, vgpus, etc\&.
.SH "COPYRIGHT AND DISCLAIMER"
.sp
Copyright \(co 2007\-2022 Proxmox Server Solutions GmbH
.sp
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version\&.
.sp
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE\&. See the GNU Affero General Public License for more details\&.
.sp
You should have received a copy of the GNU Affero General Public License along with this program\&. If not, see \m[blue]\fBhttps://www\&.gnu\&.org/licenses/\fR\m[]
.SH "AUTHOR"
.PP
\fBProxmox Server Solutions Gmbh
\fR\fB\m[blue]\fBwww\&.proxmox\&.com\fR\m[]\fR\fB
\fR

View file

@ -1,16 +0,0 @@
*qmeventd* `[-f]` `[-v]` `PATH`
`-v`:: Turn on verbose messages
`-f`:: Do not daemonize server
`PATH`:: The path to listen on
This service is usually started and managed using systemd toolset. The
service is called 'qmeventd'.
systemctl start qmeventd
systemctl stop qmeventd
systemctl status qmeventd

View file

@ -1,32 +0,0 @@
ifdef::manvolnum[]
qmeventd(8)
===========
:pve-toplevel:
NAME
----
qmeventd - PVE QEMU Eventd Daemon
SYNOPSIS
--------
include::qmeventd.8-synopsis.adoc[]
DESCRIPTION
-----------
endif::manvolnum[]
ifndef::manvolnum[]
PVE QEMU Event Daemon
=====================
endif::manvolnum[]
`qmeventd` is a daemon that listens on PATH for incoming connections from
a qemu qmp socket, and waits for SHUTDOWN events. When a client then
disconnects, it executes `/usr/sbin/qm cleanup`. This makes it easy
to clean up leftover tap devices, vgpus, etc.
ifdef::manvolnum[]
include::pve-copyright.adoc[]
endif::manvolnum[]