Re: [PATCHv2 06/14] Fix vmdef usage while in monitor in qemuDomainHotplugVcpus

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 01/07/2015 10:42 AM, Ján Tomko wrote:
> Exit the monitor right after we've done with it to get
> the virDomainObjPtr lock back, otherwise we might be accessing
> vm->def while it's being cleaned up by qemuProcessStop.
> 
> If the domain crashed while we were in the monitor, exit
> early instead of changing vm->def which is now the persistent
> definition.
> ---
>  src/qemu/qemu_driver.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index f7c9219..1275ba4 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -4367,7 +4367,7 @@ static int qemuDomainHotplugVcpus(virQEMUDriverPtr driver,
>              if (rc == 0)
>                  goto unsupported;
>              if (rc < 0)
> -                goto cleanup;
> +                goto exit_monitor;
>  
>              vcpus++;
>          }
> @@ -4378,7 +4378,7 @@ static int qemuDomainHotplugVcpus(virQEMUDriverPtr driver,
>              if (rc == 0)
>                  goto unsupported;
>              if (rc < 0)
> -                goto cleanup;
> +                goto exit_monitor;
>  
>              vcpus--;
>          }
> @@ -4395,6 +4395,10 @@ static int qemuDomainHotplugVcpus(virQEMUDriverPtr driver,
>       * fatal */
>      if ((ncpupids = qemuMonitorGetCPUInfo(priv->mon, &cpupids)) <= 0) {
>          virResetLastError();
> +        goto exit_monitor;
> +    }
> +    if (qemuDomainObjExitMonitor(driver, vm) < 0) {
> +        ret = -1;
>          goto cleanup;
>      }
>  
> @@ -4515,10 +4519,10 @@ static int qemuDomainHotplugVcpus(virQEMUDriverPtr driver,
>      cpupids = NULL;
>  
>   cleanup:
> -    qemuDomainObjExitMonitor(driver, vm);
> -    vm->def->vcpus = vcpus;
>      VIR_FREE(cpupids);
>      VIR_FREE(mem_mask);
> +    if (virDomainObjIsActive(vm))
> +        vm->def->vcpus = vcpus;
>      virDomainAuditVcpu(vm, oldvcpus, nvcpus, "update", rc == 1);

NOTE: We'll audit regardless of ExitMonitor status here.

ACK in general, but the Audit stuff needs to be handled in the same
manner as other calls.

John
>      if (cgroup_vcpu)
>          virCgroupFree(&cgroup_vcpu);
> @@ -4527,6 +4531,8 @@ static int qemuDomainHotplugVcpus(virQEMUDriverPtr driver,
>   unsupported:
>      virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
>                     _("cannot change vcpu count of this domain"));
> + exit_monitor:
> +    ignore_value(qemuDomainObjExitMonitor(driver, vm));
>      goto cleanup;
>  }
>  
> 

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]