[libvirt] [PATCH 1/3] qemu: implement qemu's dump-guest-memory

Wen Congyang wency at cn.fujitsu.com
Wed May 23 09:17:32 UTC 2012


At 05/23/2012 04:56 PM, Martin Kletzander Wrote:
> On 04/20/2012 09:27 AM, Wen Congyang wrote:
>> dump-guest-memory is a new dump mechanism, and it can work when the
>> guest uses host devices. This patch adds a API to use this new
>> monitor command.
>>
>> ---
>>  src/qemu/qemu_monitor.c      |   38 ++++++++++++++++++++++++++++++++++++++
>>  src/qemu/qemu_monitor.h      |   12 ++++++++++++
>>  src/qemu/qemu_monitor_json.c |   34 ++++++++++++++++++++++++++++++++++
>>  src/qemu/qemu_monitor_json.h |    6 ++++++
>>  4 files changed, 90 insertions(+), 0 deletions(-)
>>
>> diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
>> index 2f66c46..a5d3eec 100644
>> --- a/src/qemu/qemu_monitor.c
>> +++ b/src/qemu/qemu_monitor.c
>> @@ -2018,6 +2018,44 @@ int qemuMonitorMigrateCancel(qemuMonitorPtr mon)
>>      return ret;
>>  }
>>  
>> +int qemuMonitorDumpToFd(qemuMonitorPtr mon,
>> +                        unsigned int flags,
>> +                        int fd,
>> +                        unsigned long long begin,
>> +                        unsigned long long length)
>> +{
>> +    int ret;
>> +    VIR_DEBUG("mon=%p fd=%d flags=%x begin=%llx length=%llx",
>> +              mon, fd, flags, begin, length);
>> +
>> +    if (!mon) {
>> +        qemuReportError(VIR_ERR_INVALID_ARG, "%s",
>> +                        _("monitor must not be NULL"));
>> +        return -1;
>> +    }
>> +
>> +    if (!mon->json) {
>> +        /* dump-guest-memory is supported after qemu-1.0, and we always use json
>> +         * if qemu's version is >= 0.15. So if we use text mode, the qemu is
>> +         * old, and it does not support dump-guest-memory.
>> +         */
>> +        qemuReportError(VIR_ERR_NO_SUPPORT, "%s",
>> +                        _("dump-guest-memory is not supported in text mode"));
>> +        return -1;
>> +    }
> 
> Correct me if I'm wrong, but shouldn't this be rather handled by adding
> it as a qemu capability? Maybe by checking the qemu version in
> qemuCapsComputeCmdFlags()? Or probably even better by checking that
> command in qemuCapsComputeCmdFlags(). That way we can be sure that the
> command is supported.
> 

If mon->json is false, we use the text mode, so the qemu's version is < 0.15.
The dump-guest-memory is supported after qemu-1.0. So we can say that the
qemu does not support dump-guest-memory if mon->json is false.

Thanks
Wen Congyang




More information about the libvir-list mailing list