Re: [PATCH v3 1/2] Optimize machine option to set more options with it

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

 



On 04/02/2013 09:50 PM, Li Zhang wrote:
> On 2013年04月02日 20:52, Eric Blake wrote:
>> On 04/02/2013 04:05 AM, Daniel P. Berrange wrote:
>>> On Fri, Mar 29, 2013 at 01:22:46PM +0800, Li Zhang wrote:
>>>> From: Li Zhang <zhlcindy@xxxxxxxxxxxxxxxxxx>
>>>>
>>>> Currently, -machine option is used only when dump-guest-core is set.
>>>>
>>>> To use options defined in machine option for newer version of QEMU,
>>>> it needs to use -machine xxx, and to be compatible with older version
>>>>   -M, this patch addes QEMU_CAPS_MACHINE_OPT capability for newer
>> s/addes/adds/
>>
>>>> version which supports -machine option.
>>>>
>>> ACK
>> Pushed, after making some fixes (don't have two spaces in the error
>> message, smaller scope for the buffer, use faster buffer functions, and
>> report an error if dump_guest_core is present with the -M form where it
>> is not supported):
> Thanks a lot. :)
>>
>> diff --git i/src/qemu/qemu_command.c w/src/qemu/qemu_command.c
>> index 14be49f..a6d011e 100644
>> --- i/src/qemu/qemu_command.c
>> +++ w/src/qemu/qemu_command.c
>> @@ -5200,8 +5200,6 @@ qemuBuildMachineArgStr(virCommandPtr cmd,
>>                          const virDomainDefPtr def,
>>                          virQEMUCapsPtr qemuCaps)
>>   {
>> -    virBuffer buf = VIR_BUFFER_INITIALIZER;
>> -
>>       /* This should *never* be NULL, since we always provide
>>        * a machine in the capabilities data for QEMU. So this
>>        * check is just here as a safety in case the unexpected
>> @@ -5214,16 +5212,23 @@ qemuBuildMachineArgStr(virCommandPtr cmd,
>>            * '-M' to keep the most of the compatibility with older
>> versions.
>>            */
>>           virCommandAddArgList(cmd, "-M", def->os.machine, NULL);
>> +        if (def->mem.dump_core) {
>> +            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
>> +                           _("dump-guest-core is not available "
>> +                             "with this QEMU binary"));
>> +            return -1;
>> +        }
>>       } else {
>> +        virBuffer buf = VIR_BUFFER_INITIALIZER;
>>
>>           virCommandAddArg(cmd, "-machine");
>> -        virBufferAsprintf(&buf, "%s", def->os.machine);
>> +        virBufferAdd(&buf, def->os.machine, -1);
>>
>>           if (def->mem.dump_core) {
>>               if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DUMP_GUEST_CORE)) {
>> -                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
>> -                               "%s", _("dump-guest-core is not
>> available "
>> -                                " with this QEMU binary"));
>> +                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
>> +                               _("dump-guest-core is not available "
>> +                                 "with this QEMU binary"));
>>                   return -1;
>>               }
>>
>> @@ -5231,7 +5236,7 @@ qemuBuildMachineArgStr(virCommandPtr cmd,
>>
>> virDomainMemDumpTypeToString(def->mem.dump_core));
>>           }
>>
>> -        virCommandAddArg(cmd, virBufferContentAndReset(&buf));
>> +        virCommandAddArgBuffer(cmd, &buf);
>>       }
>>

Just ran a make -C tests valgrind and got the following which points
right at this patch:

TEST: qemuxml2argvtest
      ........................................ 40
      ........................................ 80
      ........................................ 120
      ........................................ 160
      ........................................ 200
      ........................................ 240
      ..................................       274 OK
==6299== 1,004 bytes in 1 blocks are definitely lost in loss record 77 of 83
==6299==    at 0x4A0887C: malloc (vg_replace_malloc.c:270)
==6299==    by 0x4A089F0: realloc (vg_replace_malloc.c:662)
==6299==    by 0x4C6B35E: virReallocN (viralloc.c:184)
==6299==    by 0x4C6DD97: virBufferGrow (virbuffer.c:129)
==6299==    by 0x4C6DFC9: virBufferAdd (virbuffer.c:165)
==6299==    by 0x43097A: qemuBuildCommandLine (qemu_command.c:5224)
==6299==    by 0x41E960: testCompareXMLToArgvHelper (qemuxml2argvtest.c:154)
==6299==    by 0x41FF4F: virtTestRun (testutils.c:157)
==6299==    by 0x416C47: mymain (qemuxml2argvtest.c:371)
==6299==    by 0x42058A: virtTestMain (testutils.c:719)
==6299==    by 0x38D6821A04: (below main) (in /usr/lib64/libc-2.16.so)
==6299==


>>       return 0;
>>
> 
> -- 
> libvir-list mailing list
> libvir-list@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/libvir-list

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