fix coding style

This commit is contained in:
Dietmar Maurer 2012-05-30 12:08:33 +02:00
parent c971c4f221
commit 97d62eb73c

View File

@ -2678,7 +2678,7 @@ sub vm_start {
});
}
sub qmp__read_avail {
my $qmp_read_avail = sub {
my ($fh, $timeout) = @_;
my $sel = new IO::Select;
@ -2704,7 +2704,7 @@ sub qmp__read_avail {
die "qmp read timeout\n" if !scalar(@ready);
my $obj = from_json($res);
return $obj;
}
};
sub __read_avail {
my ($fh, $timeout) = @_;
@ -2814,6 +2814,7 @@ sub vm_monitor_command {
sub vm_qmp_command {
my ($vmid, $cmdstr, $nocheck) = @_;
#http://git.qemu.org/?p=qemu.git;a=blob;f=qmp-commands.hx;h=db980fa811325aeca8ad43472ba468702d4a25a2;hb=HEAD
my $res;
@ -2824,7 +2825,6 @@ sub vm_qmp_command {
my $sock = IO::Socket::UNIX->new( Peer => $sname ) ||
die "unable to connect to VM $vmid socket - $!\n";
my $timeout = 3;
# maybe this works with qmp, need to be tested
@ -2836,7 +2836,7 @@ sub vm_qmp_command {
#}
# 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": []}} ';
die "got unexpected qemu qmp banner\n" if !$data->{QMP};
@ -2855,17 +2855,15 @@ sub vm_qmp_command {
die "monitor write error - $!";
}
$res = qmp__read_avail($sock, $timeout);
$res = &$qmp_read_avail($sock, $timeout);
# res = '{"return": {}}
die "qmp negociation error\n" if !$res->{return};
$timeout = 20;
my $fullcmd = undef;
#generate json from hash for complex cmd
my $fullcmd;
if (ref($cmdstr) eq "HASH") {
#generate json from hash for complex cmd
$fullcmd = to_json($cmdstr);
if ($fullcmd->{execute} =~ m/^(info\s+migrate|migrate\s)/) {
@ -2873,9 +2871,8 @@ sub vm_qmp_command {
} elsif ($fullcmd->{execute} =~ m/^(eject|change)/) {
$timeout = 60; # note: cdrom mount command is slow
}
}
} else {
#execute command for simple action
else {
$fullcmd = '{ "execute": "' . $cmdstr . '" }';
}
@ -2887,8 +2884,7 @@ sub vm_qmp_command {
return if ($cmdstr eq 'q') || ($cmdstr eq 'quit');
}
$res = qmp__read_avail($sock, $timeout);
$res = &$qmp_read_avail($sock, $timeout);
};
my $err = $@;