5
0
mirror of git://git.proxmox.com/git/pve-qemu.git synced 2024-12-22 17:35:52 +03:00
pve-qemu/debian/parse-machines.pl
Thomas Lamprecht 6503e6e08d machine list: save as JSON
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-03-05 16:21:30 +01:00

28 lines
496 B
Perl
Executable File

#!/usr/bin/perl
use warnings;
use strict;
use JSON;
my $machines = [];
while (<STDIN>) {
if (/^\s*Supported machines are:/) {
next;
}
s/^\s+//;
my @machine = split(/\s+/);
next if $machine[0] !~ m/^pc-(i440fx|q35)-(.+)$/;
push @$machines, {
'id' => $machine[0],
'type' => $1,
'version' => $2,
};
}
die "no QEMU machine types detected from STDIN input" if scalar (@$machines) <= 0;
print to_json($machines, { utf8 => 1 }) or die "$!\n";