mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
Check boot order on device attach
https://bugzilla.redhat.com/show_bug.cgi?id=1007754 When attaching a new device, we need to check if its boot order configuration is compatible with current domain definition. Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
563a12b346
commit
585076c7e6
@ -17873,11 +17873,30 @@ virDomainDeviceIsUSB(virDomainDeviceDefPtr dev)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
virDomainDeviceInfoCheckBootIndex(virDomainDefPtr def ATTRIBUTE_UNUSED,
|
||||||
|
virDomainDeviceDefPtr device ATTRIBUTE_UNUSED,
|
||||||
|
virDomainDeviceInfoPtr info,
|
||||||
|
void *opaque)
|
||||||
|
{
|
||||||
|
virDomainDeviceInfoPtr newinfo = opaque;
|
||||||
|
|
||||||
|
if (info->bootIndex == newinfo->bootIndex) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
|
_("boot order %d is already used by another device"),
|
||||||
|
newinfo->bootIndex);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
virDomainDefCompatibleDevice(virDomainDefPtr def,
|
virDomainDefCompatibleDevice(virDomainDefPtr def,
|
||||||
virDomainDeviceDefPtr dev,
|
virDomainDeviceDefPtr dev,
|
||||||
virDomainDeviceAction action)
|
virDomainDeviceAction action)
|
||||||
{
|
{
|
||||||
|
virDomainDeviceInfoPtr info = virDomainDeviceGetInfo(dev);
|
||||||
|
|
||||||
if (action != VIR_DOMAIN_DEVICE_ACTION_ATTACH)
|
if (action != VIR_DOMAIN_DEVICE_ACTION_ATTACH)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -17890,6 +17909,19 @@ virDomainDefCompatibleDevice(virDomainDefPtr def,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (info && info->bootIndex > 0) {
|
||||||
|
if (def->os.nBootDevs > 0) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
|
_("per-device boot elements cannot be used"
|
||||||
|
" together with os/boot elements"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (virDomainDeviceInfoIterate(def,
|
||||||
|
virDomainDeviceInfoCheckBootIndex,
|
||||||
|
info) < 0)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user