mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-27 19:11:16 +00:00
qemu: Allow the disk wwn to have "0x" prefix
The recent qemu requires "0x" prefix for the disk wwn, this patch changes virValidateWWN to allow the prefix, and prepend "0x" if it's not specified. E.g. qemu-kvm: -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=6000c60016ea71ad: Property 'scsi-hd.wwn' doesn't take value '6000c60016ea71ad' Though it's a qemu regression, but it's nice to allow the prefix, and doesn't hurt for us to always output "0x".
This commit is contained in:
parent
5829054caf
commit
09d2547f96
@ -280,7 +280,7 @@
|
|||||||
|
|
||||||
<define name='wwn'>
|
<define name='wwn'>
|
||||||
<data type='string'>
|
<data type='string'>
|
||||||
<param name='pattern'>[0-9a-fA-F]{16}</param>
|
<param name='pattern'>(0x)?[0-9a-fA-F]{16}</param>
|
||||||
</data>
|
</data>
|
||||||
</define>
|
</define>
|
||||||
|
|
||||||
|
@ -3358,8 +3358,12 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
|
|||||||
disk->blockio.physical_block_size);
|
disk->blockio.physical_block_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (disk->wwn)
|
if (disk->wwn) {
|
||||||
virBufferAsprintf(&opt, ",wwn=%s", disk->wwn);
|
if (STRPREFIX(disk->wwn, "0x"))
|
||||||
|
virBufferAsprintf(&opt, ",wwn=%s", disk->wwn);
|
||||||
|
else
|
||||||
|
virBufferAsprintf(&opt, ",wwn=0x%s", disk->wwn);
|
||||||
|
}
|
||||||
|
|
||||||
if (disk->vendor)
|
if (disk->vendor)
|
||||||
virBufferAsprintf(&opt, ",vendor=%s", disk->vendor);
|
virBufferAsprintf(&opt, ",vendor=%s", disk->vendor);
|
||||||
|
@ -3228,12 +3228,18 @@ bool virIsDevMapperDevice(const char *dev_name ATTRIBUTE_UNUSED)
|
|||||||
bool
|
bool
|
||||||
virValidateWWN(const char *wwn) {
|
virValidateWWN(const char *wwn) {
|
||||||
int i;
|
int i;
|
||||||
|
const char *p = wwn;
|
||||||
|
|
||||||
for (i = 0; wwn[i]; i++)
|
if (STRPREFIX(wwn, "0x")) {
|
||||||
if (!c_isxdigit(wwn[i]))
|
p += 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; p[i]; i++) {
|
||||||
|
if (!c_isxdigit(p[i]))
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (i != 16 || wwn[i]) {
|
if (i != 16 || p[i]) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Malformed wwn: %s"));
|
_("Malformed wwn: %s"));
|
||||||
return false;
|
return false;
|
||||||
|
@ -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 \
|
/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefaults \
|
||||||
-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \
|
-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 \
|
-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
|
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
|
||||||
|
@ -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 \
|
-device lsi,id=scsi1,bus=pci.0,addr=0x4 \
|
||||||
-usb \
|
-usb \
|
||||||
-drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-scsi0-0-1-0 \
|
-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 \
|
-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
|
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
<source dev='/dev/HostVG/QEMUGuest2'/>
|
<source dev='/dev/HostVG/QEMUGuest2'/>
|
||||||
<target dev='sdb' bus='scsi'/>
|
<target dev='sdb' bus='scsi'/>
|
||||||
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
|
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
|
||||||
<wwn>5000c50015ea71ad</wwn>
|
<wwn>0x5000c50015ea71ad</wwn>
|
||||||
</disk>
|
</disk>
|
||||||
<controller type='usb' index='0'/>
|
<controller type='usb' index='0'/>
|
||||||
<controller type='scsi' index='0' model='virtio-scsi'/>
|
<controller type='scsi' index='0' model='virtio-scsi'/>
|
||||||
|
Loading…
Reference in New Issue
Block a user