mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
Allow partial address formatting
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
5fe2d5e977
commit
137134650f
@ -38,6 +38,7 @@
|
|||||||
<driver name='qemu' type='qcow2'/>
|
<driver name='qemu' type='qcow2'/>
|
||||||
<source file='/default-pool/testvol1.img'/>
|
<source file='/default-pool/testvol1.img'/>
|
||||||
<target dev='sdb' bus='scsi'/>
|
<target dev='sdb' bus='scsi'/>
|
||||||
|
<address type='spapr-vio'/>
|
||||||
</disk>
|
</disk>
|
||||||
<controller type='scsi' index='0'>
|
<controller type='scsi' index='0'>
|
||||||
<address type='spapr-vio'/>
|
<address type='spapr-vio'/>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# Base class for all VM devices
|
# Base class for all VM devices
|
||||||
#
|
#
|
||||||
# Copyright 2008 Red Hat, Inc.
|
# Copyright 2008, 2013 Red Hat, Inc.
|
||||||
# Cole Robinson <crobinso@redhat.com>
|
# Cole Robinson <crobinso@redhat.com>
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
@ -267,14 +267,17 @@ class VirtualDeviceAddress(XMLBuilderDomain):
|
|||||||
if not self.type:
|
if not self.type:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def format_props(*args):
|
||||||
|
return "".join([" %s='%s'" % (k, getattr(self, k)) for k in args if getattr(self, k, None) is not None])
|
||||||
|
|
||||||
xml = "<address type='%s'" % self.type
|
xml = "<address type='%s'" % self.type
|
||||||
if self.type == self.ADDRESS_TYPE_PCI:
|
if self.type == self.ADDRESS_TYPE_PCI:
|
||||||
xml += " domain='%s' bus='%s' slot='%s' function='%s'" % (self.domain, self.bus, self.slot, self.function)
|
xml += format_props("domain", "bus", "slot", "function")
|
||||||
elif self.type == self.ADDRESS_TYPE_DRIVE:
|
elif self.type == self.ADDRESS_TYPE_DRIVE:
|
||||||
xml += " controller='%s' bus='%s' unit='%s'" % (self.controller, self.bus, self.unit)
|
xml += format_props("controller", "bus", "unit")
|
||||||
elif self.type == self.ADDRESS_TYPE_VIRTIO_SERIAL:
|
elif self.type == self.ADDRESS_TYPE_VIRTIO_SERIAL:
|
||||||
xml += " controller='%s' bus='%s' port='%s'" % (self.controller, self.bus, self.port)
|
xml += format_props("controller", "bus", "port")
|
||||||
elif self.type == self.ADDRESS_TYPE_CCID:
|
elif self.type == self.ADDRESS_TYPE_CCID:
|
||||||
xml += " controller='%s' slot='%s'" % (self.controller, self.slot)
|
xml += format_props("controller", "slot")
|
||||||
xml += "/>"
|
xml += "/>"
|
||||||
return xml
|
return xml
|
||||||
|
Loading…
Reference in New Issue
Block a user