Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow both cdrom & disk to use the virtio interface #136

Open
leifliddy opened this issue Apr 21, 2023 · 2 comments
Open

Allow both cdrom & disk to use the virtio interface #136

leifliddy opened this issue Apr 21, 2023 · 2 comments

Comments

@leifliddy
Copy link

leifliddy commented Apr 21, 2023

I'm running into this exact same issue with qemu-system-aarch64 (running on a macbook m2)
except it's with the virtio interface.

#35

source "qemu" "vagrant" {
  headless            = true
  cpu_model           = "host"
  memory              = 2048
  cpus                = 4  
  disk_size           = 210000 
  net_device          = "virtio-net"
  disk_interface      = "virtio"
  cdrom_interface     = "virtio"
  format              = "qcow2"
  accelerator         = "hvf"
  machine_type        = "virt"
  qemu_binary         = "qemu-system-aarch64"
  iso_url             = "${var.iso_path}"
...
}

The issue is two fold.

  1. I can only use the virtio interface for both the hdd + cdrom on this system. So I can't use virtio-scsi, sata, ide....etc
unsupported bus type 'virtio-scsi'

So I can't utilize this "fix" hashicorp/packer#10211 (comment)
As that comment shows, people were experiencing this exact issue years ago.

  1. There's a device conflict:
    The error I'm getting is
qemu-system-aarch64: -drive file=boot.iso,if=virtio,id=cdrom0,media=cdrom,index=0: drive with bus=0, unit=0 (index=0) exists](qemu-system-aarch64: -drive file=boot.iso,if=virtio,index=0,id=cdrom0,media=cdrom: drive with bus=0, unit=0 (index=0) exists)

Normally when I'm running qemu manually on my system, I use the following argument

-cdrom boot.iso 

and that works fine. But packer seems very opinionated in this area and forces the use of the -drive argument
I would like to request one of the following two features.

  1. Allow both cdrom & disk to use the virtio interfaces.
    The same logic already exists here for the virtio-scsi interface:
    221d5f9

  2. Create an additional iso_manual_args option (or something like that) that would be mutually exclusive with iso_url(s)
    So that users could simply manually specify the cdrom args themselves.
    Currently packer enforces the use of iso_url

One of iso_url or iso_urls must be specified
@leifliddy leifliddy changed the title Allow both cdrom & disk to use virtio Allow both cdrom & disk to use the virtio interface Apr 21, 2023
@leifliddy
Copy link
Author

I was able to workaround this issue with the following

  qemuargs = [  
    ["-drive", "file=${var.iso_path},if=virtio,index=1,id=cdrom0,media=cdrom"],
    ["-boot", "d"]
  ]    

But it still would be nice to have a proper fix for it. Not sure why that aforementioned fix was only made for virtio-scsi and not for virtio as well.

@leifliddy
Copy link
Author

leifliddy commented Apr 22, 2023

Nevermind, that workaround doesn't register the hdd disk, so it's a pure cdrom boot.

Not sure why packer can't just specify the cdrom with the -cdrom argument as that would solve most of my problems.

But....there's one more thing that would need to be sorted out after that.
Ok, let's say I have the following

   -drive file=disk.qcow2,format=qcow2,if=virtio,cache=writethrough \
   -cdrom boot.iso \

So if I try -boot once=c or -boot once=d
I'm greeted with this

qemu-system-aarch64: no function defined to set boot device list for this architecture

However, just specifying -boot c or boot d work as expected.
I think this might be a difference between qemu-system-x86_64 and qemu-system-aarch64

qemu is so complicated -- honestly I have no idea how you guys deal with this stuff. Differences in versions, platforms, and binaries....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant