From ea71be24d6d93a38f47c463820e52e3d0c05de93 Mon Sep 17 00:00:00 2001 From: Fabian Ebner Date: Mon, 1 Mar 2021 16:53:25 +0100 Subject: [PATCH] machine: split out helper for handling query-machines qmp command result to be re-used in the vmstatus() call. Signed-off-by: Fabian Ebner Reviewed-by: Stefan Reiter --- PVE/QemuServer/Machine.pm | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/PVE/QemuServer/Machine.pm b/PVE/QemuServer/Machine.pm index c168adee..24749516 100644 --- a/PVE/QemuServer/Machine.pm +++ b/PVE/QemuServer/Machine.pm @@ -18,11 +18,8 @@ sub machine_type_is_q35 { return $conf->{machine} && ($conf->{machine} =~ m/q35/) ? 1 : 0; } -# this only works if VM is running -sub get_current_qemu_machine { - my ($vmid) = @_; - - my $res = PVE::QemuServer::Monitor::mon_cmd($vmid, 'query-machines'); +sub current_from_query_machines { + my ($res) = @_; my ($current, $pve_version, $default); foreach my $e (@$res) { @@ -37,6 +34,15 @@ sub get_current_qemu_machine { return $current || $default || 'pc'; } +# this only works if VM is running +sub get_current_qemu_machine { + my ($vmid) = @_; + + my $res = PVE::QemuServer::Monitor::mon_cmd($vmid, 'query-machines'); + + return current_from_query_machines($res); +} + # returns a string with major.minor+pve, patch version-part is ignored # as it's seldom ressembling a real QEMU machine type, so it would be '0' 99% of # the time anyway.. This explicitly separates pveversion from the machine.