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

[#71] first steps to check duplicated slots

parent 0f83af9b
......@@ -440,8 +440,14 @@ sub _domain_create_from_base {
_xml_modify_video($xml);
$self->_xml_modify_usb($xml);
$self->_fix_slots();
open my $out,'>',"/var/tmp/$args{name}.xml" or die $!;
print $out $xml->toString();
close $out;
my $dom = $self->vm->define_domain($xml->toString());
$dom->create;
$dom->create();
my $domain = Ravada::Domain::KVM->new(domain => $dom , storage => $self->storage_pool
, _vm => $self);
......@@ -697,10 +703,29 @@ sub _xml_modify_network {
}
}
sub _fix_slots {
my $self = shift;
my $doc = shift;
my %slot;
for my $item ($doc->findnodes('/domain/devices/*')) {
for my $node ($item->childNodes()) {
next if $node->nodeName ne 'address';
my $slot = $node->getAttribute('slot');
my $function = $node->getAttribute('slot');
if ($slot{$slot}->{$function}) {
die "Conflict of slot";
}
}
}
return %slot;
}
sub _xml_modify_usb {
my $self = shift;
my $doc = shift;
for my $ctrl ($doc->findnodes('/domain/devices/controller')) {
next if $ctrl->getAttribute('type') ne 'usb';
$ctrl->setAttribute(model => 'ich9-ehci1');
......@@ -735,6 +760,7 @@ sub _xml_add_usb_redirect {
sub _xml_add_usb_uhci1 {
my $self = shift;
my $devices = shift;
# USB uhci1
my $controller = $devices->addNewChild(undef,"controller");
$controller->setAttribute(type => 'usb');
......
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