qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

hd-geo-test: Clean up use of buf[] in create_qcow2_with_mbr()

valgrind reports write unitialized bytes from buf[]. Clear them.

ASan reports we store to misaligned address in buf[]. Use stl_le_p()
for that.

Cc: Sam Eiderman <shmuel.eiderman@oracle.com>
Cc: John Snow <jsnow@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-id: 20200317092354.31831-1-armbru@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>

authored by

Markus Armbruster and committed by
John Snow
6e9d611a 1a519323

+3 -3
+3 -3
tests/qtest/hd-geo-test.c
··· 421 421 char *raw_path = strdup(template); 422 422 char *qcow2_path = strdup(template); 423 423 char cmd[100 + 2 * PATH_MAX]; 424 - uint8_t buf[512]; 424 + uint8_t buf[512] = {}; 425 425 int i, ret, fd, offset; 426 426 uint64_t qcow2_size = sectors * 512; 427 427 uint8_t status, parttype, head, sector, cyl; ··· 457 457 buf[offset + 0x6] = sector; 458 458 buf[offset + 0x7] = cyl; 459 459 460 - (*(uint32_t *)&buf[offset + 0x8]) = cpu_to_le32(mbr[i].start_sect); 461 - (*(uint32_t *)&buf[offset + 0xc]) = cpu_to_le32(mbr[i].nr_sects); 460 + stl_le_p(&buf[offset + 0x8], mbr[i].start_sect); 461 + stl_le_p(&buf[offset + 0xc], mbr[i].nr_sects); 462 462 463 463 offset += 0x10; 464 464 }