[pve-devel] r5122 - qemu-server/pve2
svn-commits at proxmox.com
svn-commits at proxmox.com
Mon Sep 13 11:26:40 CEST 2010
Author: dietmar
Date: 2010-09-13 09:26:40 +0000 (Mon, 13 Sep 2010)
New Revision: 5122
Modified:
qemu-server/pve2/ChangeLog
qemu-server/pve2/QemuServer.pm
qemu-server/pve2/nqm
qemu-server/pve2/qm
Log:
* nqm: implement monitor command
* QemuServer.pm (vm_monitor_command): remove $self - not needed at all.
Modified: qemu-server/pve2/ChangeLog
===================================================================
--- qemu-server/pve2/ChangeLog 2010-09-13 08:57:29 UTC (rev 5121)
+++ qemu-server/pve2/ChangeLog 2010-09-13 09:26:40 UTC (rev 5122)
@@ -1,3 +1,9 @@
+2010-09-13 Proxmox Support Team <support at proxmox.com>
+
+ * nqm: implement monitor command
+
+ * QemuServer.pm (vm_monitor_command): remove $self - not needed at all.
+
2010-09-10 Proxmox Support Team <support at proxmox.com>
* nqm: implement wait, showcmd and startall
Modified: qemu-server/pve2/QemuServer.pm
===================================================================
--- qemu-server/pve2/QemuServer.pm 2010-09-13 08:57:29 UTC (rev 5121)
+++ qemu-server/pve2/QemuServer.pm 2010-09-13 09:26:40 UTC (rev 5122)
@@ -2118,20 +2118,20 @@
} else {
unlink $statefile;
# fixme: send resume - is that necessary ?
- eval { $self->vm_monitor_command ($vmid, "cont", 1) };
+ eval { vm_monitor_command ($vmid, "cont", 1) };
}
}
if (my $migrate_speed =
$conf->{migrate_speed} || $defaults->{migrate_speed}) {
my $cmd = "migrate_set_speed ${migrate_speed}m";
- eval { $self->vm_monitor_command ($vmid, $cmd, 1); };
+ eval { vm_monitor_command ($vmid, $cmd, 1); };
}
if (my $migrate_downtime =
$conf->{migrate_downtime} || $defaults->{migrate_downtime}) {
my $cmd = "migrate_set_downtime ${migrate_downtime}";
- eval { $self->vm_monitor_command ($vmid, $cmd, 1); };
+ eval { vm_monitor_command ($vmid, $cmd, 1); };
}
});
}
@@ -2169,7 +2169,7 @@
}
sub vm_monitor_command {
- my ($self, $vmid, $cmdstr, $nolog) = @_;
+ my ($vmid, $cmdstr, $nolog) = @_;
my $res;
@@ -2248,7 +2248,7 @@
# generate ticket, olny first 8 character used by vnc
$ticket = Digest::SHA1::sha1_base64 (rand(), time()) if !$ticket;
- $self->vm_monitor_command ($vmid, "change vnc ticket $ticket", 1);
+ vm_monitor_command ($vmid, "change vnc ticket $ticket", 1);
return $ticket;
}
@@ -2276,7 +2276,7 @@
syslog ("info", "VM $vmid sending 'reset'");
- $self->vm_monitor_command ($vmid, "system_reset", 1);
+ vm_monitor_command ($vmid, "system_reset", 1);
});
}
@@ -2311,7 +2311,7 @@
syslog ("info", "VM $vmid sending 'shutdown'");
- $self->vm_monitor_command ($vmid, "system_powerdown", 1);
+ vm_monitor_command ($vmid, "system_powerdown", 1);
});
}
@@ -2333,7 +2333,7 @@
syslog ("info", "VM $vmid stopping");
- eval { $self->vm_monitor_command ($vmid, "quit", 1); };
+ eval { vm_monitor_command ($vmid, "quit", 1); };
my $err = $@;
@@ -2385,7 +2385,7 @@
syslog ("info", "VM $vmid suspend");
- $self->vm_monitor_command ($vmid, "stop", 1);
+ vm_monitor_command ($vmid, "stop", 1);
});
}
@@ -2400,7 +2400,7 @@
syslog ("info", "VM $vmid resume");
- $self->vm_monitor_command ($vmid, "cont", 1);
+ vm_monitor_command ($vmid, "cont", 1);
});
}
@@ -2415,7 +2415,7 @@
syslog ("info", "VM $vmid sending cntl-alt-delete");
- $self->vm_monitor_command ($vmid, "sendkey ctrl-alt-delete", 1);
+ vm_monitor_command ($vmid, "sendkey ctrl-alt-delete", 1);
});
}
@@ -2463,12 +2463,12 @@
}
if ($volid eq 'eject' || $volid eq 'none') {
- $self->vm_monitor_command ($vmid, "eject $qdn", 1);
+ vm_monitor_command ($vmid, "eject $qdn", 1);
} else {
my $path = get_iso_path ($self->{storecfg}, $vmid, $volid);
- $self->vm_monitor_command ($vmid, "eject $qdn", 1);
- $self->vm_monitor_command ($vmid, "change $qdn \"$path\"", 1);
+ vm_monitor_command ($vmid, "eject $qdn", 1);
+ vm_monitor_command ($vmid, "change $qdn \"$path\"", 1);
}
});
}
@@ -2571,7 +2571,7 @@
syslog ('info', $msg);
print $msg;
- eval { $self->vm_monitor_command ($vmid, "quit", 1); };
+ eval { vm_monitor_command ($vmid, "quit", 1); };
print STDERR $@ if $@;
}
Modified: qemu-server/pve2/nqm
===================================================================
--- qemu-server/pve2/nqm 2010-09-13 08:57:29 UTC (rev 5121)
+++ qemu-server/pve2/nqm 2010-09-13 09:26:40 UTC (rev 5122)
@@ -10,6 +10,7 @@
use PVE::QemuServer;
use PVE::API2::QemuServer;
use PVE::JSONSchema qw(get_standard_option);
+use Term::ReadLine;
use PVE::CLIHandler;
@@ -122,6 +123,47 @@
return undef;
}});
+__PACKAGE__->register_method ({
+ name => 'monitor',
+ path => 'monitor',
+ method => 'POST',
+ description => "Enter Qemu Monitor interface.",
+ parameters => {
+ additionalProperties => 0,
+ properties => {
+ vmid => get_standard_option('pve-vmid'),
+ },
+ },
+ returns => { type => 'null'},
+ code => sub {
+ my ($param) = @_;
+
+ my $vmid = $param->{vmid};
+
+ my $conf = PVE::QemuServer::load_config ($vmid); # check if VM exists
+
+ print "Entering Qemu Monitor for VM $vmid - type 'help' for help\n";
+
+ my $term = new Term::ReadLine ('qm');
+
+ my $input;
+ while (defined ($input = $term->readline('qm> '))) {
+ chomp $input;
+
+ next if $input =~ m/^\s*$/;
+
+ if ($input =~ m/^\s*q(uit)?\s*$/) {
+ exit (0);
+ }
+ eval {
+ print PVE::QemuServer::vm_monitor_command ($vmid, $input);
+ };
+ print "ERROR: $@" if $@;
+ }
+ }});
+
+# fixme: unlink
+
my $cmddef = {
list => [ "PVE::API2::QemuServer", 'vmlist', [],
{ node => $hostname }, sub {
@@ -157,6 +199,8 @@
wait => [ __PACKAGE__, 'wait', ['vmid']],
+ monitor => [ __PACKAGE__, 'monitor', ['vmid']],
+
startall => [ __PACKAGE__, 'startall', []],
};
Modified: qemu-server/pve2/qm
===================================================================
--- qemu-server/pve2/qm 2010-09-13 08:57:29 UTC (rev 5121)
+++ qemu-server/pve2/qm 2010-09-13 09:26:40 UTC (rev 5122)
@@ -455,7 +455,7 @@
exit (0);
}
eval {
- print $qm->vm_monitor_command ($vmid, $input);
+ print PVE::QemuServer::vm_monitor_command ($vmid, $input);
};
print "ERROR: $@" if $@;
}
More information about the pve-devel
mailing list