mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-23 21:15:20 +00:00
qemu: Allow spaces in disk serial
https://bugzilla.redhat.com/show_bug.cgi?id=1195660 There's been a bug report appearing on the qemu-devel list, that libvirt is unable to pass spaces in disk serial number [1]. Not only our RNG schema forbids that, the code is not prepared either. However, with a bit of escaping (if needed) we can allow spaces there. 1: https://lists.gnu.org/archive/html/qemu-devel/2015-02/msg04041.html Signed-off-by: Michal Privoznik <mprivozn@redhat.com> (cherry picked from commit 5aee81a0cb60308b8614ee37c0b69c1dde1f00d8)
This commit is contained in:
parent
6ae19e709e
commit
61ab292139
@ -5089,7 +5089,7 @@
|
|||||||
</define>
|
</define>
|
||||||
<define name="diskSerial">
|
<define name="diskSerial">
|
||||||
<data type="string">
|
<data type="string">
|
||||||
<param name="pattern">[A-Za-z0-9_\.\+\-]+</param>
|
<param name="pattern">[A-Za-z0-9_\.\+\- ]+</param>
|
||||||
</data>
|
</data>
|
||||||
</define>
|
</define>
|
||||||
<define name="bridgeMode">
|
<define name="bridgeMode">
|
||||||
|
@ -2630,7 +2630,7 @@ qemuBuildIoEventFdStr(virBufferPtr buf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define QEMU_SERIAL_PARAM_ACCEPTED_CHARS \
|
#define QEMU_SERIAL_PARAM_ACCEPTED_CHARS \
|
||||||
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_"
|
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_ "
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuSafeSerialParamValue(const char *value)
|
qemuSafeSerialParamValue(const char *value)
|
||||||
@ -3613,7 +3613,8 @@ qemuBuildDriveStr(virConnectPtr conn,
|
|||||||
virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_SERIAL)) {
|
virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_SERIAL)) {
|
||||||
if (qemuSafeSerialParamValue(disk->serial) < 0)
|
if (qemuSafeSerialParamValue(disk->serial) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
virBufferAsprintf(&opt, ",serial=%s", disk->serial);
|
virBufferAddLit(&opt, ",serial=");
|
||||||
|
virBufferEscape(&opt, '\\', " ", "%s", disk->serial);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (disk->cachemode) {
|
if (disk->cachemode) {
|
||||||
|
7
tests/qemuxml2argvdata/qemuxml2argv-disk-serial.args
Normal file
7
tests/qemuxml2argvdata/qemuxml2argv-disk-serial.args
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
|
||||||
|
/usr/libexec/qemu-kvm -S -M pc -cpu qemu32 -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-drive,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1 \
|
||||||
|
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
|
27
tests/qemuxml2argvdata/qemuxml2argv-disk-serial.xml
Normal file
27
tests/qemuxml2argvdata/qemuxml2argv-disk-serial.xml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<domain type='kvm'>
|
||||||
|
<name>QEMUGuest1</name>
|
||||||
|
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||||
|
<memory unit='KiB'>219136</memory>
|
||||||
|
<currentMemory unit='KiB'>219136</currentMemory>
|
||||||
|
<vcpu placement='static'>1</vcpu>
|
||||||
|
<os>
|
||||||
|
<type arch='i686' machine='pc'>hvm</type>
|
||||||
|
<boot dev='hd'/>
|
||||||
|
</os>
|
||||||
|
<clock offset='utc'/>
|
||||||
|
<on_poweroff>destroy</on_poweroff>
|
||||||
|
<on_reboot>restart</on_reboot>
|
||||||
|
<on_crash>destroy</on_crash>
|
||||||
|
<devices>
|
||||||
|
<emulator>/usr/libexec/qemu-kvm</emulator>
|
||||||
|
<disk type='block' device='disk'>
|
||||||
|
<source dev='/dev/HostVG/QEMUGuest1'/>
|
||||||
|
<target dev='hda' bus='ide'/>
|
||||||
|
<serial> WD-WMAP9A966149</serial>
|
||||||
|
<address type='drive' controller='0' bus='0' target='0' unit='1'/>
|
||||||
|
</disk>
|
||||||
|
<controller type='usb' index='0'/>
|
||||||
|
<controller type='ide' index='0'/>
|
||||||
|
<memballoon model='virtio'/>
|
||||||
|
</devices>
|
||||||
|
</domain>
|
@ -902,6 +902,11 @@ mymain(void)
|
|||||||
QEMU_CAPS_DEVICE,
|
QEMU_CAPS_DEVICE,
|
||||||
QEMU_CAPS_SCSI_BLOCK, QEMU_CAPS_VIRTIO_BLK_SG_IO,
|
QEMU_CAPS_SCSI_BLOCK, QEMU_CAPS_VIRTIO_BLK_SG_IO,
|
||||||
QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI);
|
QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI);
|
||||||
|
DO_TEST("disk-serial",
|
||||||
|
QEMU_CAPS_KVM,
|
||||||
|
QEMU_CAPS_DEVICE,
|
||||||
|
QEMU_CAPS_DRIVE,
|
||||||
|
QEMU_CAPS_DRIVE_SERIAL);
|
||||||
|
|
||||||
DO_TEST("graphics-vnc", QEMU_CAPS_VNC);
|
DO_TEST("graphics-vnc", QEMU_CAPS_VNC);
|
||||||
DO_TEST("graphics-vnc-socket", QEMU_CAPS_VNC);
|
DO_TEST("graphics-vnc-socket", QEMU_CAPS_VNC);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user