Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LibVirt: Initial support for virtio-scsi virtual drives (read: ssd trim) #1467

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions lib/Rex/Virtualization/LibVirt/create.pm
Original file line number Diff line number Diff line change
Expand Up @@ -329,11 +329,16 @@ sub _set_storage_defaults {
function => "0x0",
};
}
elsif ( $store->{"bus"} eq "ide" && !exists $store->{"address"} ) {
elsif (
( $store->{"bus"} =~ /\Aide|scsi\Z/msx && !exists $store->{"address"} )
)
{
# The scsi conditional for the bus works around this error during virsh define:
# error: internal error: SCSI controller only supports 1 bus
$store->{"address"} = {
type => "drive",
controller => 0,
bus => 1,
bus => $store->{"bus"} eq 'scsi' ? 0 : 1,
unit => 0,
};
}
Expand Down Expand Up @@ -444,7 +449,15 @@ __DATA__

<% for my $disk (@{$::storage}) { %>
<disk type="<%= $disk->{type} %>" device="<%= $disk->{device} %>">
<driver name="qemu" type="<%= $disk->{driver_type} %>"/>
<driver name="qemu" type="<%= $disk->{driver_type} %>"
<% if(exists $disk->{driver_cache}) { %>
cache="<%= $disk->{driver_cache} %>"
<% } %>
<% if(exists $disk->{driver_discard}) { %>
discard="<%= $disk->{driver_discard} %>"
<% } %>
/>

<% if ($disk->{type} eq "file") { %>
<source file="<%= $disk->{file} %>"/>
<% } elsif ($disk->{file} eq "block") { %>
Expand All @@ -460,6 +473,11 @@ __DATA__
<controller type="ide" index="0">
<address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x1"/>
</controller>
<% if (grep { exists($_->{bus}) && $_->{bus} =~ /scsi/ } @{$::storage}) { %>
<controller type='scsi' index='0' model='<%= $::scsi_model // 'auto' %>'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</controller>
<% } %>
<% for my $netdev (@{$::network}) { %>
<interface type="<%= $netdev->{type} %>">
<% if(exists $netdev->{mac}) { %>
Expand Down
2 changes: 1 addition & 1 deletion t/issue/948.t
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ sub Rex::Commands::File::file {
my ( $name, %params ) = @_;

my $fmt = get_image_format();
like $params{content}, qr|<driver name="qemu" type="$fmt"/>|,
like $params{content}, qr|<driver name="qemu" type="$fmt"\s*/>|,
"Found file content for $fmt format.";
$count_file++;
}
Expand Down