[libvirt] [PATCH] qemu: Allow spaces in disk serial

Eric Blake eblake at redhat.com
Mon Feb 23 22:10:46 UTC 2015


On 02/23/2015 04:39 AM, Michal Privoznik wrote:
> 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 at redhat.com>
> ---
>  docs/schemas/domaincommon.rng                      |  2 +-
>  src/qemu/qemu_command.c                            |  5 ++--
>  .../qemuxml2argvdata/qemuxml2argv-disk-serial.args |  6 +++++
>  .../qemuxml2argvdata/qemuxml2argv-disk-serial.xml  | 27 ++++++++++++++++++++++
>  tests/qemuxml2argvtest.c                           |  5 ++++
>  5 files changed, 42 insertions(+), 3 deletions(-)
>  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-serial.args
>  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-serial.xml
> 

> @@ -3616,7 +3616,8 @@ qemuBuildDriveStr(virConnectPtr conn,
>          virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_SERIAL)) {
>          if (qemuSafeSerialParamValue(disk->serial) < 0)
>              goto error;
> -        virBufferAsprintf(&opt, ",serial=%s", disk->serial);
> +        virBufferAddLit(&opt, ",serial=");
> +        virBufferEscapeShell(&opt, disk->serial);

NACK to this hunk.  We do NOT want shell escaping, because we are NOT
invoking the shell directly.  As proof:

>      }
>  
>      if (disk->cachemode) {
> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-serial.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-serial.args
> new file mode 100644
> index 0000000..8b08cfb
> --- /dev/null
> +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-serial.args
> @@ -0,0 +1,6 @@
> +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'\''' \

your patch is passing the equivalent of serial="'  WD-WMAP9a966149'"
(including the single quotes, which were not present in your XML).  The
log file output will need shell escaping, but we already do that.

Needs a v2.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 604 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150223/956ebc5d/attachment-0001.sig>


More information about the libvir-list mailing list