mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-06 09:13:55 -06:00
net/virtio: add failover support
This patch adds support to handle failover device pairs of a virtio-net device and a (vfio-)pci device, where the virtio-net acts as the standby device and the (vfio-)pci device as the primary. The general idea is that we have a pair of devices, a (vfio-)pci and a emulated (virtio-net) device. Before migration the vfio device is unplugged and data flows to the emulated device, on the target side another (vfio-)pci device is plugged in to take over the data-path. In the guest the net_failover module will pair net devices with the same MAC address. To achieve this we need: 1. Provide a callback function for the should_be_hidden DeviceListener. It is called when the primary device is plugged in. Evaluate the QOpt passed in to check if it is the matching primary device. It returns if the device should be hidden or not. When it should be hidden it stores the device options in the VirtioNet struct and the device is added once the VIRTIO_NET_F_STANDBY feature is negotiated during virtio feature negotiation. If the virtio-net devices are not realized at the time the (vfio-)pci devices are realized, we need to connect the devices later. This way we make sure primary and standby devices can be specified in any order. 2. Register a callback for migration status notifier. When called it will unplug its primary device before the migration happens. 3. Register a callback for the migration code that checks if a device needs to be unplugged from the guest. Signed-off-by: Jens Freimann <jfreimann@redhat.com> Message-Id: <20191029114905.6856-11-jfreimann@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
ea45cb8d84
commit
9711cd0dfc
5 changed files with 384 additions and 0 deletions
|
@ -18,6 +18,7 @@
|
|||
#include "standard-headers/linux/virtio_net.h"
|
||||
#include "hw/virtio/virtio.h"
|
||||
#include "net/announce.h"
|
||||
#include "qemu/option_int.h"
|
||||
|
||||
#define TYPE_VIRTIO_NET "virtio-net-device"
|
||||
#define VIRTIO_NET(obj) \
|
||||
|
@ -43,6 +44,7 @@ typedef struct virtio_net_conf
|
|||
int32_t speed;
|
||||
char *duplex_str;
|
||||
uint8_t duplex;
|
||||
char *primary_id_str;
|
||||
} virtio_net_conf;
|
||||
|
||||
/* Coalesced packets type & status */
|
||||
|
@ -187,6 +189,16 @@ struct VirtIONet {
|
|||
AnnounceTimer announce_timer;
|
||||
bool needs_vnet_hdr_swap;
|
||||
bool mtu_bypass_backend;
|
||||
QemuOpts *primary_device_opts;
|
||||
QDict *primary_device_dict;
|
||||
DeviceState *primary_dev;
|
||||
BusState *primary_bus;
|
||||
char *primary_device_id;
|
||||
char *standby_id;
|
||||
bool primary_should_be_hidden;
|
||||
bool failover;
|
||||
DeviceListener primary_listener;
|
||||
Notifier migration_state;
|
||||
};
|
||||
|
||||
void virtio_net_set_netclient_name(VirtIONet *n, const char *name,
|
||||
|
|
|
@ -160,6 +160,7 @@ typedef struct VirtioDeviceClass {
|
|||
*/
|
||||
int (*post_load)(VirtIODevice *vdev);
|
||||
const VMStateDescription *vmsd;
|
||||
bool (*primary_unplug_pending)(void *opaque);
|
||||
} VirtioDeviceClass;
|
||||
|
||||
void virtio_instance_init_common(Object *proxy_obj, void *data,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue