[PATCH] qemuDomainChangeDiskLive: Modify 'startupPolicy' before changing source

Peter Krempa pkrempa at redhat.com
Mon Sep 13 08:04:47 UTC 2021


On Fri, Sep 10, 2021 at 22:04:01 +0300, Nir Soffer wrote:
> On Fri, Sep 10, 2021 at 4:35 PM Peter Krempa <pkrempa at redhat.com> wrote:
> >
> > We don't support all startup policies with all source types so to
> > correctly allow switching from a 'file' based cdrom with 'optional'
> > startup policy to a 'block' based one which doesn't support optional we
> > must update the startup policy field first. Obviously we need to have
> > fallback if the update fails.
> 
> Why is there a difference between file and block for startup policy?

I'm not sure about the historic reasons for why 'block' was not
considered when this was implemented originally.

> Is this documented?

(citation from 'formatdomain.rst' the source for https://www.libvirt.org/formatdomain.html )

   For a "file" or "volume" disk type which represents a cdrom or floppy (the
   ``device`` attribute), it is possible to define policy what to do with the
   disk if the source file is not accessible. (NB, ``startupPolicy`` is not
   valid for "volume" disk unless the specified storage volume is of "file"
   type). This is done by the ``startupPolicy`` attribute ( :since:`since 0.9.7`
   ), accepting these values:

   ========= =====================================================================
   mandatory fail if missing for any reason (the default)
   requisite fail if missing on boot up, drop if missing on migrate/restore/revert
   optional  drop if missing at any start attempt
   ========= =====================================================================

   :since:`Since 1.1.2` the ``startupPolicy`` is extended to support hard disks
   besides cdrom and floppy. On guest cold bootup, if a certain disk is not
   accessible or its disk chain is broken, with startupPolicy 'optional' the
   guest will drop this disk. This feature doesn't support migration currently.

As you can notice only "file" and "volume" (pointing to a file) are
allowed.

> Do we have a way to switch from file to block with current libvirt
> (centos 8 stream, rhel 8.4) without this patch, or do we need to wait
> until this fix is available? (rhel 8.5?)

You can issue two separate update calls. One updating the startup policy
first and then the second one updating the source.

On another note, I don't quite understand though why oVirt actually even
uses startup policy in the first place. Since oVirt is already doing a
pretty complicated storage management, checking whether the image file
exists is a trivial operation.

Similarly, when migrating you can use the destination XML (which can be
optionally used with the migration API) allows you to update storage
source and even provide empty storage for a cdrom. This can be used to
update paths to storage too. This allows superior flexibility when
compared to startup policy.




More information about the libvir-list mailing list