diff --git a/docs/schemas/basictypes.rng b/docs/schemas/basictypes.rng
index adaedd8794..34c2254330 100644
--- a/docs/schemas/basictypes.rng
+++ b/docs/schemas/basictypes.rng
@@ -280,7 +280,7 @@
- [0-9a-fA-F]{16}
+ (0x)?[0-9a-fA-F]{16}
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 63b9350c2b..009d42d452 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3358,8 +3358,12 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
disk->blockio.physical_block_size);
}
- if (disk->wwn)
- virBufferAsprintf(&opt, ",wwn=%s", disk->wwn);
+ if (disk->wwn) {
+ if (STRPREFIX(disk->wwn, "0x"))
+ virBufferAsprintf(&opt, ",wwn=%s", disk->wwn);
+ else
+ virBufferAsprintf(&opt, ",wwn=0x%s", disk->wwn);
+ }
if (disk->vendor)
virBufferAsprintf(&opt, ",vendor=%s", disk->vendor);
diff --git a/src/util/virutil.c b/src/util/virutil.c
index 0e4063b2a7..6890362890 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -3228,12 +3228,18 @@ bool virIsDevMapperDevice(const char *dev_name ATTRIBUTE_UNUSED)
bool
virValidateWWN(const char *wwn) {
int i;
+ const char *p = wwn;
- for (i = 0; wwn[i]; i++)
- if (!c_isxdigit(wwn[i]))
+ if (STRPREFIX(wwn, "0x")) {
+ p += 2;
+ }
+
+ for (i = 0; p[i]; i++) {
+ if (!c_isxdigit(p[i]))
break;
+ }
- if (i != 16 || wwn[i]) {
+ if (i != 16 || p[i]) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Malformed wwn: %s"));
return false;
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-ide-wwn.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-ide-wwn.args
index 1633d29c38..3b9693cc6d 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-ide-wwn.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-ide-wwn.args
@@ -2,5 +2,5 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test \
/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefaults \
-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \
-drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-ide0-0-1,serial=WD-WMAP9A966149 \
--device ide-hd,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1,wwn=5000c50015ea71ad \
+-device ide-hd,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1,wwn=0x5000c50015ea71ad \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-wwn.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-wwn.args
index 0393640cbd..0dd2aa9d83 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-wwn.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-wwn.args
@@ -5,7 +5,7 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test \
-device lsi,id=scsi1,bus=pci.0,addr=0x4 \
-usb \
-drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-scsi0-0-1-0 \
--device scsi-cd,bus=scsi0.0,channel=0,scsi-id=1,lun=0,drive=drive-scsi0-0-1-0,id=scsi0-0-1-0,wwn=5000c50015ea71ac \
+-device scsi-cd,bus=scsi0.0,channel=0,scsi-id=1,lun=0,drive=drive-scsi0-0-1-0,id=scsi0-0-1-0,wwn=0x5000c50015ea71ac \
-drive file=/dev/HostVG/QEMUGuest2,if=none,id=drive-scsi0-0-0-0 \
--device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi0-0-0-0,id=scsi0-0-0-0,wwn=5000c50015ea71ad \
+-device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi0-0-0-0,id=scsi0-0-0-0,wwn=0x5000c50015ea71ad \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-wwn.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-wwn.xml
index dc355484bd..caf957b66b 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-wwn.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-wwn.xml
@@ -25,7 +25,7 @@
- 5000c50015ea71ad
+ 0x5000c50015ea71ad