[libvirt] [PATCH 3/4] qemu: Don't deny ShutdownVMDaemon for non-running VMs

Cole Robinson crobinso at redhat.com
Tue May 18 16:45:56 UTC 2010


On 05/18/2010 12:27 PM, Eric Blake wrote:
> On 05/17/2010 11:17 AM, Cole Robinson wrote:
>> Clients that require this already seem to do so. Calling this function
>> with pid < 1 also should not cause problems.
>>
>> Signed-off-by: Cole Robinson <crobinso at redhat.com>
>> ---
>>  src/qemu/qemu_driver.c |    7 +++----
>>  1 files changed, 3 insertions(+), 4 deletions(-)
>>
>> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
>> index 61aacfb..d2f1a36 100644
>> --- a/src/qemu/qemu_driver.c
>> +++ b/src/qemu/qemu_driver.c
>> @@ -3608,10 +3608,8 @@ static void qemudShutdownVMDaemon(struct qemud_driver *driver,
>>      virDomainDefPtr def;
>>      int i;
>>  
>> -    if (!virDomainObjIsActive(vm))
>> -        return;
>> -
>> -    VIR_DEBUG("Shutting down VM '%s' migrated=%d", vm->def->name, migrated);
>> +    VIR_DEBUG("Shutting down VM '%s' pid=%d migrated=%d",
>> +              vm->def->name, vm->pid, migrated);
>>  
>>      /* This method is routinely used in clean up paths. Disable error
>>       * reporting so we don't squash a legit error. */
>> @@ -3634,6 +3632,7 @@ static void qemudShutdownVMDaemon(struct qemud_driver *driver,
>>          }
>>      }
>>  
>> +    /* This will safely handle a non-running guest with pid=0 or pid=-1*/
>>      if (virKillProcess(vm->pid, 0) == 0 &&
>>          virKillProcess(vm->pid, SIGTERM) < 0)
>>          virReportSystemError(errno,
> 
> Just comments and a debug statement, so no damage done; and the added
> comments make the code easier to read.
> 

Dropping the virDomainObjIsActive check is functional change. That's the
piece that could cause issues if users depend on it. Doesn't seem to be
the case though.

- Cole




More information about the libvir-list mailing list