qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Vivier <lvivier@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Jason Wang <jasowang@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [PATCH v2] failover: specify an alternate MAC address
Date: Tue, 2 Nov 2021 09:14:51 +0100	[thread overview]
Message-ID: <913b4d85-9c05-0bb8-2dd5-02744a44b388@redhat.com> (raw)
In-Reply-To: <20211101053105-mutt-send-email-mst@kernel.org>

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	other threads:[~2021-11-02  8:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-27  9:59 [PATCH v2] failover: specify an alternate MAC address Laurent Vivier
2021-10-27 10:12 ` Philippe Mathieu-Daudé
2021-10-28  5:43 ` Jason Wang
2021-11-01  9:39 ` Michael S. Tsirkin
2021-11-02  8:14   ` Laurent Vivier [this message]
2021-11-02  8:45     ` Michael S. Tsirkin
2021-11-07  8:25     ` Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=913b4d85-9c05-0bb8-2dd5-02744a44b388@redhat.com \
    --to=lvivier@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).