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