Skip to content

Commit

Permalink
core: drop floppy disks from the API
Browse files Browse the repository at this point in the history
We have been rejecting floppy disks since v0.16.0 with:
 > 627216d "Reject floppy disks" in 2019-03-29

The original request is: kubevirt#2016

It should be fine to remove this from the API.

Signed-off-by: Victor Toso <[email protected]>
  • Loading branch information
victortoso committed Feb 17, 2022
1 parent 3d8e2c1 commit 205a38f
Show file tree
Hide file tree
Showing 10 changed files with 5 additions and 199 deletions.
1 change: 0 additions & 1 deletion api/api-rule-violations-known.list
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ API rule violation: names_match,kubevirt.io/api/core/v1,FeatureHyperv,VPIndex
API rule violation: names_match,kubevirt.io/api/core/v1,FeatureHyperv,VendorID
API rule violation: names_match,kubevirt.io/api/core/v1,FeatureSpinlocks,Retries
API rule violation: names_match,kubevirt.io/api/core/v1,FeatureVendorID,VendorID
API rule violation: names_match,kubevirt.io/api/core/v1,FloppyTarget,ReadOnly
API rule violation: names_match,kubevirt.io/api/core/v1,HPETTimer,Enabled
API rule violation: names_match,kubevirt.io/api/core/v1,HypervTimer,Enabled
API rule violation: names_match,kubevirt.io/api/core/v1,KVMTimer,Enabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2182,15 +2182,6 @@ func validateDisks(field *k8sfield.Path, disks []v1.Disk) []metav1.StatusCause {
})
}

// Reject Floppy disks
if disk.Floppy != nil {
causes = append(causes, metav1.StatusCause{
Type: metav1.CauseTypeFieldValueNotSupported,
Message: "Floppy disks are deprecated and will be removed from the API soon.",
Field: field.Index(idx).Child("name").String(),
})
}

// Verify only a single device type is set.
deviceTargetSetCount := 0
var diskType, bus string
Expand All @@ -2204,9 +2195,6 @@ func validateDisks(field *k8sfield.Path, disks []v1.Disk) []metav1.StatusCause {
diskType = "lun"
bus = disk.LUN.Bus
}
if disk.Floppy != nil {
deviceTargetSetCount++
}
if disk.CDRom != nil {
deviceTargetSetCount++
diskType = "cdrom"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2672,20 +2672,6 @@ var _ = Describe("Validating VMICreate Admitter", func() {
),
)

It("should reject floppy disks", func() {
vmi := api.NewMinimalVMI("testvmi")

vmi.Spec.Domain.Devices.Disks = append(vmi.Spec.Domain.Devices.Disks, v1.Disk{
Name: "floppydisk",
DiskDevice: v1.DiskDevice{
Floppy: &v1.FloppyTarget{},
},
})
causes := validateDisks(k8sfield.NewPath("fake"), vmi.Spec.Domain.Devices.Disks)
Expect(len(causes)).To(Equal(1))
Expect(causes[0].Field).To(Equal("fake[0].name"))
})

It("should allow disk without a target", func() {
vmi := api.NewMinimalVMI("testvmi")

Expand Down
6 changes: 0 additions & 6 deletions pkg/virt-launcher/virtwrap/converter/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,6 @@ func Convert_v1_Disk_To_api_Disk(c *ConverterContext, diskDevice *v1.Disk, disk
disk.Target.Bus = diskDevice.LUN.Bus
disk.Target.Device, _ = makeDeviceName(diskDevice.Name, diskDevice.LUN.Bus, prefixMap)
disk.ReadOnly = toApiReadOnly(diskDevice.LUN.ReadOnly)
} else if diskDevice.Floppy != nil {
disk.Device = "floppy"
disk.Target.Bus = "fdc"
disk.Target.Tray = string(diskDevice.Floppy.Tray)
disk.Target.Device, _ = makeDeviceName(diskDevice.Name, disk.Target.Bus, prefixMap)
disk.ReadOnly = toApiReadOnly(diskDevice.Floppy.ReadOnly)
} else if diskDevice.CDRom != nil {
disk.Device = "cdrom"
disk.Target.Tray = string(diskDevice.CDRom.Tray)
Expand Down
87 changes: 0 additions & 87 deletions pkg/virt-launcher/virtwrap/converter/converter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,21 +365,6 @@ var _ = Describe("Converter", func() {
},
},
},
{
Name: "floppy_tray_unspecified",
DiskDevice: v1.DiskDevice{
Floppy: &v1.FloppyTarget{},
},
},
{
Name: "floppy_tray_open",
DiskDevice: v1.DiskDevice{
Floppy: &v1.FloppyTarget{
Tray: v1.TrayStateOpen,
ReadOnly: true,
},
},
},
{
Name: "should_default_to_disk",
},
Expand Down Expand Up @@ -464,26 +449,6 @@ var _ = Describe("Converter", func() {
},
},
},
{
Name: "floppy_tray_unspecified",
VolumeSource: v1.VolumeSource{
HostDisk: &v1.HostDisk{
Path: "/var/run/kubevirt-private/vmi-disks/volume2/disk.img",
Type: v1.HostDiskExistsOrCreate,
Capacity: resource.MustParse("1Gi"),
},
},
},
{
Name: "floppy_tray_open",
VolumeSource: v1.VolumeSource{
HostDisk: &v1.HostDisk{
Path: "/var/run/kubevirt-private/vmi-disks/volume3/disk.img",
Type: v1.HostDiskExistsOrCreate,
Capacity: resource.MustParse("1Gi"),
},
},
},
{
Name: "should_default_to_disk",
VolumeSource: v1.VolumeSource{
Expand Down Expand Up @@ -647,19 +612,6 @@ var _ = Describe("Converter", func() {
<readonly></readonly>
<alias name="ua-cdrom_tray_open"></alias>
</disk>
<disk device="floppy" type="file">
<source file="/var/run/kubevirt-private/vmi-disks/floppy_tray_unspecified/disk.img"></source>
<target bus="fdc" dev="fda" tray="closed"></target>
<driver error_policy="stop" name="qemu" type="raw" iothread="1"></driver>
<alias name="ua-floppy_tray_unspecified"></alias>
</disk>
<disk device="floppy" type="file">
<source file="/var/run/kubevirt-private/vmi-disks/floppy_tray_open/disk.img"></source>
<target bus="fdc" dev="fdb" tray="open"></target>
<driver error_policy="stop" name="qemu" type="raw" iothread="1"></driver>
<readonly></readonly>
<alias name="ua-floppy_tray_open"></alias>
</disk>
<disk device="disk" type="file">
<source file="/var/run/kubevirt-private/vmi-disks/should_default_to_disk/disk.img"></source>
<target bus="sata" dev="sdc"></target>
Expand Down Expand Up @@ -862,19 +814,6 @@ var _ = Describe("Converter", func() {
<readonly></readonly>
<alias name="ua-cdrom_tray_open"></alias>
</disk>
<disk device="floppy" type="file">
<source file="/var/run/kubevirt-private/vmi-disks/floppy_tray_unspecified/disk.img"></source>
<target bus="fdc" dev="fda" tray="closed"></target>
<driver error_policy="stop" name="qemu" type="raw" iothread="1"></driver>
<alias name="ua-floppy_tray_unspecified"></alias>
</disk>
<disk device="floppy" type="file">
<source file="/var/run/kubevirt-private/vmi-disks/floppy_tray_open/disk.img"></source>
<target bus="fdc" dev="fdb" tray="open"></target>
<driver error_policy="stop" name="qemu" type="raw" iothread="1"></driver>
<readonly></readonly>
<alias name="ua-floppy_tray_open"></alias>
</disk>
<disk device="disk" type="file">
<source file="/var/run/kubevirt-private/vmi-disks/should_default_to_disk/disk.img"></source>
<target bus="sata" dev="sdc"></target>
Expand Down Expand Up @@ -1080,19 +1019,6 @@ var _ = Describe("Converter", func() {
<readonly></readonly>
<alias name="ua-cdrom_tray_open"></alias>
</disk>
<disk device="floppy" type="file">
<source file="/var/run/kubevirt-private/vmi-disks/floppy_tray_unspecified/disk.img"></source>
<target bus="fdc" dev="fda" tray="closed"></target>
<driver error_policy="stop" name="qemu" type="raw" iothread="1"></driver>
<alias name="ua-floppy_tray_unspecified"></alias>
</disk>
<disk device="floppy" type="file">
<source file="/var/run/kubevirt-private/vmi-disks/floppy_tray_open/disk.img"></source>
<target bus="fdc" dev="fdb" tray="open"></target>
<driver error_policy="stop" name="qemu" type="raw" iothread="1"></driver>
<readonly></readonly>
<alias name="ua-floppy_tray_open"></alias>
</disk>
<disk device="disk" type="file">
<source file="/var/run/kubevirt-private/vmi-disks/should_default_to_disk/disk.img"></source>
<target bus="sata" dev="sdc"></target>
Expand Down Expand Up @@ -1307,19 +1233,6 @@ var _ = Describe("Converter", func() {
<readonly></readonly>
<alias name="ua-cdrom_tray_open"></alias>
</disk>
<disk device="floppy" type="file">
<source file="/var/run/kubevirt-private/vmi-disks/floppy_tray_unspecified/disk.img"></source>
<target bus="fdc" dev="fda" tray="closed"></target>
<driver error_policy="stop" name="qemu" type="raw" iothread="1"></driver>
<alias name="ua-floppy_tray_unspecified"></alias>
</disk>
<disk device="floppy" type="file">
<source file="/var/run/kubevirt-private/vmi-disks/floppy_tray_open/disk.img"></source>
<target bus="fdc" dev="fdb" tray="open"></target>
<driver error_policy="stop" name="qemu" type="raw" iothread="1"></driver>
<readonly></readonly>
<alias name="ua-floppy_tray_open"></alias>
</disk>
<disk device="disk" type="file">
<source file="/var/run/kubevirt-private/vmi-disks/should_default_to_disk/disk.img"></source>
<target bus="sata" dev="sdc"></target>
Expand Down
7 changes: 0 additions & 7 deletions staging/src/kubevirt.io/api/core/v1/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ func SetDefaults_FeatureVendorID(obj *FeatureVendorID) {
func SetDefaults_DiskDevice(obj *DiskDevice) {
if obj.Disk == nil &&
obj.CDRom == nil &&
obj.Floppy == nil &&
obj.LUN == nil {
obj.Disk = &DiskTarget{}
}
Expand All @@ -90,12 +89,6 @@ func SetDefaults_CDRomTarget(obj *CDRomTarget) {
}
}

func SetDefaults_FloppyTarget(obj *FloppyTarget) {
if obj.Tray == "" {
obj.Tray = TrayStateClosed
}
}

func SetDefaults_FeatureSpinlocks(obj *FeatureSpinlocks) {
if obj.Enabled == nil {
obj.Enabled = _true
Expand Down
21 changes: 4 additions & 17 deletions staging/src/kubevirt.io/api/core/v1/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ type Devices struct {
UseVirtioTransitional *bool `json:"useVirtioTransitional,omitempty"`
// DisableHotplug disabled the ability to hotplug disks.
DisableHotplug bool `json:"disableHotplug,omitempty"`
// Disks describes disks, cdroms, floppy and luns which are connected to the vmi.
// Disks describes disks, cdroms and luns which are connected to the vmi.
Disks []Disk `json:"disks,omitempty"`
// Watchdog describes a watchdog device which can be added to the vmi.
Watchdog *Watchdog `json:"watchdog,omitempty"`
Expand Down Expand Up @@ -594,8 +594,6 @@ type DiskDevice struct {
Disk *DiskTarget `json:"disk,omitempty"`
// Attach a volume as a LUN to the vmi.
LUN *LunTarget `json:"lun,omitempty"`
// Attach a volume as a floppy to the vmi.
Floppy *FloppyTarget `json:"floppy,omitempty"`
// Attach a volume as a cdrom to the vmi.
CDRom *CDRomTarget `json:"cdrom,omitempty"`
}
Expand Down Expand Up @@ -629,24 +627,13 @@ type LunTarget struct {
ReadOnly bool `json:"readonly,omitempty"`
}

type FloppyTarget struct {
// ReadOnly.
// Defaults to false.
ReadOnly bool `json:"readonly,omitempty"`
// Tray indicates if the tray of the device is open or closed.
// Allowed values are "open" and "closed".
// Defaults to closed.
// +optional
Tray TrayState `json:"tray,omitempty"`
}

// TrayState indicates if a tray of a cdrom or floppy is open or closed.
// TrayState indicates if a tray of a cdrom is open or closed.
type TrayState string

const (
// TrayStateOpen indicates that the tray of a cdrom or floppy is open.
// TrayStateOpen indicates that the tray of a cdrom is open.
TrayStateOpen TrayState = "open"
// TrayStateClosed indicates that the tray of a cdrom or floppy is closed.
// TrayStateClosed indicates that the tray of a cdrom is closed.
TrayStateClosed TrayState = "closed"
)

Expand Down
1 change: 0 additions & 1 deletion staging/src/kubevirt.io/client-go/api/deepcopy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ var _ = Describe("Generated deepcopy functions", func() {
&v1.DiskDevice{},
&v1.DiskTarget{},
&v1.LunTarget{},
&v1.FloppyTarget{},
&v1.CDRomTarget{},
&v1.Volume{},
&v1.VolumeSource{},
Expand Down
23 changes: 1 addition & 22 deletions staging/src/kubevirt.io/client-go/api/defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,21 +204,6 @@ var _ = Describe("Defaults", func() {
},
},
},
{
Name: "floppy_tray_unspecified",
DiskDevice: v1.DiskDevice{
Floppy: &v1.FloppyTarget{},
},
},
{
Name: "floppy_tray_open",
DiskDevice: v1.DiskDevice{
Floppy: &v1.FloppyTarget{
Tray: v1.TrayStateOpen,
ReadOnly: true,
},
},
},
{
Name: "should_default_to_disk",
},
Expand All @@ -236,14 +221,8 @@ var _ = Describe("Defaults", func() {
Expect(disks[1].CDRom.Tray).To(Equal(v1.TrayStateOpen), "Tray state was explicitly set to open")
Expect(*disks[1].CDRom.ReadOnly).To(BeFalse(), "ReadOnly state was explicitly set to true")
Expect(disks[1].DedicatedIOThread).To(BeNil(), "Default DedicatedIOThread state should be nil")
Expect(disks[2].Floppy.Tray).To(Equal(v1.TrayStateClosed), "Default tray state for Floppy should be closed")
Expect(disks[2].Floppy.ReadOnly).To(BeFalse(), "Default ReadOnly state for Floppy should be false")
Expect(disks[2].Disk).ToNot(BeNil(), "Default type should be Disk")
Expect(disks[2].DedicatedIOThread).To(BeNil(), "Default DedicatedIOThread state should be nil")
Expect(disks[3].Floppy.Tray).To(Equal(v1.TrayStateOpen), "TrayState was explicitly set to open")
Expect(disks[3].Floppy.ReadOnly).To(BeTrue(), "ReadOnly was explicitly set to true")
Expect(disks[3].DedicatedIOThread).To(BeNil(), "Default DedicatedIOThread state should be nil")
Expect(disks[4].Disk).ToNot(BeNil(), "Default type should be Disk")
Expect(disks[4].DedicatedIOThread).To(BeNil(), "Default DedicatedIOThread state should be nil")
})

It("should set the default watchdog and the default watchdog action", func() {
Expand Down
32 changes: 0 additions & 32 deletions staging/src/kubevirt.io/client-go/api/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,6 @@ var exampleJSONFmt = `{
"tray": "open"
}
},
{
"name": "floppy0",
"floppy": {
"readonly": true,
"tray": "open"
}
},
{
"name": "lun0",
"lun": {
Expand Down Expand Up @@ -228,12 +221,6 @@ var exampleJSONFmt = `{
"name": "testnetworksecret"
}
}
},
{
"name": "floppy0",
"persistentVolumeClaim": {
"claimName": "testclaim"
}
}
],
"networks": [
Expand Down Expand Up @@ -279,15 +266,6 @@ var _ = Describe("Schema", func() {
},
},
},
{
Name: "floppy0",
DiskDevice: v12.DiskDevice{
Floppy: &v12.FloppyTarget{
ReadOnly: true,
Tray: "open",
},
},
},
{
Name: "lun0",
DiskDevice: v12.DiskDevice{
Expand Down Expand Up @@ -342,16 +320,6 @@ var _ = Describe("Schema", func() {
},
},
},
{
Name: "floppy0",
VolumeSource: v12.VolumeSource{
PersistentVolumeClaim: &v12.PersistentVolumeClaimVolumeSource{
PersistentVolumeClaimVolumeSource: v1.PersistentVolumeClaimVolumeSource{
ClaimName: "testclaim",
},
},
},
},
}
exampleVMI.Spec.Domain.Features = &v12.Features{
ACPI: v12.FeatureState{Enabled: pointer.BoolPtr(false)},
Expand Down

0 comments on commit 205a38f

Please sign in to comment.