[libvirt] [PATCH v4 0/3] Move ide validation from qemuBuildControllerDevStr to qemuDomainDeviceDefValidate
Validate IDE controllers in qemuDomainDeviceDefValidate for reminding users earlier. v3->v4: Drop changes in tests/qemuxml2argvdata/qemuxml2argv-disk-floppy-pseries.args Merged patch #3 and #4 for avoiding git bisect failure. Lin Ma (3): tests: qemuxml2argv: Use scsi controller instead of ide in pseries tests: qemuhotplugtest: Drop ide controller in ccw qemu_domain: Error out earlier when configuring IDE controller incorrectly src/qemu/qemu_command.c | 17 ----------- src/qemu/qemu_domain.c | 35 +++++++++++++++++++++- .../qemuhotplug-base-ccw-live+ccw-virtio.xml | 4 --- ...ive-with-2-ccw-virtio+ccw-virtio-1-explicit.xml | 4 --- ...live-with-2-ccw-virtio+ccw-virtio-1-reverse.xml | 4 --- ...qemuhotplug-base-ccw-live-with-2-ccw-virtio.xml | 4 --- ...-live-with-ccw-virtio+ccw-virtio-2-explicit.xml | 4 --- ...-base-ccw-live-with-ccw-virtio+ccw-virtio-2.xml | 4 --- .../qemuhotplug-base-ccw-live-with-ccw-virtio.xml | 4 --- .../qemuhotplug-base-ccw-live.xml | 4 --- .../qemuxml2argv-disk-floppy-pseries.xml | 4 +-- 11 files changed, 36 insertions(+), 52 deletions(-) -- 2.14.0
Adding an IDE controller for a machinetype that has no built-in IDE controller, Libvirt will log an error. Currently the machinetype list which returns by qemuDomainMachineHasBuiltinIDE only includes 440fx, malta, sun4u and g3beige. Signed-off-by: Lin Ma <lma@suse.com> --- tests/qemuxml2argvdata/qemuxml2argv-disk-floppy-pseries.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-floppy-pseries.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-floppy-pseries.xml index be0ede6bd..df82cfd0e 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-floppy-pseries.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-floppy-pseries.xml @@ -17,7 +17,7 @@ <disk type='block' device='disk'> <driver name='qemu' type='raw'/> <source dev='/dev/HostVG/QEMUGuest1'/> - <target dev='hda' bus='ide'/> + <target dev='hda' bus='scsi'/> <address type='drive' controller='0' bus='0' target='0' unit='0'/> </disk> <disk type='block' device='floppy'> @@ -34,7 +34,7 @@ </disk> <controller type='usb' index='0'/> <controller type='fdc' index='0'/> - <controller type='ide' index='0'/> + <controller type='scsi' index='0'/> <controller type='pci' index='0' model='pci-root'/> <memballoon model='none'/> </devices> -- 2.14.0
Adding an IDE controller for a machinetype that has no built-in IDE controller, libvirt will log an error. Currently the machinetype list which returns by qemuDomainMachineHasBuiltinIDE only includes 440fx, malta, sun4u and g3beige. Signed-off-by: Lin Ma <lma@suse.com> --- tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live+ccw-virtio.xml | 4 ---- ...uhotplug-base-ccw-live-with-2-ccw-virtio+ccw-virtio-1-explicit.xml | 4 ---- ...muhotplug-base-ccw-live-with-2-ccw-virtio+ccw-virtio-1-reverse.xml | 4 ---- .../qemuhotplug-base-ccw-live-with-2-ccw-virtio.xml | 4 ---- ...emuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2-explicit.xml | 4 ---- .../qemuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2.xml | 4 ---- .../qemuhotplug-base-ccw-live-with-ccw-virtio.xml | 4 ---- tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live.xml | 4 ---- 8 files changed, 32 deletions(-) diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live+ccw-virtio.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live+ccw-virtio.xml index cd03d0e09..75948f324 100644 --- a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live+ccw-virtio.xml +++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live+ccw-virtio.xml @@ -33,10 +33,6 @@ <alias name='usb'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> </controller> - <controller type='ide' index='0'> - <alias name='ide0'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> - </controller> <controller type='scsi' index='0' model='virtio-scsi'> <alias name='scsi0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio+ccw-virtio-1-explicit.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio+ccw-virtio-1-explicit.xml index 519d8161f..301658178 100644 --- a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio+ccw-virtio-1-explicit.xml +++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio+ccw-virtio-1-explicit.xml @@ -43,10 +43,6 @@ <alias name='usb'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> </controller> - <controller type='ide' index='0'> - <alias name='ide0'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> - </controller> <controller type='scsi' index='0' model='virtio-scsi'> <alias name='scsi0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio+ccw-virtio-1-reverse.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio+ccw-virtio-1-reverse.xml index 7be75f977..bb9d427c2 100644 --- a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio+ccw-virtio-1-reverse.xml +++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio+ccw-virtio-1-reverse.xml @@ -43,10 +43,6 @@ <alias name='usb'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> </controller> - <controller type='ide' index='0'> - <alias name='ide0'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> - </controller> <controller type='scsi' index='0' model='virtio-scsi'> <alias name='scsi0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio.xml index a83f1b5d7..c41f5affd 100644 --- a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio.xml +++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio.xml @@ -33,10 +33,6 @@ <alias name='usb'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> </controller> - <controller type='ide' index='0'> - <alias name='ide0'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> - </controller> <controller type='scsi' index='0' model='virtio-scsi'> <alias name='scsi0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2-explicit.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2-explicit.xml index 3e9020751..b1114dba9 100644 --- a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2-explicit.xml +++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2-explicit.xml @@ -42,10 +42,6 @@ <alias name='usb'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> </controller> - <controller type='ide' index='0'> - <alias name='ide0'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> - </controller> <controller type='scsi' index='0' model='virtio-scsi'> <alias name='scsi0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2.xml index 3e9020751..b1114dba9 100644 --- a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2.xml +++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2.xml @@ -42,10 +42,6 @@ <alias name='usb'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> </controller> - <controller type='ide' index='0'> - <alias name='ide0'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> - </controller> <controller type='scsi' index='0' model='virtio-scsi'> <alias name='scsi0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio.xml index 0fa8d036b..3476f61db 100644 --- a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio.xml +++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio.xml @@ -32,10 +32,6 @@ <alias name='usb'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> </controller> - <controller type='ide' index='0'> - <alias name='ide0'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> - </controller> <controller type='scsi' index='0' model='virtio-scsi'> <alias name='scsi0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live.xml index d4434a18c..3a202d069 100644 --- a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live.xml +++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live.xml @@ -23,10 +23,6 @@ <alias name='usb'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> </controller> - <controller type='ide' index='0'> - <alias name='ide0'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> - </controller> <controller type='scsi' index='0' model='virtio-scsi'> <alias name='scsi0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> -- 2.14.0
Validate IDE controllers in qemuDomainDeviceDefValidate for reminding users earlier. Signed-off-by: Lin Ma <lma@suse.com> --- src/qemu/qemu_command.c | 17 ----------------- src/qemu/qemu_domain.c | 35 ++++++++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 18 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 6a8da1d58..96e4b8b9e 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3123,23 +3123,6 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef, } break; - case VIR_DOMAIN_CONTROLLER_TYPE_IDE: - /* Since we currently only support the integrated IDE - * controller on various boards, if we ever get to here, it's - * because some other machinetype had an IDE controller - * specified, or one with a single IDE contraller had multiple - * ide controllers specified. - */ - if (qemuDomainHasBuiltinIDE(domainDef)) - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Only a single IDE controller is supported " - "for this machine type")); - else - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("IDE controllers are unsupported for " - "this QEMU binary or machine type")); - goto error; - default: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unsupported controller type: %s"), diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index e8e03134f..f14cb1720 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3884,6 +3884,36 @@ qemuDomainDeviceDefValidateDisk(const virDomainDiskDef *disk) } +static int +qemuDomainControllerDefValidate(const virDomainControllerDef *controller, + const virDomainDef *def) +{ + if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_IDE) { + /* No need to check implicit/builtin IDE controller */ + if (controller->idx == 0 && qemuDomainHasBuiltinIDE(def)) + return 0; + + /* Since we currently only support the integrated IDE + * controller on various boards, if we ever get to here, it's + * because some other machinetype had an IDE controller + * specified, or one with a single IDE controller had multiple + * ide controllers specified. + */ + if (qemuDomainHasBuiltinIDE(def)) + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Only a single IDE controller is supported " + "for this machine type")); + else + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("IDE controllers are unsupported for " + "this QEMU binary or machine type: %s"), + def->os.machine); + return -1; + } + return 0; +} + + static int qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev, const virDomainDef *def, @@ -3928,11 +3958,14 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev, ret = qemuDomainDeviceDefValidateDisk(dev->data.disk); break; + case VIR_DOMAIN_DEVICE_CONTROLLER: + ret = qemuDomainControllerDefValidate(dev->data.controller, def); + break; + case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_FS: case VIR_DOMAIN_DEVICE_INPUT: case VIR_DOMAIN_DEVICE_SOUND: - case VIR_DOMAIN_DEVICE_CONTROLLER: case VIR_DOMAIN_DEVICE_GRAPHICS: case VIR_DOMAIN_DEVICE_HUB: case VIR_DOMAIN_DEVICE_MEMBALLOON: -- 2.14.0
On 12/03/2017 11:06 PM, Lin Ma wrote:
Validate IDE controllers in qemuDomainDeviceDefValidate for reminding users earlier.
v3->v4: Drop changes in tests/qemuxml2argvdata/qemuxml2argv-disk-floppy-pseries.args Merged patch #3 and #4 for avoiding git bisect failure.
Lin Ma (3): tests: qemuxml2argv: Use scsi controller instead of ide in pseries tests: qemuhotplugtest: Drop ide controller in ccw qemu_domain: Error out earlier when configuring IDE controller incorrectly
I've encapsulated/incorporated these into a series I've posted that takes care of more qemu_command controller checks in Validate functionality. See patches 5-7 in: https://www.redhat.com/archives/libvir-list/2017-December/msg00079.html
src/qemu/qemu_command.c | 17 ----------- src/qemu/qemu_domain.c | 35 +++++++++++++++++++++- .../qemuhotplug-base-ccw-live+ccw-virtio.xml | 4 --- ...ive-with-2-ccw-virtio+ccw-virtio-1-explicit.xml | 4 --- ...live-with-2-ccw-virtio+ccw-virtio-1-reverse.xml | 4 --- ...qemuhotplug-base-ccw-live-with-2-ccw-virtio.xml | 4 --- ...-live-with-ccw-virtio+ccw-virtio-2-explicit.xml | 4 --- ...-base-ccw-live-with-ccw-virtio+ccw-virtio-2.xml | 4 --- .../qemuhotplug-base-ccw-live-with-ccw-virtio.xml | 4 --- .../qemuhotplug-base-ccw-live.xml | 4 --- .../qemuxml2argv-disk-floppy-pseries.xml | 4 +-- 11 files changed, 36 insertions(+), 52 deletions(-)
participants (2)
-
John Ferlan -
Lin Ma