[Kimchi-devel] [PATCH 2/4] vmiface update support: update model.

Sheldon shaohef at linux.vnet.ibm.com
Wed Apr 23 01:15:16 UTC 2014


On 04/23/2014 12:03 AM, Aline Manera wrote:
> On 04/18/2014 09:46 AM, shaohef at linux.vnet.ibm.com wrote:
>> From: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
>>
>> For network source, change will be on the active VM instance and
>> persisted VM configuration.
>>
>> For model, change will be on the active VM instance only
>>
>> Signed-off-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
>> ---
>> src/kimchi/control/vm/ifaces.py | 1 +
>> src/kimchi/model/vmifaces.py | 22 ++++++++++++++++++++++
>> 2 files changed, 23 insertions(+)
>>
>> diff --git a/src/kimchi/control/vm/ifaces.py 
>> b/src/kimchi/control/vm/ifaces.py
>> index 874ef54..1b5dc36 100644
>> --- a/src/kimchi/control/vm/ifaces.py
>> +++ b/src/kimchi/control/vm/ifaces.py
>> @@ -34,6 +34,7 @@ class VMIfaces(Collection):
>> class VMIface(Resource):
>> def __init__(self, model, vm, ident):
>> super(VMIface, self).__init__(model, ident)
>> + self.update_params = ["model", "network"]
>> self.vm = vm
>> self.ident = ident
>> self.info = {}
>> diff --git a/src/kimchi/model/vmifaces.py b/src/kimchi/model/vmifaces.py
>> index 9bf110e..8a28358 100644
>> --- a/src/kimchi/model/vmifaces.py
>> +++ b/src/kimchi/model/vmifaces.py
>> @@ -129,3 +129,25 @@ class VMIfaceModel(object):
>>
>> dom.detachDeviceFlags(etree.tostring(iface),
>> libvirt.VIR_DOMAIN_AFFECT_CURRENT)
>> +
>> + def update(self, vm, mac, params):
>> + dom = VMModel.get_vm(vm, self.conn)
>> + iface = self._get_vmiface(vm, mac)
>> +
>> + if iface is None:
>> + raise NotFoundError("KCHVMIF0001E", {'name': vm, 'iface': mac})
>> +
>> + # change on the active VM instance and persisted VM configuration.
>> + if iface.attrib['type'] == 'network' and 'network' in params:
>> + iface.source.attrib['network'] = params['network']
>> + xml = etree.tostring(iface)
>> + dom.updateDeviceFlags(xml, flags=libvirt.VIR_DOMAIN_AFFECT_CONFIG +
>> + libvirt.VIR_DOMAIN_AFFECT_CURRENT)
>> +
>
>> + # change on the persisted VM configuration only.
>> + if 'model' in params and dom.isPersistent():
>> + iface.model.attrib["type"] = params['model']
>> + xml = etree.tostring(iface)
>> + dom.updateDeviceFlags(xml, flags=libvirt.VIR_DOMAIN_AFFECT_CONFIG)
>> +
>
> Question: From what I understood this change will only take effect in 
> next boot, right?
> Should we warn user about it?
Yes.
To YuXing:
When user want to update the model, please warn user about it.
>
>> + return mac
>
>
>


-- 
Thanks and best regards!

Sheldon Feng(冯少合)<shaohef at linux.vnet.ibm.com>
IBM Linux Technology Center




More information about the Kimchi-devel mailing list