mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-08-08 09:01:58 +00:00
fix coding style
This commit is contained in:
parent
c971c4f221
commit
97d62eb73c
@ -2678,7 +2678,7 @@ sub vm_start {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
sub qmp__read_avail {
|
my $qmp_read_avail = sub {
|
||||||
my ($fh, $timeout) = @_;
|
my ($fh, $timeout) = @_;
|
||||||
|
|
||||||
my $sel = new IO::Select;
|
my $sel = new IO::Select;
|
||||||
@ -2704,7 +2704,7 @@ sub qmp__read_avail {
|
|||||||
die "qmp read timeout\n" if !scalar(@ready);
|
die "qmp read timeout\n" if !scalar(@ready);
|
||||||
my $obj = from_json($res);
|
my $obj = from_json($res);
|
||||||
return $obj;
|
return $obj;
|
||||||
}
|
};
|
||||||
|
|
||||||
sub __read_avail {
|
sub __read_avail {
|
||||||
my ($fh, $timeout) = @_;
|
my ($fh, $timeout) = @_;
|
||||||
@ -2814,6 +2814,7 @@ sub vm_monitor_command {
|
|||||||
|
|
||||||
sub vm_qmp_command {
|
sub vm_qmp_command {
|
||||||
my ($vmid, $cmdstr, $nocheck) = @_;
|
my ($vmid, $cmdstr, $nocheck) = @_;
|
||||||
|
|
||||||
#http://git.qemu.org/?p=qemu.git;a=blob;f=qmp-commands.hx;h=db980fa811325aeca8ad43472ba468702d4a25a2;hb=HEAD
|
#http://git.qemu.org/?p=qemu.git;a=blob;f=qmp-commands.hx;h=db980fa811325aeca8ad43472ba468702d4a25a2;hb=HEAD
|
||||||
my $res;
|
my $res;
|
||||||
|
|
||||||
@ -2824,7 +2825,6 @@ sub vm_qmp_command {
|
|||||||
my $sock = IO::Socket::UNIX->new( Peer => $sname ) ||
|
my $sock = IO::Socket::UNIX->new( Peer => $sname ) ||
|
||||||
die "unable to connect to VM $vmid socket - $!\n";
|
die "unable to connect to VM $vmid socket - $!\n";
|
||||||
|
|
||||||
|
|
||||||
my $timeout = 3;
|
my $timeout = 3;
|
||||||
|
|
||||||
# maybe this works with qmp, need to be tested
|
# maybe this works with qmp, need to be tested
|
||||||
@ -2836,7 +2836,7 @@ sub vm_qmp_command {
|
|||||||
#}
|
#}
|
||||||
|
|
||||||
# read banner;
|
# read banner;
|
||||||
my $data = qmp__read_avail($sock, $timeout);
|
my $data = &$qmp_read_avail($sock, $timeout);
|
||||||
# '{"QMP": {"version": {"qemu": {"micro": 93, "minor": 0, "major": 1}, "package": " (qemu-kvm-devel)"}, "capabilities": []}} ';
|
# '{"QMP": {"version": {"qemu": {"micro": 93, "minor": 0, "major": 1}, "package": " (qemu-kvm-devel)"}, "capabilities": []}} ';
|
||||||
die "got unexpected qemu qmp banner\n" if !$data->{QMP};
|
die "got unexpected qemu qmp banner\n" if !$data->{QMP};
|
||||||
|
|
||||||
@ -2855,28 +2855,25 @@ sub vm_qmp_command {
|
|||||||
die "monitor write error - $!";
|
die "monitor write error - $!";
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = qmp__read_avail($sock, $timeout);
|
$res = &$qmp_read_avail($sock, $timeout);
|
||||||
# res = '{"return": {}}
|
# res = '{"return": {}}
|
||||||
die "qmp negociation error\n" if !$res->{return};
|
die "qmp negociation error\n" if !$res->{return};
|
||||||
|
|
||||||
|
|
||||||
$timeout = 20;
|
$timeout = 20;
|
||||||
|
|
||||||
|
my $fullcmd;
|
||||||
my $fullcmd = undef;
|
|
||||||
#generate json from hash for complex cmd
|
|
||||||
if (ref($cmdstr) eq "HASH") {
|
if (ref($cmdstr) eq "HASH") {
|
||||||
$fullcmd = to_json($cmdstr);
|
#generate json from hash for complex cmd
|
||||||
|
$fullcmd = to_json($cmdstr);
|
||||||
|
|
||||||
if ($fullcmd->{execute} =~ m/^(info\s+migrate|migrate\s)/) {
|
if ($fullcmd->{execute} =~ m/^(info\s+migrate|migrate\s)/) {
|
||||||
$timeout = 60*60; # 1 hour
|
$timeout = 60*60; # 1 hour
|
||||||
} elsif ($fullcmd->{execute} =~ m/^(eject|change)/) {
|
} elsif ($fullcmd->{execute} =~ m/^(eject|change)/) {
|
||||||
$timeout = 60; # note: cdrom mount command is slow
|
$timeout = 60; # note: cdrom mount command is slow
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
#execute command for simple action
|
#execute command for simple action
|
||||||
else {
|
$fullcmd = '{ "execute": "' . $cmdstr . '" }';
|
||||||
$fullcmd = '{ "execute": "'.$cmdstr.'" }';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!($b = $sock->syswrite($fullcmd)) || ($b != length($fullcmd))) {
|
if (!($b = $sock->syswrite($fullcmd)) || ($b != length($fullcmd))) {
|
||||||
@ -2884,11 +2881,10 @@ sub vm_qmp_command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ref($cmdstr) ne "HASH") {
|
if (ref($cmdstr) ne "HASH") {
|
||||||
return if ($cmdstr eq 'q') || ($cmdstr eq 'quit');
|
return if ($cmdstr eq 'q') || ($cmdstr eq 'quit');
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = qmp__read_avail($sock, $timeout);
|
$res = &$qmp_read_avail($sock, $timeout);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
my $err = $@;
|
my $err = $@;
|
||||||
|
Loading…
Reference in New Issue
Block a user