Packer: Not possible to *add* custom qemu '-device'

Created on 24 Oct 2018  ยท  6Comments  ยท  Source: hashicorp/packer

Not possible to pass custom qemu '-device' args

packer version
Packer v1.3.1
  • Host platform
uname -a ; dpkg -l |grep qemu
Linux s1 -87-generic #110-Ubuntu SMP Tue Jul 18 12:55:35 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
ii  ipxe-qemu                          1.0.0+git-20150424.a25a16d-1ubuntu1.2      all          PXE boot firmware - ROM images for qemu
ii  qemu-block-extra:amd64             1:2.5+dfsg-5ubuntu10.16                    amd64        extra block backend modules for qemu-system and qemu-utils
ii  qemu-kvm                           1:2.5+dfsg-5ubuntu10.16                    amd64        QEMU Full virtualization
ii  qemu-system-common                 1:2.5+dfsg-5ubuntu10.16                    amd64        QEMU full system emulation binaries (common files)
ii  qemu-system-x86                    1:2.5+dfsg-5ubuntu10.16                    amd64        QEMU full system emulation binaries (x86)
ii  qemu-utils                         1:2.5+dfsg-5ubuntu10.16                    amd64        QEMU utilities

template.json:

...
    {                                                                           
      "type": "qemu",                                                           
      "qemuargs": [                                                             
        [                                                                       
          "-m",                                                                 
          "8096M"                                                               
        ],                                                                      
        [                                                                       
          "-fda",                                                               
          "config-drive/cloudata.iso"                                           
        ],                                                                      
        [                                                                       
          "-smp",                                                               
          "4"                                                                   
        ],                                                                      
        ["-object","rng-random,id=objrng0,filename=/dev/urandom"],              
        ["-device", "virtio-rng-pci,rng=objrng0,id=rng0,bus=pci.0,addr=0x10" ]  
      ],  
...

From debug log:

# W\o device section
Executing /usr/bin/qemu-system-x86_64: []string{"-name", "mcp-offline-mirror-2018-10-24-13-22-19-201810241122", "-netdev", "user,id=user.0,hostfwd=tcp::7021-:22", "-boot", "c", "-vnc", "0.0.0.0:56", "-machine", "type=pc,accel=kvm", "-device", "virtio-net,netdev=user.0", "-drive", "file=images/mcp-offline-mirror-2018-10-24-13-22-19-qemu-201810241122/mcp-offline-mirror-2018-10-24-13-22-19-201810241122,if=virtio,cache=writeback,discard=ignore,format=qcow2", "-m", "8096M", "-fda", "config-drive/cloudata.iso", "-smp", "4"}

# With device section
Executing /usr/bin/qemu-system-x86_64: []string{"-name", "mcp-offline-mirror-2018-10-24-13-23-42-201810241123", "-fda", "config-drive/cloudata.iso", "-object", "rng-random,id=objrng0,filename=/dev/urandom", "-machine", "type=pc,accel=kvm", "-netdev", "user,id=user.0,hostfwd=tcp::7003-:22", "-boot", "c", "-vnc", "0.0.0.0:56", "-m", "8096M", "-smp", "4", "-device", "virtio-rng-pci,rng=objrng0,id=rng0,bus=pci.0,addr=0x10", "-drive", "file=images/mcp-offline-mirror-2018-10-24-13-23-42-qemu-201810241123/mcp-offline-mirror-2018-10-24-13-23-42-201810241123,if=virtio,cache=writeback,discard=ignore,format=qcow2"}

looks like packer exactly overwrite default one:
"-device", "virtio-net,netdev=user.0"
with passed
"-device", "virtio-rng-pci,rng=objrng0,id=rng0,bus=pci.0,addr=0x10"

bug buildeqemu

Most helpful comment

Ah...just saw attachments,
yup, in attached version of packer - issue fixed.
Thanks!

All 6 comments

Hi! I believe this should be closed by a recent PR, #6807 -- this will be going out with the v. 1.3.2 release that should be happening this week or next, but if you want to test it out, here's a linux build of the current master branch, which contains this patch:

packer.zip

I'll keep this issue open until you can confirm whether your issue is solved.

I just quickly w\a it with manual passing both 'devices'.
Would check those with new release, and post result.
Thanks for quick response!

Ah...just saw attachments,
yup, in attached version of packer - issue fixed.
Thanks!

I'm still having issues with this on packer linux 1.3.2. I'm using
"disk_interface": "virtio-scsi",

A full functioning qemu string looks like this for me.
Executing /usr/local/bin/qemu-system-x86_64: []string{"-m", "6144", "-usbdevice", "tablet", "-fda", "/tmp/packer651374824", "-cdrom", "/files/packer-itcloud/ISO/en_windows_7_enterprise_with_sp1_x64_dvd_620201.iso", "-vnc", "127.0.0.1:10", "-machine", "type=pc,accel=kvm", "-device", "virtio-scsi-pci,id=scsi0", "-device", "scsi-hd,bus=scsi0.0,drive=drive0", "-device", "virtio-net,netdev=user.0", "-drive", "if=none,file=VM/Win7-qemu/Win7.qcow2,id=drive0,cache=unsafe,discard=ignore,format=qcow2", "-name", "Win7.qcow2", "-netdev", "user,id=user.0,hostfwd=tcp::3889-:5985", "-boot", "once=d"}

Seems like the -device arguments for scsi disks still get wiped even after this code change.

I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings