[libvirt] [PATCH] lxc: fix show the wrong xml when guest start failed

Luyao Huang lhuang at redhat.com
Tue Jan 6 14:31:15 UTC 2015


On 01/06/2015 10:11 PM, Michal Privoznik wrote:
> On 22.12.2014 08:21, Luyao Huang wrote:
>> https://bugzilla.redhat.com/show_bug.cgi?id=1176503
>>
>> When guest start failed, libvirt will keep the current vm->def,
>> this will make a issue that we cannot get a right xml after guest
>> start failed. Pass the newDef to def will make it work well.
>>
>> Signed-off-by: Luyao Huang <lhuang at redhat.com>
>> ---
>>   src/lxc/lxc_process.c | 10 ++++++----
>>   1 file changed, 6 insertions(+), 4 deletions(-)
>>
>> diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
>> index 1c0d4e5..b7171ac 100644
>> --- a/src/lxc/lxc_process.c
>> +++ b/src/lxc/lxc_process.c
>> @@ -1353,10 +1353,6 @@ int virLXCProcessStart(virConnectPtr conn,
>>           VIR_FREE(veths[i]);
>>       }
>>       if (rc != 0) {
>> -        if (vm->newDef) {
>> -            virDomainDefFree(vm->newDef);
>> -            vm->newDef = NULL;
>> -        }
>>           if (priv->monitor) {
>>               virObjectUnref(priv->monitor);
>>               priv->monitor = NULL;
>> @@ -1373,6 +1369,12 @@ int virLXCProcessStart(virConnectPtr conn,
>>               VIR_FREE(vm->def->seclabels[0]->label);
>> VIR_FREE(vm->def->seclabels[0]->imagelabel);
>>           }
>> +        if (vm->newDef) {
>> +            virDomainDefFree(vm->def);
>> +            vm->def = vm->newDef;
>> +            vm->def->id = -1;
>> +            vm->newDef = NULL;
>> +        }
>>       }
>>       for (i = 0; i < nttyFDs; i++)
>>           VIR_FORCE_CLOSE(ttyFDs[i]);
>>
>
> Shouldn't this be in virLXCProcessStop() like it is in other drivers, 
> e.g. qemu?
>
These code is already in virLXCProcessStop(), but if we meet some issue 
and do 'goto cleanup' in
virLXCProcessStart, we won't call virLXCProcessStop.

Maybe we can merge what we do in cleanup to virLXCProcessStop() ?
I think use this way to fix this issue maybe toodangerous for me (maybe 
will cause some
other issue when rework the cleanup and virLXCProcessStop), because i am 
not familiar with LXC.
So i use this easy way to fix this issue.

Thanks for your review :)
> Michal
Luyao




More information about the libvir-list mailing list