diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index 7168c86c..75751845 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -472,7 +472,7 @@ PVE::JSONSchema::register_standard_option("pve-qm-hostpci", $hostpcidesc); my $serialdesc = { optional => 1, - type => 'string', format => 'pve-qm-serial', + type => 'string', pattern => '/dev/ttyS\d+', description => < 1, - type => 'string', format => 'pve-qm-parallel', + type => 'string', pattern => '/dev/parport\d+', description => <{"parallel$i"} = $paralleldesc; @@ -1142,59 +1140,6 @@ sub verify_usb_device { die "unable to parse usb device\n"; } -PVE::JSONSchema::register_format('pve-qm-parallel', \&verify_parallel); -sub verify_parallel { - my ($value, $noerr) = @_; - - return $value if parse_parallel($value); - - return undef if $noerr; - - die "invalid device name\n"; -} - -sub parse_parallel { - my ($value) = @_; - - return undef if !$value; - - my $res = {}; - if ($value =~ m|^/dev/parport\d+$|) { - $res->{dev} = $value; - } else { - return undef; - } - - return $res; -} - -PVE::JSONSchema::register_format('pve-qm-serial', \&verify_serial); -sub verify_serial { - my ($value, $noerr) = @_; - - return $value if parse_serial($value); - - return undef if $noerr; - - die "invalid device name\n"; - -} - -sub parse_serial { - my ($value) = @_; - - return undef if !$value; - - my $res = {}; - if ($value =~ m|^/dev/ttyS\d+$|) { - $res->{dev} = $value; - } else { - return undef; - } - - return $res; -} - # add JSON properties for create and set function sub json_config_properties { my $prop = shift; @@ -2051,17 +1996,13 @@ sub config_to_command { # serial devices for (my $i = 0; $i < $MAX_SERIAL_PORTS; $i++) { - my $d = parse_serial($conf->{"serial$i"}); - next if !$d; - push @$cmd, '-chardev', "tty,id=serial$i,path=$d->{dev}"; + push @$cmd, '-chardev', "tty,id=serial$i,path=$conf->{serial$i}"; push @$cmd, '-device', "isa-serial,chardev=serial$i"; } # parallel devices for (my $i = 0; $i < $MAX_PARALLEL_PORTS; $i++) { - my $d = parse_parallel($conf->{"parallel$i"}); - next if !$d; - push @$cmd, '-chardev', "parport,id=parallel$i,path=$d->{dev}"; + push @$cmd, '-chardev', "parport,id=parallel$i,path=$conf->{parallel$i}"; push @$cmd, '-device', "isa-parallel,chardev=parallel$i"; }