From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id BA68D1FF16F for ; Tue, 14 Oct 2025 16:40:53 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 5979F7B1E; Tue, 14 Oct 2025 16:40:27 +0200 (CEST) From: Fiona Ebner To: pve-devel@lists.proxmox.com Date: Tue, 14 Oct 2025 16:39:19 +0200 Message-ID: <20251014143946.160679-9-f.ebner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251014143946.160679-1-f.ebner@proxmox.com> References: <20251014143946.160679-1-f.ebner@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1760452752964 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.021 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH qemu-server 08/16] helpers: add functions for qemu-storage-daemon instances X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" In particular, a function to get the path to the PID file and a function to check whether the qemu-storage-daemon instance is running. Signed-off-by: Fiona Ebner --- src/PVE/QemuServer.pm | 4 ++-- src/PVE/QemuServer/Helpers.pm | 33 ++++++++++++++++++++++++++------- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm index 7e1b7540..613ab361 100644 --- a/src/PVE/QemuServer.pm +++ b/src/PVE/QemuServer.pm @@ -2944,7 +2944,7 @@ sub query_supported_cpu_flags { my $kvm_supported = defined(kvm_version()); my $qemu_cmd = PVE::QemuServer::Helpers::get_command_for_arch($arch); my $fakevmid = -1; - my $pidfile = PVE::QemuServer::Helpers::pidfile_name($fakevmid); + my $pidfile = PVE::QemuServer::Helpers::vm_pidfile_name($fakevmid); # Start a temporary (frozen) VM with vmid -1 to allow sending a QMP command my $query_supported_run_qemu = sub { @@ -3197,7 +3197,7 @@ sub config_to_command { push @$cmd, '-mon', "chardev=qmp-event,mode=control"; } - push @$cmd, '-pidfile', PVE::QemuServer::Helpers::pidfile_name($vmid); + push @$cmd, '-pidfile', PVE::QemuServer::Helpers::vm_pidfile_name($vmid); push @$cmd, '-daemonize'; diff --git a/src/PVE/QemuServer/Helpers.pm b/src/PVE/QemuServer/Helpers.pm index cfbcf726..2c78a7b4 100644 --- a/src/PVE/QemuServer/Helpers.pm +++ b/src/PVE/QemuServer/Helpers.pm @@ -84,7 +84,12 @@ sub qmp_socket { return "${var_run_tmpdir}/${vmid}.${type}"; } -sub pidfile_name { +sub qsd_pidfile_name { + my ($vmid) = @_; + return "${var_run_tmpdir}/qsd-${vmid}.pid"; +} + +sub vm_pidfile_name { my ($vmid) = @_; return "${var_run_tmpdir}/$vmid.pid"; } @@ -94,7 +99,7 @@ sub vnc_socket { return "${var_run_tmpdir}/$vmid.vnc"; } -# Parse the cmdline of a running kvm/qemu process and return arguments as hash +# Parse the cmdline of a running kvm/qemu-* process and return arguments as hash sub parse_cmdline { my ($pid) = @_; @@ -106,7 +111,7 @@ sub parse_cmdline { my @param = split(/\0/, $line); my $cmd = $param[0]; - return if !$cmd || ($cmd !~ m|kvm$| && $cmd !~ m@(?:^|/)qemu-system-[^/]+$@); + return if !$cmd || ($cmd !~ m|kvm$| && $cmd !~ m@(?:^|/)qemu-[^/]+$@); my $phash = {}; my $pending_cmd; @@ -130,10 +135,8 @@ sub parse_cmdline { return; } -sub vm_running_locally { - my ($vmid) = @_; - - my $pidfile = pidfile_name($vmid); +my sub instance_running_locally { + my ($pidfile) = @_; if (my $fd = IO::File->new("<$pidfile")) { my $st = stat($fd); @@ -164,6 +167,22 @@ sub vm_running_locally { return; } +sub qsd_running_locally { + my ($vmid) = @_; + + my $pidfile = qsd_pidfile_name($vmid); + + return instance_running_locally($pidfile); +} + +sub vm_running_locally { + my ($vmid) = @_; + + my $pidfile = vm_pidfile_name($vmid); + + return instance_running_locally($pidfile); +} + sub min_version { my ($verstr, $major, $minor, $pve) = @_; -- 2.47.3 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel