Skip to content

Build a qcow2 image with packer #19

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

Open
marcpires opened this issue Mar 9, 2021 · 2 comments
Open

Build a qcow2 image with packer #19

marcpires opened this issue Mar 9, 2021 · 2 comments

Comments

@marcpires
Copy link

I am trying to use packer to build an image using packer. I created a custom image adding packer and other tools I need, but when I run virt-install inside the container I got the following error.

qemu-container | [Tue, 09 Mar 2021 11:44:34 virt-install 261] ERROR (cli:254) Failed to connect socket to '/var/run/libvirt/libvirt-sock': No such file or directory
qemu-container | [Tue, 09 Mar 2021 11:44:34 virt-install 261] DEBUG (cli:256) 
qemu-container | Traceback (most recent call last):
qemu-container |   File "/usr/share/virt-manager/virt-install", line 955, in <module>
qemu-container |     sys.exit(main())
qemu-container |   File "/usr/share/virt-manager/virt-install", line 937, in main
qemu-container |     conn = cli.getConnection(options.connect)
qemu-container |   File "/usr/share/virt-manager/virtinst/cli.py", line 216, in getConnection
qemu-container |     conn.open(_openauth_cb, None)
qemu-container |   File "/usr/share/virt-manager/virtinst/connection.py", line 138, in open
qemu-container |     open_flags)
qemu-container |   File "/usr/lib/python3/dist-packages/libvirt.py", line 104, in openAuth
qemu-container |     if ret is None:raise libvirtError('virConnectOpenAuth() failed')
qemu-container | libvirt.libvirtError: **Failed to connect socket to '/var/run/libvirt/libvirt-sock'**: No such file or directory
qemu-container | make: *** [Makefile:100: virt-install] Error 1

Adding a volume to my '/var/run/libvirt/libvirt-sock' it works, but as I plan to use this in a CI, it would require my agent to have QEMU/KVM installed.

@tianon
Copy link
Owner

tianon commented Mar 19, 2021

Sorry, I don't know how I missed this earlier!

This sounds like you're not running libvirt inside your container, which is likely going to be necessary to use libvirt there. 😅

I'm really very unfamiliar with Packer though -- does it maybe have a direct QEMU harness instead of going through libvirt?

@MaxPeal
Copy link
Contributor

MaxPeal commented Mar 1, 2022

@marcpires have you a link to youre packer.json / packer.pkr.hcl?

@tianon yes packer use QEMU directly but also hase many other plugins that can work / or can not work.
https://www.packer.io/plugins/builders/qemu

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

No branches or pull requests

3 participants