Re: [PATCH 4/4] qemu: Switch code to use new agent job APIs

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

 




On 06/08/2018 09:45 AM, Michal Privoznik wrote:
> There are two sets of functions here:
> 1) some functions talk on both monitor and agent monitor,
> 2) some functions only talk on agent monitor.
> 
> For functions from set 1) we need to use
> qemuDomainObjBeginJobWithAgent() and for functions from set 2) we
> need to use qemuDomainObjBeginAgentJob() only.
> 

It seems to me the category for (1) is more - some code makes the
decision whether to use agent or normal code after the point at which we
take the lock so we need to block not only agent, but also normal jobs.


> Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
> ---
>  src/qemu/qemu_driver.c | 91 ++++++++++++++++++++++++++++++++------------------
>  1 file changed, 58 insertions(+), 33 deletions(-)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 28769878cc..bc1368386b 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -1956,6 +1956,7 @@ static int qemuDomainShutdownFlags(virDomainPtr dom, unsigned int flags)
>      bool useAgent = false, agentRequested, acpiRequested;
>      bool isReboot = false;
>      bool agentForced;
> +    bool agentJob = false;
>      int agentFlag = QEMU_AGENT_SHUTDOWN_POWERDOWN;
>  
>      virCheckFlags(VIR_DOMAIN_SHUTDOWN_ACPI_POWER_BTN |
> @@ -1982,9 +1983,14 @@ static int qemuDomainShutdownFlags(virDomainPtr dom, unsigned int flags)
>      if (virDomainShutdownFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
>          goto cleanup;
>  
> -    if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
> +    if ((!useAgent && qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) ||
> +        (useAgent && qemuDomainObjBeginJobWithAgent(driver, vm,
> +                                                    QEMU_JOB_MODIFY,
> +                                                    QEMU_AGENT_JOB_MODIFY) < 0))

I think if you change qemuDomainObjBeginAgentJob to use MODIFY_BLOCK,
then this just becomes a single call...

>          goto cleanup;
>  
> +    agentJob = useAgent;
> +
>      if (virDomainObjGetState(vm, NULL) != VIR_DOMAIN_RUNNING) {
>          virReportError(VIR_ERR_OPERATION_INVALID,
>                         "%s", _("domain is not running"));
> @@ -2028,7 +2034,10 @@ static int qemuDomainShutdownFlags(virDomainPtr dom, unsigned int flags)
>      }
>  
>   endjob:
> -    qemuDomainObjEndJob(driver, vm);
> +    if (agentJob)
> +        qemuDomainObjEndJobWithAgent(driver, vm);
> +    else
> +        qemuDomainObjEndJob(driver, vm);

... and this can be a single EndAgentJob... Given that the existing
EndJobWithAgent does what EndJob does - is there reason to worry about
calling EndJob at all if EndJobWithAgent is called (or whatever that
code becomes).


There'd be similar comments for each JobWithAgent. The consumers of just
the agentJob seem to be fine... it's this combined one that looks odd.

John

[...]

--
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]

  Powered by Linux