[libvirt] [PATCH] virsh domxml-from-native to treat SCSI as the bus type for pseries by default

From: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com> The bus type IDE being enum Zero, the bus type on pseries system appears as IDE for all the disk types. Pseries platform needs this to appear as SCSI instead of IDE. Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com> --- src/qemu/qemu_command.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index abb62e9..728409f 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9995,6 +9995,7 @@ error: static virDomainDiskDefPtr qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt, const char *val, + virDomainDefPtr dom, int nvirtiodisk, bool old_style_ceph_args) { @@ -10018,7 +10019,11 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt, if (VIR_ALLOC(def) < 0) goto cleanup; - def->bus = VIR_DOMAIN_DISK_BUS_IDE; + if (((dom->os.arch == VIR_ARCH_PPC64) && + dom->os.machine && STREQ(dom->os.machine, "pseries"))) + def->bus = VIR_DOMAIN_DISK_BUS_SCSI; + else + def->bus = VIR_DOMAIN_DISK_BUS_IDE; def->device = VIR_DOMAIN_DISK_DEVICE_DISK; def->type = VIR_DOMAIN_DISK_TYPE_FILE; @@ -11332,8 +11337,13 @@ qemuParseCommandLine(virCapsPtr qemuCaps, disk->type = VIR_DOMAIN_DISK_TYPE_FILE; if (STREQ(arg, "-cdrom")) { disk->device = VIR_DOMAIN_DISK_DEVICE_CDROM; - if (VIR_STRDUP(disk->dst, "hdc") < 0) - goto error; + if (((def->os.arch == VIR_ARCH_PPC64) && + def->os.machine && STREQ(def->os.machine, "pseries"))) { + disk->bus = VIR_DOMAIN_DISK_BUS_SCSI; + if (VIR_STRDUP(disk->dst, "sdc") < 0) + goto error; + } else if (VIR_STRDUP(disk->dst, "hdc") < 0) + goto error; disk->readonly = true; } else { if (STRPREFIX(arg, "-fd")) { @@ -11345,6 +11355,9 @@ qemuParseCommandLine(virCapsPtr qemuCaps, disk->bus = VIR_DOMAIN_DISK_BUS_IDE; else disk->bus = VIR_DOMAIN_DISK_BUS_SCSI; + if (((def->os.arch == VIR_ARCH_PPC64) && + def->os.machine && STREQ(def->os.machine, "pseries"))) + disk->bus = VIR_DOMAIN_DISK_BUS_SCSI; } if (VIR_STRDUP(disk->dst, arg + 1) < 0) goto error; @@ -11636,7 +11649,7 @@ qemuParseCommandLine(virCapsPtr qemuCaps, } } else if (STREQ(arg, "-drive")) { WANT_VALUE(); - if (!(disk = qemuParseCommandLineDisk(xmlopt, val, + if (!(disk = qemuParseCommandLineDisk(xmlopt, val, def, nvirtiodisk, ceph_args != NULL))) goto error;

On 2013年10月24日 15:07, Shivaprasad G Bhat wrote:
From: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
The bus type IDE being enum Zero, the bus type on pseries system appears as IDE for all the disk types. Pseries platform needs this to appear as SCSI instead of IDE.
Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com> --- src/qemu/qemu_command.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index abb62e9..728409f 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9995,6 +9995,7 @@ error: static virDomainDiskDefPtr qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt, const char *val, + virDomainDefPtr dom, int nvirtiodisk, bool old_style_ceph_args) { @@ -10018,7 +10019,11 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt, if (VIR_ALLOC(def) < 0) goto cleanup;
- def->bus = VIR_DOMAIN_DISK_BUS_IDE; + if (((dom->os.arch == VIR_ARCH_PPC64) && + dom->os.machine && STREQ(dom->os.machine, "pseries"))) + def->bus = VIR_DOMAIN_DISK_BUS_SCSI; + else + def->bus = VIR_DOMAIN_DISK_BUS_IDE; The indent should be 4 spaces. def->device = VIR_DOMAIN_DISK_DEVICE_DISK; def->type = VIR_DOMAIN_DISK_TYPE_FILE;
@@ -11332,8 +11337,13 @@ qemuParseCommandLine(virCapsPtr qemuCaps, disk->type = VIR_DOMAIN_DISK_TYPE_FILE; if (STREQ(arg, "-cdrom")) { disk->device = VIR_DOMAIN_DISK_DEVICE_CDROM; - if (VIR_STRDUP(disk->dst, "hdc") < 0) - goto error; + if (((def->os.arch == VIR_ARCH_PPC64) && + def->os.machine && STREQ(def->os.machine, "pseries"))) { + disk->bus = VIR_DOMAIN_DISK_BUS_SCSI; Please pay attention of the indent. + if (VIR_STRDUP(disk->dst, "sdc") < 0) + goto error; + } else if (VIR_STRDUP(disk->dst, "hdc") < 0) + goto error; disk->readonly = true; } else { if (STRPREFIX(arg, "-fd")) { @@ -11345,6 +11355,9 @@ qemuParseCommandLine(virCapsPtr qemuCaps, disk->bus = VIR_DOMAIN_DISK_BUS_IDE; else disk->bus = VIR_DOMAIN_DISK_BUS_SCSI; + if (((def->os.arch == VIR_ARCH_PPC64) && + def->os.machine && STREQ(def->os.machine, "pseries"))) + disk->bus = VIR_DOMAIN_DISK_BUS_SCSI; Here too. } if (VIR_STRDUP(disk->dst, arg + 1) < 0) goto error; @@ -11636,7 +11649,7 @@ qemuParseCommandLine(virCapsPtr qemuCaps, } } else if (STREQ(arg, "-drive")) { WANT_VALUE(); - if (!(disk = qemuParseCommandLineDisk(xmlopt, val, + if (!(disk = qemuParseCommandLineDisk(xmlopt, val, def, nvirtiodisk, ceph_args != NULL))) goto error;
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

On 10/24/2013 08:07 AM, Shivaprasad G Bhat wrote:
From: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
The bus type IDE being enum Zero, the bus type on pseries system appears as IDE for all the disk types. Pseries platform needs this to appear as SCSI instead of IDE.
Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com> --- src/qemu/qemu_command.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index abb62e9..728409f 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9995,6 +9995,7 @@ error: static virDomainDiskDefPtr qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt, const char *val, + virDomainDefPtr dom,
TAB damage. Please run 'make syntax-check' and fix that.
int nvirtiodisk, bool old_style_ceph_args) { @@ -10018,7 +10019,11 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt, if (VIR_ALLOC(def) < 0) goto cleanup;
- def->bus = VIR_DOMAIN_DISK_BUS_IDE; + if (((dom->os.arch == VIR_ARCH_PPC64) && + dom->os.machine && STREQ(dom->os.machine, "pseries"))) + def->bus = VIR_DOMAIN_DISK_BUS_SCSI; + else + def->bus = VIR_DOMAIN_DISK_BUS_IDE;
I'm wondering if we should reuse our post-XML-parse callbacks here, rather than open-coding a machine check. In other words, since we already have code that knows how to do per-machine fixups to a domain definition, we should be reusing those instead of open-coding duplicate checks. (Actually, domxml-from-native needs a LOT of TLC, there's much more wrong with it, even on non-pseries machines, than what you are trying to patch). -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (3)
-
Eric Blake
-
Li Zhang
-
Shivaprasad G Bhat