[libvirt] [PATCH v2] domain_conf: skip boot order check of CD-ROM or floppy device when change-media
Ján Tomko
jtomko at redhat.com
Thu Jan 11 13:36:29 UTC 2018
On Thu, Jan 11, 2018 at 06:16:37PM +0800, Chen Hanxiao wrote:
>From: Chen Hanxiao <chenhanxiao at gmail.com>
>
>If we insert or eject a CD-ROM/floppy device by:
> 'virsh change-media VM --eject/--insert some.iso --live',
>and the original CD-ROM device was configed with a boot order,
>we may get:
> unsupported configuration: boot order 2 is already used by another device
>
>We just updated 'source file' section rather than hotplug a new device.
>This check should be skipped in this case.
>
Attempting to change the boot index on update won't work and should be
forbidden, as stated in the review for v1:
https://www.redhat.com/archives/libvir-list/2018-January/msg00178.html
>Signed-off-by: Chen Hanxiao <chenhanxiao at gmail.com>
>---
>v2:
> commit message updated
> remove ATTRIBUTE_UNUSED from @device
>
> src/conf/domain_conf.c | 19 ++++++++++++++-----
> 1 file changed, 14 insertions(+), 5 deletions(-)
>
>diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
>index a1c25060f..e006cea0a 100644
>--- a/src/conf/domain_conf.c
>+++ b/src/conf/domain_conf.c
>@@ -26881,17 +26881,26 @@ virDomainDeviceIsUSB(virDomainDeviceDefPtr dev)
>
> static int
> virDomainDeviceInfoCheckBootIndex(virDomainDefPtr def ATTRIBUTE_UNUSED,
>- virDomainDeviceDefPtr device ATTRIBUTE_UNUSED,
>+ virDomainDeviceDefPtr device,
> virDomainDeviceInfoPtr info,
> void *opaque)
> {
> virDomainDeviceInfoPtr newinfo = opaque;
>+ virDomainDiskDefPtr disk = device->data.disk;
>+ int disk_device = disk->device;
>
> if (info->bootIndex == newinfo->bootIndex) {
>- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
>- _("boot order %u is already used by another device"),
>- newinfo->bootIndex);
>- return -1;
>+ /* Skip check for insert or eject CD-ROM device */
>+ if (disk_device == VIR_DOMAIN_DISK_DEVICE_FLOPPY ||
>+ disk_device == VIR_DOMAIN_DISK_DEVICE_CDROM) {
Even though cdrom hotplug is not supported by libvirt, assuming that
we're dealing with an update just because of the device type is wrong:
https://www.redhat.com/archives/libvir-list/2018-January/msg00180.html
virDomainDefCompatibleDevice should be aware of the operation (attach
vs. update) and behave accordingly (forbid duplicit bootindexes for
attach and a bootindex change for update)
Jan
>+ VIR_DEBUG("Skip boot index check for floppy or CDROM");
>+ return 0;
>+ } else {
>+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
>+ _("boot order %u is already used by another device"),
>+ newinfo->bootIndex);
>+ return -1;
>+ }
> }
> return 0;
> }
>--
>2.14.3
>
>--
>libvir-list mailing list
>libvir-list at redhat.com
>https://www.redhat.com/mailman/listinfo/libvir-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20180111/82129997/attachment-0001.sig>
More information about the libvir-list
mailing list