mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-08 22:15:21 +00:00
qemu: add bootindex for usb-host and usb-redir devices
Allow bootindex to be specified for redirected USB devices and host USB devices. Bug: https://bugzilla.redhat.com/show_bug.cgi?id=805414
This commit is contained in:
parent
bf60b6b33f
commit
a4c19459aa
@ -2779,6 +2779,9 @@
|
||||
<optional>
|
||||
<ref name="address"/>
|
||||
</optional>
|
||||
<optional>
|
||||
<ref name="deviceBoot"/>
|
||||
</optional>
|
||||
</element>
|
||||
</define>
|
||||
<define name="redirfilter">
|
||||
|
@ -279,8 +279,8 @@ struct _virDomainDeviceInfo {
|
||||
* devices. */
|
||||
int rombar; /* enum virDomainPciRombarMode */
|
||||
char *romfile;
|
||||
/* bootIndex is only user for disk, network interface, and
|
||||
* hostdev devices. */
|
||||
/* bootIndex is only used for disk, network interface, hostdev
|
||||
* and redirdev devices */
|
||||
int bootIndex;
|
||||
};
|
||||
|
||||
|
@ -191,6 +191,8 @@ VIR_ENUM_IMPL(qemuCaps, QEMU_CAPS_LAST,
|
||||
"vnc",
|
||||
|
||||
"drive-mirror", /* 115 */
|
||||
"usb-redir.bootindex",
|
||||
"usb-host.bootindex",
|
||||
);
|
||||
|
||||
struct _qemuCaps {
|
||||
@ -1325,6 +1327,11 @@ static struct qemuCapsStringFlags qemuCapsObjectPropsPixx4PM[] = {
|
||||
|
||||
static struct qemuCapsStringFlags qemuCapsObjectPropsUsbRedir[] = {
|
||||
{ "filter", QEMU_CAPS_USB_REDIR_FILTER },
|
||||
{ "bootindex", QEMU_CAPS_USB_REDIR_BOOTINDEX },
|
||||
};
|
||||
|
||||
static struct qemuCapsStringFlags qemuCapsObjectPropsUsbHost[] = {
|
||||
{ "bootindex", QEMU_CAPS_USB_HOST_BOOTINDEX },
|
||||
};
|
||||
|
||||
struct qemuCapsObjectTypeProps {
|
||||
@ -1350,6 +1357,8 @@ static struct qemuCapsObjectTypeProps qemuCapsObjectProps[] = {
|
||||
ARRAY_CARDINALITY(qemuCapsObjectPropsPixx4PM) },
|
||||
{ "usb-redir", qemuCapsObjectPropsUsbRedir,
|
||||
ARRAY_CARDINALITY(qemuCapsObjectPropsUsbRedir) },
|
||||
{ "usb-host", qemuCapsObjectPropsUsbHost,
|
||||
ARRAY_CARDINALITY(qemuCapsObjectPropsUsbHost) },
|
||||
};
|
||||
|
||||
|
||||
@ -1545,6 +1554,7 @@ qemuCapsExtractDeviceStr(const char *qemu,
|
||||
"-device", "PIIX4_PM,?",
|
||||
"-device", "usb-redir,?",
|
||||
"-device", "ide-drive,?",
|
||||
"-device", "usb-host,?",
|
||||
NULL);
|
||||
/* qemu -help goes to stdout, but qemu -device ? goes to stderr. */
|
||||
virCommandSetErrorBuffer(cmd, &output);
|
||||
|
@ -153,6 +153,8 @@ enum qemuCapsFlags {
|
||||
QEMU_CAPS_BLOCK_COMMIT = 113, /* block-commit */
|
||||
QEMU_CAPS_VNC = 114, /* Is -vnc available? */
|
||||
QEMU_CAPS_DRIVE_MIRROR = 115, /* drive-mirror monitor command */
|
||||
QEMU_CAPS_USB_REDIR_BOOTINDEX = 116, /* usb-redir.bootindex */
|
||||
QEMU_CAPS_USB_HOST_BOOTINDEX = 117, /* usb-host.bootindex */
|
||||
|
||||
QEMU_CAPS_LAST, /* this must always be the last item */
|
||||
};
|
||||
|
@ -3504,6 +3504,16 @@ qemuBuildRedirdevDevStr(virDomainDefPtr def,
|
||||
}
|
||||
}
|
||||
|
||||
if (dev->info.bootIndex) {
|
||||
if (!qemuCapsGet(caps, QEMU_CAPS_USB_REDIR_BOOTINDEX)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("USB redirection booting is not "
|
||||
"supported by this version of QEMU"));
|
||||
goto error;
|
||||
}
|
||||
virBufferAsprintf(&buf, ",bootindex=%d", dev->info.bootIndex);
|
||||
}
|
||||
|
||||
if (qemuBuildDeviceAddressStr(&buf, &dev->info, caps) < 0)
|
||||
goto error;
|
||||
|
||||
@ -3540,6 +3550,8 @@ qemuBuildUSBHostdevDevStr(virDomainHostdevDefPtr dev,
|
||||
dev->source.subsys.u.usb.device);
|
||||
}
|
||||
virBufferAsprintf(&buf, ",id=%s", dev->info->alias);
|
||||
if (dev->info->bootIndex)
|
||||
virBufferAsprintf(&buf, ",bootindex=%d", dev->info->bootIndex);
|
||||
|
||||
if (qemuBuildDeviceAddressStr(&buf, dev->info, caps) < 0)
|
||||
goto error;
|
||||
@ -6439,16 +6451,27 @@ qemuBuildCommandLine(virConnectPtr conn,
|
||||
|
||||
if (hostdev->info->bootIndex) {
|
||||
if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
|
||||
hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) {
|
||||
(hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI &&
|
||||
hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("booting from assigned devices is only"
|
||||
" supported for PCI devices"));
|
||||
goto error;
|
||||
} else if (!qemuCapsGet(caps, QEMU_CAPS_PCI_BOOTINDEX)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("booting from assigned PCI devices is not"
|
||||
" supported with this version of qemu"));
|
||||
" supported for PCI and USB devices"));
|
||||
goto error;
|
||||
} else {
|
||||
if (hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI &&
|
||||
!qemuCapsGet(caps, QEMU_CAPS_PCI_BOOTINDEX)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("booting from assigned PCI devices is not"
|
||||
" supported with this version of qemu"));
|
||||
goto error;
|
||||
}
|
||||
if (hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB &&
|
||||
!qemuCapsGet(caps, QEMU_CAPS_USB_HOST_BOOTINDEX)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("booting from assigned USB devices is not"
|
||||
" supported with this version of qemu"));
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user