mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
qemu: define virDomainDevAddUSBController()
This new function will add a single controller of the given model, except the case of ich9-usb-ehci1 (the master controller for a USB2 controller set) in which case a set of related controllers will be added (EHCI1, UHCI1, UHCI2, UHCI3). These controllers will not be given PCI addresses, but should be otherwise ready to use. "-1" is allowed for controller model, and means "default for this machinetype". This matches the existing practice in qemuDomainDefPostParse(), which always adds the default controller with model = -1, and relies on the commandline builder to set a model (that is wrong, but will be fixed later).
This commit is contained in:
parent
ed64d92bea
commit
8ebca27bb7
@ -14290,6 +14290,60 @@ virDomainDefAddController(virDomainDefPtr def, int type, int idx, int model)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* virDomainDefAddUSBController:
|
||||
* @def: the domain
|
||||
* @idx: index for new controller (or -1 for "lowest unused index")
|
||||
* @model: VIR_DOMAIN_CONTROLLER_MODEL_USB_* or -1
|
||||
*
|
||||
* Add a USB controller of the specified model (or default model for
|
||||
* current machinetype if model == -1). If model is ich9-usb-ehci,
|
||||
* also add companion uhci1, uhci2, and uhci3 controllers at the same
|
||||
* index.
|
||||
*
|
||||
* Returns 0 on success, -1 on failure.
|
||||
*/
|
||||
int
|
||||
virDomainDefAddUSBController(virDomainDefPtr def, int idx, int model)
|
||||
{
|
||||
virDomainControllerDefPtr cont; /* this is a *copy* of the DefPtr */
|
||||
|
||||
cont = virDomainDefAddController(def, VIR_DOMAIN_CONTROLLER_TYPE_USB,
|
||||
idx, model);
|
||||
if (!cont)
|
||||
return -1;
|
||||
|
||||
if (model != VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_EHCI1)
|
||||
return 0;
|
||||
|
||||
/* When the initial controller is ich9-usb-ehci, also add the
|
||||
* companion controllers
|
||||
*/
|
||||
|
||||
idx = cont->idx; /* in case original request was "-1" */
|
||||
|
||||
if (!(cont = virDomainDefAddController(def, VIR_DOMAIN_CONTROLLER_TYPE_USB,
|
||||
idx, VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_UHCI1)))
|
||||
return -1;
|
||||
cont->info.mastertype = VIR_DOMAIN_CONTROLLER_MASTER_USB;
|
||||
cont->info.master.usb.startport = 0;
|
||||
|
||||
if (!(cont = virDomainDefAddController(def, VIR_DOMAIN_CONTROLLER_TYPE_USB,
|
||||
idx, VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_UHCI2)))
|
||||
return -1;
|
||||
cont->info.mastertype = VIR_DOMAIN_CONTROLLER_MASTER_USB;
|
||||
cont->info.master.usb.startport = 2;
|
||||
|
||||
if (!(cont = virDomainDefAddController(def, VIR_DOMAIN_CONTROLLER_TYPE_USB,
|
||||
idx, VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_UHCI3)))
|
||||
return -1;
|
||||
cont->info.mastertype = VIR_DOMAIN_CONTROLLER_MASTER_USB;
|
||||
cont->info.master.usb.startport = 4;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
virDomainDefMaybeAddController(virDomainDefPtr def,
|
||||
int type,
|
||||
|
@ -3089,6 +3089,8 @@ VIR_ENUM_DECL(virDomainCpuPlacementMode)
|
||||
|
||||
VIR_ENUM_DECL(virDomainStartupPolicy)
|
||||
|
||||
int
|
||||
virDomainDefAddUSBController(virDomainDefPtr def, int idx, int model);
|
||||
int
|
||||
virDomainDefMaybeAddController(virDomainDefPtr def,
|
||||
int type,
|
||||
|
@ -198,6 +198,7 @@ virDomainControllerTypeToString;
|
||||
virDomainCpuPlacementModeTypeFromString;
|
||||
virDomainCpuPlacementModeTypeToString;
|
||||
virDomainDefAddImplicitControllers;
|
||||
virDomainDefAddUSBController;
|
||||
virDomainDefCheckABIStability;
|
||||
virDomainDefCheckDuplicateDiskInfo;
|
||||
virDomainDefCheckUnsupportedMemoryHotplug;
|
||||
|
Loading…
Reference in New Issue
Block a user