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

Fix/qemuagent #873

Closed
wants to merge 2 commits into from
Closed

Fix/qemuagent #873

wants to merge 2 commits into from

Conversation

maseman
Copy link
Contributor

@maseman maseman commented Aug 13, 2021

Reimplements qemu-guest-agent interface query using go-libvirt interface.

Needed to query dhcp allocated IPs on bridged networks.

Testcase

I wanted to produce a decent reproducible test case so I generated an VM image (using alpine scripts) that runs qemu-guest-agent and configures a static IP that can be queried. See TestAccLibvirtDomain_NetworkInterfaceQemuGuestAgentStaticIP.

The VM test image in https://github.com/maseman/testvm-tflibvirt is generated with a workflow as a release asset. At ~100MB I thought it best NOT to add the file to terraform-provider-libvirt /testdata and instead setup a download in the testcase.

Alpine VMs like this (and with small overlay configurations) might be useful for other more complex test scenarios in the future.

See TestAccLibvirtDomain_NetworkInterfaceQemuGuestAgentStaticIP

Testcase requires download of external vm image generated
from GitHub workflow.
Uses libvirt.DomainInterfaceAddressesSrcAgent in call to

virConn.DomainInterfaceAddresses
@mmolnar mmolnar mentioned this pull request Sep 16, 2021
@remoe
Copy link
Contributor

remoe commented Oct 10, 2021

I have created a test version with this fix: https://github.com/remoe/terraform-provider-libvirt/releases/tag/untagged-fb1e891272fa09d2d159

It works on my side.

ATTENTION: this not an official version. Use it only for testing.


interfaces, err = virConn.DomainInterfaceAddresses(domain, uint32(libvirt.DomainInterfaceAddressesSrcLease), 0)
var interfaces []libvirt.DomainInterface
interfaces, err = virConn.DomainInterfaceAddresses(domain, addrsrc, 0)
if err != nil {
switch err.(type) {
default:
return interfaces, fmt.Errorf("Error retrieving interface addresses: %s", err)
case libvirt.Error:
virErr := err.(libvirt.Error)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove this cast here as it is not needed in this switch type.

@remoe
Copy link
Contributor

remoe commented Nov 16, 2021

Can anyone merge this with the above changes for next release?

@dmacvicar
Copy link
Owner

I have manually rebased and committed this.

I don't like the 120M image for the test, so the test is pending and I opened #913 to revisit it.

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

Successfully merging this pull request may close these issues.

3 participants