[virt-tools-list] [virt-manager] Reset Guest.domain to None on domain creation error

Cole Robinson crobinso at redhat.com
Thu Apr 27 19:10:41 UTC 2017


On 04/16/2017 01:54 PM, Cole Robinson wrote:
> On 04/14/2017 01:45 AM, Xiaodai Wang wrote:
>>
>>>
>>> ----- Original Message -----
>>>> From: "Cole Robinson" <crobinso at redhat.com>
>>>> To: "Xiaodai Wang" <xiaodwan at redhat.com>, "Christophe Fergeau"
>>>> <cfergeau at redhat.com>
>>>> Cc: virt-tools-list at redhat.com
>>>> Sent: Friday, April 14, 2017 2:23:55 AM
>>>> Subject: Re: [virt-tools-list] [virt-manager] Reset Guest.domain to None on
>>>> domain creation error
>>>>
>>>> On 04/13/2017 07:04 AM, Xiaodai Wang wrote:
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> ----- Original Message -----
>>>>>> From: "Christophe Fergeau" <cfergeau at redhat.com>
>>>>>> To: virt-tools-list at redhat.com
>>>>>> Sent: Thursday, April 13, 2017 5:18:46 PM
>>>>>> Subject: [virt-tools-list] [virt-manager] Reset Guest.domain to None on
>>>>>> 	domain creation error
>>>>>>
>>>>>> When an error occurs when the VM creation wizard tries to start the VM,
>>>>>> it's then not possible to press again the "Finish" button to try again
>>>>>> to start it, as this errors out with:
>>>>>>
>>>>>> Traceback (most recent call last):
>>>>>>   File "/home/teuf/redhat/virt/virt-manager/virtManager/asyncjob.py",
>>>>>>   line
>>>>>>   88, in cb_wrapper
>>>>>>     callback(asyncjob, *args, **kwargs)
>>>>>>   File "/home/teuf/redhat/virt/virt-manager/virtManager/create.py", line
>>>>>>   2341, in _do_async_install
>>>>>>     guest.start_install(meter=meter)
>>>>>>   File "/home/teuf/redhat/virt/virt-manager/virtinst/guest.py", line
>>>>>>   457,
>>>>>>   in
>>>>>>   start_install
>>>>>>     raise RuntimeError(_("Domain has already been started!"))
>>>>>> RuntimeError: Domain has already been started!
>>>>>>
>>>>>> This is caused by code introduced in commit fc6778 which does not reset
>>>>>> self.domain to None when an exception is caught.
>>>>>>
>>>>>> Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>
>>>>>> ---
>>>>>>  virtinst/guest.py | 1 +
>>>>>>  1 file changed, 1 insertion(+)
>>>>>>
>>>>>> diff --git a/virtinst/guest.py b/virtinst/guest.py
>>>>>> index c8c3d14..3997519 100644
>>>>>> --- a/virtinst/guest.py
>>>>>> +++ b/virtinst/guest.py
>>>>>> @@ -408,6 +408,7 @@ class Guest(XMLBuilder):
>>>>>>                      exc_info = sys.exc_info()
>>>>>>                      try:
>>>>>>                          self.domain.undefine()
>>>>>> +                        self.domain = None
>>>>>
>>>>>
>>>>> This will still have other problems. Since the guest has already been
>>>>> created, if you begin installation again,
>>>>> some conflict like "The Mac address 'xxx' is in use by another virtual
>>>>> machine" will occur.
>>>>
>>>> This isn't correct, the case Christophe is talking about leaves the guest
>>>> 'undefined' afterwards, so there won't be any MAC collision
>>>
>>> In my testing (did as bz 1441902), undefine() always fail at here (don't know
>>> why) and the guest will not be removed.
>>> So the self.domain=None will not be ran and the problem is still there.
>>
> 
> Further patches I added to virt-manager.git should fix this issue, see commit
> 93085d2b9d4a3dd6cbb9edfeae9b6cefee9419c1
> 
>> undefine() fail because "libvirtError: Requested operation is not valid: cannot
>> delete inactive domain with nvram".
> 
> Indeed, that's a virtinst bug, we need to be passing the UNDEFINE_NVRAM flag,
> and only for drivers that support it :/
> 

Fixed upstream now:

commit 8181e8609867fe6ed101e48212d42a1c38373539
Author: Cole Robinson <crobinso at redhat.com>
Date:   Thu Apr 27 13:11:13 2017 -0400

    guest: Only use define+start logic for vz

    Handling this for qemu, which may need UNDEFINE_NVRAM flags to do
    the cleanup, is a pain, so move this logic to only apply to vz
    driver which doesn't support createXML

    Mentioned on list:
https://www.redhat.com/archives/virt-tools-list/2017-April/msg00037.html


- Cole




More information about the virt-tools-list mailing list