qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2] failover: specify an alternate MAC address


From: Laurent Vivier
Subject: Re: [PATCH v2] failover: specify an alternate MAC address
Date: Tue, 2 Nov 2021 09:14:51 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0

On 01/11/2021 10:39, Michael S. Tsirkin wrote:
On Wed, Oct 27, 2021 at 11:59:45AM +0200, Laurent Vivier wrote:
If the guest driver doesn't support the STANDBY feature, by default
we keep the virtio-net device and don't hotplug the VFIO device,
but in some cases, user can prefer to use the VFIO device rather
than the virtio-net one. We can't unplug the virtio-net device
(because on migration it is expected on the destination side) but
we can keep both interfaces if the MAC addresses are different
(to have the same MAC address can cause kernel crash with old
kernel). The VFIO device will be unplugged before the migration
like in the normal failover migration but without a failover device.

This patch adds a new property to the virtio-net device:
"failover-legacy-mac"

If an alternate MAC address is provided with "failover-legacy-mac" and
the STANDBY feature is not supported, both interfaces are plugged
but the standby interface (virtio-net) MAC address is set to the
value provided by the "failover-legacy-mac" parameter.

If the STANDBY feature is supported by guest and QEMU, the virtio-net
failover acts as usual.

Signed-off-by: Laurent Vivier <lvivier@redhat.com>

Wait a second. What if config is read before features are set?
Are we going to provide a legacy or a new mac?
We provide the new MAC and at this point the primary device is not plugged.

When features are set:
- if STANDBY is set, the primary device is plugged, and secondary (virtio-net) uses the new MAC
- if STANDBY is not set:
    - if legacy MAC is provided:
        the primary device is plugged and legacy MAC is used
    - else
        the primary device is not plugged and new MAC is used.

I guess current guests do not do this, but the spec does allow this,
and then the mac will apparently change for the guests.

What I read in virtio 1.0 specs, "3.1.1 Driver requirements: Device initialization", is the virtio configuration space (step 7) is is accessed after the features are negotiated. I don't think the part in step 4 can involve the MAC address, and moreover the config is not read before, but during the negotiation (I guess we can see that as the config access is part of the negotiation).

3.1.1 Driver Requirements: Device Initialization

The driver MUST follow this sequence to initialize a device:
1. Reset the device.
2. Set the ACKNOWLEDGE status bit: the guest OS has notice the device.
3. Set the DRIVER status bit: the guest OS knows how to drive the device.
4. Read device feature bits, and write the subset of feature bits understood by the OS and driver to the device. During this step the driver MAY read (but MUST NOT write) the device-specific configuration fields to check that it can support the device before accepting it. 5. Set the FEATURES_OK status bit. The driver MUST NOT accept new feature bits after this step. 6. Re-read device status to ensure the FEATURES_OK bit is still set: otherwise, the device does not support our subset of features and the device is unusable. 7. Perform device-specific setup, including discovery of virtqueues for the device, optional per-bus setup, reading and possibly writing the device’s virtio configuration space, and population of virtqueues.
8. Set the DRIVER_OK status bit. At this point the device is “live”.


It might be cleaner to just add a PRIMARY_MAC feature -
would need guest work though ...

We can't add a new feature: the goal of this patch is to be able to use the primary device (VFIO) with kernel that doesn't support STANDBY feature. If we can add a feature, to add the STANDBY feature would be a better choice.

If changing the MAC address is not acceptable we can return to a mix of v1 and 
v2 of my patch:

"virtio: failover: allow to keep the VFIO device rather than the virtio-net one"

https://patchew.org/QEMU/20210729191910.317114-1-lvivier@redhat.com/

that disables the virtio-net driver on the module probe.

Thanks,
Laurent




reply via email to

[Prev in Thread] Current Thread [Next in Thread]