1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
#!/usr/bin/perl
use Sys::Virt;
my $uri = shift @ARGV;
my $c = Sys::Virt->new(uri => $uri);
my $d = $c->get_domain_by_name("vm1");
unless ($d->is_active()) {
$d->create;
}
my $mask = $d->get_emulator_pin_info;
@bits = split(//, unpack("b*", $mask));
print join(":", @bits), "\n";
if ($bits[0] == '1' && $bits[1] == '1') {
@bits[0] = 0;
my $newmask = '';
for(my $i = 0 ; $i <= $#bits ; $i++) {
vec($newmask, $i, 1) = $bits[$i];
}
@bits = split(//, unpack("b*", $newmask));
print join(":", @bits), "\n";
$d->pin_emulator($newmask);
$newermask = $d->get_emulator_pin_info;
@bits = split(//, unpack("b*", $newermask));
print join(":", @bits), "\n";
$d->pin_emulator($mask);
$newermask = $d->get_emulator_pin_info;
@bits = split(//, unpack("b*", $newermask));
print join(":", @bits), "\n";
}
|