libxl: add validation if sound device is supported

Xen supports only subset of libvirt's sound devices, and starting with
Xen 4.17 it is enforced by libxl. Verify it early.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Marek Marczykowski-Górecki 2022-12-20 23:52:05 +01:00 committed by Michal Privoznik
parent 4102acc608
commit f2fe8a3504

View File

@ -312,6 +312,28 @@ libxlDomainDefValidate(const virDomainDef *def,
return -1;
}
if (def->nsounds > 0) {
virDomainSoundDef *snd = def->sounds[0];
switch (snd->model) {
case VIR_DOMAIN_SOUND_MODEL_ICH6:
case VIR_DOMAIN_SOUND_MODEL_ES1370:
case VIR_DOMAIN_SOUND_MODEL_AC97:
case VIR_DOMAIN_SOUND_MODEL_SB16:
break;
default:
case VIR_DOMAIN_SOUND_MODEL_PCSPK:
case VIR_DOMAIN_SOUND_MODEL_ICH7:
case VIR_DOMAIN_SOUND_MODEL_USB:
case VIR_DOMAIN_SOUND_MODEL_ICH9:
case VIR_DOMAIN_SOUND_MODEL_LAST:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unsupported audio model %s"),
virDomainSoundModelTypeToString(snd->model));
return -1;
}
}
return 0;
}