diff --git a/builder/qemu/step_run.go b/builder/qemu/step_run.go index 5360955f4..86611e9e8 100644 --- a/builder/qemu/step_run.go +++ b/builder/qemu/step_run.go @@ -260,7 +260,7 @@ func (s *stepRun) getDeviceAndDriveArgs(config *Config, state multistep.StateBag } for i, cdPath := range cdPaths { if config.CDROMInterface == "" { - driveArgs = append(driveArgs, fmt.Sprintf("file=%s,index=%d,media=cdrom", cdPath, i)) + driveArgs = append(driveArgs, fmt.Sprintf("file=%s,media=cdrom", cdPath)) } else if config.CDROMInterface == "virtio-scsi" { driveArgs = append(driveArgs, fmt.Sprintf("file=%s,if=none,index=%d,id=cdrom%d,media=cdrom", cdPath, i, i)) deviceArgs = append(deviceArgs, "virtio-scsi-device", fmt.Sprintf("scsi-cd,drive=cdrom%d", i)) diff --git a/builder/qemu/step_run_test.go b/builder/qemu/step_run_test.go index 533b5317a..2139c8b8a 100644 --- a/builder/qemu/step_run_test.go +++ b/builder/qemu/step_run_test.go @@ -52,7 +52,7 @@ func Test_UserOverrides(t *testing.T) { }, []string{ "-display", "gtk", - "-drive", "file=/path/to/test.iso,index=0,media=cdrom", + "-drive", "file=/path/to/test.iso,media=cdrom", "-randomflag1", "127.0.0.1-1234-http/directory", "-randomflag2", "output/directory-myvm", "-device", ",netdev=user.0", @@ -66,7 +66,7 @@ func Test_UserOverrides(t *testing.T) { }, []string{ "-display", "partydisplay", - "-drive", "file=/path/to/test.iso,index=0,media=cdrom", + "-drive", "file=/path/to/test.iso,media=cdrom", "-device", ",netdev=user.0", }, "User input overrides default, rest is populated as normal", @@ -81,7 +81,7 @@ func Test_UserOverrides(t *testing.T) { "-display", "gtk", "-device", "somerandomdevice", "-device", "mynetdevice,netdev=user.0", - "-drive", "file=/path/to/test.iso,index=0,media=cdrom", + "-drive", "file=/path/to/test.iso,media=cdrom", }, "Net device gets added", }, @@ -135,7 +135,7 @@ func Test_DriveAndDeviceArgs(t *testing.T) { []string{ "-display", "gtk", "-boot", "once=d", - "-drive", "file=/path/to/test.iso,index=0,media=cdrom", + "-drive", "file=/path/to/test.iso,media=cdrom", }, "Boot value should default to once=d when diskImage isn't set", }, @@ -164,7 +164,7 @@ func Test_DriveAndDeviceArgs(t *testing.T) { "-device", "virtio-scsi-pci,id=scsi0", "-device", "scsi-hd,bus=scsi0.0,drive=drive0", "-drive", "if=none,file=path_to_output,id=drive0,cache=writeback,discard=,format=qcow2", - "-drive", "file=fake_cd_path.iso,index=0,media=cdrom", + "-drive", "file=fake_cd_path.iso,media=cdrom", }, "virtio-scsi interface, DiskImage true, extra cdrom, detectZeroes off", }, @@ -193,7 +193,7 @@ func Test_DriveAndDeviceArgs(t *testing.T) { "-device", "virtio-scsi-pci,id=scsi0", "-device", "scsi-hd,bus=scsi0.0,drive=drive0", "-drive", "if=none,file=path_to_output,id=drive0,cache=writeback,discard=,format=qcow2,detect-zeroes=on", - "-drive", "file=fake_cd_path.iso,index=0,media=cdrom", + "-drive", "file=fake_cd_path.iso,media=cdrom", }, "virtio-scsi interface, DiskImage true, extra cdrom, detectZeroes on", }, @@ -224,8 +224,8 @@ func Test_DriveAndDeviceArgs(t *testing.T) { "-device", "scsi-hd,bus=scsi0.0,drive=drive1", "-drive", "if=none,file=qemupath1,id=drive0,cache=writeback,discard=,format=qcow2", "-drive", "if=none,file=qemupath2,id=drive1,cache=writeback,discard=,format=qcow2", - "-drive", "file=/path/to/test.iso,index=0,media=cdrom", - "-drive", "file=fake_cd_path.iso,index=1,media=cdrom", + "-drive", "file=/path/to/test.iso,media=cdrom", + "-drive", "file=fake_cd_path.iso,media=cdrom", }, "virtio-scsi interface, bootable iso, cdrom", }, @@ -256,8 +256,8 @@ func Test_DriveAndDeviceArgs(t *testing.T) { "-device", "scsi-hd,bus=scsi0.0,drive=drive1", "-drive", "if=none,file=qemupath1,id=drive0,cache=writeback,discard=,format=qcow2,detect-zeroes=on", "-drive", "if=none,file=qemupath2,id=drive1,cache=writeback,discard=,format=qcow2,detect-zeroes=on", - "-drive", "file=/path/to/test.iso,index=0,media=cdrom", - "-drive", "file=fake_cd_path.iso,index=1,media=cdrom", + "-drive", "file=/path/to/test.iso,media=cdrom", + "-drive", "file=fake_cd_path.iso,media=cdrom", }, "virtio-scsi interface, DiskImage false, extra cdrom, detect zeroes on", }, @@ -284,7 +284,7 @@ func Test_DriveAndDeviceArgs(t *testing.T) { "-device", "virtio-scsi-pci,id=scsi0", "-device", "scsi-hd,bus=scsi0.0,drive=drive0", "-drive", "if=none,file=output/dir/path/mydisk.qcow2,id=drive0,cache=writeback,discard=,format=qcow2,detect-zeroes=", - "-drive", "file=/path/to/test.iso,index=0,media=cdrom", + "-drive", "file=/path/to/test.iso,media=cdrom", }, "virtio-scsi interface, DiskImage false, no extra disks or cds", }, @@ -302,8 +302,8 @@ func Test_DriveAndDeviceArgs(t *testing.T) { "-display", "gtk", "-boot", "once=d", "-drive", "file=output/dir/path/mydisk.qcow2,if=,cache=,discard=,format=,detect-zeroes=", - "-drive", "file=/path/to/test.iso,index=0,media=cdrom", - "-drive", "file=fake_cd_path.iso,index=1,media=cdrom", + "-drive", "file=/path/to/test.iso,media=cdrom", + "-drive", "file=fake_cd_path.iso,media=cdrom", }, "cd_path is set and DiskImage is false", }, @@ -322,7 +322,7 @@ func Test_DriveAndDeviceArgs(t *testing.T) { "-display", "gtk", "-boot", "once=d", "-drive", "file=output/dir/path/mydisk.qcow2,if=,cache=,discard=,format=,detect-zeroes=", - "-drive", "file=/path/to/test.iso,index=0,media=cdrom", + "-drive", "file=/path/to/test.iso,media=cdrom", }, "empty config", }, @@ -345,7 +345,7 @@ func Test_DriveAndDeviceArgs(t *testing.T) { []string{ "-boot", "once=d", "-drive", "file=path_to_output,if=virtio,cache=writeback,format=qcow2", - "-drive", "file=/path/to/test.iso,index=0,media=cdrom", + "-drive", "file=/path/to/test.iso,media=cdrom", }, "version less than 2", }, @@ -369,8 +369,8 @@ func Test_DriveAndDeviceArgs(t *testing.T) { "-boot", "once=d", "-drive", "file=qemupath1,if=virtio,cache=writeback,discard=,format=qcow2,detect-zeroes=", "-drive", "file=qemupath2,if=virtio,cache=writeback,discard=,format=qcow2,detect-zeroes=", - "-drive", "file=fake_cd_path.iso,index=1,media=cdrom", - "-drive", "file=/path/to/test.iso,index=0,media=cdrom", + "-drive", "file=fake_cd_path.iso,media=cdrom", + "-drive", "file=/path/to/test.iso,media=cdrom", }, "virtio interface with extra disks", }, @@ -395,7 +395,7 @@ func Test_DriveAndDeviceArgs(t *testing.T) { "-display", "gtk", "-boot", "c", "-drive", "file=path_to_output,if=virtio,cache=writeback,discard=,format=qcow2,detect-zeroes=", - "-drive", "file=fake_cd_path.iso,index=0,media=cdrom", + "-drive", "file=fake_cd_path.iso,media=cdrom", }, "virtio interface with disk image", }, @@ -456,7 +456,7 @@ func Test_OptionalConfigOptionsGetSet(t *testing.T) { "-vnc", ":5,password", "-machine", "type=pc,accel=hvf", "-device", ",netdev=user.0", - "-drive", "file=/path/to/test.iso,index=0,media=cdrom", + "-drive", "file=/path/to/test.iso,media=cdrom", "-qmp", "unix:qmp_path,server,nowait", }