Re: [PATCH 05/11] tests: qemuxml2xml: Format status XML header dynamically

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

 



On 07.07.2016 15:41, Peter Krempa wrote:
> Status XML tests were done by prepending a constant string to an
> existing XML. With the planned changes the header will depend on data
> present in the definition rather than just on the data that was parsed.
> 
> The first dynamic element in the header will be the vcpu thread list.
> Reuse and rename qemuXML2XMLPreFormatCallback for gathering the relevant
> data when checking the active XML parsing and formating and pass the
> bitmap to a newly crated header generator.
> ---
>  tests/qemuxml2xmltest.c | 72 +++++++++++++++++++++++++++++++++++++++++--------
>  1 file changed, 61 insertions(+), 11 deletions(-)
> 
> diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
> index ae328c2..a672fbb 100644
> --- a/tests/qemuxml2xmltest.c
> +++ b/tests/qemuxml2xmltest.c
> @@ -33,13 +33,21 @@ struct testInfo {
>      char *outActiveName;
>      char *outInactiveName;
> 
> +    virBitmapPtr activeVcpus;
> +
>      virQEMUCapsPtr qemuCaps;
>  };
> 
>  static int
> -qemuXML2XMLPreFormatCallback(virDomainDefPtr def ATTRIBUTE_UNUSED,
> -                             const void *opaque ATTRIBUTE_UNUSED)
> +qemuXML2XMLActivePreFormatCallback(virDomainDefPtr def,
> +                                   const void *opaque)
>  {
> +    struct testInfo *info = (struct testInfo *) opaque;
> +
> +    /* store vCPU bitmap so that the status XML can be created faithfully */
> +    if (!info->activeVcpus)
> +        info->activeVcpus = virDomainDefGetOnlineVcpumap(def);

This won't fly, @info is never cleared, in particular, its @activeVcpus is never set so it will contain some garbage that's on the stack when we get here:

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff1d76824 in virBitmapNextSetBit (bitmap=0x432bc0 <_start>, pos=0) at util/virbitmap.c:930
930         bits = bitmap->map[nl] & ~((1UL << nb) - 1);
(gdb) bt
#0  0x00007ffff1d76824 in virBitmapNextSetBit (bitmap=0x432bc0 <_start>, pos=0) at util/virbitmap.c:930
#1  0x0000000000432e1e in testGetStatuXMLPrefixVcpus (buf=0x7fffffffd560, data=0x7fffffffd680) at qemuxml2xmltest.c:115
#2  0x0000000000432ecb in testGetStatusXMLPrefix (data=0x7fffffffd680) at qemuxml2xmltest.c:131
#3  0x0000000000433003 in testCompareStatusXMLToXMLFiles (opaque=0x7fffffffd680) at qemuxml2xmltest.c:160
#4  0x0000000000447a52 in virTestRun (title=0x55d07e "QEMU XML-2-XML-status minimal", body=0x432f14 <testCompareStatusXMLToXMLFiles>, data=0x7fffffffd680) at testutils.c:179
#5  0x000000000043375f in mymain () at qemuxml2xmltest.c:360
#6  0x0000000000449447 in virTestMain (argc=1, argv=0x7fffffffd8e8, func=0x43361c <mymain>) at testutils.c:969
#7  0x0000000000446973 in main (argc=1, argv=0x7fffffffd8e8) at qemuxml2xmltest.c:891


ACK with this squashed in:

diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index a672fbb..eb392f4 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -311,6 +311,8 @@ mymain(void)
     struct testInfo info;
     virQEMUDriverConfigPtr cfg = NULL;
 
+    memset(&info, 0, sizeof(info));
+
     if (qemuTestDriverInit(&driver) < 0)
         return EXIT_FAILURE;
 

Michal

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