Skip to content

Commit

Permalink
B #5705: Allow multiple sd SATA disks on q35 VMs
Browse files Browse the repository at this point in the history
If needed, q35 VMs will create a new SATA controller to allow more than
a sd[a-z] SATA disk to be attached to a VM
  • Loading branch information
brodriguez-opennebula committed Nov 1, 2023
1 parent c461d30 commit cdd80b6
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/vmm/LibVirtDriverKVM.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,8 @@ int LibVirtDriver::deployment_description_kvm(
// ------------------------------------------------------------------------
// Disks
// ------------------------------------------------------------------------
bool need_sata_controller = 0;

get_attribute(nullptr, host, cluster, "DISK", "DRIVER", default_driver);

if (default_driver.empty())
Expand Down Expand Up @@ -1570,12 +1572,27 @@ int LibVirtDriver::deployment_description_kvm(

if ( target_number >= 0 && target_number < 256 )
{
file << "\t\t\t<address type='drive' controller='0' bus='0' " <<
"target='" << target_number << "' unit='0'/>" << endl;
if ( sd_bus.compare((std::string)("sata")) == 0 )
{
need_sata_controller = machine.find("q35");
if (need_sata_controller)
file << "\t\t\t<address type='drive' controller='1' bus='0' " <<
"target='0' unit='" << target_number << "'/>" << endl;
else
file << "\t\t\t<address type='drive' controller='0' bus='0' " <<
"target='" << target_number << "' unit='0'/>" << endl;
}

else
{
file << "\t\t\t<address type='drive' controller='0' bus='0' " <<
"target='" << target_number << "' unit='0'/>" << endl;
}
}
}

file << "\t\t</disk>" << endl;

}

// ------------------------------------------------------------------------
Expand Down Expand Up @@ -1669,6 +1686,9 @@ int LibVirtDriver::deployment_description_kvm(
file << "/>" << endl
<< "\t\t</controller>" << endl;

if (need_sata_controller)
file << "\t\t<controller type='sata' index='1'/>" << endl;

// ------------------------------------------------------------------------
// Network interfaces
// ------------------------------------------------------------------------
Expand Down

0 comments on commit cdd80b6

Please sign in to comment.