Merge pull request #14755 from wanyaoqi/automated-cherry-pick-of-#14753-upstream-release-3.8

Automated cherry pick of #14753: fix(region): use virtio replace ide on diskattach
This commit is contained in:
Zexi Li
2022-08-05 17:52:05 +08:00
committed by GitHub
2 changed files with 14 additions and 1 deletions
+8
View File
@@ -63,3 +63,11 @@ const (
DISK_NOT_EXIST = "not_exist"
DISK_EXIST = "exist"
)
const (
DISK_DRIVER_VIRTIO = "virtio"
DISK_DRIVER_SCSI = "scsi"
DISK_DRIVER_PVSCSI = "pvscsi"
DISK_DRIVER_IDE = "ide"
DISK_DRIVER_SATA = "sata"
)
+6 -1
View File
@@ -3279,7 +3279,12 @@ func (self *SGuest) attach2Disk(ctx context.Context, disk *SDisk, userCred mccli
// depends the last disk of this guest
existingDisks, _ := self.GetGuestDisks()
if len(existingDisks) > 0 {
driver = existingDisks[len(existingDisks)-1].Driver
prevDisk := existingDisks[len(existingDisks)-1]
if prevDisk.Driver == api.DISK_DRIVER_IDE {
driver = api.DISK_DRIVER_VIRTIO
} else {
driver = prevDisk.Driver
}
} else {
osProf := self.GetOSProfile()
driver = osProf.DiskDriver