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

Re: [libvirt] [PATCH v3 5/8] Qemu arbitrary monitor commands.



On Fri, Jul 02, 2010 at 11:18:22AM -0400, Chris Lalancette wrote:
> Implement the qemu driver's virDomainQemuMonitorCommand
> and hook it into the API entry point.
> 
> Changes since v1:
>  - Rename the (external) qemuMonitorCommand to qemuDomainMonitorCommand
>  - Add virCheckFlags to qemuDomainMonitorCommand
> 
> Changes since v2:
>  - Drop ATTRIBUTE_UNUSED from the flags
> 
> Signed-off-by: Chris Lalancette <clalance redhat com>
> ---
>  src/qemu/qemu_driver.c       |   42 +++++++++++++++++++++++++++++++++++++++++-
>  src/qemu/qemu_monitor.c      |   13 +++++++++++++
>  src/qemu/qemu_monitor.h      |    2 ++
>  src/qemu/qemu_monitor_json.c |   28 ++++++++++++++++++++++++++++
>  src/qemu/qemu_monitor_json.h |    4 ++++
>  src/qemu/qemu_monitor_text.c |   21 +++++++++++++++++++++
>  src/qemu/qemu_monitor_text.h |    3 +++
>  7 files changed, 112 insertions(+), 1 deletions(-)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index a495378..e38eba7 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -12443,6 +12443,46 @@ cleanup:
>      return ret;
>  }
>  
> +static int qemuDomainMonitorCommand(virDomainPtr domain, const char *cmd,
> +                                    char **result, unsigned int flags)
> +{
> +    struct qemud_driver *driver = domain->conn->privateData;
> +    virDomainObjPtr vm = NULL;
> +    int ret = -1;
> +    qemuDomainObjPrivatePtr priv;
> +
> +    virCheckFlags(0, -1);
> +
> +    VIR_WARN(_("Qemu monitor command '%s' executed; libvirt results may be unpredictable!"), cmd);

Can we rate-limit this to once per VM, by setting a flag in 'priv' that
is reset when the guest is started. ALso we should include the VM name
in the log message. No need for the 'libvirt results may be unpredictable'
bit I think. 

> +
> +    qemuDriverLock(driver);
> +    vm = virDomainFindByUUID(&driver->domains, domain->uuid);
> +    if (!vm) {
> +        char uuidstr[VIR_UUID_STRING_BUFLEN];
> +        virUUIDFormat(domain->uuid, uuidstr);
> +        qemuReportError(VIR_ERR_NO_DOMAIN,
> +                        _("no domain with matching uuid '%s'"), uuidstr);
> +        goto cleanup;
> +    }
> +
> +    if (!virDomainObjIsActive(vm)) {
> +        qemuReportError(VIR_ERR_OPERATION_INVALID,
> +                        "%s", _("domain is not running"));
> +        goto cleanup;
> +   }
> +
> +    priv = vm->privateData;
> +    qemuDomainObjEnterMonitorWithDriver(driver, vm);
> +    ret = qemuMonitorArbitraryCommand(priv->mon, cmd, result);
> +    qemuDomainObjExitMonitorWithDriver(driver, vm);

Need begin/end job calls too


Daniel
-- 
|: Red Hat, Engineering, London    -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org        -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|


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