[virt-tools-list] [PATCH v2] virt-clone:update the VNC handling information when cloning

Cole Robinson crobinso at redhat.com
Thu Mar 29 14:03:36 UTC 2012


On 03/29/2012 09:59 AM, Wanlong Gao wrote:
> On 03/29/2012 09:27 PM, Cole Robinson wrote:
> 
>> On 03/27/2012 08:43 PM, Wanlong Gao wrote:
>>> Assume you set port='5900' and no autoport.
>>> Then, copied guest's vnc will have the same port with the orignal.
>>> If one of them started, another can't get vnc.
>>>
>>> So, if you find 'port=xxxx' in the orignal xml, you should modify it as autoport
>>> with some warning. Then, you can run both of guests at once.
>>>
>>> Suggested-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu at jp.fujitsu.com>
>>> Signed-off-by: Wanlong Gao <gaowanlong at cn.fujitsu.com>
>>> ---
>>>  virtinst/CloneManager.py |    5 +++++
>>>  1 file changed, 5 insertions(+)
>>>
>>> diff --git a/virtinst/CloneManager.py b/virtinst/CloneManager.py
>>> index ff3c074..5953b41 100644
>>> --- a/virtinst/CloneManager.py
>>> +++ b/virtinst/CloneManager.py
>>> @@ -441,6 +441,11 @@ class CloneDesign(object):
>>>          self._guest.name = self._clone_name
>>>          self._guest.uuid = self._clone_uuid
>>>          self._clone_mac.reverse()
>>> +        if self._guest.graphics_dev and self._guest.graphics_dev.port and \
>>> +           self._guest.graphics_dev.port != -1:
>>> +            logging.warn(_("Setting the graphics device port to autoport, "
>>> +                           "in order to avoid conflicting."))
>>> +            self._guest.graphics_dev.port = -1
>>>          for iface in self._guest.get_devices("interface"):
>>>              iface.target_dev = None
>>>  
>>
>> This still doesn't handle multiple <graphics> devices. You want to do
>>
>> for dev in guest.get_devices("graphics"):
>>   ...
>>
>> Also, use this diff in the testsuite to actually verify your change:
>>
>> diff --git a/tests/clone-xml/general-cfg-in.xml b/tests/clone-xml/general-cfg-in
>> index 799f81e..b3ab912 100644
>> --- a/tests/clone-xml/general-cfg-in.xml
>> +++ b/tests/clone-xml/general-cfg-in.xml
>> @@ -37,5 +37,6 @@
>>      </interface>
>>      <input type='mouse' bus='ps2'/>
>>      <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1'/>
>> +    <graphics type='vnc' port='5905'/>
>>    </devices>
>>  </domain>
>>
>> You'll also need to edit tests/clone-xml/general-cfg-out.xml for the final output.
> 
> 
> But I saw that the VM doesn't allow muti-graphic device, right?
> 

qemu might not, but some hypervisors allow it, so it's a theoretically
possible situation.

Thanks,
Cole




More information about the virt-tools-list mailing list