From ff556cf2a0b9047ee61d1abba87c119acc878ffa Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Wed, 5 Jun 2013 09:52:22 +0200 Subject: [PATCH] implement get_current_qemu_machine --- PVE/QemuServer.pm | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index fca246d5..d1850383 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -4764,4 +4764,21 @@ sub clone_disk { return $disk; } +# this only works if VM is running +sub get_current_qemu_machine { + my ($vmid) = @_; + + my $cmd = { execute => 'query-machines', arguments => {} }; + my $res = PVE::QemuServer::vm_qmp_command($vmid, $cmd); + + my ($current, $default); + foreach my $e (@$res) { + $default = $e->{name} if $e->{'is-default'}; + $current = $e->{name} if $e->{'is-current'}; + } + + # fallback to the default machine if current is not supported by qemu + return $current || $default || 'pc'; +} + 1; -- 2.39.5