Disk serial is not a property of the image but of the disk frontend.
Account for this appropriately.
---
src/qemu/qemu_command.c | 17 +++++++++--------
.../qemuxml2argv-disk-drive-shared.args | 5 +++--
tests/qemuxml2argvdata/qemuxml2argv-disk-ide-wwn.args | 5 ++---
tests/qemuxml2argvdata/qemuxml2argv-disk-serial.args | 8 ++++----
4 files changed, 18 insertions(+), 17 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 8c7bb245ed..49fd05034b 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1611,6 +1611,7 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk,
static void
qemuBuildDiskFrontendAttributes(virDomainDiskDefPtr disk,
+ virQEMUCapsPtr qemuCaps,
virBufferPtr buf)
{
/* generate geometry command string */
@@ -1626,6 +1627,12 @@ qemuBuildDiskFrontendAttributes(virDomainDiskDefPtr disk,
virBufferAsprintf(buf, ",trans=%s",
virDomainDiskGeometryTransTypeToString(disk->geometry.trans));
}
+
+ if (disk->serial &&
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_SERIAL)) {
+ virBufferAddLit(buf, ",serial=");
+ virBufferEscape(buf, '\\', " ", "%s",
disk->serial);
+ }
}
@@ -1690,13 +1697,7 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
virBufferAddLit(&opt, ",readonly=on");
if (!emitDeviceSyntax)
- qemuBuildDiskFrontendAttributes(disk, &opt);
-
- if (disk->serial &&
- virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_SERIAL)) {
- virBufferAddLit(&opt, ",serial=");
- virBufferEscape(&opt, '\\', " ", "%s",
disk->serial);
- }
+ qemuBuildDiskFrontendAttributes(disk, qemuCaps, &opt);
if (disk->cachemode) {
virBufferAsprintf(&opt, ",cache=%s",
@@ -2125,7 +2126,7 @@ qemuBuildDriveDevStr(const virDomainDef *def,
disk->blockio.physical_block_size);
}
- qemuBuildDiskFrontendAttributes(disk, &opt);
+ qemuBuildDiskFrontendAttributes(disk, qemuCaps, &opt);
if (disk->wwn) {
if (STRPREFIX(disk->wwn, "0x"))
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared.args
b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared.args
index 502157bf8c..2bcb875931 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared.args
@@ -20,8 +20,9 @@ server,nowait \
-boot c \
-usb \
-drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-ide0-0-0,\
-serial=XYZXYZXYZYXXYZYZYXYZY,cache=none \
--device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
+cache=none \
+-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,\
+serial=XYZXYZXYZYXXYZYZYXYZY \
-drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,media=cdrom,\
id=drive-ide0-1-0,readonly=on \
-device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-ide-wwn.args
b/tests/qemuxml2argvdata/qemuxml2argv-disk-ide-wwn.args
index f2fb372a2a..b6138c9537 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-ide-wwn.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-ide-wwn.args
@@ -19,8 +19,7 @@ server,nowait \
-no-acpi \
-boot c \
-usb \
--drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-1,\
-serial=WD-WMAP9A966149 \
+-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-1 \
-device ide-hd,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1,\
-wwn=0x5000c50015ea71ad \
+serial=WD-WMAP9A966149,wwn=0x5000c50015ea71ad \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-serial.args
b/tests/qemuxml2argvdata/qemuxml2argv-disk-serial.args
index 18acb4f7af..0a0171a067 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-serial.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-serial.args
@@ -19,11 +19,11 @@ server,nowait \
-no-acpi \
-boot c \
-usb \
--drive 'file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-1,\
+-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-1 \
+-device 'ide-drive,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1,\
serial=\ \ WD-WMAP9A966149' \
--device ide-drive,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1 \
--drive 'file=/dev/HostVG/AllSerialChars,format=raw,if=none,id=drive-ide0-0-2,\
+-drive file=/dev/HostVG/AllSerialChars,format=raw,if=none,id=drive-ide0-0-2 \
+-device 'ide-drive,bus=ide.0,unit=2,drive=drive-ide0-0-2,id=ide0-0-2,\
serial=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_\ .+' \
--device ide-drive,bus=ide.0,unit=2,drive=drive-ide0-0-2,id=ide0-0-2 \
-drive file=/some/file,format=raw,if=sd,index=0,serial=sdserial \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
--
2.14.3