Giter Club home page Giter Club logo

Comments (5)

a2geek avatar a2geek commented on July 3, 2024 4

Hmm. Going with your suggestion, I "widened" the net... I tried setting command, section, and flags to 4. Flags wouldn't allow it (actually gave me a flags related error).

But...

	cmd := uint32(4)
	section := uint32(4)
	fmt.Printf("NetworkUpdate(%d, %d, -1, %s, %d)\n", cmd, section, networkDhcpXML, 0)
	err = client.NetworkUpdate(net, cmd, section, -1, networkDhcpXML, 0)

Gave me:

NetworkUpdate(4, 4, -1, <host name='vm-8029d8c8-ee6c-45b9-6476-3ba7381c3cb5' ip='192.168.123.7'/>, 0)
Setup network DHCP

... and as proof:

$ virsh net-dumpxml default
<network>
  <name>default</name>
  <uuid>bcb85dc8-ad27-4861-9f85-692167fd79fa</uuid>
  <forward mode='nat'>
    <nat>
      <port start='1024' end='65535'/>
    </nat>
  </forward>
  <bridge name='virbr0' stp='on' delay='0'/>
  <mac address='52:54:00:82:d1:6e'/>
  <ip address='192.168.123.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.123.2' end='192.168.123.254'/>
      <host name='vm-8029d8c8-ee6c-45b9-6476-3ba7381c3cb5' ip='192.168.123.7'/>
      <host name='totally-fake-vm' ip='192.168.123.6'/>
    </dhcp>
  </ip>
</network>

... and running it again errors out (as expected):

NetworkUpdate(4, 4, -1, <host name='vm-8029d8c8-ee6c-45b9-6476-3ba7381c3cb5' ip='192.168.123.7'/>, 0)
panic: Requested operation is not valid: there is an existing dhcp host entry in network 'default' that matches "<host mac='unknown' name='vm-8029d8c8-ee6c-45b9-6476-3ba7381c3cb5' ip='192.168.123.7'/>"

Is something cross-wired somewhere? Even in my code? Sadly, I'm not spotting anything. (But also admitting I'm a Go rookie, haven't touched C in 30 years, and utter neophyte with Libvirt! LOL)

from go-libvirt.

karlskewes avatar karlskewes commented on July 3, 2024 1

Thank you so much for posting this issue. We've just run into it with the terraform libvirt provider.

Seems there has been work going on upstream to improve a situation where command and section argument ordering is swapped around.

See:

from go-libvirt.

trapgate avatar trapgate commented on July 3, 2024

The error you're getting seems to be coming from virNetworkDefUpdateIP in the libvirt sources. But that's not the right routine - you're trying to update the DHCP host settings, which is section "ip/dhcp/host", and is handled by virNetworkDefUpdateIPDHCPHost. You'd get this error if the section parameter passed into the NetworkUpdate call were wrong (3 instead of 4), but libvirt.NetworkSectionIpDhcpHost and NETWORK_SECTION_IP_DHCP_HOST are both 4, in the sources I'm looking at. (libvirt 4.0.0). It might be interesting to try some other values for the section parameter, and see if you get back sensible errors.

from go-libvirt.

a2geek avatar a2geek commented on July 3, 2024

I get the same response regardless of values (tried 1, 2, 3, 4, 5, and 500):

NetworkUpdate(3, 500, -1, <host name='vm-8029d8c8-ee6c-45b9-6476-3ba7381c3cb5' ip='192.168.123.7'/>, 0)
panic: Operation not supported: can't update 'ip' section of network 'default'

I am using Go 1.12 and modules. go.mod is:

$ cat go.mod
module ip-dhcp-host

go 1.12

require github.com/digitalocean/go-libvirt v0.0.0-20190715144809-7b622097a793

Just in case there's a specific version or something.

from go-libvirt.

cfergeau avatar cfergeau commented on July 3, 2024

My take on this is cfergeau@8108763

from go-libvirt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.