mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-22 13:33:52 +03:00
B #5705: Fix SATA disk layout
This commit adds a SATA controller for each disk using the SATA bus. The
q35 machine adds ACHI controller in slot 0x1f function 2 (used for
context), in this case controller index starts from 1.
This should fix VMs using SD_DISK_BUS = sata or q35 machines with more
than one SATA disk.
(cherry picked from commit 67247af9fb
)
This commit is contained in:
parent
53b0d9970c
commit
592a2a64f5
@ -1088,6 +1088,14 @@ int LibVirtDriver::deployment_description_kvm(
|
||||
|
||||
num = vm->get_template_attribute("DISK", disk);
|
||||
|
||||
int sata_index = 0;
|
||||
string sata_controllers;
|
||||
|
||||
if (machine.find("q35") != std::string::npos)
|
||||
{
|
||||
sata_index = 1;
|
||||
}
|
||||
|
||||
for (int i=0; i < num ;i++)
|
||||
{
|
||||
type = disk[i]->vector_value("TYPE");
|
||||
@ -1562,22 +1570,44 @@ int LibVirtDriver::deployment_description_kvm(
|
||||
file << "\t\t\t</iotune>" << endl;
|
||||
}
|
||||
|
||||
// ---- SCSI target ----
|
||||
|
||||
// ---- Disk target ----
|
||||
// * SATA bus
|
||||
// - requires a controller per disk as it requires bus=0 and target=0
|
||||
// - q35 adds ACHI controller in slot 0x1f function 2 (used for context)
|
||||
// - A controller will be added for each disk starting from 1 if q35
|
||||
// * SCSI bus
|
||||
// - target is based on dev target to have a predictable order
|
||||
if ( target[0] == 's' && target[1] == 'd' )
|
||||
{
|
||||
int target_number = target[2] - 'a';
|
||||
|
||||
if ( target_number >= 0 && target_number < 256 )
|
||||
if ( disk_bus == "sata" )
|
||||
{
|
||||
file << "\t\t\t<address type='drive' controller='0' bus='0' " <<
|
||||
"target='" << target_number << "' unit='0'/>" << endl;
|
||||
sata_controllers += ("\t\t<controller type='sata' index='" +
|
||||
to_string(sata_index) + "'/>\n");
|
||||
|
||||
file << "\t\t\t<address type='drive' controller='" << sata_index
|
||||
<< "' bus='0' target='0' unit='0'/>" << endl;
|
||||
|
||||
sata_index++;
|
||||
}
|
||||
else if ( target_number >= 0 && target_number < 256 )
|
||||
{
|
||||
file << "\t\t\t<address type='drive' controller='0' bus='0'"
|
||||
<< " target='" << target_number << "' unit='0'/>"
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
file << "\t\t</disk>" << endl;
|
||||
}
|
||||
|
||||
// Add SATA controllers if needed
|
||||
if (!sata_controllers.empty())
|
||||
{
|
||||
file << sata_controllers;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Context Device
|
||||
// ------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user