diff --git a/docs/schemas/basictypes.rng b/docs/schemas/basictypes.rng index adaedd8794a1a1547ba1d292fe43b0f6b39fe26d..34c22543306321b2062f89180f4059fa513f563d 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 63b9350c2b0502c44d61319262fe9692fec70971..009d42d452688c118a1a0881ef37bbe640c68aed 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 0e4063b2a70eb31aac6a582b69a3e5475d849c9a..68903628903494258ea964a28c03eba32e25c8e1 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 1633d29c38acc45a9bfb766014161d18a6211e47..3b9693cc6d6674f275df5c0828c1f8ea4fd35ab7 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 0393640cbd3ed396d573b3621fa8f8485e4a64d8..0dd2aa9d833efaae7b95e8f749ead611153adc3d 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 dc355484bd5641e316e35c68586e889c58c7bb03..caf957b66b0cd5989436b156a109ac2905b26cd1 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