qemu: Disable spice-related devices without spice graphics

For most of them qemu errors out with unclear message, and for the
audiodev qemu just falls back to timer-based audio with a warning
message, and will possibly also error out in the future.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2035163
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Martin Kletzander 2022-05-11 15:46:57 +02:00
parent 45c0ff3eea
commit 36e86dbf33

View File

@ -1965,6 +1965,7 @@ qemuValidateDomainChrTargetDef(const virDomainChrDef *chr)
static int
qemuValidateDomainChrSourceDef(const virDomainChrSourceDef *def,
const virDomainDef *vmdef,
virQEMUCaps *qemuCaps)
{
switch ((virDomainChrType)def->type) {
@ -1996,6 +1997,16 @@ qemuValidateDomainChrSourceDef(const virDomainChrSourceDef *def,
}
break;
case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
if (!virDomainDefHasSpiceGraphics(vmdef)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("chardev '%s' not supported without spice graphics"),
virDomainChrTypeToString(def->type));
return -1;
}
break;
case VIR_DOMAIN_CHR_TYPE_NULL:
case VIR_DOMAIN_CHR_TYPE_VC:
case VIR_DOMAIN_CHR_TYPE_PTY:
@ -2003,8 +2014,6 @@ qemuValidateDomainChrSourceDef(const virDomainChrSourceDef *def,
case VIR_DOMAIN_CHR_TYPE_PIPE:
case VIR_DOMAIN_CHR_TYPE_STDIO:
case VIR_DOMAIN_CHR_TYPE_UDP:
case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
case VIR_DOMAIN_CHR_TYPE_NMDM:
case VIR_DOMAIN_CHR_TYPE_LAST:
break;
@ -2027,7 +2036,7 @@ qemuValidateDomainChrDef(const virDomainChrDef *dev,
const virDomainDef *def,
virQEMUCaps *qemuCaps)
{
if (qemuValidateDomainChrSourceDef(dev->source, qemuCaps) < 0)
if (qemuValidateDomainChrSourceDef(dev->source, def, qemuCaps) < 0)
return -1;
if (qemuValidateDomainChrTargetDef(dev) < 0)
@ -2120,7 +2129,7 @@ qemuValidateDomainSmartcardDef(const virDomainSmartcardDef *smartcard,
return -1;
}
if (qemuValidateDomainChrSourceDef(smartcard->data.passthru, qemuCaps) < 0)
if (qemuValidateDomainChrSourceDef(smartcard->data.passthru, def, qemuCaps) < 0)
return -1;
break;
@ -2136,6 +2145,7 @@ qemuValidateDomainSmartcardDef(const virDomainSmartcardDef *smartcard,
static int
qemuValidateDomainRNGDef(const virDomainRNGDef *def,
const virDomainDef *vmdef,
virQEMUCaps *qemuCaps)
{
virDomainCapsDeviceRNG rngCaps = { 0 };
@ -2158,7 +2168,9 @@ qemuValidateDomainRNGDef(const virDomainRNGDef *def,
return -1;
}
if (qemuValidateDomainChrSourceDef(def->source.chardev, qemuCaps) < 0)
if (qemuValidateDomainChrSourceDef(def->source.chardev,
vmdef,
qemuCaps) < 0)
return -1;
break;
@ -2199,7 +2211,7 @@ qemuValidateDomainRedirdevDef(const virDomainRedirdevDef *dev,
const virDomainDef *def,
virQEMUCaps *qemuCaps)
{
if (qemuValidateDomainChrSourceDef(dev->source, qemuCaps) < 0)
if (qemuValidateDomainChrSourceDef(dev->source, def, qemuCaps) < 0)
return -1;
if (dev->bus != VIR_DOMAIN_REDIRDEV_BUS_USB) {
@ -4379,6 +4391,7 @@ qemuValidateDomainDeviceDefFS(virDomainFSDef *fs,
static int
qemuValidateDomainDeviceDefAudio(virDomainAudioDef *audio,
const virDomainDef *def,
virQEMUCaps *qemuCaps G_GNUC_UNUSED)
{
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_AUDIODEV)) {
@ -4483,6 +4496,11 @@ qemuValidateDomainDeviceDefAudio(virDomainAudioDef *audio,
break;
case VIR_DOMAIN_AUDIO_TYPE_SPICE:
if (!virDomainDefHasSpiceGraphics(def)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Spice audio is not supported without spice graphics"));
return -1;
}
break;
case VIR_DOMAIN_AUDIO_TYPE_FILE:
@ -5146,7 +5164,7 @@ qemuValidateDomainDeviceDef(const virDomainDeviceDef *dev,
return qemuValidateDomainSmartcardDef(dev->data.smartcard, def, qemuCaps);
case VIR_DOMAIN_DEVICE_RNG:
return qemuValidateDomainRNGDef(dev->data.rng, qemuCaps);
return qemuValidateDomainRNGDef(dev->data.rng, def, qemuCaps);
case VIR_DOMAIN_DEVICE_REDIRDEV:
return qemuValidateDomainRedirdevDef(dev->data.redirdev, def, qemuCaps);
@ -5206,7 +5224,7 @@ qemuValidateDomainDeviceDef(const virDomainDeviceDef *dev,
return qemuValidateDomainDeviceDefShmem(dev->data.shmem, qemuCaps);
case VIR_DOMAIN_DEVICE_AUDIO:
return qemuValidateDomainDeviceDefAudio(dev->data.audio, qemuCaps);
return qemuValidateDomainDeviceDefAudio(dev->data.audio, def, qemuCaps);
case VIR_DOMAIN_DEVICE_LEASE:
case VIR_DOMAIN_DEVICE_PANIC: