From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: Re: [pve-devel] [PATCH qemu-server] vzdump: use minimal VM config for offline backup
Date: Mon, 7 Sep 2020 08:59:26 +0200 [thread overview]
Message-ID: <b7916e00-ee6f-3624-9d3f-68eee1ac0872@proxmox.com> (raw)
In-Reply-To: <20200824092131.24617-1-s.reiter@proxmox.com>
does that not break the feature that
we can start a vm that started a backup while stopped?
atm we can start a backup on a stopped vm, and then simply start
it, without aborting the backup. if i read the patch
correctly, the vm now has just a minimal config and not
what the user configured
On 8/24/20 11:21 AM, Stefan Reiter wrote:
> In case we backup a stopped VM, we start an instance of QEMU to run the
> backup job. This instance will be killed afterwards without ever running
> the actual VM, so there's no need to potentially allocate or use host
> system resources for features never used.
>
> The minimal_trim_opts array contains elements that will be cleaned from
> the config before starting.
>
> We only write back the config in case of resume, which is never set together
> with the new "minimal" option.
>
> Reported in the forum:
> https://forum.proxmox.com/threads/pbs-tries-to-start-vms-during-backup-not-enough-ram.74773/
>
> Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
> ---
>
> It is weird to me that this even happens, AFAIU QEMU only allocates the guest
> RAM as virtual as long as the guest doesn't write to it - but the forum post
> proves that it does, and it's probably also a good idea to not assign hostpci
> and usb devices for offline backups.
>
> PVE/QemuServer.pm | 34 ++++++++++++++++++++++++++++++++++
> PVE/VZDump/QemuServer.pm | 1 +
> 2 files changed, 35 insertions(+)
>
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
> index a5ee8e2..73eb561 100644
> --- a/PVE/QemuServer.pm
> +++ b/PVE/QemuServer.pm
> @@ -4778,6 +4778,37 @@ sub vm_migrate_alloc_nbd_disks {
> return $nbd;
> }
>
> +my @minimal_trim_opts = (
> + qr/^hostpci\d+/,
> + qr/^serial\d+/,
> + qr/^usb\d+/,
> + qr/^net\d+/,
> + qr/^rng\d+/,
> + qr/^ivshmem/,
> + qr/^hugepages/,
> + qr/^smp/,
> + qr/^cores/,
> + qr/^sockets/,
> + qr/^vcpus/,
> + qr/^cpu/,
> + qr/^agent/,
> + qr/^numa(?:\d+)?/,
> +);
> +
> +my sub vm_trim_conf_minimal {
> + my ($conf) = @_;
> +
> + $conf->{memory} = 1;
> + $conf->{balloon} = 0;
> +
> + # remove anything that does not affect backup but can claim host resources
> + foreach my $r (@minimal_trim_opts) {
> + foreach my $key (keys %{$conf}) {
> + delete $conf->{$key} if $key =~ $r;
> + }
> + }
> +}
> +
> # see vm_start_nolock for parameters, additionally:
> # migrate_opts:
> # storagemap = parsed storage map for allocating NBD disks
> @@ -4823,6 +4854,7 @@ sub vm_start {
> # timeout => in seconds
> # paused => start VM in paused state (backup)
> # resume => resume from hibernation
> +# minimal => only use necessary resources (backup)
> # migrate_opts:
> # nbd => volumes for NBD exports (vm_migrate_alloc_nbd_disks)
> # migratedfrom => source node
> @@ -4851,6 +4883,8 @@ sub vm_start_nolock {
> $conf = PVE::QemuConfig->load_config($vmid); # update/reload
> }
>
> + vm_trim_conf_minimal($conf) if $params->{minimal};
> +
> PVE::QemuServer::Cloudinit::generate_cloudinitconfig($conf, $vmid);
>
> my $defaults = load_defaults();
> diff --git a/PVE/VZDump/QemuServer.pm b/PVE/VZDump/QemuServer.pm
> index 7297795..ea8faa3 100644
> --- a/PVE/VZDump/QemuServer.pm
> +++ b/PVE/VZDump/QemuServer.pm
> @@ -827,6 +827,7 @@ sub enforce_vm_running_for_backup {
> skiplock => 1,
> skiptemplate => 1,
> paused => 1,
> + minimal => !$self->{vm_was_running},
> };
> PVE::QemuServer::vm_start($self->{storecfg}, $vmid, $params);
> };
>
next prev parent reply other threads:[~2020-09-07 7:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-24 9:21 Stefan Reiter
2020-09-07 6:59 ` Dominik Csapak [this message]
2020-09-07 7:05 ` Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b7916e00-ee6f-3624-9d3f-68eee1ac0872@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox