During post parse processing, let's force setting the controller model to default value if not already set for defined controllers (e.g. the non implicit ones). Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx> --- src/qemu/qemu_domain.c | 8 +++---- src/qemu/qemu_domain_address.c | 27 ++++++++++++++++++++++ src/qemu/qemu_domain_address.h | 4 ++++ .../hostdev-scsi-lsi-iscsi-auth.xml | 2 +- .../qemuxml2xmloutdata/hostdev-scsi-lsi-iscsi.xml | 2 +- tests/qemuxml2xmloutdata/hostdev-scsi-lsi.xml | 2 +- 6 files changed, 37 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 6b4bd3cca..c8123ce59 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4251,11 +4251,9 @@ qemuDomainControllerDefPostParse(virDomainControllerDefPtr cont, { switch ((virDomainControllerType)cont->type) { case VIR_DOMAIN_CONTROLLER_TYPE_SCSI: - /* set the default SCSI controller model for S390 arches */ - if (cont->model == -1 && - ARCH_IS_S390(def->os.arch)) { - cont->model = VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI; - } + /* Set the default SCSI controller model if not already set */ + if (qemuDomainSetSCSIControllerModel(def, cont, qemuCaps) < 0) + return -1; break; case VIR_DOMAIN_CONTROLLER_TYPE_USB: diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 5211b4f8a..75c263015 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -60,6 +60,8 @@ qemuDomainGetSCSIControllerModel(const virDomainDef *def, if (qemuDomainIsPSeries(def)) return VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI; + else if (ARCH_IS_S390(def->os.arch)) + return VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI; else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_LSI)) return VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC; else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_SCSI)) @@ -74,6 +76,31 @@ qemuDomainGetSCSIControllerModel(const virDomainDef *def, /** * @def: Domain definition + * @cont: Domain controller def + * @qemuCaps: qemu capabilities + * + * Set the controller model based on the existing value and the + * capabilities if possible. + * + * Returns 0 on success, -1 on failure with error set. + */ +int +qemuDomainSetSCSIControllerModel(const virDomainDef *def, + virDomainControllerDefPtr cont, + virQEMUCapsPtr qemuCaps) +{ + int model = qemuDomainGetSCSIControllerModel(def, cont, qemuCaps); + + if (model < 0) + return -1; + + cont->model = model; + return 0; +} + + +/** + * @def: Domain definition * @info: Domain device info * @qemuCaps: QEMU capabilities * diff --git a/src/qemu/qemu_domain_address.h b/src/qemu/qemu_domain_address.h index 209b59e0d..04fb2fc14 100644 --- a/src/qemu/qemu_domain_address.h +++ b/src/qemu/qemu_domain_address.h @@ -32,6 +32,10 @@ int qemuDomainGetSCSIControllerModel(const virDomainDef *def, const virDomainControllerDef *cont, virQEMUCapsPtr qemuCaps); +int qemuDomainSetSCSIControllerModel(const virDomainDef *def, + virDomainControllerDefPtr cont, + virQEMUCapsPtr qemuCaps); + int qemuDomainFindSCSIControllerModel(const virDomainDef *def, virDomainDeviceInfoPtr info, virQEMUCapsPtr qemuCaps); diff --git a/tests/qemuxml2xmloutdata/hostdev-scsi-lsi-iscsi-auth.xml b/tests/qemuxml2xmloutdata/hostdev-scsi-lsi-iscsi-auth.xml index cad016129..3d0efdcaf 100644 --- a/tests/qemuxml2xmloutdata/hostdev-scsi-lsi-iscsi-auth.xml +++ b/tests/qemuxml2xmloutdata/hostdev-scsi-lsi-iscsi-auth.xml @@ -19,7 +19,7 @@ <target dev='hda' bus='ide'/> <address type='drive' controller='0' bus='0' target='0' unit='0'/> </disk> - <controller type='scsi' index='0'> + <controller type='scsi' index='0' model='lsilogic'> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </controller> <controller type='usb' index='0'> diff --git a/tests/qemuxml2xmloutdata/hostdev-scsi-lsi-iscsi.xml b/tests/qemuxml2xmloutdata/hostdev-scsi-lsi-iscsi.xml index b7312ca4f..28b80a02b 100644 --- a/tests/qemuxml2xmloutdata/hostdev-scsi-lsi-iscsi.xml +++ b/tests/qemuxml2xmloutdata/hostdev-scsi-lsi-iscsi.xml @@ -19,7 +19,7 @@ <target dev='hda' bus='ide'/> <address type='drive' controller='0' bus='0' target='0' unit='0'/> </disk> - <controller type='scsi' index='0'> + <controller type='scsi' index='0' model='lsilogic'> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </controller> <controller type='usb' index='0'> diff --git a/tests/qemuxml2xmloutdata/hostdev-scsi-lsi.xml b/tests/qemuxml2xmloutdata/hostdev-scsi-lsi.xml index 54498aa5c..545ce3ba8 100644 --- a/tests/qemuxml2xmloutdata/hostdev-scsi-lsi.xml +++ b/tests/qemuxml2xmloutdata/hostdev-scsi-lsi.xml @@ -19,7 +19,7 @@ <target dev='hda' bus='ide'/> <address type='drive' controller='0' bus='0' target='0' unit='0'/> </disk> - <controller type='scsi' index='0'> + <controller type='scsi' index='0' model='lsilogic'> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </controller> <controller type='usb' index='0'> -- 2.13.6 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list