<div dir="ltr">Hi Cole,<div><br></div><div>Thanks for the comments.<br><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Nov 22, 2013 at 1:54 AM, Cole Robinson <span dir="ltr"><<a href="mailto:crobinso@redhat.com" target="_blank">crobinso@redhat.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On 11/21/2013 03:06 PM, Shivaprasad G Bhat wrote:<br>
> From: Shivaprasad G Bhat <<a href="mailto:shivaprasadbhat@gmail.com">shivaprasadbhat@gmail.com</a>><br>
><br>
> The bus type IDE being enum Zero, the bus type on pseries system appears as IDE for all the -hda/-cdrom and for disk drives with if="none" type. Pseries platform needs this to appear as SCSI instead of IDE. The ide being not supported, the explicit requests for ide devices will return an error.<br>
><br>
> Signed-off-by: Shivaprasad G Bhat <<a href="mailto:sbhat@linux.vnet.ibm.com">sbhat@linux.vnet.ibm.com</a>><br>
> ---<br>
> src/qemu/qemu_command.c | 66 +++++++++++++++++++-<br>
> tests/qemuargv2xmltest.c | 1<br>
> .../qemuxml2argv-pseries-disk.args | 5 ++<br>
> .../qemuxml2argvdata/qemuxml2argv-pseries-disk.xml | 40 ++++++++++++<br>
> 4 files changed, 108 insertions(+), 4 deletions(-)<br>
> create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.args<br>
> create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.xml<br>
><br>
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c<br>
> index 8dc7e43..21b5108 100644<br>
> --- a/src/qemu/qemu_command.c<br>
> +++ b/src/qemu/qemu_command.c<br>
> @@ -10032,6 +10032,7 @@ error:<br>
> static virDomainDiskDefPtr<br>
> qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt,<br>
> const char *val,<br>
> + virDomainDefPtr dom,<br>
> int nvirtiodisk,<br>
> bool old_style_ceph_args)<br>
> {<br>
> @@ -10055,7 +10056,11 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt,<br>
> if (VIR_ALLOC(def) < 0)<br>
> goto cleanup;<br>
><br>
> - def->bus = VIR_DOMAIN_DISK_BUS_IDE;<br>
> + if (((dom->os.arch == VIR_ARCH_PPC64) &&<br>
> + dom->os.machine && STREQ(dom->os.machine, "pseries")))<br>
> + def->bus = VIR_DOMAIN_DISK_BUS_SCSI;<br>
> + else<br>
> + def->bus = VIR_DOMAIN_DISK_BUS_IDE;<br>
> def->device = VIR_DOMAIN_DISK_DEVICE_DISK;<br>
> def->type = VIR_DOMAIN_DISK_TYPE_FILE;<br>
><br>
> @@ -10140,9 +10145,15 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt,<br>
> def->type = VIR_DOMAIN_DISK_TYPE_FILE;<br>
> }<br>
> } else if (STREQ(keywords[i], "if")) {<br>
> - if (STREQ(values[i], "ide"))<br>
> + if (STREQ(values[i], "ide")) {<br>
> def->bus = VIR_DOMAIN_DISK_BUS_IDE;<br>
> - else if (STREQ(values[i], "scsi"))<br>
> + if (((dom->os.arch == VIR_ARCH_PPC64) &&<br>
> + dom->os.machine && STREQ(dom->os.machine, "pseries"))) {<br>
> + virReportError(VIR_ERR_INTERNAL_ERROR,<br>
> + _("pseries systems do not support ide devices '%s'"), val);<br>
> + goto error;<br>
> + }<br>
> + } else if (STREQ(values[i], "scsi"))<br>
> def->bus = VIR_DOMAIN_DISK_BUS_SCSI;<br>
> else if (STREQ(values[i], "virtio"))<br>
> def->bus = VIR_DOMAIN_DISK_BUS_VIRTIO;<br>
> @@ -11368,6 +11379,9 @@ qemuParseCommandLine(virCapsPtr qemuCaps,<br>
> disk->type = VIR_DOMAIN_DISK_TYPE_FILE;<br>
> if (STREQ(arg, "-cdrom")) {<br>
> disk->device = VIR_DOMAIN_DISK_DEVICE_CDROM;<br>
> + if (((def->os.arch == VIR_ARCH_PPC64) &&<br>
> + def->os.machine && STREQ(def->os.machine, "pseries")))<br>
> + disk->bus = VIR_DOMAIN_DISK_BUS_SCSI;<br>
> if (VIR_STRDUP(disk->dst, "hdc") < 0)<br>
> goto error;<br>
> disk->readonly = true;<br>
> @@ -11381,6 +11395,9 @@ qemuParseCommandLine(virCapsPtr qemuCaps,<br>
> disk->bus = VIR_DOMAIN_DISK_BUS_IDE;<br>
> else<br>
> disk->bus = VIR_DOMAIN_DISK_BUS_SCSI;<br>
> + if (((def->os.arch == VIR_ARCH_PPC64) &&<br>
> + def->os.machine && STREQ(def->os.machine, "pseries")))<br>
> + disk->bus = VIR_DOMAIN_DISK_BUS_SCSI;<br>
> }<br>
> if (VIR_STRDUP(disk->dst, arg + 1) < 0)<br>
> goto error;<br>
> @@ -11672,7 +11689,7 @@ qemuParseCommandLine(virCapsPtr qemuCaps,<br>
> }<br>
> } else if (STREQ(arg, "-drive")) {<br>
> WANT_VALUE();<br>
> - if (!(disk = qemuParseCommandLineDisk(xmlopt, val,<br>
> + if (!(disk = qemuParseCommandLineDisk(xmlopt, val, def,<br>
> nvirtiodisk,<br>
> ceph_args != NULL)))<br>
> goto error;<br>
> @@ -11858,6 +11875,47 @@ qemuParseCommandLine(virCapsPtr qemuCaps,<br>
> }<br>
> } else if (STREQ(arg, "-S")) {<br>
> /* ignore, always added by libvirt */<br>
> + } else if (STREQ(arg, "-device")) {<br>
> + /* something we can't fully parse. Check if supported and<br>
> + * add it to the qemu namespace<br>
> + * cmdline/environment advanced options and hope for the best<br>
> + */<br>
> + bool unsupported = false;<br>
> + WANT_VALUE()<br>
> +<br>
> + if ((def->os.arch == VIR_ARCH_PPC64) &&<br>
> + def->os.machine && STREQ(def->os.machine, "pseries")) {<br>
> + int nkws;<br>
> + char **kws;<br>
> + char **vals;<br>
> + size_t j;<br>
> +<br>
> + if (!qemuParseKeywords(val, &kws, &vals, &nkws, 1)) {<br>
> + for (j = 0; j < nkws; j++) {<br>
> + if (STREQLEN(kws[j], "ide", 3) ||<br>
> + (STREQ(kws[j], "if") && vals[j] &&<br>
> + STREQ(vals[j], "ide"))) {<br>
> + virReportError(VIR_ERR_INTERNAL_ERROR,<br>
> + _("pseries systems do not support ide devices '%s'"), val);<br>
> + unsupported = true;<br>
> + break;<br>
> + }<br>
> + }<br>
> + for (j = 0; j < nkws; j++) {<br>
> + VIR_FREE(kws[j]);<br>
> + VIR_FREE(vals[j]);<br>
> + }<br>
> + VIR_FREE(kws);<br>
> + VIR_FREE(vals);<br>
> + }<br>
> + }<br>
> +<br>
> + if (unsupported || VIR_REALLOC_N(cmd->args, cmd->num_args+2) < 0)<br>
> + goto error;<br>
> + if (VIR_STRDUP(cmd->args[cmd->num_args++], arg) < 0)<br>
> + goto error;<br>
> + if (VIR_STRDUP(cmd->args[cmd->num_args++], val) < 0)<br>
> + goto error;<br>
<br>
</div></div>This -device handling chunk should at least be a separate patch and have a<br>
test case that exercises it. But I don't know if that's how we want to handle<br>
-device conversions, just turning them into qemu commandline passthrough bits,<br>
but actually learning to parse -device would be a pretty massive undertaking.</blockquote><div> </div><div>I have removed the chunk from v4 and i'll address it separately as suggested. <br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im"><br>
> } else {<br>
> /* something we can't yet parse. Add it to the qemu namespace<br>
> * cmdline/environment advanced options and hope for the best<br>
> diff --git a/tests/qemuargv2xmltest.c b/tests/qemuargv2xmltest.c<br>
> index 6dd8bb0..0bf4c37 100644<br>
> --- a/tests/qemuargv2xmltest.c<br>
> +++ b/tests/qemuargv2xmltest.c<br>
> @@ -249,6 +249,7 @@ mymain(void)<br>
> DO_TEST("hyperv");<br>
><br>
> DO_TEST("pseries-nvram");<br>
> + DO_TEST("pseries-disk");<br>
><br>
> DO_TEST("nosharepages");<br>
><br>
> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.args<br>
> new file mode 100644<br>
> index 0000000..5fc0938<br>
> --- /dev/null<br>
> +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.args<br>
> @@ -0,0 +1,5 @@<br>
> +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \<br>
> +/usr/bin/qemu-system-ppc64 \<br>
> +-S -M pseries -m 512 -smp 1 \<br>
> +-no-acpi -boot c -usb \<br>
> +-boot c -hda /dev/HostVG/QEMUGuest1 -cdrom /root/boot.iso<br>
<br>
</div>Does -hda actually create a scsi disk on pseries? Interesting.<br></blockquote><div> </div><div>Yes. It does. :) </div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div class="h5"><br>
> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.xml<br>
> new file mode 100644<br>
> index 0000000..dbbd6aa<br>
> --- /dev/null<br>
> +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.xml<br>
> @@ -0,0 +1,40 @@<br>
> +<domain type='qemu'><br>
> + <name>QEMUGuest1</name><br>
> + <uuid>87eedafe-eedc-4336-8130-ed9fe5dc90c8</uuid><br>
> + <memory unit='KiB'>524288</memory><br>
> + <currentMemory unit='KiB'>524288</currentMemory><br>
> + <vcpu placement='static'>1</vcpu><br>
> + <os><br>
> + <type arch='ppc64' machine='pseries'>hvm</type><br>
> + <boot dev='hd'/><br>
> + </os><br>
> + <clock offset='utc'/><br>
> + <on_poweroff>destroy</on_poweroff><br>
> + <on_reboot>restart</on_reboot><br>
> + <on_crash>destroy</on_crash><br>
> + <devices><br>
> + <emulator>/usr/bin/qemu-system-ppc64</emulator><br>
> + <disk type='block' device='disk'><br>
> + <driver name='qemu' type='raw'/><br>
> + <source dev='/dev/HostVG/QEMUGuest1'/><br>
> + <target dev='hda' bus='scsi'/><br>
> + <address type='drive' controller='0' bus='0' target='0' unit='0'/><br>
> + </disk><br>
> + <disk type='file' device='cdrom'><br>
> + <driver name='qemu' type='raw'/><br>
> + <source file='/root/boot.iso'/><br>
> + <target dev='hdc' bus='scsi'/><br>
> + <readonly/><br>
> + <address type='drive' controller='0' bus='0' target='0' unit='2'/><br>
> + </disk><br>
> + <controller type='usb' index='0'/><br>
> + <controller type='scsi' index='0'/><br>
> + <controller type='pci' index='0' model='pci-root'/><br>
> + <input type='mouse' bus='ps2'/><br>
> + <graphics type='sdl'/><br>
> + <video><br>
> + <model type='cirrus' vram='9216' heads='1'/><br>
> + </video><br>
> + <memballoon model='virtio'/><br>
> + </devices><br>
> +</domain><br>
><br>
<br>
</div></div>Does this XML actually work if you 'virsh define' it? I'd think libvirt would<br>
complain about target='hda' with bus='scsi' but I didn't confirm.<br></blockquote><div> </div><div>It works. I see that selinux option is not added by default to the xml. Otherwise the xml works taking hda to scsiI. </div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="HOEnZb"><font color="#888888"><br>
- Cole<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
--<br>
libvir-list mailing list<br>
<a href="mailto:libvir-list@redhat.com">libvir-list@redhat.com</a><br>
<a href="https://www.redhat.com/mailman/listinfo/libvir-list" target="_blank">https://www.redhat.com/mailman/listinfo/libvir-list</a><br>
</div></div></blockquote></div><br></div></div></div>