google / novm

Experimental KVM-based VMM for containers, written in Go.
Apache License 2.0
1.68k stars 123 forks source link

--nic instructions do not work #9

Closed pwaller closed 9 years ago

pwaller commented 9 years ago

The only instructions I could find for specifying a network device were in the output of novm run -h.

        Network definitions are provided as --nic [opt=val],...

            Available options are:

            mac=00:11:22:33:44:55 Set the MAC address.
            tap=tap1              Set the tap name.
            bridge=br0            Enslave to a bridge.
            ip=192.168.1.2/24     Set the IP address.
            gateway=192.168.1.1   Set the gateway IP.
            debug=true            Enable debugging.

So I tried:

# novm --debug create --nofork --init --nic tap=tap1,ip=192.168.1.2/24,gateway=192.168.1.1,debug=true
Traceback (most recent call last):
  File "/usr/bin/../lib/novm/python/novm/cli.py", line 203, in main
    result = fn(*built_args)
  File "/usr/bin/../lib/novm/python/novm/shell.py", line 118, in create
    command=command)
  File "/usr/bin/../lib/novm/python/novm/manager.py", line 287, in create
    vmmopt=vmmopt)
  File "/usr/bin/../lib/novm/python/novm/manager.py", line 341, in run_novmm
    state_args, metadata = state(state_file)
  File "/usr/bin/../lib/novm/python/novm/manager.py", line 187, in state
    for (index, nic) in zip(range(len(nics)), nics)
  File "/usr/bin/../lib/novm/python/novm/net.py", line 201, in create
    }, **kwargs)
  File "/usr/bin/../lib/novm/python/novm/virtio.py", line 66, in create
    **kwargs)
TypeError: create() got an unexpected keyword argument 'tap'

And:

# novm --debug create --nofork --init --nic ip=192.168.1.2/24,gateway=192.168.1.1,debug=true
20`15/01/10 13:43:00 json: cannot unmarshal string into Go value of type bool
pwaller commented 9 years ago

So I've managed to get something to work. First thing was to remove ,debug=true, then it worked. Not sure what's going on with unexpected keywork argument 'tap'.

pwaller commented 9 years ago

I've found the source of my two problems.

It seems tap should actually be tapname.

It also seems that a bool value is being serialised to json and then transmitted to go. I suspect it's this line here, where foo or bar takes the literal value of bar, whether it is boolean or not. This maybe needs to be foo or bool(bar) but then I'm not sure this will play nice for different values the user might reasonably expect to pass.

amscanne commented 9 years ago

Thanks for the report! I've fixed the two problems indicated.