From: Stefan Reiter <s.reiter@proxmox.com>
To: pve-devel@lists.proxmox.com, pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH v2 qemu-server 09/11] extract register_qmeventd_handle to QemuServer.pm
Date: Wed, 3 Mar 2021 10:56:10 +0100 [thread overview]
Message-ID: <20210303095612.7475-10-s.reiter@proxmox.com> (raw)
In-Reply-To: <20210303095612.7475-1-s.reiter@proxmox.com>
...to be reused by live-restore.
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
---
v2:
* unchanged
PVE/QemuServer.pm | 28 ++++++++++++++++++++++++++++
PVE/VZDump/QemuServer.pm | 32 ++------------------------------
2 files changed, 30 insertions(+), 30 deletions(-)
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index d4ee8ec..e420de3 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -7470,6 +7470,34 @@ sub device_bootorder {
return $bootorder;
}
+sub register_qmeventd_handle {
+ my ($vmid) = @_;
+
+ my $fh;
+ my $peer = "/var/run/qmeventd.sock";
+ my $count = 0;
+
+ for (;;) {
+ $count++;
+ $fh = IO::Socket::UNIX->new(Peer => $peer, Blocking => 0, Timeout => 1);
+ last if $fh;
+ if ($! != EINTR && $! != EAGAIN) {
+ die "unable to connect to qmeventd socket (vmid: $vmid) - $!\n";
+ }
+ if ($count > 4) {
+ die "unable to connect to qmeventd socket (vmid: $vmid) - timeout "
+ . "after $count retries\n";
+ }
+ usleep(25000);
+ }
+
+ # send handshake to mark VM as backing up
+ print $fh to_json({vzdump => {vmid => "$vmid"}});
+
+ # return handle to be closed later when inhibit is no longer required
+ return $fh;
+}
+
# bash completion helper
sub complete_backup_archives {
diff --git a/PVE/VZDump/QemuServer.pm b/PVE/VZDump/QemuServer.pm
index 901b366..aaff712 100644
--- a/PVE/VZDump/QemuServer.pm
+++ b/PVE/VZDump/QemuServer.pm
@@ -481,7 +481,7 @@ sub archive_pbs {
my $devlist = _get_task_devlist($task);
$self->enforce_vm_running_for_backup($vmid);
- $self->register_qmeventd_handle($vmid);
+ $self->{qmeventd_fh} = PVE::QemuServer::register_qmeventd_handle($vmid);
my $backup_job_uuid;
eval {
@@ -650,7 +650,7 @@ sub archive_vma {
my $devlist = _get_task_devlist($task);
$self->enforce_vm_running_for_backup($vmid);
- $self->register_qmeventd_handle($vmid);
+ $self->{qmeventd_fh} = PVE::QemuServer::register_qmeventd_handle($vmid);
my $cpid;
my $backup_job_uuid;
@@ -809,34 +809,6 @@ sub enforce_vm_running_for_backup {
die $@ if $@;
}
-sub register_qmeventd_handle {
- my ($self, $vmid) = @_;
-
- my $fh;
- my $peer = "/var/run/qmeventd.sock";
- my $count = 0;
-
- for (;;) {
- $count++;
- $fh = IO::Socket::UNIX->new(Peer => $peer, Blocking => 0, Timeout => 1);
- last if $fh;
- if ($! != EINTR && $! != EAGAIN) {
- $self->log("warn", "unable to connect to qmeventd socket (vmid: $vmid) - $!\n");
- return;
- }
- if ($count > 4) {
- $self->log("warn", "unable to connect to qmeventd socket (vmid: $vmid)"
- . " - timeout after $count retries\n");
- return;
- }
- usleep(25000);
- }
-
- # send handshake to mark VM as backing up
- print $fh to_json({vzdump => {vmid => "$vmid"}});
- $self->{qmeventd_fh} = $fh;
-}
-
# resume VM againe once we got in a clear state (stop mode backup of running VM)
sub resume_vm_after_job_start {
my ($self, $task, $vmid) = @_;
--
2.20.1
next prev parent reply other threads:[~2021-03-03 9:57 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-03 9:56 [pbs-devel] [PATCH v2 00/11] live-restore for PBS snapshots Stefan Reiter
2021-03-03 9:56 ` [pbs-devel] [PATCH v2 pve-qemu 01/11] clean up pve/ patches by merging Stefan Reiter
2021-03-03 16:32 ` [pbs-devel] applied: [pve-devel] " Thomas Lamprecht
2021-03-03 9:56 ` [pbs-devel] [PATCH v2 pve-qemu 02/11] move bitmap-mirror patches to seperate folder Stefan Reiter
2021-03-03 16:32 ` [pbs-devel] applied: [pve-devel] " Thomas Lamprecht
2021-03-03 9:56 ` [pbs-devel] [PATCH v2 pve-qemu 03/11] add alloc-track block driver patch Stefan Reiter
2021-03-15 14:14 ` [pbs-devel] [pve-devel] " Wolfgang Bumiller
2021-03-15 15:41 ` [pbs-devel] [PATCH pve-qemu v3] " Stefan Reiter
2021-03-16 19:57 ` [pbs-devel] applied: [pve-devel] " Thomas Lamprecht
2021-03-03 9:56 ` [pbs-devel] [PATCH v2 proxmox-backup 04/11] RemoteChunkReader: add LRU cached variant Stefan Reiter
2021-03-03 9:56 ` [pbs-devel] [PATCH v2 proxmox-backup-qemu 05/11] access: use bigger cache and LRU chunk reader Stefan Reiter
2021-03-16 20:17 ` [pbs-devel] [pve-devel] " Thomas Lamprecht
2021-03-17 13:37 ` Stefan Reiter
2021-03-17 13:59 ` Thomas Lamprecht
2021-03-17 16:03 ` Dietmar Maurer
2021-03-03 9:56 ` [pbs-devel] [PATCH v2 qemu-server 06/11] make qemu_drive_mirror_monitor more generic Stefan Reiter
2021-03-03 9:56 ` [pbs-devel] [PATCH v2 qemu-server 07/11] cfg2cmd: allow PBS snapshots as backing files for drives Stefan Reiter
2021-03-03 9:56 ` [pbs-devel] [PATCH v2 qemu-server 08/11] enable live-restore for PBS Stefan Reiter
2021-03-03 9:56 ` Stefan Reiter [this message]
2021-03-03 9:56 ` [pbs-devel] [PATCH v2 qemu-server 10/11] live-restore: register qmeventd handle Stefan Reiter
2021-03-03 9:56 ` [pbs-devel] [PATCH v2 manager 11/11] ui: restore: add live-restore checkbox Stefan Reiter
2021-04-15 18:34 ` [pbs-devel] applied: [pve-devel] " Thomas Lamprecht
2021-03-22 11:08 ` [pbs-devel] [pve-devel] [PATCH v2 00/11] live-restore for PBS snapshots Dominic Jäger
2021-04-06 19:09 ` [pbs-devel] partially-applied: " Thomas Lamprecht
2021-04-15 18:35 ` [pbs-devel] " 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=20210303095612.7475-10-s.reiter@proxmox.com \
--to=s.reiter@proxmox.com \
--cc=pbs-devel@lists.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