提交 575914cf 编写于 作者: E Eric Blake

qemu: avoid adding "" in smbios arguments

The log lists things like -smbios type=1,vendor="Red Hat", which
is great for shell parsing, but not so great when you realize that
execve() then passes those literal "" on as part of the command
line argument, such that qemu sets SMBIOS with extra literal quotes.

The eventual addition of virCommand is needed before we have the API
to shell-quote a string representation of a command line, so that the
log can still be pasted into a shell, but without inserting extra
bytes into the execve() arguments.

* src/qemu/qemu_conf.c (qemuBuildSmbiosBiosStr)
(qemuBuildSmbiosSystemStr): Qemu doesn't like quotes around uuid
arguments, and the remaining quotes are passed literally to
smbios, making <smbios mode='host'/> inaccurate.  Removing the
quotes makes the log harder to parse, but that can be fixed later
with virCommand improvements.
* tests/qemuxml2argvdata/qemuxml2argv-smbios.args: 'Fix' test; it
will need fixing again once virCommand learns how to shell-quote a
potential command line.
上级 8eb236c5
......@@ -3622,16 +3622,16 @@ static char *qemuBuildSmbiosBiosStr(virSysinfoDefPtr def)
/* 0:Vendor */
if (def->bios_vendor)
virBufferVSprintf(&buf, ",vendor=\"%s\"", def->bios_vendor);
virBufferVSprintf(&buf, ",vendor=%s", def->bios_vendor);
/* 0:BIOS Version */
if (def->bios_version)
virBufferVSprintf(&buf, ",version=\"%s\"", def->bios_version);
virBufferVSprintf(&buf, ",version=%s", def->bios_version);
/* 0:BIOS Release Date */
if (def->bios_date)
virBufferVSprintf(&buf, ",date=\"%s\"", def->bios_date);
virBufferVSprintf(&buf, ",date=%s", def->bios_date);
/* 0:System BIOS Major Release and 0:System BIOS Minor Release */
if (def->bios_release)
virBufferVSprintf(&buf, ",release=\"%s\"", def->bios_release);
virBufferVSprintf(&buf, ",release=%s", def->bios_release);
if (virBufferError(&buf)) {
virReportOOMError();
......@@ -3658,23 +3658,23 @@ static char *qemuBuildSmbiosSystemStr(virSysinfoDefPtr def)
/* 1:Manufacturer */
if (def->system_manufacturer)
virBufferVSprintf(&buf, ",manufacturer=\"%s\"",
virBufferVSprintf(&buf, ",manufacturer=%s",
def->system_manufacturer);
/* 1:Product Name */
if (def->system_product)
virBufferVSprintf(&buf, ",product=\"%s\"", def->system_product);
virBufferVSprintf(&buf, ",product=%s", def->system_product);
/* 1:Version */
if (def->system_version)
virBufferVSprintf(&buf, ",version=\"%s\"", def->system_version);
virBufferVSprintf(&buf, ",version=%s", def->system_version);
/* 1:Serial Number */
if (def->system_serial)
virBufferVSprintf(&buf, ",serial=\"%s\"", def->system_serial);
virBufferVSprintf(&buf, ",serial=%s", def->system_serial);
/* 1:UUID */
if (def->system_uuid)
virBufferVSprintf(&buf, ",uuid=\"%s\"", def->system_uuid);
virBufferVSprintf(&buf, ",uuid=%s", def->system_uuid);
/* 1:SKU Number */
if (def->system_sku)
virBufferVSprintf(&buf, ",sku=\"%s\"", def->system_sku);
virBufferVSprintf(&buf, ",sku=%s", def->system_sku);
if (virBufferError(&buf)) {
virReportOOMError();
......
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -smbios type=0,vendor="QEmu/KVM",version="0.13" -smbios type=1,manufacturer="Fedora",product="Virt-Manager",version="0.8.2-3.fc14",serial="32dfcb37-5af1-552b-357c-be8c3aa38310",uuid="c7a5fdbd-edaf-9455-926a-d65c16db1809" -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -smbios type=0,vendor=QEmu/KVM,version=0.13 -smbios type=1,manufacturer=Fedora,product=Virt-Manager,version=0.8.2-3.fc14,serial=32dfcb37-5af1-552b-357c-be8c3aa38310,uuid=c7a5fdbd-edaf-9455-926a-d65c16db1809 -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册