History | View | Annotate | Download (36.3 kB)
net: delete QemuOpts when net_client_init() fails.
This fixes the following scenario using QMP.
First, put a bogus argument "foo" to "type", which results in an error. {"execute": "netdev_add", "arguments": { "type": "foo", "id": "netdev1" } }Then, call it again with correct argument "user"....
net: Fix VM start with '-net none'
Commit 50e32ea8f31035877decc10f1075aa0e619e09cb changed the behaviourfor the return type of net_client_init() when a nic type with no initmethod was specified. 'none' is one such nic type. Instead of returning0, which gets interpreted as an index into the nd_table[] array, we...
Make netdev_del delete the netdev even when it's in use
To hot-unplug guest and host part of a network device, you do:
device_del NIC-ID netdev_del NETDEV-ID
For PCI devices, device_del merely tells ACPI to unplug the device.The device goes away for real only after the guest processed the ACPI...
Merge remote branch 'mst/for_anthony' into staging
net: Fix hotplug with pci_add
The correct model type wasn't getting added when hotplugging nics withpci_add.
Testcase: start VM with default nic type. In the qemu_monitor:
(qemu) pci_add auto nic model=virtio
This results in a nic hot-plug of the same nic type as the default....
Monitor: Drop QMP documentation from code
Previous commit added QMP documentation to the qemu-monitor.hxfile, it's is a copy of this information.
While it's good to keep it near code, maintaining two copies ofthe same information is too hard and has little benefit as we...
monitor: Use argument type 'b' for set_link
Second argument is now "on" or "off" instead of "up" or "down".
Signed-off-by: Markus Armbruster <armbru@redhat.com>Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
monitor: Convert do_set_link() to QObject, QError
monitor: New commands netdev_add, netdev_del
Monitor commands to go with -netdev.
error: Drop extra messages after qemu_opts_set() and qemu_opts_parse()
Both functions report errors nicely enough now, no need for additionalmessages.
error: Convert net_client_init() to QError
The conversion is shallow: client type init() methods aren'tconverted. Converting them is a big job for relatively littlepractical benefit, so leave it for later.
Signed-off-by: Markus Armbruster <armbru@redhat.com>...
net: remove broken net_set_boot_mask() boot device validation
There are many problems with net_set_boot_mask():
1) It is broken when using the device model instead of "-net nic". Example: $ qemu-system-x86_64 -device rtl8139,vlan=0,id=net0,mac=52:54:00:82:41:fd,bus=pci.0,addr=0x4 -net user,vlan=0,name=hostnet0 -vnc 0.0.0.0:0 -boot n...
net: remove NICInfo.bootable field
It is just set by net_set_boot_mask() and never used. The logic for rom loadingchanged a lot since this field was introduced. It is not needed anymore.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>Acked-by: Juan Quintela <quintela@redhat.com>...
tap: add vhost/vhostfd options
This adds vhost binary option to tap, to enable vhost net accelerator.Default is off for now, we'll be able to make default on long termwhen we know it's stable.
vhostfd option can be used by management, to pass in the fd. Assigning...
qemu-option: Move the implied first name into QemuOptsList
We sometimes permit omitting the first option name, for example-device foo is short for -device driver=foo. The name to use("driver" in the example) is passed as argument to qemu_opts_parse()....
error: Replace qemu_error() by error_report()
error_report() terminates the message with a newline. Strip it itfrom its arguments.
This fixes a few error messages lacking a newline:net_handle_fd_param()'s "No file descriptor named %s found", andtap_open()'s "vnet_hdr=1 requested, but no kernel support for...
qdev: Catch attempt to attach more than one device to a netdev
Guest device and host netdev are peers, i.e. it's a 1:1 relation.However, we fail to enforce that:
$ qemu -nodefaults --nographic -netdev user,id=net0 -device e1000,netdev=net0 -device virtio-net-pci,netdev=net0 -monitor stdio...
qdev: Add a DEV_NVECTORS_UNSPECIFIED enum for unspecified nr of MSI vectors
net.c used a constant to signify no MSI vectors were specified. Extendthat to all qdev devices.
Signed-off-by: Amit Shah <amit.shah@redhat.com>Reported-by: "Michael S. Tsirkin" <mst@redhat.com>...
Allow const QemuOptDesc
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Fix warning on OpenBSD
/src/qemu/net.c: In function `net_check_clients':/src/qemu/net.c:1287: warning: `has_nic' might be used uninitialized in this function/src/qemu/net.c:1287: warning: `has_host_dev' might be used uninitialized in this function
net: net_check_clients() checks only VLAN clients, fix
Clients not associated with a VLAN exist since commit d80b9fc6.
Signed-off-by: Markus Armbruster <armbru@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
net: info network shows only VLAN clients, fix
net: Monitor command set_link finds only VLAN clients, fix
net: Remove unused net_client_uninit()
Unused since commit 9ad4531e.
net: net_check_clients() runs too early to see -device, fix
Call it right after -device devices get created.
net: Fix bogus "Warning: vlan 0 with no nics" with -device
net_check_clients() prints this when an VLAN has host devices, but noguest devices. It uses VLANState members nb_guest_devs andnb_host_devs to keep track of these devices. However, -device does...
don't dereference NULL after failed strdup
Most of these are obvious NULL-deref bug fixes, for example,the ones in these files:
block/curl.c net.c slirp/misc.c
and the first one in block/vvfat.c.The others in block/vvfat.c may not lead to an immediate segfault, but I...
default devices: network
Add a default_net variable which specified whenever a default networkshould be created. It is cleared in case any -net option is specifiedand it is also added to the new -nodefaults switch.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>...
net: add qemu_foreach_nic()
Signed-off-by: Mark McLoughlin <markmc@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
net: print correct error for '-netdev ""'
Reported-by: Markus Armbruster <armbru@redhat.com>Signed-off-by: Mark McLoughlin <markmc@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
net: move parse_macaddr() to net/util.[ch]
net: remove qemu_new_vlan_client()
... and VLANClientState::opaque and qemu_find_vlan_client().
All of these are now unused
net: remove VLANClientState members now in NetClientInfo
Add a NetClientInfo pointer to VLANClientState and use thatfor the typecode and function pointers.
net: introduce NICState and qemu_new_nic()
Common state for all NICs.
The opaque member will replace the opaque member in VLANClientStatesince only NICs need it.
The conf member will allow us to iterate over NICs, access the MACaddr for the NIC and send a packet from each NIC in qemu_announce_self()....
net: introduce qemu_new_net_client()
A replacement for qemu_new_vlan_client(), using NetClientInfo toreplace most arguments.
net: move vde code from net.c to net/vde.c
net: move socket backend code from net.c to net/socket.c
net: move dump backend code from net.c to net/dump.c
net: clean up includes in net.c
This is probably a little drastic, but the includes in this file arenow totally out of control when compared with what includes areactually needed.
This may break the build on e.g. *BSD, but it will be easily fixed byre-instating an include....
net: move slirp code from net.c to net/slirp.c
Add support for GNU/kFreeBSD
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
net: disable receiving if client returns zero
If a receiver returns zero, that means its queue is full and it willnotify us when room is available using qemu_flush_queued_packets().
Take note of that and disable that receiver until it flushes its queue....
net: move AIX code into net/tap-aix.c
Okay, this makes the tap options available on AIX even though there'sno support, but if we want to do it right we should have not compilethe tap code at all on AIX using e.g. CONFIG_TAP.
Signed-off-by: Mark McLoughlin <markmc@redhat.com>...
net: move more stuff into net/tap-win32.c, add net/tap.h
net: move tap-linux.h under net/
net: split all the tap code out into net/tap.c
Enable UFO on virtio-net and tap devices
Enable UFO on the host tap device if supported and allow setting UFOon virtio-net in the guest.
Signed-off-by: Sridhar Samudrala <sri@us.ibm.com>Signed-off-by: Mark McLoughlin <markmc@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
net: add tap_set_offload()
This API allows virtio-net to enable various offload features on atap interface - e.g. to tell the host kernel it can pass up partialchecksums to userspace.
net: add flags parameter to packet queue interface
This allows for the addition of a raw flag, and leaves the way openfor other flags too.
net: add an API for 'raw' packets
In the case where a NIC and backend agree on a packet header format,this API allows injecting packets which lack the agreed upon header.
We need this for sending our gratuitous ARP.
net: add receive_raw parameter to qemu_new_vlan_client()
Trivial patch to allow supplying a receive_raw function.
A future cleanup should combine this function pointer parameters into atable.
net: implement tap support for receive_raw()
tap_receive_raw() always prepends a vnet header if IFF_VNET_HDR isenabled.
tap_receive() only prepends when the a header is required but the NICdoesn't supply one.
net: import linux tap ioctl definitions
Making features dependent on the availability of newer versions if_tun.his going to get seriously clumsy, so let's just import the definitionswe need. It's only a small handful.
If and when we're comfortable depending on 2.6.30 headers, we can remove...
net: make tap_receive() re-use tap_receive_iov() code
In future we will want to prepend a virtio_net header if the NIC didn'tsupply one but IFF_VNET_HDR is enabled on the interface. This is mosteasily achived by using writev() in all cases.
net: enable IFF_VNET_HDR on tap fds if available
For now, we just add an empty header before writing and strip the headerafter reading.
We really only want IFF_VNET_HDR when virtio_net is using it, but itwould significantly complicate matters to try and do that. There should...
net: refactor tap initialization
Re-factor things so that there is only one call site fornet_tap_fd_init().
Two concerns about the QemuOpts usage here - firstly, we set the scriptarguments to their default value and, secondly, we set the ifname valueto the name allocated by the kernel if none is supplied. Are we okay...
net: add a vnet_hdr=on|off parameter
This allows people to disable the IFF_VNET_HDR flag, e.g. for debuggingpurposes or if they know they may migrate the guest to a machine withoutIFF_VNET_HDR support.
It also allows making the lack of IFF_VNET_HDR support an error...
net: add a client type code
This is so as to allow APIs which operate on specific client typeswithout having to add a function table entry which is only implementedby a single client type.
net: add tap_has_vnet_hdr() and tap_using_vnet_hdr() APIs
These lamely named functions allow virtio-net to query whetherIFF_VNET_HDR is enabled on a tap interface and inform the tap codethat virtio-net will supply packets with a vnet header.
qdev: add netdev property
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
net: add macaddr type.
Add new type for mac addresses.
Add function which sets the qemu default mac address if it finds the macaddress uninitialized (i.e. all zeros).
net: refactor packet queueing code
The packet queue code is fairly standalone, has some complex details andeasily reusable. It makes sense to split it out on its own. This patchdoesn't contain any functional changes.
Patchworks-ID: 35511Signed-off-by: Mark McLoughlin <markmc@redhat.com>...
net: add queue for peer-to-peer packet forwarding
Now that we have re-factored the packet queue code, we can re-useit for peer-to-peer also.
Patchworks-ID: 35520Signed-off-by: Mark McLoughlin <markmc@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
net: fix multiple NICs causing net opts process to stop
For NICs, net_init_client() returns the index into the NICInfo table.
qemu_opts_foreach() interprets non-zero as an error return an stopsiterating over the options.
So, if you have more than one '-net nic' on the command line, subsequent...
net: maintain a list of vlan-less clients
Allows them to be cleaned up at shutdown.
This is pretty lame, but will eventually go away as we make vlansthe special case.
Patchworks-ID: 35518Signed-off-by: Mark McLoughlin <markmc@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
net: add -net nic,netdev= option
Patchworks-ID: 35515Signed-off-by: Mark McLoughlin <markmc@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
net: allow NICs to be connected to netdevs
Introduce a 'peer' member to VLANClientState as an alternativeto a vlan. The idea being that packets are transfered directlyfrom peer clients rather than going through a vlan.
Patchworks-ID: 35516Signed-off-by: Mark McLoughlin <markmc@redhat.com>...
net: allow clients not associated with a vlan
Allow net clients to be created which are not connected to any vlan.
This is needed by Gerd in order to allow adding -device nic, wherethe absence of a vlan parameter will not imply vlan=0. Also neededto allow adding a -netdevice option which doesn't connect the backend...
net: add QemuOptsList arg to net_client_parse()
Patchworks-ID: 35505Signed-off-by: Mark McLoughlin <markmc@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
net: handle -netdevice options
Same as for -net except for:
- only tap, user, vde and socket types are supported- the vlan parameter is not allowed- the name parameter is not allowed but the id parameter isrequired
Patchworks-ID: 35517Signed-off-by: Mark McLoughlin <markmc@redhat.com>...
net: pass monitor handle to client init functions
Needed for e.g. looking up a file descriptor name usingmonitor_get_fd() in net_init_tap()
Patchworks-ID: 35509Signed-off-by: Mark McLoughlin <markmc@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
net: handle id= parameter for -net
Use id= in the same was as the current name= parameter; if both arespecified, id= is used.
Patchworks-ID: 35514Signed-off-by: Mark McLoughlin <markmc@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
net: remove id field from NICInfo
Just use the name field instead since we now use the id paramater asthe name, if supplied. Only implication with this change is that ifid is not supplied, the value of the name paramater is used as anid.
Patchworks-ID: 35512...
net: use qtailq for vlan and client lists
Patchworks-ID: 35507Signed-off-by: Mark McLoughlin <markmc@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
slirp: fix !CONFIG_SLIRP compilation
This moves the code that depens on slirp under CONFIG_SLIRP again.
Patchworks-ID: 35372Signed-off-by: Juan Quintela <quintela@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Port host_net_add monitor command to QemuOpts
Here is where we rely on qemu_opts_parse() to handle an empty string.We could alternatively explicitly handle this here by usingqemu_opts_create() when we're not supplied any parameters, but itscleaner this way....
Port usb net to QemuOpts
We need net_client_init_from_opts() exported for this
Final net cleanup after conversion to QemuOpts
Now that net_client_init() has no users, kill it off and renamenet_client_init_from_opts().
There is no further need for the old code in net_client_parse() either.We use qemu_opts_parse() 'firstname' facitity for that. Instead, move...
Port -net none and -net nic to QemuOpts
We use a table of network types to look up the initialization functionand parameter descriptions in net_client_init().
For now, we use QemuOpts for the 'none' and 'nic' types. Subsequentpatches port the other types too and the special casing is removed....
Port -net user to QemuOpts
The handling of guestfwd and hostfwd requires the previous changesto allow multiple values for each parameter. The only way to accessthose multiple values is to use qemu_opt_foreach().
Port -net tap to QemuOpts
Some parameters are not valid with fd=. Rather than having a separateparameter description table for validating fd=, it's easir to justcheck for those invalid parameters later.
Note, the need to possible lookup a file descriptor name from the...
Port -net socket to QemuOpts
Port -net vde to QemuOpts
The net_vde_init() change is needed because we now pass NULL pointersinstead of empty strings for group/sock if they're not set.
Port -net dump to QemuOpts
Note, not incrementing nb_host_devs in net_init_dump() is intentional.
Clean up legacy code in net_client_init()
Now that we've ported everything over to QemuOpts, we can kill offall the cruft in net_client_init().
Note, the 'channel' type requires special handling as it uses aformat that QemuOpts can't parse
Drop config_error(), use qemu_error() instead
Diagnostic output goes to stderr, except when we're in a monitorcommand, when it goes to the monitor instead.
config_error() implements this with a monitor argument: if it'snon-null, report there, else to stderr. This obliges us to pass the...
Use qemu_strdup() for NICInfo string fields
Make NICInfo string fields non-const
We now only assign strdup()ed strings to these fields, never staticstrings.
aliguori: fix build for ppc_prep and mips_jazz
Move memset() from net_client_uninit() to net_client_init()
zeroing a structure before using it is more common than zeroing afterusing it. Also makes the setting of nd->used more obvious.
Use qemu_strdup() for VLANClientState string fields
Make net_client_init() consume slirp_configs even on error
net_slirp_init() walks slirp_configs, and stops when it encounters onethat doesn't work. Instead of consuming slirp_configs members there,consume them in the sole caller. This makes sure all are consumed....
Don't exit() in config_error()
Propagating errors up the call chain is tedious. In startup code, wecan take a shortcut: terminate the program. This is wrong elsewhere,the monitor in particular.
config_error() tries to cater for both customers: it terminates the...
Make it obvious that pci_nic_init() can't fail
Before this patch, pci_nic_init() returns NULL when it can't find themodel in pci_nic_models[]. Except this can't happen, becauseqemu_check_nic_model_list() just searched for model inpci_nic_models[], and terminated the program on failure....
Fix pci_add nic not to exit on bad model
Monitor command "pci_add ADDR nic model=MODEL" uses pci_nic_init() tocreate the NIC. When MODEL is unknown or "?", this prints to stderrand terminates the program.
Change pci_nic_init() not to treat "?" specially, and to return NULL...
Correctly free nd structure
When we "free" a NICInfo structure, we can leak pointers, since we don't domuch more than setting used = 0.
We free() the model parameter, but we don't set it to NULL. This means thata new user of this structure will see garbage in there. It was not noticed...
net: fix coding style nit
Put space between = and - assigning a negative numberto avoid confusion with old-style "-=" (which we also have, and need to be fixed).
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Fix sys-queue.h conflict for good
Problem: Our file sys-queue.h is a copy of the BSD file, but there aresome additions and it's not entirely compatible. Because of that, there havebeen conflicts with system headers on BSD systems. Some hacks have beenintroduced in the commits 15cc9235840a22c289edbe064a9b3c19c5f49896,...
Unexport ticks_per_sec variable. Create get_ticks_per_sec() function
Signed-off-by: Juan Quintela <quintela@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Include sys-queue.h early to override system queue definitions on BSD
monitor: Port handler_3 to use QDict
This commit ports command handlers that receive three arguments to usethe new monitor's dictionary.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>