Commit d21701f8 authored by Francesc Guasch's avatar Francesc Guasch
Browse files

fix: USB drives in KVM

parent 51a1999f
......@@ -355,7 +355,9 @@ sub _around_start($orig, $self, @arg) {
last if !$error;
warn "WARNING: $error ".$self->_vm->name." ".$self->_vm->enabled if $error;
next if $error && ref($error) && $error->code == 1;# pool has asynchronous jobs running.
;# pool has asynchronous jobs running.
next if $error && ref($error) && $error->code == 1
&& $error !~ /internal error.*unexpected address/;
if ($error && $self->id_base && !$self->is_local && $self->_vm->enabled) {
$self->_request_set_base();
......
......@@ -2522,7 +2522,6 @@ sub _change_hardware_disk_bus($self, $index, $bus) {
return if $target->getAttribute('bus') eq $bus;
$target->setAttribute(bus => $bus);
$self->_change_xml_address($doc, $address, $bus);
}
confess "Error: disk $index not found in ".$self->name if !$changed;
......@@ -2624,6 +2623,25 @@ sub _change_hardware_network($self, $index, $data) {
sub reload_config($self, $doc) {
my $in = $doc->toString();
my ($out, $err);
run3(["virt-xml-validate","-"],\$in,\$out,\$err);
if ($? ){
warn $out if $out;
my $file_out = "/var/tmp/".$self->name().".xml";
open my $out1,">",$file_out or die $!;
print $out1 $self->xml_description();
close $out1;
open my $out2,">","/var/tmp/".$self->name().".new.xml" or die $!;
my $doc_string = $doc->toString();
$doc_string =~ s/^<.xml.*//;
$doc_string =~ s/"/'/g;
print $out2 $doc_string;
close $out2;
confess "\$?=$? $err\ncheck $file_out" if $?;
}
my $new_domain = $self->_vm->vm->define_domain($doc->toString);
$self->domain($new_domain);
}
......@@ -2660,12 +2678,21 @@ sub _change_xml_address_usb($self, $address) {
for (keys %attribute) {
$address->setAttribute($_ => $attribute{$_});
}
for (qw(controller unit target domain slot function)) {
$address->removeAttribute($_);
}
=pod
$address->setAttribute(unit => $self->_new_address_xml(
match => 'usb'
,attribute => 'port'
)
);
=cut
}
sub _change_xml_address_ide($self, $doc, $address, $max_bus=2, $max_unit=9) {
......
......@@ -76,7 +76,7 @@ sub test_drivers_id {
);
rvd_back->_process_requests_dont_fork();
is($req->status,'done') or next;
is($req->error,'') or next;
is($req->error,'') or exit;
ok(!$@,"Expecting no error, got : ".($@ or ''));
my $value = $domain->get_driver($type);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment