kvmtool
changeset 11 48ec3ee16cd8
parent 10 f48202d2c4a0
child 12 c372a47ee501
equal deleted inserted replaced
10:f48202d2c4a0 11:48ec3ee16cd8
    58         }
    58         }
    59         when ("monitor") { cmd_monitor(@ARGV) }
    59         when ("monitor") { cmd_monitor(@ARGV) }
    60         when ("kill")    { cmd_kill(@ARGV) }
    60         when ("kill")    { cmd_kill(@ARGV) }
    61         default          { pod2usage() };
    61         default          { pod2usage() };
    62     }
    62     }
    63 
       
    64 }
       
    65 
       
    66 sub cmd_kill(@) {
       
    67     my ($kvm) = @_;
       
    68     pod2usage() if not defined $kvm;
       
    69     my $config = config->load_running_config(_running_config_file $kvm);
       
    70     my $pidfile = $config->get("-pidfile");
       
    71     my $pid = slurp $pidfile, { chomp => 1 };
       
    72 
       
    73     kill $KILL => $pid;
       
    74     waitpid($pid, 0);
       
    75     unlink $pidfile, _monitor_link $kvm, _running_config_file $kvm;
       
    76 
    63 
    77 }
    64 }
    78 
    65 
    79 sub cmd_start(@) {
    66 sub cmd_start(@) {
    80     my ($kvm) = @_;
    67     my ($kvm) = @_;
   181         }
   168         }
   182     };
   169     };
   183     system("stty $termio");
   170     system("stty $termio");
   184 }
   171 }
   185 
   172 
       
   173 sub cmd_kill(@) {
       
   174     my ($kvm) = @_;
       
   175     pod2usage() if not defined $kvm;
       
   176     my $config = config->load_running_config(_running_config_file $kvm);
       
   177     my $pidfile = $config->get("-pidfile");
       
   178     my $pid = slurp $pidfile, { chomp => 1 };
       
   179 
       
   180     kill $KILL => $pid;
       
   181     waitpid($pid, 0);
       
   182     unlink $pidfile, _monitor_link $kvm, _running_config_file $kvm;
       
   183 
       
   184 }
       
   185 
       
   186 
   186 {
   187 {
   187 
   188 
   188     package config;
   189     package config;
   189     use strict;
   190     use strict;
   190     use warnings;
   191     use warnings;
   285 =item B<-c>|B<--config> I<config>
   286 =item B<-c>|B<--config> I<config>
   286 
   287 
   287 Use the specified configuration instead of the one once imported.
   288 Use the specified configuration instead of the one once imported.
   288 (default: I<undef>)
   289 (default: I<undef>)
   289 
   290 
       
   291 =item B<--dev>=I<device>
       
   292 
       
   293 Pathname of the KVM device. (default: F</dev/kvm>)
       
   294 
   290 =item B<-i>|B<--import> 
   295 =item B<-i>|B<--import> 
   291 
   296 
   292 Import the specified configuration. (default: I<undef>)
   297 Import the specified configuration. (default: I<undef>)
   293 
   298 
   294 =item B<--dev>=I<device>
       
   295 
       
   296 Pathname of the KVM device. (default: /dev/kvm)
       
   297 
       
   298 =item B<-h>|B<--help>
   299 =item B<-h>|B<--help>
   299 
   300 
   300 Show a short help page.
   301 Show a short help page.
   301 
   302 
   302 =item B<-m>|B<--man>
   303 =item B<-m>|B<--man>