Currently the QEMU driver secretly sets the QEMU_AUDIO_DRV env variable
depending on how <graphics> are configured.
This introduces support for configuring audio backends from the <audio>
elements in the XML config.
The existing default behaviour is now only used if no <audio> element is
present.
All except the 'jack' audio driver are supported via QEMU's old env
variable config.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
src/libvirt_private.syms | 2 +
src/qemu/qemu_command.c | 158 +++++++++++++++---
src/qemu/qemu_validate.c | 55 +++++-
.../qemuxml2argvdata/audio-alsa-minimal.args | 29 ++++
tests/qemuxml2argvdata/audio-alsa-minimal.xml | 36 ++++
.../audio-coreaudio-minimal.args | 29 ++++
.../audio-coreaudio-minimal.xml | 36 ++++
.../qemuxml2argvdata/audio-file-minimal.args | 29 ++++
tests/qemuxml2argvdata/audio-file-minimal.xml | 36 ++++
tests/qemuxml2argvdata/audio-jack-minimal.err | 1 +
tests/qemuxml2argvdata/audio-jack-minimal.xml | 36 ++++
.../qemuxml2argvdata/audio-many-backends.err | 1 +
.../qemuxml2argvdata/audio-many-backends.xml | 60 +++++++
.../qemuxml2argvdata/audio-none-minimal.args | 29 ++++
tests/qemuxml2argvdata/audio-none-minimal.xml | 36 ++++
tests/qemuxml2argvdata/audio-oss-best.args | 31 ++++
tests/qemuxml2argvdata/audio-oss-best.xml | 39 +++++
tests/qemuxml2argvdata/audio-oss-minimal.args | 29 ++++
tests/qemuxml2argvdata/audio-oss-minimal.xml | 36 ++++
.../audio-pulseaudio-minimal.args | 29 ++++
.../audio-pulseaudio-minimal.xml | 36 ++++
tests/qemuxml2argvdata/audio-sdl-best.args | 30 ++++
tests/qemuxml2argvdata/audio-sdl-best.xml | 36 ++++
tests/qemuxml2argvdata/audio-sdl-minimal.args | 29 ++++
tests/qemuxml2argvdata/audio-sdl-minimal.xml | 36 ++++
.../qemuxml2argvdata/audio-spice-minimal.args | 29 ++++
.../qemuxml2argvdata/audio-spice-minimal.xml | 36 ++++
tests/qemuxml2argvtest.c | 18 ++
.../qemuxml2xmloutdata/audio-alsa-minimal.xml | 1 +
.../audio-coreaudio-minimal.xml | 1 +
.../qemuxml2xmloutdata/audio-file-minimal.xml | 1 +
.../qemuxml2xmloutdata/audio-none-minimal.xml | 1 +
tests/qemuxml2xmloutdata/audio-oss-best.xml | 1 +
.../qemuxml2xmloutdata/audio-oss-minimal.xml | 1 +
.../audio-pulseaudio-minimal.xml | 1 +
tests/qemuxml2xmloutdata/audio-sdl-best.xml | 1 +
.../qemuxml2xmloutdata/audio-sdl-minimal.xml | 1 +
.../audio-spice-minimal.xml | 1 +
tests/qemuxml2xmltest.c | 14 ++
39 files changed, 985 insertions(+), 26 deletions(-)
create mode 100644 tests/qemuxml2argvdata/audio-alsa-minimal.args
create mode 100644 tests/qemuxml2argvdata/audio-alsa-minimal.xml
create mode 100644 tests/qemuxml2argvdata/audio-coreaudio-minimal.args
create mode 100644 tests/qemuxml2argvdata/audio-coreaudio-minimal.xml
create mode 100644 tests/qemuxml2argvdata/audio-file-minimal.args
create mode 100644 tests/qemuxml2argvdata/audio-file-minimal.xml
create mode 100644 tests/qemuxml2argvdata/audio-jack-minimal.err
create mode 100644 tests/qemuxml2argvdata/audio-jack-minimal.xml
create mode 100644 tests/qemuxml2argvdata/audio-many-backends.err
create mode 100644 tests/qemuxml2argvdata/audio-many-backends.xml
create mode 100644 tests/qemuxml2argvdata/audio-none-minimal.args
create mode 100644 tests/qemuxml2argvdata/audio-none-minimal.xml
create mode 100644 tests/qemuxml2argvdata/audio-oss-best.args
create mode 100644 tests/qemuxml2argvdata/audio-oss-best.xml
create mode 100644 tests/qemuxml2argvdata/audio-oss-minimal.args
create mode 100644 tests/qemuxml2argvdata/audio-oss-minimal.xml
create mode 100644 tests/qemuxml2argvdata/audio-pulseaudio-minimal.args
create mode 100644 tests/qemuxml2argvdata/audio-pulseaudio-minimal.xml
create mode 100644 tests/qemuxml2argvdata/audio-sdl-best.args
create mode 100644 tests/qemuxml2argvdata/audio-sdl-best.xml
create mode 100644 tests/qemuxml2argvdata/audio-sdl-minimal.args
create mode 100644 tests/qemuxml2argvdata/audio-sdl-minimal.xml
create mode 100644 tests/qemuxml2argvdata/audio-spice-minimal.args
create mode 100644 tests/qemuxml2argvdata/audio-spice-minimal.xml
create mode 120000 tests/qemuxml2xmloutdata/audio-alsa-minimal.xml
create mode 120000 tests/qemuxml2xmloutdata/audio-coreaudio-minimal.xml
create mode 120000 tests/qemuxml2xmloutdata/audio-file-minimal.xml
create mode 120000 tests/qemuxml2xmloutdata/audio-none-minimal.xml
create mode 120000 tests/qemuxml2xmloutdata/audio-oss-best.xml
create mode 120000 tests/qemuxml2xmloutdata/audio-oss-minimal.xml
create mode 120000 tests/qemuxml2xmloutdata/audio-pulseaudio-minimal.xml
create mode 120000 tests/qemuxml2xmloutdata/audio-sdl-best.xml
create mode 120000 tests/qemuxml2xmloutdata/audio-sdl-minimal.xml
create mode 120000 tests/qemuxml2xmloutdata/audio-spice-minimal.xml
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 5af6339674..7c289e6f34 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -226,6 +226,8 @@ virDiskNameParse;
virDiskNameToBusDeviceIndex;
virDiskNameToIndex;
virDomainActualNetDefFree;
+virDomainAudioSDLDriverTypeFromString;
+virDomainAudioSDLDriverTypeToString;
virDomainAudioTypeTypeFromString;
virDomainAudioTypeTypeToString;
virDomainBlockedReasonTypeFromString;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 4785dfb791..8107e46036 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -177,6 +177,21 @@ VIR_ENUM_IMPL(qemuNumaPolicy,
"interleave",
);
+VIR_ENUM_DECL(qemuAudioDriver);
+VIR_ENUM_IMPL(qemuAudioDriver,
+ VIR_DOMAIN_AUDIO_TYPE_LAST,
+ "none",
+ "alsa",
+ "coreaudio",
+ "jack",
+ "oss",
+ "pa",
+ "sdl",
+ "spice",
+ "wav",
+);
+
+
/**
* qemuBuildMasterKeyCommandLine:
@@ -7543,11 +7558,90 @@ qemuBuildMemoryDeviceCommandLine(virCommandPtr cmd,
return 0;
}
+static void
+qemuBuildAudioOSSEnv(virCommandPtr cmd,
+ const char *prefix,
+ virDomainAudioIOOSS *def)
+{
+ if (def->dev)
+ virCommandAddEnvFormat(cmd, "%sDEV=%s",
+ prefix, def->dev);
+}
+
+static int
+qemuBuildAudioCommandLineEnv(virCommandPtr cmd,
+ virDomainDefPtr def)
+{
+ virDomainAudioDefPtr audio;
+ if (def->naudios != 1)
+ return 0;
+
+ audio = def->audios[0];
+ virCommandAddEnvPair(cmd, "QEMU_AUDIO_DRV",
+ qemuAudioDriverTypeToString(audio->type));
+
+ switch ((virDomainAudioType)audio->type) {
+ case VIR_DOMAIN_AUDIO_TYPE_NONE:
+ break;
+
+ case VIR_DOMAIN_AUDIO_TYPE_ALSA:
+ break;
+
+ case VIR_DOMAIN_AUDIO_TYPE_COREAUDIO:
+ break;
+
+ case VIR_DOMAIN_AUDIO_TYPE_JACK:
+ break;
+
+ case VIR_DOMAIN_AUDIO_TYPE_OSS:
+ qemuBuildAudioOSSEnv(cmd, "QEMU_OSS_ADC_",
&audio->backend.oss.input);
+ qemuBuildAudioOSSEnv(cmd, "QEMU_OSS_DAC_",
&audio->backend.oss.output);
+ break;
+
+ case VIR_DOMAIN_AUDIO_TYPE_PULSEAUDIO:
+ break;
+
+ case VIR_DOMAIN_AUDIO_TYPE_SDL:
+ if (audio->backend.sdl.driver) {
+ /*
+ * Some SDL audio driver names are different on SDL 1.2
+ * vs 2.0. Given how old SDL 1.2 is, we're not going
+ * make any attempt to support it here as it is unlikely
+ * to have an real world users. We can assume libvirt
+ * driver name strings match SDL 2.0 names.
+ */
+ virCommandAddEnvPair(cmd, "SDL_AUDIODRIVER",
+ virDomainAudioSDLDriverTypeToString(
+ audio->backend.sdl.driver));
+ }
+ break;
+ case VIR_DOMAIN_AUDIO_TYPE_SPICE:
+ break;
+
+ case VIR_DOMAIN_AUDIO_TYPE_FILE:
+ break;
+
+ case VIR_DOMAIN_AUDIO_TYPE_LAST:
+ default:
+ virReportEnumRangeError(virDomainAudioType, audio->type);
+ return -1;
+ }
+ return 0;
+}
+
+static int
+qemuBuildAudioCommandLine(virCommandPtr cmd,
+ virDomainDefPtr def)
+{
+ return qemuBuildAudioCommandLineEnv(cmd, def);
+}
+
static int
qemuBuildGraphicsSDLCommandLine(virQEMUDriverConfigPtr cfg G_GNUC_UNUSED,
virCommandPtr cmd,
virQEMUCapsPtr qemuCaps G_GNUC_UNUSED,
+ virDomainDefPtr def,
virDomainGraphicsDefPtr graphics)
{
g_auto(virBuffer) opt = VIR_BUFFER_INITIALIZER;
@@ -7559,12 +7653,14 @@ qemuBuildGraphicsSDLCommandLine(virQEMUDriverConfigPtr cfg
G_GNUC_UNUSED,
if (graphics->data.sdl.fullscreen)
virCommandAddArg(cmd, "-full-screen");
- /* If using SDL for video, then we should just let it
- * use QEMU's host audio drivers, possibly SDL too
- * User can set these two before starting libvirtd
- */
- virCommandAddEnvPass(cmd, "QEMU_AUDIO_DRV");
- virCommandAddEnvPass(cmd, "SDL_AUDIODRIVER");
+ if (def->naudios == 0) {
+ /* If using SDL for video, then we should just let it
+ * use QEMU's host audio drivers, possibly SDL too
+ * User can set these two before starting libvirtd
+ */
+ virCommandAddEnvPass(cmd, "QEMU_AUDIO_DRV");
+ virCommandAddEnvPass(cmd, "SDL_AUDIODRIVER");
+ }
virCommandAddArg(cmd, "-display");
virBufferAddLit(&opt, "sdl");
@@ -7583,6 +7679,7 @@ static int
qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr cfg,
virCommandPtr cmd,
virQEMUCapsPtr qemuCaps,
+ virDomainDefPtr def,
virDomainGraphicsDefPtr graphics)
{
g_auto(virBuffer) opt = VIR_BUFFER_INITIALIZER;
@@ -7703,14 +7800,16 @@ qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr cfg,
if (graphics->data.vnc.keymap)
virCommandAddArgList(cmd, "-k", graphics->data.vnc.keymap, NULL);
- /* Unless user requested it, set the audio backend to none, to
- * prevent it opening the host OS audio devices, since that causes
- * security issues and might not work when using VNC.
- */
- if (cfg->vncAllowHostAudio)
- virCommandAddEnvPass(cmd, "QEMU_AUDIO_DRV");
- else
- virCommandAddEnvString(cmd, "QEMU_AUDIO_DRV=none");
+ if (def->naudios == 0) {
+ /* Unless user requested it, set the audio backend to none, to
+ * prevent it opening the host OS audio devices, since that causes
+ * security issues and might not work when using VNC.
+ */
+ if (cfg->vncAllowHostAudio)
+ virCommandAddEnvPass(cmd, "QEMU_AUDIO_DRV");
+ else
+ virCommandAddEnvString(cmd, "QEMU_AUDIO_DRV=none");
+ }
return 0;
}
@@ -7719,6 +7818,7 @@ qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr cfg,
static int
qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg,
virCommandPtr cmd,
+ virDomainDefPtr def,
virDomainGraphicsDefPtr graphics)
{
g_auto(virBuffer) opt = VIR_BUFFER_INITIALIZER;
@@ -7916,10 +8016,13 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg,
if (graphics->data.spice.keymap)
virCommandAddArgList(cmd, "-k",
graphics->data.spice.keymap, NULL);
- /* SPICE includes native support for tunnelling audio, so we
- * set the audio backend to point at SPICE's own driver
- */
- virCommandAddEnvString(cmd, "QEMU_AUDIO_DRV=spice");
+
+ if (def->naudios == 0) {
+ /* SPICE includes native support for tunnelling audio, so we
+ * set the audio backend to point at SPICE's own driver
+ */
+ virCommandAddEnvString(cmd, "QEMU_AUDIO_DRV=spice");
+ }
return 0;
}
@@ -7961,19 +8064,19 @@ qemuBuildGraphicsCommandLine(virQEMUDriverConfigPtr cfg,
switch (graphics->type) {
case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
if (qemuBuildGraphicsSDLCommandLine(cfg, cmd,
- qemuCaps, graphics) < 0)
+ qemuCaps, def, graphics) < 0)
return -1;
break;
case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
if (qemuBuildGraphicsVNCCommandLine(cfg, cmd,
- qemuCaps, graphics) < 0)
+ qemuCaps, def, graphics) < 0)
return -1;
break;
case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
if (qemuBuildGraphicsSPICECommandLine(cfg, cmd,
- graphics) < 0)
+ def, graphics) < 0)
return -1;
break;
@@ -9972,10 +10075,12 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
virCommandAddArg(cmd, "-display");
virCommandAddArg(cmd, "none");
- if (cfg->nogfxAllowHostAudio)
- virCommandAddEnvPass(cmd, "QEMU_AUDIO_DRV");
- else
- virCommandAddEnvString(cmd, "QEMU_AUDIO_DRV=none");
+ if (def->naudios == 0) {
+ if (cfg->nogfxAllowHostAudio)
+ virCommandAddEnvPass(cmd, "QEMU_AUDIO_DRV");
+ else
+ virCommandAddEnvString(cmd, "QEMU_AUDIO_DRV=none");
+ }
}
/* Disable global config files and default devices */
@@ -10050,6 +10155,9 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
if (qemuBuildInputCommandLine(cmd, def, qemuCaps) < 0)
return NULL;
+ if (qemuBuildAudioCommandLine(cmd, def) < 0)
+ return NULL;
+
if (qemuBuildGraphicsCommandLine(cfg, cmd, def, qemuCaps) < 0)
return NULL;
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index d24300b305..ba3ef9067a 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -1228,6 +1228,12 @@ qemuValidateDomainDef(const virDomainDef *def,
return -1;
}
+ if (def->naudios > 1) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("only one audio backend is supported with this QEMU
binary"));
+ return -1;
+ }
+
return 0;
}
@@ -4145,6 +4151,50 @@ qemuValidateDomainDeviceDefFS(virDomainFSDefPtr fs,
}
+static int
+qemuValidateDomainDeviceDefAudio(virDomainAudioDefPtr audio,
+ virQEMUCapsPtr qemuCaps G_GNUC_UNUSED)
+{
+ switch ((virDomainAudioType)audio->type) {
+ case VIR_DOMAIN_AUDIO_TYPE_NONE:
+ break;
+
+ case VIR_DOMAIN_AUDIO_TYPE_ALSA:
+ break;
+
+ case VIR_DOMAIN_AUDIO_TYPE_COREAUDIO:
+ break;
+
+ case VIR_DOMAIN_AUDIO_TYPE_JACK:
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("'jack' audio backend is not supported with this
QEMU"));
+ return -1;
+
+ case VIR_DOMAIN_AUDIO_TYPE_OSS:
+ break;
+
+ case VIR_DOMAIN_AUDIO_TYPE_PULSEAUDIO:
+ break;
+
+ case VIR_DOMAIN_AUDIO_TYPE_SDL:
+ break;
+
+ case VIR_DOMAIN_AUDIO_TYPE_SPICE:
+ break;
+
+ case VIR_DOMAIN_AUDIO_TYPE_FILE:
+ break;
+
+ case VIR_DOMAIN_AUDIO_TYPE_LAST:
+ default:
+ virReportEnumRangeError(virDomainAudioType, audio->type);
+ return -1;
+ }
+
+ return 0;
+}
+
+
static int
qemuSoundCodecTypeToCaps(int type)
{
@@ -4838,9 +4888,12 @@ qemuValidateDomainDeviceDef(const virDomainDeviceDef *dev,
ret = qemuValidateDomainDeviceDefShmem(dev->data.shmem, qemuCaps);
break;
+ case VIR_DOMAIN_DEVICE_AUDIO:
+ ret = qemuValidateDomainDeviceDefAudio(dev->data.audio, qemuCaps);
+ break;
+
case VIR_DOMAIN_DEVICE_LEASE:
case VIR_DOMAIN_DEVICE_PANIC:
- case VIR_DOMAIN_DEVICE_AUDIO:
case VIR_DOMAIN_DEVICE_NONE:
case VIR_DOMAIN_DEVICE_LAST:
break;
diff --git a/tests/qemuxml2argvdata/audio-alsa-minimal.args
b/tests/qemuxml2argvdata/audio-alsa-minimal.args
new file mode 100644
index 0000000000..01fe6e2beb
--- /dev/null
+++ b/tests/qemuxml2argvdata/audio-alsa-minimal.args
@@ -0,0 +1,29 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/tmp/lib/domain--1-QEMUGuest1 \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \
+XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \
+XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
+QEMU_AUDIO_DRV=alsa \
+/usr/bin/qemu-system-i386 \
+-name QEMUGuest1 \
+-S \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
+-m 214 \
+-realtime mlock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
+server=on,wait=off \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-usb \
+-drive file=/dev/cdrom,format=raw,if=none,id=drive-ide0-1-0,readonly=on \
+-device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0,bootindex=1
diff --git a/tests/qemuxml2argvdata/audio-alsa-minimal.xml
b/tests/qemuxml2argvdata/audio-alsa-minimal.xml
new file mode 100644
index 0000000000..ab26688317
--- /dev/null
+++ b/tests/qemuxml2argvdata/audio-alsa-minimal.xml
@@ -0,0 +1,36 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='cdrom'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i386</emulator>
+ <disk type='block' device='cdrom'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/cdrom'/>
+ <target dev='hdc' bus='ide'/>
+ <readonly/>
+ <address type='drive' controller='0' bus='1'
target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x2'/>
+ </controller>
+ <controller type='ide' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x1'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <audio id='1' type='alsa'/>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/audio-coreaudio-minimal.args
b/tests/qemuxml2argvdata/audio-coreaudio-minimal.args
new file mode 100644
index 0000000000..c4d502b889
--- /dev/null
+++ b/tests/qemuxml2argvdata/audio-coreaudio-minimal.args
@@ -0,0 +1,29 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/tmp/lib/domain--1-QEMUGuest1 \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \
+XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \
+XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
+QEMU_AUDIO_DRV=coreaudio \
+/usr/bin/qemu-system-i386 \
+-name QEMUGuest1 \
+-S \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
+-m 214 \
+-realtime mlock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
+server=on,wait=off \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-usb \
+-drive file=/dev/cdrom,format=raw,if=none,id=drive-ide0-1-0,readonly=on \
+-device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0,bootindex=1
diff --git a/tests/qemuxml2argvdata/audio-coreaudio-minimal.xml
b/tests/qemuxml2argvdata/audio-coreaudio-minimal.xml
new file mode 100644
index 0000000000..f271e995ff
--- /dev/null
+++ b/tests/qemuxml2argvdata/audio-coreaudio-minimal.xml
@@ -0,0 +1,36 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='cdrom'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i386</emulator>
+ <disk type='block' device='cdrom'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/cdrom'/>
+ <target dev='hdc' bus='ide'/>
+ <readonly/>
+ <address type='drive' controller='0' bus='1'
target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x2'/>
+ </controller>
+ <controller type='ide' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x1'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <audio id='1' type='coreaudio'/>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/audio-file-minimal.args
b/tests/qemuxml2argvdata/audio-file-minimal.args
new file mode 100644
index 0000000000..fd504f50e7
--- /dev/null
+++ b/tests/qemuxml2argvdata/audio-file-minimal.args
@@ -0,0 +1,29 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/tmp/lib/domain--1-QEMUGuest1 \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \
+XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \
+XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
+QEMU_AUDIO_DRV=wav \
+/usr/bin/qemu-system-i386 \
+-name QEMUGuest1 \
+-S \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
+-m 214 \
+-realtime mlock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
+server=on,wait=off \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-usb \
+-drive file=/dev/cdrom,format=raw,if=none,id=drive-ide0-1-0,readonly=on \
+-device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0,bootindex=1
diff --git a/tests/qemuxml2argvdata/audio-file-minimal.xml
b/tests/qemuxml2argvdata/audio-file-minimal.xml
new file mode 100644
index 0000000000..3091b94cf3
--- /dev/null
+++ b/tests/qemuxml2argvdata/audio-file-minimal.xml
@@ -0,0 +1,36 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='cdrom'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i386</emulator>
+ <disk type='block' device='cdrom'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/cdrom'/>
+ <target dev='hdc' bus='ide'/>
+ <readonly/>
+ <address type='drive' controller='0' bus='1'
target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x2'/>
+ </controller>
+ <controller type='ide' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x1'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <audio id='1' type='file'/>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/audio-jack-minimal.err
b/tests/qemuxml2argvdata/audio-jack-minimal.err
new file mode 100644
index 0000000000..0747113933
--- /dev/null
+++ b/tests/qemuxml2argvdata/audio-jack-minimal.err
@@ -0,0 +1 @@
+unsupported configuration: 'jack' audio backend is not supported with this QEMU
diff --git a/tests/qemuxml2argvdata/audio-jack-minimal.xml
b/tests/qemuxml2argvdata/audio-jack-minimal.xml
new file mode 100644
index 0000000000..d88d066008
--- /dev/null
+++ b/tests/qemuxml2argvdata/audio-jack-minimal.xml
@@ -0,0 +1,36 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='cdrom'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i386</emulator>
+ <disk type='block' device='cdrom'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/cdrom'/>
+ <target dev='hdc' bus='ide'/>
+ <readonly/>
+ <address type='drive' controller='0' bus='1'
target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x2'/>
+ </controller>
+ <controller type='ide' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x1'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <audio id='1' type='jack'/>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/audio-many-backends.err
b/tests/qemuxml2argvdata/audio-many-backends.err
new file mode 100644
index 0000000000..19b69e8b95
--- /dev/null
+++ b/tests/qemuxml2argvdata/audio-many-backends.err
@@ -0,0 +1 @@
+unsupported configuration: only one audio backend is supported with this QEMU binary
diff --git a/tests/qemuxml2argvdata/audio-many-backends.xml
b/tests/qemuxml2argvdata/audio-many-backends.xml
new file mode 100644
index 0000000000..86eef90e52
--- /dev/null
+++ b/tests/qemuxml2argvdata/audio-many-backends.xml
@@ -0,0 +1,60 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='cdrom'/>
+ </os>
+ <cpu mode='custom' match='exact' check='none'>
+ <model fallback='forbid'>qemu64</model>
+ </cpu>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i386</emulator>
+ <disk type='block' device='cdrom'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/cdrom'/>
+ <target dev='hdc' bus='ide'/>
+ <readonly/>
+ <address type='drive' controller='0' bus='1'
target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0' model='piix3-uhci'>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x2'/>
+ </controller>
+ <controller type='ide' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x1'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <graphics type='vnc' port='-1' autoport='yes'>
+ <listen type='address'/>
+ <audio id='2'/>
+ </graphics>
+ <sound model='ac97'>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x03' function='0x0'/>
+ </sound>
+ <sound model='ich6'>
+ <audio id='2'/>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x04' function='0x0'/>
+ </sound>
+ <sound model='es1370'>
+ <audio id='3'/>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x05' function='0x0'/>
+ </sound>
+ <audio id='1' type='none'/>
+ <audio id='2' type='alsa'/>
+ <audio id='3' type='pulseaudio'/>
+ <video>
+ <model type='cirrus' vram='16384' heads='1'
primary='yes'/>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x02' function='0x0'/>
+ </video>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/audio-none-minimal.args
b/tests/qemuxml2argvdata/audio-none-minimal.args
new file mode 100644
index 0000000000..00c6e37ccc
--- /dev/null
+++ b/tests/qemuxml2argvdata/audio-none-minimal.args
@@ -0,0 +1,29 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/tmp/lib/domain--1-QEMUGuest1 \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \
+XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \
+XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-i386 \
+-name QEMUGuest1 \
+-S \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
+-m 214 \
+-realtime mlock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
+server=on,wait=off \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-usb \
+-drive file=/dev/cdrom,format=raw,if=none,id=drive-ide0-1-0,readonly=on \
+-device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0,bootindex=1
diff --git a/tests/qemuxml2argvdata/audio-none-minimal.xml
b/tests/qemuxml2argvdata/audio-none-minimal.xml
new file mode 100644
index 0000000000..4729edaa63
--- /dev/null
+++ b/tests/qemuxml2argvdata/audio-none-minimal.xml
@@ -0,0 +1,36 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='cdrom'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i386</emulator>
+ <disk type='block' device='cdrom'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/cdrom'/>
+ <target dev='hdc' bus='ide'/>
+ <readonly/>
+ <address type='drive' controller='0' bus='1'
target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x2'/>
+ </controller>
+ <controller type='ide' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x1'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <audio id='1' type='none'/>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/audio-oss-best.args
b/tests/qemuxml2argvdata/audio-oss-best.args
new file mode 100644
index 0000000000..e6a7bb4af8
--- /dev/null
+++ b/tests/qemuxml2argvdata/audio-oss-best.args
@@ -0,0 +1,31 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/tmp/lib/domain--1-QEMUGuest1 \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \
+XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \
+XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
+QEMU_AUDIO_DRV=oss \
+QEMU_OSS_ADC_DEV=/dev/dsp0 \
+QEMU_OSS_DAC_DEV=/dev/dsp1 \
+/usr/bin/qemu-system-i386 \
+-name QEMUGuest1 \
+-S \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
+-m 214 \
+-realtime mlock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
+server=on,wait=off \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-usb \
+-drive file=/dev/cdrom,format=raw,if=none,id=drive-ide0-1-0,readonly=on \
+-device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0,bootindex=1
diff --git a/tests/qemuxml2argvdata/audio-oss-best.xml
b/tests/qemuxml2argvdata/audio-oss-best.xml
new file mode 100644
index 0000000000..0947bd6def
--- /dev/null
+++ b/tests/qemuxml2argvdata/audio-oss-best.xml
@@ -0,0 +1,39 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='cdrom'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i386</emulator>
+ <disk type='block' device='cdrom'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/cdrom'/>
+ <target dev='hdc' bus='ide'/>
+ <readonly/>
+ <address type='drive' controller='0' bus='1'
target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x2'/>
+ </controller>
+ <controller type='ide' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x1'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <audio id='1' type='oss'>
+ <input dev='/dev/dsp0'/>
+ <output dev='/dev/dsp1'/>
+ </audio>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/audio-oss-minimal.args
b/tests/qemuxml2argvdata/audio-oss-minimal.args
new file mode 100644
index 0000000000..53c632e6d9
--- /dev/null
+++ b/tests/qemuxml2argvdata/audio-oss-minimal.args
@@ -0,0 +1,29 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/tmp/lib/domain--1-QEMUGuest1 \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \
+XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \
+XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
+QEMU_AUDIO_DRV=oss \
+/usr/bin/qemu-system-i386 \
+-name QEMUGuest1 \
+-S \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
+-m 214 \
+-realtime mlock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
+server=on,wait=off \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-usb \
+-drive file=/dev/cdrom,format=raw,if=none,id=drive-ide0-1-0,readonly=on \
+-device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0,bootindex=1
diff --git a/tests/qemuxml2argvdata/audio-oss-minimal.xml
b/tests/qemuxml2argvdata/audio-oss-minimal.xml
new file mode 100644
index 0000000000..abddc1ac8c
--- /dev/null
+++ b/tests/qemuxml2argvdata/audio-oss-minimal.xml
@@ -0,0 +1,36 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='cdrom'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i386</emulator>
+ <disk type='block' device='cdrom'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/cdrom'/>
+ <target dev='hdc' bus='ide'/>
+ <readonly/>
+ <address type='drive' controller='0' bus='1'
target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x2'/>
+ </controller>
+ <controller type='ide' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x1'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <audio id='1' type='oss'/>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/audio-pulseaudio-minimal.args
b/tests/qemuxml2argvdata/audio-pulseaudio-minimal.args
new file mode 100644
index 0000000000..af274e4328
--- /dev/null
+++ b/tests/qemuxml2argvdata/audio-pulseaudio-minimal.args
@@ -0,0 +1,29 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/tmp/lib/domain--1-QEMUGuest1 \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \
+XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \
+XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
+QEMU_AUDIO_DRV=pa \
+/usr/bin/qemu-system-i386 \
+-name QEMUGuest1 \
+-S \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
+-m 214 \
+-realtime mlock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
+server=on,wait=off \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-usb \
+-drive file=/dev/cdrom,format=raw,if=none,id=drive-ide0-1-0,readonly=on \
+-device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0,bootindex=1
diff --git a/tests/qemuxml2argvdata/audio-pulseaudio-minimal.xml
b/tests/qemuxml2argvdata/audio-pulseaudio-minimal.xml
new file mode 100644
index 0000000000..013b708498
--- /dev/null
+++ b/tests/qemuxml2argvdata/audio-pulseaudio-minimal.xml
@@ -0,0 +1,36 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='cdrom'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i386</emulator>
+ <disk type='block' device='cdrom'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/cdrom'/>
+ <target dev='hdc' bus='ide'/>
+ <readonly/>
+ <address type='drive' controller='0' bus='1'
target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x2'/>
+ </controller>
+ <controller type='ide' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x1'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <audio id='1' type='pulseaudio'/>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/audio-sdl-best.args
b/tests/qemuxml2argvdata/audio-sdl-best.args
new file mode 100644
index 0000000000..6aca7037a8
--- /dev/null
+++ b/tests/qemuxml2argvdata/audio-sdl-best.args
@@ -0,0 +1,30 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/tmp/lib/domain--1-QEMUGuest1 \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \
+XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \
+XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
+QEMU_AUDIO_DRV=sdl \
+SDL_AUDIODRIVER=pulseaudio \
+/usr/bin/qemu-system-i386 \
+-name QEMUGuest1 \
+-S \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
+-m 214 \
+-realtime mlock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
+server=on,wait=off \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-usb \
+-drive file=/dev/cdrom,format=raw,if=none,id=drive-ide0-1-0,readonly=on \
+-device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0,bootindex=1
diff --git a/tests/qemuxml2argvdata/audio-sdl-best.xml
b/tests/qemuxml2argvdata/audio-sdl-best.xml
new file mode 100644
index 0000000000..d6835a22bc
--- /dev/null
+++ b/tests/qemuxml2argvdata/audio-sdl-best.xml
@@ -0,0 +1,36 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='cdrom'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i386</emulator>
+ <disk type='block' device='cdrom'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/cdrom'/>
+ <target dev='hdc' bus='ide'/>
+ <readonly/>
+ <address type='drive' controller='0' bus='1'
target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x2'/>
+ </controller>
+ <controller type='ide' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x1'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <audio id='1' type='sdl' driver='pulseaudio'/>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/audio-sdl-minimal.args
b/tests/qemuxml2argvdata/audio-sdl-minimal.args
new file mode 100644
index 0000000000..126c36ba7e
--- /dev/null
+++ b/tests/qemuxml2argvdata/audio-sdl-minimal.args
@@ -0,0 +1,29 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/tmp/lib/domain--1-QEMUGuest1 \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \
+XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \
+XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
+QEMU_AUDIO_DRV=sdl \
+/usr/bin/qemu-system-i386 \
+-name QEMUGuest1 \
+-S \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
+-m 214 \
+-realtime mlock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
+server=on,wait=off \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-usb \
+-drive file=/dev/cdrom,format=raw,if=none,id=drive-ide0-1-0,readonly=on \
+-device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0,bootindex=1
diff --git a/tests/qemuxml2argvdata/audio-sdl-minimal.xml
b/tests/qemuxml2argvdata/audio-sdl-minimal.xml
new file mode 100644
index 0000000000..223e06196d
--- /dev/null
+++ b/tests/qemuxml2argvdata/audio-sdl-minimal.xml
@@ -0,0 +1,36 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='cdrom'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i386</emulator>
+ <disk type='block' device='cdrom'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/cdrom'/>
+ <target dev='hdc' bus='ide'/>
+ <readonly/>
+ <address type='drive' controller='0' bus='1'
target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x2'/>
+ </controller>
+ <controller type='ide' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x1'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <audio id='1' type='sdl'/>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/audio-spice-minimal.args
b/tests/qemuxml2argvdata/audio-spice-minimal.args
new file mode 100644
index 0000000000..a7a85959d6
--- /dev/null
+++ b/tests/qemuxml2argvdata/audio-spice-minimal.args
@@ -0,0 +1,29 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/tmp/lib/domain--1-QEMUGuest1 \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \
+XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \
+XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
+QEMU_AUDIO_DRV=spice \
+/usr/bin/qemu-system-i386 \
+-name QEMUGuest1 \
+-S \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
+-m 214 \
+-realtime mlock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
+server=on,wait=off \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-usb \
+-drive file=/dev/cdrom,format=raw,if=none,id=drive-ide0-1-0,readonly=on \
+-device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0,bootindex=1
diff --git a/tests/qemuxml2argvdata/audio-spice-minimal.xml
b/tests/qemuxml2argvdata/audio-spice-minimal.xml
new file mode 100644
index 0000000000..eecae5ad12
--- /dev/null
+++ b/tests/qemuxml2argvdata/audio-spice-minimal.xml
@@ -0,0 +1,36 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='cdrom'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i386</emulator>
+ <disk type='block' device='cdrom'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/cdrom'/>
+ <target dev='hdc' bus='ide'/>
+ <readonly/>
+ <address type='drive' controller='0' bus='1'
target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x2'/>
+ </controller>
+ <controller type='ide' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x1'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <audio id='1' type='spice'/>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index d6d707cd24..b7be131792 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1043,6 +1043,24 @@ mymain(void)
QEMU_CAPS_BOOT_STRICT,
QEMU_CAPS_VIRTIO_BLK_SCSI);
+ /* Simplest possible <audio>, all supported with ENV */
+ DO_TEST("audio-none-minimal", NONE);
+ DO_TEST("audio-alsa-minimal", NONE);
+ DO_TEST("audio-coreaudio-minimal", NONE);
+ DO_TEST_PARSE_ERROR("audio-jack-minimal", NONE);
+ DO_TEST("audio-oss-minimal", NONE);
+ DO_TEST("audio-pulseaudio-minimal", NONE);
+ DO_TEST("audio-sdl-minimal", NONE);
+ DO_TEST("audio-spice-minimal", NONE);
+ DO_TEST("audio-file-minimal", NONE);
+
+ /* Best <audio> still compat with old ENV */
+ DO_TEST("audio-oss-best", NONE);
+ DO_TEST("audio-sdl-best", NONE);
+
+ /* Multiple backends not supported with ENV */
+ DO_TEST_PARSE_ERROR("audio-many-backends", NONE);
+
DO_TEST("reboot-timeout-disabled", QEMU_CAPS_REBOOT_TIMEOUT);
DO_TEST("reboot-timeout-enabled", QEMU_CAPS_REBOOT_TIMEOUT);
DO_TEST_PARSE_ERROR("reboot-timeout-enabled", NONE);
diff --git a/tests/qemuxml2xmloutdata/audio-alsa-minimal.xml
b/tests/qemuxml2xmloutdata/audio-alsa-minimal.xml
new file mode 120000
index 0000000000..c4f64da11f
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/audio-alsa-minimal.xml
@@ -0,0 +1 @@
+../qemuxml2argvdata/audio-alsa-minimal.xml
\ No newline at end of file
diff --git a/tests/qemuxml2xmloutdata/audio-coreaudio-minimal.xml
b/tests/qemuxml2xmloutdata/audio-coreaudio-minimal.xml
new file mode 120000
index 0000000000..3d3078850f
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/audio-coreaudio-minimal.xml
@@ -0,0 +1 @@
+../qemuxml2argvdata/audio-coreaudio-minimal.xml
\ No newline at end of file
diff --git a/tests/qemuxml2xmloutdata/audio-file-minimal.xml
b/tests/qemuxml2xmloutdata/audio-file-minimal.xml
new file mode 120000
index 0000000000..0b187008a6
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/audio-file-minimal.xml
@@ -0,0 +1 @@
+../qemuxml2argvdata/audio-file-minimal.xml
\ No newline at end of file
diff --git a/tests/qemuxml2xmloutdata/audio-none-minimal.xml
b/tests/qemuxml2xmloutdata/audio-none-minimal.xml
new file mode 120000
index 0000000000..ce0a93c3e4
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/audio-none-minimal.xml
@@ -0,0 +1 @@
+../qemuxml2argvdata/audio-none-minimal.xml
\ No newline at end of file
diff --git a/tests/qemuxml2xmloutdata/audio-oss-best.xml
b/tests/qemuxml2xmloutdata/audio-oss-best.xml
new file mode 120000
index 0000000000..e716f61f72
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/audio-oss-best.xml
@@ -0,0 +1 @@
+../qemuxml2argvdata/audio-oss-best.xml
\ No newline at end of file
diff --git a/tests/qemuxml2xmloutdata/audio-oss-minimal.xml
b/tests/qemuxml2xmloutdata/audio-oss-minimal.xml
new file mode 120000
index 0000000000..d30a208e69
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/audio-oss-minimal.xml
@@ -0,0 +1 @@
+../qemuxml2argvdata/audio-oss-minimal.xml
\ No newline at end of file
diff --git a/tests/qemuxml2xmloutdata/audio-pulseaudio-minimal.xml
b/tests/qemuxml2xmloutdata/audio-pulseaudio-minimal.xml
new file mode 120000
index 0000000000..9cba6b5f00
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/audio-pulseaudio-minimal.xml
@@ -0,0 +1 @@
+../qemuxml2argvdata/audio-pulseaudio-minimal.xml
\ No newline at end of file
diff --git a/tests/qemuxml2xmloutdata/audio-sdl-best.xml
b/tests/qemuxml2xmloutdata/audio-sdl-best.xml
new file mode 120000
index 0000000000..0c90810974
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/audio-sdl-best.xml
@@ -0,0 +1 @@
+../qemuxml2argvdata/audio-sdl-best.xml
\ No newline at end of file
diff --git a/tests/qemuxml2xmloutdata/audio-sdl-minimal.xml
b/tests/qemuxml2xmloutdata/audio-sdl-minimal.xml
new file mode 120000
index 0000000000..787b220f0a
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/audio-sdl-minimal.xml
@@ -0,0 +1 @@
+../qemuxml2argvdata/audio-sdl-minimal.xml
\ No newline at end of file
diff --git a/tests/qemuxml2xmloutdata/audio-spice-minimal.xml
b/tests/qemuxml2xmloutdata/audio-spice-minimal.xml
new file mode 120000
index 0000000000..5f07fd844a
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/audio-spice-minimal.xml
@@ -0,0 +1 @@
+../qemuxml2argvdata/audio-spice-minimal.xml
\ No newline at end of file
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 01ac5886f2..03ab424e1a 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -1463,6 +1463,20 @@ mymain(void)
DO_TEST_CAPS_LATEST("virtio-9p-createmode");
DO_TEST("downscript", NONE);
+ /* Simplest possible <audio>, all supported with ENV */
+ DO_TEST("audio-none-minimal", NONE);
+ DO_TEST("audio-alsa-minimal", NONE);
+ DO_TEST("audio-coreaudio-minimal", NONE);
+ DO_TEST("audio-oss-minimal", NONE);
+ DO_TEST("audio-pulseaudio-minimal", NONE);
+ DO_TEST("audio-sdl-minimal", NONE);
+ DO_TEST("audio-spice-minimal", NONE);
+ DO_TEST("audio-file-minimal", NONE);
+
+ /* Best <audio> still compat with old ENV */
+ DO_TEST("audio-oss-best", NONE);
+ DO_TEST("audio-sdl-best", NONE);
+
cleanup:
if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
virFileDeleteTree(fakerootdir);
--
2.29.2