[virt-tools-list] [PATCH v2] virtinst:Add spapr-vio address type for pseries kvm guest
Li Zhang
zhlcindy at linux.vnet.ibm.com
Tue Feb 28 05:11:54 UTC 2012
On 02/27/2012 08:34 AM, Cole Robinson wrote:
> On 02/22/2012 05:13 AM, Li Zhang wrote:
>> For pseries kvm guest, scsi controller can use
>> spapr-vio address type, not only pci address type.
>> So it's necessary to provide such an option to
>> device to configure it.
>>
>> This patch provides spapr-vio address type option for
>> scsi controller. And scsi controller and address type
>> tags are generated in xml file. It is like the following:
>>
>> <controller type='scsi' index='0'>
>> <address type='spapr-vio'/>
>> </controller>
>>
>> Signed-off-by: Li Zhang<zhlcindy at linux.vnet.ibm.com>
>> ---
>> virtinst/Guest.py | 8 ++++++++
>> virtinst/VirtualDevice.py | 6 +++++-
>> 2 files changed, 13 insertions(+), 1 deletions(-)
>>
>> diff --git a/virtinst/Guest.py b/virtinst/Guest.py
>> index b180770..5c61f36 100644
>> --- a/virtinst/Guest.py
>> +++ b/virtinst/Guest.py
>> @@ -870,11 +870,19 @@ class Guest(XMLBuilderDomain.XMLBuilderDomain):
>> finally:
>> if origpath:
>> dev.path = origpath
>> + def get_vscsi_ctrl_xml():
>> + vscsi_class = virtinst.VirtualController.get_class_for_type(
>> + virtinst.VirtualController.CONTROLLER_TYPE_SCSI)
>> + ctrl = vscsi_class(self.conn)
>> + ctrl.set_address("spapr-vio")
>> + return ctrl._get_xml_config()
>>
>> xml = self._get_emulator_xml()
>> # Build XML
>> for dev in devs:
>> xml = _util.xml_append(xml, get_dev_xml(dev))
>> + if dev.address.type == "spapr-vio":
>> + xml = _util.xml_append(xml, get_vscsi_ctrl_xml())
>>
>
> Hmm, does libvirt not handle this? It generally handles adding implicit
> <controller> devices, but maybe that's just a back compat thing.
>
> If not it's okay, just want to make sure this is needed.
Sorry I missed these comments yesterday.
In libvirt, <controller> devices are generated implicitly,
but for spapr-vio, it can't be added. :)
So it is needed to add it.
>
>> return xml
>>
>> diff --git a/virtinst/VirtualDevice.py b/virtinst/VirtualDevice.py
>> index 2234979..660643d 100644
>> --- a/virtinst/VirtualDevice.py
>> +++ b/virtinst/VirtualDevice.py
>> @@ -143,9 +143,11 @@ class VirtualDeviceAddress(XMLBuilderDomain):
>> ADDRESS_TYPE_DRIVE = "drive"
>> ADDRESS_TYPE_VIRTIO_SERIAL = "virtio-serial"
>> ADDRESS_TYPE_CCID = "ccid"
>> + ADDRESS_TYPE_SPAPR_VIO = "spapr-vio"
>>
>> TYPES = [ADDRESS_TYPE_PCI, ADDRESS_TYPE_DRIVE,
>> - ADDRESS_TYPE_VIRTIO_SERIAL, ADDRESS_TYPE_CCID]
>> + ADDRESS_TYPE_VIRTIO_SERIAL, ADDRESS_TYPE_CCID,
>> + ADDRESS_TYPE_SPAPR_VIO]
>>
>> def __init__(self, conn, parsexml=None, parsexmlnode=None, caps=None, addrstr=None):
>> XMLBuilderDomain.__init__(self, conn, parsexml, parsexmlnode,
>> @@ -185,6 +187,8 @@ class VirtualDeviceAddress(XMLBuilderDomain):
>> self.domain = "0"
>> if addrstr.count(":"):
>> self.domain, self.bus = addrstr.split(":", 1)
>> + elif addrstr == "spapr-vio":
>> + self.type = self.ADDRESS_TYPE_SPAPR_VIO
>> else:
>> raise ValueError(_("Could not determine or unsupported format of '%s'") % addrstr)
>> except:
>
> Rest looks okay, but please add a unit test. You can probably just add a new
> device to tests/xmlconfig.py:testManyDevices to make sure that implicit
> controller adding works.
>
> Thanks,
> Cole
>
More information about the virt-tools-list
mailing list